aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-02-16 14:43:03 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-24 04:51:31 +0100
commitb855240b782395f94315f43ea3e7e182299fac48 (patch)
treebc594c04449be8cd14cd0ab0bb72dafc2be0ffb2 /tests/auto
parent6a42a6e0a9a1abdda0d07a5a20b4ac7e45348684 (diff)
Rename QDeclarative symbols to QQuick and QQml
Symbols beginning with QDeclarative are already exported by the quick1 module. Users can apply the bin/rename-qtdeclarative-symbols.sh script to modify client code using the previous names of the renamed symbols. Task-number: QTBUG-23737 Change-Id: Ifaa482663767634931e8711a8e9bf6e404859e66 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/auto.pro4
-rw-r--r--tests/auto/compilerwarnings/data/test_cpp.txt2
-rw-r--r--tests/auto/declarative/animation/qabstractanimationjob/qabstractanimationjob.pro5
-rw-r--r--tests/auto/declarative/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp229
-rw-r--r--tests/auto/declarative/animation/qanimationgroupjob/qanimationgroupjob.pro5
-rw-r--r--tests/auto/declarative/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp310
-rw-r--r--tests/auto/declarative/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro5
-rw-r--r--tests/auto/declarative/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp931
-rw-r--r--tests/auto/declarative/animation/qpauseanimationjob/qpauseanimationjob.pro5
-rw-r--r--tests/auto/declarative/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp470
-rw-r--r--tests/auto/declarative/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro5
-rw-r--r--tests/auto/declarative/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp1617
-rw-r--r--tests/auto/declarative/debugger/debugger.pro16
-rw-r--r--tests/auto/declarative/debugger/qdebugmessageservice/qdebugmessageservice.pro21
-rw-r--r--tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp242
-rw-r--r--tests/auto/declarative/debugger/qdeclarativedebugclient/qdeclarativedebugclient.pro11
-rw-r--r--tests/auto/declarative/debugger/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp197
-rw-r--r--tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro29
-rw-r--r--tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp1790
-rw-r--r--tests/auto/declarative/debugger/qdeclarativedebugservice/qdeclarativedebugservice.pro11
-rw-r--r--tests/auto/declarative/debugger/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp216
-rw-r--r--tests/auto/declarative/debugger/qdeclarativeenginedebug/qdeclarativeenginedebug.pro11
-rw-r--r--tests/auto/declarative/debugger/qdeclarativeenginedebug/tst_qdeclarativeenginedebug.cpp1235
-rw-r--r--tests/auto/declarative/debugger/qdeclarativeinspector/app/app.pro9
-rw-r--r--tests/auto/declarative/debugger/qdeclarativeinspector/qdeclarativeinspector.pro3
-rw-r--r--tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.cpp186
-rw-r--r--tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.pro12
-rw-r--r--tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro15
-rw-r--r--tests/auto/declarative/debugger/qdeclarativeprofilerservice/tst_qdeclarativeprofilerservice.cpp310
-rw-r--r--tests/auto/declarative/debugger/qpacketprotocol/qpacketprotocol.pro10
-rw-r--r--tests/auto/declarative/debugger/qpacketprotocol/tst_qpacketprotocol.cpp263
-rw-r--r--tests/auto/declarative/debugger/qv8profilerservice/qv8profilerservice.pro16
-rw-r--r--tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp280
-rw-r--r--tests/auto/declarative/debugger/shared/debugutil.cpp190
-rw-r--r--tests/auto/declarative/debugger/shared/debugutil_p.h127
-rw-r--r--tests/auto/declarative/declarative.pro55
-rw-r--r--tests/auto/declarative/parserstress/parserstress.pro12
-rw-r--r--tests/auto/declarative/parserstress/tst_parserstress.cpp154
-rw-r--r--tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro15
-rw-r--r--tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp197
-rw-r--r--tests/auto/declarative/qdeclarativechangeset/qdeclarativechangeset.pro9
-rw-r--r--tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp812
-rw-r--r--tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro15
-rw-r--r--tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp186
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro15
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp292
-rw-r--r--tests/auto/declarative/qdeclarativeconsole/data/tracing.qml56
-rw-r--r--tests/auto/declarative/qdeclarativeconsole/qdeclarativeconsole.pro15
-rw-r--r--tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp170
-rw-r--r--tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro15
-rw-r--r--tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp652
-rw-r--r--tests/auto/declarative/qdeclarativecpputils/qdeclarativecpputils.pro9
-rw-r--r--tests/auto/declarative/qdeclarativecpputils/tst_qdeclarativecpputils.cpp106
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.var.qml23
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.variant.qml23
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro22
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp210
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h1311
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp6062
-rw-r--r--tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro9
-rw-r--r--tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp365
-rw-r--r--tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro15
-rw-r--r--tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp243
-rw-r--r--tests/auto/declarative/qdeclarativeexpression/qdeclarativeexpression.pro15
-rw-r--r--tests/auto/declarative/qdeclarativeexpression/tst_qdeclarativeexpression.cpp121
-rw-r--r--tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro14
-rw-r--r--tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp179
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro9
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp424
-rw-r--r--tests/auto/declarative/qdeclarativeincubator/qdeclarativeincubator.pro18
-rw-r--r--tests/auto/declarative/qdeclarativeincubator/testtypes.cpp137
-rw-r--r--tests/auto/declarative/qdeclarativeincubator/testtypes.h125
-rw-r--r--tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp1030
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro14
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp221
-rw-r--r--tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp678
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro18
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.h823
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp2289
-rw-r--r--tests/auto/declarative/qdeclarativelistcompositor/qdeclarativelistcompositor.pro9
-rw-r--r--tests/auto/declarative/qdeclarativelistcompositor/tst_qdeclarativelistcompositor.cpp1637
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro15
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp1632
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro15
-rw-r--r--tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp570
-rw-r--r--tests/auto/declarative/qdeclarativelocale/qdeclarativelocale.pro15
-rw-r--r--tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp1183
-rw-r--r--tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro7
-rw-r--r--tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp202
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.2.1.pro7
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp84
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.2.pro7
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp84
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp83
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro7
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp73
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/pluginMixed.pro7
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp73
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/pluginVersion.pro7
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp58
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro7
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp83
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro8
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro9
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp353
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro19
-rw-r--r--tests/auto/declarative/qdeclarativeparser/qdeclarativeparser.pro9
-rw-r--r--tests/auto/declarative/qdeclarativeparser/tst_qdeclarativeparser.cpp210
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro15
-rw-r--r--tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp1721
-rw-r--r--tests/auto/declarative/qdeclarativepropertycache/qdeclarativepropertycache.pro8
-rw-r--r--tests/auto/declarative/qdeclarativepropertycache/tst_qdeclarativepropertycache.cpp281
-rw-r--r--tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro9
-rw-r--r--tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp241
-rw-r--r--tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro15
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp732
-rw-r--r--tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro15
-rw-r--r--tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp243
-rw-r--r--tests/auto/declarative/qdeclarativetranslation/qdeclarativetranslation.pro16
-rw-r--r--tests/auto/declarative/qdeclarativetranslation/tst_qdeclarativetranslation.cpp137
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro18
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/testtypes.h219
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp1306
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro15
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp300
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro19
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp1160
-rw-r--r--tests/auto/declarative/qjsengine/qjsengine.pro13
-rw-r--r--tests/auto/declarative/qjsvalue/qjsvalue.pro6
-rw-r--r--tests/auto/declarative/qjsvalueiterator/qjsvalueiterator.pro7
-rw-r--r--tests/auto/declarative/qmlmin/qmlmin.pro9
-rw-r--r--tests/auto/declarative/qmlmin/tst_qmlmin.cpp192
-rwxr-xr-xtests/auto/declarative/runall.sh100
-rw-r--r--tests/auto/declarative/v4/testtypes.cpp49
-rw-r--r--tests/auto/declarative/v4/tst_v4.cpp353
-rw-r--r--tests/auto/declarative/v4/v4.pro17
-rw-r--r--tests/auto/headersclean/headersclean.pro2
-rw-r--r--tests/auto/headersclean/tst_headersclean.cpp2
-rw-r--r--tests/auto/particles/qquickage/qquickage.pro2
-rw-r--r--tests/auto/particles/qquickangleddirection/qquickangleddirection.pro2
-rw-r--r--tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro2
-rw-r--r--tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro2
-rw-r--r--tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro2
-rw-r--r--tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro2
-rw-r--r--tests/auto/particles/qquickfriction/qquickfriction.pro2
-rw-r--r--tests/auto/particles/qquickgravity/qquickgravity.pro2
-rw-r--r--tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro2
-rw-r--r--tests/auto/particles/qquickimageparticle/qquickimageparticle.pro2
-rw-r--r--tests/auto/particles/qquickitemparticle/qquickitemparticle.pro2
-rw-r--r--tests/auto/particles/qquicklineextruder/qquicklineextruder.pro2
-rw-r--r--tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro2
-rw-r--r--tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro2
-rw-r--r--tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro2
-rw-r--r--tests/auto/particles/qquickpointattractor/qquickpointattractor.pro2
-rw-r--r--tests/auto/particles/qquickpointdirection/qquickpointdirection.pro2
-rw-r--r--tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro2
-rw-r--r--tests/auto/particles/qquickspritegoal/qquickspritegoal.pro2
-rw-r--r--tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro2
-rw-r--r--tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro2
-rw-r--r--tests/auto/particles/qquickturbulence/qquickturbulence.pro2
-rw-r--r--tests/auto/particles/qquickwander/qquickwander.pro2
-rw-r--r--tests/auto/qml/animation/animation.pro (renamed from tests/auto/declarative/animation/animation.pro)0
-rw-r--r--tests/auto/qml/animation/qabstractanimationjob/qabstractanimationjob.pro5
-rw-r--r--tests/auto/qml/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp229
-rw-r--r--tests/auto/qml/animation/qanimationgroupjob/qanimationgroupjob.pro5
-rw-r--r--tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp310
-rw-r--r--tests/auto/qml/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro5
-rw-r--r--tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp931
-rw-r--r--tests/auto/qml/animation/qpauseanimationjob/qpauseanimationjob.pro5
-rw-r--r--tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp470
-rw-r--r--tests/auto/qml/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro5
-rw-r--r--tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp1617
-rw-r--r--tests/auto/qml/debugger/debugger.pro16
-rw-r--r--tests/auto/qml/debugger/qdebugmessageservice/data/test.qml (renamed from tests/auto/declarative/debugger/qdebugmessageservice/data/test.qml)0
-rw-r--r--tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro21
-rw-r--r--tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp242
-rw-r--r--tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro10
-rw-r--r--tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp263
-rw-r--r--tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro11
-rw-r--r--tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp197
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/breakpointRelocation.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/changeBreakpoint.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/changeBreakpoint.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/condition.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/condition.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/createComponent.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/createComponent.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/exception.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/exception.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/loadjsfile.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/loadjsfile.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/oncompleted.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/oncompleted.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/stepAction.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/stepAction.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/test.js (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.js)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/test.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/timer.qml (renamed from tests/auto/declarative/debugger/qdeclarativedebugjs/data/timer.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro29
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp1790
-rw-r--r--tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro11
-rw-r--r--tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp216
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebug/qqmlenginedebug.pro11
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebug/tst_qqmlenginedebug.cpp1235
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/app/app.pro9
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/app/main.cpp (renamed from tests/auto/declarative/debugger/qdeclarativeinspector/app/main.cpp)0
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/app/qtquick2.qml (renamed from tests/auto/declarative/debugger/qdeclarativeinspector/app/qtquick2.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro3
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp186
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro12
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/data/exit.qml (renamed from tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/exit.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/data/test.qml (renamed from tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/test.qml)0
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro15
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp310
-rw-r--r--tests/auto/qml/debugger/qv8profilerservice/data/console.qml (renamed from tests/auto/declarative/debugger/qv8profilerservice/data/console.qml)0
-rw-r--r--tests/auto/qml/debugger/qv8profilerservice/data/exit.qml (renamed from tests/auto/declarative/debugger/qv8profilerservice/data/exit.qml)0
-rw-r--r--tests/auto/qml/debugger/qv8profilerservice/data/test.qml (renamed from tests/auto/declarative/debugger/qv8profilerservice/data/test.qml)0
-rw-r--r--tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro16
-rw-r--r--tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp280
-rw-r--r--tests/auto/qml/debugger/shared/debugutil.cpp190
-rw-r--r--tests/auto/qml/debugger/shared/debugutil_p.h127
-rw-r--r--tests/auto/qml/parserstress/parserstress.pro12
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.3.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.4-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Array/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Array/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Boolean/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Boolean/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.1-2.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma/Date/15.9.1.13-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.13-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-10.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-10.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-11.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-11.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-12.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-12.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-13.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-13.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-9.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-9.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.14.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.14.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.15.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.15.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.16.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.16.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.17.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.17.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.18.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.18.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.19.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.19.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.20.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.20.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-10.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-10.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-11.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-11.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-12.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-12.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-13.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-13.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-14.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-14.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-15.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-15.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-16.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-16.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-17.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-17.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-18.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-18.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-9.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-9.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.25-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.25-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.26-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.26-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.27-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.27-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.28-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.28-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.29-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.29-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.3-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.30-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.30-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.31-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.31-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.32-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.32-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.33-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.33-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.34-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.34-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.35-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.35-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.4-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.9.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.9.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Date/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Date/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.1.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.1.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.14-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.14-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-10-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-10-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-11.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-11.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-5-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-5-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-6-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-6-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-7-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-7-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-8-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-8-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-9-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-9-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.3.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.3.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.7-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-02.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.7-02.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.9.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.9.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Expressions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Expressions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/FunctionObjects/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.1.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.1.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/GlobalObject/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/GlobalObject/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-10.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-10.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-11.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-11.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-12.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-12.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-9.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-9.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/LexicalConventions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.4-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.6-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.6-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.7-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.7-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.10.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.10.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.11.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.11.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.12.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.12.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.13.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.13.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.14.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.14.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.15.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.15.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.16.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.16.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.17.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.17.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.18.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.18.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.9.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.9.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Math/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Math/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/NativeObjects/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/NativeObjects/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/NativeObjects/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/NativeObjects/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Number/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Number/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/ObjectObjects/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/shell.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma/README (renamed from tests/auto/declarative/parserstress/tests/ecma/README)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/SourceText/6-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/SourceText/6-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/SourceText/6-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/SourceText/6-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/SourceText/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/SourceText/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/SourceText/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/SourceText/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.10-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.10-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.10.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.10.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-8.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-8.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-9-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-9-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-10.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-10.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-11.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-11.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-12.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-12.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-19.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-19.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-5-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-5-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-6-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-6-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-7-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-7-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-8-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-8-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-9-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-9-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.7-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.7-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.8-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.8-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/12.9-1-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/12.9-1-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Statements/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Statements/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.10-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.10-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-2-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-2-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-3-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-3-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.6-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.6-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.7-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.7-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.9-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.9-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/15.5.5.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/15.5.5.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/String/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/String/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.4-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.5-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.5-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.7.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.8.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.8.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.9-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.9-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/TypeConversion/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/TypeConversion/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Types/8.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Types/8.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Types/8.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Types/8.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Types/8.6.2.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Types/8.6.2.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Types/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Types/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/Types/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/Types/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/10.1.4-9.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.4-9.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/10.1.6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/10.1.8-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.8-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/11.6.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.1.2.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.1.2.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.2.1.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.1.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.2.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.2.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.3.3.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.3.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.4.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.4.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.5.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.4-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.4-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.5-6.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.5-6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.7-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.7-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.1-5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.1-5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.6.4-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.4-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.7.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.7.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.8-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.8-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/15.9.5.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/15.9.5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/8.6.2.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/8.6.2.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/9.9-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/9.9-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/extensions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/extensions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/jsref.js (renamed from tests/auto/declarative/parserstress/tests/ecma/jsref.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma/template.js (renamed from tests/auto/declarative/parserstress/tests/ecma/template.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-005.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-005.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-006.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-006.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-007.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-007.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-008.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-008.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-009.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-009.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-010-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-010-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-011-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-011-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-005.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-005.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-006.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-006.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-007.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-007.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-008.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-008.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-009.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-009.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-010.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-010.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-011.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-011.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-012.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-012.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-013.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-013.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-014.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-014.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-015.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-015.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-016.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-016.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-017.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-017.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-019.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-019.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/function-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/function-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-005.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-005.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-006.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-006.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-007.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-007.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-008.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-008.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-009.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-009.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-010.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-010.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-011.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-011.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-012.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-012.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-013.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-013.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-014.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-014.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-015.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-015.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-016.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-016.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-017.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-017.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-018.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-018.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-019.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-019.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-020.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-020.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-021.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-021.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-022.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-022.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-023.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-023.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-024.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-024.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-025.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-025.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-026.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-026.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-027.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-027.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-028.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-028.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-029.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-029.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-030.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-030.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-031.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-031.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-032.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-032.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-033.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-033.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-034.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-034.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-035.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-035.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-036.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-036.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-037.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-037.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-038.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-038.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-039.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-039.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-040.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-040.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-041.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-041.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-042.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-042.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-047.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-047.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-048.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-048.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-049.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-049.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-050.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-050.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-051.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-051.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-052.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-052.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-053.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-053.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-054.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-054.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-005.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-005.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-006.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-006.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-007.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-007.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-008.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-008.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-009.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-009.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Expressions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Expressions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Expressions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Expressions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/call-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/call-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/shell.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/README (renamed from tests/auto/declarative/parserstress/tests/ecma_2/README)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/constructor-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/constructor-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/function-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/function-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/hex-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/multiline-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/multiline-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/regress-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regress-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/RegExp/unicode-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/RegExp/unicode-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-005.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-005.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-006.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-006.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-007.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-007.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/if-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/if-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/label-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/label-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-005.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-005.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-006.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-006.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-007.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-007.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-008.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-008.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-009.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-009.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-010.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-010.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/try-012.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-012.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/while-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/while-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/while-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/Statements/while-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/match-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/match-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/match-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/match-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/match-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/match-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/match-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/match-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/replace-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/replace-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/split-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/split-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/split-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/split-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/String/split-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/String/split-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/extensions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/browser.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/extensions/constructor-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/constructor-001.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/extensions/function-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/function-001.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-001.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-002.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-003-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-003-n.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-004-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-004-n.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-005-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-005-n.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-006.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-006.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/extensions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/extensions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/instanceof/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/instanceof/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/instanceof/regress-7635.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/instanceof/regress-7635.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/instanceof/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/instanceof/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/jsref.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/jsref.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_2/template.js (renamed from tests/auto/declarative/parserstress/tests/ecma_2/template.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.11-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.11-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.4-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.4-001.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/15.4.5.1-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.5.1-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Array/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Array/regress-101488.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-101488.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Array/regress-130451.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-130451.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-01.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-02.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-02.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-03.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-03.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-04.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-04.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/regress-387501.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-387501.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/regress-421325.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-421325.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Array/regress-430717.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-430717.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Array/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Array/shell.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Date/15.9.1.2-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.1.2-01.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Date/15.9.3.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.3.2-1.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Date/15.9.4.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.4.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.4.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.4.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5-02.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.5-02.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.5.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.6.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.6.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.7.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.7.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Date/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Date/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Date/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/binding-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/binding-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181654.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181654.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181914.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181914.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-58946.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-58946.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-95101.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-95101.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Exceptions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.4-1.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-23346.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/regress-23346.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/shell.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-01.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-02.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-02.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-03.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-03.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.6.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.6.1-1.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.1-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.1-01.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.2-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.2-01.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.3-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.3-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.9.6-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.9.6-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Expressions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Expressions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Expressions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/FunExpr/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-001-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-001-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/FunExpr/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/15.3.4.3-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/15.3.4.3-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/15.3.4.4-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/15.3.4.4-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/arguments-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/arguments-001.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Function/arguments-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/arguments-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/call-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/call-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/regress-131964.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-131964.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/regress-137181.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-137181.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/regress-193555.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-193555.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Function/regress-313570.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-313570.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/regress-49286.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-49286.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/regress-58274.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-58274.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/regress-85880.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-85880.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/regress-94506.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-94506.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/regress-97921.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-97921.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/scope-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/scope-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/scope-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/scope-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Function/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Function/shell.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.2-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.2-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.3-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.3-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.3-02.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.3-02.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.5-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.5-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.6-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.6-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.7-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.7-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.7-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.7-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/browser.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Number/regress-442242-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/regress-442242-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Number/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Number/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/tostring-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/tostring-001.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Object/8.6.1-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.1-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.2.6-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.2.6-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/class-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/class-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/class-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/class-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/class-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/class-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/class-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/class-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/class-005.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/class-005.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Object/regress-361274.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-361274.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Object/regress-385393-07.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-385393-07.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/regress-72773.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-72773.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/regress-79129-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-79129-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Object/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Object/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.13.1-001.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.13.1-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.4.1-001.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.4.1-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Operators/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Operators/browser.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Operators/order-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Operators/order-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Operators/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Operators/shell.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/README (renamed from tests/auto/declarative/parserstress/tests/ecma_3/README)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2-1.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2.12.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2.12.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-100199.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-100199.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-105972.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-105972.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-119909.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-119909.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-122076.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-122076.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-123437.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-123437.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-165353.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-165353.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169497.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169497.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169534.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169534.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-187133.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-187133.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-188206.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-188206.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-191479.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-191479.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-202564.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-202564.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-209067.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-209067.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-209919.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-209919.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-216591.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-216591.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-220367-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-220367-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-223273.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-223273.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-223535.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-223535.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-224676.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-224676.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-225289.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-225289.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-225343.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-225343.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-24712.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-24712.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-285219.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-285219.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-28686.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-28686.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-289669.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-289669.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-307456.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-307456.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-309840.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-309840.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-311414.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-311414.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-312351.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-312351.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-31316.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-31316.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-330684.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-330684.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-334158.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-334158.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-346090.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-346090.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-367888.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-367888.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375642.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375642.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375711.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375711.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-02.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-02.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-03.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-03.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-04.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-04.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57572.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57572.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57631.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57631.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-67773.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-67773.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-72964.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-72964.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-76683.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-76683.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-78156.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-78156.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-85721.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-85721.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-87231.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-87231.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-98306.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-98306.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/RegExp/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/RegExp/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Regress/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Regress/browser.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Regress/regress-385393-04.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-385393-04.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Regress/regress-419152.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-419152.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420087.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-420087.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420610.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-420610.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Regress/regress-441477-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-441477-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Regress/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Regress/shell.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Statements/12.6.3.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/12.6.3.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-121744.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-121744.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-131348.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-131348.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-157509.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-157509.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-194364.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-194364.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-226517.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-226517.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Statements/regress-302439.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-302439.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Statements/regress-324650.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-324650.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-83532-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-83532-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-83532-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-83532-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Statements/switch-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Statements/switch-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.11.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.11.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.14.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.14.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/regress-104375.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/regress-104375.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/regress-189898.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/regress-189898.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/String/regress-304376.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/regress-304376.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/String/regress-313567.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/regress-313567.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/regress-392378.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/regress-83293.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/regress-83293.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/String/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/String/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/browser.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-01.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002-n.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002-n.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-003.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-003.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-004.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-004.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-005.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-005.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/browser.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/10.1.3-2.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/10.1.3-2.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/7.9.1.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/7.9.1.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/extensions/browser.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/browser.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-103087.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-103087.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-188206-01.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-188206-01.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-188206-02.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-188206-02.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-220367-002.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-220367-002.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-228087.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-228087.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/regress-274152.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-274152.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/regress-320854.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-320854.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/regress-327170.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-327170.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/regress-368516.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-368516.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/regress-385393-03.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-385393-03.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/regress-429248.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-429248.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/extensions/regress-430740.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-430740.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/extensions/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/extensions/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/ecma_3/shell.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/shell.js)0
-rwxr-xr-xtests/auto/qml/parserstress/tests/ecma_3/template.js (renamed from tests/auto/declarative/parserstress/tests/ecma_3/template.js)0
-rw-r--r--tests/auto/qml/parserstress/tests/shell.js (renamed from tests/auto/declarative/parserstress/tests/shell.js)0
-rw-r--r--tests/auto/qml/parserstress/tst_parserstress.cpp154
-rw-r--r--tests/auto/qml/qjsengine/qjsengine.pro13
-rw-r--r--tests/auto/qml/qjsengine/script/com/__init__.js (renamed from tests/auto/declarative/qjsengine/script/com/__init__.js)0
-rw-r--r--tests/auto/qml/qjsengine/script/com/trolltech/__init__.js (renamed from tests/auto/declarative/qjsengine/script/com/trolltech/__init__.js)0
-rw-r--r--tests/auto/qml/qjsengine/script/com/trolltech/recursive/__init__.js (renamed from tests/auto/declarative/qjsengine/script/com/trolltech/recursive/__init__.js)0
-rw-r--r--tests/auto/qml/qjsengine/script/com/trolltech/syntaxerror/__init__.js (renamed from tests/auto/declarative/qjsengine/script/com/trolltech/syntaxerror/__init__.js)0
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp (renamed from tests/auto/declarative/qjsengine/tst_qjsengine.cpp)0
-rw-r--r--tests/auto/qml/qjsvalue/qjsvalue.pro6
-rw-r--r--tests/auto/qml/qjsvalue/tst_qjsvalue.cpp (renamed from tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp)0
-rw-r--r--tests/auto/qml/qjsvalue/tst_qjsvalue.h (renamed from tests/auto/declarative/qjsvalue/tst_qjsvalue.h)0
-rw-r--r--tests/auto/qml/qjsvalueiterator/qjsvalueiterator.pro7
-rw-r--r--tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp (renamed from tests/auto/declarative/qjsvalueiterator/tst_qjsvalueiterator.cpp)0
-rw-r--r--tests/auto/qml/qml.pro55
-rw-r--r--tests/auto/qml/qmlmin/qmlmin.pro9
-rw-r--r--tests/auto/qml/qmlmin/tst_qmlmin.cpp192
-rw-r--r--tests/auto/qml/qmlplugindump/qmlplugindump.pro (renamed from tests/auto/declarative/qmlplugindump/qmlplugindump.pro)0
-rw-r--r--tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp (renamed from tests/auto/declarative/qmlplugindump/tst_qmlplugindump.cpp)0
-rw-r--r--tests/auto/qml/qqmlcomponent/data/createObject.qml (renamed from tests/auto/declarative/qdeclarativecomponent/data/createObject.qml)0
-rw-r--r--tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml (renamed from tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml)0
-rw-r--r--tests/auto/qml/qqmlcomponent/data/incubateObject.qml (renamed from tests/auto/declarative/qdeclarativecomponent/data/incubateObject.qml)0
-rw-r--r--tests/auto/qml/qqmlcomponent/qqmlcomponent.pro15
-rw-r--r--tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp186
-rw-r--r--tests/auto/qml/qqmlconsole/data/assert.qml (renamed from tests/auto/declarative/qdeclarativeconsole/data/assert.qml)0
-rw-r--r--tests/auto/qml/qqmlconsole/data/exception.qml (renamed from tests/auto/declarative/qdeclarativeconsole/data/exception.qml)0
-rw-r--r--tests/auto/qml/qqmlconsole/data/logging.qml (renamed from tests/auto/declarative/qdeclarativeconsole/data/logging.qml)0
-rw-r--r--tests/auto/qml/qqmlconsole/data/profiling.qml (renamed from tests/auto/declarative/qdeclarativeconsole/data/profiling.qml)0
-rw-r--r--tests/auto/qml/qqmlconsole/data/tracing.qml56
-rw-r--r--tests/auto/qml/qqmlconsole/qqmlconsole.pro15
-rw-r--r--tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp170
-rw-r--r--tests/auto/qml/qqmlcontext/data/Object_22535.qml (renamed from tests/auto/declarative/qdeclarativecontext/data/Object_22535.qml)0
-rw-r--r--tests/auto/qml/qqmlcontext/data/RefreshExpressionsType.qml (renamed from tests/auto/declarative/qdeclarativecontext/data/RefreshExpressionsType.qml)0
-rw-r--r--tests/auto/qml/qqmlcontext/data/qtbug_22535.qml (renamed from tests/auto/declarative/qdeclarativecontext/data/qtbug_22535.qml)0
-rw-r--r--tests/auto/qml/qqmlcontext/data/refreshExpressions.qml (renamed from tests/auto/declarative/qdeclarativecontext/data/refreshExpressions.qml)0
-rw-r--r--tests/auto/qml/qqmlcontext/data/refreshExpressionsRootContext.qml (renamed from tests/auto/declarative/qdeclarativecontext/data/refreshExpressionsRootContext.qml)0
-rw-r--r--tests/auto/qml/qqmlcontext/qqmlcontext.pro15
-rw-r--r--tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp652
-rw-r--r--tests/auto/qml/qqmlcpputils/qqmlcpputils.pro9
-rw-r--r--tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp106
-rw-r--r--tests/auto/qml/qqmlecmascript/data/AliasBindingsAssignCorrectlyType.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsAssignCorrectlyType.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/ConstantsOverrideBindings.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/ConstantsOverrideBindings.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/CustomObject.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/ElementAssignType.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/ElementAssignType.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/MethodsObject.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/NestedTypeTransientErrors.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/PropertyVarBaseItem.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarBaseItem.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent5.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent5.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/PropertyVarInheritanceComponent.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarInheritanceComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/PropertyVarOwnershipComponent.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarOwnershipComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVar.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceSignalComponentVar.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVariant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceSignalComponentVariant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/ScarceResourceVarComponent.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceVarComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/Scope6Nested.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/Scope6Nested.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/ScopeObject.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/SequenceConversionComponent.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/SequenceConversionComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/SpuriousWarning.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/SpuriousWarning.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/TypeForDynamicCreation.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/TypeForDynamicCreation.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasBindingsAssignCorrectly.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsAssignCorrectly.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasPropertyAndBinding.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasToCompositeElement.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasToCompositeElement.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasreset/AliasPropertyComponent.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/AliasPropertyComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.5.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.error.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignBasicTypes.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignBasicTypes.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.5.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.5.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.6.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.6.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.7.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.7.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/attachedProperty.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/attachedProperty.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/attachedPropertyScope.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/automaticSemicolon.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/automaticSemicolon.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/bindingLoop.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/bindingLoop.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/blank.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/blank.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/booleanConversion.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/booleanConversion.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/bug.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlots.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlots.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/compiled.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/compositePropertyType.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/deferredProperties.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/deferredProperties.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/deferredPropertiesErrors.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/deleteLater.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/deleteLater.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/deleteWhileBindingRunning.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/deleteWhileBindingRunning.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/deletedEngine.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/deletedObject.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/doubleEvaluate.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/doubleEvaluate.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/dynamicCreation.helper.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.helper.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/dynamicCreation.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/dynamicCreationOwnership.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreationOwnership.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/dynamicDeletion.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/dynamicDeletion.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/dynamicString.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/dynamicString.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/elementAssign.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/elementAssign.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/enums.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/enums.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/enums.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/enums.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/eval.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/eval.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/exception.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/exception.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/exceptionClearsOnReeval.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/exceptionClearsOnReeval.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/extensionObjects.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/extensionObjectsPropertyOverride.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/extensionObjectsPropertyOverride.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/forInLoop.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/forInLoop.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/function.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/function.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/functionAssignment.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/functionErrors.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.handle.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.handle.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.object.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.object.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/importScope.1.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/importScope.1.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/importScope.2.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/importScope.2.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/importScope.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/in.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/in.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_callback.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_callback.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_pragma.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_pragma_inner.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_inner.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_pragma_outer.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_outer.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_remote.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_remote.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_remote_missing.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_remote_missing.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_shared.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/include_shared.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/invokableObjectArg.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectArg.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/invokableObjectRet.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectRet.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/js/include2.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/js/include3.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsObject.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleOne.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleOne.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleTwo.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleTwo.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importFive.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importFive.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importFour.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importFour.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importOne.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importOne.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibrary.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibrary.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithImports.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithImports.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importThree.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importThree.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importTwo.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importTwo.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importWithNoImports.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importWithNoImports.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testImport.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImport.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibrary.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibrary.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testImportScoping.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportScoping.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testModuleImport.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testModuleImport.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testScriptImport.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testScriptImport.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/failFive.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFive.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/failFour.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFour.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/failOne.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failOne.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/failThree.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failThree.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/failTwo.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failTwo.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/importOne.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importOne.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/importPragmaLibrary.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importPragmaLibrary.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/importWithImports.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importWithImports.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/testImportPragmaLibrary.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testImportPragmaLibrary.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/testModuleImport.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testModuleImport.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimportfail/testScriptImport.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testScriptImport.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/listAssignment.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/listAssignment.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/listProperties.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/listToVariant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/metaobjectRevision.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/metaobjectRevision2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/metaobjectRevision3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/metaobjectRevision4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/methods.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/methods.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/methods.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/methods.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/methods.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/methods.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/methods.5.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMajorVersionFail.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/moduleApiMajorVersionFail.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMinorVersionFail.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/moduleApiMinorVersionFail.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApi.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApi.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiCaching.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiCaching.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiEnums.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiEnums.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiWriting.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApi.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApi.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiCaching.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApiCaching.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiWriting.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApiWriting.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/multiEngineObject.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/nonExistentAttachedObject.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/nonExistentAttachedObject.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/nonNotifyable.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/nonNotifyable.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/nonscriptable.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/nonscriptable.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/nullObjectBinding.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/numberAssignment.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/objectConversion.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/objectConversion.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/objectName.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/objectName.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/objectsCompareAsEqual.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/objectsPassThroughSignals.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/objectsPassThroughSignals.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/outerBindingOverridesInnerBinding.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/outerBindingOverridesInnerBinding.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/ownership.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyAssignmentErrors.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertySplicing.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertySplicing.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.10.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.10.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.5.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.5.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.6.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.6.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.7.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.7.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.8.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.8.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.9.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.9.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.circular.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.circular.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.circular.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.circular.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.inherit.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.inherit.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVar.reparent.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.reparent.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarCpp.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarCpp.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarImplicitOwnership.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarImplicitOwnership.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.type.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.3.type.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.type1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.type2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qlistqobjectMethods.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qmlToString.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/declarativeToString.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qobjectConnectionListExceptionHandling.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qobjectConnectionListExceptionHandling.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qobjectDerivedArgument.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qobjectDerivedArgument.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_10696.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_11600.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_11600.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_11606.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_20344.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_20344.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_21580.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21580.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_21864.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_21864.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_22464.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22464.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_22679.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22679.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_22843.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_22843.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtbug_9792.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtbug_9792.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/qtcreatorbug_1289.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/readonlyDeclaration.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/readonlyDeclaration.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/realToInt.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/realToInt.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/regExp.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/regExp.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/regExp.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/regExp.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/remote_file.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopy.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopy.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyFromJs.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyFromJs.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.var.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.variant.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportDifferent.var.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportDifferent.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.var.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.variant.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.var.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.variant.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyNoBinding.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyNoBinding.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceDestroyedCopy.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceDestroyedCopy.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunction.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunction.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.var.qml23
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.variant.qml23
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameNoBinding.var.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameNoBinding.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameWithBinding.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameWithBinding.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceObjectGc.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceObjectGc.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceSignal.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceSignal.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.var.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.variant.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestMultiple.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestMultiple.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.var.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestPreserve.var.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.variant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestPreserve.variant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scope.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scope.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scope.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scope.5.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scope.5.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scope.6.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scope.6.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scope.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scope.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.1.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.2.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.5.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.5.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.6.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptConnect.6.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptDisconnect.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptDisconnect.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptDisconnect.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptErrors.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/scriptErrors.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.array.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.error.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.bindings.error.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.bindings.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.copy.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.copy.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.indexes.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.error.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.read.error.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.read.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.threads.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.threads.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.error.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.write.error.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.write.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sharedAttachedObject.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/sharedAttachedObject.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/shutdownErrors.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalAssignment.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalAssignment.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalHandlers.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalHandlers.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalTriggeredBindings.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalWithJSValueInVariant.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalWithJSValueInVariant.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalWithQJSValue.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalWithQJSValue.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalWithUnknownTypes.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/signalWithUnknownTypes.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/strictlyEquals.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/strictlyEquals.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/stringArg.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/stringArg.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/switchStatement.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/switchStatement.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/switchStatement.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/switchStatement.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/switchStatement.5.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.5.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/switchStatement.6.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.6.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/threadScript.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/threadScript.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/transientErrors.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/transientErrors.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/tryStatement.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/tryStatement.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/tryStatement.3.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.3.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/tryStatement.4.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.4.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/typeOf.js (renamed from tests/auto/declarative/qdeclarativeecmascript/data/typeOf.js)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/typeOf.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/typeOf.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/unaryExpression.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/unaryExpression.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/urlListProperty.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/urlListProperty.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/urlProperty.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/urlProperty.2.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.2.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/v8bindingException.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/v8bindingException.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/v8functionException.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/v8functionException.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/valueTypeFunctions.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/valueTypeFunctions.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/variantsAssignedUndefined.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/variantsAssignedUndefined.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/withStatement.1.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/withStatement.1.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/writeAttachedProperty.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/writeAttachedProperty.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/data/writeRemovesBinding.qml (renamed from tests/auto/declarative/qdeclarativeecmascript/data/writeRemovesBinding.qml)0
-rw-r--r--tests/auto/qml/qqmlecmascript/qqmlecmascript.pro22
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.cpp210
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.h1311
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp6062
-rw-r--r--tests/auto/qml/qqmlengine/qqmlengine.pro9
-rw-r--r--tests/auto/qml/qqmlengine/tst_qqmlengine.cpp365
-rw-r--r--tests/auto/qml/qqmlerror/data/test.txt (renamed from tests/auto/declarative/qdeclarativeerror/data/test.txt)0
-rw-r--r--tests/auto/qml/qqmlerror/qqmlerror.pro15
-rw-r--r--tests/auto/qml/qqmlerror/tst_qqmlerror.cpp243
-rw-r--r--tests/auto/qml/qqmlexpression/data/scriptString.qml (renamed from tests/auto/declarative/qdeclarativeexpression/data/scriptString.qml)0
-rw-r--r--tests/auto/qml/qqmlexpression/qqmlexpression.pro15
-rw-r--r--tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp121
-rw-r--r--tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro9
-rw-r--r--tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp424
-rw-r--r--tests/auto/qml/qqmlincubator/data/AsynchronousIfNestedType.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/AsynchronousIfNestedType.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/asynchronousIfNested.1.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.1.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/asynchronousIfNested.2.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.2.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/asynchronousIfNested.3.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.3.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/chainInCompletion.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/chainInCompletion.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/chainedAsynchronousIfNested.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/chainedAsynchronousIfNested.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/clear.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/clear.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/clearDuringCompletion.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/clearDuringCompletion.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/contextDelete.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/contextDelete.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/forceCompletion.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/forceCompletion.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/nestedComponent.js (renamed from tests/auto/declarative/qdeclarativeincubator/data/nestedComponent.js)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/nestedComponent.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/nestedComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/noIncubationController.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/noIncubationController.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/objectDeleted.errors.txt (renamed from tests/auto/declarative/qdeclarativeincubator/data/objectDeleted.errors.txt)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/objectDeleted.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/objectDeleted.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/recursiveClear.1.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/recursiveClear.1.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/recursiveClear.2.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/recursiveClear.2.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/selfDelete.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/selfDelete.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/setInitialState.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/setInitialState.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/statusChanged.nested.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/statusChanged.nested.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/data/statusChanged.qml (renamed from tests/auto/declarative/qdeclarativeincubator/data/statusChanged.qml)0
-rw-r--r--tests/auto/qml/qqmlincubator/qqmlincubator.pro18
-rw-r--r--tests/auto/qml/qqmlincubator/testtypes.cpp137
-rw-r--r--tests/auto/qml/qqmlincubator/testtypes.h125
-rw-r--r--tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp1030
-rw-r--r--tests/auto/qml/qqmlinfo/data/NestedComponent.qml (renamed from tests/auto/declarative/qdeclarativeinfo/data/NestedComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlinfo/data/NestedObject.qml (renamed from tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml)0
-rw-r--r--tests/auto/qml/qqmlinfo/data/nestedQmlObject.qml (renamed from tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml)0
-rw-r--r--tests/auto/qml/qqmlinfo/data/qmlObject.qml (renamed from tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml)0
-rw-r--r--tests/auto/qml/qqmlinfo/qqmlinfo.pro14
-rw-r--r--tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp221
-rw-r--r--tests/auto/qml/qqmlinstruction/qqmlinstruction.pro8
-rw-r--r--tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp678
-rw-r--r--tests/auto/qml/qqmllanguage/data/Alias.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/Alias.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/Alias2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/Alias3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/Alias4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/AliasPropertyChangeSignalsType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/AliasPropertyChangeSignalsType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/ComponentComposite.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/CompositeType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/CompositeType2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/CompositeType2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/CompositeType3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/CompositeType4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/CompositeType4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/DontDoubleCallClassBeginItem.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/DontDoubleCallClassBeginItem.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/DynamicPropertiesNestedType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/HelperAlias.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/I18n.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/I18n.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/I18nType30.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/I18nType30.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/LocalLast.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/LocalLast.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/MyComponent.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/MyComponent.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/MyCompositeValueSource.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/MyCompositeValueSource.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/MyContainerComponent.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/MyContainerComponent.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/NestedAlias.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/NestedComponentRoot.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/NestedComponentRoot.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/NestedErrorsType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/OnCompletedType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/OnDestructionType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/ReadOnlyType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/ReadOnlyType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.10.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.10.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.11.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.11.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/aliasPropertiesAndSignals.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/aliasPropertiesAndSignals.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/allowedRevisionOverloads.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/allowedRevisionOverloads.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignBasicTypes.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignCompositeToType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignLiteralSignalProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignLiteralSignalProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignLiteralToVar.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVar.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignLiteralToVariant.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignObjectToSignal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignObjectToSignal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignObjectToVariant.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignQmlComponent.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignQmlComponent.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignSignal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignSignal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignToNamespace.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignToNamespace.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignTypeExtremes.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignTypeExtremes.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignValueToSignal.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/assignValueToSignal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/attachedProperties.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/autoComponentCreation.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/autoComponentCreation.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/autoNotifyConnection.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.8.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.8.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.9.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.9.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/component.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/component.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/componentCompositeType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/cppnamespace.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/cppnamespace.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/crash2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/crash2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/customOnProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/customParserTypes.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/customVariantTypes.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/customVariantTypes.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/declaredPropertyValues.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/defaultGrouped.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/defaultGrouped.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/defaultPropertyListOrder.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/destroyedSignal.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/destroyedSignal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dontDoubleCallClassBegin.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/doubleSignal.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/doubleSignal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/duplicateIDs.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/duplicateIDs.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicMeta.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicObject.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicProperties.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicPropertiesNested.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/dynamicSignalsAndSlots.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/empty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/empty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/empty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/empty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/emptySignal.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/emptySignal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/enumTypes.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/enumTypes.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/failingComponent.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/failingComponent.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/failingComponentTest.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/failingComponentTest.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/fakeDotProperty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/fakeDotProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/finalOverride.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/finalOverride.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/finalOverride.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/finalOverride.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyNames.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyNames.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyUse.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyUse.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/i18nNameSpace.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/i18nNameSpace.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/i18nScript.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/i18nStrings.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/i18nStrings.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/i18nType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/i18nType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/idProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importFile.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importFile.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importFile.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importFile.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importIncorrectCase.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.10.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.10.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.10.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.10.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.8.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.8.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.9.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.9.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importJs.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importJs.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importNamespaceConflict.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importNamespaceConflict.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importNewerVersion.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importNewerVersion.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importNewerVersion.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importNewerVersion.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importNonExist.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importNonExist.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importNonExist.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importNonExist.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importNonExistOlder.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importNonExistOlder.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importscript.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/importscript.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/importscript.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/importscript.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/incorrectCase.errors.insensitive.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.insensitive.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/incorrectCase.errors.sensitive.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/incorrectCase.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/incorrectCaseType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/inlineAssignmentsOverrideBindings.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/inlineQmlComponents.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/interfaceProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/interfaceQList.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/interfaceQList.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.10.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.10.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.8.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.9.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAlias.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.12.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.12.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.13.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.13.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.8.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.9.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidID.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidID.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidImportID.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidImportID.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidOn.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidOn.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidOn.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidOn.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidProperty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidRoot.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidRoot.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidRoot.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidRoot.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidRoot.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidRoot.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidRoot.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidRoot.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidTypeName.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidTypeName.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidTypeName.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidTypeName.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidTypeName.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidTypeName.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidTypeName.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidTypeName.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/qmldir (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/qmldir)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/LocalLast.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/PrivateType.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/qmldir (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/qmldir (renamed from tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/qmldir)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/listAssignment.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/listAssignment.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/listAssignment.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/listAssignment.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/listAssignment.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/listAssignment.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/listItemDeleteSelf.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/listProperties.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/majorVersionIsolation.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/majorVersionIsolation.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/majorVersionIsolation.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/majorVersionIsolation.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/method.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/method.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/method.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/method.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/missingObject.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/missingObject.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/missingObject.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/missingSignal.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/missingSignal.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/missingSignal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.10.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.10.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.11.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.11.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.11.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.11.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.8.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.9.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/multiSet.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nestedComponentRoots.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nestedComponentRoots.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nestedErrors.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nestedErrors.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/noCreation.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/noCreation.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/noCreation.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/noCreation.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonScriptableProperty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonScriptableProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/notAvailable.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/notAvailable.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nullDotProperty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/nullDotProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/onCompleted.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/onDestruction.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/property.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/property.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/propertyInit.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/propertyInit.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/propertyInit.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/propertyInit.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/propertyValueSource.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/propertyValueSource.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/LocalInternal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/LocalInternal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/Test.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/Test.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestLocal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestLocal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestNamed.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestNamed.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestSubDir.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestSubDir.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/UndeclaredLocal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/UndeclaredLocal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/WrongTestLocal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/WrongTestLocal.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/noqmldir/Test.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/noqmldir/Test.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/pics/blue.png (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/pics/blue.png)bin84 -> 84 bytes
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/qmldir (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/qmldir)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/SubTest.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/subdir/SubTest.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/qmldir (renamed from tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/subdir/qmldir)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readOnly.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/readonly.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/readonly.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/registrationOrder.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/registrationOrder.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/remoteLoadCrash.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/remoteLoadCrash.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/revisions11.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/revisions11.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/revisionsbasesub11.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/revisionsbasesub11.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/revisionssub11.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/revisionssub11.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/rootAsQmlComponent.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/rootAsQmlComponent.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/scriptString.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/scriptString.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/scriptString.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/scriptString.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/scriptString.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/scriptString2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/scriptString3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/scriptString4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/scriptString4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/signal.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/signal.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/simpleBindings.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/simpleBindings.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/simpleContainer.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/simpleContainer.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/simpleObject.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/simpleObject.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/singularProperty.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/singularProperty.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/singularProperty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/singularProperty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/singularProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/subdir/Test.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/subdir/subsubdir/SubTest.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/test.js (renamed from tests/auto/declarative/qdeclarativelanguage/data/test.js)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/test2.js (renamed from tests/auto/declarative/qdeclarativelanguage/data/test2.js)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/unregisteredObject.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/unregisteredObject.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/unsupportedProperty.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/unsupportedProperty.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/valueTypes.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/valueTypes.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/variantNotify.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/variantNotify.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/versionedbase.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/versionedbase.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.1.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.1.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.10.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.10.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.11.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.11.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.12.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.12.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.13.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.13.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.14.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.14.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.15.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.15.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.16.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.16.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.17.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.17.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.17.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.17.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.2.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.2.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.3.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.3.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.4.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.4.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.5.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.5.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.6.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.6.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.7.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.7.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.8.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.8.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.9.errors.txt (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.errors.txt)0
-rw-r--r--tests/auto/qml/qqmllanguage/data/wrongType.9.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.qml)0
-rw-r--r--tests/auto/qml/qqmllanguage/qqmllanguage.pro18
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.cpp (renamed from tests/auto/declarative/qdeclarativelanguage/testtypes.cpp)0
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.h823
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp2289
-rw-r--r--tests/auto/qml/qqmllistreference/data/MyType.qml (renamed from tests/auto/declarative/qdeclarativelistreference/data/MyType.qml)0
-rw-r--r--tests/auto/qml/qqmllistreference/data/engineTypes.qml (renamed from tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml)0
-rw-r--r--tests/auto/qml/qqmllistreference/data/variantToList.qml (renamed from tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml)0
-rw-r--r--tests/auto/qml/qqmllistreference/qqmllistreference.pro15
-rw-r--r--tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp570
-rw-r--r--tests/auto/qml/qqmllocale/data/date.qml (renamed from tests/auto/declarative/qdeclarativelocale/data/date.qml)0
-rw-r--r--tests/auto/qml/qqmllocale/data/functions.qml (renamed from tests/auto/declarative/qdeclarativelocale/data/functions.qml)0
-rw-r--r--tests/auto/qml/qqmllocale/data/localeCompare.qml (renamed from tests/auto/declarative/qdeclarativelocale/data/localeCompare.qml)0
-rw-r--r--tests/auto/qml/qqmllocale/data/number.qml (renamed from tests/auto/declarative/qdeclarativelocale/data/number.qml)0
-rw-r--r--tests/auto/qml/qqmllocale/data/properties.qml (renamed from tests/auto/declarative/qdeclarativelocale/data/properties.qml)0
-rw-r--r--tests/auto/qml/qqmllocale/qqmllocale.pro15
-rw-r--r--tests/auto/qml/qqmllocale/tst_qqmllocale.cpp1183
-rw-r--r--tests/auto/qml/qqmlmetatype/qqmlmetatype.pro7
-rw-r--r--tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp202
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/implicit1/implicitQmldir.errors.txt (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/implicitQmldir.errors.txt)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/implicit1/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/implicit1/temptest.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/temptest.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/implicit2/Test.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/Test.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/implicit2/implicitQmldir.2.errors.txt (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/implicitQmldir.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/implicit2/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/implicit2/temptest2.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/temptest2.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.2.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/incorrectCase.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/incorrectCase.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/pluginWithQmlFile.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/pluginWithQmlFile.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.errors.txt (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.errors.txt)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.errors.txt (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.errors.txt)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/works.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/works.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/works2.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/works2.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/data/works21.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/data/works21.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/WrongCase/qmldir (renamed from tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/WrongCase/qmldir)0
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro7
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp84
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro7
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp84
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp83
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro7
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp73
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginMixed/pluginMixed.pro7
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp73
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginVersion/pluginVersion.pro7
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp58
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro7
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp83
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/pluginWrongCase.pro8
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro9
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp353
-rw-r--r--tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.pro19
-rw-r--r--tests/auto/qml/qqmlparser/qqmlparser.pro9
-rw-r--r--tests/auto/qml/qqmlparser/tst_qqmlparser.cpp210
-rw-r--r--tests/auto/qml/qqmlpixmapcache/data/dataLeak.qml (renamed from tests/auto/declarative/qdeclarativepixmapcache/data/dataLeak.qml)0
-rw-r--r--tests/auto/qml/qqmlproperty/data/NoContextTypeA.qml (renamed from tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeA.qml)0
-rw-r--r--tests/auto/qml/qqmlproperty/data/NoContextTypeB.qml (renamed from tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeB.qml)0
-rw-r--r--tests/auto/qml/qqmlproperty/data/TestType.qml (renamed from tests/auto/declarative/qdeclarativeproperty/data/TestType.qml)0
-rw-r--r--tests/auto/qml/qqmlproperty/data/aliasPropertyBindings.qml (renamed from tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml)0
-rw-r--r--tests/auto/qml/qqmlproperty/data/assignEmptyVariantMap.qml (renamed from tests/auto/declarative/qdeclarativeproperty/data/assignEmptyVariantMap.qml)0
-rw-r--r--tests/auto/qml/qqmlproperty/data/readSynthesizedObject.qml (renamed from tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml)0
-rw-r--r--tests/auto/qml/qqmlproperty/qqmlproperty.pro15
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp1721
-rw-r--r--tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro8
-rw-r--r--tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp281
-rw-r--r--tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro9
-rw-r--r--tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp241
-rw-r--r--tests/auto/qml/qqmlqt/data/atob.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/atob.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/btoa.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/btoa.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/createComponent.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/createComponent.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/createComponentData.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/createComponent_lib.js (renamed from tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js)0
-rw-r--r--tests/auto/qml/qqmlqt/data/createComponent_lib.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/createQmlObject.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/darker.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/darker.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/dateTimeConversion.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/dateTimeConversion.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/enums.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/enums.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/fontFamilies.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/formatting.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/formatting.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/hsla.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/hsla.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/isQtObject.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/isQtObject.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/lighter.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/lighter.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/md5.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/md5.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/openUrlExternally.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/openUrlExternally_lib.js (renamed from tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.js)0
-rw-r--r--tests/auto/qml/qqmlqt/data/openUrlExternally_lib.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/point.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/point.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/quit.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/quit.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/rect.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/rect.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/resolvedUrl.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/resolvedUrl.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/rgba.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/rgba.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/size.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/size.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/tint.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/tint.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/vector.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/vector.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/data/vector4.qml (renamed from tests/auto/declarative/qdeclarativeqt/data/vector4.qml)0
-rw-r--r--tests/auto/qml/qqmlqt/qqmlqt.pro15
-rw-r--r--tests/auto/qml/qqmlqt/tst_qqmlqt.cpp732
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/README (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/README)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/changeversion.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/changeversion.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/creation-a.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/creation-a.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/creation.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/creation.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/error-a.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/error-a.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/error-b.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/error-b.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/error-creation.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/error-creation.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/error-notransaction.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/error-notransaction.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/error-outsidetransaction.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/error-outsidetransaction.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/iteration-forwardonly.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/iteration-forwardonly.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/iteration.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/iteration.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/readonly-error.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/readonly-error.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/readonly.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/readonly.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/reopen1.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/reopen1.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/reopen2.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/reopen2.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/selection-bindnames.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/selection-bindnames.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/data/selection.js (renamed from tests/auto/declarative/qdeclarativesqldatabase/data/selection.js)0
-rw-r--r--tests/auto/qml/qqmlsqldatabase/qqmlsqldatabase.pro15
-rw-r--r--tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp243
-rw-r--r--tests/auto/qml/qqmltranslation/data/idtranslation.qml (renamed from tests/auto/declarative/qdeclarativetranslation/data/idtranslation.qml)0
-rw-r--r--tests/auto/qml/qqmltranslation/data/qml_fr.qm (renamed from tests/auto/declarative/qdeclarativetranslation/data/qml_fr.qm)bin374 -> 374 bytes
-rw-r--r--tests/auto/qml/qqmltranslation/data/qml_fr.ts (renamed from tests/auto/declarative/qdeclarativetranslation/data/qml_fr.ts)0
-rw-r--r--tests/auto/qml/qqmltranslation/data/qmlid_fr.qm (renamed from tests/auto/declarative/qdeclarativetranslation/data/qmlid_fr.qm)bin119 -> 119 bytes
-rw-r--r--tests/auto/qml/qqmltranslation/data/qmlid_fr.ts (renamed from tests/auto/declarative/qdeclarativetranslation/data/qmlid_fr.ts)0
-rw-r--r--tests/auto/qml/qqmltranslation/data/translation.qml (renamed from tests/auto/declarative/qdeclarativetranslation/data/translation.qml)0
-rw-r--r--tests/auto/qml/qqmltranslation/data/translation.qrc (renamed from tests/auto/declarative/qdeclarativetranslation/data/translation.qrc)0
-rw-r--r--tests/auto/qml/qqmltranslation/qqmltranslation.pro16
-rw-r--r--tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp137
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType4.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType4.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType5.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType5.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.2.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.2.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.3.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingAssignment.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingConflict.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingConflict.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingRead.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingRead.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingVariantCopy.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.1.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.1.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.2.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.2.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.3.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.3.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.4.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.4.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.5.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.5.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/color_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/color_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/color_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/color_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/color_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/color_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/conflicting.1.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.1.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/conflicting.2.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.2.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/conflicting.3.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.3.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/deletedObject.js (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.js)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/deletedObject.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/enums.1.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/enums.2.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/enums.3.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/enums.4.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/enums.5.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/font_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_write.2.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/font_write.2.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_write.3.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/font_write.3.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_write.4.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/font_write.4.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_write.5.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/font_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/font_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/matrix4x4_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/matrix4x4_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/matrix4x4_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/point_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/point_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/point_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/point_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/point_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/pointf_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/pointf_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/pointf_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/pointf_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/pointf_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/quaternion_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/quaternion_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/quaternion_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rect_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/rect_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rect_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rect_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/rect_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rectf_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/rectf_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rectf_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/rectf_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/rectf_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/returnValues.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/scriptAccess.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/scriptVariantCopy.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/size_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/size_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/size_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/size_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/size_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizef_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/sizef_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizef_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizef_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/sizef_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizereadonly_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror2.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror3.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror3.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror4.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror4.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/staticAssignment.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/staticAssignment.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/valueInterceptors.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/valueSources.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/varAssignment.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/variant_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/variant_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector2d_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector2d_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector2d_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector3d_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector3d_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector3d_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector4d_compare.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_compare.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector4d_read.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_read.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/vector4d_write.qml (renamed from tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_write.qml)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro18
-rw-r--r--tests/auto/qml/qqmlvaluetypes/testtypes.cpp (renamed from tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp)0
-rw-r--r--tests/auto/qml/qqmlvaluetypes/testtypes.h219
-rw-r--r--tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp1306
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/abort.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/abort.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/abort.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/abort_opened.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/abort_unsent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/attr.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/attr.xml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/callbackException.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/cdata.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/cdata.xml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/constructor.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/defaultState.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/document.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/document.xml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/domExceptionCodes.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/element.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/element.xml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_args.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_sent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_args.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_sent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_unsent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/instanceStateValues.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/invalidMethodUsage.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.1.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.2.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_invalid_method.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_network.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_network.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_network.wait (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_sync.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_user.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/open_username.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/redirectError.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/redirectRecur.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/redirects.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/redirecttarget.html (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/responseText.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/responseXML_invalid.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/seconddocument.html (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_alreadySent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.2.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.3.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.5.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.7.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_data.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_DELETE.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_DELETE.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_GET.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_HEAD.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_HEAD.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/send_unsent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_args.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_caseInsensitive.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_caseInsensitive.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_illegalName.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_sent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_unsent.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/staticStateValues.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/status.200.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/status.400.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/status.400.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/status.404.reply (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/status.expect (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/status.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/testdocument.html (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/text.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/text.xml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/utf16.html (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.html)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/utf16.qml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml)0
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/data/utf16.xml (renamed from tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.xml)bin154 -> 154 bytes
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/qqmlxmlhttprequest.pro19
-rw-r--r--tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp1160
-rw-r--r--tests/auto/qml/qquickbinding/data/deletedObject.qml (renamed from tests/auto/declarative/qdeclarativebinding/data/deletedObject.qml)0
-rw-r--r--tests/auto/qml/qquickbinding/data/restoreBinding.qml (renamed from tests/auto/declarative/qdeclarativebinding/data/restoreBinding.qml)0
-rw-r--r--tests/auto/qml/qquickbinding/data/restoreBindingWithLoop.qml (renamed from tests/auto/declarative/qdeclarativebinding/data/restoreBindingWithLoop.qml)0
-rw-r--r--tests/auto/qml/qquickbinding/data/test-binding.qml (renamed from tests/auto/declarative/qdeclarativebinding/data/test-binding.qml)0
-rw-r--r--tests/auto/qml/qquickbinding/data/test-binding2.qml (renamed from tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml)0
-rw-r--r--tests/auto/qml/qquickbinding/qquickbinding.pro15
-rw-r--r--tests/auto/qml/qquickbinding/tst_qquickbinding.cpp197
-rw-r--r--tests/auto/qml/qquickchangeset/qquickchangeset.pro9
-rw-r--r--tests/auto/qml/qquickchangeset/tst_qquickchangeset.cpp812
-rw-r--r--tests/auto/qml/qquickconnection/data/connection-targetchange.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/connection-targetchange.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/connection-unknownsignals-ignored.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/connection-unknownsignals-notarget.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/connection-unknownsignals-parent.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/connection-unknownsignals.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/error-object.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/error-object.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/error-property.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/error-property.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/error-property2.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/error-syntax.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/moduleapi-target.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/moduleapi-target.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/test-connection.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/test-connection2.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/test-connection3.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/data/trimming.qml (renamed from tests/auto/declarative/qdeclarativeconnection/data/trimming.qml)0
-rw-r--r--tests/auto/qml/qquickconnection/qquickconnection.pro15
-rw-r--r--tests/auto/qml/qquickconnection/tst_qquickconnection.cpp292
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/data/basic.qml (renamed from tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml)0
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/data/dummy.qml (renamed from tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml)0
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/data/resetFiltering.qml (renamed from tests/auto/declarative/qdeclarativefolderlistmodel/data/resetFiltering.qml)0
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/innerdir/test2.txt (renamed from tests/auto/declarative/qdeclarativefolderlistmodel/data/resetfiltering/innerdir/test2.txt)0
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test.txt (renamed from tests/auto/declarative/qdeclarativefolderlistmodel/data/resetfiltering/test.txt)0
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro14
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp179
-rw-r--r--tests/auto/qml/qquicklistcompositor/qquicklistcompositor.pro9
-rw-r--r--tests/auto/qml/qquicklistcompositor/tst_qquicklistcompositor.cpp1637
-rw-r--r--tests/auto/qml/qquicklistmodel/data/enumerate.qml (renamed from tests/auto/declarative/qdeclarativelistmodel/data/enumerate.qml)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/model.qml (renamed from tests/auto/declarative/qdeclarativelistmodel/data/model.qml)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/multipleroles.qml (renamed from tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/script.js (renamed from tests/auto/declarative/qdeclarativelistmodel/data/script.js)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/setmodelcachelist.qml (renamed from tests/auto/declarative/qdeclarativelistmodel/data/setmodelcachelist.qml)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/signalhandlers.qml (renamed from tests/auto/declarative/qdeclarativelistmodel/data/signalhandlers.qml)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/workerremoveelement.js (renamed from tests/auto/declarative/qdeclarativelistmodel/data/workerremoveelement.js)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/workerremoveelement.qml (renamed from tests/auto/declarative/qdeclarativelistmodel/data/workerremoveelement.qml)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/workerremovelist.js (renamed from tests/auto/declarative/qdeclarativelistmodel/data/workerremovelist.js)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/workerremovelist.qml (renamed from tests/auto/declarative/qdeclarativelistmodel/data/workerremovelist.qml)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/workersync.js (renamed from tests/auto/declarative/qdeclarativelistmodel/data/workersync.js)0
-rw-r--r--tests/auto/qml/qquicklistmodel/data/workersync.qml (renamed from tests/auto/declarative/qdeclarativelistmodel/data/workersync.qml)0
-rw-r--r--tests/auto/qml/qquicklistmodel/qquicklistmodel.pro15
-rw-r--r--tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp1632
-rw-r--r--tests/auto/qml/qquickworkerscript/data/BaseWorker.qml (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/Global.js (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/Global.js)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/externalObjectWorker.qml (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/externalObjectWorker.qml)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/script.js (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/script.js)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/script_error_onCall.js (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onCall.js)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/script_error_onLoad.js (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onLoad.js)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/script_fixed_return.js (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/script_fixed_return.js)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/script_include.js (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/script_pragma.js (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/script_pragma.js)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/stressDispose.js (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.js)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/stressDispose.qml (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/worker.qml (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/worker_error_onCall.qml (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onCall.qml)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/worker_error_onLoad.qml (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onLoad.qml)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/worker_include.qml (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml)0
-rw-r--r--tests/auto/qml/qquickworkerscript/data/worker_pragma.qml (renamed from tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml)0
-rw-r--r--tests/auto/qml/qquickworkerscript/qquickworkerscript.pro15
-rw-r--r--tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp300
-rw-r--r--tests/auto/qml/runall.sh100
-rw-r--r--tests/auto/qml/v4/data/conditionalExpr.qml (renamed from tests/auto/declarative/v4/data/conditionalExpr.qml)0
-rw-r--r--tests/auto/qml/v4/data/doubleBoolJump.qml (renamed from tests/auto/declarative/v4/data/doubleBoolJump.qml)0
-rw-r--r--tests/auto/qml/v4/data/fetchException.qml (renamed from tests/auto/declarative/v4/data/fetchException.qml)0
-rw-r--r--tests/auto/qml/v4/data/logicalOr.2.qml (renamed from tests/auto/declarative/v4/data/logicalOr.2.qml)0
-rw-r--r--tests/auto/qml/v4/data/logicalOr.qml (renamed from tests/auto/declarative/v4/data/logicalOr.qml)0
-rw-r--r--tests/auto/qml/v4/data/nestedLogicalOr.qml (renamed from tests/auto/declarative/v4/data/nestedLogicalOr.qml)0
-rw-r--r--tests/auto/qml/v4/data/nestedObjectAccess.qml (renamed from tests/auto/declarative/v4/data/nestedObjectAccess.qml)0
-rw-r--r--tests/auto/qml/v4/data/nullQObject.qml (renamed from tests/auto/declarative/v4/data/nullQObject.qml)0
-rw-r--r--tests/auto/qml/v4/data/qrealToIntRounding.qml (renamed from tests/auto/declarative/v4/data/qrealToIntRounding.qml)0
-rw-r--r--tests/auto/qml/v4/data/qtbug_21883.qml (renamed from tests/auto/declarative/v4/data/qtbug_21883.qml)0
-rw-r--r--tests/auto/qml/v4/data/qtbug_22816.qml (renamed from tests/auto/declarative/v4/data/qtbug_22816.qml)0
-rw-r--r--tests/auto/qml/v4/data/stringComparison.qml (renamed from tests/auto/declarative/v4/data/stringComparison.qml)0
-rw-r--r--tests/auto/qml/v4/data/subscriptionsInConditionalExpressions.qml (renamed from tests/auto/declarative/v4/data/subscriptionsInConditionalExpressions.qml)0
-rw-r--r--tests/auto/qml/v4/data/unaryMinus.qml (renamed from tests/auto/declarative/v4/data/unaryMinus.qml)0
-rw-r--r--tests/auto/qml/v4/data/unaryPlus.qml (renamed from tests/auto/declarative/v4/data/unaryPlus.qml)0
-rw-r--r--tests/auto/qml/v4/data/unnecessaryReeval.qml (renamed from tests/auto/declarative/v4/data/unnecessaryReeval.qml)0
-rw-r--r--tests/auto/qml/v4/testtypes.cpp49
-rw-r--r--tests/auto/qml/v4/testtypes.h (renamed from tests/auto/declarative/v4/testtypes.h)0
-rw-r--r--tests/auto/qml/v4/tst_v4.cpp353
-rw-r--r--tests/auto/qml/v4/v4.pro17
-rw-r--r--tests/auto/qmldevtools/compile/tst_compile.cpp10
-rw-r--r--tests/auto/qmltest/createbenchmark/item.qml2
-rw-r--r--tests/auto/qmltest/qmltest.pro2
-rw-r--r--tests/auto/qmltest/qqmlbinding/tst_binding.qml (renamed from tests/auto/qmltest/qdeclarativebinding/tst_binding.qml)0
-rw-r--r--tests/auto/qmltest/qqmlbinding/tst_binding2.qml (renamed from tests/auto/qmltest/qdeclarativebinding/tst_binding2.qml)0
-rw-r--r--tests/auto/qtquick2/examples/examples.pro10
-rw-r--r--tests/auto/qtquick2/examples/tst_examples.cpp307
-rw-r--r--tests/auto/qtquick2/geometry/geometry.pro9
-rw-r--r--tests/auto/qtquick2/nodes/nodes.pro9
-rw-r--r--tests/auto/qtquick2/qdeclarativeanimationcontroller/qdeclarativeanimationcontroller.pro10
-rw-r--r--tests/auto/qtquick2/qdeclarativeanimationcontroller/tst_qdeclarativeanimationcontroller.cpp42
-rw-r--r--tests/auto/qtquick2/qdeclarativeanimations/qdeclarativeanimations.pro18
-rw-r--r--tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp1319
-rw-r--r--tests/auto/qtquick2/qdeclarativeapplication/qdeclarativeapplication.pro7
-rw-r--r--tests/auto/qtquick2/qdeclarativeapplication/tst_qdeclarativeapplication.cpp159
-rw-r--r--tests/auto/qtquick2/qdeclarativebehaviors/qdeclarativebehaviors.pro15
-rw-r--r--tests/auto/qtquick2/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp473
-rw-r--r--tests/auto/qtquick2/qdeclarativefontloader/qdeclarativefontloader.pro17
-rw-r--r--tests/auto/qtquick2/qdeclarativefontloader/tst_qdeclarativefontloader.cpp255
-rw-r--r--tests/auto/qtquick2/qdeclarativepath/qdeclarativepath.pro15
-rw-r--r--tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp199
-rw-r--r--tests/auto/qtquick2/qdeclarativepixmapcache/qdeclarativepixmapcache.pro21
-rw-r--r--tests/auto/qtquick2/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp467
-rw-r--r--tests/auto/qtquick2/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro15
-rw-r--r--tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp242
-rw-r--r--tests/auto/qtquick2/qdeclarativespringanimation/qdeclarativespringanimation.pro15
-rw-r--r--tests/auto/qtquick2/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp133
-rw-r--r--tests/auto/qtquick2/qdeclarativestates/qdeclarativestates.pro14
-rw-r--r--tests/auto/qtquick2/qdeclarativestates/tst_qdeclarativestates.cpp1608
-rw-r--r--tests/auto/qtquick2/qdeclarativestyledtext/qdeclarativestyledtext.pro8
-rw-r--r--tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp185
-rw-r--r--tests/auto/qtquick2/qdeclarativesystempalette/qdeclarativesystempalette.pro8
-rw-r--r--tests/auto/qtquick2/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp185
-rw-r--r--tests/auto/qtquick2/qdeclarativetimer/qdeclarativetimer.pro8
-rw-r--r--tests/auto/qtquick2/qdeclarativetimer/tst_qdeclarativetimer.cpp393
-rw-r--r--tests/auto/qtquick2/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro15
-rw-r--r--tests/auto/qtquick2/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp962
-rw-r--r--tests/auto/qtquick2/qquickaccessible/data/hittest.qml176
-rw-r--r--tests/auto/qtquick2/qquickaccessible/qquickaccessible.pro25
-rw-r--r--tests/auto/qtquick2/qquickaccessible/tst_qquickaccessible.cpp410
-rw-r--r--tests/auto/qtquick2/qquickanchors/qquickanchors.pro16
-rw-r--r--tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp669
-rw-r--r--tests/auto/qtquick2/qquickanimatedimage/qquickanimatedimage.pro17
-rw-r--r--tests/auto/qtquick2/qquickanimatedimage/tst_qquickanimatedimage.cpp374
-rw-r--r--tests/auto/qtquick2/qquickborderimage/qquickborderimage.pro17
-rw-r--r--tests/auto/qtquick2/qquickborderimage/tst_qquickborderimage.cpp373
-rw-r--r--tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro20
-rw-r--r--tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp775
-rw-r--r--tests/auto/qtquick2/qquickcanvasitem/qquickcanvasitem.pro34
-rw-r--r--tests/auto/qtquick2/qquickdrag/qquickdrag.pro9
-rw-r--r--tests/auto/qtquick2/qquickdrag/tst_qquickdrag.cpp1034
-rw-r--r--tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro9
-rw-r--r--tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp1117
-rw-r--r--tests/auto/qtquick2/qquickflickable/qquickflickable.pro15
-rw-r--r--tests/auto/qtquick2/qquickflickable/tst_qquickflickable.cpp663
-rw-r--r--tests/auto/qtquick2/qquickflipable/qquickflipable.pro15
-rw-r--r--tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp135
-rw-r--r--tests/auto/qtquick2/qquickfocusscope/qquickfocusscope.pro14
-rw-r--r--tests/auto/qtquick2/qquickfocusscope/tst_qquickfocusscope.cpp636
-rw-r--r--tests/auto/qtquick2/qquickgridview/data/addTransitions.qml129
-rw-r--r--tests/auto/qtquick2/qquickgridview/data/moveTransitions.qml143
-rw-r--r--tests/auto/qtquick2/qquickgridview/data/removeTransitions.qml146
-rw-r--r--tests/auto/qtquick2/qquickgridview/qquickgridview.pro15
-rw-r--r--tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp5075
-rw-r--r--tests/auto/qtquick2/qquickimage/qquickimage.pro17
-rw-r--r--tests/auto/qtquick2/qquickimage/tst_qquickimage.cpp749
-rw-r--r--tests/auto/qtquick2/qquickitem/qquickitem.pro14
-rw-r--r--tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp1468
-rw-r--r--tests/auto/qtquick2/qquickitem2/qquickitem2.pro15
-rw-r--r--tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp1380
-rw-r--r--tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro38
-rw-r--r--tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp436
-rw-r--r--tests/auto/qtquick2/qquicklistview/data/addTransitions.qml134
-rw-r--r--tests/auto/qtquick2/qquicklistview/data/moveTransitions.qml141
-rw-r--r--tests/auto/qtquick2/qquicklistview/data/removeTransitions.qml144
-rw-r--r--tests/auto/qtquick2/qquicklistview/qquicklistview.pro16
-rw-r--r--tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp5715
-rw-r--r--tests/auto/qtquick2/qquickloader/qquickloader.pro19
-rw-r--r--tests/auto/qtquick2/qquickloader/tst_qquickloader.cpp987
-rw-r--r--tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro17
-rw-r--r--tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp806
-rw-r--r--tests/auto/qtquick2/qquickmultipointtoucharea/qquickmultipointtoucharea.pro11
-rw-r--r--tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp727
-rw-r--r--tests/auto/qtquick2/qquickpathview/qquickpathview.pro15
-rw-r--r--tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp1458
-rw-r--r--tests/auto/qtquick2/qquickpincharea/qquickpincharea.pro15
-rw-r--r--tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp404
-rw-r--r--tests/auto/qtquick2/qquickpositioners/qquickpositioners.pro14
-rw-r--r--tests/auto/qtquick2/qquickpositioners/tst_qquickpositioners.cpp1472
-rw-r--r--tests/auto/qtquick2/qquickrepeater/qquickrepeater.pro15
-rw-r--r--tests/auto/qtquick2/qquickrepeater/tst_qquickrepeater.cpp644
-rw-r--r--tests/auto/qtquick2/qquickscreen/qquickscreen.pro10
-rw-r--r--tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp77
-rw-r--r--tests/auto/qtquick2/qquickshadereffect/qquickshadereffect.pro8
-rw-r--r--tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro15
-rw-r--r--tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp98
-rw-r--r--tests/auto/qtquick2/qquicktext/qquicktext.pro19
-rw-r--r--tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp2432
-rw-r--r--tests/auto/qtquick2/qquicktextedit/qquicktextedit.pro16
-rw-r--r--tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp3884
-rw-r--r--tests/auto/qtquick2/qquicktextinput/qquicktextinput.pro13
-rw-r--r--tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp4706
-rw-r--r--tests/auto/qtquick2/qquickview/qquickview.pro13
-rw-r--r--tests/auto/qtquick2/qquickview/tst_qquickview.cpp207
-rw-r--r--tests/auto/qtquick2/qquickvisualdatamodel/qquickvisualdatamodel.pro16
-rw-r--r--tests/auto/qtquick2/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp3446
-rw-r--r--tests/auto/qtquick2/qtquick2.pro70
-rw-r--r--tests/auto/qtquick2/rendernode/rendernode.pro18
-rw-r--r--tests/auto/qtquick2/rendernode/tst_rendernode.cpp242
-rw-r--r--tests/auto/qtquick2/shared/util.pri7
-rw-r--r--tests/auto/qtquick2/shared/viewtestutil.cpp493
-rw-r--r--tests/auto/qtquick2/shared/viewtestutil.h180
-rw-r--r--tests/auto/qtquick2/shared/visualtestutil.h112
-rw-r--r--tests/auto/quick/examples/data/dummytest.qml (renamed from tests/auto/qtquick2/examples/data/dummytest.qml)0
-rw-r--r--tests/auto/quick/examples/data/webbrowser/webbrowser.qml (renamed from tests/auto/qtquick2/examples/data/webbrowser/webbrowser.qml)0
-rw-r--r--tests/auto/quick/examples/examples.pro10
-rw-r--r--tests/auto/quick/examples/tst_examples.cpp307
-rw-r--r--tests/auto/quick/geometry/geometry.pro9
-rw-r--r--tests/auto/quick/geometry/tst_geometry.cpp (renamed from tests/auto/qtquick2/geometry/tst_geometry.cpp)0
-rw-r--r--tests/auto/quick/nodes/nodes.pro9
-rw-r--r--tests/auto/quick/nodes/tst_nodestest.cpp (renamed from tests/auto/qtquick2/nodes/tst_nodestest.cpp)0
-rw-r--r--tests/auto/quick/qquickaccessible/data/checkbuttons.qml (renamed from tests/auto/qtquick2/qquickaccessible/data/checkbuttons.qml)0
-rw-r--r--tests/auto/quick/qquickaccessible/data/hittest.qml176
-rw-r--r--tests/auto/quick/qquickaccessible/data/pushbutton.qml (renamed from tests/auto/qtquick2/qquickaccessible/data/pushbutton.qml)0
-rw-r--r--tests/auto/quick/qquickaccessible/data/statictext.qml (renamed from tests/auto/qtquick2/qquickaccessible/data/statictext.qml)0
-rw-r--r--tests/auto/quick/qquickaccessible/data/widgets/TextRect.qml (renamed from tests/auto/qtquick2/qquickaccessible/data/widgets/TextRect.qml)0
-rw-r--r--tests/auto/quick/qquickaccessible/qquickaccessible.pro25
-rw-r--r--tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp410
-rw-r--r--tests/auto/quick/qquickanchors/data/anchors.qml (renamed from tests/auto/qtquick2/qquickanchors/data/anchors.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/centerin.qml (renamed from tests/auto/qtquick2/qquickanchors/data/centerin.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/centerinRotation.qml (renamed from tests/auto/qtquick2/qquickanchors/data/centerinRotation.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/crash1.qml (renamed from tests/auto/qtquick2/qquickanchors/data/crash1.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/fill.qml (renamed from tests/auto/qtquick2/qquickanchors/data/fill.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/hvCenter.qml (renamed from tests/auto/qtquick2/qquickanchors/data/hvCenter.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/loop1.qml (renamed from tests/auto/qtquick2/qquickanchors/data/loop1.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/loop2.qml (renamed from tests/auto/qtquick2/qquickanchors/data/loop2.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/data/margins.qml (renamed from tests/auto/qtquick2/qquickanchors/data/margins.qml)0
-rw-r--r--tests/auto/quick/qquickanchors/qquickanchors.pro16
-rw-r--r--tests/auto/quick/qquickanchors/tst_qquickanchors.cpp669
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/colors.gif (renamed from tests/auto/qtquick2/qquickanimatedimage/data/colors.gif)bin505 -> 505 bytes
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/colors.qml (renamed from tests/auto/qtquick2/qquickanimatedimage/data/colors.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/hearts.gif (renamed from tests/auto/qtquick2/qquickanimatedimage/data/hearts.gif)bin6524 -> 6524 bytes
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/hearts.qml (renamed from tests/auto/qtquick2/qquickanimatedimage/data/hearts.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/qmldir (renamed from tests/auto/qtquick2/qquickanimatedimage/data/qmldir)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/qtbug-16520.qml (renamed from tests/auto/qtquick2/qquickanimatedimage/data/qtbug-16520.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/stickman.gif (renamed from tests/auto/qtquick2/qquickanimatedimage/data/stickman.gif)bin164923 -> 164923 bytes
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/stickman.qml (renamed from tests/auto/qtquick2/qquickanimatedimage/data/stickman.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/stickmanerror1.qml (renamed from tests/auto/qtquick2/qquickanimatedimage/data/stickmanerror1.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/stickmanpause.qml (renamed from tests/auto/qtquick2/qquickanimatedimage/data/stickmanpause.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/stickmanscaled.qml (renamed from tests/auto/qtquick2/qquickanimatedimage/data/stickmanscaled.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/data/stickmanstopped.qml (renamed from tests/auto/qtquick2/qquickanimatedimage/data/stickmanstopped.qml)0
-rw-r--r--tests/auto/quick/qquickanimatedimage/qquickanimatedimage.pro17
-rw-r--r--tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp374
-rw-r--r--tests/auto/quick/qquickanimationcontroller/data/tst_numberanimation.qml (renamed from tests/auto/qtquick2/qdeclarativeanimationcontroller/data/tst_numberanimation.qml)0
-rw-r--r--tests/auto/quick/qquickanimationcontroller/qquickanimationcontroller.pro10
-rw-r--r--tests/auto/quick/qquickanimationcontroller/tst_qquickanimationcontroller.cpp42
-rw-r--r--tests/auto/quick/qquickanimations/data/Double.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/Double.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/attached.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/attached.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/badproperty1.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/badproperty1.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/badproperty2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/badproperty2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/badtype1.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/badtype1.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/badtype2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/badtype2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/badtype3.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/badtype3.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/badtype4.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/badtype4.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/disabledTransition.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/disabledTransition.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/dontAutoStart.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/dontAutoStart.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/dontStart.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/dontStart.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/dontStart2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/dontStart2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/dotproperty.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/dotproperty.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/doubleRegistrationBug.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/doubleRegistrationBug.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/looping.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/looping.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/mixedtype1.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype1.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/mixedtype2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/nonTransitionBug.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/nonTransitionBug.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pathAnimation.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pathAnimation2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pathAnimationNoStart.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimationNoStart.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pathInterpolator.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolator.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pathInterpolatorBack.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pathInterpolatorBack2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pathTransition.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pathTransition.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pauseBindingBug.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pauseBindingBug.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/pauseBug.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/pauseBug.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/properties.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/properties.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/properties2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/properties2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/properties3.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/properties3.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/properties4.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/properties4.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/properties5.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/properties5.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/propertiesTransition.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/propertiesTransition2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/propertiesTransition3.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition3.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/propertiesTransition4.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition4.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/propertiesTransition5.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition5.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/propertiesTransition6.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition6.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/propertiesTransition7.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition7.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/reanchor.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/reanchor.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/registrationBug.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/registrationBug.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/reparent.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/reparent.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/rotation.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/rotation.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/runningTrueBug.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/runningTrueBug.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/transitionAssignmentBug.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/transitionAssignmentBug.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/valuesource.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/valuesource.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/data/valuesource2.qml (renamed from tests/auto/qtquick2/qdeclarativeanimations/data/valuesource2.qml)0
-rw-r--r--tests/auto/quick/qquickanimations/qquickanimations.pro18
-rw-r--r--tests/auto/quick/qquickanimations/tst_qquickanimations.cpp1319
-rw-r--r--tests/auto/quick/qquickapplication/qquickapplication.pro7
-rw-r--r--tests/auto/quick/qquickapplication/tst_qquickapplication.cpp159
-rw-r--r--tests/auto/quick/qquickbehaviors/data/binding.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/binding.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/color.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/color.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/cpptrigger.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/cpptrigger.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/delayedRegistration.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/delayedRegistration.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/disabled.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/disabled.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/dontStart.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/dontStart.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/empty.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/empty.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/explicit.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/explicit.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/groupProperty.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/groupProperty2.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty2.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/groupedPropertyCrash.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/groupedPropertyCrash.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/loop.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/loop.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/nonSelecting2.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/nonSelecting2.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/parent.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/parent.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/qtbug12295.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/qtbug12295.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/reassignedAnimation.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/reassignedAnimation.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/runningTrue.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/runningTrue.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/scripttrigger.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/scripttrigger.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/simple.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/simple.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/startOnCompleted.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/startOnCompleted.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/startup.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/startup.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/startup2.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/startup2.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/data/valueType.qml (renamed from tests/auto/qtquick2/qdeclarativebehaviors/data/valueType.qml)0
-rw-r--r--tests/auto/quick/qquickbehaviors/qquickbehaviors.pro15
-rw-r--r--tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp473
-rw-r--r--tests/auto/quick/qquickborderimage/data/colors-mirror.png (renamed from tests/auto/qtquick2/qquickborderimage/data/colors-mirror.png)bin5554 -> 5554 bytes
-rw-r--r--tests/auto/quick/qquickborderimage/data/colors-round-quotes.sci (renamed from tests/auto/qtquick2/qquickborderimage/data/colors-round-quotes.sci)0
-rw-r--r--tests/auto/quick/qquickborderimage/data/colors-round-remote.sci (renamed from tests/auto/qtquick2/qquickborderimage/data/colors-round-remote.sci)0
-rw-r--r--tests/auto/quick/qquickborderimage/data/colors-round.sci (renamed from tests/auto/qtquick2/qquickborderimage/data/colors-round.sci)0
-rw-r--r--tests/auto/quick/qquickborderimage/data/colors.png (renamed from tests/auto/qtquick2/qquickborderimage/data/colors.png)bin1655 -> 1655 bytes
-rw-r--r--tests/auto/quick/qquickborderimage/data/heart200.png (renamed from tests/auto/qtquick2/qquickborderimage/data/heart200.png)bin7943 -> 7943 bytes
-rw-r--r--tests/auto/quick/qquickborderimage/data/invalid.sci (renamed from tests/auto/qtquick2/qquickborderimage/data/invalid.sci)0
-rw-r--r--tests/auto/quick/qquickborderimage/data/mirror.qml (renamed from tests/auto/qtquick2/qquickborderimage/data/mirror.qml)0
-rw-r--r--tests/auto/quick/qquickborderimage/qquickborderimage.pro17
-rw-r--r--tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp373
-rw-r--r--tests/auto/quick/qquickcanvas/data/AnimationsWhileHidden.qml (renamed from tests/auto/qtquick2/qquickcanvas/data/AnimationsWhileHidden.qml)0
-rw-r--r--tests/auto/quick/qquickcanvas/data/Headless.qml (renamed from tests/auto/qtquick2/qquickcanvas/data/Headless.qml)0
-rw-r--r--tests/auto/quick/qquickcanvas/data/colors.png (renamed from tests/auto/qtquick2/qquickcanvas/data/colors.png)bin1655 -> 1655 bytes
-rw-r--r--tests/auto/quick/qquickcanvas/data/focus.qml (renamed from tests/auto/qtquick2/qquickcanvas/data/focus.qml)0
-rw-r--r--tests/auto/quick/qquickcanvas/data/window.qml (renamed from tests/auto/qtquick2/qquickcanvas/data/window.qml)0
-rw-r--r--tests/auto/quick/qquickcanvas/qquickcanvas.pro20
-rw-r--r--tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp775
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/anim-gr.gif (renamed from tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.gif)bin241 -> 241 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/anim-gr.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.png)bin460 -> 460 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/anim-poster-gr.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/anim-poster-gr.png)bin422 -> 422 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/background.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/background.png)bin86 -> 86 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/broken.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/broken.png)bin87 -> 87 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/ggrr-256x256.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/ggrr-256x256.png)bin120 -> 120 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/green-16x16.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/green-16x16.png)bin92 -> 92 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/green-1x1.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/green-1x1.png)bin82 -> 82 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/green-256x256.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/green-256x256.png)bin103 -> 103 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/green-2x2.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/green-2x2.png)bin118 -> 118 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/green.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/green.png)bin87 -> 87 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/grgr-256x256.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/grgr-256x256.png)bin130 -> 130 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/red-16x16.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/red-16x16.png)bin130 -> 130 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/red.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/red.png)bin87 -> 87 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/redtransparent.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/redtransparent.png)bin109 -> 109 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/rgrg-256x256.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/rgrg-256x256.png)bin131 -> 131 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/rrgg-256x256.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/rrgg-256x256.png)bin120 -> 120 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/testhelper.js (renamed from tests/auto/qtquick2/qquickcanvasitem/data/testhelper.js)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/transparent.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/transparent.png)bin100 -> 100 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/transparent50.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/transparent50.png)bin155 -> 155 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_arc.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_arc.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_arcto.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_canvas.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_composite.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_composite.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_context.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_context.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_drawimage.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_drawimage.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_fillStyle.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_fillStyle.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_fillrect.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_fillrect.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_gradient.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_gradient.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_line.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_line.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_path.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_path.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_pattern.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_pattern.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_pixel.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_shadow.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_shadow.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_state.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_state.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_strokeStyle.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_strokeStyle.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_text.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_text.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_transform.qml (renamed from tests/auto/qtquick2/qquickcanvasitem/data/tst_transform.qml)0
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/yellow.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/yellow.png)bin95 -> 95 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/yellow75.png (renamed from tests/auto/qtquick2/qquickcanvasitem/data/yellow75.png)bin150 -> 150 bytes
-rw-r--r--tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro34
-rw-r--r--tests/auto/quick/qquickcanvasitem/tst_qquickcanvasitem.cpp (renamed from tests/auto/qtquick2/qquickcanvasitem/tst_qquickcanvasitem.cpp)0
-rw-r--r--tests/auto/quick/qquickdrag/qquickdrag.pro9
-rw-r--r--tests/auto/quick/qquickdrag/tst_qquickdrag.cpp1034
-rw-r--r--tests/auto/quick/qquickdroparea/qquickdroparea.pro9
-rw-r--r--tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp1117
-rw-r--r--tests/auto/quick/qquickflickable/data/disabled.qml (renamed from tests/auto/qtquick2/qquickflickable/data/disabled.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/flickable01.qml (renamed from tests/auto/qtquick2/qquickflickable/data/flickable01.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/flickable02.qml (renamed from tests/auto/qtquick2/qquickflickable/data/flickable02.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/flickable03.qml (renamed from tests/auto/qtquick2/qquickflickable/data/flickable03.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/flickable04.qml (renamed from tests/auto/qtquick2/qquickflickable/data/flickable04.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/flickableqgraphicswidget.qml (renamed from tests/auto/qtquick2/qquickflickable/data/flickableqgraphicswidget.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/margins.qml (renamed from tests/auto/qtquick2/qquickflickable/data/margins.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/nestedPressDelay.qml (renamed from tests/auto/qtquick2/qquickflickable/data/nestedPressDelay.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/resize.qml (renamed from tests/auto/qtquick2/qquickflickable/data/resize.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/data/wheel.qml (renamed from tests/auto/qtquick2/qquickflickable/data/wheel.qml)0
-rw-r--r--tests/auto/quick/qquickflickable/qquickflickable.pro15
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp663
-rw-r--r--tests/auto/quick/qquickflipable/data/crash.qml (renamed from tests/auto/qtquick2/qquickflipable/data/crash.qml)0
-rw-r--r--tests/auto/quick/qquickflipable/data/flipable-abort.qml (renamed from tests/auto/qtquick2/qquickflipable/data/flipable-abort.qml)0
-rw-r--r--tests/auto/quick/qquickflipable/data/test-flipable.qml (renamed from tests/auto/qtquick2/qquickflipable/data/test-flipable.qml)0
-rw-r--r--tests/auto/quick/qquickflipable/qquickflipable.pro15
-rw-r--r--tests/auto/quick/qquickflipable/tst_qquickflipable.cpp135
-rw-r--r--tests/auto/quick/qquickfocusscope/data/canvasFocus.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/canvasFocus.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/chain.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/chain.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/forceActiveFocus.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/forceActiveFocus.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/forcefocus.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/forcefocus.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/qtBug13380.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/qtBug13380.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/signalEmission.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/signalEmission.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/test.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/test.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/test2.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/test2.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/test3.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/test3.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/test4.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/test4.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/data/test5.qml (renamed from tests/auto/qtquick2/qquickfocusscope/data/test5.qml)0
-rw-r--r--tests/auto/quick/qquickfocusscope/qquickfocusscope.pro14
-rw-r--r--tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp636
-rw-r--r--tests/auto/quick/qquickfontloader/data/daniel.ttf (renamed from tests/auto/qtquick2/qdeclarativefontloader/data/daniel.ttf)bin51984 -> 51984 bytes
-rw-r--r--tests/auto/quick/qquickfontloader/data/dummy.ttf (renamed from tests/auto/qtquick2/qdeclarativefontloader/data/dummy.ttf)0
-rw-r--r--tests/auto/quick/qquickfontloader/data/qtbug-20268.qml (renamed from tests/auto/qtquick2/qdeclarativefontloader/data/qtbug-20268.qml)0
-rw-r--r--tests/auto/quick/qquickfontloader/data/tarzeau_ocr_a.ttf (renamed from tests/auto/qtquick2/qdeclarativefontloader/data/tarzeau_ocr_a.ttf)bin24544 -> 24544 bytes
-rw-r--r--tests/auto/quick/qquickfontloader/qquickfontloader.pro17
-rw-r--r--tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp255
-rw-r--r--tests/auto/quick/qquickgridview/data/ComponentView.qml (renamed from tests/auto/qtquick2/qquickgridview/data/ComponentView.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/addTransitions.qml129
-rw-r--r--tests/auto/quick/qquickgridview/data/asyncloader.qml (renamed from tests/auto/qtquick2/qquickgridview/data/asyncloader.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/attachedSignals.qml (renamed from tests/auto/qtquick2/qquickgridview/data/attachedSignals.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/creationContext.qml (renamed from tests/auto/qtquick2/qquickgridview/data/creationContext.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/displaygrid.qml (renamed from tests/auto/qtquick2/qquickgridview/data/displaygrid.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/footer.qml (renamed from tests/auto/qtquick2/qquickgridview/data/footer.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/gridview-enforcerange.qml (renamed from tests/auto/qtquick2/qquickgridview/data/gridview-enforcerange.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/gridview-initCurrent.qml (renamed from tests/auto/qtquick2/qquickgridview/data/gridview-initCurrent.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/gridview-noCurrent.qml (renamed from tests/auto/qtquick2/qquickgridview/data/gridview-noCurrent.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/gridview1.qml (renamed from tests/auto/qtquick2/qquickgridview/data/gridview1.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/gridview2.qml (renamed from tests/auto/qtquick2/qquickgridview/data/gridview2.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/gridview3.qml (renamed from tests/auto/qtquick2/qquickgridview/data/gridview3.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/gridview4.qml (renamed from tests/auto/qtquick2/qquickgridview/data/gridview4.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/header.qml (renamed from tests/auto/qtquick2/qquickgridview/data/header.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/manual-highlight.qml (renamed from tests/auto/qtquick2/qquickgridview/data/manual-highlight.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/margins.qml (renamed from tests/auto/qtquick2/qquickgridview/data/margins.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/mirroring.qml (renamed from tests/auto/qtquick2/qquickgridview/data/mirroring.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/moveTransitions.qml143
-rw-r--r--tests/auto/quick/qquickgridview/data/multipleTransitions.qml (renamed from tests/auto/qtquick2/qquickgridview/data/multipleTransitions.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/populateTransitions.qml (renamed from tests/auto/qtquick2/qquickgridview/data/populateTransitions.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/propertychangestest.qml (renamed from tests/auto/qtquick2/qquickgridview/data/propertychangestest.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/removeTransitions.qml146
-rw-r--r--tests/auto/quick/qquickgridview/data/resizeview.qml (renamed from tests/auto/qtquick2/qquickgridview/data/resizeview.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/setindex.qml (renamed from tests/auto/qtquick2/qquickgridview/data/setindex.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/snapOneRow.qml (renamed from tests/auto/qtquick2/qquickgridview/data/snapOneRow.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/snapToRow.qml (renamed from tests/auto/qtquick2/qquickgridview/data/snapToRow.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/unaligned.qml (renamed from tests/auto/qtquick2/qquickgridview/data/unaligned.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/data/unrequestedItems.qml (renamed from tests/auto/qtquick2/qquickgridview/data/unrequestedItems.qml)0
-rw-r--r--tests/auto/quick/qquickgridview/qquickgridview.pro15
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp5075
-rw-r--r--tests/auto/quick/qquickimage/data/aspectratio.qml (renamed from tests/auto/qtquick2/qquickimage/data/aspectratio.qml)0
-rw-r--r--tests/auto/quick/qquickimage/data/big.jpeg (renamed from tests/auto/qtquick2/qquickimage/data/big.jpeg)bin1700081 -> 1700081 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/big256.png (renamed from tests/auto/qtquick2/qquickimage/data/big256.png)bin3566 -> 3566 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/colors.png (renamed from tests/auto/qtquick2/qquickimage/data/colors.png)bin1655 -> 1655 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/colors1.png (renamed from tests/auto/qtquick2/qquickimage/data/colors1.png)bin1655 -> 1655 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/green.png (renamed from tests/auto/qtquick2/qquickimage/data/green.png)bin314 -> 314 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/heart-win32.png (renamed from tests/auto/qtquick2/qquickimage/data/heart-win32.png)bin12621 -> 12621 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/heart.png (renamed from tests/auto/qtquick2/qquickimage/data/heart.png)bin12577 -> 12577 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/heart.svg (renamed from tests/auto/qtquick2/qquickimage/data/heart.svg)0
-rw-r--r--tests/auto/quick/qquickimage/data/heart200-win32.png (renamed from tests/auto/qtquick2/qquickimage/data/heart200-win32.png)bin8062 -> 8062 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/heart200.png (renamed from tests/auto/qtquick2/qquickimage/data/heart200.png)bin8063 -> 8063 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/htiling.qml (renamed from tests/auto/qtquick2/qquickimage/data/htiling.qml)0
-rw-r--r--tests/auto/quick/qquickimage/data/mirror.qml (renamed from tests/auto/qtquick2/qquickimage/data/mirror.qml)0
-rw-r--r--tests/auto/quick/qquickimage/data/nullpixmap.qml (renamed from tests/auto/qtquick2/qquickimage/data/nullpixmap.qml)0
-rw-r--r--tests/auto/quick/qquickimage/data/pattern.png (renamed from tests/auto/qtquick2/qquickimage/data/pattern.png)bin1371 -> 1371 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/qtbug_16389.qml (renamed from tests/auto/qtquick2/qquickimage/data/qtbug_16389.qml)0
-rw-r--r--tests/auto/quick/qquickimage/data/qtbug_22125.qml (renamed from tests/auto/qtquick2/qquickimage/data/qtbug_22125.qml)0
-rw-r--r--tests/auto/quick/qquickimage/data/rect.png (renamed from tests/auto/qtquick2/qquickimage/data/rect.png)bin171 -> 171 bytes
-rw-r--r--tests/auto/quick/qquickimage/data/sourceSize.qml (renamed from tests/auto/qtquick2/qquickimage/data/sourceSize.qml)0
-rw-r--r--tests/auto/quick/qquickimage/data/vtiling.qml (renamed from tests/auto/qtquick2/qquickimage/data/vtiling.qml)0
-rw-r--r--tests/auto/quick/qquickimage/qquickimage.pro17
-rw-r--r--tests/auto/quick/qquickimage/tst_qquickimage.cpp749
-rw-r--r--tests/auto/quick/qquickitem/data/order.1.qml (renamed from tests/auto/qtquick2/qquickitem/data/order.1.qml)0
-rw-r--r--tests/auto/quick/qquickitem/data/order.2.qml (renamed from tests/auto/qtquick2/qquickitem/data/order.2.qml)0
-rw-r--r--tests/auto/quick/qquickitem/data/polishOnCompleted.qml (renamed from tests/auto/qtquick2/qquickitem/data/polishOnCompleted.qml)0
-rw-r--r--tests/auto/quick/qquickitem/qquickitem.pro14
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp1468
-rw-r--r--tests/auto/quick/qquickitem2/data/childrenProperty.qml (renamed from tests/auto/qtquick2/qquickitem2/data/childrenProperty.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/childrenRect.qml (renamed from tests/auto/qtquick2/qquickitem2/data/childrenRect.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/childrenRectBug.qml (renamed from tests/auto/qtquick2/qquickitem2/data/childrenRectBug.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/childrenRectBug2.qml (renamed from tests/auto/qtquick2/qquickitem2/data/childrenRectBug2.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/childrenRectBug3.qml (renamed from tests/auto/qtquick2/qquickitem2/data/childrenRectBug3.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/implicitsize.qml (renamed from tests/auto/qtquick2/qquickitem2/data/implicitsize.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/keynavigationtest.qml (renamed from tests/auto/qtquick2/qquickitem2/data/keynavigationtest.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/keynavigationtest_implicit.qml (renamed from tests/auto/qtquick2/qquickitem2/data/keynavigationtest_implicit.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/keysim.qml (renamed from tests/auto/qtquick2/qquickitem2/data/keysim.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/keyspriority.qml (renamed from tests/auto/qtquick2/qquickitem2/data/keyspriority.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/keystest.qml (renamed from tests/auto/qtquick2/qquickitem2/data/keystest.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/layoutmirroring.qml (renamed from tests/auto/qtquick2/qquickitem2/data/layoutmirroring.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/mapCoordinates.qml (renamed from tests/auto/qtquick2/qquickitem2/data/mapCoordinates.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/parentLoop.qml (renamed from tests/auto/qtquick2/qquickitem2/data/parentLoop.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/propertychanges.qml (renamed from tests/auto/qtquick2/qquickitem2/data/propertychanges.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/qtbug_16871.qml (renamed from tests/auto/qtquick2/qquickitem2/data/qtbug_16871.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/resourcesProperty.qml (renamed from tests/auto/qtquick2/qquickitem2/data/resourcesProperty.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/transformCrash.qml (renamed from tests/auto/qtquick2/qquickitem2/data/transformCrash.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/data/visiblechildren.qml (renamed from tests/auto/qtquick2/qquickitem2/data/visiblechildren.qml)0
-rw-r--r--tests/auto/quick/qquickitem2/qquickitem2.pro15
-rw-r--r--tests/auto/quick/qquickitem2/tst_qquickitem.cpp1380
-rw-r--r--tests/auto/quick/qquickitemlayer/data/DisableLayer.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/DisableLayer.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/Effect.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/Effect.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/Enabled.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/Enabled.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/ItemEffect.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/ItemEffect.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/Mipmap.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/Mipmap.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/RectangleEffect.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/RectangleEffect.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/SamplerNameChange.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/SamplerNameChange.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/Smooth.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/Smooth.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/SourceRect.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/SourceRect.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/TextureProvider.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/TextureProvider.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/ToggleLayerAndEffect.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/ToggleLayerAndEffect.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/Visible.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/Visible.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/ZOrder.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/ZOrder.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/data/ZOrderChange.qml (renamed from tests/auto/qtquick2/qquickitemlayer/data/ZOrderChange.qml)0
-rw-r--r--tests/auto/quick/qquickitemlayer/qquickitemlayer.pro38
-rw-r--r--tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp436
-rw-r--r--tests/auto/quick/qquicklistview/data/ComponentView.qml (renamed from tests/auto/qtquick2/qquicklistview/data/ComponentView.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/Page.qml (renamed from tests/auto/qtquick2/qquicklistview/data/Page.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/addTransitions.qml134
-rw-r--r--tests/auto/quick/qquicklistview/data/asyncloader.qml (renamed from tests/auto/qtquick2/qquicklistview/data/asyncloader.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/attachedSignals.qml (renamed from tests/auto/qtquick2/qquicklistview/data/attachedSignals.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/creationContext.qml (renamed from tests/auto/qtquick2/qquicklistview/data/creationContext.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/displaylist.qml (renamed from tests/auto/qtquick2/qquicklistview/data/displaylist.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/fillModelOnComponentCompleted.qml (renamed from tests/auto/qtquick2/qquicklistview/data/fillModelOnComponentCompleted.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/footer.qml (renamed from tests/auto/qtquick2/qquicklistview/data/footer.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/header.qml (renamed from tests/auto/qtquick2/qquicklistview/data/header.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/headerfooter.qml (renamed from tests/auto/qtquick2/qquicklistview/data/headerfooter.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/itemlist.qml (renamed from tests/auto/qtquick2/qquicklistview/data/itemlist.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-enforcerange-nohighlight.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listview-enforcerange-nohighlight.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-enforcerange.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listview-enforcerange.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-initCurrent.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listview-initCurrent.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-noCurrent.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listview-noCurrent.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-sections-package.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listview-sections-package.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-sections.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listview-sections.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listview-sections_delegate.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listviewtest-package.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listviewtest-package.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/listviewtest.qml (renamed from tests/auto/qtquick2/qquicklistview/data/listviewtest.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/manual-highlight.qml (renamed from tests/auto/qtquick2/qquicklistview/data/manual-highlight.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/margins.qml (renamed from tests/auto/qtquick2/qquicklistview/data/margins.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/margins2.qml (renamed from tests/auto/qtquick2/qquicklistview/data/margins2.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/moveTransitions.qml141
-rw-r--r--tests/auto/quick/qquicklistview/data/multipleTransitions.qml (renamed from tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/populateTransitions.qml (renamed from tests/auto/qtquick2/qquicklistview/data/populateTransitions.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/propertychangestest.qml (renamed from tests/auto/qtquick2/qquicklistview/data/propertychangestest.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/qtbug-21742.qml (renamed from tests/auto/qtquick2/qquicklistview/data/qtbug-21742.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/qtbug14821.qml (renamed from tests/auto/qtquick2/qquicklistview/data/qtbug14821.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/qtbug16037.qml (renamed from tests/auto/qtquick2/qquicklistview/data/qtbug16037.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/removeTransitions.qml144
-rw-r--r--tests/auto/quick/qquicklistview/data/resizeview.qml (renamed from tests/auto/qtquick2/qquicklistview/data/resizeview.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/rightToLeft.qml (renamed from tests/auto/qtquick2/qquicklistview/data/rightToLeft.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/sizelessthan1.qml (renamed from tests/auto/qtquick2/qquicklistview/data/sizelessthan1.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/snapOneItem.qml (renamed from tests/auto/qtquick2/qquicklistview/data/snapOneItem.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/snapToItem.qml (renamed from tests/auto/qtquick2/qquicklistview/data/snapToItem.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/strictlyenforcerange.qml (renamed from tests/auto/qtquick2/qquicklistview/data/strictlyenforcerange.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/data/unrequestedItems.qml (renamed from tests/auto/qtquick2/qquicklistview/data/unrequestedItems.qml)0
-rw-r--r--tests/auto/quick/qquicklistview/incrementalmodel.cpp (renamed from tests/auto/qtquick2/qquicklistview/incrementalmodel.cpp)0
-rw-r--r--tests/auto/quick/qquicklistview/incrementalmodel.h (renamed from tests/auto/qtquick2/qquicklistview/incrementalmodel.h)0
-rw-r--r--tests/auto/quick/qquicklistview/qquicklistview.pro16
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp5716
-rw-r--r--tests/auto/quick/qquickloader/data/ActiveComponent.qml (renamed from tests/auto/qtquick2/qquickloader/data/ActiveComponent.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/AnchoredLoader.qml (renamed from tests/auto/qtquick2/qquickloader/data/AnchoredLoader.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/BigComponent.qml (renamed from tests/auto/qtquick2/qquickloader/data/BigComponent.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/BlueRect.qml (renamed from tests/auto/qtquick2/qquickloader/data/BlueRect.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/CreationContextLoader.qml (renamed from tests/auto/qtquick2/qquickloader/data/CreationContextLoader.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/GraphicsWidget250x250.qml (renamed from tests/auto/qtquick2/qquickloader/data/GraphicsWidget250x250.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/GreenRect.qml (renamed from tests/auto/qtquick2/qquickloader/data/GreenRect.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/InitialPropertyValuesComponent.qml (renamed from tests/auto/qtquick2/qquickloader/data/InitialPropertyValuesComponent.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml (renamed from tests/auto/qtquick2/qquickloader/data/InvalidSourceComponent.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/NoResize.qml (renamed from tests/auto/qtquick2/qquickloader/data/NoResize.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/NoResizeGraphicsWidget.qml (renamed from tests/auto/qtquick2/qquickloader/data/NoResizeGraphicsWidget.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/QTBUG_16928.qml (renamed from tests/auto/qtquick2/qquickloader/data/QTBUG_16928.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/QTBUG_17114.qml (renamed from tests/auto/qtquick2/qquickloader/data/QTBUG_17114.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/Rect120x60.qml (renamed from tests/auto/qtquick2/qquickloader/data/Rect120x60.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/SetSourceComponent.qml (renamed from tests/auto/qtquick2/qquickloader/data/SetSourceComponent.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/SizeGraphicsWidgetToLoader.qml (renamed from tests/auto/qtquick2/qquickloader/data/SizeGraphicsWidgetToLoader.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/SizeLoaderToGraphicsWidget.qml (renamed from tests/auto/qtquick2/qquickloader/data/SizeLoaderToGraphicsWidget.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/SizeToItem.qml (renamed from tests/auto/qtquick2/qquickloader/data/SizeToItem.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/SizeToLoader.qml (renamed from tests/auto/qtquick2/qquickloader/data/SizeToLoader.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/VmeError.qml (renamed from tests/auto/qtquick2/qquickloader/data/VmeError.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/active.1.qml (renamed from tests/auto/qtquick2/qquickloader/data/active.1.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/active.2.qml (renamed from tests/auto/qtquick2/qquickloader/data/active.2.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/active.3.qml (renamed from tests/auto/qtquick2/qquickloader/data/active.3.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/active.4.qml (renamed from tests/auto/qtquick2/qquickloader/data/active.4.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/active.5.qml (renamed from tests/auto/qtquick2/qquickloader/data/active.5.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/active.6.qml (renamed from tests/auto/qtquick2/qquickloader/data/active.6.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/active.7.qml (renamed from tests/auto/qtquick2/qquickloader/data/active.7.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/active.8.qml (renamed from tests/auto/qtquick2/qquickloader/data/active.8.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/asynchronous.qml (renamed from tests/auto/qtquick2/qquickloader/data/asynchronous.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/crash.qml (renamed from tests/auto/qtquick2/qquickloader/data/crash.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/creationContext.qml (renamed from tests/auto/qtquick2/qquickloader/data/creationContext.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/differentorigin.qml (renamed from tests/auto/qtquick2/qquickloader/data/differentorigin.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/implicitSize.qml (renamed from tests/auto/qtquick2/qquickloader/data/implicitSize.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.1.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.1.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.2.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.2.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.3.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.3.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.4.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.4.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.5.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.5.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.6.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.6.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.7.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.7.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.8.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.8.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.binding.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.binding.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.error.1.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.1.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.error.2.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.2.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.error.3.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.3.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.error.4.qml (renamed from tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.4.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/nonItem.qml (renamed from tests/auto/qtquick2/qquickloader/data/nonItem.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/parented.qml (renamed from tests/auto/qtquick2/qquickloader/data/parented.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/qmldir (renamed from tests/auto/qtquick2/qquickloader/data/qmldir)0
-rw-r--r--tests/auto/quick/qquickloader/data/sameorigin-load.qml (renamed from tests/auto/qtquick2/qquickloader/data/sameorigin-load.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/sameorigin.qml (renamed from tests/auto/qtquick2/qquickloader/data/sameorigin.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/sizebound.qml (renamed from tests/auto/qtquick2/qquickloader/data/sizebound.qml)0
-rw-r--r--tests/auto/quick/qquickloader/data/vmeErrors.qml (renamed from tests/auto/qtquick2/qquickloader/data/vmeErrors.qml)0
-rw-r--r--tests/auto/quick/qquickloader/qquickloader.pro19
-rw-r--r--tests/auto/quick/qquickloader/tst_qquickloader.cpp987
-rw-r--r--tests/auto/quick/qquickmousearea/data/clickThrough.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/clickThrough.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/clickThrough2.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/clickThrough2.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/clickandhold.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/clickandhold.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/clicktwice.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/clicktwice.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/doubleclick.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/doubleclick.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/dragging.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/dragging.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/dragproperties.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/dragproperties.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/dragreset.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/dragreset.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/hoverPosition.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/hoverPosition.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/hoverPropagation.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/hoverPropagation.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/hoverVisible.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/hoverVisible.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/noclickandhold.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/noclickandhold.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/pressedCanceled.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/pressedCanceled.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/pressedOrdering.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/pressedOrdering.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/preventstealing.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/preventstealing.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/rejectEvent.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/rejectEvent.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/updateMousePosOnClick.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnClick.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/data/updateMousePosOnResize.qml (renamed from tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnResize.qml)0
-rw-r--r--tests/auto/quick/qquickmousearea/qquickmousearea.pro17
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp806
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/data/basic.qml (renamed from tests/auto/qtquick2/qquickmultipointtoucharea/data/basic.qml)0
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/data/inFlickable.qml (renamed from tests/auto/qtquick2/qquickmultipointtoucharea/data/inFlickable.qml)0
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/data/nested.qml (renamed from tests/auto/qtquick2/qquickmultipointtoucharea/data/nested.qml)0
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/data/nonOverlapping.qml (renamed from tests/auto/qtquick2/qquickmultipointtoucharea/data/nonOverlapping.qml)0
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/data/properties.qml (renamed from tests/auto/qtquick2/qquickmultipointtoucharea/data/properties.qml)0
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/data/signalTest.qml (renamed from tests/auto/qtquick2/qquickmultipointtoucharea/data/signalTest.qml)0
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/qquickmultipointtoucharea.pro11
-rw-r--r--tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp727
-rw-r--r--tests/auto/quick/qquickpath/data/arc.qml (renamed from tests/auto/qtquick2/qdeclarativepath/data/arc.qml)0
-rw-r--r--tests/auto/quick/qquickpath/data/closedcurve.qml (renamed from tests/auto/qtquick2/qdeclarativepath/data/closedcurve.qml)0
-rw-r--r--tests/auto/quick/qquickpath/data/curve.qml (renamed from tests/auto/qtquick2/qdeclarativepath/data/curve.qml)0
-rw-r--r--tests/auto/quick/qquickpath/data/svg.qml (renamed from tests/auto/qtquick2/qdeclarativepath/data/svg.qml)0
-rw-r--r--tests/auto/quick/qquickpath/qquickpath.pro15
-rw-r--r--tests/auto/quick/qquickpath/tst_qquickpath.cpp199
-rw-r--r--tests/auto/quick/qquickpathview/data/ComponentView.qml (renamed from tests/auto/qtquick2/qquickpathview/data/ComponentView.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/asyncloader.qml (renamed from tests/auto/qtquick2/qquickpathview/data/asyncloader.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/closedPath.qml (renamed from tests/auto/qtquick2/qquickpathview/data/closedPath.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/creationContext.qml (renamed from tests/auto/qtquick2/qquickpathview/data/creationContext.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/datamodel.qml (renamed from tests/auto/qtquick2/qquickpathview/data/datamodel.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/displaypath.qml (renamed from tests/auto/qtquick2/qquickpathview/data/displaypath.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/dragpath.qml (renamed from tests/auto/qtquick2/qquickpathview/data/dragpath.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/emptymodel.qml (renamed from tests/auto/qtquick2/qquickpathview/data/emptymodel.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/missingPercent.qml (renamed from tests/auto/qtquick2/qquickpathview/data/missingPercent.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/openPath.qml (renamed from tests/auto/qtquick2/qquickpathview/data/openPath.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathUpdate.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathUpdate.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathUpdateOnStartChanged.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathUpdateOnStartChanged.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathline.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathline.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathtest.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathtest.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathview0.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathview0.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathview1.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathview1.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathview2.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathview2.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathview3.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathview3.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/pathview_package.qml (renamed from tests/auto/qtquick2/qquickpathview/data/pathview_package.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/propertychanges.qml (renamed from tests/auto/qtquick2/qquickpathview/data/propertychanges.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/treemodel.qml (renamed from tests/auto/qtquick2/qquickpathview/data/treemodel.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/undefinedpath.qml (renamed from tests/auto/qtquick2/qquickpathview/data/undefinedpath.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/data/vdm.qml (renamed from tests/auto/qtquick2/qquickpathview/data/vdm.qml)0
-rw-r--r--tests/auto/quick/qquickpathview/qquickpathview.pro15
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp1458
-rw-r--r--tests/auto/quick/qquickpincharea/data/pinchproperties.qml (renamed from tests/auto/qtquick2/qquickpincharea/data/pinchproperties.qml)0
-rw-r--r--tests/auto/quick/qquickpincharea/qquickpincharea.pro15
-rw-r--r--tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp404
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/exists.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/exists.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/exists1.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/exists1.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/exists2.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/exists2.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists1.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists1.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists2.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists2.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists3.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists3.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists4.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists4.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists5.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists5.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists6.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists6.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists7.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists7.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/http/exists8.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists8.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/data/massive.png (renamed from tests/auto/qtquick2/qdeclarativepixmapcache/data/massive.png)bin31834 -> 31834 bytes
-rw-r--r--tests/auto/quick/qquickpixmapcache/qquickpixmapcache.pro21
-rw-r--r--tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp467
-rw-r--r--tests/auto/quick/qquickpositioners/data/allInvisible.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/allInvisible.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/attachedproperties-column.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/attachedproperties-column.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/attachedproperties-dynamic.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/attachedproperties-dynamic.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/attachedproperties-flow.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/attachedproperties-flow.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/attachedproperties-grid.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/attachedproperties-grid.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/attachedproperties-row.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/attachedproperties-row.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/flow-testimplicitsize.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/flow-testimplicitsize.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/flowtest-toptobottom.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/flowtest-toptobottom.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/flowtest.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/flowtest.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/grid-animated.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/grid-animated.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/grid-row-column-spacing.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/grid-row-column-spacing.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/grid-spacing.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/grid-spacing.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/grid-toptobottom.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/grid-toptobottom.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/gridtest.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/gridtest.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/gridzerocolumns.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/gridzerocolumns.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/horizontal-animated-disabled.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/horizontal-animated-disabled.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/horizontal-animated.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/horizontal-animated.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/horizontal-spacing.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/horizontal-spacing.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/horizontal.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/horizontal.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/propertychangestest.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/propertychangestest.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/rectangleComponent.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/rectangleComponent.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/repeatertest.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/repeatertest.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/vertical-animated.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/vertical-animated.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/vertical-spacing.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/vertical-spacing.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/data/vertical.qml (renamed from tests/auto/qtquick2/qquickpositioners/data/vertical.qml)0
-rw-r--r--tests/auto/quick/qquickpositioners/qquickpositioners.pro14
-rw-r--r--tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp1472
-rw-r--r--tests/auto/quick/qquickrepeater/data/asyncloader.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/asyncloader.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/data/initparent.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/initparent.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/data/intmodel.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/intmodel.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/data/itemlist.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/itemlist.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/data/modelChanged.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/modelChanged.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/data/objlist.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/objlist.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/data/properties.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/properties.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/data/repeater1.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/repeater1.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/data/repeater2.qml (renamed from tests/auto/qtquick2/qquickrepeater/data/repeater2.qml)0
-rw-r--r--tests/auto/quick/qquickrepeater/qquickrepeater.pro15
-rw-r--r--tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp644
-rw-r--r--tests/auto/quick/qquickscreen/data/screen.qml (renamed from tests/auto/qtquick2/qquickscreen/data/screen.qml)0
-rw-r--r--tests/auto/quick/qquickscreen/qquickscreen.pro10
-rw-r--r--tests/auto/quick/qquickscreen/tst_qquickscreen.cpp77
-rw-r--r--tests/auto/quick/qquickshadereffect/qquickshadereffect.pro8
-rw-r--r--tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp (renamed from tests/auto/qtquick2/qquickshadereffect/tst_qquickshadereffect.cpp)0
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/deleteOnUpdate.qml (renamed from tests/auto/qtquick2/qdeclarativesmoothedanimation/data/deleteOnUpdate.qml)0
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/simpleanimation.qml (renamed from tests/auto/qtquick2/qdeclarativesmoothedanimation/data/simpleanimation.qml)0
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation1.qml (renamed from tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation1.qml)0
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation2.qml (renamed from tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation2.qml)0
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation3.qml (renamed from tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation3.qml)0
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationBehavior.qml (renamed from tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml)0
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationValueSource.qml (renamed from tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml)0
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro15
-rw-r--r--tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp242
-rw-r--r--tests/auto/quick/qquickspringanimation/data/springanimation1.qml (renamed from tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation1.qml)0
-rw-r--r--tests/auto/quick/qquickspringanimation/data/springanimation2.qml (renamed from tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation2.qml)0
-rw-r--r--tests/auto/quick/qquickspringanimation/data/springanimation3.qml (renamed from tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation3.qml)0
-rw-r--r--tests/auto/quick/qquickspringanimation/qquickspringanimation.pro15
-rw-r--r--tests/auto/quick/qquickspringanimation/tst_qquickspringanimation.cpp133
-rw-r--r--tests/auto/quick/qquickspriteimage/data/advance.qml (renamed from tests/auto/qtquick2/qquickspriteimage/data/advance.qml)0
-rw-r--r--tests/auto/quick/qquickspriteimage/data/basic.qml (renamed from tests/auto/qtquick2/qquickspriteimage/data/basic.qml)0
-rw-r--r--tests/auto/quick/qquickspriteimage/data/squarefacesprite.png (renamed from tests/auto/qtquick2/qquickspriteimage/data/squarefacesprite.png)bin496 -> 496 bytes
-rw-r--r--tests/auto/quick/qquickspriteimage/qquickspriteimage.pro15
-rw-r--r--tests/auto/quick/qquickspriteimage/tst_qquickspriteimage.cpp98
-rw-r--r--tests/auto/quick/qquickstates/data/ExtendedRectangle.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/ExtendedRectangle.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/Implementation/MyType.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/Implementation/MyType.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/Implementation/images/qt-logo.png (renamed from tests/auto/qtquick2/qdeclarativestates/data/Implementation/images/qt-logo.png)bin5149 -> 5149 bytes
-rw-r--r--tests/auto/quick/qquickstates/data/QTBUG-14830.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/QTBUG-14830.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/anchorChanges1.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/anchorChanges1.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/anchorChanges2.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/anchorChanges2.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/anchorChanges3.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/anchorChanges3.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/anchorChanges4.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/anchorChanges4.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/anchorChanges5.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/anchorChanges5.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/anchorChangesCrash.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/anchorChangesCrash.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/anchorRewindBug.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/anchorRewindBug2.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug2.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/attachedPropertyChanges.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/attachedPropertyChanges.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/autoStateAtStartupRestoreBug.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/avoidFastForward.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/avoidFastForward.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicBinding.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicBinding.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicBinding2.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicBinding2.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicBinding3.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicBinding3.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicBinding4.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicBinding4.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicChanges.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicChanges.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicChanges2.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicChanges2.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicChanges3.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicChanges3.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicChanges4.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicChanges4.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/basicExtension.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/basicExtension.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/deleting.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/deleting.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/deletingState.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/deletingState.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/editProperties.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/editProperties.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/explicit.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/explicit.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/extendsBug.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/extendsBug.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/fakeExtension.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/fakeExtension.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/illegalObj.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/illegalObj.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/illegalTempState.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/illegalTempState.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/image.png (renamed from tests/auto/qtquick2/qdeclarativestates/data/image.png)bin173 -> 173 bytes
-rw-r--r--tests/auto/quick/qquickstates/data/legalTempState.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/legalTempState.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/nonExistantProp.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/nonExistantProp.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/parentChange1.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/parentChange1.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/parentChange2.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/parentChange2.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/parentChange3.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/parentChange3.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/parentChange4.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/parentChange4.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/parentChange5.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/parentChange5.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/parentChange6.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/parentChange6.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/propertyErrors.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/propertyErrors.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/reset.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/reset.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/restoreEntryValues.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/restoreEntryValues.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/returnToBase.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/returnToBase.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/revertListBug.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/revertListBug.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/script.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/script.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/signalOverride.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/signalOverride.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/signalOverride2.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/signalOverride2.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/signalOverrideCrash.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/signalOverrideCrash2.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash2.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/signalOverrideCrash3.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash3.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/unnamedWhen.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/unnamedWhen.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/urlResolution.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/urlResolution.qml)0
-rw-r--r--tests/auto/quick/qquickstates/data/whenOrdering.qml (renamed from tests/auto/qtquick2/qdeclarativestates/data/whenOrdering.qml)0
-rw-r--r--tests/auto/quick/qquickstates/qquickstates.pro14
-rw-r--r--tests/auto/quick/qquickstates/tst_qquickstates.cpp1608
-rw-r--r--tests/auto/quick/qquickstyledtext/qquickstyledtext.pro8
-rw-r--r--tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp185
-rw-r--r--tests/auto/quick/qquicksystempalette/qquicksystempalette.pro8
-rw-r--r--tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp185
-rw-r--r--tests/auto/quick/qquicktext/data/alignments.qml (renamed from tests/auto/qtquick2/qquicktext/data/alignments.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_cb.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_cb.png)bin496 -> 496 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_cc.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_cc.png)bin556 -> 556 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_ct.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_ct.png)bin533 -> 533 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_lb.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_lb.png)bin496 -> 496 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_lc.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_lc.png)bin535 -> 535 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_lt.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_lt.png)bin514 -> 514 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_rb.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_rb.png)bin505 -> 505 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_rc.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_rc.png)bin559 -> 559 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/alignments_rt.png (renamed from tests/auto/qtquick2/qquicktext/data/alignments_rt.png)bin539 -> 539 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/embeddedImagesLocal.qml (renamed from tests/auto/qtquick2/qquicktext/data/embeddedImagesLocal.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/embeddedImagesLocalError.qml (renamed from tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalError.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/embeddedImagesLocalRelative.qml (renamed from tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalRelative.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/embeddedImagesRemote.qml (renamed from tests/auto/qtquick2/qquicktext/data/embeddedImagesRemote.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/embeddedImagesRemoteError.qml (renamed from tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteError.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/embeddedImagesRemoteRelative.qml (renamed from tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteRelative.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/fontSizeMode.qml (renamed from tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/horizontalAlignment_RightToLeft.qml (renamed from tests/auto/qtquick2/qquicktext/data/horizontalAlignment_RightToLeft.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/http/exists.png (renamed from tests/auto/qtquick2/qquicktext/data/http/exists.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/images/face-sad.png (renamed from tests/auto/qtquick2/qquicktext/data/images/face-sad.png)bin6148 -> 6148 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/images/heart200.png (renamed from tests/auto/qtquick2/qquicktext/data/images/heart200.png)bin8248 -> 8248 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/images/starfish_2.png (renamed from tests/auto/qtquick2/qquicktext/data/images/starfish_2.png)bin18243 -> 18243 bytes
-rw-r--r--tests/auto/quick/qquicktext/data/imgTagsElide.qml (renamed from tests/auto/qtquick2/qquicktext/data/imgTagsElide.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/imgTagsUpdates.qml (renamed from tests/auto/qtquick2/qquicktext/data/imgTagsUpdates.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/lineCount.qml (renamed from tests/auto/qtquick2/qquicktext/data/lineCount.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/lineHeight.qml (renamed from tests/auto/qtquick2/qquicktext/data/lineHeight.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/lineLayout.qml (renamed from tests/auto/qtquick2/qquicktext/data/lineLayout.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/multilengthStrings.qml (renamed from tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/multilengthStringsWrapped.qml (renamed from tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/multilineelide.qml (renamed from tests/auto/qtquick2/qquicktext/data/multilineelide.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/qtbug_14734.qml (renamed from tests/auto/qtquick2/qquicktext/data/qtbug_14734.qml)0
-rw-r--r--tests/auto/quick/qquicktext/data/rotated.qml (renamed from tests/auto/qtquick2/qquicktext/data/rotated.qml)0
-rw-r--r--tests/auto/quick/qquicktext/qquicktext.pro19
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp2432
-rw-r--r--tests/auto/quick/qquicktextedit/data/Cursor.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/Cursor.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/CursorRect.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/CursorRect.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_cb.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_cb.png)bin496 -> 496 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_cc.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_cc.png)bin556 -> 556 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_ct.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_ct.png)bin533 -> 533 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_lb.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_lb.png)bin496 -> 496 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_lc.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_lc.png)bin535 -> 535 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_lt.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_lt.png)bin514 -> 514 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_rb.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_rb.png)bin505 -> 505 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_rc.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_rc.png)bin559 -> 559 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/alignments_rt.png (renamed from tests/auto/qtquick2/qquicktextedit/data/alignments_rt.png)bin539 -> 539 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/cursorTest.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/cursorTest.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/cursorTestExternal.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/cursorTestExternal.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/cursorTestInline.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/cursorTestInline.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/cursorVisible.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/cursorVisible.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/embeddedImagesLocal.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocal.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/embeddedImagesLocalError.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalError.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/embeddedImagesLocalRelative.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalRelative.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/embeddedImagesRemote.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemote.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteError.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteError.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteRelative.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteRelative.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/geometrySignals.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/geometrySignals.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/horizontalAlignment_RightToLeft.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/horizontalAlignment_RightToLeft.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/http/ErrItem.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/http/ErrItem.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/http/NormItem.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/http/NormItem.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/http/cursorHttpTest.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTest.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail1.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail1.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail2.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail2.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/http/cursorHttpTestPass.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestPass.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/http/exists.png (renamed from tests/auto/qtquick2/qquicktextedit/data/http/exists.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/quick/qquicktextedit/data/http/qmldir (renamed from tests/auto/qtquick2/qquicktextedit/data/http/qmldir)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/httpfail/FailItem.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/httpfail/FailItem.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/httpslow/WaitItem.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/httpslow/WaitItem.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/inputContext.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/inputContext.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/inputMethodEvent.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/inputMethodEvent.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/inputmethodhints.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/inputmethodhints.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/linkActivated.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/linkActivated.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/mouseselection_default.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/mouseselection_default.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/mouseselection_false.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/mouseselection_false.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/mouseselection_false_words.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/mouseselection_false_words.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/mouseselection_true.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/mouseselection_true.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/mouseselection_true_words.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/mouseselection_true_words.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/mouseselectionmode_characters.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_characters.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/mouseselectionmode_default.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_default.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/mouseselectionmode_words.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_words.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/navigation.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/navigation.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/openInputPanel.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/openInputPanel.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/persistentSelection.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/persistentSelection.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/positionAt.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/positionAt.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/qtbug-22058.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/qtbug-22058.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/data/readOnly.qml (renamed from tests/auto/qtquick2/qquicktextedit/data/readOnly.qml)0
-rw-r--r--tests/auto/quick/qquicktextedit/qquicktextedit.pro16
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp3884
-rw-r--r--tests/auto/quick/qquicktextinput/data/Cursor.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/Cursor.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/cursorTest.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/cursorTest.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/cursorTestExternal.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/cursorTestExternal.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/cursorTestInline.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/cursorTestInline.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/cursorVisible.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/cursorVisible.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/echoMode.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/echoMode.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/geometrySignals.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/geometrySignals.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/halign_center.png (renamed from tests/auto/qtquick2/qquicktextinput/data/halign_center.png)bin293 -> 293 bytes
-rw-r--r--tests/auto/quick/qquicktextinput/data/halign_left.png (renamed from tests/auto/qtquick2/qquicktextinput/data/halign_left.png)bin291 -> 291 bytes
-rw-r--r--tests/auto/quick/qquicktextinput/data/halign_right.png (renamed from tests/auto/qtquick2/qquicktextinput/data/halign_right.png)bin292 -> 292 bytes
-rw-r--r--tests/auto/quick/qquicktextinput/data/horizontalAlignment.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/horizontalAlignment_RightToLeft.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment_RightToLeft.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/inputContext.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/inputContext.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/inputMethodEvent.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/inputMethodEvent.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/inputmethods.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/inputmethods.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/masks.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/masks.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/maxLength.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/maxLength.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/mouseselection_true.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/mouseselection_true.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/mouseselectionmode_characters.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_characters.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/mouseselectionmode_default.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_default.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/mouseselectionmode_words.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_words.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/navigation.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/navigation.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/negativeDimensions.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/negativeDimensions.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/openInputPanel.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/openInputPanel.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/persistentSelection.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/persistentSelection.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/positionAt.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/positionAt.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/preeditAutoScroll.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/preeditAutoScroll.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/qtbug-19956double.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/qtbug-19956double.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/qtbug-19956int.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/qtbug-19956int.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/qtbug-19956regexp.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/qtbug-19956regexp.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/readOnly.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/readOnly.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/data/validators.qml (renamed from tests/auto/qtquick2/qquicktextinput/data/validators.qml)0
-rw-r--r--tests/auto/quick/qquicktextinput/qquicktextinput.pro13
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp4706
-rw-r--r--tests/auto/quick/qquicktimer/qquicktimer.pro8
-rw-r--r--tests/auto/quick/qquicktimer/tst_qquicktimer.cpp393
-rw-r--r--tests/auto/quick/qquickview/data/error1.qml (renamed from tests/auto/qtquick2/qquickview/data/error1.qml)0
-rw-r--r--tests/auto/quick/qquickview/data/resizemodeitem.qml (renamed from tests/auto/qtquick2/qquickview/data/resizemodeitem.qml)0
-rw-r--r--tests/auto/quick/qquickview/qquickview.pro13
-rw-r--r--tests/auto/quick/qquickview/tst_qquickview.cpp207
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/create.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/create.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/datalist-package.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/datalist-package.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/datalist.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/datalist.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/groups-invalid.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/groups-invalid.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/groups-package.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/groups-package.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/groups.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/groups.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_listView.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_listView.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_package.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_package.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties-package.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties-package.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/modelproperties.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/modelproperties2.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties2.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties-package.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties-package.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/objectlist.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/objectlist.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties-package.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties-package.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/onChanged.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/onChanged.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/packageView.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/packageView.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/singlerole1.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole1.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/singlerole2.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole2.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties-package.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties-package.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties-package.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties-package.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/data/visualdatamodel.qml (renamed from tests/auto/qtquick2/qquickvisualdatamodel/data/visualdatamodel.qml)0
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro16
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp3446
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/empty.xml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/empty.xml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/get.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/get.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/model.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/model.xml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.xml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/model2.xml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/model2.xml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/propertychanges.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/propertychanges.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/recipes.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/recipes.xml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.xml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/roleCrash.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleCrash.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/roleErrors.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleErrors.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/roleKeys.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleKeys.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/testtypes.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/testtypes.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/data/unique.qml (renamed from tests/auto/qtquick2/qdeclarativexmllistmodel/data/unique.qml)0
-rw-r--r--tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro15
-rw-r--r--tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp962
-rw-r--r--tests/auto/quick/quick.pro70
-rw-r--r--tests/auto/quick/rendernode/data/MessUpState.qml (renamed from tests/auto/qtquick2/rendernode/data/MessUpState.qml)0
-rw-r--r--tests/auto/quick/rendernode/data/RenderOrder.qml (renamed from tests/auto/qtquick2/rendernode/data/RenderOrder.qml)0
-rw-r--r--tests/auto/quick/rendernode/rendernode.pro18
-rw-r--r--tests/auto/quick/rendernode/tst_rendernode.cpp242
-rw-r--r--tests/auto/quick/shared/util.pri7
-rw-r--r--tests/auto/quick/shared/viewtestutil.cpp493
-rw-r--r--tests/auto/quick/shared/viewtestutil.h180
-rw-r--r--tests/auto/quick/shared/visualtestutil.cpp (renamed from tests/auto/qtquick2/shared/visualtestutil.cpp)0
-rw-r--r--tests/auto/quick/shared/visualtestutil.h112
-rw-r--r--tests/auto/shared/util.cpp32
-rw-r--r--tests/auto/shared/util.h24
-rw-r--r--tests/auto/shared/util.pri2
3564 files changed, 91884 insertions, 91883 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 367b2e724b..5012b5cdec 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -1,7 +1,7 @@
TEMPLATE=subdirs
SUBDIRS=\
- declarative \
- qtquick2 \
+ qml \
+ quick \
particles \
qmldevtools
diff --git a/tests/auto/compilerwarnings/data/test_cpp.txt b/tests/auto/compilerwarnings/data/test_cpp.txt
index c74bb20fdb..01b3bf9980 100644
--- a/tests/auto/compilerwarnings/data/test_cpp.txt
+++ b/tests/auto/compilerwarnings/data/test_cpp.txt
@@ -40,7 +40,7 @@
****************************************************************************/
#ifndef QT_NO_DECLARATIVE
-#include <QtDeclarative/QtDeclarative>
+#include <QtQml/QtQml>
#endif
#ifndef Q_OS_MAC
diff --git a/tests/auto/declarative/animation/qabstractanimationjob/qabstractanimationjob.pro b/tests/auto/declarative/animation/qabstractanimationjob/qabstractanimationjob.pro
deleted file mode 100644
index db8649bbb9..0000000000
--- a/tests/auto/declarative/animation/qabstractanimationjob/qabstractanimationjob.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG += testcase parallel_test
-macx:CONFIG -= app_bundle
-TARGET = tst_qabstractanimationjob
-QT = core-private declarative-private testlib
-SOURCES = tst_qabstractanimationjob.cpp
diff --git a/tests/auto/declarative/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp b/tests/auto/declarative/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp
deleted file mode 100644
index 772605d494..0000000000
--- a/tests/auto/declarative/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <QtDeclarative/private/qabstractanimationjob_p.h>
-#include <QtDeclarative/private/qanimationgroupjob_p.h>
-#include <QtTest>
-
-class tst_QAbstractAnimationJob : public QObject
-{
- Q_OBJECT
-private slots:
- void construction();
- void destruction();
- void currentLoop();
- void currentLoopTime();
- void currentTime();
- void direction();
- void group();
- void loopCount();
- void state();
- void totalDuration();
- void avoidJumpAtStart();
- void avoidJumpAtStartWithStop();
- void avoidJumpAtStartWithRunning();
-};
-
-class TestableQAbstractAnimation : public QAbstractAnimationJob
-{
-public:
- TestableQAbstractAnimation() : m_duration(10) {}
- virtual ~TestableQAbstractAnimation() {};
-
- int duration() const { return m_duration; }
- virtual void updateCurrentTime(int) {}
-
- void setDuration(int duration) { m_duration = duration; }
-private:
- int m_duration;
-};
-
-class DummyQAnimationGroup : public QAnimationGroupJob
-{
-public:
- int duration() const { return 10; }
- virtual void updateCurrentTime(int) {}
-};
-
-void tst_QAbstractAnimationJob::construction()
-{
- TestableQAbstractAnimation anim;
-}
-
-void tst_QAbstractAnimationJob::destruction()
-{
- TestableQAbstractAnimation *anim = new TestableQAbstractAnimation;
- delete anim;
-}
-
-void tst_QAbstractAnimationJob::currentLoop()
-{
- TestableQAbstractAnimation anim;
- QCOMPARE(anim.currentLoop(), 0);
-}
-
-void tst_QAbstractAnimationJob::currentLoopTime()
-{
- TestableQAbstractAnimation anim;
- QCOMPARE(anim.currentLoopTime(), 0);
-}
-
-void tst_QAbstractAnimationJob::currentTime()
-{
- TestableQAbstractAnimation anim;
- QCOMPARE(anim.currentTime(), 0);
- anim.setCurrentTime(10);
- QCOMPARE(anim.currentTime(), 10);
-}
-
-void tst_QAbstractAnimationJob::direction()
-{
- TestableQAbstractAnimation anim;
- QCOMPARE(anim.direction(), QAbstractAnimationJob::Forward);
- anim.setDirection(QAbstractAnimationJob::Backward);
- QCOMPARE(anim.direction(), QAbstractAnimationJob::Backward);
- anim.setDirection(QAbstractAnimationJob::Forward);
- QCOMPARE(anim.direction(), QAbstractAnimationJob::Forward);
-}
-
-void tst_QAbstractAnimationJob::group()
-{
- TestableQAbstractAnimation *anim = new TestableQAbstractAnimation;
- DummyQAnimationGroup group;
- group.appendAnimation(anim);
- QCOMPARE(anim->group(), &group);
-}
-
-void tst_QAbstractAnimationJob::loopCount()
-{
- TestableQAbstractAnimation anim;
- QCOMPARE(anim.loopCount(), 1);
- anim.setLoopCount(10);
- QCOMPARE(anim.loopCount(), 10);
-}
-
-void tst_QAbstractAnimationJob::state()
-{
- TestableQAbstractAnimation anim;
- QCOMPARE(anim.state(), QAbstractAnimationJob::Stopped);
-}
-
-void tst_QAbstractAnimationJob::totalDuration()
-{
- TestableQAbstractAnimation anim;
- QCOMPARE(anim.duration(), 10);
- anim.setLoopCount(5);
- QCOMPARE(anim.totalDuration(), 50);
-}
-
-void tst_QAbstractAnimationJob::avoidJumpAtStart()
-{
- TestableQAbstractAnimation anim;
- anim.setDuration(1000);
-
- /*
- the timer shouldn't actually start until we hit the event loop,
- so the sleep should have no effect
- */
- anim.start();
- QTest::qSleep(300);
- QCoreApplication::processEvents();
- QVERIFY(anim.currentTime() < 50);
-}
-
-void tst_QAbstractAnimationJob::avoidJumpAtStartWithStop()
-{
- TestableQAbstractAnimation anim;
- anim.setDuration(1000);
-
- TestableQAbstractAnimation anim2;
- anim2.setDuration(1000);
-
- TestableQAbstractAnimation anim3;
- anim3.setDuration(1000);
-
- anim.start();
- QTest::qWait(300);
- anim.stop();
-
- /*
- same test as avoidJumpAtStart, but after there is a
- running animation that is stopped
- */
- anim2.start();
- QTest::qSleep(300);
- anim3.start();
- QCoreApplication::processEvents();
- QVERIFY(anim2.currentTime() < 50);
- QVERIFY(anim3.currentTime() < 50);
-}
-
-void tst_QAbstractAnimationJob::avoidJumpAtStartWithRunning()
-{
- TestableQAbstractAnimation anim;
- anim.setDuration(2000);
-
- TestableQAbstractAnimation anim2;
- anim2.setDuration(1000);
-
- TestableQAbstractAnimation anim3;
- anim3.setDuration(1000);
-
- anim.start();
- QTest::qWait(300); //make sure timer has started
-
- /*
- same test as avoidJumpAtStart, but with an
- existing running animation
- */
- anim2.start();
- QTest::qSleep(300); //force large delta for next tick
- anim3.start();
- QCoreApplication::processEvents();
- QVERIFY(anim2.currentTime() < 50);
- QVERIFY(anim3.currentTime() < 50);
-}
-
-
-QTEST_MAIN(tst_QAbstractAnimationJob)
-
-#include "tst_qabstractanimationjob.moc"
diff --git a/tests/auto/declarative/animation/qanimationgroupjob/qanimationgroupjob.pro b/tests/auto/declarative/animation/qanimationgroupjob/qanimationgroupjob.pro
deleted file mode 100644
index b9c9d2921d..0000000000
--- a/tests/auto/declarative/animation/qanimationgroupjob/qanimationgroupjob.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG += testcase parallel_test
-macx:CONFIG -= app_bundle
-TARGET = tst_qanimationgroupjob
-QT = core-private declarative-private testlib
-SOURCES = tst_qanimationgroupjob.cpp
diff --git a/tests/auto/declarative/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp b/tests/auto/declarative/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp
deleted file mode 100644
index 2bb974af7d..0000000000
--- a/tests/auto/declarative/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp
+++ /dev/null
@@ -1,310 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-
-#include <QtDeclarative/private/qanimationgroupjob_p.h>
-#include <QtDeclarative/private/qsequentialanimationgroupjob_p.h>
-#include <QtDeclarative/private/qparallelanimationgroupjob_p.h>
-
-Q_DECLARE_METATYPE(QAbstractAnimationJob::State)
-
-class tst_QAnimationGroupJob : public QObject
-{
- Q_OBJECT
-public Q_SLOTS:
- void initTestCase();
-
-private slots:
- void construction();
- void emptyGroup();
- void setCurrentTime();
- void addChildTwice();
-};
-
-void tst_QAnimationGroupJob::initTestCase()
-{
- qRegisterMetaType<QAbstractAnimationJob::State>("QAbstractAnimationJob::State");
-}
-
-void tst_QAnimationGroupJob::construction()
-{
- QSequentialAnimationGroupJob animationgroup;
-}
-
-class TestableGenericAnimation : public QAbstractAnimationJob
-{
-public:
- TestableGenericAnimation(int duration = 250) : m_duration(duration) {}
- int duration() const { return m_duration; }
-
-private:
- int m_duration;
-};
-
-class UncontrolledAnimation : public QObject, public QAbstractAnimationJob
-{
- Q_OBJECT
-public:
- UncontrolledAnimation()
- : id(0)
- {
- }
-
- int duration() const { return -1; /* not time driven */ }
-
-protected:
- void timerEvent(QTimerEvent *event)
- {
- if (event->timerId() == id)
- stop();
- }
-
- void updateRunning(bool running)
- {
- if (running) {
- id = startTimer(500);
- } else {
- killTimer(id);
- id = 0;
- }
- }
-
-private:
- int id;
-};
-
-class StateChangeListener: public QAnimationJobChangeListener
-{
-public:
- virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State)
- {
- states << newState;
- }
-
- int count()
- {
- return states.count();
- }
-
- QList<QAbstractAnimationJob::State> states;
-};
-
-void tst_QAnimationGroupJob::emptyGroup()
-{
- QSequentialAnimationGroupJob group;
- StateChangeListener groupStateChangedSpy;
- group.addAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- group.start();
-
- QCOMPARE(groupStateChangedSpy.count(), 2);
-
- QCOMPARE(groupStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(groupStateChangedSpy.states.at(1), QAnimationGroupJob::Stopped);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
-
- QTest::ignoreMessage(QtWarningMsg, "QAbstractAnimationJob::pause: Cannot pause a stopped animation");
- group.pause();
-
- QCOMPARE(groupStateChangedSpy.count(), 2);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
-
- group.start();
-
- QCOMPARE(groupStateChangedSpy.states.at(2),
- QAnimationGroupJob::Running);
- QCOMPARE(groupStateChangedSpy.states.at(3),
- QAnimationGroupJob::Stopped);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
-
- group.stop();
-
- QCOMPARE(groupStateChangedSpy.count(), 4);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
-}
-
-void tst_QAnimationGroupJob::setCurrentTime()
-{
- // was originally sequence operating on same object/property
- QSequentialAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
- QAbstractAnimationJob *a1_s_o1 = new TestableGenericAnimation;
- QAbstractAnimationJob *a2_s_o1 = new TestableGenericAnimation;
- QAbstractAnimationJob *a3_s_o1 = new TestableGenericAnimation;
- a2_s_o1->setLoopCount(3);
- sequence->appendAnimation(a1_s_o1);
- sequence->appendAnimation(a2_s_o1);
- sequence->appendAnimation(a3_s_o1);
-
- // was originally sequence operating on different object/properties
- QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob();
- QAbstractAnimationJob *a1_s_o2 = new TestableGenericAnimation;
- QAbstractAnimationJob *a1_s_o3 = new TestableGenericAnimation;
- sequence2->appendAnimation(a1_s_o2);
- sequence2->appendAnimation(a1_s_o3);
-
- // was originally parallel operating on different object/properties
- QAnimationGroupJob *parallel = new QParallelAnimationGroupJob();
- QAbstractAnimationJob *a1_p_o1 = new TestableGenericAnimation;
- QAbstractAnimationJob *a1_p_o2 = new TestableGenericAnimation;
- QAbstractAnimationJob *a1_p_o3 = new TestableGenericAnimation;
- a1_p_o2->setLoopCount(3);
- parallel->appendAnimation(a1_p_o1);
- parallel->appendAnimation(a1_p_o2);
- parallel->appendAnimation(a1_p_o3);
-
- QAbstractAnimationJob *notTimeDriven = new UncontrolledAnimation;
- QCOMPARE(notTimeDriven->totalDuration(), -1);
-
- QAbstractAnimationJob *loopsForever = new TestableGenericAnimation;
- loopsForever->setLoopCount(-1);
- QCOMPARE(loopsForever->totalDuration(), -1);
-
- QParallelAnimationGroupJob group;
- group.appendAnimation(sequence);
- group.appendAnimation(sequence2);
- group.appendAnimation(parallel);
- group.appendAnimation(notTimeDriven);
- group.appendAnimation(loopsForever);
-
- // Current time = 1
- group.setCurrentTime(1);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(parallel->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_p_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_p_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_p_o3->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
-
- QCOMPARE(group.currentLoopTime(), 1);
- QCOMPARE(sequence->currentLoopTime(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 1);
- QCOMPARE(a2_s_o1->currentLoopTime(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 1);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
- QCOMPARE(a1_p_o1->currentLoopTime(), 1);
- QCOMPARE(a1_p_o2->currentLoopTime(), 1);
- QCOMPARE(a1_p_o3->currentLoopTime(), 1);
- QCOMPARE(notTimeDriven->currentLoopTime(), 1);
- QCOMPARE(loopsForever->currentLoopTime(), 1);
-
- // Current time = 250
- group.setCurrentTime(250);
- QCOMPARE(group.currentLoopTime(), 250);
- QCOMPARE(sequence->currentLoopTime(), 250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
- QCOMPARE(a1_p_o1->currentLoopTime(), 250);
- QCOMPARE(a1_p_o2->currentLoopTime(), 0);
- QCOMPARE(a1_p_o2->currentLoop(), 1);
- QCOMPARE(a1_p_o3->currentLoopTime(), 250);
- QCOMPARE(notTimeDriven->currentLoopTime(), 250);
- QCOMPARE(loopsForever->currentLoopTime(), 0);
- QCOMPARE(loopsForever->currentLoop(), 1);
- QCOMPARE(sequence->currentAnimation(), a2_s_o1);
-
- // Current time = 251
- group.setCurrentTime(251);
- QCOMPARE(group.currentLoopTime(), 251);
- QCOMPARE(sequence->currentLoopTime(), 251);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 1);
- QCOMPARE(a2_s_o1->currentLoop(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(sequence2->currentLoopTime(), 251);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 1);
- QCOMPARE(a1_p_o1->currentLoopTime(), 250);
- QCOMPARE(a1_p_o2->currentLoopTime(), 1);
- QCOMPARE(a1_p_o2->currentLoop(), 1);
- QCOMPARE(a1_p_o3->currentLoopTime(), 250);
- QCOMPARE(notTimeDriven->currentLoopTime(), 251);
- QCOMPARE(loopsForever->currentLoopTime(), 1);
- QCOMPARE(sequence->currentAnimation(), a2_s_o1);
-}
-
-void tst_QAnimationGroupJob::addChildTwice()
-{
- QAbstractAnimationJob *subGroup;
- QAbstractAnimationJob *subGroup2;
- QAnimationGroupJob *parent = new QSequentialAnimationGroupJob();
-
- subGroup = new QAbstractAnimationJob;
- parent->appendAnimation(subGroup);
- parent->appendAnimation(subGroup);
- QVERIFY(parent->firstChild() && !parent->firstChild()->nextSibling());
-
- parent->clear();
-
- QVERIFY(!parent->firstChild());
-
- // adding the same item twice to a group will remove the item from its current position
- // and append it to the end
- subGroup = new QAbstractAnimationJob;
- parent->appendAnimation(subGroup);
- subGroup2 = new QAbstractAnimationJob;
- parent->appendAnimation(subGroup2);
-
- QCOMPARE(parent->firstChild(), subGroup);
- QCOMPARE(parent->lastChild(), subGroup2);
-
- parent->appendAnimation(subGroup);
-
- QCOMPARE(parent->firstChild(), subGroup2);
- QCOMPARE(parent->lastChild(), subGroup);
-
- delete parent;
-}
-
-QTEST_MAIN(tst_QAnimationGroupJob)
-#include "tst_qanimationgroupjob.moc"
diff --git a/tests/auto/declarative/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro b/tests/auto/declarative/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro
deleted file mode 100644
index 332fa4554b..0000000000
--- a/tests/auto/declarative/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG += testcase
-macx:CONFIG -= app_bundle
-TARGET = tst_qparallelanimationgroupjob
-QT = core-private gui declarative-private testlib
-SOURCES = tst_qparallelanimationgroupjob.cpp
diff --git a/tests/auto/declarative/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp b/tests/auto/declarative/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
deleted file mode 100644
index ef24182115..0000000000
--- a/tests/auto/declarative/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
+++ /dev/null
@@ -1,931 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-
-#include <QtDeclarative/private/qparallelanimationgroupjob_p.h>
-
-Q_DECLARE_METATYPE(QAbstractAnimationJob::State)
-
-class tst_QParallelAnimationGroupJob : public QObject
-{
- Q_OBJECT
-public Q_SLOTS:
- void initTestCase();
-
-private slots:
- void construction();
- void setCurrentTime();
- void stateChanged();
- void clearGroup();
- void propagateGroupUpdateToChildren();
- void updateChildrenWithRunningGroup();
- void deleteChildrenWithRunningGroup();
- void startChildrenWithStoppedGroup();
- void stopGroupWithRunningChild();
- void startGroupWithRunningChild();
- void zeroDurationAnimation();
- void stopUncontrolledAnimations();
- void loopCount_data();
- void loopCount();
- void addAndRemoveDuration();
- void pauseResume();
-
- void crashWhenRemovingUncontrolledAnimation();
-};
-
-void tst_QParallelAnimationGroupJob::initTestCase()
-{
- qRegisterMetaType<QAbstractAnimationJob::State>("QAbstractAnimationJob::State");
-#if defined(Q_OS_MAC) || defined(Q_OS_WINCE)
- // give the mac/wince app start event queue time to clear
- QTest::qWait(1000);
-#endif
-}
-
-void tst_QParallelAnimationGroupJob::construction()
-{
- QParallelAnimationGroupJob animationgroup;
-}
-
-class TestAnimation : public QAbstractAnimationJob
-{
-public:
- TestAnimation(int duration = 250) : m_duration(duration) {}
- int duration() const { return m_duration; }
-
-private:
- int m_duration;
-};
-
-class UncontrolledAnimation : public QObject, public QAbstractAnimationJob
-{
- Q_OBJECT
-public:
- UncontrolledAnimation()
- : id(0)
- {
- }
-
- int duration() const { return -1; /* not time driven */ }
-
-protected:
- void timerEvent(QTimerEvent *event)
- {
- if (event->timerId() == id)
- stop();
- }
-
- void updateRunning(bool running)
- {
- if (running) {
- id = startTimer(500);
- } else {
- killTimer(id);
- id = 0;
- }
- }
-
-private:
- int id;
-};
-
-class StateChangeListener: public QAnimationJobChangeListener
-{
-public:
- virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State)
- {
- states << newState;
- }
-
- void clear() { states.clear(); }
- int count() { return states.count(); }
-
- QList<QAbstractAnimationJob::State> states;
-};
-
-class FinishedListener: public QAnimationJobChangeListener
-{
-public:
- FinishedListener() : m_count(0) {}
-
- virtual void animationFinished(QAbstractAnimationJob *) { ++m_count; }
- void clear() { m_count = 0; }
- int count() { return m_count; }
-
-private:
- int m_count;
-};
-
-void tst_QParallelAnimationGroupJob::setCurrentTime()
-{
- // originally was parallel operating on different object/properties
- QAnimationGroupJob *parallel = new QParallelAnimationGroupJob();
- TestAnimation *a1_p_o1 = new TestAnimation;
- TestAnimation *a1_p_o2 = new TestAnimation;
- TestAnimation *a1_p_o3 = new TestAnimation;
- a1_p_o2->setLoopCount(3);
- parallel->appendAnimation(a1_p_o1);
- parallel->appendAnimation(a1_p_o2);
- parallel->appendAnimation(a1_p_o3);
-
- UncontrolledAnimation *notTimeDriven = new UncontrolledAnimation;
- QCOMPARE(notTimeDriven->totalDuration(), -1);
-
- TestAnimation *loopsForever = new TestAnimation;
- loopsForever->setLoopCount(-1);
- QCOMPARE(loopsForever->totalDuration(), -1);
-
- QParallelAnimationGroupJob group;
- group.appendAnimation(parallel);
- group.appendAnimation(notTimeDriven);
- group.appendAnimation(loopsForever);
-
- // Current time = 1
- group.setCurrentTime(1);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(parallel->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_p_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_p_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_p_o3->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
-
- QCOMPARE(group.currentLoopTime(), 1);
- QCOMPARE(a1_p_o1->currentLoopTime(), 1);
- QCOMPARE(a1_p_o2->currentLoopTime(), 1);
- QCOMPARE(a1_p_o3->currentLoopTime(), 1);
- QCOMPARE(notTimeDriven->currentLoopTime(), 1);
- QCOMPARE(loopsForever->currentLoopTime(), 1);
-
- // Current time = 250
- group.setCurrentTime(250);
- QCOMPARE(group.currentLoopTime(), 250);
- QCOMPARE(a1_p_o1->currentLoopTime(), 250);
- QCOMPARE(a1_p_o2->currentLoopTime(), 0);
- QCOMPARE(a1_p_o2->currentLoop(), 1);
- QCOMPARE(a1_p_o3->currentLoopTime(), 250);
- QCOMPARE(notTimeDriven->currentLoopTime(), 250);
- QCOMPARE(loopsForever->currentLoopTime(), 0);
- QCOMPARE(loopsForever->currentLoop(), 1);
-
- // Current time = 251
- group.setCurrentTime(251);
- QCOMPARE(group.currentLoopTime(), 251);
- QCOMPARE(a1_p_o1->currentLoopTime(), 250);
- QCOMPARE(a1_p_o2->currentLoopTime(), 1);
- QCOMPARE(a1_p_o2->currentLoop(), 1);
- QCOMPARE(a1_p_o3->currentLoopTime(), 250);
- QCOMPARE(notTimeDriven->currentLoopTime(), 251);
- QCOMPARE(loopsForever->currentLoopTime(), 1);
-}
-
-void tst_QParallelAnimationGroupJob::stateChanged()
-{
- //this ensures that the correct animations are started when starting the group
- TestAnimation *anim1 = new TestAnimation(1000);
- TestAnimation *anim2 = new TestAnimation(2000);
- TestAnimation *anim3 = new TestAnimation(3000);
- TestAnimation *anim4 = new TestAnimation(3000);
-
- QParallelAnimationGroupJob group;
- group.appendAnimation(anim1);
- group.appendAnimation(anim2);
- group.appendAnimation(anim3);
- group.appendAnimation(anim4);
-
- StateChangeListener spy1;
- anim1->addAnimationChangeListener(&spy1, QAbstractAnimationJob::StateChange);
- StateChangeListener spy2;
- anim2->addAnimationChangeListener(&spy2, QAbstractAnimationJob::StateChange);
- StateChangeListener spy3;
- anim3->addAnimationChangeListener(&spy3, QAbstractAnimationJob::StateChange);
- StateChangeListener spy4;
- anim4->addAnimationChangeListener(&spy4, QAbstractAnimationJob::StateChange);
-
- //first; let's start forward
- group.start();
- //all the animations should be started
- QCOMPARE(spy1.count(), 1);
- QCOMPARE(spy1.states.last(), TestAnimation::Running);
- QCOMPARE(spy2.count(), 1);
- QCOMPARE(spy2.states.last(), TestAnimation::Running);
- QCOMPARE(spy3.count(), 1);
- QCOMPARE(spy3.states.last(), TestAnimation::Running);
- QCOMPARE(spy4.count(), 1);
- QCOMPARE(spy4.states.last(), TestAnimation::Running);
-
- group.setCurrentTime(1500); //anim1 should be finished
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(spy1.count(), 2);
- QCOMPARE(spy1.states.last(), TestAnimation::Stopped);
- QCOMPARE(spy2.count(), 1); //no change
- QCOMPARE(spy3.count(), 1); //no change
- QCOMPARE(spy4.count(), 1); //no change
-
- group.setCurrentTime(2500); //anim2 should be finished
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(spy1.count(), 2); //no change
- QCOMPARE(spy2.count(), 2);
- QCOMPARE(spy2.states.last(), TestAnimation::Stopped);
- QCOMPARE(spy3.count(), 1); //no change
- QCOMPARE(spy4.count(), 1); //no change
-
- group.setCurrentTime(3500); //everything should be finished
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(spy1.count(), 2); //no change
- QCOMPARE(spy2.count(), 2); //no change
- QCOMPARE(spy3.count(), 2);
- QCOMPARE(spy3.states.last(), TestAnimation::Stopped);
- QCOMPARE(spy4.count(), 2);
- QCOMPARE(spy4.states.last(), TestAnimation::Stopped);
-
- //cleanup
- spy1.clear();
- spy2.clear();
- spy3.clear();
- spy4.clear();
-
- //now let's try to reverse that
- group.setDirection(QAbstractAnimationJob::Backward);
- group.start();
-
- //only anim3 and anim4 should be started
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(spy1.count(), 0);
- QCOMPARE(spy2.count(), 0);
- QCOMPARE(spy3.count(), 1);
- QCOMPARE(spy3.states.last(), TestAnimation::Running);
- QCOMPARE(spy4.count(), 1);
- QCOMPARE(spy4.states.last(), TestAnimation::Running);
-
- group.setCurrentTime(1500); //anim2 should be started
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(spy1.count(), 0); //no change
- QCOMPARE(spy2.count(), 1);
- QCOMPARE(spy2.states.last(), TestAnimation::Running);
- QCOMPARE(spy3.count(), 1); //no change
- QCOMPARE(spy4.count(), 1); //no change
-
- group.setCurrentTime(500); //anim1 is finally also started
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(spy1.count(), 1);
- QCOMPARE(spy1.states.last(), TestAnimation::Running);
- QCOMPARE(spy2.count(), 1); //no change
- QCOMPARE(spy3.count(), 1); //no change
- QCOMPARE(spy4.count(), 1); //no change
-
- group.setCurrentTime(0); //everything should be stopped
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(spy1.count(), 2);
- QCOMPARE(spy1.states.last(), TestAnimation::Stopped);
- QCOMPARE(spy2.count(), 2);
- QCOMPARE(spy2.states.last(), TestAnimation::Stopped);
- QCOMPARE(spy3.count(), 2);
- QCOMPARE(spy3.states.last(), TestAnimation::Stopped);
- QCOMPARE(spy4.count(), 2);
- QCOMPARE(spy4.states.last(), TestAnimation::Stopped);
-}
-
-void tst_QParallelAnimationGroupJob::clearGroup()
-{
- QParallelAnimationGroupJob group;
- static const int animationCount = 10;
-
- for (int i = 0; i < animationCount; ++i) {
- group.appendAnimation(new QParallelAnimationGroupJob);
- }
-
- int count = 0;
- for (QAbstractAnimationJob *anim = group.firstChild(); anim; anim = anim->nextSibling())
- ++count;
- QCOMPARE(count, animationCount);
-
- group.clear();
-
- QVERIFY(!group.firstChild() && !group.lastChild());
- QCOMPARE(group.currentLoopTime(), 0);
-}
-
-void tst_QParallelAnimationGroupJob::propagateGroupUpdateToChildren()
-{
- // this test verifies if group state changes are updating its children correctly
- QParallelAnimationGroupJob group;
-
- TestAnimation anim1(100);
- TestAnimation anim2(200);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
-
- group.start();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Running);
-
- group.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Paused);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
-
- group.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-}
-
-void tst_QParallelAnimationGroupJob::updateChildrenWithRunningGroup()
-{
- // assert that its possible to modify a child's state directly while their group is running
- QParallelAnimationGroupJob group;
-
- TestAnimation anim(200);
-
- StateChangeListener groupStateChangedSpy;
- group.addAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
- StateChangeListener childStateChangedSpy;
- anim.addAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange);
-
- QCOMPARE(groupStateChangedSpy.count(), 0);
- QCOMPARE(childStateChangedSpy.count(), 0);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim);
-
- group.start();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim.state(), QAnimationGroupJob::Running);
-
- QCOMPARE(groupStateChangedSpy.count(), 1);
- QCOMPARE(childStateChangedSpy.count(), 1);
-
- QCOMPARE(groupStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(childStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
-
- // starting directly a running child will not have any effect
- anim.start();
-
- QCOMPARE(groupStateChangedSpy.count(), 1);
- QCOMPARE(childStateChangedSpy.count(), 1);
-
- anim.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim.state(), QAnimationGroupJob::Paused);
-
- // in the animation stops directly, the group will still be running
- anim.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim.state(), QAnimationGroupJob::Stopped);
-
- //cleanup
- group.removeAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
- anim.removeAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange);
-}
-
-void tst_QParallelAnimationGroupJob::deleteChildrenWithRunningGroup()
-{
- // test if children can be activated when their group is stopped
- QParallelAnimationGroupJob group;
-
- TestAnimation *anim1 = new TestAnimation(200);
- group.appendAnimation(anim1);
-
- QCOMPARE(group.duration(), anim1->duration());
-
- group.start();
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim1->state(), QAnimationGroupJob::Running);
-
- QTest::qWait(80);
- QVERIFY(group.currentLoopTime() > 0);
-
- delete anim1;
- QVERIFY(!group.firstChild());
- QCOMPARE(group.duration(), 0);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(group.currentLoopTime(), 0); //that's the invariant
-}
-
-void tst_QParallelAnimationGroupJob::startChildrenWithStoppedGroup()
-{
- // test if children can be activated when their group is stopped
- QParallelAnimationGroupJob group;
-
- TestAnimation anim1(200);
- TestAnimation anim2(200);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
-
- group.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- anim1.start();
- anim2.start();
- anim2.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
-}
-
-void tst_QParallelAnimationGroupJob::stopGroupWithRunningChild()
-{
- // children that started independently will not be affected by a group stop
- QParallelAnimationGroupJob group;
-
- TestAnimation anim1(200);
- TestAnimation anim2(200);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
-
- anim1.start();
- anim2.start();
- anim2.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
-
- group.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
-
- anim1.stop();
- anim2.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-}
-
-void tst_QParallelAnimationGroupJob::startGroupWithRunningChild()
-{
- // as the group has precedence over its children, starting a group will restart all the children
- QParallelAnimationGroupJob group;
-
- TestAnimation anim1(200);
- TestAnimation anim2(200);
-
- StateChangeListener stateChangedSpy1;
- anim1.addAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
- StateChangeListener stateChangedSpy2;
- anim2.addAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
-
- QCOMPARE(stateChangedSpy1.count(), 0);
- QCOMPARE(stateChangedSpy2.count(), 0);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
-
- anim1.start();
- anim2.start();
- anim2.pause();
-
- QCOMPARE(stateChangedSpy1.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(stateChangedSpy2.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(stateChangedSpy2.states.at(1), QAnimationGroupJob::Paused);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
-
- group.start();
-
- QCOMPARE(stateChangedSpy1.count(), 3);
- QCOMPARE(stateChangedSpy1.states.at(1), QAnimationGroupJob::Stopped);
- QCOMPARE(stateChangedSpy1.states.at(2), QAnimationGroupJob::Running);
-
- QCOMPARE(stateChangedSpy2.count(), 4);
- QCOMPARE(stateChangedSpy2.states.at(2), QAnimationGroupJob::Stopped);
- QCOMPARE(stateChangedSpy2.states.at(3), QAnimationGroupJob::Running);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Running);
-
- //cleanup
- anim1.removeAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
- anim2.removeAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
-}
-
-void tst_QParallelAnimationGroupJob::zeroDurationAnimation()
-{
- QParallelAnimationGroupJob group;
-
- TestAnimation anim1(0);
- TestAnimation anim2(100);
- TestAnimation anim3(10);
-
- StateChangeListener stateChangedSpy1;
- anim1.addAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
- FinishedListener finishedSpy1;
- anim1.addAnimationChangeListener(&finishedSpy1, QAbstractAnimationJob::Completion);
-
- StateChangeListener stateChangedSpy2;
- anim2.addAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
- FinishedListener finishedSpy2;
- anim2.addAnimationChangeListener(&finishedSpy2, QAbstractAnimationJob::Completion);
-
- StateChangeListener stateChangedSpy3;
- anim3.addAnimationChangeListener(&stateChangedSpy3, QAbstractAnimationJob::StateChange);
- FinishedListener finishedSpy3;
- anim3.addAnimationChangeListener(&finishedSpy3, QAbstractAnimationJob::Completion);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
- group.appendAnimation(&anim3);
- QCOMPARE(stateChangedSpy1.count(), 0);
- group.start();
- QCOMPARE(stateChangedSpy1.count(), 2);
- QCOMPARE(finishedSpy1.count(), 1);
- QCOMPARE(stateChangedSpy1.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(stateChangedSpy1.states.at(1), QAnimationGroupJob::Stopped);
-
- QCOMPARE(stateChangedSpy2.count(), 1);
- QCOMPARE(finishedSpy2.count(), 0);
- QCOMPARE(stateChangedSpy1.states.at(0), QAnimationGroupJob::Running);
-
- QCOMPARE(stateChangedSpy3.count(), 1);
- QCOMPARE(finishedSpy3.count(), 0);
- QCOMPARE(stateChangedSpy3.states.at(0), QAnimationGroupJob::Running);
-
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim3.state(), QAnimationGroupJob::Running);
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
-
- group.stop();
- group.setLoopCount(4);
- stateChangedSpy1.clear();
- stateChangedSpy2.clear();
- stateChangedSpy3.clear();
-
- group.start();
- QCOMPARE(stateChangedSpy1.count(), 2);
- QCOMPARE(stateChangedSpy2.count(), 1);
- QCOMPARE(stateChangedSpy3.count(), 1);
- group.setCurrentTime(50);
- QCOMPARE(stateChangedSpy1.count(), 2);
- QCOMPARE(stateChangedSpy2.count(), 1);
- QCOMPARE(stateChangedSpy3.count(), 2);
- group.setCurrentTime(150);
- QCOMPARE(stateChangedSpy1.count(), 4);
- QCOMPARE(stateChangedSpy2.count(), 3);
- QCOMPARE(stateChangedSpy3.count(), 4);
- group.setCurrentTime(50);
- QCOMPARE(stateChangedSpy1.count(), 6);
- QCOMPARE(stateChangedSpy2.count(), 5);
- QCOMPARE(stateChangedSpy3.count(), 6);
-
- //cleanup
- anim1.removeAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
- anim1.removeAnimationChangeListener(&finishedSpy1, QAbstractAnimationJob::Completion);
- anim2.removeAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
- anim2.removeAnimationChangeListener(&finishedSpy2, QAbstractAnimationJob::Completion);
- anim3.removeAnimationChangeListener(&stateChangedSpy3, QAbstractAnimationJob::StateChange);
- anim3.removeAnimationChangeListener(&finishedSpy3, QAbstractAnimationJob::Completion);
-}
-
-void tst_QParallelAnimationGroupJob::stopUncontrolledAnimations()
-{
- QParallelAnimationGroupJob group;
-
- TestAnimation anim1(0);
-
- UncontrolledAnimation notTimeDriven;
- QCOMPARE(notTimeDriven.totalDuration(), -1);
-
- TestAnimation loopsForever(100);
- loopsForever.setLoopCount(-1);
-
- StateChangeListener stateChangedSpy;
- anim1.addAnimationChangeListener(&stateChangedSpy, QAbstractAnimationJob::StateChange);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&notTimeDriven);
- group.appendAnimation(&loopsForever);
-
- group.start();
-
- QCOMPARE(stateChangedSpy.count(), 2);
- QCOMPARE(stateChangedSpy.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(stateChangedSpy.states.at(1), QAnimationGroupJob::Stopped);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running);
- QCOMPARE(loopsForever.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
-
- notTimeDriven.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever.state(), QAnimationGroupJob::Running);
-
- loopsForever.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever.state(), QAnimationGroupJob::Stopped);
-}
-
-struct AnimState {
- AnimState(int time = -1) : time(time), state(-1) {}
- AnimState(int time, int state) : time(time), state(state) {}
- int time;
- int state;
-};
-
-#define Running QAbstractAnimationJob::Running
-#define Stopped QAbstractAnimationJob::Stopped
-
-Q_DECLARE_METATYPE(AnimState)
-void tst_QParallelAnimationGroupJob::loopCount_data()
-{
- QTest::addColumn<bool>("directionBackward");
- QTest::addColumn<int>("setLoopCount");
- QTest::addColumn<int>("initialGroupTime");
- QTest::addColumn<int>("currentGroupTime");
- QTest::addColumn<AnimState>("expected1");
- QTest::addColumn<AnimState>("expected2");
- QTest::addColumn<AnimState>("expected3");
-
- // D U R A T I O N
- // 100 60*2 0
- // direction = Forward
- QTest::newRow("50") << false << 3 << 0 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("100") << false << 3 << 0 << 100 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped);
- QTest::newRow("110") << false << 3 << 0 << 110 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("120") << false << 3 << 0 << 120 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
-
- QTest::newRow("170") << false << 3 << 0 << 170 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("220") << false << 3 << 0 << 220 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped);
- QTest::newRow("230") << false << 3 << 0 << 230 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("240") << false << 3 << 0 << 240 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
-
- QTest::newRow("290") << false << 3 << 0 << 290 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("340") << false << 3 << 0 << 340 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped);
- QTest::newRow("350") << false << 3 << 0 << 350 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("360") << false << 3 << 0 << 360 << AnimState(100, Stopped) << AnimState( 60 ) << AnimState( 0, Stopped);
-
- QTest::newRow("410") << false << 3 << 0 << 410 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
- QTest::newRow("460") << false << 3 << 0 << 460 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
- QTest::newRow("470") << false << 3 << 0 << 470 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
- QTest::newRow("480") << false << 3 << 0 << 480 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
-
- // direction = Forward, rewind
- QTest::newRow("120-110") << false << 3 << 120 << 110 << AnimState( 0, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("120-50") << false << 3 << 120 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("120-0") << false << 3 << 120 << 0 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
- QTest::newRow("300-110") << false << 3 << 300 << 110 << AnimState( 0, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("300-50") << false << 3 << 300 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("300-0") << false << 3 << 300 << 0 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
- QTest::newRow("115-105") << false << 3 << 115 << 105 << AnimState( 42, Stopped) << AnimState( 45, Running) << AnimState( 0, Stopped);
-
- // direction = Backward
- QTest::newRow("b120-120") << true << 3 << 120 << 120 << AnimState( 42, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
- QTest::newRow("b120-110") << true << 3 << 120 << 110 << AnimState( 42, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("b120-100") << true << 3 << 120 << 100 << AnimState(100, Running) << AnimState( 40, Running) << AnimState( 0, Stopped);
- QTest::newRow("b120-50") << true << 3 << 120 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("b120-0") << true << 3 << 120 << 0 << AnimState( 0, Stopped) << AnimState( 0, Stopped) << AnimState( 0, Stopped);
- QTest::newRow("b360-170") << true << 3 << 360 << 170 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("b360-220") << true << 3 << 360 << 220 << AnimState(100, Running) << AnimState( 40, Running) << AnimState( 0, Stopped);
- QTest::newRow("b360-210") << true << 3 << 360 << 210 << AnimState( 90, Running) << AnimState( 30, Running) << AnimState( 0, Stopped);
- QTest::newRow("b360-120") << true << 3 << 360 << 120 << AnimState( 0, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
-
- // rewind, direction = Backward
- QTest::newRow("b50-110") << true << 3 << 50 << 110 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
- QTest::newRow("b50-120") << true << 3 << 50 << 120 << AnimState(100, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
- QTest::newRow("b50-140") << true << 3 << 50 << 140 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
- QTest::newRow("b50-240") << true << 3 << 50 << 240 << AnimState(100, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
- QTest::newRow("b50-260") << true << 3 << 50 << 260 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
- QTest::newRow("b50-350") << true << 3 << 50 << 350 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
-
- // infinite looping
- QTest::newRow("inf1220") << false << -1 << 0 << 1220 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
- QTest::newRow("inf1310") << false << -1 << 0 << 1310 << AnimState( 100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
- // infinite looping, direction = Backward (will only loop once)
- QTest::newRow("b.inf120-120") << true << -1 << 120 << 120 << AnimState( 42, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
- QTest::newRow("b.inf120-20") << true << -1 << 120 << 20 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
- QTest::newRow("b.inf120-110") << true << -1 << 120 << 110 << AnimState( 42, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
-
-
-}
-
-void tst_QParallelAnimationGroupJob::loopCount()
-{
- QFETCH(bool, directionBackward);
- QFETCH(int, setLoopCount);
- QFETCH(int, initialGroupTime);
- QFETCH(int, currentGroupTime);
- QFETCH(AnimState, expected1);
- QFETCH(AnimState, expected2);
- QFETCH(AnimState, expected3);
-
- QParallelAnimationGroupJob group;
-
- TestAnimation anim1(100);
- TestAnimation anim2(60); //total 120
- anim2.setLoopCount(2);
- TestAnimation anim3(0);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
- group.appendAnimation(&anim3);
-
- group.setLoopCount(setLoopCount);
- if (initialGroupTime >= 0)
- group.setCurrentTime(initialGroupTime);
- if (directionBackward)
- group.setDirection(QAbstractAnimationJob::Backward);
-
- group.start();
- if (initialGroupTime >= 0)
- group.setCurrentTime(initialGroupTime);
-
- anim1.setCurrentTime(42); // 42 is "untouched"
- anim2.setCurrentTime(42);
-
- group.setCurrentTime(currentGroupTime);
-
- QCOMPARE(anim1.currentLoopTime(), expected1.time);
- QCOMPARE(anim2.currentLoopTime(), expected2.time);
- QCOMPARE(anim3.currentLoopTime(), expected3.time);
-
- if (expected1.state >=0)
- QCOMPARE(int(anim1.state()), expected1.state);
- if (expected2.state >=0)
- QCOMPARE(int(anim2.state()), expected2.state);
- if (expected3.state >=0)
- QCOMPARE(int(anim3.state()), expected3.state);
-
-}
-
-void tst_QParallelAnimationGroupJob::addAndRemoveDuration()
-{
- QParallelAnimationGroupJob group;
- QCOMPARE(group.duration(), 0);
- TestAnimation *test = new TestAnimation(250); // 0, duration = 250;
- group.appendAnimation(test);
- QCOMPARE(test->group(), static_cast<QAnimationGroupJob*>(&group));
- QCOMPARE(test->duration(), 250);
- QCOMPARE(group.duration(), 250);
-
- TestAnimation *test2 = new TestAnimation(750); // 1
- group.appendAnimation(test2);
- QCOMPARE(test2->group(), static_cast<QAnimationGroupJob*>(&group));
- QCOMPARE(group.duration(), 750);
-
- TestAnimation *test3 = new TestAnimation(500); // 2
- group.appendAnimation(test3);
- QCOMPARE(test3->group(), static_cast<QAnimationGroupJob*>(&group));
- QCOMPARE(group.duration(), 750);
-
- group.removeAnimation(test2); // remove the one with duration = 750
- delete test2;
- QCOMPARE(group.duration(), 500);
-
- group.removeAnimation(test3); // remove the one with duration = 500
- delete test3;
- QCOMPARE(group.duration(), 250);
-
- group.removeAnimation(test); // remove the last one (with duration = 250)
- QCOMPARE(test->group(), static_cast<QAnimationGroupJob*>(0));
- QCOMPARE(group.duration(), 0);
- delete test;
-}
-
-void tst_QParallelAnimationGroupJob::pauseResume()
-{
- QParallelAnimationGroupJob group;
- TestAnimation *anim = new TestAnimation(250); // 0, duration = 250;
- group.appendAnimation(anim);
- StateChangeListener spy;
- anim->addAnimationChangeListener(&spy, QAbstractAnimationJob::StateChange);
- QCOMPARE(group.duration(), 250);
- group.start();
- QTest::qWait(100);
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim->state(), QAnimationGroupJob::Running);
- QCOMPARE(spy.count(), 1);
- spy.clear();
- const int currentTime = group.currentLoopTime();
- QCOMPARE(anim->currentLoopTime(), currentTime);
-
- group.pause();
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(group.currentLoopTime(), currentTime);
- QCOMPARE(anim->state(), QAnimationGroupJob::Paused);
- QCOMPARE(anim->currentLoopTime(), currentTime);
- QCOMPARE(spy.count(), 1);
- spy.clear();
-
- group.resume();
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(group.currentLoopTime(), currentTime);
- QCOMPARE(anim->state(), QAnimationGroupJob::Running);
- QCOMPARE(anim->currentLoopTime(), currentTime);
- QCOMPARE(spy.count(), 1);
-
- group.stop();
- spy.clear();
- group.appendAnimation(new TestAnimation(500));
- group.start();
- QCOMPARE(spy.count(), 1); //the animation should have been started
- QCOMPARE(spy.states.at(0), TestAnimation::Running);
- group.setCurrentTime(250); //end of first animation
- QCOMPARE(spy.count(), 2); //the animation should have been stopped
- QCOMPARE(spy.states.at(1), TestAnimation::Stopped);
- group.pause();
- QCOMPARE(spy.count(), 2); //this shouldn't have changed
- group.resume();
- QCOMPARE(spy.count(), 2); //this shouldn't have changed
-}
-
-// This is a regression test for QTBUG-8910, where a crash occurred when the
-// last animation was removed from a group.
-void tst_QParallelAnimationGroupJob::crashWhenRemovingUncontrolledAnimation()
-{
- QParallelAnimationGroupJob group;
- TestAnimation *anim = new TestAnimation;
- anim->setLoopCount(-1);
- TestAnimation *anim2 = new TestAnimation;
- anim2->setLoopCount(-1);
- group.appendAnimation(anim);
- group.appendAnimation(anim2);
- group.start();
- delete anim;
- // it would crash here because the internals of the group would still have a reference to anim
- delete anim2;
-}
-
-
-QTEST_MAIN(tst_QParallelAnimationGroupJob)
-#include "tst_qparallelanimationgroupjob.moc"
diff --git a/tests/auto/declarative/animation/qpauseanimationjob/qpauseanimationjob.pro b/tests/auto/declarative/animation/qpauseanimationjob/qpauseanimationjob.pro
deleted file mode 100644
index d2b48a6c74..0000000000
--- a/tests/auto/declarative/animation/qpauseanimationjob/qpauseanimationjob.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG += testcase
-macx:CONFIG -= app_bundle
-TARGET = tst_qpauseanimationjob
-QT = core-private gui-private declarative-private testlib
-SOURCES = tst_qpauseanimationjob.cpp
diff --git a/tests/auto/declarative/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp b/tests/auto/declarative/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp
deleted file mode 100644
index 97be325017..0000000000
--- a/tests/auto/declarative/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp
+++ /dev/null
@@ -1,470 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-
-#include <QtDeclarative/private/qpauseanimationjob_p.h>
-#include <QtDeclarative/private/qsequentialanimationgroupjob_p.h>
-#include <QtDeclarative/private/qparallelanimationgroupjob_p.h>
-
-#ifdef Q_OS_WIN
-static const char winTimerError[] = "On windows, consistent timing is not working properly due to bad timer resolution";
-#endif
-
-class TestablePauseAnimation : public QPauseAnimationJob
-{
-public:
- TestablePauseAnimation()
- : m_updateCurrentTimeCount(0)
- {
- }
-
- TestablePauseAnimation(int duration)
- : QPauseAnimationJob(duration), m_updateCurrentTimeCount(0)
- {
- }
-
- int m_updateCurrentTimeCount;
-protected:
- void updateCurrentTime(int currentTime)
- {
- QPauseAnimationJob::updateCurrentTime(currentTime);
- ++m_updateCurrentTimeCount;
- }
-};
-
-class TestableGenericAnimation : public QAbstractAnimationJob
-{
-public:
- TestableGenericAnimation(int duration = 250) : m_duration(duration) {}
- int duration() const { return m_duration; }
-
-private:
- int m_duration;
-};
-
-class EnableConsistentTiming
-{
-public:
- EnableConsistentTiming()
- {
- QUnifiedTimer *timer = QUnifiedTimer::instance();
- timer->setConsistentTiming(true);
- }
- ~EnableConsistentTiming()
- {
- QUnifiedTimer *timer = QUnifiedTimer::instance();
- timer->setConsistentTiming(false);
- }
-};
-
-class tst_QPauseAnimationJob : public QObject
-{
- Q_OBJECT
-public Q_SLOTS:
- void initTestCase();
-
-private slots:
- void changeDirectionWhileRunning();
- void noTimerUpdates_data();
- void noTimerUpdates();
- void multiplePauseAnimations();
- void pauseAndPropertyAnimations();
- void pauseResume();
- void sequentialPauseGroup();
- void sequentialGroupWithPause();
- void multipleSequentialGroups();
- void zeroDuration();
-};
-
-void tst_QPauseAnimationJob::initTestCase()
-{
-// qRegisterMetaType<QAbstractAnimationJob::State>("QAbstractAnimationJob::State");
-}
-
-void tst_QPauseAnimationJob::changeDirectionWhileRunning()
-{
- EnableConsistentTiming enabled;
-
- TestablePauseAnimation animation;
- animation.setDuration(400);
- animation.start();
- QTest::qWait(100);
- QVERIFY(animation.state() == QAbstractAnimationJob::Running);
- animation.setDirection(QAbstractAnimationJob::Backward);
- QTest::qWait(animation.totalDuration() + 50);
- QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
-}
-
-void tst_QPauseAnimationJob::noTimerUpdates_data()
-{
- QTest::addColumn<int>("duration");
- QTest::addColumn<int>("loopCount");
-
- QTest::newRow("0") << 200 << 1;
- QTest::newRow("1") << 160 << 1;
- QTest::newRow("2") << 160 << 2;
- QTest::newRow("3") << 200 << 3;
-}
-
-void tst_QPauseAnimationJob::noTimerUpdates()
-{
- EnableConsistentTiming enabled;
-
- QFETCH(int, duration);
- QFETCH(int, loopCount);
-
- TestablePauseAnimation animation;
- animation.setDuration(duration);
- animation.setLoopCount(loopCount);
- animation.start();
- QTest::qWait(animation.totalDuration() + 100);
-
-#ifdef Q_OS_WIN
- if (animation.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
-
- QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
- const int expectedLoopCount = 1 + loopCount;
-
-#ifdef Q_OS_WIN
- if (animation.m_updateCurrentTimeCount != expectedLoopCount)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QCOMPARE(animation.m_updateCurrentTimeCount, expectedLoopCount);
-}
-
-void tst_QPauseAnimationJob::multiplePauseAnimations()
-{
- EnableConsistentTiming enabled;
-
- TestablePauseAnimation animation;
- animation.setDuration(200);
-
- TestablePauseAnimation animation2;
- animation2.setDuration(800);
-
- animation.start();
- animation2.start();
- QTest::qWait(animation.totalDuration() + 100);
-
-#ifdef Q_OS_WIN
- if (animation.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
-
-#ifdef Q_OS_WIN
- if (animation2.state() != QAbstractAnimationJob::Running)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(animation2.state() == QAbstractAnimationJob::Running);
-
-#ifdef Q_OS_WIN
- if (animation.m_updateCurrentTimeCount != 2)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QCOMPARE(animation.m_updateCurrentTimeCount, 2);
-
-#ifdef Q_OS_WIN
- if (animation2.m_updateCurrentTimeCount != 2)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
-
- QTest::qWait(550);
-
-#ifdef Q_OS_WIN
- if (animation2.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped);
-
-#ifdef Q_OS_WIN
- if (animation2.m_updateCurrentTimeCount != 3)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QCOMPARE(animation2.m_updateCurrentTimeCount, 3);
-}
-
-void tst_QPauseAnimationJob::pauseAndPropertyAnimations()
-{
- EnableConsistentTiming enabled;
-
- TestablePauseAnimation pause;
- pause.setDuration(200);
-
- TestableGenericAnimation animation;
-
- pause.start();
-
- QTest::qWait(100);
- animation.start();
-
- QVERIFY(animation.state() == QAbstractAnimationJob::Running);
- QVERIFY(pause.state() == QAbstractAnimationJob::Running);
- QCOMPARE(pause.m_updateCurrentTimeCount, 2);
-
- QTest::qWait(animation.totalDuration() + 100);
-
-#ifdef Q_OS_WIN
- if (animation.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(pause.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(pause.m_updateCurrentTimeCount > 3);
-}
-
-void tst_QPauseAnimationJob::pauseResume()
-{
- TestablePauseAnimation animation;
- animation.setDuration(400);
- animation.start();
- QVERIFY(animation.state() == QAbstractAnimationJob::Running);
- QTest::qWait(200);
- animation.pause();
- QVERIFY(animation.state() == QAbstractAnimationJob::Paused);
- animation.start();
- QTest::qWait(300);
- QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
-
-#ifdef Q_OS_WIN
- if (animation.m_updateCurrentTimeCount != 3)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QCOMPARE(animation.m_updateCurrentTimeCount, 3);
-}
-
-void tst_QPauseAnimationJob::sequentialPauseGroup()
-{
- QSequentialAnimationGroupJob group;
-
- TestablePauseAnimation animation1(200);
- group.appendAnimation(&animation1);
- TestablePauseAnimation animation2(200);
- group.appendAnimation(&animation2);
- TestablePauseAnimation animation3(200);
- group.appendAnimation(&animation3);
-
- group.start();
- QCOMPARE(animation1.m_updateCurrentTimeCount, 1);
- QCOMPARE(animation2.m_updateCurrentTimeCount, 0);
- QCOMPARE(animation3.m_updateCurrentTimeCount, 0);
-
- QVERIFY(group.state() == QAbstractAnimationJob::Running);
- QVERIFY(animation1.state() == QAbstractAnimationJob::Running);
- QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped);
-
- group.setCurrentTime(250);
- QCOMPARE(animation1.m_updateCurrentTimeCount, 2);
- QCOMPARE(animation2.m_updateCurrentTimeCount, 1);
- QCOMPARE(animation3.m_updateCurrentTimeCount, 0);
-
- QVERIFY(group.state() == QAbstractAnimationJob::Running);
- QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped);
- QCOMPARE((QAbstractAnimationJob*)&animation2, group.currentAnimation());
- QVERIFY(animation2.state() == QAbstractAnimationJob::Running);
- QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped);
-
- group.setCurrentTime(500);
- QCOMPARE(animation1.m_updateCurrentTimeCount, 2);
- QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
- QCOMPARE(animation3.m_updateCurrentTimeCount, 1);
-
- QVERIFY(group.state() == QAbstractAnimationJob::Running);
- QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped);
- QCOMPARE((QAbstractAnimationJob*)&animation3, group.currentAnimation());
- QVERIFY(animation3.state() == QAbstractAnimationJob::Running);
-
- group.setCurrentTime(750);
-
- QVERIFY(group.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped);
-
- QCOMPARE(animation1.m_updateCurrentTimeCount, 2);
- QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
- QCOMPARE(animation3.m_updateCurrentTimeCount, 2);
-}
-
-void tst_QPauseAnimationJob::sequentialGroupWithPause()
-{
- QSequentialAnimationGroupJob group;
-
- TestableGenericAnimation animation;
- group.appendAnimation(&animation);
-
- TestablePauseAnimation pause;
- pause.setDuration(250);
- group.appendAnimation(&pause);
-
- group.start();
-
- QVERIFY(group.state() == QAbstractAnimationJob::Running);
- QVERIFY(animation.state() == QAbstractAnimationJob::Running);
- QVERIFY(pause.state() == QAbstractAnimationJob::Stopped);
-
- group.setCurrentTime(300);
-
- QVERIFY(group.state() == QAbstractAnimationJob::Running);
- QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
- QCOMPARE((QAbstractAnimationJob*)&pause, group.currentAnimation());
- QVERIFY(pause.state() == QAbstractAnimationJob::Running);
-
- group.setCurrentTime(600);
-
- QVERIFY(group.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
- QVERIFY(pause.state() == QAbstractAnimationJob::Stopped);
-
- QCOMPARE(pause.m_updateCurrentTimeCount, 2);
-}
-
-void tst_QPauseAnimationJob::multipleSequentialGroups()
-{
- EnableConsistentTiming enabled;
-
- QParallelAnimationGroupJob group;
- group.setLoopCount(2);
-
- QSequentialAnimationGroupJob subgroup1;
- group.appendAnimation(&subgroup1);
-
- TestableGenericAnimation animation(300);
- subgroup1.appendAnimation(&animation);
-
- TestablePauseAnimation pause(200);
- subgroup1.appendAnimation(&pause);
-
- QSequentialAnimationGroupJob subgroup2;
- group.appendAnimation(&subgroup2);
-
- TestableGenericAnimation animation2(200);
- subgroup2.appendAnimation(&animation2);
-
- TestablePauseAnimation pause2(250);
- subgroup2.appendAnimation(&pause2);
-
- QSequentialAnimationGroupJob subgroup3;
- group.appendAnimation(&subgroup3);
-
- TestablePauseAnimation pause3(400);
- subgroup3.appendAnimation(&pause3);
-
- TestableGenericAnimation animation3(200);
- subgroup3.appendAnimation(&animation3);
-
- QSequentialAnimationGroupJob subgroup4;
- group.appendAnimation(&subgroup4);
-
- TestablePauseAnimation pause4(310);
- subgroup4.appendAnimation(&pause4);
-
- TestablePauseAnimation pause5(60);
- subgroup4.appendAnimation(&pause5);
-
- group.start();
-
- QVERIFY(group.state() == QAbstractAnimationJob::Running);
- QVERIFY(subgroup1.state() == QAbstractAnimationJob::Running);
- QVERIFY(subgroup2.state() == QAbstractAnimationJob::Running);
- QVERIFY(subgroup3.state() == QAbstractAnimationJob::Running);
- QVERIFY(subgroup4.state() == QAbstractAnimationJob::Running);
-
- // This is a pretty long animation so it tends to get rather out of sync
- // when using the consistent timer, so run for an extra half second for good
- // measure...
- QTest::qWait(group.totalDuration() + 500);
-
-#ifdef Q_OS_WIN
- if (group.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(group.state() == QAbstractAnimationJob::Stopped);
-
-#ifdef Q_OS_WIN
- if (subgroup1.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(subgroup1.state() == QAbstractAnimationJob::Stopped);
-
-#ifdef Q_OS_WIN
- if (subgroup2.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(subgroup2.state() == QAbstractAnimationJob::Stopped);
-
-#ifdef Q_OS_WIN
- if (subgroup3.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(subgroup3.state() == QAbstractAnimationJob::Stopped);
-
-#ifdef Q_OS_WIN
- if (subgroup4.state() != QAbstractAnimationJob::Stopped)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QVERIFY(subgroup4.state() == QAbstractAnimationJob::Stopped);
-
-#ifdef Q_OS_WIN
- if (pause5.m_updateCurrentTimeCount != 4)
- QEXPECT_FAIL("", winTimerError, Abort);
-#endif
- QCOMPARE(pause5.m_updateCurrentTimeCount, 4);
-}
-
-void tst_QPauseAnimationJob::zeroDuration()
-{
- TestablePauseAnimation animation;
- animation.setDuration(0);
- animation.start();
- QTest::qWait(animation.totalDuration() + 100);
- QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
- QCOMPARE(animation.m_updateCurrentTimeCount, 1);
-}
-
-QTEST_MAIN(tst_QPauseAnimationJob)
-#include "tst_qpauseanimationjob.moc"
diff --git a/tests/auto/declarative/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro b/tests/auto/declarative/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro
deleted file mode 100644
index 914fc3ca62..0000000000
--- a/tests/auto/declarative/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-CONFIG += testcase parallel_test
-macx:CONFIG -= app_bundle
-TARGET = tst_qsequentialanimationgroupjob
-QT = core-private declarative-private testlib
-SOURCES = tst_qsequentialanimationgroupjob.cpp
diff --git a/tests/auto/declarative/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp b/tests/auto/declarative/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
deleted file mode 100644
index d5a9b07f8f..0000000000
--- a/tests/auto/declarative/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
+++ /dev/null
@@ -1,1617 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtDeclarative/private/qsequentialanimationgroupjob_p.h>
-#include <QtDeclarative/private/qparallelanimationgroupjob_p.h>
-#include <QtDeclarative/private/qpauseanimationjob_p.h>
-
-Q_DECLARE_METATYPE(QAbstractAnimationJob::State)
-Q_DECLARE_METATYPE(QAbstractAnimationJob*)
-
-class tst_QSequentialAnimationGroupJob : public QObject
-{
- Q_OBJECT
-public Q_SLOTS:
- void initTestCase();
-
-private slots:
- void construction();
- void setCurrentTime();
- void setCurrentTimeWithUncontrolledAnimation();
- void seekingForwards();
- void seekingBackwards();
- void pauseAndResume();
- void restart();
- void looping();
- void startDelay();
- void clearGroup();
- void groupWithZeroDurationAnimations();
- void propagateGroupUpdateToChildren();
- void updateChildrenWithRunningGroup();
- void deleteChildrenWithRunningGroup();
- void startChildrenWithStoppedGroup();
- void stopGroupWithRunningChild();
- void startGroupWithRunningChild();
- void zeroDurationAnimation();
- void stopUncontrolledAnimations();
- void finishWithUncontrolledAnimation();
- void addRemoveAnimation();
- void currentAnimation();
- void currentAnimationWithZeroDuration();
- void insertAnimation();
- void clear();
- void pauseResume();
-};
-
-void tst_QSequentialAnimationGroupJob::initTestCase()
-{
- qRegisterMetaType<QAbstractAnimationJob::State>("QAbstractAnimationJob::State");
- qRegisterMetaType<QAbstractAnimationJob*>("QAbstractAnimationJob*");
-}
-
-void tst_QSequentialAnimationGroupJob::construction()
-{
- QSequentialAnimationGroupJob animationgroup;
-}
-
-class TestAnimation : public QAbstractAnimationJob
-{
-public:
- TestAnimation(int duration = 250) : m_duration(duration) {}
- int duration() const { return m_duration; }
-
-private:
- int m_duration;
-};
-
-class TestValueAnimation : public TestAnimation
-{
-public:
- TestValueAnimation(int duration = 250)
- : TestAnimation(duration), start(0), end(0), value(0) {}
-
- void updateCurrentTime(int msecs)
- {
- if (msecs >= duration())
- value = end;
- else
- value = start + (end - start) * (qreal(msecs) / duration());
- }
-
- qreal start, end;
- qreal value;
-};
-
-class UncontrolledAnimation : public QObject, public QAbstractAnimationJob
-{
- Q_OBJECT
-public:
- int duration() const { return -1; /* not time driven */ }
-
-protected:
- void updateCurrentTime(int currentTime)
- {
- if (currentTime >= 250)
- stop();
- }
-};
-
-class StateChangeListener: public QAnimationJobChangeListener
-{
-public:
- virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State)
- {
- states << newState;
- }
-
- void clear() { states.clear(); }
- int count() const { return states.count(); }
-
- QList<QAbstractAnimationJob::State> states;
-};
-
-class FinishedListener: public QAnimationJobChangeListener
-{
-public:
- FinishedListener() : m_count(0) {}
-
- virtual void animationFinished(QAbstractAnimationJob *) { ++m_count; }
- void clear() { m_count = 0; }
- int count() { return m_count; }
-
-private:
- int m_count;
-};
-
-void tst_QSequentialAnimationGroupJob::setCurrentTime()
-{
- // sequence operating on same object/property
- QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
- TestAnimation *a1_s_o1 = new TestAnimation;
- TestAnimation *a2_s_o1 = new TestAnimation;
- TestAnimation *a3_s_o1 = new TestAnimation;
- a2_s_o1->setLoopCount(3);
- sequence->appendAnimation(a1_s_o1);
- sequence->appendAnimation(a2_s_o1);
- sequence->appendAnimation(a3_s_o1);
-
- // sequence operating on different object/properties
- QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob();
- TestAnimation *a1_s_o2 = new TestAnimation;
- TestAnimation *a1_s_o3 = new TestAnimation;
- sequence2->appendAnimation(a1_s_o2);
- sequence2->appendAnimation(a1_s_o3);
-
- QSequentialAnimationGroupJob group;
- group.appendAnimation(sequence);
- group.appendAnimation(sequence2);
-
- // Current time = 1
- group.setCurrentTime(1);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
-
- QCOMPARE(group.currentLoopTime(), 1);
- QCOMPARE(sequence->currentLoopTime(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 1);
- QCOMPARE(a2_s_o1->currentLoopTime(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 250
- group.setCurrentTime(250);
- QCOMPARE(group.currentLoopTime(), 250);
- QCOMPARE(sequence->currentLoopTime(), 250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 251
- group.setCurrentTime(251);
- QCOMPARE(group.currentLoopTime(), 251);
- QCOMPARE(sequence->currentLoopTime(), 251);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 1);
- QCOMPARE(a2_s_o1->currentLoop(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(sequence2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 750
- group.setCurrentTime(750);
- QCOMPARE(group.currentLoopTime(), 750);
- QCOMPARE(sequence->currentLoopTime(), 750);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 0);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(sequence2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 1000
- group.setCurrentTime(1000);
- QCOMPARE(group.currentLoopTime(), 1000);
- QCOMPARE(sequence->currentLoopTime(), 1000);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(sequence2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 1010
- group.setCurrentTime(1010);
- QCOMPARE(group.currentLoopTime(), 1010);
- QCOMPARE(sequence->currentLoopTime(), 1010);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 10);
- QCOMPARE(sequence2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 1250
- group.setCurrentTime(1250);
- QCOMPARE(group.currentLoopTime(), 1250);
- QCOMPARE(sequence->currentLoopTime(), 1250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
- QCOMPARE(sequence2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 1500
- group.setCurrentTime(1500);
- QCOMPARE(group.currentLoopTime(), 1500);
- QCOMPARE(sequence->currentLoopTime(), 1250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
- QCOMPARE(sequence2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 1750
- group.setCurrentTime(1750);
- QCOMPARE(group.currentLoopTime(), 1750);
- QCOMPARE(sequence->currentLoopTime(), 1250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
- QCOMPARE(sequence2->currentLoopTime(), 500);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 250);
-
- // Current time = 2000
- group.setCurrentTime(2000);
- QCOMPARE(group.currentLoopTime(), 1750);
- QCOMPARE(sequence->currentLoopTime(), 1250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
- QCOMPARE(sequence2->currentLoopTime(), 500);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 250);
-}
-
-void tst_QSequentialAnimationGroupJob::setCurrentTimeWithUncontrolledAnimation()
-{
- // sequence operating on different object/properties
- QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
- TestAnimation *a1_s_o1 = new TestAnimation;
- TestAnimation *a1_s_o2 = new TestAnimation;
- sequence->appendAnimation(a1_s_o1);
- sequence->appendAnimation(a1_s_o2);
-
- UncontrolledAnimation *notTimeDriven = new UncontrolledAnimation;
- QCOMPARE(notTimeDriven->totalDuration(), -1);
-
- TestAnimation *loopsForever = new TestAnimation;
- loopsForever->setLoopCount(-1);
- QCOMPARE(loopsForever->totalDuration(), -1);
-
- QSequentialAnimationGroupJob group;
- group.appendAnimation(sequence);
- group.appendAnimation(notTimeDriven);
- group.appendAnimation(loopsForever);
- group.start();
- group.pause(); // this allows the group to listen for the finish signal of its children
-
- // Current time = 1
- group.setCurrentTime(1);
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Paused);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
-
- QCOMPARE(group.currentLoopTime(), 1);
- QCOMPARE(sequence->currentLoopTime(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 1);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(notTimeDriven->currentLoopTime(), 0);
- QCOMPARE(loopsForever->currentLoopTime(), 0);
-
- // Current time = 250
- group.setCurrentTime(250);
- QCOMPARE(group.currentLoopTime(), 250);
- QCOMPARE(sequence->currentLoopTime(), 250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(notTimeDriven->currentLoopTime(), 0);
- QCOMPARE(loopsForever->currentLoopTime(), 0);
-
- // Current time = 500
- group.setCurrentTime(500);
- QCOMPARE(group.currentLoopTime(), 500);
- QCOMPARE(sequence->currentLoopTime(), 500);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(notTimeDriven->currentLoopTime(), 0);
- QCOMPARE(loopsForever->currentLoopTime(), 0);
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob *>(notTimeDriven));
-
- // Current time = 505
- group.setCurrentTime(505);
- QCOMPARE(group.currentLoopTime(), 505);
- QCOMPARE(sequence->currentLoopTime(), 500);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(notTimeDriven->currentLoopTime(), 5);
- QCOMPARE(loopsForever->currentLoopTime(), 0);
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob *>(notTimeDriven));
- QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Paused);
- QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
-
- // Current time = 750 (end of notTimeDriven animation)
- group.setCurrentTime(750);
- QCOMPARE(group.currentLoopTime(), 750);
- QCOMPARE(sequence->currentLoopTime(), 500);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(notTimeDriven->currentLoopTime(), 250);
- QCOMPARE(loopsForever->currentLoopTime(), 0);
- QCOMPARE(group.currentAnimation(), loopsForever);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever->state(), QAnimationGroupJob::Paused);
-
- // Current time = 800 (as notTimeDriven was finished at 750, loopsforever should still run)
- group.setCurrentTime(800);
- QCOMPARE(group.currentLoopTime(), 800);
- QCOMPARE(group.currentAnimation(), loopsForever);
- QCOMPARE(sequence->currentLoopTime(), 500);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(notTimeDriven->currentLoopTime(), 250);
- QCOMPARE(loopsForever->currentLoopTime(), 50);
-
- loopsForever->stop(); // this should stop the group
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
-}
-
-void tst_QSequentialAnimationGroupJob::seekingForwards()
-{
-
- // sequence operating on same object/property
- QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob;
- TestAnimation *a1_s_o1 = new TestAnimation;
- TestAnimation *a2_s_o1 = new TestAnimation;
- TestAnimation *a3_s_o1 = new TestAnimation;
- a2_s_o1->setLoopCount(3);
- sequence->appendAnimation(a1_s_o1);
- sequence->appendAnimation(a2_s_o1);
- sequence->appendAnimation(a3_s_o1);
-
- // sequence operating on different object/properties
- QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob;
- TestAnimation *a1_s_o2 = new TestAnimation;
- TestAnimation *a1_s_o3 = new TestAnimation;
- sequence2->appendAnimation(a1_s_o2);
- sequence2->appendAnimation(a1_s_o3);
-
- QSequentialAnimationGroupJob group;
- group.appendAnimation(sequence);
- group.appendAnimation(sequence2);
-
- // Current time = 1
- group.setCurrentTime(1);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped);
-
- QCOMPARE(group.currentLoopTime(), 1);
- QCOMPARE(sequence->currentLoopTime(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 1);
- QCOMPARE(a2_s_o1->currentLoopTime(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(sequence2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // Current time = 1500
- group.setCurrentTime(1500);
- QCOMPARE(group.currentLoopTime(), 1500);
- QCOMPARE(sequence->currentLoopTime(), 1250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
- QCOMPARE(sequence2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- // this will restart the group
- group.start();
- group.pause();
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Paused);
- QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped);
-
- // Current time = 1750
- group.setCurrentTime(1750);
- QCOMPARE(group.currentLoopTime(), 1750);
- QCOMPARE(sequence->currentLoopTime(), 1250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
- QCOMPARE(sequence2->currentLoopTime(), 500);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 250);
-}
-
-void tst_QSequentialAnimationGroupJob::seekingBackwards()
-{
- // sequence operating on same object/property
- QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
- TestAnimation *a1_s_o1 = new TestAnimation;
- TestAnimation *a2_s_o1 = new TestAnimation;
- TestAnimation *a3_s_o1 = new TestAnimation;
- a2_s_o1->setLoopCount(3);
- sequence->appendAnimation(a1_s_o1);
- sequence->appendAnimation(a2_s_o1);
- sequence->appendAnimation(a3_s_o1);
-
- // sequence operating on different object/properties
- QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob();
- TestAnimation *a1_s_o2 = new TestAnimation;
- TestAnimation *a1_s_o3 = new TestAnimation;
- sequence2->appendAnimation(a1_s_o2);
- sequence2->appendAnimation(a1_s_o3);
-
- QSequentialAnimationGroupJob group;
- group.appendAnimation(sequence);
- group.appendAnimation(sequence2);
-
- group.start();
-
- // Current time = 1600
- group.setCurrentTime(1600);
- QCOMPARE(group.currentLoopTime(), 1600);
- QCOMPARE(sequence->currentLoopTime(), 1250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
- QCOMPARE(sequence2->currentLoopTime(), 350);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 100);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence2->state(), QAnimationGroupJob::Running);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Running);
-
- // Seeking backwards, current time = 1
- group.setCurrentTime(1);
- QCOMPARE(group.currentLoopTime(), 1);
- QCOMPARE(sequence->currentLoopTime(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 1);
-
- QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
- "hence they don't reset from their current animation", Continue);
- QCOMPARE(a2_s_o1->currentLoopTime(), 0);
- QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
- "hence they don't reset from their current animation", Continue);
- QCOMPARE(a2_s_o1->currentLoop(), 0);
- QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
- "hence they don't reset from their current animation", Continue);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(sequence2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o2->currentLoopTime(), 0);
- QCOMPARE(a1_s_o3->currentLoopTime(), 0);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Running);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Running);
- QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped);
-
- // Current time = 2000
- group.setCurrentTime(2000);
- QCOMPARE(group.currentLoopTime(), 1750);
- QCOMPARE(sequence->currentLoopTime(), 1250);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 2);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
- QCOMPARE(sequence2->currentLoopTime(), 500);
- QCOMPARE(a1_s_o2->currentLoopTime(), 250);
- QCOMPARE(a1_s_o3->currentLoopTime(), 250);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped);
-}
-
-typedef QList<QAbstractAnimationJob::State> StateList;
-
-static bool compareStates(const StateChangeListener& spy, const StateList &expectedStates)
-{
- bool equals = true;
- for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) {
- if (i >= spy.count() || i >= expectedStates.count()) {
- equals = false;
- break;
- }
- QAbstractAnimationJob::State st = expectedStates.at(i);
- QAbstractAnimationJob::State actual = spy.states.at(i);
- if (equals && actual != st) {
- equals = false;
- break;
- }
- }
- if (!equals) {
- const char *stateStrings[] = {"Stopped", "Paused", "Running"};
- QString e,a;
- for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) {
- if (i < expectedStates.count()) {
- int exp = int(expectedStates.at(i));
- if (!e.isEmpty())
- e += QLatin1String(", ");
- e += QLatin1String(stateStrings[exp]);
- }
- if (i < spy.count()) {
- QAbstractAnimationJob::State actual = spy.states.at(i);
- if (!a.isEmpty())
- a += QLatin1String(", ");
- if (int(actual) >= 0 && int(actual) <= 2) {
- a += QLatin1String(stateStrings[int(actual)]);
- } else {
- a += QLatin1String("NaN");
- }
- }
-
- }
- qDebug("\n"
- "expected (count == %d): %s\n"
- "actual (count == %d): %s\n", expectedStates.count(), qPrintable(e), spy.count(), qPrintable(a));
- }
- return equals;
-}
-
-void tst_QSequentialAnimationGroupJob::pauseAndResume()
-{
- // sequence operating on same object/property
- QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
- TestAnimation *a1_s_o1 = new TestAnimation;
- TestAnimation *a2_s_o1 = new TestAnimation;
- TestAnimation *a3_s_o1 = new TestAnimation;
- a2_s_o1->setLoopCount(2);
- sequence->appendAnimation(a1_s_o1);
- sequence->appendAnimation(a2_s_o1);
- sequence->appendAnimation(a3_s_o1);
- sequence->setLoopCount(2);
-
- StateChangeListener a1StateChangedSpy;
- a1_s_o1->addAnimationChangeListener(&a1StateChangedSpy, QAbstractAnimationJob::StateChange);
- StateChangeListener seqStateChangedSpy;
- sequence->addAnimationChangeListener(&seqStateChangedSpy, QAbstractAnimationJob::StateChange);
-
- QSequentialAnimationGroupJob group;
- group.appendAnimation(sequence);
-
- group.start();
- group.pause();
-
- // Current time = 1751
- group.setCurrentTime(1751);
- QCOMPARE(group.currentLoopTime(), 1751);
- QCOMPARE(sequence->currentLoopTime(), 751);
- QCOMPARE(sequence->currentLoop(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 1);
- QCOMPARE(a3_s_o1->currentLoop(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 1);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Paused);
-
- QCOMPARE(a1StateChangedSpy.count(), 5); // Running,Paused,Stopped,Running,Stopped
- QCOMPARE(seqStateChangedSpy.count(), 2); // Running,Paused
-
- QVERIFY(compareStates(a1StateChangedSpy, (StateList() << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Paused
- << QAbstractAnimationJob::Stopped
- << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Stopped)));
-
- //### is this the same test as compareStates test above?
- QCOMPARE(a1StateChangedSpy.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(a1StateChangedSpy.states.at(1), QAnimationGroupJob::Paused);
- QCOMPARE(a1StateChangedSpy.states.at(2), QAnimationGroupJob::Stopped);
- QCOMPARE(a1StateChangedSpy.states.at(3), QAnimationGroupJob::Running);
- QCOMPARE(a1StateChangedSpy.states.at(4), QAnimationGroupJob::Stopped);
-
- QCOMPARE(seqStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(seqStateChangedSpy.states.at(1), QAnimationGroupJob::Paused);
-
- group.resume();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Running);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Running);
-
- QVERIFY(group.currentLoopTime() >= 1751);
- QVERIFY(sequence->currentLoopTime() >= 751);
- QCOMPARE(sequence->currentLoop(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 1);
- QCOMPARE(a3_s_o1->currentLoop(), 0);
- QVERIFY(a3_s_o1->currentLoopTime() >= 1);
-
- QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running
- QCOMPARE(seqStateChangedSpy.states.at(2), QAnimationGroupJob::Running);
-
- group.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Paused);
-
- QVERIFY(group.currentLoopTime() >= 1751);
- QVERIFY(sequence->currentLoopTime() >= 751);
- QCOMPARE(sequence->currentLoop(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 1);
- QCOMPARE(a3_s_o1->currentLoop(), 0);
- QVERIFY(a3_s_o1->currentLoopTime() >= 1);
-
- QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused
- QCOMPARE(seqStateChangedSpy.states.at(3), QAnimationGroupJob::Paused);
-
- group.stop();
-
- QCOMPARE(seqStateChangedSpy.count(), 5); // Running,Paused,Running,Paused,Stopped
- QCOMPARE(seqStateChangedSpy.states.at(4), QAnimationGroupJob::Stopped);
-}
-
-void tst_QSequentialAnimationGroupJob::restart()
-{
- // originally was sequence operating on same object/property
- QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
- //### no equivilant signal
- //QSignalSpy seqCurrentAnimChangedSpy(sequence, SIGNAL(currentAnimationChanged(QAbstractAnimationJob*)));
-
- StateChangeListener seqStateChangedSpy;
- sequence->addAnimationChangeListener(&seqStateChangedSpy, QAbstractAnimationJob::StateChange);
-
- TestAnimation *anims[3];
- StateChangeListener *animsStateChanged[3];
-
- for (int i = 0; i < 3; i++) {
- anims[i] = new TestAnimation(100);
- animsStateChanged[i] = new StateChangeListener;
- anims[i]->addAnimationChangeListener(animsStateChanged[i], QAbstractAnimationJob::StateChange);
- }
-
- anims[1]->setLoopCount(2);
- sequence->appendAnimation(anims[0]);
- sequence->appendAnimation(anims[1]);
- sequence->appendAnimation(anims[2]);
- sequence->setLoopCount(2);
-
- QSequentialAnimationGroupJob group;
- group.appendAnimation(sequence);
-
- group.start();
-
- QTest::qWait(500);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
-
- QTest::qWait(300);
- QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped);
-
- for (int i = 0; i < 3; i++) {
- QCOMPARE(animsStateChanged[i]->count(), 4);
- QCOMPARE(animsStateChanged[i]->states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(animsStateChanged[i]->states.at(1), QAnimationGroupJob::Stopped);
- QCOMPARE(animsStateChanged[i]->states.at(2), QAnimationGroupJob::Running);
- QCOMPARE(animsStateChanged[i]->states.at(3), QAnimationGroupJob::Stopped);
- }
-
- QCOMPARE(seqStateChangedSpy.count(), 2);
- QCOMPARE(seqStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(seqStateChangedSpy.states.at(1), QAnimationGroupJob::Stopped);
-
- //QCOMPARE(seqCurrentAnimChangedSpy.count(), 6);
- //for(int i=0; i<seqCurrentAnimChangedSpy.count(); i++)
- // QCOMPARE(static_cast<QAbstractAnimationJob*>(anims[i%3]), qVariantValue<QAbstractAnimationJob*>(seqCurrentAnimChangedSpy.at(i).at(0)));
-
- group.start();
-
- QCOMPARE(animsStateChanged[0]->count(), 5);
- QCOMPARE(animsStateChanged[1]->count(), 4);
- QCOMPARE(animsStateChanged[2]->count(), 4);
- QCOMPARE(seqStateChangedSpy.count(), 3);
-}
-
-void tst_QSequentialAnimationGroupJob::looping()
-{
- // originally was sequence operating on same object/property
- QSequentialAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
- QAbstractAnimationJob *a1_s_o1 = new TestAnimation;
- QAbstractAnimationJob *a2_s_o1 = new TestAnimation;
- QAbstractAnimationJob *a3_s_o1 = new TestAnimation;
-
- StateChangeListener a1Spy;
- a1_s_o1->addAnimationChangeListener(&a1Spy, QAbstractAnimationJob::StateChange);
- StateChangeListener a2Spy;
- a2_s_o1->addAnimationChangeListener(&a2Spy, QAbstractAnimationJob::StateChange);
- StateChangeListener a3Spy;
- a3_s_o1->addAnimationChangeListener(&a3Spy, QAbstractAnimationJob::StateChange);
- StateChangeListener seqSpy;
- sequence->addAnimationChangeListener(&seqSpy, QAbstractAnimationJob::StateChange);
-
- a2_s_o1->setLoopCount(2);
- sequence->appendAnimation(a1_s_o1);
- sequence->appendAnimation(a2_s_o1);
- sequence->appendAnimation(a3_s_o1);
- sequence->setLoopCount(2);
-
- QSequentialAnimationGroupJob group;
- StateChangeListener groupSpy;
- group.addAnimationChangeListener(&groupSpy, QAbstractAnimationJob::StateChange);
-
- group.appendAnimation(sequence);
- group.setLoopCount(2);
-
- group.start();
- group.pause();
-
- // Current time = 1750
- group.setCurrentTime(1750);
- QCOMPARE(group.currentLoopTime(), 1750);
- QCOMPARE(sequence->currentLoopTime(), 750);
- QCOMPARE(sequence->currentLoop(), 1);
- QCOMPARE(a1_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 1);
- // this animation is at the beginning because it is the current one inside sequence
- QCOMPARE(a3_s_o1->currentLoop(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 0);
- QCOMPARE(sequence->currentAnimation(), a3_s_o1);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Paused);
-
- QCOMPARE(a1Spy.count(), 5); // Running,Paused,Stopped,Running,Stopped
- QVERIFY(compareStates(a1Spy, (StateList() << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Paused
- << QAbstractAnimationJob::Stopped
- << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Stopped)));
-
- QCOMPARE(a2Spy.count(), 4); // Running,Stopped,Running,Stopped
- QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Stopped
- << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Paused)));
-
- QCOMPARE(seqSpy.count(), 2); // Running,Paused
- QCOMPARE(groupSpy.count(), 2); // Running,Paused
-
- // Looping, current time = duration + 1
- group.setCurrentTime(group.duration() + 1);
- QCOMPARE(group.currentLoopTime(), 1);
- QCOMPARE(group.currentLoop(), 1);
- QCOMPARE(sequence->currentLoopTime(), 1);
- QCOMPARE(sequence->currentLoop(), 0);
- QCOMPARE(a1_s_o1->currentLoopTime(), 1);
- QCOMPARE(a2_s_o1->currentLoopTime(), 250);
- QCOMPARE(a2_s_o1->currentLoop(), 1);
- // this animation is at the end because it was run on the previous loop
- QCOMPARE(a3_s_o1->currentLoop(), 0);
- QCOMPARE(a3_s_o1->currentLoopTime(), 250);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
- QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Paused);
- QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Stopped);
-
- QCOMPARE(a1Spy.count(), 7); // Running,Paused,Stopped,Running,Stopped,Running,Stopped
- QCOMPARE(a2Spy.count(), 4); // Running, Stopped, Running, Stopped
- QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Stopped
- << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Paused
- << QAbstractAnimationJob::Stopped)));
- QVERIFY(compareStates(seqSpy, (StateList() << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Paused
- << QAbstractAnimationJob::Stopped
- << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Paused)));
- QCOMPARE(groupSpy.count(), 2);
-
- //cleanup
- a1_s_o1->removeAnimationChangeListener(&a1Spy, QAbstractAnimationJob::StateChange);
- a2_s_o1->removeAnimationChangeListener(&a2Spy, QAbstractAnimationJob::StateChange);
- a3_s_o1->removeAnimationChangeListener(&a3Spy, QAbstractAnimationJob::StateChange);
- sequence->removeAnimationChangeListener(&seqSpy, QAbstractAnimationJob::StateChange);
- group.removeAnimationChangeListener(&groupSpy, QAbstractAnimationJob::StateChange);
-}
-
-void tst_QSequentialAnimationGroupJob::startDelay()
-{
- QSequentialAnimationGroupJob group;
- group.appendAnimation(new QPauseAnimationJob(250));
- group.appendAnimation(new QPauseAnimationJob(125));
- QCOMPARE(group.totalDuration(), 375);
-
- group.start();
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
-
- QTest::qWait(500);
-
- QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped);
- QVERIFY(group.currentLoopTime() == 375);
-}
-
-void tst_QSequentialAnimationGroupJob::clearGroup()
-{
- QSequentialAnimationGroupJob group;
-
- static const int animationCount = 20;
-
- for (int i = 0; i < animationCount/2; ++i) {
- QSequentialAnimationGroupJob *subGroup = new QSequentialAnimationGroupJob;
- group.appendAnimation(subGroup);
- group.appendAnimation(new QPauseAnimationJob(100));
- subGroup->appendAnimation(new QPauseAnimationJob(10));
- }
-
- int count = 0;
- for (QAbstractAnimationJob *anim = group.firstChild(); anim; anim = anim->nextSibling())
- ++count;
- QCOMPARE(count, animationCount);
-
- group.clear();
-
- QVERIFY(!group.firstChild() && !group.lastChild());
- QCOMPARE(group.currentLoopTime(), 0);
-}
-
-void tst_QSequentialAnimationGroupJob::groupWithZeroDurationAnimations()
-{
- QSequentialAnimationGroupJob group;
-
- TestValueAnimation *a1 = new TestValueAnimation(0);
- a1->start = 42;
- a1->end = 43;
- group.appendAnimation(a1);
-
- //this should just run fine and change nothing
- group.setCurrentTime(0);
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(a1));
-
- TestValueAnimation *a2 = new TestValueAnimation(500);
- a2->start = 13;
- a2->end = 31;
- group.appendAnimation(a2);
-
- TestValueAnimation *a3 = new TestValueAnimation(0);
- a3->start = 43;
- a3->end = 44;
- group.appendAnimation(a3);
-
- TestValueAnimation *a4 = new TestValueAnimation(250);
- a4->start = 13;
- a4->end = 75;
- group.appendAnimation(a4);
-
- TestValueAnimation *a5 = new TestValueAnimation(0);
- a5->start = 42;
- a5->end = 12;
- group.appendAnimation(a5);
-
- QCOMPARE((int)a1->value, 43); //### is this actually the behavior we want?
- QCOMPARE((int)a2->value, 0);
- QCOMPARE((int)a3->value, 0);
- QCOMPARE((int)a4->value, 0);
- QCOMPARE((int)a5->value, 0);
-
- group.start();
-
- QCOMPARE((int)a1->value, 43); //### is this actually the behavior we want?
- QCOMPARE((int)a2->value, 13);
- QCOMPARE((int)a3->value, 0);
- QCOMPARE((int)a4->value, 0);
- QCOMPARE((int)a5->value, 0);
-
- QTest::qWait(100);
-
- QCOMPARE((int)a1->value, 43);
- QVERIFY(a2->value > 13 && a2->value < 31);
- QCOMPARE((int)a3->value, 0);
- QCOMPARE((int)a4->value, 0);
- QCOMPARE((int)a5->value, 0);
-
- QTest::qWait(500);
-
- QTRY_COMPARE((int)a3->value, 44);
- QCOMPARE((int)a1->value, 43);
- QCOMPARE((int)a2->value, 31);
- //QCOMPARE((int)a4->value, 36);
- QCOMPARE((int)a5->value, 0);
- QCOMPARE(a1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a3->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a4->state(), QAnimationGroupJob::Running);
- QCOMPARE(a5->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QTest::qWait(500);
-
- QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE((int)a1->value, 43);
- QCOMPARE((int)a2->value, 31);
- QCOMPARE((int)a3->value, 44);
- QCOMPARE((int)a4->value, 75);
- QCOMPARE((int)a5->value, 12);
- QCOMPARE(a1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a2->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a3->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a4->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(a5->state(), QAnimationGroupJob::Stopped);
-}
-
-void tst_QSequentialAnimationGroupJob::propagateGroupUpdateToChildren()
-{
- // this test verifies if group state changes are updating its children correctly
- QSequentialAnimationGroupJob group;
-
- TestAnimation anim1(100);
- TestAnimation anim2(200);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
-
- group.start();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Paused);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-}
-
-void tst_QSequentialAnimationGroupJob::updateChildrenWithRunningGroup()
-{
- // assert that its possible to modify a child's state directly while their group is running
- QSequentialAnimationGroupJob group;
-
- TestAnimation anim(200);
-
- StateChangeListener groupStateChangedSpy;
- group.addAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
- StateChangeListener childStateChangedSpy;
- anim.addAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange);
-
- QCOMPARE(groupStateChangedSpy.count(), 0);
- QCOMPARE(childStateChangedSpy.count(), 0);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim);
-
- group.start();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim.state(), QAnimationGroupJob::Running);
-
- QCOMPARE(groupStateChangedSpy.count(), 1);
- QCOMPARE(childStateChangedSpy.count(), 1);
-
- QCOMPARE(groupStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(childStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
-
- // starting directly a running child will not have any effect
- anim.start();
-
- QCOMPARE(groupStateChangedSpy.count(), 1);
- QCOMPARE(childStateChangedSpy.count(), 1);
-
- anim.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim.state(), QAnimationGroupJob::Paused);
-
- // in the animation stops directly, the group will still be running
- anim.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim.state(), QAnimationGroupJob::Stopped);
-
- //cleanup
- group.removeAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
- anim.removeAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange);
-}
-
-void tst_QSequentialAnimationGroupJob::deleteChildrenWithRunningGroup()
-{
- // test if children can be activated when their group is stopped
- QSequentialAnimationGroupJob group;
-
- TestAnimation *anim1 = new TestAnimation(200);
- group.appendAnimation(anim1);
-
- QCOMPARE(group.duration(), anim1->duration());
-
- group.start();
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim1->state(), QAnimationGroupJob::Running);
-
- QTest::qWait(100);
- QTRY_VERIFY(group.currentLoopTime() > 0);
-
- delete anim1;
- QVERIFY(!group.firstChild());
- QCOMPARE(group.duration(), 0);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(group.currentLoopTime(), 0); //that's the invariant
-}
-
-void tst_QSequentialAnimationGroupJob::startChildrenWithStoppedGroup()
-{
- // test if children can be activated when their group is stopped
- QSequentialAnimationGroupJob group;
-
- TestAnimation anim1(200);
- TestAnimation anim2(200);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
-
- group.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- anim1.start();
- anim2.start();
- anim2.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
-}
-
-void tst_QSequentialAnimationGroupJob::stopGroupWithRunningChild()
-{
- // children that started independently will not be affected by a group stop
- QSequentialAnimationGroupJob group;
-
- TestAnimation anim1(200);
- TestAnimation anim2(200);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(&anim1);
- group.appendAnimation(&anim2);
-
- anim1.start();
- anim2.start();
- anim2.pause();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
-
- group.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
-
- anim1.stop();
- anim2.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
-}
-
-void tst_QSequentialAnimationGroupJob::startGroupWithRunningChild()
-{
- // as the group has precedence over its children, starting a group will restart all the children
- QSequentialAnimationGroupJob group;
-
- TestAnimation *anim1 = new TestAnimation(200);
- TestAnimation *anim2 = new TestAnimation(200);
-
- StateChangeListener stateChangedSpy1;
- anim1->addAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
- StateChangeListener stateChangedSpy2;
- anim2->addAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
-
- QCOMPARE(stateChangedSpy1.count(), 0);
- QCOMPARE(stateChangedSpy2.count(), 0);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2->state(), QAnimationGroupJob::Stopped);
-
- group.appendAnimation(anim1);
- group.appendAnimation(anim2);
-
- anim1->start();
- anim2->start();
- anim2->pause();
-
- QVERIFY(compareStates(stateChangedSpy1, (StateList() << QAbstractAnimationJob::Running)));
-
- QVERIFY(compareStates(stateChangedSpy2, (StateList() << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Paused)));
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1->state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2->state(), QAnimationGroupJob::Paused);
-
- group.start();
-
- QVERIFY(compareStates(stateChangedSpy1, (StateList() << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Stopped
- << QAbstractAnimationJob::Running)));
- QVERIFY(compareStates(stateChangedSpy2, (StateList() << QAbstractAnimationJob::Running
- << QAbstractAnimationJob::Paused)));
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim1->state(), QAnimationGroupJob::Running);
- QCOMPARE(anim2->state(), QAnimationGroupJob::Paused);
-
- QTest::qWait(300);
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2->state(), QAnimationGroupJob::Running);
-
- QCOMPARE(stateChangedSpy2.count(), 4);
- QCOMPARE(stateChangedSpy2.states.at(2), QAnimationGroupJob::Stopped);
- QCOMPARE(stateChangedSpy2.states.at(3), QAnimationGroupJob::Running);
-
- group.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2->state(), QAnimationGroupJob::Stopped);
-
- anim1->removeAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
- anim2->removeAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
-}
-
-void tst_QSequentialAnimationGroupJob::zeroDurationAnimation()
-{
- QSequentialAnimationGroupJob group;
-
- TestAnimation *anim1 = new TestAnimation(0);
- TestAnimation *anim2 = new TestAnimation(100);
- TestValueAnimation *anim3 = new TestValueAnimation(0);
- anim3->end = 100;
-
- StateChangeListener stateChangedSpy;
- anim1->addAnimationChangeListener(&stateChangedSpy, QAbstractAnimationJob::StateChange);
-
- group.appendAnimation(anim1);
- group.appendAnimation(anim2);
- group.appendAnimation(anim3);
- group.setLoopCount(2);
- group.start();
-
- QCOMPARE(stateChangedSpy.count(), 2);
- QCOMPARE(stateChangedSpy.states.at(0), QAnimationGroupJob::Running);
- QCOMPARE(stateChangedSpy.states.at(1), QAnimationGroupJob::Stopped);
-
- QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2->state(), QAnimationGroupJob::Running);
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
-
- //now let's try to seek to the next loop
- group.setCurrentTime(group.duration() + 1);
- QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim2->state(), QAnimationGroupJob::Running);
- QCOMPARE(anim3->state(), QAnimationGroupJob::Stopped);
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- //TODO: test that anim3 was run
- QCOMPARE(anim3->value, qreal(100)); //anim3 should have been run
-
- anim1->removeAnimationChangeListener(&stateChangedSpy, QAbstractAnimationJob::StateChange);
-}
-
-void tst_QSequentialAnimationGroupJob::stopUncontrolledAnimations()
-{
- QSequentialAnimationGroupJob group;
-
- UncontrolledAnimation notTimeDriven;
- QCOMPARE(notTimeDriven.totalDuration(), -1);
-
- TestAnimation loopsForever(100);
- loopsForever.setLoopCount(-1);
-
- group.appendAnimation(&notTimeDriven);
- group.appendAnimation(&loopsForever);
-
- group.start();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running);
- QCOMPARE(loopsForever.state(), QAnimationGroupJob::Stopped);
-
- notTimeDriven.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever.state(), QAnimationGroupJob::Running);
-
- loopsForever.stop();
-
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(loopsForever.state(), QAnimationGroupJob::Stopped);
-}
-
-void tst_QSequentialAnimationGroupJob::finishWithUncontrolledAnimation()
-{
- //1st case:
- //first we test a group with one uncontrolled animation
- QSequentialAnimationGroupJob group;
- UncontrolledAnimation notTimeDriven;
- group.appendAnimation(&notTimeDriven);
- FinishedListener spy;
- group.addAnimationChangeListener(&spy, QAbstractAnimationJob::Completion);
-
- group.start();
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running);
- QCOMPARE(group.currentLoopTime(), 0);
- QCOMPARE(notTimeDriven.currentLoopTime(), 0);
-
- QTest::qWait(300); //wait for the end of notTimeDriven
- QTRY_COMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
- const int actualDuration = notTimeDriven.currentLoopTime();
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(group.currentLoopTime(), actualDuration);
- QCOMPARE(spy.count(), 1);
-
- //2nd case:
- // lets make sure the seeking will work again
- spy.clear();
- TestAnimation anim;
- group.appendAnimation(&anim);
- StateChangeListener animStateChangedSpy;
- anim.addAnimationChangeListener(&animStateChangedSpy, QAbstractAnimationJob::StateChange);
-
- group.setCurrentTime(300);
- QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(notTimeDriven.currentLoopTime(), actualDuration);
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
-
- //3rd case:
- //now let's add a perfectly defined animation at the end
- QCOMPARE(animStateChangedSpy.count(), 0);
- group.start();
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running);
- QCOMPARE(group.currentLoopTime(), 0);
- QCOMPARE(notTimeDriven.currentLoopTime(), 0);
-
- QCOMPARE(animStateChangedSpy.count(), 0);
-
- QTest::qWait(300); //wait for the end of notTimeDriven
- QTRY_COMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim.state(), QAnimationGroupJob::Running);
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
- QCOMPARE(animStateChangedSpy.count(), 1);
- QTest::qWait(300); //wait for the end of anim
-
- QTRY_COMPARE(anim.state(), QAnimationGroupJob::Stopped);
- QCOMPARE(anim.currentLoopTime(), anim.duration());
-
- //we should simply be at the end
- QCOMPARE(spy.count(), 1);
- QCOMPARE(animStateChangedSpy.count(), 2);
- QCOMPARE(group.currentLoopTime(), notTimeDriven.currentLoopTime() + anim.currentLoopTime());
-
- //cleanup
- group.removeAnimationChangeListener(&spy, QAbstractAnimationJob::Completion);
- anim.removeAnimationChangeListener(&animStateChangedSpy, QAbstractAnimationJob::StateChange);
-}
-
-void tst_QSequentialAnimationGroupJob::addRemoveAnimation()
-{
- //this test is specific to the sequential animation group
- QSequentialAnimationGroupJob group;
-
- QCOMPARE(group.duration(), 0);
- QCOMPARE(group.currentLoopTime(), 0);
- QAbstractAnimationJob *anim1 = new TestAnimation;
- group.appendAnimation(anim1);
- QCOMPARE(group.duration(), 250);
- QCOMPARE(group.currentLoopTime(), 0);
- QCOMPARE(group.currentAnimation(), anim1);
-
- //let's append an animation
- QAbstractAnimationJob *anim2 = new TestAnimation;
- group.appendAnimation(anim2);
- QCOMPARE(group.duration(), 500);
- QCOMPARE(group.currentLoopTime(), 0);
- QCOMPARE(group.currentAnimation(), anim1);
-
- //let's prepend an animation
- QAbstractAnimationJob *anim0 = new TestAnimation;
- group.prependAnimation(anim0);
- QCOMPARE(group.duration(), 750);
- QCOMPARE(group.currentLoopTime(), 0);
- QCOMPARE(group.currentAnimation(), anim0); //anim0 has become the new currentAnimation
-
- group.setCurrentTime(300); //anim0 | anim1 | anim2
- QCOMPARE(group.currentLoopTime(), 300);
- QCOMPARE(group.currentAnimation(), anim1);
- QCOMPARE(anim1->currentLoopTime(), 50);
-
- group.removeAnimation(anim0); //anim1 | anim2
- QCOMPARE(group.currentLoopTime(), 50);
- QCOMPARE(group.currentAnimation(), anim1);
- QCOMPARE(anim1->currentLoopTime(), 50);
-
- group.setCurrentTime(0);
- group.prependAnimation(anim0); //anim0 | anim1 | anim2
- group.setCurrentTime(300);
- QCOMPARE(group.currentLoopTime(), 300);
- QCOMPARE(group.currentAnimation(), anim1);
- QCOMPARE(anim1->currentLoopTime(), 50);
-
- group.removeAnimation(anim1); //anim0 | anim2
- QCOMPARE(group.currentLoopTime(), 250);
- QCOMPARE(group.currentAnimation(), anim2);
- QCOMPARE(anim0->currentLoopTime(), 250);
-}
-
-void tst_QSequentialAnimationGroupJob::currentAnimation()
-{
- QSequentialAnimationGroupJob group;
- QVERIFY(group.currentAnimation() == 0);
-
- TestAnimation anim(0);
- group.appendAnimation(&anim);
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
-}
-
-void tst_QSequentialAnimationGroupJob::currentAnimationWithZeroDuration()
-{
- QSequentialAnimationGroupJob group;
- QVERIFY(group.currentAnimation() == 0);
-
- TestAnimation zero1(0);
- TestAnimation zero2(0);
-
- TestAnimation anim;
-
- TestAnimation zero3(0);
- TestAnimation zero4(0);
-
- group.appendAnimation(&zero1);
- group.appendAnimation(&zero2);
- group.appendAnimation(&anim);
- group.appendAnimation(&zero3);
- group.appendAnimation(&zero4);
-
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&zero1));
-
- group.setCurrentTime(0);
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
-
- group.setCurrentTime(group.duration());
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&zero4));
-
- group.setDirection(QAbstractAnimationJob::Backward);
-
- group.setCurrentTime(0);
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&zero1));
-
- group.setCurrentTime(group.duration());
- QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
-}
-
-void tst_QSequentialAnimationGroupJob::insertAnimation()
-{
- QSequentialAnimationGroupJob group;
- group.setLoopCount(2);
- TestAnimation *anim = new TestAnimation;
- group.appendAnimation(anim);
- QCOMPARE(group.duration(), anim->duration());
- group.setCurrentTime(300);
- QCOMPARE(group.currentLoop(), 1);
-
- //this will crash if the sequential group calls duration on the created animation
- group.appendAnimation(new TestAnimation);
-}
-
-class ClearFinishedListener: public QAnimationJobChangeListener
-{
-public:
- ClearFinishedListener(QSequentialAnimationGroupJob *g) : group(g) {}
-
- virtual void animationFinished(QAbstractAnimationJob *)
- {
- group->clear();
- }
-
- QSequentialAnimationGroupJob *group;
-};
-
-class RefillFinishedListener: public QAnimationJobChangeListener
-{
-public:
- RefillFinishedListener(QSequentialAnimationGroupJob *g) : group(g) {}
-
- virtual void animationFinished(QAbstractAnimationJob *)
- {
- group->stop();
- group->clear();
- group->appendAnimation(new TestAnimation);
- group->start();
- }
-
- QSequentialAnimationGroupJob *group;
-};
-
-void tst_QSequentialAnimationGroupJob::clear()
-{
- QSKIP("deleting an animation when finished is not currently supported");
- QSequentialAnimationGroupJob group;
- TestAnimation *anim1 = new TestAnimation;
- group.appendAnimation(anim1);
- ClearFinishedListener clearListener(&group);
- anim1->addAnimationChangeListener(&clearListener, QAbstractAnimationJob::Completion);
-
- TestAnimation *anim2 = new TestAnimation;
- group.appendAnimation(anim2);
- QCOMPARE(group.firstChild(), anim1);
- QCOMPARE(group.lastChild(), anim2);
-
- group.start();
- QTest::qWait(anim1->duration() + 100);
- QTRY_VERIFY(!group.firstChild());
- QCOMPARE(group.state(), QAbstractAnimationJob::Stopped);
- QCOMPARE(group.currentLoopTime(), 0);
-
- anim1 = new TestAnimation;
- group.appendAnimation(anim1);
- RefillFinishedListener refillListener(&group);
- anim1->addAnimationChangeListener(&refillListener, QAbstractAnimationJob::Completion);
- group.start();
- QTest::qWait(anim1->duration() + 100);
- QTRY_COMPARE(group.state(), QAbstractAnimationJob::Running);
-}
-
-void tst_QSequentialAnimationGroupJob::pauseResume()
-{
- QParallelAnimationGroupJob group;
- TestAnimation *anim = new TestAnimation;
- group.appendAnimation(anim);
- StateChangeListener spy;
- anim->addAnimationChangeListener(&spy, QAbstractAnimationJob::StateChange);
- QCOMPARE(group.duration(), 250);
- group.start();
- QTest::qWait(100);
- QTRY_COMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(anim->state(), QAnimationGroupJob::Running);
- QCOMPARE(spy.count(), 1);
- spy.clear();
- const int currentTime = group.currentLoopTime();
- QCOMPARE(anim->currentLoopTime(), currentTime);
-
- group.pause();
- QCOMPARE(group.state(), QAnimationGroupJob::Paused);
- QCOMPARE(group.currentLoopTime(), currentTime);
- QCOMPARE(anim->state(), QAnimationGroupJob::Paused);
- QCOMPARE(anim->currentLoopTime(), currentTime);
- QCOMPARE(spy.count(), 1);
- spy.clear();
-
- group.resume();
- QCOMPARE(group.state(), QAnimationGroupJob::Running);
- QCOMPARE(group.currentLoopTime(), currentTime);
- QCOMPARE(anim->state(), QAnimationGroupJob::Running);
- QCOMPARE(anim->currentLoopTime(), currentTime);
- QCOMPARE(spy.count(), 1);
-
- anim->removeAnimationChangeListener(&spy, QAbstractAnimationJob::StateChange);
-}
-
-QTEST_MAIN(tst_QSequentialAnimationGroupJob)
-#include "tst_qsequentialanimationgroupjob.moc"
diff --git a/tests/auto/declarative/debugger/debugger.pro b/tests/auto/declarative/debugger/debugger.pro
deleted file mode 100644
index 314f0d1b78..0000000000
--- a/tests/auto/declarative/debugger/debugger.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TEMPLATE = subdirs
-
-PRIVATETESTS += \
- qdeclarativeenginedebug \
- qdeclarativedebugclient \
- qdeclarativedebugservice \
- qdeclarativedebugjs \
- qdeclarativeinspector \
- qdeclarativeprofilerservice \
- qpacketprotocol \
- qv8profilerservice \
- qdebugmessageservice
-
-contains(QT_CONFIG, private_tests) {
- SUBDIRS += $$PRIVATETESTS
-}
diff --git a/tests/auto/declarative/debugger/qdebugmessageservice/qdebugmessageservice.pro b/tests/auto/declarative/debugger/qdebugmessageservice/qdebugmessageservice.pro
deleted file mode 100644
index 698e9604f0..0000000000
--- a/tests/auto/declarative/debugger/qdebugmessageservice/qdebugmessageservice.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdebugmessageservice
-QT += network declarative-private testlib
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-
-SOURCES += tst_qdebugmessageservice.cpp \
- ../shared/debugutil.cpp
-
-INCLUDEPATH += ../shared
-
-include(../../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-OTHER_FILES += data/test.qml
diff --git a/tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp b/tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp
deleted file mode 100644
index 94738dc083..0000000000
--- a/tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtDeclarative/private/qdeclarativedebugclient_p.h>
-
-//QDeclarativeDebugTest
-#include "../shared/debugutil_p.h"
-#include "../../../shared/util.h"
-
-#include <QtCore/QString>
-#include <QtTest/QtTest>
-
-const char *NORMALMODE = "-qmljsdebugger=port:3777,block";
-const char *QMLFILE = "test.qml";
-
-class QDeclarativeDebugMsgClient;
-class tst_QDebugMessageService : public QDeclarativeDataTest
-{
- Q_OBJECT
-
-public:
- tst_QDebugMessageService();
-
- void init();
-
-private slots:
- void initTestCase();
- void cleanupTestCase();
-
- void cleanup();
-
- void retrieveDebugOutput();
-
-private:
- QDeclarativeDebugProcess *m_process;
- QDeclarativeDebugMsgClient *m_client;
- QDeclarativeDebugConnection *m_connection;
-};
-
-struct LogEntry {
- LogEntry(QtMsgType _type, QString _message)
- : type(_type), message(_message) {}
-
- QtMsgType type;
- QString message;
- int line;
- QString file;
- QString function;
-
- QString toString() const { return QString::number(type) + ": " + message; }
-};
-
-bool operator==(const LogEntry &t1, const LogEntry &t2)
-{
- return t1.type == t2.type && t1.message == t2.message
- && t1.line == t2.line && t1.file == t2.file
- && t1.function == t2.function;
-}
-
-class QDeclarativeDebugMsgClient : public QDeclarativeDebugClient
-{
- Q_OBJECT
-public:
- QDeclarativeDebugMsgClient(QDeclarativeDebugConnection *connection)
- : QDeclarativeDebugClient(QLatin1String("DebugMessages"), connection)
- {
- }
-
- QList<LogEntry> logBuffer;
-
-protected:
- //inherited from QDeclarativeDebugClient
- void stateChanged(State state);
- void messageReceived(const QByteArray &data);
-
-signals:
- void enabled();
- void debugOutput();
-};
-
-void QDeclarativeDebugMsgClient::stateChanged(State state)
-{
- if (state == Enabled) {
- emit enabled();
- }
-}
-
-void QDeclarativeDebugMsgClient::messageReceived(const QByteArray &data)
-{
- QDataStream ds(data);
- QByteArray command;
- ds >> command;
-
- if (command == "MESSAGE") {
- int type;
- QByteArray message;
- QByteArray file;
- QByteArray function;
- int line;
- ds >> type >> message >> file >> line >> function;
- QVERIFY(ds.atEnd());
-
- QVERIFY(type >= QtDebugMsg);
- QVERIFY(type <= QtFatalMsg);
-
- LogEntry entry((QtMsgType)type, QString::fromUtf8(message));
- entry.line = line;
- entry.file = QString::fromUtf8(file);
- entry.function = QString::fromUtf8(function);
- logBuffer << entry;
- emit debugOutput();
- } else {
- QFAIL("Unknown message");
- }
-}
-
-tst_QDebugMessageService::tst_QDebugMessageService()
-{
-}
-
-void tst_QDebugMessageService::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- m_process = 0;
- m_client = 0;
- m_connection = 0;
-}
-
-void tst_QDebugMessageService::cleanupTestCase()
-{
- if (m_process)
- delete m_process;
-
- if (m_client)
- delete m_client;
-
- if (m_connection)
- delete m_connection;
-}
-
-void tst_QDebugMessageService::init()
-{
- m_connection = new QDeclarativeDebugConnection();
- m_process = new QDeclarativeDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene");
- m_client = new QDeclarativeDebugMsgClient(m_connection);
-
- m_process->start(QStringList() << QLatin1String(NORMALMODE) << QDeclarativeDataTest::instance()->testFile(QMLFILE));
- if (!m_process->waitForSessionStart()) {
- QFAIL(QString("Could not launch app. Application output: \n%1").arg(m_process->output()).toAscii());
- }
-
- m_connection->connectToHost("127.0.0.1", 3777);
- QVERIFY(m_connection->waitForConnected());
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(enabled())));
-}
-
-void tst_QDebugMessageService::cleanup()
-{
- if (QTest::currentTestFailed())
- qDebug() << m_process->output();
- if (m_process)
- delete m_process;
-
- if (m_client)
- delete m_client;
-
- if (m_connection)
- delete m_connection;
-
- m_process = 0;
- m_client = 0;
- m_connection = 0;
-}
-
-void tst_QDebugMessageService::retrieveDebugOutput()
-{
- init();
-
- int maxTries = 2;
- while ((m_client->logBuffer.size() < 2)
- || (maxTries-- > 0))
- QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(debugOutput()), 1000);
-
- QVERIFY(m_client->logBuffer.size() >= 2);
-
- const QString path =
- QUrl::fromLocalFile(QDeclarativeDataTest::instance()->testFile(QMLFILE)).toString();
- LogEntry entry1(QtDebugMsg, QLatin1String("console.log"));
- entry1.line = 48;
- entry1.file = path;
- entry1.function = QLatin1String("onCompleted");
- LogEntry entry2(QtDebugMsg, QLatin1String("console.count: 1"));
- entry2.line = 49;
- entry2.file = path;
- entry2.function = QLatin1String("onCompleted");
-
- QVERIFY(m_client->logBuffer.contains(entry1));
- QVERIFY(m_client->logBuffer.contains(entry2));
-}
-
-QTEST_MAIN(tst_QDebugMessageService)
-
-#include "tst_qdebugmessageservice.moc"
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugclient/qdeclarativedebugclient.pro b/tests/auto/declarative/debugger/qdeclarativedebugclient/qdeclarativedebugclient.pro
deleted file mode 100644
index 8eb33fb81d..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativedebugclient/qdeclarativedebugclient.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativedebugclient
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qdeclarativedebugclient.cpp \
- ../shared/debugutil.cpp
-
-CONFIG += declarative_debug
-
-QT += declarative-private testlib
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp b/tests/auto/declarative/debugger/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
deleted file mode 100644
index e059c7617b..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativedebugclient/tst_qdeclarativedebugclient.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QHostAddress>
-#include <QDebug>
-#include <QThread>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-
-#include "../shared/debugutil_p.h"
-
-#define PORT 13770
-#define STR_PORT "13770"
-
-class tst_QDeclarativeDebugClient : public QObject
-{
- Q_OBJECT
-
-private:
- QDeclarativeDebugConnection *m_conn;
-
-private slots:
- void initTestCase();
-
- void name();
- void state();
- void sendMessage();
- void parallelConnect();
- void sequentialConnect();
-};
-
-void tst_QDeclarativeDebugClient::initTestCase()
-{
- const QString waitingMsg = QString("QDeclarativeDebugServer: Waiting for connection on port %1...").arg(PORT);
- QTest::ignoreMessage(QtWarningMsg, waitingMsg.toAscii().constData());
- new QDeclarativeEngine(this);
-
- m_conn = new QDeclarativeDebugConnection(this);
-
- QDeclarativeDebugTestClient client("tst_QDeclarativeDebugClient::handshake()", m_conn);
- QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::handshake()");
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
- for (int i = 0; i < 50; ++i) {
- // try for 5 seconds ...
- m_conn->connectToHost("127.0.0.1", PORT);
- if (m_conn->waitForConnected())
- break;
- QTest::qSleep(100);
- }
-
- QVERIFY(m_conn->isConnected());
-
- QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
- QTRY_COMPARE(client.state(), QDeclarativeDebugClient::Enabled);
-}
-
-void tst_QDeclarativeDebugClient::name()
-{
- QString name = "tst_QDeclarativeDebugClient::name()";
-
- QDeclarativeDebugClient client(name, m_conn);
- QCOMPARE(client.name(), name);
-}
-
-void tst_QDeclarativeDebugClient::state()
-{
- {
- QDeclarativeDebugConnection dummyConn;
- QDeclarativeDebugClient client("tst_QDeclarativeDebugClient::state()", &dummyConn);
- QCOMPARE(client.state(), QDeclarativeDebugClient::NotConnected);
- QCOMPARE(client.serviceVersion(), -1.0f);
- }
-
- QDeclarativeDebugTestClient client("tst_QDeclarativeDebugClient::state()", m_conn);
- QCOMPARE(client.state(), QDeclarativeDebugClient::Unavailable);
-
- {
- QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::state()", 2);
- QTRY_COMPARE(client.state(), QDeclarativeDebugClient::Enabled);
- QCOMPARE(client.serviceVersion(), 2.0f);
- }
-
- QTRY_COMPARE(client.state(), QDeclarativeDebugClient::Unavailable);
-
- // duplicate plugin name
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugClient: Conflicting plugin name \"tst_QDeclarativeDebugClient::state()\" ");
- QDeclarativeDebugClient client2("tst_QDeclarativeDebugClient::state()", m_conn);
- QCOMPARE(client2.state(), QDeclarativeDebugClient::NotConnected);
-
- QDeclarativeDebugClient client3("tst_QDeclarativeDebugClient::state3()", 0);
- QCOMPARE(client3.state(), QDeclarativeDebugClient::NotConnected);
-}
-
-void tst_QDeclarativeDebugClient::sendMessage()
-{
- QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::sendMessage()");
- QDeclarativeDebugTestClient client("tst_QDeclarativeDebugClient::sendMessage()", m_conn);
-
- QByteArray msg = "hello!";
-
- QTRY_COMPARE(client.state(), QDeclarativeDebugClient::Enabled);
-
- client.sendMessage(msg);
- QByteArray resp = client.waitForResponse();
- QCOMPARE(resp, msg);
-}
-
-void tst_QDeclarativeDebugClient::parallelConnect()
-{
- QDeclarativeDebugConnection connection2;
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Another client is already connected");
- // will connect & immediately disconnect
- connection2.connectToHost("127.0.0.1", PORT);
- QVERIFY(connection2.waitForConnected());
- QTRY_COMPARE(connection2.state(), QAbstractSocket::UnconnectedState);
- QVERIFY(m_conn->isConnected());
-}
-
-void tst_QDeclarativeDebugClient::sequentialConnect()
-{
- QDeclarativeDebugConnection connection2;
- QDeclarativeDebugTestClient client2("tst_QDeclarativeDebugClient::handshake()", &connection2);
- QDeclarativeDebugTestService service("tst_QDeclarativeDebugClient::handshake()");
-
- m_conn->close();
- QVERIFY(!m_conn->isConnected());
- QCOMPARE(m_conn->state(), QAbstractSocket::UnconnectedState);
-
- // Make sure that the disconnect is actually delivered to the server
- QTest::qWait(100);
-
- connection2.connectToHost("127.0.0.1", PORT);
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
- QVERIFY(connection2.waitForConnected());
- QVERIFY(connection2.isConnected());
- QTRY_VERIFY(client2.state() == QDeclarativeDebugClient::Enabled);
-}
-
-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];
- char arg[] = "-qmljsdebugger=port:" STR_PORT;
- _argv[_argc - 1] = arg;
-
- QGuiApplication app(_argc, _argv);
- tst_QDeclarativeDebugClient tc;
- return QTest::qExec(&tc, _argc, _argv);
- delete _argv;
-}
-
-#include "tst_qdeclarativedebugclient.moc"
-
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro b/tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro
deleted file mode 100644
index 5618995b4d..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/qdeclarativedebugjs.pro
+++ /dev/null
@@ -1,29 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativedebugjs
-QT += declarative-private testlib
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qdeclarativedebugjs.cpp \
- ../shared/debugutil.cpp
-
-INCLUDEPATH += ../shared
-
-include (../../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-OTHER_FILES += data/test.qml data/test.js \
- data/timer.qml \
- data/exception.qml \
- data/oncompleted.qml \
- data/loadjsfile.qml \
- data/condition.qml \
- data/changeBreakpoint.qml \
- data/stepAction.qml \
- data/breakpointRelocation.qml \
- data/createComponent.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp b/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp
deleted file mode 100644
index 7d57c8eda2..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/tst_qdeclarativedebugjs.cpp
+++ /dev/null
@@ -1,1790 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QtCore/QProcess>
-#include <QtCore/QTimer>
-#include <QtCore/QFileInfo>
-#include <QtCore/QDir>
-#include <QtCore/QMutex>
-#include <QtCore/QLibraryInfo>
-#include <QtDeclarative/private/qdeclarativedebugclient_p.h>
-#include <QtDeclarative/QJSEngine>
-
-//QDeclarativeDebugTest
-#include "../shared/debugutil_p.h"
-#include "../../../shared/util.h"
-
-const char *V8REQUEST = "v8request";
-const char *V8MESSAGE = "v8message";
-const char *SEQ = "seq";
-const char *TYPE = "type";
-const char *COMMAND = "command";
-const char *ARGUMENTS = "arguments";
-const char *STEPACTION = "stepaction";
-const char *STEPCOUNT = "stepcount";
-const char *EXPRESSION = "expression";
-const char *FRAME = "frame";
-const char *GLOBAL = "global";
-const char *DISABLEBREAK = "disable_break";
-const char *HANDLES = "handles";
-const char *INCLUDESOURCE = "includeSource";
-const char *FROMFRAME = "fromFrame";
-const char *TOFRAME = "toFrame";
-const char *BOTTOM = "bottom";
-const char *NUMBER = "number";
-const char *FRAMENUMBER = "frameNumber";
-const char *TYPES = "types";
-const char *IDS = "ids";
-const char *FILTER = "filter";
-const char *FROMLINE = "fromLine";
-const char *TOLINE = "toLine";
-const char *TARGET = "target";
-const char *LINE = "line";
-const char *COLUMN = "column";
-const char *ENABLED = "enabled";
-const char *CONDITION = "condition";
-const char *IGNORECOUNT = "ignoreCount";
-const char *BREAKPOINT = "breakpoint";
-const char *FLAGS = "flags";
-
-const char *CONTINEDEBUGGING = "continue";
-const char *EVALUATE = "evaluate";
-const char *LOOKUP = "lookup";
-const char *BACKTRACE = "backtrace";
-const char *SCOPE = "scope";
-const char *SCOPES = "scopes";
-const char *SCRIPTS = "scripts";
-const char *SOURCE = "source";
-const char *SETBREAKPOINT = "setbreakpoint";
-const char *CHANGEBREAKPOINT = "changebreakpoint";
-const char *CLEARBREAKPOINT = "clearbreakpoint";
-const char *SETEXCEPTIONBREAK = "setexceptionbreak";
-const char *V8FLAGS = "v8flags";
-const char *VERSION = "version";
-const char *DISCONNECT = "disconnect";
-const char *LISTBREAKPOINTS = "listbreakpoints";
-const char *GARBAGECOLLECTOR = "gc";
-//const char *PROFILE = "profile";
-
-const char *CONNECT = "connect";
-const char *INTERRUPT = "interrupt";
-const char *BREAKAFTERCOMPILE = "breakaftercompile";
-
-const char *REQUEST = "request";
-const char *IN = "in";
-const char *NEXT = "next";
-const char *OUT = "out";
-
-const char *FUNCTION = "function";
-const char *SCRIPT = "script";
-const char *SCRIPTREGEXP = "scriptRegExp";
-const char *EVENT = "event";
-
-const char *ALL = "all";
-const char *UNCAUGHT = "uncaught";
-
-//const char *PAUSE = "pause";
-//const char *RESUME = "resume";
-
-const char *BLOCKMODE = "-qmljsdebugger=port:3771,block";
-const char *NORMALMODE = "-qmljsdebugger=port:3771";
-const char *TEST_QMLFILE = "test.qml";
-const char *TEST_JSFILE = "test.js";
-const char *TIMER_QMLFILE = "timer.qml";
-const char *LOADJSFILE_QMLFILE = "loadjsfile.qml";
-const char *EXCEPTION_QMLFILE = "exception.qml";
-const char *ONCOMPLETED_QMLFILE = "oncompleted.qml";
-const char *CREATECOMPONENT_QMLFILE = "createComponent.qml";
-const char *CONDITION_QMLFILE = "condition.qml";
-const char *CHANGEBREAKPOINT_QMLFILE = "changeBreakpoint.qml";
-const char *STEPACTION_QMLFILE = "stepAction.qml";
-const char *BREAKPOINTRELOCATION_QMLFILE = "breakpointRelocation.qml";
-
-#define VARIANTMAPINIT \
- QString obj("{}"); \
- QJSValue jsonVal = parser.call(QJSValueList() << obj); \
- jsonVal.setProperty(SEQ,QJSValue(seq++)); \
- jsonVal.setProperty(TYPE,REQUEST);
-
-
-#undef QVERIFY
-#define QVERIFY(statement) \
-do {\
- if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) {\
- if (QTest::currentTestFailed()) \
- qDebug().nospace() << "\nDEBUGGEE OUTPUT:\n" << process->output();\
- return;\
- }\
-} while (0)
-
-
-class QJSDebugClient;
-
-class tst_QDeclarativeDebugJS : public QDeclarativeDataTest
-{
- Q_OBJECT
-
- bool init(const QString &qmlFile = QString(TEST_QMLFILE), bool blockMode = true);
-
-private slots:
- void initTestCase();
- void cleanupTestCase();
-
- void cleanup();
-
- void connect();
- void interrupt();
- void breakAfterCompile();
- void getVersion();
- void getVersionWhenAttaching();
-
- void applyV8Flags();
-
- void disconnect();
-
- void gc();
-
- void listBreakpoints();
-
- void setBreakpointInScriptOnCompleted();
- void setBreakpointInScriptOnComponentCreated();
- void setBreakpointInScriptOnTimerCallback();
- void setBreakpointInScriptInDifferentFile();
- void setBreakpointInScriptOnComment();
- void setBreakpointInScriptOnEmptyLine();
- void setBreakpointInScriptWithCondition();
- //void setBreakpointInFunction(); //NOT SUPPORTED
- void setBreakpointOnEvent();
- void setBreakpointWhenAttaching();
-
- void changeBreakpoint();
- void changeBreakpointOnCondition();
-
- void clearBreakpoint();
-
- void setExceptionBreak();
-
- void stepNext();
- void stepNextWithCount();
- void stepIn();
- void stepOut();
- void continueDebugging();
-
- void backtrace();
-
- void getFrameDetails();
-
- void getScopeDetails();
-
- void evaluateInGlobalScope();
- void evaluateInLocalScope();
-
- void getScopes();
-
- void getScripts();
-
- void getSource();
-
- // void profile(); //NOT SUPPORTED
-
- // void verifyQMLOptimizerDisabled();
-
-private:
- QDeclarativeDebugProcess *process;
- QJSDebugClient *client;
- QDeclarativeDebugConnection *connection;
- QTime t;
-};
-
-class QJSDebugClient : public QDeclarativeDebugClient
-{
- Q_OBJECT
-public:
- enum StepAction
- {
- Continue,
- In,
- Out,
- Next
- };
-
- enum Exception
- {
- All,
- Uncaught
- };
-
-// enum ProfileCommand
-// {
-// Pause,
-// Resume
-// };
-
- QJSDebugClient(QDeclarativeDebugConnection *connection)
- : QDeclarativeDebugClient(QLatin1String("V8Debugger"), connection),
- seq(0)
- {
- parser = jsEngine.evaluate(QLatin1String("JSON.parse"));
- stringify = jsEngine.evaluate(QLatin1String("JSON.stringify"));
- }
-
- void connect();
- void interrupt();
- void breakAfterCompile(bool enabled);
-
- void continueDebugging(StepAction stepAction, int stepCount = 1);
- void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
- void lookup(QList<int> handles, bool includeSource = false);
- void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false);
- void frame(int number = -1);
- void scope(int number = -1, int frameNumber = -1);
- void scopes(int frameNumber = -1);
- void scripts(int types = 4, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant());
- void source(int frame = -1, int fromLine = -1, int toLine = -1);
- void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = true, QString condition = QString(), int ignoreCount = -1);
- void changeBreakpoint(int breakpoint, bool enabled = true, QString condition = QString(), int ignoreCount = -1);
- void clearBreakpoint(int breakpoint);
- void setExceptionBreak(Exception type, bool enabled = false);
- void v8flags(QString flags);
- void version();
- //void profile(ProfileCommand command); //NOT SUPPORTED
- void disconnect();
- void gc();
- void listBreakpoints();
-
-protected:
- //inherited from QDeclarativeDebugClient
- void stateChanged(State state);
- void messageReceived(const QByteArray &data);
-
-signals:
- void enabled();
- void connected();
- void interruptRequested();
- void breakAfterCompileRequested();
- void result();
- void stopped();
-
-private:
- void sendMessage(const QByteArray &);
- void flushSendBuffer();
- QByteArray packMessage(const QByteArray &type, const QByteArray &message = QByteArray());
-
-private:
- QJSEngine jsEngine;
- int seq;
-
- QList<QByteArray> sendBuffer;
-public:
- QJSValue parser;
- QJSValue stringify;
- QByteArray response;
-
-};
-
-void QJSDebugClient::connect()
-{
- sendMessage(packMessage(CONNECT));
-}
-
-void QJSDebugClient::interrupt()
-{
- sendMessage(packMessage(INTERRUPT));
-}
-
-void QJSDebugClient::breakAfterCompile(bool enabled)
-{
- QByteArray request;
- QDataStream rs(&request, QIODevice::WriteOnly);
- rs << enabled;
- sendMessage(packMessage(BREAKAFTERCOMPILE, request));
-}
-
-void QJSDebugClient::continueDebugging(StepAction action, int count)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "continue",
- // "arguments" : { "stepaction" : <"in", "next" or "out">,
- // "stepcount" : <number of steps (default 1)>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CONTINEDEBUGGING)));
-
- if (action != Continue) {
- QJSValue args = parser.call(QJSValueList() << obj);
- switch (action) {
- case In: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(IN)));
- break;
- case Out: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(OUT)));
- break;
- case Next: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(NEXT)));
- break;
- default:break;
- }
- if (!args.isUndefined()) {
- if (count != 1)
- args.setProperty(QLatin1String(STEPCOUNT),QJSValue(count));
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
- }
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::evaluate(QString expr, bool global, bool disableBreak, int frame, const QVariantMap &/*addContext*/)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "evaluate",
- // "arguments" : { "expression" : <expression to evaluate>,
- // "frame" : <number>,
- // "global" : <boolean>,
- // "disable_break" : <boolean>,
- // "additional_context" : [
- // { "name" : <name1>, "handle" : <handle1> },
- // { "name" : <name2>, "handle" : <handle2> },
- // ...
- // ]
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(EVALUATE)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(EXPRESSION),QJSValue(expr));
-
- if (frame != -1)
- args.setProperty(QLatin1String(FRAME),QJSValue(frame));
-
- if (global)
- args.setProperty(QLatin1String(GLOBAL),QJSValue(global));
-
- if (disableBreak)
- args.setProperty(QLatin1String(DISABLEBREAK),QJSValue(disableBreak));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::lookup(QList<int> handles, bool includeSource)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "lookup",
- // "arguments" : { "handles" : <array of handles>,
- // "includeSource" : <boolean indicating whether the source will be included when script objects are returned>,
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(LOOKUP)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- QString arr("[]");
- QJSValue array = parser.call(QJSValueList() << arr);
- int index = 0;
- foreach (int handle, handles) {
- array.setProperty(index++,QJSValue(handle));
- }
- args.setProperty(QLatin1String(HANDLES),array);
-
- if (includeSource)
- args.setProperty(QLatin1String(INCLUDESOURCE),QJSValue(includeSource));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::backtrace(int fromFrame, int toFrame, bool bottom)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "backtrace",
- // "arguments" : { "fromFrame" : <number>
- // "toFrame" : <number>
- // "bottom" : <boolean, set to true if the bottom of the stack is requested>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(BACKTRACE)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- if (fromFrame != -1)
- args.setProperty(QLatin1String(FROMFRAME),QJSValue(fromFrame));
-
- if (toFrame != -1)
- args.setProperty(QLatin1String(TOFRAME),QJSValue(toFrame));
-
- if (bottom)
- args.setProperty(QLatin1String(BOTTOM),QJSValue(bottom));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::frame(int number)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "frame",
- // "arguments" : { "number" : <frame number>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(FRAME)));
-
- if (number != -1) {
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(NUMBER),QJSValue(number));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::scope(int number, int frameNumber)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "scope",
- // "arguments" : { "number" : <scope number>
- // "frameNumber" : <frame number, optional uses selected frame if missing>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCOPE)));
-
- if (number != -1) {
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(NUMBER),QJSValue(number));
-
- if (frameNumber != -1)
- args.setProperty(QLatin1String(FRAMENUMBER),QJSValue(frameNumber));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::scopes(int frameNumber)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "scopes",
- // "arguments" : { "frameNumber" : <frame number, optional uses selected frame if missing>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCOPES)));
-
- if (frameNumber != -1) {
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(FRAMENUMBER),QJSValue(frameNumber));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::scripts(int types, QList<int> ids, bool includeSource, QVariant /*filter*/)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "scripts",
- // "arguments" : { "types" : <types of scripts to retrieve
- // set bit 0 for native scripts
- // set bit 1 for extension scripts
- // set bit 2 for normal scripts
- // (default is 4 for normal scripts)>
- // "ids" : <array of id's of scripts to return. If this is not specified all scripts are requrned>
- // "includeSource" : <boolean indicating whether the source code should be included for the scripts returned>
- // "filter" : <string or number: filter string or script id.
- // If a number is specified, then only the script with the same number as its script id will be retrieved.
- // If a string is specified, then only scripts whose names contain the filter string will be retrieved.>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCRIPTS)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
- args.setProperty(QLatin1String(TYPES),QJSValue(types));
-
- if (ids.count()) {
- QString arr("[]");
- QJSValue array = parser.call(QJSValueList() << arr);
- int index = 0;
- foreach (int id, ids) {
- array.setProperty(index++,QJSValue(id));
- }
- args.setProperty(QLatin1String(IDS),array);
- }
-
- if (includeSource)
- args.setProperty(QLatin1String(INCLUDESOURCE),QJSValue(includeSource));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::source(int frame, int fromLine, int toLine)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "source",
- // "arguments" : { "frame" : <frame number (default selected frame)>
- // "fromLine" : <from line within the source default is line 0>
- // "toLine" : <to line within the source this line is not included in
- // the result default is the number of lines in the script>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SOURCE)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- if (frame != -1)
- args.setProperty(QLatin1String(FRAME),QJSValue(frame));
-
- if (fromLine != -1)
- args.setProperty(QLatin1String(FROMLINE),QJSValue(fromLine));
-
- if (toLine != -1)
- args.setProperty(QLatin1String(TOLINE),QJSValue(toLine));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::setBreakpoint(QString type, QString target, int line, int column, bool enabled, QString condition, int ignoreCount)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "setbreakpoint",
- // "arguments" : { "type" : <"function" or "script" or "scriptId" or "scriptRegExp">
- // "target" : <function expression or script identification>
- // "line" : <line in script or function>
- // "column" : <character position within the line>
- // "enabled" : <initial enabled state. True or false, default is true>
- // "condition" : <string with break point condition>
- // "ignoreCount" : <number specifying the number of break point hits to ignore, default value is 0>
- // }
- // }
-
- if (type == QLatin1String(EVENT)) {
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << target.toUtf8() << enabled;
- sendMessage(packMessage(QByteArray("breakonsignal"), reply));
-
- } else {
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SETBREAKPOINT)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- args.setProperty(QLatin1String(TYPE),QJSValue(type));
- args.setProperty(QLatin1String(TARGET),QJSValue(target));
-
- if (line != -1)
- args.setProperty(QLatin1String(LINE),QJSValue(line));
-
- if (column != -1)
- args.setProperty(QLatin1String(COLUMN),QJSValue(column));
-
- args.setProperty(QLatin1String(ENABLED),QJSValue(enabled));
-
- if (!condition.isEmpty())
- args.setProperty(QLatin1String(CONDITION),QJSValue(condition));
-
- if (ignoreCount != -1)
- args.setProperty(QLatin1String(IGNORECOUNT),QJSValue(ignoreCount));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
- }
-}
-
-void QJSDebugClient::changeBreakpoint(int breakpoint, bool enabled, QString condition, int ignoreCount)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "changebreakpoint",
- // "arguments" : { "breakpoint" : <number of the break point to clear>
- // "enabled" : <initial enabled state. True or false, default is true>
- // "condition" : <string with break point condition>
- // "ignoreCount" : <number specifying the number of break point hits }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CHANGEBREAKPOINT)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- args.setProperty(QLatin1String(BREAKPOINT),QJSValue(breakpoint));
-
- args.setProperty(QLatin1String(ENABLED),QJSValue(enabled));
-
- if (!condition.isEmpty())
- args.setProperty(QLatin1String(CONDITION),QJSValue(condition));
-
- if (ignoreCount != -1)
- args.setProperty(QLatin1String(IGNORECOUNT),QJSValue(ignoreCount));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::clearBreakpoint(int breakpoint)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "clearbreakpoint",
- // "arguments" : { "breakpoint" : <number of the break point to clear>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CLEARBREAKPOINT)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- args.setProperty(QLatin1String(BREAKPOINT),QJSValue(breakpoint));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::setExceptionBreak(Exception type, bool enabled)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "setexceptionbreak",
- // "arguments" : { "type" : <string: "all", or "uncaught">,
- // "enabled" : <optional bool: enables the break type if true>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SETEXCEPTIONBREAK)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- if (type == All)
- args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(ALL)));
- else if (type == Uncaught)
- args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(UNCAUGHT)));
-
- if (enabled)
- args.setProperty(QLatin1String(ENABLED),QJSValue(enabled));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::v8flags(QString flags)
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "v8flags",
- // "arguments" : { "flags" : <string: a sequence of v8 flags just like those used on the command line>
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(V8FLAGS)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- args.setProperty(QLatin1String(FLAGS),QJSValue(flags));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::version()
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "version",
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(VERSION)));
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-//void QJSDebugClient::profile(ProfileCommand command)
-//{
-//// { "seq" : <number>,
-//// "type" : "request",
-//// "command" : "profile",
-//// "arguments" : { "command" : "resume" or "pause" }
-//// }
-// VARIANTMAPINIT;
-// jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(PROFILE)));
-
-// QJSValue args = parser.call(QJSValueList() << obj);
-
-// if (command == Resume)
-// args.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(RESUME)));
-// else
-// args.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(PAUSE)));
-
-// args.setProperty(QLatin1String("modules"),QJSValue(1));
-// if (!args.isUndefined()) {
-// jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
-// }
-
-// QJSValue json = stringify.call(QJSValueList() << jsonVal);
-// sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-//}
-
-void QJSDebugClient::disconnect()
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "disconnect",
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(DISCONNECT)));
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(DISCONNECT, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::gc()
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "gc",
- // "arguments" : { "type" : <string: "all">,
- // }
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(GARBAGECOLLECTOR)));
-
- QJSValue args = parser.call(QJSValueList() << obj);
-
- args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(ALL)));
-
- if (!args.isUndefined()) {
- jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
- }
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::listBreakpoints()
-{
- // { "seq" : <number>,
- // "type" : "request",
- // "command" : "listbreakpoints",
- // }
- VARIANTMAPINIT;
- jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(LISTBREAKPOINTS)));
-
- QJSValue json = stringify.call(QJSValueList() << jsonVal);
- sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
-}
-
-void QJSDebugClient::stateChanged(State state)
-{
- if (state == Enabled) {
- flushSendBuffer();
- emit enabled();
- }
-}
-
-void QJSDebugClient::messageReceived(const QByteArray &data)
-{
- QDataStream ds(data);
- QByteArray command;
- ds >> command;
-
- if (command == "V8DEBUG") {
- QByteArray type;
- ds >> type >> response;
-
- if (type == CONNECT) {
- emit connected();
-
- } else if (type == INTERRUPT) {
- emit interruptRequested();
-
- } else if (type == V8MESSAGE) {
- QString jsonString(response);
- QVariantMap value = parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
- QString type = value.value("type").toString();
-
- if (type == "response") {
-
- if (!value.value("success").toBool()) {
-// qDebug() << "Error: The test case will fail since no signal is emitted";
- return;
- }
-
- QString debugCommand(value.value("command").toString());
- if (debugCommand == "backtrace" ||
- debugCommand == "lookup" ||
- debugCommand == "setbreakpoint" ||
- debugCommand == "evaluate" ||
- debugCommand == "listbreakpoints" ||
- debugCommand == "version" ||
- debugCommand == "v8flags" ||
- debugCommand == "disconnect" ||
- debugCommand == "gc" ||
- debugCommand == "changebreakpoint" ||
- debugCommand == "clearbreakpoint" ||
- debugCommand == "frame" ||
- debugCommand == "scope" ||
- debugCommand == "scopes" ||
- debugCommand == "scripts" ||
- debugCommand == "source" ||
- debugCommand == "setexceptionbreak" /*||
- debugCommand == "profile"*/) {
- emit result();
-
- } else {
- // DO NOTHING
- }
-
- } else if (type == QLatin1String(EVENT)) {
- QString event(value.value(QLatin1String(EVENT)).toString());
-
- if (event == "break" ||
- event == "exception")
- emit stopped();
- }
-
- } else if (type == BREAKAFTERCOMPILE) {
- emit breakAfterCompileRequested();
-
- }
- }
-}
-
-void QJSDebugClient::sendMessage(const QByteArray &msg)
-{
- if (state() == Enabled) {
- QDeclarativeDebugClient::sendMessage(msg);
- } else {
- sendBuffer.append(msg);
- }
-}
-
-void QJSDebugClient::flushSendBuffer()
-{
- foreach (const QByteArray &msg, sendBuffer)
- QDeclarativeDebugClient::sendMessage(msg);
- sendBuffer.clear();
-}
-
-QByteArray QJSDebugClient::packMessage(const QByteArray &type, const QByteArray &message)
-{
- QByteArray reply;
- QDataStream rs(&reply, QIODevice::WriteOnly);
- QByteArray cmd = "V8DEBUG";
- rs << cmd << type << message;
- return reply;
-}
-
-void tst_QDeclarativeDebugJS::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- t.start();
- process = 0;
- client = 0;
- connection = 0;
-}
-
-void tst_QDeclarativeDebugJS::cleanupTestCase()
-{
- if (process) {
- process->stop();
- delete process;
- }
-
- if (client)
- delete client;
-
- if (connection)
- delete connection;
-
-// qDebug() << "Time Elapsed:" << t.elapsed();
-}
-
-bool tst_QDeclarativeDebugJS::init(const QString &qmlFile, bool blockMode)
-{
- connection = new QDeclarativeDebugConnection();
- process = new QDeclarativeDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene");
- client = new QJSDebugClient(connection);
-
- QStringList systemEnvironment = QProcess::systemEnvironment();
- systemEnvironment << "QML_DISABLE_OPTIMIZER=1";
- process->setEnvironment(systemEnvironment);
- if (blockMode)
- process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(qmlFile));
- else
- process->start(QStringList() << QLatin1String(NORMALMODE) << testFile(qmlFile));
-
- if (!process->waitForSessionStart()) {
- return false;
- }
-
- connection->connectToHost("127.0.0.1", 3771);
- if (!connection->waitForConnected())
- return false;
-
- return QDeclarativeDebugTest::waitForSignal(client, SIGNAL(enabled()));
-}
-
-void tst_QDeclarativeDebugJS::cleanup()
-{
- if (process) {
- process->stop();
- delete process;
- }
-
- if (client)
- delete client;
-
- if (connection)
- delete connection;
-
- process = 0;
- client = 0;
- connection = 0;
-}
-
-void tst_QDeclarativeDebugJS::connect()
-{
- //void connect()
-
- QVERIFY(init());
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(connected())));
-}
-
-void tst_QDeclarativeDebugJS::interrupt()
-{
- //void connect()
-
- QVERIFY(init());
- client->connect();
-
- client->interrupt();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(interruptRequested())));
-}
-
-void tst_QDeclarativeDebugJS::breakAfterCompile()
-{
- //void breakAfterCompile(bool enabled)
-
- QVERIFY(init());
- client->breakAfterCompile(true);
- client->connect();
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(breakAfterCompileRequested())));
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-}
-
-void tst_QDeclarativeDebugJS::getVersion()
-{
- //void version()
-
- QVERIFY(init());
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(connected())));
-
- client->version();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::getVersionWhenAttaching()
-{
- //void version()
-
- QVERIFY(init(QLatin1String(TIMER_QMLFILE), false));
- client->connect();
-
- client->version();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::applyV8Flags()
-{
- //void v8flags(QString flags)
-
- QVERIFY(init());
- client->connect();
-
- client->v8flags(QString());
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::disconnect()
-{
- //void disconnect()
-
- QVERIFY(init());
- client->connect();
-
- client->disconnect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::gc()
-{
- //void gc()
-
- QVERIFY(init());
- client->connect();
-
- client->gc();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::listBreakpoints()
-{
- //void listBreakpoints()
-
- int sourceLine1 = 47;
- int sourceLine2 = 48;
- int sourceLine3 = 49;
-
- QVERIFY(init());
- client->connect();
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine1, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine2, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine3, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
- client->listBreakpoints();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QList<QVariant> breakpoints = value.value("body").toMap().value("breakpoints").toList();
-
- QCOMPARE(breakpoints.count(), 3);
-}
-
-void tst_QDeclarativeDebugJS::setBreakpointInScriptOnCompleted()
-{
- //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- int sourceLine = 47;
- QVERIFY(init(ONCOMPLETED_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(ONCOMPLETED_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::setBreakpointInScriptOnComponentCreated()
-{
- //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- int sourceLine = 47;
- QVERIFY(init(CREATECOMPONENT_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(ONCOMPLETED_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::setBreakpointInScriptOnTimerCallback()
-{
- int sourceLine = 48;
- QVERIFY(init(TIMER_QMLFILE));
-
- client->connect();
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TIMER_QMLFILE), sourceLine, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TIMER_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::setBreakpointInScriptInDifferentFile()
-{
- //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- int sourceLine = 43;
- QVERIFY(init(LOADJSFILE_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_JSFILE), sourceLine, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TEST_JSFILE));
-}
-
-void tst_QDeclarativeDebugJS::setBreakpointInScriptOnComment()
-{
- //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- int sourceLine = 47;
- int actualLine = 49;
- QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
- QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()), 1));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), actualLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::setBreakpointInScriptOnEmptyLine()
-{
- //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- int sourceLine = 48;
- int actualLine = 49;
- QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
- QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped()), 1));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), actualLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::setBreakpointInScriptWithCondition()
-{
- //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- int out = 10;
- int sourceLine = 50;
- QVERIFY(init(CONDITION_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CONDITION_QMLFILE), sourceLine, 1, true, QLatin1String("a > 10"));
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- //Get the frame index
- QString jsonString = client->response;
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- int frameIndex = body.value("index").toInt();
-
- //Verify the value of 'result'
- client->evaluate(QLatin1String("a"),frameIndex);
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-
- jsonString = client->response;
- value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- body = value.value("body").toMap();
-
- QVERIFY(body.value("value").toInt() > out);
-}
-
-void tst_QDeclarativeDebugJS::setBreakpointWhenAttaching()
-{
- int sourceLine = 49;
- QVERIFY(init(QLatin1String(TIMER_QMLFILE), false));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TIMER_QMLFILE), sourceLine);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-}
-
-//void tst_QDeclarativeDebugJS::setBreakpointInFunction()
-//{
-// //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
-// int actualLine = 31;
-
-// client->connect();
-// client->setBreakpoint(QLatin1String(FUNCTION), QLatin1String("doSomethingElse"), -1, -1, true);
-
-// QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
-// QString jsonString(client->response);
-// QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
-// QVariantMap body = value.value("body").toMap();
-
-// QCOMPARE(body.value("sourceLine").toInt(), actualLine);
-// QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(QMLFILE));
-//}
-
-void tst_QDeclarativeDebugJS::setBreakpointOnEvent()
-{
- //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- QVERIFY(init(TIMER_QMLFILE));
-
- client->connect();
-
- client->setBreakpoint(QLatin1String(EVENT), QLatin1String("triggered"), -1, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TIMER_QMLFILE));
-}
-
-
-void tst_QDeclarativeDebugJS::changeBreakpoint()
-{
- //void changeBreakpoint(int breakpoint, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- int sourceLine1 = 50;
- int sourceLine2 = 51;
- QVERIFY(init(CHANGEBREAKPOINT_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true);
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true);
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- //Will hit 1st brakpoint, change this breakpoint enable = false
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
- QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
-
- int breakpoint = breakpointsHit.at(0).toInt();
- client->changeBreakpoint(breakpoint,false);
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-
- //Continue with debugging
- client->continueDebugging(QJSDebugClient::Continue);
- //Hit 2nd breakpoint
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- //Continue with debugging
- client->continueDebugging(QJSDebugClient::Continue);
- //Should stop at 2nd breakpoint
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- jsonString = client->response;
- value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
-}
-
-void tst_QDeclarativeDebugJS::changeBreakpointOnCondition()
-{
- //void changeBreakpoint(int breakpoint, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
-
- int sourceLine1 = 50;
- int sourceLine2 = 51;
-
- QVERIFY(init(CHANGEBREAKPOINT_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true);
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true);
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- //Will hit 1st brakpoint, change this breakpoint enable = false
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
- QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
-
- int breakpoint = breakpointsHit.at(0).toInt();
- client->changeBreakpoint(breakpoint, false, QLatin1String("d == 0"));
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-
- //Continue with debugging
- client->continueDebugging(QJSDebugClient::Continue);
- //Hit 2nd breakpoint
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- //Continue with debugging
- client->continueDebugging(QJSDebugClient::Continue);
- //Should stop at 2nd breakpoint
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- jsonString = client->response;
- value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
-
-}
-
-void tst_QDeclarativeDebugJS::clearBreakpoint()
-{
- //void clearBreakpoint(int breakpoint);
-
- int sourceLine1 = 50;
- int sourceLine2 = 51;
- QVERIFY(init(CHANGEBREAKPOINT_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true);
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true);
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- //Will hit 1st brakpoint, change this breakpoint enable = false
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
- QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
-
- int breakpoint = breakpointsHit.at(0).toInt();
- client->clearBreakpoint(breakpoint);
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-
- //Continue with debugging
- client->continueDebugging(QJSDebugClient::Continue);
- //Hit 2nd breakpoint
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- //Continue with debugging
- client->continueDebugging(QJSDebugClient::Continue);
- //Should stop at 2nd breakpoint
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- jsonString = client->response;
- value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
-}
-
-void tst_QDeclarativeDebugJS::setExceptionBreak()
-{
- //void setExceptionBreak(QString type, bool enabled = false);
-
- QVERIFY(init(EXCEPTION_QMLFILE));
- client->setExceptionBreak(QJSDebugClient::All,true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-}
-
-void tst_QDeclarativeDebugJS::stepNext()
-{
- //void continueDebugging(StepAction stepAction, int stepCount = 1);
-
- int sourceLine = 50;
- QVERIFY(init(STEPACTION_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->continueDebugging(QJSDebugClient::Next);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine + 1);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::stepNextWithCount()
-{
- //void continueDebugging(StepAction stepAction, int stepCount = 1);
-
- int sourceLine = 50;
- QVERIFY(init(STEPACTION_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->continueDebugging(QJSDebugClient::Next, 2);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine + 2);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::stepIn()
-{
- //void continueDebugging(StepAction stepAction, int stepCount = 1);
-
- int sourceLine = 54;
- int actualLine = 50;
- QVERIFY(init(STEPACTION_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, 1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->continueDebugging(QJSDebugClient::In);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), actualLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::stepOut()
-{
- //void continueDebugging(StepAction stepAction, int stepCount = 1);
-
- int sourceLine = 50;
- int actualLine = 54;
- QVERIFY(init(STEPACTION_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->continueDebugging(QJSDebugClient::Out);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), actualLine);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::continueDebugging()
-{
- //void continueDebugging(StepAction stepAction, int stepCount = 1);
-
- int sourceLine1 = 54;
- int sourceLine2 = 51;
- QVERIFY(init(STEPACTION_QMLFILE));
-
- client->connect();
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine1, -1, true);
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine2, -1, true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->continueDebugging(QJSDebugClient::Continue);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
- QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
-}
-
-void tst_QDeclarativeDebugJS::backtrace()
-{
- //void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false);
-
- int sourceLine = 47;
- QVERIFY(init(ONCOMPLETED_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->backtrace();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::getFrameDetails()
-{
- //void frame(int number = -1);
-
- int sourceLine = 47;
- QVERIFY(init(ONCOMPLETED_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->frame();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::getScopeDetails()
-{
- //void scope(int number = -1, int frameNumber = -1);
-
- int sourceLine = 47;
- QVERIFY(init(ONCOMPLETED_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->scope();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::evaluateInGlobalScope()
-{
- //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
-
- QVERIFY(init());
-
- client->connect();
- client->evaluate(QLatin1String("print('Hello World')"), true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-
- //Verify the value of 'print'
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- QCOMPARE(body.value("text").toString(),QLatin1String("undefined"));
-}
-
-void tst_QDeclarativeDebugJS::evaluateInLocalScope()
-{
- //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
-
- int sourceLine = 47;
- QVERIFY(init(ONCOMPLETED_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->frame();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-
- //Get the frame index
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- QVariantMap body = value.value("body").toMap();
-
- int frameIndex = body.value("index").toInt();
-
- client->evaluate(QLatin1String("root.a"), frameIndex);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-
- //Verify the value of 'timer.interval'
- jsonString = client->response;
- value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
-
- body = value.value("body").toMap();
-
- QCOMPARE(body.value("value").toInt(),10);
-}
-
-void tst_QDeclarativeDebugJS::getScopes()
-{
- //void scopes(int frameNumber = -1);
-
- int sourceLine = 47;
- QVERIFY(init(ONCOMPLETED_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->scopes();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-void tst_QDeclarativeDebugJS::getScripts()
-{
- //void scripts(int types = -1, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant());
-
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-23475 - Unreliable test on Mac OS X");
-#endif
-
- QVERIFY(init());
-
- client->connect();
-
- client->scripts();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
- QString jsonString(client->response);
- QVariantMap value = client->parser.call(QJSValueList()
- << QJSValue(jsonString)).toVariant().toMap();
-
- QList<QVariant> scripts = value.value("body").toList();
-
- QCOMPARE(scripts.count(), 2);
-}
-
-void tst_QDeclarativeDebugJS::getSource()
-{
- //void source(int frame = -1, int fromLine = -1, int toLine = -1);
-
- int sourceLine = 47;
- QVERIFY(init(ONCOMPLETED_QMLFILE));
-
- client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
- client->connect();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(stopped())));
-
- client->source();
- QVERIFY(QDeclarativeDebugTest::waitForSignal(client, SIGNAL(result())));
-}
-
-QTEST_MAIN(tst_QDeclarativeDebugJS)
-
-#include "tst_qdeclarativedebugjs.moc"
-
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugservice/qdeclarativedebugservice.pro b/tests/auto/declarative/debugger/qdeclarativedebugservice/qdeclarativedebugservice.pro
deleted file mode 100644
index 015a7232f6..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativedebugservice/qdeclarativedebugservice.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativedebugservice
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qdeclarativedebugservice.cpp \
- ../shared/debugutil.cpp
-
-CONFIG += parallel_test declarative_debug
-
-QT += declarative-private testlib
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp b/tests/auto/declarative/debugger/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
deleted file mode 100644
index c38b7854e0..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativedebugservice/tst_qdeclarativedebugservice.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QHostAddress>
-#include <QDebug>
-#include <QThread>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-
-#include <private/qdeclarativedebugclient_p.h>
-#include <private/qdeclarativedebugservice_p.h>
-
-#include "../../../shared/util.h"
-#include "../shared/debugutil_p.h"
-
-#define PORT 13769
-#define STR_PORT "13769"
-
-class tst_QDeclarativeDebugService : public QObject
-{
- Q_OBJECT
-private:
- QDeclarativeDebugConnection *m_conn;
-
-private slots:
- void initTestCase();
-
- void name();
- void version();
- void state();
- void sendMessage();
- void idForObject();
- void objectForId();
- void objectToString();
-};
-
-void tst_QDeclarativeDebugService::initTestCase()
-{
- const QString waitingMsg = QString("QDeclarativeDebugServer: Waiting for connection on port %1...").arg(PORT);
- QTest::ignoreMessage(QtWarningMsg, waitingMsg.toAscii().constData());
- new QDeclarativeEngine(this);
-
- m_conn = new QDeclarativeDebugConnection(this);
-
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
- for (int i = 0; i < 50; ++i) {
- // try for 5 seconds ...
- m_conn->connectToHost("127.0.0.1", PORT);
- if (m_conn->waitForConnected())
- break;
- QTest::qSleep(100);
- }
- QVERIFY(m_conn->isConnected());
-
- QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
-}
-
-void tst_QDeclarativeDebugService::name()
-{
- QString name = "tst_QDeclarativeDebugService::name()";
-
- QDeclarativeDebugService service(name, 1);
- QCOMPARE(service.name(), name);
-}
-
-void tst_QDeclarativeDebugService::version()
-{
- QString name = "tst_QDeclarativeDebugService::name()";
-
- QDeclarativeDebugService service(name, 2);
- QCOMPARE(service.version(), 2.0f);
-}
-
-void tst_QDeclarativeDebugService::state()
-{
- QDeclarativeDebugTestService service("tst_QDeclarativeDebugService::state()");
- QCOMPARE(service.state(), QDeclarativeDebugService::Unavailable);
-
- {
- QDeclarativeDebugTestClient client("tst_QDeclarativeDebugService::state()", m_conn);
- QTRY_COMPARE(client.state(), QDeclarativeDebugClient::Enabled);
- QTRY_COMPARE(service.state(), QDeclarativeDebugService::Enabled);
- }
-
-
- QTRY_COMPARE(service.state(), QDeclarativeDebugService::Unavailable);
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugService: Conflicting plugin name \"tst_QDeclarativeDebugService::state()\" ");
- QDeclarativeDebugTestService duplicate("tst_QDeclarativeDebugService::state()");
- QCOMPARE(duplicate.state(), QDeclarativeDebugService::NotConnected);
-}
-
-void tst_QDeclarativeDebugService::sendMessage()
-{
- QDeclarativeDebugTestService service("tst_QDeclarativeDebugService::sendMessage()");
- QDeclarativeDebugTestClient client("tst_QDeclarativeDebugService::sendMessage()", m_conn);
-
- QByteArray msg = "hello!";
-
- QTRY_COMPARE(client.state(), QDeclarativeDebugClient::Enabled);
- QTRY_COMPARE(service.state(), QDeclarativeDebugService::Enabled);
-
- client.sendMessage(msg);
- QByteArray resp = client.waitForResponse();
- QCOMPARE(resp, msg);
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugService: Conflicting plugin name \"tst_QDeclarativeDebugService::sendMessage()\" ");
- QDeclarativeDebugTestService duplicate("tst_QDeclarativeDebugService::sendMessage()");
- duplicate.sendMessage("msg");
-}
-
-void tst_QDeclarativeDebugService::idForObject()
-{
- QCOMPARE(QDeclarativeDebugService::idForObject(0), -1);
-
- QObject *objA = new QObject;
-
- int idA = QDeclarativeDebugService::idForObject(objA);
- QVERIFY(idA >= 0);
- QCOMPARE(QDeclarativeDebugService::objectForId(idA), objA);
-
- int idAA = QDeclarativeDebugService::idForObject(objA);
- QCOMPARE(idAA, idA);
-
- QObject *objB = new QObject;
- int idB = QDeclarativeDebugService::idForObject(objB);
- QVERIFY(idB != idA);
- QCOMPARE(QDeclarativeDebugService::objectForId(idB), objB);
-
- delete objA;
- delete objB;
-}
-
-void tst_QDeclarativeDebugService::objectForId()
-{
- QCOMPARE(QDeclarativeDebugService::objectForId(-1), static_cast<QObject*>(0));
- QCOMPARE(QDeclarativeDebugService::objectForId(1), static_cast<QObject*>(0));
-
- QObject *obj = new QObject;
- int id = QDeclarativeDebugService::idForObject(obj);
- QCOMPARE(QDeclarativeDebugService::objectForId(id), obj);
-
- delete obj;
- QCOMPARE(QDeclarativeDebugService::objectForId(id), static_cast<QObject*>(0));
-}
-
-void tst_QDeclarativeDebugService::objectToString()
-{
- QCOMPARE(QDeclarativeDebugService::objectToString(0), QString("NULL"));
-
- QObject *obj = new QObject;
- QCOMPARE(QDeclarativeDebugService::objectToString(obj), QString("QObject: <unnamed>"));
-
- obj->setObjectName("Hello");
- QCOMPARE(QDeclarativeDebugService::objectToString(obj), QString("QObject: Hello"));
- delete obj;
-}
-
-
-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];
- char arg[] = "-qmljsdebugger=port:" STR_PORT;
- _argv[_argc - 1] = arg;
-
- QGuiApplication app(_argc, _argv);
- tst_QDeclarativeDebugService tc;
- return QTest::qExec(&tc, _argc, _argv);
- delete _argv;
-}
-
-#include "tst_qdeclarativedebugservice.moc"
diff --git a/tests/auto/declarative/debugger/qdeclarativeenginedebug/qdeclarativeenginedebug.pro b/tests/auto/declarative/debugger/qdeclarativeenginedebug/qdeclarativeenginedebug.pro
deleted file mode 100644
index 6b414d3c32..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativeenginedebug/qdeclarativeenginedebug.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeenginedebug
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qdeclarativeenginedebug.cpp \
- ../shared/debugutil.cpp
-
-CONFIG += parallel_test declarative_debug
-
-QT += core-private declarative-private quick-private v8-private testlib
diff --git a/tests/auto/declarative/debugger/qdeclarativeenginedebug/tst_qdeclarativeenginedebug.cpp b/tests/auto/declarative/debugger/qdeclarativeenginedebug/tst_qdeclarativeenginedebug.cpp
deleted file mode 100644
index 246ba6080a..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativeenginedebug/tst_qdeclarativeenginedebug.cpp
+++ /dev/null
@@ -1,1235 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QHostAddress>
-#include <QDebug>
-#include <QThread>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativeproperty.h>
-#include <QtQuick/qquickitem.h>
-
-#include <private/qdeclarativebinding_p.h>
-#include <private/qdeclarativeboundsignal_p.h>
-#include <private/qdeclarativeenginedebug_p.h>
-#include <private/qdeclarativedebugservice_p.h>
-#include <private/qdeclarativemetatype_p.h>
-#include <private/qdeclarativeproperty_p.h>
-
-#include "../shared/debugutil_p.h"
-
-Q_DECLARE_METATYPE(QDeclarativeDebugWatch::State)
-
-class tst_QDeclarativeEngineDebug : public QObject
-{
- Q_OBJECT
-
-private:
- QDeclarativeDebugObjectReference findRootObject(int context = 0, bool recursive = false);
- QDeclarativeDebugPropertyReference findProperty(const QList<QDeclarativeDebugPropertyReference> &props, const QString &name) const;
- void waitForQuery(QDeclarativeDebugQuery *query);
-
- void recursiveObjectTest(QObject *o, const QDeclarativeDebugObjectReference &oref, bool recursive) const;
-
- void recursiveCompareObjects(const QDeclarativeDebugObjectReference &a, const QDeclarativeDebugObjectReference &b) const;
- void recursiveCompareContexts(const QDeclarativeDebugContextReference &a, const QDeclarativeDebugContextReference &b) const;
- void compareProperties(const QDeclarativeDebugPropertyReference &a, const QDeclarativeDebugPropertyReference &b) const;
-
- QDeclarativeDebugConnection *m_conn;
- QDeclarativeEngineDebug *m_dbg;
- QDeclarativeEngine *m_engine;
- QQuickItem *m_rootItem;
-
- QObjectList m_components;
-
-private slots:
- void initTestCase();
- void cleanupTestCase();
-
- void watch_property();
- void watch_object();
- void watch_expression();
- void watch_expression_data();
- void watch_context();
- void watch_file();
-
- void queryAvailableEngines();
- void queryRootContexts();
- void queryObject();
- void queryObject_data();
- void queryExpressionResult();
- void queryExpressionResult_data();
-
- void tst_QDeclarativeDebugFileReference();
- void tst_QDeclarativeDebugEngineReference();
- void tst_QDeclarativeDebugObjectReference();
- void tst_QDeclarativeDebugContextReference();
- void tst_QDeclarativeDebugPropertyReference();
-
- void setBindingForObject();
- void setMethodBody();
- void queryObjectTree();
- void setBindingInStates();
-};
-
-class NonScriptProperty : public QObject {
- Q_OBJECT
- Q_PROPERTY(int nonScriptProp READ nonScriptProp WRITE setNonScriptProp NOTIFY nonScriptPropChanged SCRIPTABLE false)
-public:
- int nonScriptProp() const { return 0; }
- void setNonScriptProp(int) {}
-signals:
- void nonScriptPropChanged();
-};
-QML_DECLARE_TYPE(NonScriptProperty)
-
-
-QDeclarativeDebugObjectReference tst_QDeclarativeEngineDebug::findRootObject(int context, bool recursive)
-{
- QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- if (q_engines->engines().count() == 0)
- return QDeclarativeDebugObjectReference();
- QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- if (q_context->rootContext().objects().count() == 0)
- return QDeclarativeDebugObjectReference();
- QDeclarativeDebugObjectQuery *q_obj = recursive ?
- m_dbg->queryObjectRecursive(q_context->rootContext().objects()[context], this) :
- m_dbg->queryObject(q_context->rootContext().objects()[context], this);
- waitForQuery(q_obj);
-
- QDeclarativeDebugObjectReference result = q_obj->object();
-
- delete q_engines;
- delete q_context;
- delete q_obj;
-
- return result;
-}
-
-QDeclarativeDebugPropertyReference tst_QDeclarativeEngineDebug::findProperty(const QList<QDeclarativeDebugPropertyReference> &props, const QString &name) const
-{
- foreach(const QDeclarativeDebugPropertyReference &p, props) {
- if (p.name() == name)
- return p;
- }
- return QDeclarativeDebugPropertyReference();
-}
-
-void tst_QDeclarativeEngineDebug::waitForQuery(QDeclarativeDebugQuery *query)
-{
- QVERIFY(query);
- QCOMPARE(query->parent(), qobject_cast<QObject*>(this));
- QVERIFY(query->state() == QDeclarativeDebugQuery::Waiting);
- if (!QDeclarativeDebugTest::waitForSignal(query, SIGNAL(stateChanged(QDeclarativeDebugQuery::State))))
- QFAIL("query timed out");
-}
-
-void tst_QDeclarativeEngineDebug::recursiveObjectTest(QObject *o, const QDeclarativeDebugObjectReference &oref, bool recursive) const
-{
- const QMetaObject *meta = o->metaObject();
-
- QDeclarativeType *type = QDeclarativeMetaType::qmlType(meta);
- QString className = type ? QString(type->qmlTypeName()) : QString(meta->className());
- className = className.mid(className.lastIndexOf(QLatin1Char('/'))+1);
-
- QCOMPARE(oref.debugId(), QDeclarativeDebugService::idForObject(o));
- QCOMPARE(oref.name(), o->objectName());
- QCOMPARE(oref.className(), className);
- QCOMPARE(oref.contextDebugId(), QDeclarativeDebugService::idForObject(qmlContext(o)));
-
- const QObjectList &children = o->children();
- for (int i=0; i<children.count(); i++) {
- QObject *child = children[i];
- if (!qmlContext(child))
- continue;
- int debugId = QDeclarativeDebugService::idForObject(child);
- QVERIFY(debugId >= 0);
-
- QDeclarativeDebugObjectReference cref;
- foreach (const QDeclarativeDebugObjectReference &ref, oref.children()) {
- if (ref.debugId() == debugId) {
- cref = ref;
- break;
- }
- }
- QVERIFY(cref.debugId() >= 0);
-
- if (recursive)
- recursiveObjectTest(child, cref, true);
- }
-
- foreach (const QDeclarativeDebugPropertyReference &p, oref.properties()) {
- QCOMPARE(p.objectDebugId(), QDeclarativeDebugService::idForObject(o));
-
- // signal properties are fake - they are generated from QDeclarativeBoundSignal children
- if (p.name().startsWith("on") && p.name().length() > 2 && p.name()[2].isUpper()) {
- QList<QDeclarativeBoundSignal*> signalHandlers = o->findChildren<QDeclarativeBoundSignal*>();
- QString signal = p.value().toString();
- bool found = false;
- for (int i = 0; i < signalHandlers.count(); ++i)
- if (signalHandlers.at(i)->expression()->expression() == signal) {
- found = true;
- break;
- }
- QVERIFY(found);
- QVERIFY(p.valueTypeName().isEmpty());
- QVERIFY(p.binding().isEmpty());
- QVERIFY(!p.hasNotifySignal());
- continue;
- }
-
- QMetaProperty pmeta = meta->property(meta->indexOfProperty(p.name().toUtf8().constData()));
-
- QCOMPARE(p.name(), QString::fromUtf8(pmeta.name()));
-
- if (pmeta.type() < QVariant::UserType && pmeta.userType() != QMetaType::QVariant) // TODO test complex types
- QCOMPARE(p.value(), pmeta.read(o));
-
- if (p.name() == "parent")
- QVERIFY(p.valueTypeName() == "QGraphicsObject*" || p.valueTypeName() == "QQuickItem*");
- else
- QCOMPARE(p.valueTypeName(), QString::fromUtf8(pmeta.typeName()));
-
- QDeclarativeAbstractBinding *binding =
- QDeclarativePropertyPrivate::binding(QDeclarativeProperty(o, p.name()));
- if (binding)
- QCOMPARE(binding->expression(), p.binding());
-
- QCOMPARE(p.hasNotifySignal(), pmeta.hasNotifySignal());
-
- QVERIFY(pmeta.isValid());
- }
-}
-
-void tst_QDeclarativeEngineDebug::recursiveCompareObjects(const QDeclarativeDebugObjectReference &a, const QDeclarativeDebugObjectReference &b) const
-{
- QCOMPARE(a.debugId(), b.debugId());
- QCOMPARE(a.className(), b.className());
- QCOMPARE(a.name(), b.name());
- QCOMPARE(a.contextDebugId(), b.contextDebugId());
-
- QCOMPARE(a.source().url(), b.source().url());
- QCOMPARE(a.source().lineNumber(), b.source().lineNumber());
- QCOMPARE(a.source().columnNumber(), b.source().columnNumber());
-
- QCOMPARE(a.properties().count(), b.properties().count());
- QCOMPARE(a.children().count(), b.children().count());
-
- QList<QDeclarativeDebugPropertyReference> aprops = a.properties();
- QList<QDeclarativeDebugPropertyReference> bprops = b.properties();
-
- for (int i=0; i<aprops.count(); i++)
- compareProperties(aprops[i], bprops[i]);
-
- for (int i=0; i<a.children().count(); i++)
- recursiveCompareObjects(a.children()[i], b.children()[i]);
-}
-
-void tst_QDeclarativeEngineDebug::recursiveCompareContexts(const QDeclarativeDebugContextReference &a, const QDeclarativeDebugContextReference &b) const
-{
- QCOMPARE(a.debugId(), b.debugId());
- QCOMPARE(a.name(), b.name());
- QCOMPARE(a.objects().count(), b.objects().count());
- QCOMPARE(a.contexts().count(), b.contexts().count());
-
- for (int i=0; i<a.objects().count(); i++)
- recursiveCompareObjects(a.objects()[i], b.objects()[i]);
-
- for (int i=0; i<a.contexts().count(); i++)
- recursiveCompareContexts(a.contexts()[i], b.contexts()[i]);
-}
-
-void tst_QDeclarativeEngineDebug::compareProperties(const QDeclarativeDebugPropertyReference &a, const QDeclarativeDebugPropertyReference &b) const
-{
- QCOMPARE(a.objectDebugId(), b.objectDebugId());
- QCOMPARE(a.name(), b.name());
- QCOMPARE(a.value(), b.value());
- QCOMPARE(a.valueTypeName(), b.valueTypeName());
- QCOMPARE(a.binding(), b.binding());
- QCOMPARE(a.hasNotifySignal(), b.hasNotifySignal());
-}
-
-void tst_QDeclarativeEngineDebug::initTestCase()
-{
- qRegisterMetaType<QDeclarativeDebugWatch::State>();
- qmlRegisterType<NonScriptProperty>("Test", 1, 0, "NonScriptPropertyElement");
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 3768...");
- m_engine = new QDeclarativeEngine(this);
-
- QList<QByteArray> qml;
- qml << "import QtQuick 2.0\n"
- "import Test 1.0\n"
- "Item {"
- "id: root\n"
- "width: 10; height: 20; scale: blueRect.scale;"
- "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }"
- "Text { color: blueRect.color; }"
- "MouseArea {"
- "onEntered: { console.log('hello') }"
- "}"
- "property variant varObj\n"
- "property variant varObjList: []\n"
- "property variant varObjMap\n"
- "Component.onCompleted: {\n"
- "varObj = blueRect;\n"
- "var list = varObjList;\n"
- "list[0] = blueRect;\n"
- "varObjList = list;\n"
- "var map = new Object;\n"
- "map.rect = blueRect;\n"
- "varObjMap = map;\n"
- "}\n"
- "NonScriptPropertyElement {\n"
- "}\n"
- "}";
-
- // add second component to test multiple root contexts
- qml << "import QtQuick 2.0\n"
- "Item {}";
-
- // and a third to test methods
- qml << "import QtQuick 2.0\n"
- "Item {"
- "function myMethodNoArgs() { return 3; }\n"
- "function myMethod(a) { return a + 9; }\n"
- "function myMethodIndirect() { myMethod(3); }\n"
- "}";
-
- // and a fourth to test states
- qml << "import QtQuick 2.0\n"
- "Rectangle {\n"
- "id:rootRect\n"
- "width:100\n"
- "states: [\n"
- "State {\n"
- "name:\"state1\"\n"
- "PropertyChanges {\n"
- "target:rootRect\n"
- "width:200\n"
- "}\n"
- "}\n"
- "]\n"
- "transitions: [\n"
- "Transition {\n"
- "from:\"*\"\n"
- "to:\"state1\"\n"
- "PropertyAnimation {\n"
- "target:rootRect\n"
- "property:\"width\"\n"
- "duration:100\n"
- "}\n"
- "}\n"
- "]\n"
- "}\n"
- ;
-
- for (int i=0; i<qml.count(); i++) {
- QDeclarativeComponent component(m_engine);
- component.setData(qml[i], QUrl::fromLocalFile(""));
- QVERIFY(component.isReady()); // fails if bad syntax
- m_components << qobject_cast<QQuickItem*>(component.create());
- }
- m_rootItem = qobject_cast<QQuickItem*>(m_components.first());
-
- // add an extra context to test for multiple contexts
- QDeclarativeContext *context = new QDeclarativeContext(m_engine->rootContext(), this);
- context->setObjectName("tst_QDeclarativeDebug_childContext");
-
- m_conn = new QDeclarativeDebugConnection(this);
- m_conn->connectToHost("127.0.0.1", 3768);
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Connection established");
- bool ok = m_conn->waitForConnected();
- QVERIFY(ok);
- QTRY_VERIFY(QDeclarativeDebugService::hasDebuggingClient());
- m_dbg = new QDeclarativeEngineDebug(m_conn, this);
- QTRY_VERIFY(m_dbg->state() == QDeclarativeEngineDebug::Enabled);
-}
-
-void tst_QDeclarativeEngineDebug::cleanupTestCase()
-{
- delete m_dbg;
- delete m_conn;
- qDeleteAll(m_components);
- delete m_engine;
-}
-
-void tst_QDeclarativeEngineDebug::setMethodBody()
-{
- QDeclarativeDebugObjectReference obj = findRootObject(2);
-
- QObject *root = m_components.at(2);
- // Without args
- {
- QVariant rv;
- QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, rv)));
- QVERIFY(rv == QVariant(qreal(3)));
-
-
- QVERIFY(m_dbg->setMethodBody(obj.debugId(), "myMethodNoArgs", "return 7"));
- QTest::qWait(100);
-
- QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, rv)));
- QVERIFY(rv == QVariant(qreal(7)));
- }
-
- // With args
- {
- QVariant rv;
- QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19))));
- QVERIFY(rv == QVariant(qreal(28)));
-
- QVERIFY(m_dbg->setMethodBody(obj.debugId(), "myMethod", "return a + 7"));
- QTest::qWait(100);
-
- QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19))));
- QVERIFY(rv == QVariant(qreal(26)));
- }
-}
-
-void tst_QDeclarativeEngineDebug::watch_property()
-{
- QDeclarativeDebugObjectReference obj = findRootObject();
- QDeclarativeDebugPropertyReference prop = findProperty(obj.properties(), "width");
-
- QDeclarativeDebugPropertyWatch *watch;
-
- QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
- watch = unconnected->addWatch(prop, this);
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
- delete watch;
- delete unconnected;
-
- watch = m_dbg->addWatch(QDeclarativeDebugPropertyReference(), this);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
- delete watch;
-
- watch = m_dbg->addWatch(prop, this);
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
- QCOMPARE(watch->objectDebugId(), obj.debugId());
- QCOMPARE(watch->name(), prop.name());
-
- QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
-
- int origWidth = m_rootItem->property("width").toInt();
- m_rootItem->setProperty("width", origWidth*2);
-
- // stateChanged() is received before valueChanged()
- QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Active);
- QCOMPARE(spy.count(), 1);
-
- m_dbg->removeWatch(watch);
- delete watch;
-
- // restore original value and verify spy doesn't get additional signal since watch has been removed
- m_rootItem->setProperty("width", origWidth);
- QTest::qWait(100);
- QCOMPARE(spy.count(), 1);
-
- QCOMPARE(spy.at(0).at(0).value<QByteArray>(), prop.name().toUtf8());
- QCOMPARE(spy.at(0).at(1).value<QVariant>(), qVariantFromValue(origWidth*2));
-}
-
-void tst_QDeclarativeEngineDebug::watch_object()
-{
- QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- QVERIFY(q_engines->engines().count() > 0);
- QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- QVERIFY(q_context->rootContext().objects().count() > 0);
- QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this);
- waitForQuery(q_obj);
-
- QDeclarativeDebugObjectReference obj = q_obj->object();
-
- delete q_engines;
- delete q_context;
- delete q_obj;
-
- QDeclarativeDebugWatch *watch;
-
- QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
- watch = unconnected->addWatch(obj, this);
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
- delete watch;
- delete unconnected;
-
- watch = m_dbg->addWatch(QDeclarativeDebugObjectReference(), this);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
- delete watch;
-
- watch = m_dbg->addWatch(obj, this);
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
- QCOMPARE(watch->objectDebugId(), obj.debugId());
-
- QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
-
- int origWidth = m_rootItem->property("width").toInt();
- int origHeight = m_rootItem->property("height").toInt();
- m_rootItem->setProperty("width", origWidth*2);
- m_rootItem->setProperty("height", origHeight*2);
-
- // stateChanged() is received before any valueChanged() signals
- QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Active);
- QVERIFY(spy.count() > 0);
-
- int newWidth = -1;
- int newHeight = -1;
- for (int i=0; i<spy.count(); i++) {
- const QVariantList &values = spy[i];
- if (values[0].value<QByteArray>() == "width")
- newWidth = values[1].value<QVariant>().toInt();
- else if (values[0].value<QByteArray>() == "height")
- newHeight = values[1].value<QVariant>().toInt();
-
- }
-
- m_dbg->removeWatch(watch);
- delete watch;
-
- // since watch has been removed, restoring the original values should not trigger a valueChanged()
- spy.clear();
- m_rootItem->setProperty("width", origWidth);
- m_rootItem->setProperty("height", origHeight);
- QTest::qWait(100);
- QCOMPARE(spy.count(), 0);
-
- QCOMPARE(newWidth, origWidth * 2);
- QCOMPARE(newHeight, origHeight * 2);
-}
-
-void tst_QDeclarativeEngineDebug::watch_expression()
-{
- QFETCH(QString, expr);
- QFETCH(int, increment);
- QFETCH(int, incrementCount);
-
- int origWidth = m_rootItem->property("width").toInt();
-
- QDeclarativeDebugObjectReference obj = findRootObject();
-
- QDeclarativeDebugObjectExpressionWatch *watch;
-
- QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
- watch = unconnected->addWatch(obj, expr, this);
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Dead);
- delete watch;
- delete unconnected;
-
- watch = m_dbg->addWatch(QDeclarativeDebugObjectReference(), expr, this);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Inactive);
- delete watch;
-
- watch = m_dbg->addWatch(obj, expr, this);
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Waiting);
- QCOMPARE(watch->objectDebugId(), obj.debugId());
- QCOMPARE(watch->expression(), expr);
-
- QSignalSpy spyState(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State)));
-
- QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
- int expectedSpyCount = incrementCount + 1; // should also get signal with expression's initial value
-
- int width = origWidth;
- for (int i=0; i<incrementCount+1; i++) {
- if (i > 0) {
- width += increment;
- m_rootItem->setProperty("width", width);
- }
- if (!QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(valueChanged(QByteArray,QVariant))))
- QFAIL("Did not receive valueChanged() for expression");
- }
-
- if (spyState.count() == 0)
- QVERIFY(QDeclarativeDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QDeclarativeDebugWatch::State))));
- QCOMPARE(spyState.count(), 1);
- QCOMPARE(watch->state(), QDeclarativeDebugWatch::Active);
-
- m_dbg->removeWatch(watch);
- delete watch;
-
- // restore original value and verify spy doesn't get a signal since watch has been removed
- m_rootItem->setProperty("width", origWidth);
- QTest::qWait(100);
- QCOMPARE(spy.count(), expectedSpyCount);
-
- width = origWidth + increment;
- for (int i=0; i<spy.count(); i++) {
- QCOMPARE(spy.at(i).at(1).value<QVariant>().toInt(), width);
- width += increment;
- }
-}
-
-void tst_QDeclarativeEngineDebug::watch_expression_data()
-{
- QTest::addColumn<QString>("expr");
- QTest::addColumn<int>("increment");
- QTest::addColumn<int>("incrementCount");
-
- QTest::newRow("width") << "width" << 0 << 0;
- QTest::newRow("width+10") << "width + 10" << 10 << 5;
-}
-
-void tst_QDeclarativeEngineDebug::watch_context()
-{
- QDeclarativeDebugContextReference c;
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeEngineDebug::addWatch(): Not implemented");
- QVERIFY(!m_dbg->addWatch(c, QString(), this));
-}
-
-void tst_QDeclarativeEngineDebug::watch_file()
-{
- QDeclarativeDebugFileReference f;
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeEngineDebug::addWatch(): Not implemented");
- QVERIFY(!m_dbg->addWatch(f, this));
-}
-
-void tst_QDeclarativeEngineDebug::queryAvailableEngines()
-{
- QDeclarativeDebugEnginesQuery *q_engines;
-
- QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
- q_engines = unconnected->queryAvailableEngines(0);
- QCOMPARE(q_engines->state(), QDeclarativeDebugQuery::Error);
- delete q_engines;
- delete unconnected;
-
- q_engines = m_dbg->queryAvailableEngines(this);
- delete q_engines;
-
- q_engines = m_dbg->queryAvailableEngines(this);
- QVERIFY(q_engines->engines().isEmpty());
- waitForQuery(q_engines);
-
- // TODO test multiple engines
- QList<QDeclarativeDebugEngineReference> engines = q_engines->engines();
- QCOMPARE(engines.count(), 1);
-
- foreach(const QDeclarativeDebugEngineReference &e, engines) {
- QCOMPARE(e.debugId(), QDeclarativeDebugService::idForObject(m_engine));
- QCOMPARE(e.name(), m_engine->objectName());
- }
-
- // Make query invalid by deleting client
- q_engines = m_dbg->queryAvailableEngines(this);
- QCOMPARE(q_engines->state(), QDeclarativeDebugQuery::Waiting);
- delete m_dbg;
- QCOMPARE(q_engines->state(), QDeclarativeDebugQuery::Error);
- delete q_engines;
- m_dbg = new QDeclarativeEngineDebug(m_conn, this);
-}
-
-void tst_QDeclarativeEngineDebug::queryRootContexts()
-{
- QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
- int engineId = q_engines->engines()[0].debugId();
- delete q_engines;
-
- QDeclarativeDebugRootContextQuery *q_context;
-
- QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
- q_context = unconnected->queryRootContexts(engineId, this);
- QCOMPARE(q_context->state(), QDeclarativeDebugQuery::Error);
- delete q_context;
- delete unconnected;
-
- q_context = m_dbg->queryRootContexts(engineId, this);
- delete q_context;
-
- q_context = m_dbg->queryRootContexts(engineId, this);
- waitForQuery(q_context);
-
- QDeclarativeContext *actualContext = m_engine->rootContext();
- QDeclarativeDebugContextReference context = q_context->rootContext();
- QCOMPARE(context.debugId(), QDeclarativeDebugService::idForObject(actualContext));
- QCOMPARE(context.name(), actualContext->objectName());
-
- QCOMPARE(context.objects().count(), 4); // 4 qml component objects created for context in main()
-
- // root context query sends only root object data - it doesn't fill in
- // the children or property info
- QCOMPARE(context.objects()[0].properties().count(), 0);
- QCOMPARE(context.objects()[0].children().count(), 0);
-
- QCOMPARE(context.contexts().count(), 5);
- QVERIFY(context.contexts()[0].debugId() >= 0);
- QCOMPARE(context.contexts()[0].name(), QString("tst_QDeclarativeDebug_childContext"));
-
- // Make query invalid by deleting client
- q_context = m_dbg->queryRootContexts(engineId, this);
- QCOMPARE(q_context->state(), QDeclarativeDebugQuery::Waiting);
- delete m_dbg;
- QCOMPARE(q_context->state(), QDeclarativeDebugQuery::Error);
- delete q_context;
- m_dbg = new QDeclarativeEngineDebug(m_conn, this);
-}
-
-void tst_QDeclarativeEngineDebug::queryObject()
-{
- QFETCH(bool, recursive);
-
- QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
- QDeclarativeDebugObjectReference rootObject = q_context->rootContext().objects()[0];
-
- QDeclarativeDebugObjectQuery *q_obj = 0;
-
- QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
- q_obj = recursive ? unconnected->queryObjectRecursive(rootObject, this) : unconnected->queryObject(rootObject, this);
- QCOMPARE(q_obj->state(), QDeclarativeDebugQuery::Error);
- delete q_obj;
- delete unconnected;
-
- q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
- delete q_obj;
-
- q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
- waitForQuery(q_obj);
-
- QDeclarativeDebugObjectReference obj = q_obj->object();
-
- delete q_engines;
- delete q_context;
-
- // Make query invalid by deleting client
- q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
- QCOMPARE(q_obj->state(), QDeclarativeDebugQuery::Waiting);
- delete m_dbg;
- QCOMPARE(q_obj->state(), QDeclarativeDebugQuery::Error);
- delete q_obj;
- m_dbg = new QDeclarativeEngineDebug(m_conn, this);
-
- // check source as defined in main()
- QDeclarativeDebugFileReference source = obj.source();
- QCOMPARE(source.url(), QUrl::fromLocalFile(""));
- QCOMPARE(source.lineNumber(), 3);
- QCOMPARE(source.columnNumber(), 1);
-
- // generically test all properties, children and childrens' properties
- recursiveObjectTest(m_rootItem, obj, recursive);
-
- if (recursive) {
- foreach(const QDeclarativeDebugObjectReference &child, obj.children())
- QVERIFY(child.properties().count() > 0);
-
- QDeclarativeDebugObjectReference rect;
- QDeclarativeDebugObjectReference text;
- foreach (const QDeclarativeDebugObjectReference &child, obj.children()) {
- if (child.className() == "Rectangle")
- rect = child;
- else if (child.className() == "Text")
- text = child;
- }
-
- // test specific property values
- QCOMPARE(findProperty(rect.properties(), "width").value(), qVariantFromValue(500));
- QCOMPARE(findProperty(rect.properties(), "height").value(), qVariantFromValue(600));
- QCOMPARE(findProperty(rect.properties(), "color").value(), qVariantFromValue(QColor("blue")));
-
- QCOMPARE(findProperty(text.properties(), "color").value(), qVariantFromValue(QColor("blue")));
- } else {
- foreach(const QDeclarativeDebugObjectReference &child, obj.children())
- QCOMPARE(child.properties().count(), 0);
- }
-}
-
-void tst_QDeclarativeEngineDebug::queryObject_data()
-{
- QTest::addColumn<bool>("recursive");
-
- QTest::newRow("non-recursive") << false;
- QTest::newRow("recursive") << true;
-}
-
-void tst_QDeclarativeEngineDebug::queryExpressionResult()
-{
- QFETCH(QString, expr);
- QFETCH(QVariant, result);
-
- QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines); // check immediate deletion is ok
-
- QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
- int objectId = q_context->rootContext().objects()[0].debugId();
-
- QDeclarativeDebugExpressionQuery *q_expr;
-
- QDeclarativeEngineDebug *unconnected = new QDeclarativeEngineDebug(0);
- q_expr = unconnected->queryExpressionResult(objectId, expr, this);
- QCOMPARE(q_expr->state(), QDeclarativeDebugQuery::Error);
- delete q_expr;
- delete unconnected;
-
- q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
- delete q_expr;
-
- q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
- QCOMPARE(q_expr->expression().toString(), expr);
- waitForQuery(q_expr);
-
- QCOMPARE(q_expr->result(), result);
-
- delete q_engines;
- delete q_context;
-
- // Make query invalid by deleting client
- q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
- QCOMPARE(q_expr->state(), QDeclarativeDebugQuery::Waiting);
- delete m_dbg;
- QCOMPARE(q_expr->state(), QDeclarativeDebugQuery::Error);
- delete q_expr;
- m_dbg = new QDeclarativeEngineDebug(m_conn, this);
-}
-
-void tst_QDeclarativeEngineDebug::queryExpressionResult_data()
-{
- QTest::addColumn<QString>("expr");
- QTest::addColumn<QVariant>("result");
-
- QTest::newRow("width + 50") << "width + 50" << qVariantFromValue(60);
- QTest::newRow("blueRect.width") << "blueRect.width" << qVariantFromValue(500);
- QTest::newRow("bad expr") << "aeaef" << qVariantFromValue(QString("<undefined>"));
- QTest::newRow("QObject*") << "varObj" << qVariantFromValue(QString("<unnamed object>"));
- QTest::newRow("list of QObject*") << "varObjList" << qVariantFromValue(QString("<unknown value>"));
- QVariantMap map;
- map.insert(QLatin1String("rect"), QVariant(QLatin1String("<unnamed object>")));
- QTest::newRow("varObjMap") << "varObjMap" << qVariantFromValue(map);
-}
-
-void tst_QDeclarativeEngineDebug::tst_QDeclarativeDebugFileReference()
-{
- QDeclarativeDebugFileReference ref;
- QVERIFY(ref.url().isEmpty());
- QCOMPARE(ref.lineNumber(), -1);
- QCOMPARE(ref.columnNumber(), -1);
-
- ref.setUrl(QUrl("http://test"));
- QCOMPARE(ref.url(), QUrl("http://test"));
- ref.setLineNumber(1);
- QCOMPARE(ref.lineNumber(), 1);
- ref.setColumnNumber(1);
- QCOMPARE(ref.columnNumber(), 1);
-
- QDeclarativeDebugFileReference copy(ref);
- QDeclarativeDebugFileReference copyAssign;
- copyAssign = ref;
- foreach (const QDeclarativeDebugFileReference &r, (QList<QDeclarativeDebugFileReference>() << copy << copyAssign)) {
- QCOMPARE(r.url(), ref.url());
- QCOMPARE(r.lineNumber(), ref.lineNumber());
- QCOMPARE(r.columnNumber(), ref.columnNumber());
- }
-}
-
-void tst_QDeclarativeEngineDebug::tst_QDeclarativeDebugEngineReference()
-{
- QDeclarativeDebugEngineReference ref;
- QCOMPARE(ref.debugId(), -1);
- QVERIFY(ref.name().isEmpty());
-
- ref = QDeclarativeDebugEngineReference(1);
- QCOMPARE(ref.debugId(), 1);
- QVERIFY(ref.name().isEmpty());
-
- QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
- ref = q_engines->engines()[0];
- delete q_engines;
-
- QDeclarativeDebugEngineReference copy(ref);
- QDeclarativeDebugEngineReference copyAssign;
- copyAssign = ref;
- foreach (const QDeclarativeDebugEngineReference &r, (QList<QDeclarativeDebugEngineReference>() << copy << copyAssign)) {
- QCOMPARE(r.debugId(), ref.debugId());
- QCOMPARE(r.name(), ref.name());
- }
-}
-
-void tst_QDeclarativeEngineDebug::tst_QDeclarativeDebugObjectReference()
-{
- QDeclarativeDebugObjectReference ref;
- QCOMPARE(ref.debugId(), -1);
- QCOMPARE(ref.className(), QString());
- QCOMPARE(ref.name(), QString());
- QCOMPARE(ref.contextDebugId(), -1);
- QVERIFY(ref.properties().isEmpty());
- QVERIFY(ref.children().isEmpty());
-
- QDeclarativeDebugFileReference source = ref.source();
- QVERIFY(source.url().isEmpty());
- QVERIFY(source.lineNumber() < 0);
- QVERIFY(source.columnNumber() < 0);
-
- ref = QDeclarativeDebugObjectReference(1);
- QCOMPARE(ref.debugId(), 1);
-
- QDeclarativeDebugObjectReference rootObject = findRootObject();
- QDeclarativeDebugObjectQuery *query = m_dbg->queryObjectRecursive(rootObject, this);
- waitForQuery(query);
- ref = query->object();
- delete query;
-
- QVERIFY(ref.debugId() >= 0);
-
- QDeclarativeDebugObjectReference copy(ref);
- QDeclarativeDebugObjectReference copyAssign;
- copyAssign = ref;
- foreach (const QDeclarativeDebugObjectReference &r, (QList<QDeclarativeDebugObjectReference>() << copy << copyAssign))
- recursiveCompareObjects(r, ref);
-}
-
-void tst_QDeclarativeEngineDebug::tst_QDeclarativeDebugContextReference()
-{
- QDeclarativeDebugContextReference ref;
- QCOMPARE(ref.debugId(), -1);
- QVERIFY(ref.name().isEmpty());
- QVERIFY(ref.objects().isEmpty());
- QVERIFY(ref.contexts().isEmpty());
-
- QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
- QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- ref = q_context->rootContext();
- delete q_engines;
- delete q_context;
- QVERIFY(ref.debugId() >= 0);
-
- QDeclarativeDebugContextReference copy(ref);
- QDeclarativeDebugContextReference copyAssign;
- copyAssign = ref;
- foreach (const QDeclarativeDebugContextReference &r, (QList<QDeclarativeDebugContextReference>() << copy << copyAssign))
- recursiveCompareContexts(r, ref);
-}
-
-void tst_QDeclarativeEngineDebug::tst_QDeclarativeDebugPropertyReference()
-{
- QDeclarativeDebugObjectReference rootObject = findRootObject();
- QDeclarativeDebugObjectQuery *query = m_dbg->queryObject(rootObject, this);
- waitForQuery(query);
- QDeclarativeDebugObjectReference obj = query->object();
- delete query;
-
- QDeclarativeDebugPropertyReference ref = findProperty(obj.properties(), "scale");
- QVERIFY(ref.objectDebugId() > 0);
- QVERIFY(!ref.name().isEmpty());
- QVERIFY(!ref.value().isNull());
- QVERIFY(!ref.valueTypeName().isEmpty());
- QVERIFY(!ref.binding().isEmpty());
- QVERIFY(ref.hasNotifySignal());
-
- QDeclarativeDebugPropertyReference copy(ref);
- QDeclarativeDebugPropertyReference copyAssign;
- copyAssign = ref;
- foreach (const QDeclarativeDebugPropertyReference &r, (QList<QDeclarativeDebugPropertyReference>() << copy << copyAssign))
- compareProperties(r, ref);
-}
-
-void tst_QDeclarativeEngineDebug::setBindingForObject()
-{
- QDeclarativeDebugObjectReference rootObject = findRootObject();
- QVERIFY(rootObject.debugId() != -1);
- QDeclarativeDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties(), "width");
-
- QCOMPARE(widthPropertyRef.value(), QVariant(10));
- QCOMPARE(widthPropertyRef.binding(), QString());
-
- //
- // set literal
- //
- m_dbg->setBindingForObject(rootObject.debugId(), "width", "15", true);
-
- rootObject = findRootObject();
- widthPropertyRef = findProperty(rootObject.properties(), "width");
-
- QCOMPARE(widthPropertyRef.value(), QVariant(15));
- QCOMPARE(widthPropertyRef.binding(), QString());
-
- //
- // set expression
- //
- m_dbg->setBindingForObject(rootObject.debugId(), "width", "height", false);
-
- rootObject = findRootObject();
- widthPropertyRef = findProperty(rootObject.properties(), "width");
-
- QCOMPARE(widthPropertyRef.value(), QVariant(20));
- QCOMPARE(widthPropertyRef.binding(), QString("height"));
-
- //
- // reset
- //
- m_dbg->resetBindingForObject(rootObject.debugId(), "width");
-
- rootObject = findRootObject();
- widthPropertyRef = findProperty(rootObject.properties(), "width");
-
- // QCOMPARE(widthPropertyRef.value(), QVariant(0)); // TODO: Shouldn't this work?
- QCOMPARE(widthPropertyRef.binding(), QString());
-
- //
- // set handler
- //
- rootObject = findRootObject();
- QCOMPARE(rootObject.children().size(), 5); // Rectangle, Text, MouseArea, Component.onCompleted, NonScriptPropertyElement
- QDeclarativeDebugObjectReference mouseAreaObject = rootObject.children().at(2);
- QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObjectRecursive(mouseAreaObject, this);
- waitForQuery(q_obj);
- mouseAreaObject = q_obj->object();
-
- QCOMPARE(mouseAreaObject.className(), QString("MouseArea"));
-
- QDeclarativeDebugPropertyReference onEnteredRef = findProperty(mouseAreaObject.properties(), "onEntered");
-
- QCOMPARE(onEnteredRef.name(), QString("onEntered"));
- QCOMPARE(onEnteredRef.value(), QVariant("(function onEntered() { { console.log('hello') } })"));
-
- m_dbg->setBindingForObject(mouseAreaObject.debugId(), "onEntered", "{console.log('hello, world') }", false) ;
-
- rootObject = findRootObject();
- mouseAreaObject = rootObject.children().at(2);
- q_obj = m_dbg->queryObjectRecursive(mouseAreaObject, this);
- waitForQuery(q_obj);
- mouseAreaObject = q_obj->object();
- onEnteredRef = findProperty(mouseAreaObject.properties(), "onEntered");
- QCOMPARE(onEnteredRef.name(), QString("onEntered"));
- QCOMPARE(onEnteredRef.value(), QVariant("{console.log('hello, world') }"));
-}
-
-void tst_QDeclarativeEngineDebug::setBindingInStates()
-{
- // Check if changing bindings of propertychanges works
-
- const int sourceIndex = 3;
-
- QDeclarativeDebugObjectReference obj = findRootObject(sourceIndex);
-
- QVERIFY(obj.debugId() != -1);
- QVERIFY(obj.children().count() >= 2);
-
- // We are going to switch state a couple of times, we need to get rid of the transition before
- QDeclarativeDebugExpressionQuery *q_deleteTransition = m_dbg->queryExpressionResult(obj.debugId(),QString("transitions = []"),this);
- waitForQuery(q_deleteTransition);
- delete q_deleteTransition;
-
-
- // check initial value of the property that is changing
- QDeclarativeDebugExpressionQuery *q_setState;
- q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this);
- waitForQuery(q_setState);
- delete q_setState;
-
- obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),200);
-
-
- q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"\""),this);
- waitForQuery(q_setState);
- delete q_setState;
-
-
- obj = findRootObject(sourceIndex, true);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),100);
-
-
- // change the binding
- QDeclarativeDebugObjectReference state = obj.children()[1];
- QCOMPARE(state.className(), QString("State"));
- QVERIFY(state.children().count() > 0);
-
- QDeclarativeDebugObjectReference propertyChange = state.children()[0];
- QVERIFY(propertyChange.debugId() != -1);
-
- QVERIFY( m_dbg->setBindingForObject(propertyChange.debugId(), "width",QVariant(300),true) );
-
- // check properties changed in state
- obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),100);
-
-
- q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this);
- waitForQuery(q_setState);
- delete q_setState;
-
- obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),300);
-
- // check changing properties of base state from within a state
- QVERIFY(m_dbg->setBindingForObject(obj.debugId(),"width","height*2",false));
- QVERIFY(m_dbg->setBindingForObject(obj.debugId(),"height","200",true));
-
- obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),300);
-
- q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"\""),this);
- waitForQuery(q_setState);
- delete q_setState;
-
- obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 400);
-
- // reset binding while in a state
- q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this);
- waitForQuery(q_setState);
- delete q_setState;
-
- obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 300);
-
- m_dbg->resetBindingForObject(propertyChange.debugId(), "width");
-
- obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 400);
-
- // re-add binding
- m_dbg->setBindingForObject(propertyChange.debugId(), "width", "300", true);
-
- obj = findRootObject(sourceIndex);
- QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 300);
-}
-
-void tst_QDeclarativeEngineDebug::queryObjectTree()
-{
- const int sourceIndex = 3;
-
- // Check if states/transitions are initialized when fetching root item
- QDeclarativeDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
- waitForQuery(q_engines);
-
- QDeclarativeDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
- waitForQuery(q_context);
-
- QVERIFY(q_context->rootContext().objects().count() > sourceIndex);
- QDeclarativeDebugObjectReference rootObject = q_context->rootContext().objects()[sourceIndex];
-
- QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObjectRecursive(rootObject, this);
- waitForQuery(q_obj);
-
- QDeclarativeDebugObjectReference obj = q_obj->object();
-
- delete q_engines;
- delete q_context;
- delete q_obj;
-
- QVERIFY(obj.debugId() != -1);
- QVERIFY(obj.children().count() >= 2);
-
-
-
- // check state
- QDeclarativeDebugObjectReference state = obj.children()[1];
- QCOMPARE(state.className(), QString("State"));
- QVERIFY(state.children().count() > 0);
-
- QDeclarativeDebugObjectReference propertyChange = state.children()[0];
- QVERIFY(propertyChange.debugId() != -1);
-
- QDeclarativeDebugPropertyReference propertyChangeTarget = findProperty(propertyChange.properties(),"target");
- QCOMPARE(propertyChangeTarget.objectDebugId(), propertyChange.debugId());
-
- QDeclarativeDebugObjectReference targetReference = qvariant_cast<QDeclarativeDebugObjectReference>(propertyChangeTarget.value());
- QVERIFY(targetReference.debugId() != -1);
-
-
-
- // check transition
- QDeclarativeDebugObjectReference transition = obj.children()[0];
- QCOMPARE(transition.className(), QString("Transition"));
- QCOMPARE(findProperty(transition.properties(),"from").value().toString(), QString("*"));
- QCOMPARE(findProperty(transition.properties(),"to").value(), findProperty(state.properties(),"name").value());
- QVERIFY(transition.children().count() > 0);
-
- QDeclarativeDebugObjectReference animation = transition.children()[0];
- QVERIFY(animation.debugId() != -1);
-
- QDeclarativeDebugPropertyReference animationTarget = findProperty(animation.properties(),"target");
- QCOMPARE(animationTarget.objectDebugId(), animation.debugId());
-
- targetReference = qvariant_cast<QDeclarativeDebugObjectReference>(animationTarget.value());
- QVERIFY(targetReference.debugId() != -1);
-
- QCOMPARE(findProperty(animation.properties(),"property").value().toString(), QString("width"));
- QCOMPARE(findProperty(animation.properties(),"duration").value().toInt(), 100);
-}
-
-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];
- char arg[] = "-qmljsdebugger=port:3768";
- _argv[_argc - 1] = arg;
-
- QGuiApplication app(_argc, _argv);
- tst_QDeclarativeEngineDebug tc;
- return QTest::qExec(&tc, _argc, _argv);
- delete _argv;
-}
-
-#include "tst_qdeclarativeenginedebug.moc"
diff --git a/tests/auto/declarative/debugger/qdeclarativeinspector/app/app.pro b/tests/auto/declarative/debugger/qdeclarativeinspector/app/app.pro
deleted file mode 100644
index 6433631c4b..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativeinspector/app/app.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-TARGET = app
-QT += declarative quick widgets
-
-CONFIG += declarative_debug
-macx:CONFIG -= app_bundle
-
-SOURCES += main.cpp
-
-OTHER_FILES += qtquick1.qml qtquick2.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativeinspector/qdeclarativeinspector.pro b/tests/auto/declarative/debugger/qdeclarativeinspector/qdeclarativeinspector.pro
deleted file mode 100644
index 28d16a5029..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativeinspector/qdeclarativeinspector.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS += tst_qdeclarativeinspector.pro app
diff --git a/tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.cpp b/tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.cpp
deleted file mode 100644
index 4d7e57f4d4..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QHostAddress>
-#include <QDebug>
-#include <QThread>
-
-#include "../../../../../src/plugins/qmltooling/shared/qdeclarativeinspectorprotocol.h"
-#include "../shared/debugutil_p.h"
-
-using namespace QmlJSDebugger;
-
-#define PORT 13772
-#define STR_PORT "13772"
-
-class QDeclarativeInspectorClient : public QDeclarativeDebugClient
-{
- Q_OBJECT
-
-public:
- QDeclarativeInspectorClient(QDeclarativeDebugConnection *connection)
- : QDeclarativeDebugClient(QLatin1String("QDeclarativeObserverMode"), connection)
- , m_showAppOnTop(false)
- {
- }
-
- bool showAppOnTop() const { return m_showAppOnTop; }
- void setShowAppOnTop(bool showOnTop);
-
-signals:
- void showAppOnTopChanged();
-
-protected:
- void messageReceived(const QByteArray &message);
-
-private:
- bool m_showAppOnTop;
-};
-
-class tst_QDeclarativeInspector : public QObject
-{
- Q_OBJECT
-
-public:
- tst_QDeclarativeInspector()
- : m_process(0)
- , m_connection(0)
- , m_client(0)
- {
- }
-
-
-private:
- QDeclarativeDebugProcess *m_process;
- QDeclarativeDebugConnection *m_connection;
- QDeclarativeInspectorClient *m_client;
-
-private slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
- void connect();
- void showAppOnTop();
-};
-
-
-void QDeclarativeInspectorClient::setShowAppOnTop(bool showOnTop)
-{
- QByteArray message;
- QDataStream ds(&message, QIODevice::WriteOnly);
- ds << InspectorProtocol::ShowAppOnTop << showOnTop;
-
- sendMessage(message);
-}
-
-void QDeclarativeInspectorClient::messageReceived(const QByteArray &message)
-{
- QDataStream ds(message);
- InspectorProtocol::Message type;
- ds >> type;
-
- switch (type) {
- case InspectorProtocol::ShowAppOnTop:
- ds >> m_showAppOnTop;
- emit showAppOnTopChanged();
- break;
- default:
- qDebug() << "Unhandled message " << (int)type;
- }
-}
-
-void tst_QDeclarativeInspector::initTestCase()
-{
-}
-
-void tst_QDeclarativeInspector::cleanupTestCase()
-{
-}
-
-void tst_QDeclarativeInspector::init()
-{
- const QString executable = SRCDIR"/app/app";
- const QString argument = "-qmljsdebugger=port:"STR_PORT",block";
-
- m_process = new QDeclarativeDebugProcess(executable);
- m_process->start(QStringList() << argument);
- if (!m_process->waitForSessionStart()) {
- QFAIL(QString("Could not launch app '%1'.\nApplication output:\n%2").arg(executable, m_process->output()).toAscii());
- }
-
- QDeclarativeDebugConnection *m_connection = new QDeclarativeDebugConnection();
- m_client = new QDeclarativeInspectorClient(m_connection);
-
- m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT);
-}
-
-void tst_QDeclarativeInspector::cleanup()
-{
- delete m_process;
- delete m_connection;
- delete m_client;
-}
-
-void tst_QDeclarativeInspector::connect()
-{
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-}
-
-void tst_QDeclarativeInspector::showAppOnTop()
-{
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->setShowAppOnTop(true);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(showAppOnTopChanged())));
- QCOMPARE(m_client->showAppOnTop(), true);
-
- m_client->setShowAppOnTop(false);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(showAppOnTopChanged())));
- QCOMPARE(m_client->showAppOnTop(), false);
-}
-
-QTEST_MAIN(tst_QDeclarativeInspector)
-
-#include "tst_qdeclarativeinspector.moc"
diff --git a/tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.pro b/tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.pro
deleted file mode 100644
index 6ea6010a32..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativeinspector/tst_qdeclarativeinspector.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeinspector
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qdeclarativeinspector.cpp \
- ../shared/debugutil.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-CONFIG += parallel_test declarative_debug
-
-QT += declarative-private testlib
diff --git a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro b/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro
deleted file mode 100644
index 564945faf7..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/qdeclarativeprofilerservice.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeprofilerservice
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-
-SOURCES += tst_qdeclarativeprofilerservice.cpp \
- ../shared/debugutil.cpp
-OTHER_FILES += data/test.qml
-
-include (../../../shared/util.pri)
-
-CONFIG += parallel_test declarative_debug
-
-QT += declarative-private testlib
diff --git a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/tst_qdeclarativeprofilerservice.cpp b/tests/auto/declarative/debugger/qdeclarativeprofilerservice/tst_qdeclarativeprofilerservice.cpp
deleted file mode 100644
index 5de7b8621d..0000000000
--- a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/tst_qdeclarativeprofilerservice.cpp
+++ /dev/null
@@ -1,310 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QLibraryInfo>
-
-#include "QtDeclarative/private/qdeclarativeprofilerservice_p.h"
-#include "../shared/debugutil_p.h"
-#include "../../../shared/util.h"
-
-#define PORT 13773
-#define STR_PORT "13773"
-
-class QDeclarativeProfilerClient : public QDeclarativeDebugClient
-{
- Q_OBJECT
-
-public:
- QDeclarativeProfilerClient(QDeclarativeDebugConnection *connection)
- : QDeclarativeDebugClient(QLatin1String("CanvasFrameRate"), connection)
- {
- }
-
- QList<QDeclarativeProfilerData> traceMessages;
-
- void setTraceState(bool enabled) {
- QByteArray message;
- QDataStream stream(&message, QIODevice::WriteOnly);
- stream << enabled;
- sendMessage(message);
- }
-
-signals:
- void complete();
-
-protected:
- void messageReceived(const QByteArray &message);
-};
-
-class tst_QDeclarativeProfilerService : public QDeclarativeDataTest
-{
- Q_OBJECT
-
-public:
- tst_QDeclarativeProfilerService()
- : m_process(0)
- , m_connection(0)
- , m_client(0)
- {
- }
-
-private:
- QDeclarativeDebugProcess *m_process;
- QDeclarativeDebugConnection *m_connection;
- QDeclarativeProfilerClient *m_client;
-
- void connect(bool block, const QString &testFile);
-
-private slots:
- void cleanup();
-
- void blockingConnectWithTraceEnabled();
- void blockingConnectWithTraceDisabled();
- void nonBlockingConnect();
- void profileOnExit();
-};
-
-void QDeclarativeProfilerClient::messageReceived(const QByteArray &message)
-{
- QByteArray msg = message;
- QDataStream stream(&msg, QIODevice::ReadOnly);
-
-
- QDeclarativeProfilerData data;
- data.time = -2;
- data.messageType = -1;
- data.detailType = -1;
- data.line = -1;
- data.framerate = -1;
- data.animationcount = -1;
-
- stream >> data.time >> data.messageType;
-
- QVERIFY(data.time >= -1);
-
- switch (data.messageType) {
- case (QDeclarativeProfilerService::Event): {
- stream >> data.detailType;
-
- switch (data.detailType) {
- case QDeclarativeProfilerService::AnimationFrame: {
- stream >> data.framerate >> data.animationcount;
- QVERIFY(data.framerate != -1);
- QVERIFY(data.animationcount != -1);
- break;
- }
- case QDeclarativeProfilerService::FramePaint:
- case QDeclarativeProfilerService::Mouse:
- case QDeclarativeProfilerService::Key:
- case QDeclarativeProfilerService::StartTrace:
- case QDeclarativeProfilerService::EndTrace:
- break;
- default: {
- QString failMsg = QString("Unknown event type:") + data.detailType;
- QFAIL(qPrintable(failMsg));
- break;
- }
- }
- break;
- }
- case QDeclarativeProfilerService::Complete: {
- emit complete();
- return;
- }
- case QDeclarativeProfilerService::RangeStart: {
- stream >> data.detailType;
- QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeProfilerService::MaximumRangeType);
- break;
- }
- case QDeclarativeProfilerService::RangeEnd: {
- stream >> data.detailType;
- QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeProfilerService::MaximumRangeType);
- break;
- }
- case QDeclarativeProfilerService::RangeData: {
- stream >> data.detailType >> data.detailData;
- QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeProfilerService::MaximumRangeType);
- break;
- }
- case QDeclarativeProfilerService::RangeLocation: {
- stream >> data.detailType >> data.detailData >> data.line >> data.column;
- QVERIFY(data.detailType >= 0 && data.detailType < QDeclarativeProfilerService::MaximumRangeType);
- QVERIFY(data.line >= -2);
- break;
- }
- default:
- QString failMsg = QString("Unknown message type:") + data.messageType;
- QFAIL(qPrintable(failMsg));
- break;
- }
- QVERIFY(stream.atEnd());
- traceMessages.append(data);
-}
-
-void tst_QDeclarativeProfilerService::connect(bool block, const QString &testFile)
-{
- const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene";
- QStringList arguments;
-
- if (block)
- arguments << QString("-qmljsdebugger=port:"STR_PORT",block");
- else
- arguments << QString("-qmljsdebugger=port:"STR_PORT);
-
- arguments << QDeclarativeDataTest::instance()->testFile(testFile);
-
- m_process = new QDeclarativeDebugProcess(executable);
- m_process->start(QStringList() << arguments);
- if (!m_process->waitForSessionStart()) {
- QString failMsg = QString("Could not launch app '%1'.\nApplication output:\n%2").arg(
- executable, m_process->output());
- QFAIL(qPrintable(failMsg));
- }
-
- QDeclarativeDebugConnection *m_connection = new QDeclarativeDebugConnection();
- m_client = new QDeclarativeProfilerClient(m_connection);
-
- m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT);
-}
-
-void tst_QDeclarativeProfilerService::cleanup()
-{
- delete m_process;
- delete m_connection;
- delete m_client;
-}
-
-void tst_QDeclarativeProfilerService::blockingConnectWithTraceEnabled()
-{
- connect(true, "test.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->setTraceState(true);
- m_client->setTraceState(false);
- if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
- QString failMsg
- = QString("No trace received in time. App output: \n%1\n").arg(m_process->output());
- QFAIL(qPrintable(failMsg));
- }
-
- QVERIFY(m_client->traceMessages.count());
- // must start with "StartTrace"
- QCOMPARE(m_client->traceMessages.first().messageType, (int)QDeclarativeProfilerService::Event);
- QCOMPARE(m_client->traceMessages.first().detailType, (int)QDeclarativeProfilerService::StartTrace);
-
- // must end with "EndTrace"
- QCOMPARE(m_client->traceMessages.last().messageType, (int)QDeclarativeProfilerService::Event);
- QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeProfilerService::EndTrace);
-}
-
-void tst_QDeclarativeProfilerService::blockingConnectWithTraceDisabled()
-{
- connect(true, "test.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->setTraceState(false);
- m_client->setTraceState(true);
- m_client->setTraceState(false);
- if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
- QString failMsg
- = QString("No trace received in time. App output: \n%1\n").arg(m_process->output());
- QFAIL(qPrintable(failMsg));
- }
-
- QVERIFY(m_client->traceMessages.count());
-
- // must start with "StartTrace"
- QCOMPARE(m_client->traceMessages.first().messageType, (int)QDeclarativeProfilerService::Event);
- QCOMPARE(m_client->traceMessages.first().detailType, (int)QDeclarativeProfilerService::StartTrace);
-
- // must end with "EndTrace"
- QCOMPARE(m_client->traceMessages.last().messageType, (int)QDeclarativeProfilerService::Event);
- QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeProfilerService::EndTrace);
-}
-
-void tst_QDeclarativeProfilerService::nonBlockingConnect()
-{
- connect(false, "test.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->setTraceState(true);
- m_client->setTraceState(false);
- if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
- QString failMsg
- = QString("No trace received in time. App output: \n%1\n").arg(m_process->output());
- QFAIL(qPrintable(failMsg));
- }
-
- // must start with "StartTrace"
- QCOMPARE(m_client->traceMessages.first().messageType, (int)QDeclarativeProfilerService::Event);
- QCOMPARE(m_client->traceMessages.first().detailType, (int)QDeclarativeProfilerService::StartTrace);
-
- // must end with "EndTrace"
- QCOMPARE(m_client->traceMessages.last().messageType, (int)QDeclarativeProfilerService::Event);
- QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeProfilerService::EndTrace);
-}
-
-void tst_QDeclarativeProfilerService::profileOnExit()
-{
- connect(true, "exit.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->setTraceState(true);
-
- if (!QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
- QString failMsg
- = QString("No trace received in time. App output: \n%1\n").arg(m_process->output());
- QFAIL(qPrintable(failMsg));
- }
-
- // must start with "StartTrace"
- QCOMPARE(m_client->traceMessages.first().messageType, (int)QDeclarativeProfilerService::Event);
- QCOMPARE(m_client->traceMessages.first().detailType, (int)QDeclarativeProfilerService::StartTrace);
-
- // must end with "EndTrace"
- QCOMPARE(m_client->traceMessages.last().messageType, (int)QDeclarativeProfilerService::Event);
- QCOMPARE(m_client->traceMessages.last().detailType, (int)QDeclarativeProfilerService::EndTrace);
-}
-
-QTEST_MAIN(tst_QDeclarativeProfilerService)
-
-#include "tst_qdeclarativeprofilerservice.moc"
diff --git a/tests/auto/declarative/debugger/qpacketprotocol/qpacketprotocol.pro b/tests/auto/declarative/debugger/qpacketprotocol/qpacketprotocol.pro
deleted file mode 100644
index 949132feff..0000000000
--- a/tests/auto/declarative/debugger/qpacketprotocol/qpacketprotocol.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qpacketprotocol
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-SOURCES += tst_qpacketprotocol.cpp \
- ../shared/debugutil.cpp
-
-CONFIG += parallel_test
-QT += declarative-private network testlib
diff --git a/tests/auto/declarative/debugger/qpacketprotocol/tst_qpacketprotocol.cpp b/tests/auto/declarative/debugger/qpacketprotocol/tst_qpacketprotocol.cpp
deleted file mode 100644
index ac664730cb..0000000000
--- a/tests/auto/declarative/debugger/qpacketprotocol/tst_qpacketprotocol.cpp
+++ /dev/null
@@ -1,263 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QTimer>
-#include <QTcpSocket>
-#include <QTcpServer>
-#include <QDebug>
-#include <QBuffer>
-
-#include <private/qpacketprotocol_p.h>
-
-#include "../shared/debugutil_p.h"
-
-class tst_QPacketProtocol : public QObject
-{
- Q_OBJECT
-
-private:
- QTcpServer *m_server;
- QTcpSocket *m_client;
- QTcpSocket *m_serverConn;
-
-private slots:
- void init();
- void cleanup();
-
- void maximumPacketSize();
- void setMaximumPacketSize();
- void setMaximumPacketSize_data();
- void send();
- void send_data();
- void packetsAvailable();
- void packetsAvailable_data();
- void clear();
- void read();
- void device();
-
- void tst_QPacket_clear();
-};
-
-void tst_QPacketProtocol::init()
-{
- m_server = new QTcpServer(this);
- m_serverConn = 0;
- QVERIFY(m_server->listen(QHostAddress("127.0.0.1")));
-
- m_client = new QTcpSocket(this);
- m_client->connectToHost(m_server->serverAddress(), m_server->serverPort());
-
- QVERIFY(m_client->waitForConnected());
- QVERIFY(m_server->waitForNewConnection(5000));
- m_serverConn = m_server->nextPendingConnection();
-}
-
-void tst_QPacketProtocol::cleanup()
-{
- delete m_client;
- delete m_serverConn;
- delete m_server;
-}
-
-void tst_QPacketProtocol::maximumPacketSize()
-{
- QPacketProtocol p(m_client);
- QCOMPARE(p.maximumPacketSize(), 0x7FFFFFFF);
-}
-
-void tst_QPacketProtocol::setMaximumPacketSize()
-{
- QFETCH(qint32, size);
- QFETCH(qint32, expected);
-
- QPacketProtocol out(m_serverConn);
- QCOMPARE(out.setMaximumPacketSize(size), expected);
-}
-
-void tst_QPacketProtocol::setMaximumPacketSize_data()
-{
- QTest::addColumn<int>("size");
- QTest::addColumn<int>("expected");
-
- QTest::newRow("invalid") << qint32(sizeof(qint32) - 1) << qint32(0x7FFFFFFF);
- QTest::newRow("still invalid") << qint32(sizeof(qint32)) << qint32(0x7FFFFFFF);
- QTest::newRow("valid") << qint32(sizeof(qint32) + 1) << qint32(sizeof(qint32) + 1);
-}
-
-void tst_QPacketProtocol::send()
-{
- QFETCH(bool, useAutoSend);
-
- QPacketProtocol in(m_client);
- QPacketProtocol out(m_serverConn);
-
- QByteArray ba;
- int num;
-
- if (useAutoSend) {
- out.send() << "Hello world" << 123;
- } else {
- QPacket packet;
- packet << "Hello world" << 123;
- out.send(packet);
- }
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
-
- QPacket p = in.read();
- p >> ba >> num;
- QCOMPARE(ba, QByteArray("Hello world") + '\0');
- QCOMPARE(num, 123);
-}
-
-void tst_QPacketProtocol::send_data()
-{
- QTest::addColumn<bool>("useAutoSend");
-
- QTest::newRow("auto send") << true;
- QTest::newRow("no auto send") << false;
-}
-
-void tst_QPacketProtocol::packetsAvailable()
-{
- QFETCH(int, packetCount);
-
- QPacketProtocol out(m_client);
- QPacketProtocol in(m_serverConn);
-
- QCOMPARE(out.packetsAvailable(), qint64(0));
- QCOMPARE(in.packetsAvailable(), qint64(0));
-
- for (int i=0; i<packetCount; i++)
- out.send() << "Hello";
-
- QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
- QCOMPARE(in.packetsAvailable(), qint64(packetCount));
-}
-
-void tst_QPacketProtocol::packetsAvailable_data()
-{
- QTest::addColumn<int>("packetCount");
-
- QTest::newRow("1") << 1;
- QTest::newRow("2") << 2;
- QTest::newRow("10") << 10;
-}
-
-void tst_QPacketProtocol::clear()
-{
- QPacketProtocol in(m_client);
- QPacketProtocol out(m_serverConn);
-
- out.send() << 123;
- out.send() << 456;
- QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
-
- in.clear();
- QVERIFY(in.read().isEmpty());
-}
-
-void tst_QPacketProtocol::read()
-{
- QPacketProtocol in(m_client);
- QPacketProtocol out(m_serverConn);
-
- QVERIFY(in.read().isEmpty());
-
- out.send() << 123;
- out.send() << 456;
- QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
-
- int num;
-
- QPacket p1 = in.read();
- QVERIFY(!p1.isEmpty());
- p1 >> num;
- QCOMPARE(num, 123);
-
- QPacket p2 = in.read();
- QVERIFY(!p2.isEmpty());
- p2 >> num;
- QCOMPARE(num, 456);
-
- QVERIFY(in.read().isEmpty());
-}
-
-void tst_QPacketProtocol::device()
-{
- QPacketProtocol p(m_client);
- QVERIFY(p.device() == m_client);
-}
-
-void tst_QPacketProtocol::tst_QPacket_clear()
-{
- QPacketProtocol protocol(m_client);
-
- QPacket packet;
-
- packet << "Hello world!" << 123;
- protocol.send(packet);
-
- packet.clear();
- QVERIFY(packet.isEmpty());
- packet << "Goodbyte world!" << 789;
- protocol.send(packet);
-
- QByteArray ba;
- int num;
- QPacketProtocol in(m_serverConn);
- QVERIFY(QDeclarativeDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
-
- QPacket p1 = in.read();
- p1 >> ba >> num;
- QCOMPARE(ba, QByteArray("Hello world!") + '\0');
- QCOMPARE(num, 123);
-
- QPacket p2 = in.read();
- p2 >> ba >> num;
- QCOMPARE(ba, QByteArray("Goodbyte world!") + '\0');
- QCOMPARE(num, 789);
-}
-
-QTEST_MAIN(tst_QPacketProtocol)
-
-#include "tst_qpacketprotocol.moc"
diff --git a/tests/auto/declarative/debugger/qv8profilerservice/qv8profilerservice.pro b/tests/auto/declarative/debugger/qv8profilerservice/qv8profilerservice.pro
deleted file mode 100644
index eb57dff2fe..0000000000
--- a/tests/auto/declarative/debugger/qv8profilerservice/qv8profilerservice.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qv8profilerservice
-macx:CONFIG -= app_bundle
-
-HEADERS += ../shared/debugutil_p.h
-
-SOURCES += tst_qv8profilerservice.cpp \
- ../shared/debugutil.cpp
-
-include (../../../shared/util.pri)
-
-OTHER_FILES += data/test.qml
-
-CONFIG += parallel_test declarative_debug
-
-QT += declarative-private testlib
diff --git a/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp b/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
deleted file mode 100644
index 92b893afc6..0000000000
--- a/tests/auto/declarative/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
+++ /dev/null
@@ -1,280 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QLibraryInfo>
-
-#include "QtDeclarative/private/qv8profilerservice_p.h"
-#include "../shared/debugutil_p.h"
-#include "../../../shared/util.h"
-
-#define PORT 13774
-#define STR_PORT "13774"
-
-class QV8ProfilerClient : public QDeclarativeDebugClient
-{
- Q_OBJECT
-
-public:
- QV8ProfilerClient(QDeclarativeDebugConnection *connection)
- : QDeclarativeDebugClient(QLatin1String("V8Profiler"), connection)
- {
- }
-
- void startProfiling(const QString &name) {
- QByteArray message;
- QDataStream stream(&message, QIODevice::WriteOnly);
- stream << QByteArray("V8PROFILER") << QByteArray("start") << name;
- sendMessage(message);
- }
-
- void stopProfiling(const QString &name) {
- QByteArray message;
- QDataStream stream(&message, QIODevice::WriteOnly);
- stream << QByteArray("V8PROFILER") << QByteArray("stop") << name;
- sendMessage(message);
- }
-
- void takeSnapshot() {
- QByteArray message;
- QDataStream stream(&message, QIODevice::WriteOnly);
- stream << QByteArray("V8SNAPSHOT") << QByteArray("full");
- sendMessage(message);
- }
-
- void deleteSnapshots() {
- QByteArray message;
- QDataStream stream(&message, QIODevice::WriteOnly);
- stream << QByteArray("V8SNAPSHOT") << QByteArray("delete");
- sendMessage(message);
- }
-
- QList<QV8ProfilerData> traceMessages;
- QList<QByteArray> snapshotMessages;
-
-signals:
- void complete();
- void snapshot();
-
-protected:
- void messageReceived(const QByteArray &message);
-};
-
-class tst_QV8ProfilerService : public QDeclarativeDataTest
-{
- Q_OBJECT
-
-public:
- tst_QV8ProfilerService()
- : m_process(0)
- , m_connection(0)
- , m_client(0)
- {
- }
-
-private:
- QDeclarativeDebugProcess *m_process;
- QDeclarativeDebugConnection *m_connection;
- QV8ProfilerClient *m_client;
-
- void connect(bool block, const QString &testFile);
-
-private slots:
- void cleanup();
-
- void blockingConnectWithTraceEnabled();
- void blockingConnectWithTraceDisabled();
- void nonBlockingConnect();
- void snapshot();
- void profileOnExit();
- void console();
-};
-
-void QV8ProfilerClient::messageReceived(const QByteArray &message)
-{
- QByteArray msg = message;
- QDataStream stream(&msg, QIODevice::ReadOnly);
-
- int messageType;
- stream >> messageType;
-
- QVERIFY(messageType >= 0);
- QVERIFY(messageType < QV8ProfilerService::V8MaximumMessage);
-
- switch (messageType) {
- case QV8ProfilerService::V8Entry: {
- QV8ProfilerData entry;
- stream >> entry.filename >> entry.functionname >> entry.lineNumber >> entry.totalTime >> entry.selfTime >> entry.treeLevel;
- traceMessages.append(entry);
- break;
- }
- case QV8ProfilerService::V8Complete:
- emit complete();
- break;
- case QV8ProfilerService::V8SnapshotChunk: {
- QByteArray json;
- stream >> json;
- snapshotMessages.append(json);
- break;
- }
- case QV8ProfilerService::V8SnapshotComplete:
- emit snapshot();
- break;
- default:
- QString failMessage = QString("Unknown message type: %1").arg(messageType);
- QFAIL(qPrintable(failMessage));
- }
-
- QVERIFY(stream.atEnd());
-}
-
-void tst_QV8ProfilerService::connect(bool block, const QString &testFile)
-{
- const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene";
- QStringList arguments;
-
- if (block)
- arguments << QString("-qmljsdebugger=port:"STR_PORT",block");
- else
- arguments << QString("-qmljsdebugger=port:"STR_PORT);
-
- arguments << QDeclarativeDataTest::instance()->testFile(testFile);
-
- m_process = new QDeclarativeDebugProcess(executable);
- m_process->start(QStringList() << arguments);
- if (!m_process->waitForSessionStart()) {
- QString failMsg = QString("Could not launch app '%1'.\nApplication output:\n%2").arg(
- executable, m_process->output());
- QFAIL(qPrintable(failMsg));
- }
-
- QDeclarativeDebugConnection *m_connection = new QDeclarativeDebugConnection();
- m_client = new QV8ProfilerClient(m_connection);
-
- m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT);
-}
-
-void tst_QV8ProfilerService::cleanup()
-{
- if (QTest::currentTestFailed())
- qDebug() << "Application Output:" << m_process->output();
-
- delete m_process;
- delete m_connection;
- delete m_client;
-}
-
-void tst_QV8ProfilerService::blockingConnectWithTraceEnabled()
-{
- connect(true, "test.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->startProfiling("");
- m_client->stopProfiling("");
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())),
- "No trace received in time.");
-}
-
-void tst_QV8ProfilerService::blockingConnectWithTraceDisabled()
-{
- connect(true, "test.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->stopProfiling("");
- if (QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete()), 1000)) {
- QString failMsg
- = QString("Unexpected trace received! App output: %1\n\n").arg(m_process->output());
- QFAIL(qPrintable(failMsg));
- }
- m_client->startProfiling("");
- m_client->stopProfiling("");
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())),
- "No trace received in time.");
-}
-
-void tst_QV8ProfilerService::nonBlockingConnect()
-{
- connect(false, "test.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->startProfiling("");
- m_client->stopProfiling("");
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())),
- "No trace received in time.");
-}
-
-void tst_QV8ProfilerService::snapshot()
-{
- connect(false, "test.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->takeSnapshot();
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(snapshot())),
- "No trace received in time.");
-}
-
-void tst_QV8ProfilerService::profileOnExit()
-{
- connect(true, "exit.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->startProfiling("");
-
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())),
- "No trace received in time.");
- //QVERIFY(!m_client->traceMessages.isEmpty());
-}
-
-void tst_QV8ProfilerService::console()
-{
- connect(true, "console.qml");
- QTRY_COMPARE(m_client->state(), QDeclarativeDebugClient::Enabled);
-
- m_client->stopProfiling("");
-
- QVERIFY2(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(complete())),
- "No trace received in time.");
- QVERIFY(!m_client->traceMessages.isEmpty());
-}
-
-QTEST_MAIN(tst_QV8ProfilerService)
-
-#include "tst_qv8profilerservice.moc"
diff --git a/tests/auto/declarative/debugger/shared/debugutil.cpp b/tests/auto/declarative/debugger/shared/debugutil.cpp
deleted file mode 100644
index fcac1bc61d..0000000000
--- a/tests/auto/declarative/debugger/shared/debugutil.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "debugutil_p.h"
-
-#include <QEventLoop>
-#include <QTimer>
-
-#include <private/qdeclarativedebugclient_p.h>
-#include <private/qdeclarativedebugservice_p.h>
-
-bool QDeclarativeDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) {
- QEventLoop loop;
- QTimer timer;
- timer.setSingleShot(true);
- QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
- QObject::connect(receiver, member, &loop, SLOT(quit()));
- timer.start(timeout);
- loop.exec();
- return timer.isActive();
-}
-
-QDeclarativeDebugTestService::QDeclarativeDebugTestService(const QString &s, float version, QObject *parent)
- : QDeclarativeDebugService(s, version, parent)
-{
- registerService();
-}
-
-void QDeclarativeDebugTestService::messageReceived(const QByteArray &ba)
-{
- sendMessage(ba);
-}
-
-void QDeclarativeDebugTestService::stateChanged(State)
-{
- emit stateHasChanged();
-}
-
-
-QDeclarativeDebugTestClient::QDeclarativeDebugTestClient(const QString &s, QDeclarativeDebugConnection *c)
- : QDeclarativeDebugClient(s, c)
-{
-}
-
-QByteArray QDeclarativeDebugTestClient::waitForResponse()
-{
- lastMsg.clear();
- QDeclarativeDebugTest::waitForSignal(this, SIGNAL(serverMessage(QByteArray)));
- if (lastMsg.isEmpty()) {
- qWarning() << "tst_QDeclarativeDebugClient: no response from server!";
- return QByteArray();
- }
- return lastMsg;
-}
-
-void QDeclarativeDebugTestClient::stateChanged(State stat)
-{
- QCOMPARE(stat, state());
- emit stateHasChanged();
-}
-
-void QDeclarativeDebugTestClient::messageReceived(const QByteArray &ba)
-{
- lastMsg = ba;
- emit serverMessage(ba);
-}
-
-QDeclarativeDebugProcess::QDeclarativeDebugProcess(const QString &executable)
- : m_executable(executable)
- , m_started(false)
-{
- m_process.setProcessChannelMode(QProcess::MergedChannels);
- m_timer.setSingleShot(true);
- m_timer.setInterval(5000);
- connect(&m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(processAppOutput()));
- connect(&m_timer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit()));
-}
-
-QDeclarativeDebugProcess::~QDeclarativeDebugProcess()
-{
- stop();
-}
-
-void QDeclarativeDebugProcess::start(const QStringList &arguments)
-{
- m_mutex.lock();
- m_process.setEnvironment(m_environment);
- m_process.start(m_executable, arguments);
- m_process.waitForStarted();
- m_timer.start();
- m_mutex.unlock();
-}
-
-void QDeclarativeDebugProcess::stop()
-{
- if (m_process.state() != QProcess::NotRunning) {
- m_process.kill();
- m_process.waitForFinished(5000);
- }
-}
-
-bool QDeclarativeDebugProcess::waitForSessionStart()
-{
- if (m_process.state() != QProcess::Running) {
- qWarning() << "Could not start up " << m_executable;
- return false;
- }
- m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
-
- return m_started;
-}
-
-void QDeclarativeDebugProcess::setEnvironment(const QStringList &environment)
-{
- m_environment = environment;
-}
-
-QString QDeclarativeDebugProcess::output() const
-{
- return m_output;
-}
-
-void QDeclarativeDebugProcess::processAppOutput()
-{
- m_mutex.lock();
-
- QString newOutput = m_process.readAll();
- m_output.append(newOutput);
- m_outputBuffer.append(newOutput);
-
- while (true) {
- const int nlIndex = m_outputBuffer.indexOf(QLatin1Char('\n'));
- if (nlIndex < 0) // no further complete lines
- break;
- const QString line = m_outputBuffer.left(nlIndex);
- m_outputBuffer = m_outputBuffer.right(m_outputBuffer.size() - nlIndex - 1);
-
- if (line.startsWith("Qml debugging is enabled")) // ignore
- continue;
- if (line.startsWith("QDeclarativeDebugServer:")) {
- if (line.contains("Waiting for connection ")) {
- m_started = true;
- m_eventLoop.quit();
- continue;
- }
- if (line.contains("Connection established")) {
- continue;
- }
- }
- }
- m_mutex.unlock();
-}
diff --git a/tests/auto/declarative/debugger/shared/debugutil_p.h b/tests/auto/declarative/debugger/shared/debugutil_p.h
deleted file mode 100644
index 520cb11a5a..0000000000
--- a/tests/auto/declarative/debugger/shared/debugutil_p.h
+++ /dev/null
@@ -1,127 +0,0 @@
-
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef DEBUGUTIL_H
-#define DEBUGUTIL_H
-
-#include <QEventLoop>
-#include <QTimer>
-#include <QThread>
-#include <QTest>
-#include <QProcess>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-
-#include <private/qdeclarativedebugclient_p.h>
-#include <private/qdeclarativedebugservice_p.h>
-
-class QDeclarativeDebugTest
-{
-public:
- static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000);
-};
-
-class QDeclarativeDebugTestService : public QDeclarativeDebugService
-{
- Q_OBJECT
-public:
- QDeclarativeDebugTestService(const QString &s, float version = 1, QObject *parent = 0);
-
-signals:
- void stateHasChanged();
-
-protected:
- virtual void messageReceived(const QByteArray &ba);
- virtual void stateChanged(State state);
-};
-
-class QDeclarativeDebugTestClient : public QDeclarativeDebugClient
-{
- Q_OBJECT
-public:
- QDeclarativeDebugTestClient(const QString &s, QDeclarativeDebugConnection *c);
-
- QByteArray waitForResponse();
-
-signals:
- void stateHasChanged();
- void serverMessage(const QByteArray &);
-
-protected:
- virtual void stateChanged(State state);
- virtual void messageReceived(const QByteArray &ba);
-
-private:
- QByteArray lastMsg;
-};
-
-class QDeclarativeDebugProcess : public QObject
-{
- Q_OBJECT
-public:
- QDeclarativeDebugProcess(const QString &executable);
- ~QDeclarativeDebugProcess();
-
- void setEnvironment(const QStringList &environment);
-
- void start(const QStringList &arguments);
- bool waitForSessionStart();
-
- QString output() const;
- void stop();
-
-private slots:
- void processAppOutput();
-
-private:
- QString m_executable;
- QProcess m_process;
- QString m_outputBuffer;
- QString m_output;
- QTimer m_timer;
- QEventLoop m_eventLoop;
- QMutex m_mutex;
- bool m_started;
- QStringList m_environment;
-};
-
-#endif // DEBUGUTIL_H
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
deleted file mode 100644
index 7288da27ba..0000000000
--- a/tests/auto/declarative/declarative.pro
+++ /dev/null
@@ -1,55 +0,0 @@
-TEMPLATE = subdirs
-
-METATYPETESTS += \
- qdeclarativemetatype
-
-PUBLICTESTS += \
- parserstress \
- qdeclarativecomponent \
- qdeclarativeconsole \
- qdeclarativecontext \
- qdeclarativeengine \
- qdeclarativeerror \
- qdeclarativefolderlistmodel \
- qdeclarativeincubator \
- qdeclarativeinfo \
- qdeclarativelistreference \
- qdeclarativelocale \
- qdeclarativemoduleplugin \
- qdeclarativeqt \
- qdeclarativetranslation \
- qdeclarativexmlhttprequest \
- qdeclarativeparser \
- qjsengine \
- qjsvalue \
- qjsvalueiterator \
- qmlmin \
- qmlplugindump
-
-PRIVATETESTS += \
- animation \
- qdeclarativebinding \
- qdeclarativechangeset \
- qdeclarativeconnection \
- qdeclarativecpputils \
- qdeclarativeecmascript \
- qdeclarativeexpression \
- qdeclarativeimageprovider \
- qdeclarativeinstruction \
- qdeclarativelanguage \
- qdeclarativelistcompositor \
- qdeclarativelistmodel \
- qdeclarativeproperty \
- qdeclarativepropertymap \
- qdeclarativesqldatabase \
- qdeclarativevaluetypes \
- qdeclarativeworkerscript \
- v4
-
-SUBDIRS += $$PUBLICTESTS
-SUBDIRS += $$METATYPETESTS
-SUBDIRS += debugger
-
-contains(QT_CONFIG, private_tests) {
- SUBDIRS += $$PRIVATETESTS
-}
diff --git a/tests/auto/declarative/parserstress/parserstress.pro b/tests/auto/declarative/parserstress/parserstress.pro
deleted file mode 100644
index 021b1de9cc..0000000000
--- a/tests/auto/declarative/parserstress/parserstress.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-CONFIG += testcase
-TARGET = tst_parserstress
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_parserstress.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-DEFINES += TESTDATADIR=\\\"$$PWD/tests\\\"
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private testlib
diff --git a/tests/auto/declarative/parserstress/tst_parserstress.cpp b/tests/auto/declarative/parserstress/tst_parserstress.cpp
deleted file mode 100644
index 25ecef15f6..0000000000
--- a/tests/auto/declarative/parserstress/tst_parserstress.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QDebug>
-#include <QDir>
-#include <QFile>
-
-class tst_parserstress : public QObject
-{
- Q_OBJECT
-public:
- tst_parserstress() {}
-
-private slots:
- void ecmascript_data();
- void ecmascript();
-
-private:
- static QStringList findJSFiles(const QDir &);
- QDeclarativeEngine engine;
-};
-
-QStringList tst_parserstress::findJSFiles(const QDir &d)
-{
- QStringList rv;
-
- QStringList files = d.entryList(QStringList() << QLatin1String("*.js"),
- QDir::Files);
- foreach (const QString &file, files) {
- if (file == "browser.js")
- continue;
- rv << d.absoluteFilePath(file);
- }
-
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
- QDir::NoSymLinks);
- foreach (const QString &dir, dirs) {
- QDir sub = d;
- sub.cd(dir);
- rv << findJSFiles(sub);
- }
-
- return rv;
-}
-
-void tst_parserstress::ecmascript_data()
-{
-#ifdef TESTDATADIR
- QDir dir(TESTDATADIR);
- QStringList files = findJSFiles(dir);
-
- QTest::addColumn<QString>("file");
- foreach (const QString &file, files) {
- QTest::newRow(qPrintable(file)) << file;
- }
-#endif
-}
-
-void tst_parserstress::ecmascript()
-{
- QFETCH(QString, file);
-
- QFile f(file);
- QVERIFY(f.open(QIODevice::ReadOnly));
-
- QByteArray data = f.readAll();
-
- QVERIFY(!data.isEmpty());
-
- QString dataStr = QString::fromUtf8(data);
-
- QString qml = "import QtQuick 2.0\n";
- qml+= "\n";
- qml+= "QtObject {\n";
- qml+= " property int test\n";
- qml+= " test: {\n";
- qml+= dataStr + "\n";
- qml+= " return 1;\n";
- qml+= " }\n";
- qml+= " function stress() {\n";
- qml+= dataStr;
- qml+= " }\n";
- qml+= "}\n";
-
- QByteArray qmlData = qml.toUtf8();
-
- QDeclarativeComponent component(&engine);
-
- component.setData(qmlData, QUrl::fromLocalFile(SRCDIR + QString("/dummy.qml")));
-
- QFileInfo info(file);
-
- if (info.fileName() == QLatin1String("regress-352044-02-n.js")) {
- QVERIFY(component.isError());
-
- QCOMPARE(component.errors().length(), 2);
-
- QCOMPARE(component.errors().at(0).description(), QString("Expected token `;'"));
- QCOMPARE(component.errors().at(0).line(), 66);
-
- QCOMPARE(component.errors().at(1).description(), QString("Expected token `;'"));
- QCOMPARE(component.errors().at(1).line(), 142);
-
- } else {
-
- QVERIFY(!component.isError());
- }
-}
-
-
-QTEST_MAIN(tst_parserstress)
-
-#include "tst_parserstress.moc"
diff --git a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro
deleted file mode 100644
index 6098d03509..0000000000
--- a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativebinding
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativebinding.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp b/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp
deleted file mode 100644
index 7dc861c02b..0000000000
--- a/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qdeclarativebind_p.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativebinding : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativebinding();
-
-private slots:
- void binding();
- void whenAfterValue();
- void restoreBinding();
- void restoreBindingWithLoop();
- void deletedObject();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativebinding::tst_qdeclarativebinding()
-{
-}
-
-void tst_qdeclarativebinding::binding()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("test-binding.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QDeclarativeBind *binding3 = qobject_cast<QDeclarativeBind*>(rect->findChild<QDeclarativeBind*>("binding3"));
- QVERIFY(binding3 != 0);
-
- QCOMPARE(rect->color(), QColor("yellow"));
- QCOMPARE(rect->property("text").toString(), QString("Hello"));
- QCOMPARE(binding3->when(), false);
-
- rect->setProperty("changeColor", true);
- QCOMPARE(rect->color(), QColor("red"));
-
- QCOMPARE(binding3->when(), true);
-
- QDeclarativeBind *binding = qobject_cast<QDeclarativeBind*>(rect->findChild<QDeclarativeBind*>("binding1"));
- QVERIFY(binding != 0);
- QCOMPARE(binding->object(), qobject_cast<QObject*>(rect));
- QCOMPARE(binding->property(), QLatin1String("text"));
- QCOMPARE(binding->value().toString(), QLatin1String("Hello"));
-
- delete rect;
-}
-
-void tst_qdeclarativebinding::whenAfterValue()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("test-binding2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
-
- QVERIFY(rect != 0);
- QCOMPARE(rect->color(), QColor("yellow"));
- QCOMPARE(rect->property("text").toString(), QString("Hello"));
-
- rect->setProperty("changeColor", true);
- QCOMPARE(rect->color(), QColor("red"));
-
- delete rect;
-}
-
-void tst_qdeclarativebinding::restoreBinding()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("restoreBinding.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *myItem = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("myItem"));
- QVERIFY(myItem != 0);
-
- myItem->setY(25);
- QCOMPARE(myItem->x(), qreal(100-25));
-
- myItem->setY(13);
- QCOMPARE(myItem->x(), qreal(100-13));
-
- //Binding takes effect
- myItem->setY(51);
- QCOMPARE(myItem->x(), qreal(51));
-
- myItem->setY(88);
- QCOMPARE(myItem->x(), qreal(88));
-
- //original binding restored
- myItem->setY(49);
- QCOMPARE(myItem->x(), qreal(100-49));
-
- delete rect;
-}
-
-void tst_qdeclarativebinding::restoreBindingWithLoop()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("restoreBindingWithLoop.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *myItem = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("myItem"));
- QVERIFY(myItem != 0);
-
- myItem->setY(25);
- QCOMPARE(myItem->x(), qreal(25 + 100));
-
- myItem->setY(13);
- QCOMPARE(myItem->x(), qreal(13 + 100));
-
- //Binding takes effect
- rect->setProperty("activateBinding", true);
- myItem->setY(51);
- QCOMPARE(myItem->x(), qreal(51));
-
- myItem->setY(88);
- QCOMPARE(myItem->x(), qreal(88));
-
- //original binding restored
- QString warning = c.url().toString() + QLatin1String(":9:5: QML Rectangle: Binding loop detected for property \"x\"");
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- rect->setProperty("activateBinding", false);
- QCOMPARE(myItem->x(), qreal(88 + 100)); //if loop handling changes this could be 90 + 100
-
- myItem->setY(49);
- QCOMPARE(myItem->x(), qreal(49 + 100));
-
- delete rect;
-}
-
-//QTBUG-20692
-void tst_qdeclarativebinding::deletedObject()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("deletedObject.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QGuiApplication::sendPostedEvents(0, QEvent::DeferredDelete);
-
- //don't crash
- rect->setProperty("activateBinding", true);
-
- delete rect;
-}
-
-QTEST_MAIN(tst_qdeclarativebinding)
-
-#include "tst_qdeclarativebinding.moc"
diff --git a/tests/auto/declarative/qdeclarativechangeset/qdeclarativechangeset.pro b/tests/auto/declarative/qdeclarativechangeset/qdeclarativechangeset.pro
deleted file mode 100644
index 7c52ef5dfd..0000000000
--- a/tests/auto/declarative/qdeclarativechangeset/qdeclarativechangeset.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativechangeset
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativechangeset.cpp
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp b/tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp
deleted file mode 100644
index 254996e4db..0000000000
--- a/tests/auto/declarative/qdeclarativechangeset/tst_qdeclarativechangeset.cpp
+++ /dev/null
@@ -1,812 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <private/qdeclarativechangeset_p.h>
-
-#define VERIFY_EXPECTED_OUTPUT
-
-class tst_qdeclarativemodelchange : public QObject
-{
- Q_OBJECT
-public:
- struct Signal
- {
- int index;
- int count;
- int to;
- int moveId;
-
- bool isInsert() const { return to == -1; }
- bool isRemove() const { return to == -2; }
- bool isMove() const { return to >= 0; }
- bool isChange() const { return to == -3; }
- };
-
- static Signal Insert(int index, int count, int moveId = -1) { Signal signal = { index, count, -1, moveId }; return signal; }
- static Signal Remove(int index, int count, int moveId = -1) { Signal signal = { index, count, -2, moveId }; return signal; }
- static Signal Move(int from, int to, int count) { Signal signal = { from, count, to, -1 }; return signal; }
- static Signal Change(int index, int count) { Signal signal = { index, count, -3, -1 }; return signal; }
-
- typedef QVector<Signal> SignalList;
-
-
-#ifdef VERIFY_EXPECTED_OUTPUT
-
- template<typename T>
- void move(int from, int to, int n, T *items)
- {
- if (from > to) {
- // Only move forwards - flip if backwards moving
- int tfrom = from;
- int tto = to;
- from = tto;
- to = tto+n;
- n = tfrom-tto;
- }
-
- T replaced;
- int i=0;
- typename T::ConstIterator it=items->begin(); it += from+n;
- for (; i<to-from; ++i,++it)
- replaced.append(*it);
- i=0;
- it=items->begin(); it += from;
- for (; i<n; ++i,++it)
- replaced.append(*it);
- typename T::ConstIterator f=replaced.begin();
- typename T::Iterator t=items->begin(); t += from;
- for (; f != replaced.end(); ++f, ++t)
- *t = *f;
- }
-
- QVector<int> applyChanges(const QVector<int> &list, const QVector<Signal> &changes)
- {
- QHash<int, QVector<int> > removedValues;
- QVector<int> alteredList = list;
- foreach (const Signal &signal, changes) {
- if (signal.isInsert()) {
- if (signal.moveId != -1) {
- QVector<int> tail = alteredList.mid(signal.index);
- alteredList = alteredList.mid(0, signal.index) + removedValues.take(signal.moveId) + tail;
- } else {
- alteredList.insert(signal.index, signal.count, 100);
- }
- } else if (signal.isRemove()) {
- if (signal.moveId != -1)
- removedValues.insert(signal.moveId, alteredList.mid(signal.index, signal.count));
- alteredList.erase(alteredList.begin() + signal.index, alteredList.begin() + signal.index + signal.count);
- } else if (signal.isMove()) {
- move(signal.index, signal.to, signal.count, &alteredList);
- } else if (signal.isChange()) {
- for (int i = signal.index; i < signal.index + signal.count; ++i) {
- if (alteredList[i] < 100)
- alteredList[i] = 100;
- }
- }
- }
- return alteredList;
- }
-
-#endif
-
-private slots:
- void sequence_data();
- void sequence();
-};
-
-bool operator ==(const tst_qdeclarativemodelchange::Signal &left, const tst_qdeclarativemodelchange::Signal &right)
-{
- return left.index == right.index
- && left.count == right.count
- && left.to == right.to
- && ((left.moveId == -1 && right.moveId == -1) || (left.moveId != -1 && right.moveId != -1));
-}
-
-
-QDebug operator <<(QDebug debug, const tst_qdeclarativemodelchange::Signal &signal)
-{
- if (signal.isInsert())
- debug.nospace() << "Insert(" << signal.index << "," << signal.count << "," << signal.moveId << ")";
- else if (signal.isRemove())
- debug.nospace() << "Remove(" << signal.index << "," << signal.count << "," << signal.moveId << ")";
- else if (signal.isMove())
- debug.nospace() << "Move(" << signal.index << "," << signal.to << "," << signal.count << ")";
- else if (signal.isChange())
- debug.nospace() << "Change(" << signal.index << "," << signal.count << ")";
- return debug;
-}
-
-Q_DECLARE_METATYPE(tst_qdeclarativemodelchange::SignalList)
-
-void tst_qdeclarativemodelchange::sequence_data()
-{
- QTest::addColumn<SignalList>("input");
- QTest::addColumn<SignalList>("output");
-
- // Insert
- QTest::newRow("i(12,5)")
- << (SignalList() << Insert(12,5))
- << (SignalList() << Insert(12,5));
- QTest::newRow("i(2,3),i(12,5)")
- << (SignalList() << Insert(2,3) << Insert(12,5))
- << (SignalList() << Insert(2,3) << Insert(12,5));
- QTest::newRow("i(12,5),i(2,3)")
- << (SignalList() << Insert(12,5) << Insert(2,3))
- << (SignalList() << Insert(2,3) << Insert(15,5));
- QTest::newRow("i(12,5),i(12,3)")
- << (SignalList() << Insert(12,5) << Insert(12,3))
- << (SignalList() << Insert(12,8));
- QTest::newRow("i(12,5),i(17,3)")
- << (SignalList() << Insert(12,5) << Insert(17,3))
- << (SignalList() << Insert(12,8));
- QTest::newRow("i(12,5),i(15,3)")
- << (SignalList() << Insert(12,5) << Insert(15,3))
- << (SignalList() << Insert(12,8));
-
- // Remove
- QTest::newRow("r(3,9)")
- << (SignalList() << Remove(3,9))
- << (SignalList() << Remove(3,9));
- QTest::newRow("r(3,4),r(3,2)")
- << (SignalList() << Remove(3,4) << Remove(3,2))
- << (SignalList() << Remove(3,6));
- QTest::newRow("r(4,3),r(14,5)")
- << (SignalList() << Remove(4,3) << Remove(14,5))
- << (SignalList() << Remove(4,3) << Remove(14,5));
- QTest::newRow("r(14,5),r(4,3)")
- << (SignalList() << Remove(14,5) << Remove(4,3))
- << (SignalList() << Remove(4,3) << Remove(11,5));
- QTest::newRow("r(4,3),r(2,9)")
- << (SignalList() << Remove(4,3) << Remove(2,9))
- << (SignalList() << Remove(2,12));
-
- // Move
- QTest::newRow("m(8-10,2)")
- << (SignalList() << Move(8,10,2))
- << (SignalList() << Remove(8,2,1) << Insert(10,2,1));
-
- QTest::newRow("m(23-12,6),m(13-15,5)")
- << (SignalList() << Move(23,12,6) << Move(13,15,5))
- << (SignalList() << Remove(23,1,0) << Remove(23,5,1) << Insert(12,1,0) << Insert(15,5,1));
- QTest::newRow("m(23-12,6),m(13-15,2)")
- << (SignalList() << Move(23,12,6) << Move(13,20,2))
- << (SignalList() << Remove(23,1,0) << Remove(23,2,1) << Remove(23,3,2) << Insert(12,1,0) << Insert(13,3,2) << Insert(20,2,1));
- QTest::newRow("m(23-12,6),m(13-2,2)")
- << (SignalList() << Move(23,12,6) << Move(13,2,2))
- << (SignalList() << Remove(23,1,0) << Remove(23,2,1) << Remove(23,3,2) << Insert(2,2,1) << Insert(14,1,0) << Insert(15,3,2));
- QTest::newRow("m(23-12,6),m(12-6,5)")
- << (SignalList() << Move(23,12,6) << Move(12,6,5))
- << (SignalList() << Remove(23,5,0) << Remove(23,1,1) << Insert(6,5,0) << Insert(17,1,1));
- QTest::newRow("m(23-12,6),m(10-5,4)")
- << (SignalList() << Move(23,12,6) << Move(10,5,4))
- << (SignalList() << Remove(10,2,0) << Remove(21,2,1) << Remove(21,4,2) << Insert(5,2,0) << Insert(7,2,1) << Insert(14,4,2));
- QTest::newRow("m(23-12,6),m(16-5,4)")
- << (SignalList() << Move(23,12,6) << Move(16,5,4))
- << (SignalList() << Remove(12,2,0) << Remove(21,4,1) << Remove(21,2,2) << Insert(5,2,2) << Insert(7,2,0) << Insert(16,4,1));
- QTest::newRow("m(23-12,6),m(13-5,4)")
- << (SignalList() << Move(23,12,6) << Move(13,5,4))
- << (SignalList() << Remove(23,1,0) << Remove(23,4,1) << Remove(23,1,2) << Insert(5,4,1) << Insert(16,1,0) << Insert(17,1,2));
- QTest::newRow("m(23-12,6),m(14-5,4)")
- << (SignalList() << Move(23,12,6) << Move(14,5,4))
- << (SignalList() << Remove(23,2,0) << Remove(23,4,1) << Insert(5,4,1) << Insert(16,2,0));
- QTest::newRow("m(23-12,6),m(12-5,4)")
- << (SignalList() << Move(23,12,6) << Move(12,5,4))
- << (SignalList() << Remove(23,4,0) << Remove(23,2,1) << Insert(5,4,0) << Insert(16,2,1));
- QTest::newRow("m(23-12,6),m(11-5,8)")
- << (SignalList() << Move(23,12,6) << Move(11,5,8))
- << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Remove(21,6,2) << Insert(5,1,0) << Insert(6,6,2) << Insert(12,1,1));
- QTest::newRow("m(23-12,6),m(8-5,4)")
- << (SignalList() << Move(23,12,6) << Move(8,5,4))
- << (SignalList() << Remove(8,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(12,6,1));
- QTest::newRow("m(23-12,6),m(2-5,4)")
- << (SignalList() << Move(23,12,6) << Move(2,5,4))
- << (SignalList() << Remove(2,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(12,6,1));
- QTest::newRow("m(23-12,6),m(18-5,4)")
- << (SignalList() << Move(23,12,6) << Move(18,5,4))
- << (SignalList() << Remove(12,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(16,6,1));
- QTest::newRow("m(23-12,6),m(20-5,4)")
- << (SignalList() << Move(23,12,6) << Move(20,5,4))
- << (SignalList() << Remove(14,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(16,6,1));
-
- QTest::newRow("m(23-12,6),m(5-13,11)")
- << (SignalList() << Move(23,12,6) << Move(5,13,11))
- << (SignalList() << Remove(5,7,0) << Remove(16,4,1) << Remove(16,2,2) << Insert(5,2,2) << Insert(13,7,0) << Insert(20,4,1));
-
- QTest::newRow("m(23-12,6),m(12-23,6)")
- << (SignalList() << Move(23,12,6) << Move(12,23,6))
- << (SignalList() << Remove(23,6,0) << Insert(23,6,0)); // ### These cancel out.
- QTest::newRow("m(23-12,6),m(10-23,4)")
- << (SignalList() << Move(23,12,6) << Move(10,23,4))
- << (SignalList() << Remove(10,2 ,0) << Remove(21,2,1) << Remove(21,4,2) << Insert(10,4,2) << Insert(23,2,0) << Insert(25,2,1));
- QTest::newRow("m(23-12,6),m(16-23.4)")
- << (SignalList() << Move(23,12,6) << Move(16,23,4))
- << (SignalList() << Remove(12,2,0) << Remove(21,4,1) << Remove(21,2,2) << Insert(12,4,1) << Insert(23,2,2) << Insert(25,2,0));
- QTest::newRow("m(23-12,6),m(13-23,4)")
- << (SignalList() << Move(23,12,6) << Move(13,23,4))
- << (SignalList() << Remove(23,1,0) << Remove(23,4,1) << Remove(23,1,2) << Insert(12,1,0) << Insert(13,1,2) << Insert(23,4,1));
- QTest::newRow("m(23-12,6),m(14-23,)")
- << (SignalList() << Move(23,12,6) << Move(14,23,4))
- << (SignalList() << Remove(23,2,0) << Remove(23,4,1) << Insert(12,2,0) << Insert(23,4,1));
- QTest::newRow("m(23-12,6),m(12-23,4)")
- << (SignalList() << Move(23,12,6) << Move(12,23,4))
- << (SignalList() << Remove(23,4,0) << Remove(23,2,1) << Insert(12,2,1) << Insert(23,4,0));
- QTest::newRow("m(23-12,6),m(11-23,8)")
- << (SignalList() << Move(23,12,6) << Move(11,23,8))
- << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Remove(21,6,2) << Insert(23,1,0) << Insert(24,6,2) << Insert(30,1,1));
- QTest::newRow("m(23-12,6),m(8-23,4)")
- << (SignalList() << Move(23,12,6) << Move(8,23,4))
- << (SignalList() << Remove(8,4,0) << Remove(19,6,1) << Insert(8,6,1) << Insert(23,4,0));
- QTest::newRow("m(23-12,6),m(2-23,4)")
- << (SignalList() << Move(23,12,6) << Move(2,23,4))
- << (SignalList() << Remove(2,4,0) << Remove(19,6,1) << Insert(8,6,1) << Insert(23,4,0));
- QTest::newRow("m(23-12,6),m(18-23,4)")
- << (SignalList() << Move(23,12,6) << Move(18,23,4))
- << (SignalList() << Remove(12,4,0) << Remove(19,6,1) << Insert(12,6,1) << Insert(23,4,0));
- QTest::newRow("m(23-12,6),m(20-23,4)")
- << (SignalList() << Move(23,12,6) << Move(20,23,4))
- << (SignalList() << Remove(14,4,1) << Remove(19,6,0) << Insert(12,6,0) << Insert(23,4,1));
-
- QTest::newRow("m(23-12,6),m(11-23,10)")
- << (SignalList() << Move(23,12,6) << Move(11,23,10))
- << (SignalList() << Remove(11,1,3) << Remove(11,3,1) << Remove(19,6,2) << Insert(23,1,3) << Insert(24,6,2) << Insert(30,3,1));
-
- QTest::newRow("m(3-9,12),m(13-5,12)")
- << (SignalList() << Move(3,9,12) << Move(13,15,5))
- << (SignalList() << Remove(3,4,2) << Remove(3,5,1) << Remove(3,2,0) << Remove(3,1,3) << Insert(9,4,2) << Insert(13,2,0) << Insert(15,5,1) << Insert(20,1,3));
- QTest::newRow("m(3-9,12),m(13-15,20)")
- << (SignalList() << Move(3,9,12) << Move(13,15,20))
- << (SignalList() << Remove(3,4,0) << Remove(3,8,1) << Remove(9,12,2) << Insert(9,4,0) << Insert(15,8,1) << Insert(23,12,2));
- QTest::newRow("m(3-9,12),m(13-15,2)")
- << (SignalList() << Move(3,9,12) << Move(13,15,2))
- << (SignalList() << Remove(3,4,2) << Remove(3,2,1) << Remove(3,2,0) << Remove(3,4,3) << Insert(9,4,2) << Insert(13,2,0) << Insert(15,2,1) << Insert(17,4,3));
- QTest::newRow("m(3-9,12),m(12-5,6)")
- << (SignalList() << Move(3,9,12) << Move(12,5,6))
- << (SignalList() << Remove(3,3,0) << Remove(3,6,1) << Remove(3,3,2) << Insert(5,6,1) << Insert(15,3,0) << Insert(18,3,2));
- QTest::newRow("m(3-9,12),m(10-14,5)")
- << (SignalList() << Move(3,9,12) << Move(10,14,5))
- << (SignalList() << Remove(3,1,2) << Remove(3,5,1) << Remove(3,4,0) << Remove(3,2,3) << Insert(9,1,2) << Insert(10,4,0) << Insert(14,5,1) << Insert(19,2,3));
- QTest::newRow("m(3-9,12),m(16-20,5)")
- << (SignalList() << Move(3,9,12) << Move(16,20,5))
- << (SignalList() << Remove(3,7,0) << Remove(3,5,1) << Insert(9,7,0) << Insert(20,5,1));
- QTest::newRow("m(3-9,12),m(13-17,5)")
- << (SignalList() << Move(3,9,12) << Move(13,17,5))
- << (SignalList() << Remove(3,4,0) << Remove(3,5,1) << Remove(3,3,2) << Insert(9,4,0) << Insert(13,3,2) << Insert(17,5,1));
- QTest::newRow("m(3-9,12),m(14-18,5)")
- << (SignalList() << Move(3,9,12) << Move(14,18,5))
- << (SignalList() << Remove(3,5,0) << Remove(3,5,1) << Remove(3,2,2) << Insert(9,5,0) << Insert(14,2,2) << Insert(18,5,1));
- QTest::newRow("m(3-9,12),m(12-16,5)")
- << (SignalList() << Move(3,9,12) << Move(12,16,5))
- << (SignalList() << Remove(3,3,2) << Remove(3,5,1) << Remove(3,4,0) << Insert(9,3,2) << Insert(12,4,0) << Insert(16,5,1));
- QTest::newRow("m(3-9,12),m(11-19,5)")
- << (SignalList() << Move(3,9,12) << Move(11,19,5))
- << (SignalList() << Remove(3,2,0) << Remove(3,5,1) << Remove(3,5,2) << Insert(9,2,0) << Insert(11,5,2) << Insert(19,5,1));
- QTest::newRow("m(3-9,12),m(8-12,5)")
- << (SignalList() << Move(3,9,12) << Move(8,12,5))
- << (SignalList() << Remove(3,4,1) << Remove(3,4,0) << Remove(3,4,4) << Remove(8,1,2) << Insert(8,4,0) << Insert(12,1,2) << Insert(13,4,1) << Insert(17,4,4));
- QTest::newRow("m(3-9,12),m(2-6,5)")
- << (SignalList() << Move(3,9,12) << Move(2,6,5))
- << (SignalList() << Remove(2,1,2) << Remove(2,2,0) << Remove(2,10,3) << Remove(2,4,1) << Insert(4,2,0) << Insert(6,1,2) << Insert(7,4,1) << Insert(11,10,3));
- QTest::newRow("m(3-9,12),m(18-22,5)")
- << (SignalList() << Move(3,9,12) << Move(18,22,5))
- << (SignalList() << Remove(3,9,0) << Remove(3,3,1) << Remove(9,2,2) << Insert(9,9,0) << Insert(22,3,1) << Insert(25,2,2));
- QTest::newRow("m(3-9,12),m(20-24,5)")
- << (SignalList() << Move(3,9,12) << Move(20,24,5))
- << (SignalList() << Remove(3,11,0) << Remove(3,1,1) << Remove(9,4,2) << Insert(9,11,0) << Insert(24,1,1) << Insert(25,4,2));
-
- QTest::newRow("m(3-9,12),m(5-11,8)")
- << (SignalList() << Move(3,9,12) << Move(5,11,8))
- << (SignalList() << Remove(3,4,1) << Remove(3,6,0) << Remove(3,2,3) << Remove(5,4,2) << Insert(5,6,0) << Insert(11,4,2) << Insert(15,2,3) << Insert(15,4,1));
-
- QTest::newRow("m(3-9,12),m(12-23,6)")
- << (SignalList() << Move(3,9,12) << Move(12,23,6))
- << (SignalList() << Remove(3,3,2) << Remove(3,6,1) << Remove(3,3,0) << Insert(9,3,2) << Insert(12,3,0) << Insert(23,6,1));
- QTest::newRow("m(3-9,12),m(10-23,4)")
- << (SignalList() << Move(3,9,12) << Move(10,23,4))
- << (SignalList() << Remove(3,1,2) << Remove(3,4,1) << Remove(3,7,0) << Insert(9,1,2) << Insert(10,7,0) << Insert(23,4,1));
- QTest::newRow("m(3-9,12),m(16-23,4)")
- << (SignalList() << Move(3,9,12) << Move(16,23,4))
- << (SignalList() << Remove(3,7,2) << Remove(3,4,1) << Remove(3,1,0) << Insert(9,7,2) << Insert(16,1,0) << Insert(23,4,1));
- QTest::newRow("m(3-9,12),m(13-23,4)")
- << (SignalList() << Move(3,9,12) << Move(13,23,4))
- << (SignalList() << Remove(3,4,2) << Remove(3,4,1) << Remove(3,4,0) << Insert(9,4,2) << Insert(13,4,0) << Insert(23,4,1));
- QTest::newRow("m(3-9,12),m(14-23,4)")
- << (SignalList() << Move(3,9,12) << Move(14,23,4))
- << (SignalList() << Remove(3,5,2) << Remove(3,4,1) << Remove(3,3,0) << Insert(9,5,2) << Insert(14,3,0) << Insert(23,4,1));
- QTest::newRow("m(3-9,12),m(12-23,4)")
- << (SignalList() << Move(3,9,12) << Move(12,23,4))
- << (SignalList() << Remove(3,3,2) << Remove(3,4,1) << Remove(3,5,0) << Insert(9,3,2) << Insert(12,5,0) << Insert(23,4,1));
- QTest::newRow("m(3-9,12),m(11-23,8)")
- << (SignalList() << Move(3,9,12) << Move(11,23,8))
- << (SignalList() << Remove(3,2,2) << Remove(3,8,1) << Remove(3,2,0) << Insert(9,2,2) << Insert(11,2,0) << Insert(23,8,1));
- QTest::newRow("m(3-9,12),m(8-23,4)")
- << (SignalList() << Move(3,9,12) << Move(8,23,4))
- << (SignalList() << Remove(3,3,1) << Remove(3,9,0) << Remove(8,1,2) << Insert(8,9,0) << Insert(23,1,2) << Insert(24,3,1));
- QTest::newRow("m(3-9,12),m(2-23,4)")
- << (SignalList() << Move(3,9,12) << Move(2,23,4))
- << (SignalList() << Remove(2,1,2) << Remove(2,12,0) << Remove(2,3,1) << Insert(5,12,0) << Insert(23,1,2) << Insert(24,3,1));
- QTest::newRow("m(3-9,12),m(18-23,4)")
- << (SignalList() << Move(3,9,12) << Move(18,23,4))
- << (SignalList() << Remove(3,9,3) << Remove(3,3,2) << Remove(9,1,1) << Insert(9,9,3) << Insert(23,3,2) << Insert(26,1,1));
- QTest::newRow("m(3-9,12),m(20-23,4)")
- << (SignalList() << Move(3,9,12) << Move(20,23,4))
- << (SignalList() << Remove(3,11,3) << Remove(3,1,2) << Remove(9,3,1) << Insert(9,11,3) << Insert(23,1,2) << Insert(24,3,1));
-
- QTest::newRow("m(3-9,12),m(11-23,10)")
- << (SignalList() << Move(3,9,12) << Move(11,23,10))
- << (SignalList() << Remove(3,2,2) << Remove(3,10,1) << Insert(9,2,2) << Insert(23,10,1));
-
- // Change
- QTest::newRow("c(4,5)")
- << (SignalList() << Change(4,5))
- << (SignalList() << Change(4,5));
- QTest::newRow("c(4,5),c(12,2)")
- << (SignalList() << Change(4,5) << Change(12,2))
- << (SignalList() << Change(4,5) << Change(12,2));
- QTest::newRow("c(12,2),c(4,5)")
- << (SignalList() << Change(12,2) << Change(4,5))
- << (SignalList() << Change(4,5) << Change(12,2));
- QTest::newRow("c(4,5),c(2,2)")
- << (SignalList() << Change(4,5) << Change(2,2))
- << (SignalList() << Change(2,7));
- QTest::newRow("c(4,5),c(9,2)")
- << (SignalList() << Change(4,5) << Change(9,2))
- << (SignalList() << Change(4,7));
- QTest::newRow("c(4,5),c(3,2)")
- << (SignalList() << Change(4,5) << Change(3,2))
- << (SignalList() << Change(3,6));
- QTest::newRow("c(4,5),c(8,2)")
- << (SignalList() << Change(4,5) << Change(8,2))
- << (SignalList() << Change(4,6));
- QTest::newRow("c(4,5),c(3,2)")
- << (SignalList() << Change(4,5) << Change(3,2))
- << (SignalList() << Change(3,6));
- QTest::newRow("c(4,5),c(2,9)")
- << (SignalList() << Change(4,5) << Change(2,9))
- << (SignalList() << Change(2,9));
- QTest::newRow("c(4,5),c(12,3),c(8,6)")
- << (SignalList() << Change(4,5) << Change(12,3) << Change(8,6))
- << (SignalList() << Change(4,11));
-
- // Insert,then remove.
- QTest::newRow("i(12,6),r(12,6)")
- << (SignalList() << Insert(12,6) << Remove(12,6))
- << (SignalList());
- QTest::newRow("i(12,6),r(10,4)")
- << (SignalList() << Insert(12,6) << Remove(10,4))
- << (SignalList() << Remove(10,2) << Insert(10,4));
- QTest::newRow("i(12,6),r(16,4)")
- << (SignalList() << Insert(12,6) << Remove(16,4))
- << (SignalList() << Remove(12,2) << Insert(12,4));
- QTest::newRow("i(12,6),r(13,4)")
- << (SignalList() << Insert(12,6) << Remove(13,4))
- << (SignalList() << Insert(12,2));
- QTest::newRow("i(12,6),r(14,4)")
- << (SignalList() << Insert(12,6) << Remove(14,4))
- << (SignalList() << Insert(12,2));
- QTest::newRow("i(12,6),r(12,4)")
- << (SignalList() << Insert(12,6) << Remove(12,4))
- << (SignalList() << Insert(12,2));
- QTest::newRow("i(12,6),r(11,8)")
- << (SignalList() << Insert(12,6) << Remove(11,8))
- << (SignalList() << Remove(11,2));
- QTest::newRow("i(12,6),r(8,4)")
- << (SignalList() << Insert(12,6) << Remove(8,4))
- << (SignalList() << Remove(8,4) << Insert(8,6));
- QTest::newRow("i(12,6),r(2,4)")
- << (SignalList() << Insert(12,6) << Remove(2,4))
- << (SignalList() << Remove(2,4) << Insert(8,6));
- QTest::newRow("i(12,6),r(18,4)")
- << (SignalList() << Insert(12,6) << Remove(18,4))
- << (SignalList() << Remove(12,4) << Insert(12,6));
- QTest::newRow("i(12,6),r(20,4)")
- << (SignalList() << Insert(12,6) << Remove(20,4))
- << (SignalList() << Remove(14,4) << Insert(12,6));
-
- // Insert,then move
- QTest::newRow("i(12,6),m(12-5,6)")
- << (SignalList() << Insert(12,6) << Move(12,5,6))
- << (SignalList() << Insert(5,6));
- QTest::newRow("i(12,6),m(10-5,4)")
- << (SignalList() << Insert(12,6) << Move(10,5,4))
- << (SignalList() << Remove(10,2,0) << Insert(5,2,0) << Insert(7,2) << Insert(14,4));
- QTest::newRow("i(12,6),m(16-5,4)")
- << (SignalList() << Insert(12,6) << Move(16,5,4))
- << (SignalList() << Remove(12,2,0) << Insert(5,2) << Insert(7,2,0) << Insert(16,4));
- QTest::newRow("i(12,6),m(13-5,4)")
- << (SignalList() << Insert(12,6) << Move(13,5,4))
- << (SignalList() << Insert(5,4) << Insert(16,2));
- QTest::newRow("i(12,6),m(14-5,4)")
- << (SignalList() << Insert(12,6) << Move(14,5,4))
- << (SignalList() << Insert(5,4) << Insert(16,2));
- QTest::newRow("i(12,6),m(12-5,4)")
- << (SignalList() << Insert(12,6) << Move(12,5,4))
- << (SignalList() << Insert(5,4) << Insert(16,2));
- QTest::newRow("i(12,6),m(11-5,8)")
- << (SignalList() << Insert(12,6) << Move(11,5,8))
- << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Insert(5,1,0) << Insert(6,6) << Insert(12,1,1));
- QTest::newRow("i(12,6),m(8-5,4)")
- << (SignalList() << Insert(12,6) << Move(8,5,4))
- << (SignalList() << Remove(8,4,0) << Insert(5,4,0) << Insert(12,6));
- QTest::newRow("i(12,6),m(2-5,4)")
- << (SignalList() << Insert(12,6) << Move(2,5,4))
- << (SignalList() << Remove(2,4,0) << Insert(5,4,0) << Insert(12,6));
- QTest::newRow("i(12,6),m(18-5,4)")
- << (SignalList() << Insert(12,6) << Move(18,5,4))
- << (SignalList() << Remove(12,4,0) << Insert(5,4,0) << Insert(16,6));
- QTest::newRow("i(12,6),m(20-5,4)")
- << (SignalList() << Insert(12,6) << Move(20,5,4))
- << (SignalList() << Remove(14,4,0) << Insert(5,4,0) << Insert(16,6));
-
- QTest::newRow("i(12,6),m(5-13,11)")
- << (SignalList() << Insert(12,6) << Move(5,11,8))
- << (SignalList() << Remove(5,7,0) << Insert(5,5) << Insert(11,7,0) << Insert(18,1));
-
- QTest::newRow("i(12,6),m(12-23,6)")
- << (SignalList() << Insert(12,6) << Move(12,23,6))
- << (SignalList() << Insert(23,6));
- QTest::newRow("i(12,6),m(10-23,4)")
- << (SignalList() << Insert(12,6) << Move(10,23,4))
- << (SignalList() << Remove(10,2,0) << Insert(10,4) << Insert(23,2,0) << Insert(25,2));
- QTest::newRow("i(12,6),m(16-23,4)")
- << (SignalList() << Insert(12,6) << Move(16,23,4))
- << (SignalList() << Remove(12,2,0) << Insert(12,4) << Insert(23,2) << Insert(25,2,0));
- QTest::newRow("i(12,6),m(13-23,4)")
- << (SignalList() << Insert(12,6) << Move(13,23,4))
- << (SignalList() << Insert(12,2) << Insert(23,4));
- QTest::newRow("i(12,6),m(14-23,4)")
- << (SignalList() << Insert(12,6) << Move(14,23,4))
- << (SignalList() << Insert(12,2) << Insert(23,4));
- QTest::newRow("i(12,6),m(12-23,4)")
- << (SignalList() << Insert(12,6) << Move(12,23,4))
- << (SignalList() << Insert(12,2) << Insert(23,4));
- QTest::newRow("i(12,6),m(11-23,8)")
- << (SignalList() << Insert(12,6) << Move(11,23,8))
- << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Insert(23,1,0)<< Insert(24,6) << Insert(30,1,1));
- QTest::newRow("i(12,6),m(8-23,4)")
- << (SignalList() << Insert(12,6) << Move(8,23,4))
- << (SignalList() << Remove(8,4,0) << Insert(8,6) << Insert(23,4,0));
- QTest::newRow("i(12,6),m(2-23,4)")
- << (SignalList() << Insert(12,6) << Move(2,23,4))
- << (SignalList() << Remove(2,4,0) << Insert(8,6) << Insert(23,4,0));
- QTest::newRow("i(12,6),m(18-23,4)")
- << (SignalList() << Insert(12,6) << Move(18,23,4))
- << (SignalList() << Remove(12,4,0) << Insert(12,6) << Insert(23,4,0));
- QTest::newRow("i(12,6),m(20-23,4)")
- << (SignalList() << Insert(12,6) << Move(20,23,4))
- << (SignalList() << Remove(14,4,0) << Insert(12,6) << Insert(23,4,0));
-
- QTest::newRow("i(12,6),m(11-23,10)")
- << (SignalList() << Insert(12,6) << Move(11,23,10))
- << (SignalList() << Remove(11,1,0) << Remove(11,3,1) << Insert(23,1,0) << Insert(24,6) << Insert(30,3,1));
-
- // Insert,then change
- QTest::newRow("i(12,6),c(12,6)")
- << (SignalList() << Insert(12,6) << Change(12,6))
- << (SignalList() << Insert(12,6));
- QTest::newRow("i(12,6),c(10,6)")
- << (SignalList() << Insert(12,6) << Change(10,6))
- << (SignalList() << Insert(12,6) << Change(10,2));
- QTest::newRow("i(12,6),c(16,4)")
- << (SignalList() << Insert(12,6) << Change(16,4))
- << (SignalList() << Insert(12,6) << Change(18,2));
- QTest::newRow("i(12,6),c(13,4)")
- << (SignalList() << Insert(12,6) << Change(13,4))
- << (SignalList() << Insert(12,6));
- QTest::newRow("i(12,6),c(14,4)")
- << (SignalList() << Insert(12,6) << Change(14,4))
- << (SignalList() << Insert(12,6));
- QTest::newRow("i(12,6),c(12,4)")
- << (SignalList() << Insert(12,6) << Change(12,4))
- << (SignalList() << Insert(12,6));
- QTest::newRow("i(12,6),c(11,8)")
- << (SignalList() << Insert(12,6) << Change(11,8))
- << (SignalList() << Insert(12,6) << Change(11,1) << Change(18,1));
- QTest::newRow("i(12,6),c(8,4)")
- << (SignalList() << Insert(12,6) << Change(8,4))
- << (SignalList() << Insert(12,6) << Change(8,4));
- QTest::newRow("i(12,6),c(2,4)")
- << (SignalList() << Insert(12,6) << Change(2,4))
- << (SignalList() << Insert(12,6) << Change(2,4));
- QTest::newRow("i(12,6),c(18,4)")
- << (SignalList() << Insert(12,6) << Change(18,4))
- << (SignalList() << Insert(12,6) << Change(18,4));
- QTest::newRow("i(12,6),c(20,4)")
- << (SignalList() << Insert(12,6) << Change(20,4))
- << (SignalList() << Insert(12,6) << Change(20,4));
-
- // Remove,then insert
- QTest::newRow("r(12,6),i(12,6)")
- << (SignalList() << Remove(12,6) << Insert(12,6))
- << (SignalList() << Remove(12,6) << Insert(12,6));
- QTest::newRow("r(12,6),i(10,4)")
- << (SignalList() << Remove(12,6) << Insert(10,14))
- << (SignalList() << Remove(12,6) << Insert(10,14));
- QTest::newRow("r(12,6),i(16,4)")
- << (SignalList() << Remove(12,6) << Insert(16,4))
- << (SignalList() << Remove(12,6) << Insert(16,4));
- QTest::newRow("r(12,6),i(13,4)")
- << (SignalList() << Remove(12,6) << Insert(13,4))
- << (SignalList() << Remove(12,6) << Insert(13,4));
- QTest::newRow("r(12,6),i(14,4)")
- << (SignalList() << Remove(12,6) << Insert(14,4))
- << (SignalList() << Remove(12,6) << Insert(14,4));
- QTest::newRow("r(12,6),i(12,4)")
- << (SignalList() << Remove(12,6) << Insert(12,4))
- << (SignalList() << Remove(12,6) << Insert(12,4));
- QTest::newRow("r(12,6),i(11,8)")
- << (SignalList() << Remove(12,6) << Insert(11,8))
- << (SignalList() << Remove(12,6) << Insert(11,8));
- QTest::newRow("r(12,6),i(8,4)")
- << (SignalList() << Remove(12,6) << Insert(8,4))
- << (SignalList() << Remove(12,6) << Insert(8,4));
- QTest::newRow("r(12,6),i(2,4)")
- << (SignalList() << Remove(12,6) << Insert(2,4))
- << (SignalList() << Remove(12,6) << Insert(2,4));
- QTest::newRow("r(12,6),i(18,4)")
- << (SignalList() << Remove(12,6) << Insert(18,4))
- << (SignalList() << Remove(12,6) << Insert(18,4));
- QTest::newRow("r(12,6),i(20,4)")
- << (SignalList() << Remove(12,6) << Insert(20,4))
- << (SignalList() << Remove(12,6) << Insert(20,4));
-
- // Move,then insert
- QTest::newRow("m(12-5,6),i(12,6)")
- << (SignalList() << Move(12,5,6) << Insert(12,6))
- << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(12,6));
- QTest::newRow("m(12-5,6),i(10,4)")
- << (SignalList() << Move(12,5,6) << Insert(10,4))
- << (SignalList() << Remove(12,5,0) << Remove(12,1,1) << Insert(5,5,0) << Insert(10,4) << Insert(14,1,1));
- QTest::newRow("m(12-5,6),i(16,4)")
- << (SignalList() << Move(12,5,6) << Insert(16,4))
- << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(16,4));
- QTest::newRow("m(12-5,6),i(13,4)")
- << (SignalList() << Move(12,5,6) << Insert(13,4))
- << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(13,4));
- QTest::newRow("m(12-5,6),i(14,4)")
- << (SignalList() << Move(12,5,6) << Insert(14,4))
- << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(14,4));
- QTest::newRow("m(12-5,6),i(12,4)")
- << (SignalList() << Move(12,5,6) << Insert(12,4))
- << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(12,4));
- QTest::newRow("m(12-5,6),i(11,8)")
- << (SignalList() << Move(12,5,6) << Insert(11,8))
- << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(11,8));
- QTest::newRow("m(12-5,6),i(8,4)")
- << (SignalList() << Move(12,5,6) << Insert(8,4))
- << (SignalList() << Remove(12,3,0) << Remove(12,3,1) << Insert(5,3,0) << Insert(8,4) << Insert(12,3,1));
- QTest::newRow("m(12-5,6),i(2,4)")
- << (SignalList() << Move(12,5,6) << Insert(2,4))
- << (SignalList() << Remove(12,6,0) << Insert(2,4) << Insert(9,6,0));
- QTest::newRow("m(12-5,6),i(18,4)")
- << (SignalList() << Move(12,5,6) << Insert(18,4))
- << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(18,4));
- QTest::newRow("m(12-5,6),i(20,4)")
- << (SignalList() << Move(12,5,6) << Insert(20,4))
- << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(20,4));
-
- QTest::newRow("m(12-23,6),i(12,6)")
- << (SignalList() << Move(12,23,6) << Insert(12,6))
- << (SignalList() << Remove(12,6,0) << Insert(12,6) << Insert(29,6,0));
- QTest::newRow("m(12-23,6),i(10,4)")
- << (SignalList() << Move(12,23,6) << Insert(10,4))
- << (SignalList() << Remove(12,6,0) << Insert(10,4) << Insert(27,6,0));
- QTest::newRow("m(12-23,6),i(16,4)")
- << (SignalList() << Move(12,23,6) << Insert(16,4))
- << (SignalList() << Remove(12,6,0) << Insert(16,4) << Insert(27,6,0));
- QTest::newRow("m(12-23,6),i(13,4)")
- << (SignalList() << Move(12,23,6) << Insert(13,4))
- << (SignalList() << Remove(12,6,0) << Insert(13,4) << Insert(27,6,0));
- QTest::newRow("m(12-23,6),i(14,4)")
- << (SignalList() << Move(12,23,6) << Insert(14,4))
- << (SignalList() << Remove(12,6,0) << Insert(14,4) << Insert(27,6,0));
- QTest::newRow("m(12-23,6),i(12,4)")
- << (SignalList() << Move(12,23,6) << Insert(12,4))
- << (SignalList() << Remove(12,6,0) << Insert(12,4) << Insert(27,6,0));
- QTest::newRow("m(12-23,6),i(11,8)")
- << (SignalList() << Move(12,23,6) << Insert(11,8))
- << (SignalList() << Remove(12,6,0) << Insert(11,8) << Insert(31,6,0));
- QTest::newRow("m(12-23,6),i(8,4)")
- << (SignalList() << Move(12,23,6) << Insert(8,4))
- << (SignalList() << Remove(12,6,0) << Insert(8,4) << Insert(27,6,0));
- QTest::newRow("m(12-23,6),i(2,4)")
- << (SignalList() << Move(12,23,6) << Insert(2,4))
- << (SignalList() << Remove(12,6,0) << Insert(2,4) << Insert(27,6,0));
- QTest::newRow("m(12-23,6),i(18,4)")
- << (SignalList() << Move(12,23,6) << Insert(18,4))
- << (SignalList() << Remove(12,6,0) << Insert(18,4) << Insert(27,6,0));
- QTest::newRow("m(12-23,6),i(20,4)")
- << (SignalList() << Move(12,23,6) << Insert(20,4))
- << (SignalList() << Remove(12,6,0) << Insert(20,4) << Insert(27,6,0));
-
- // Move,then remove
- QTest::newRow("m(12-5,6),r(12,6)")
- << (SignalList() << Move(12,5,6) << Remove(12,6))
- << (SignalList() << Remove(6,6) << Remove(6,6,0) << Insert(5,6,0));
- QTest::newRow("m(12-5,6),r(10,4)")
- << (SignalList() << Move(12,5,6) << Remove(10,4))
- << (SignalList() << Remove(5,3) << Remove(9,5,0) << Remove(9,1) << Insert(5,5,0));
- QTest::newRow("m(12-5,6),r(16,4)")
- << (SignalList() << Move(12,5,6) << Remove(16,4))
- << (SignalList() << Remove(10,2) << Remove(10,6,0) << Remove(10,2) << Insert(5,6,0));
- QTest::newRow("m(12-5,6),r(13,4)")
- << (SignalList() << Move(12,5,6) << Remove(13,4))
- << (SignalList() << Remove(7,4) << Remove(8,6,0) << Insert(5,6,0));
- QTest::newRow("m(12-5,6),r(14,4)")
- << (SignalList() << Move(12,5,6) << Remove(14,4))
- << (SignalList() << Remove(8,4) << Remove(8,6,0) << Insert(5,6,0));
- QTest::newRow("m(12-5,6),r(12,4)")
- << (SignalList() << Move(12,5,6) << Remove(12,4))
- << (SignalList() << Remove(6,4) << Remove(8,6,0) << Insert(5,6,0));
- QTest::newRow("m(12-5,6),r(11,8)")
- << (SignalList() << Move(12,5,6) << Remove(11,8))
- << (SignalList() << Remove(5,7) << Remove(5,6,0) << Remove(5,1) << Insert(5,6,0));
- QTest::newRow("m(12-5,6),r(8,4)")
- << (SignalList() << Move(12,5,6) << Remove(8,4))
- << (SignalList() << Remove(5,1) << Remove(11,3,0) << Remove(11,3) << Insert(5,3,0));
- QTest::newRow("m(12-5,6),r(2,4)")
- << (SignalList() << Move(12,5,6) << Remove(2,4))
- << (SignalList() << Remove(2,3) << Remove(9,1) << Remove(9,5,0) << Insert(2,5,0));
- QTest::newRow("m(12-5,6),r(6,4)")
- << (SignalList() << Move(12,5,6) << Remove(6,4))
- << (SignalList() << Remove(12,1,0) << Remove(12,4) << Remove(12,1,1) << Insert(5,1,0) << Insert(6,1,1));
- QTest::newRow("m(12-5,6),r(18,4)")
- << (SignalList() << Move(12,5,6) << Remove(18,4))
- << (SignalList() << Remove(12,6,0) << Remove(12,4) << Insert(5,6,0));
- QTest::newRow("m(12-5,6),r(20,4)")
- << (SignalList() << Move(12,5,6) << Remove(20,4))
- << (SignalList() << Remove(12,6,0) << Remove(14,4) << Insert(5,6,0));
-
- QTest::newRow("m(12-23,6),r(12,6)")
- << (SignalList() << Move(12,23,6) << Remove(12,6))
- << (SignalList() << Remove(12,6,0) << Remove(12,6) << Insert(17,6,0));
- QTest::newRow("m(12-23,6),r(10,4)")
- << (SignalList() << Move(12,23,6) << Remove(10,4))
- << (SignalList() << Remove(10,2) << Remove(10,6,0) << Remove(10,2) << Insert(19,6,0));
- QTest::newRow("m(12-23,6),r(16,4)")
- << (SignalList() << Move(12,23,6) << Remove(16,4))
- << (SignalList() << Remove(12,6,0) << Remove(16,4) << Insert(19,6,0));
- QTest::newRow("m(12-23,6),r(13,4)")
- << (SignalList() << Move(12,23,6) << Remove(13,4))
- << (SignalList() << Remove(12,6,0) << Remove(13,4) << Insert(19,6,0));
- QTest::newRow("m(12-23,6),r(14,4)")
- << (SignalList() << Move(12,23,6) << Remove(14,4))
- << (SignalList() << Remove(12,6,0) << Remove(14,4) << Insert(19,6,0));
- QTest::newRow("m(12-23,6),r(12,4)")
- << (SignalList() << Move(12,23,6) << Remove(12,4))
- << (SignalList() << Remove(12,6,0) << Remove(12,4) << Insert(19,6,0));
- QTest::newRow("m(12-23,6),r(11,8)")
- << (SignalList() << Move(12,23,6) << Remove(11,8))
- << (SignalList() << Remove(11,1) << Remove(11,6,0) << Remove(11,7) << Insert(15,6,0));
- QTest::newRow("m(12-23,6),r(8,4)")
- << (SignalList() << Move(12,23,6) << Remove(8,4))
- << (SignalList() << Remove(8,4) << Remove(8,6,0) << Insert(19,6,0));
- QTest::newRow("m(12-23,6),r(2,4)")
- << (SignalList() << Move(12,23,6) << Remove(2,4))
- << (SignalList() << Remove(2,4) << Remove(8,6,0) << Insert(19,6,0));
- QTest::newRow("m(12-23,6),r(18,4)")
- << (SignalList() << Move(12,23,6) << Remove(18,4))
- << (SignalList() << Remove(12,6,0) << Remove(18,4) << Insert(19,6,0));
- QTest::newRow("m(12-23,6),r(20,4)")
- << (SignalList() << Move(12,23,6) << Remove(20,4))
- << (SignalList() << Remove(12,1) << Remove(12,5,0) << Remove(20,3) << Insert(20,5,0));
-
-
- // Complex
- QTest::newRow("r(15,1),r(22,1)")
- << (SignalList() << Remove(15,1) << Remove(22,1))
- << (SignalList() << Remove(15,1) << Remove(22,1));
- QTest::newRow("r(15,1),r(22,1),r(25,1)")
- << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1))
- << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1));
- QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1)")
- << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1))
- << (SignalList() << Remove(15,2) << Remove(21,1) << Remove(24,1));
- QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1)")
- << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1))
- << (SignalList() << Remove(13,1) << Remove(14,2) << Remove(20,1) << Remove(23,1));
- QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1),r(13,1)")
- << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1) << Remove(13,1))
- << (SignalList() << Remove(13,4) << Remove(19,1) << Remove(22,1));
- QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1),r(13,1),m(12,13,1)")
- << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1) << Remove(13,1) << Move(12,13,1))
- << (SignalList() << Remove(12,1,0) << Remove(12,4) << Remove(18,1) << Remove(21,1) << Insert(13,1,0));
-
-}
-
-void tst_qdeclarativemodelchange::sequence()
-{
- QFETCH(SignalList, input);
- QFETCH(SignalList, output);
-
- QDeclarativeChangeSet set;
-
- foreach (const Signal &signal, input) {
- if (signal.isRemove())
- set.remove(signal.index, signal.count);
- else if (signal.isInsert())
- set.insert(signal.index, signal.count);
- else if (signal.isMove())
- set.move(signal.index, signal.to, signal.count);
- else if (signal.isChange())
- set.change(signal.index, signal.count);
- }
-
- SignalList changes;
- foreach (const QDeclarativeChangeSet::Remove &remove, set.removes())
- changes << Remove(remove.index, remove.count, remove.moveId);
- foreach (const QDeclarativeChangeSet::Insert &insert, set.inserts())
- changes << Insert(insert.index, insert.count, insert.moveId);
- foreach (const QDeclarativeChangeSet::Change &change, set.changes())
- changes << Change(change.index, change.count);
-
-#ifdef VERIFY_EXPECTED_OUTPUT
- QVector<int> list;
- for (int i = 0; i < 40; ++i)
- list.append(i);
- QVector<int> inputList = applyChanges(list, input);
- QVector<int> outputList = applyChanges(list, output);
- if (outputList != inputList /* || changes != output*/) {
- qDebug() << input;
- qDebug() << output;
- qDebug() << changes;
- qDebug() << inputList;
- qDebug() << outputList;
- } else if (changes != output) {
- qDebug() << output;
- qDebug() << changes;
- }
- QCOMPARE(outputList, inputList);
-#else
-
- if (changes != output) {
- qDebug() << output;
- qDebug() << changes;
- }
-
-#endif
-
- QCOMPARE(changes, output);
-}
-
-
-QTEST_MAIN(tst_qdeclarativemodelchange)
-
-#include "tst_qdeclarativechangeset.moc"
diff --git a/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro
deleted file mode 100644
index 2389ca4a20..0000000000
--- a/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativecomponent
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativecomponent.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private network testlib
diff --git a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
deleted file mode 100644
index c529649fc0..0000000000
--- a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QDebug>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeproperty.h>
-#include <QtDeclarative/qdeclarativeincubator.h>
-#include <qcolor.h>
-#include "../../shared/util.h"
-
-class MyIC : public QObject, public QDeclarativeIncubationController
-{
- Q_OBJECT
-public:
- MyIC() { startTimer(5); }
-protected:
- virtual void timerEvent(QTimerEvent*) {
- incubateFor(5);
- }
-};
-
-class tst_qdeclarativecomponent : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativecomponent() { engine.setIncubationController(&ic); }
-
-private slots:
- void null();
- void loadEmptyUrl();
- void qmlCreateObject();
- void qmlCreateObjectWithProperties();
- void qmlIncubateObject();
-
-private:
- QDeclarativeEngine engine;
- MyIC ic;
-};
-
-void tst_qdeclarativecomponent::null()
-{
- {
- QDeclarativeComponent c;
- QVERIFY(c.isNull());
- }
-
- {
- QDeclarativeComponent c(&engine);
- QVERIFY(c.isNull());
- }
-}
-
-
-void tst_qdeclarativecomponent::loadEmptyUrl()
-{
- QDeclarativeComponent c(&engine);
- c.loadUrl(QUrl());
-
- QVERIFY(c.isError());
- QCOMPARE(c.errors().count(), 1);
- QDeclarativeError error = c.errors().first();
- QCOMPARE(error.url(), QUrl());
- QCOMPARE(error.line(), -1);
- QCOMPARE(error.column(), -1);
- QCOMPARE(error.description(), QLatin1String("Invalid empty URL"));
-}
-
-void tst_qdeclarativecomponent::qmlIncubateObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("incubateObject.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), false);
-
- QTRY_VERIFY(object->property("test2").toBool() == true);
-
- delete object;
-}
-
-void tst_qdeclarativecomponent::qmlCreateObject()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("createObject.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *testObject1 = object->property("qobject").value<QObject*>();
- QVERIFY(testObject1);
- QVERIFY(testObject1->parent() == object);
-
- QObject *testObject2 = object->property("declarativeitem").value<QObject*>();
- QVERIFY(testObject2);
- QVERIFY(testObject2->parent() == object);
- QCOMPARE(testObject2->metaObject()->className(), "QQuickItem");
-}
-
-void tst_qdeclarativecomponent::qmlCreateObjectWithProperties()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("createObjectWithScript.qml"));
- QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *testObject1 = object->property("declarativerectangle").value<QObject*>();
- QVERIFY(testObject1);
- QVERIFY(testObject1->parent() == object);
- QCOMPARE(testObject1->property("x").value<int>(), 17);
- QCOMPARE(testObject1->property("y").value<int>(), 17);
- QCOMPARE(testObject1->property("color").value<QColor>(), QColor(255,255,255));
- QCOMPARE(QDeclarativeProperty::read(testObject1,"border.width").toInt(), 3);
- QCOMPARE(QDeclarativeProperty::read(testObject1,"innerRect.border.width").toInt(), 20);
- delete testObject1;
-
- QObject *testObject2 = object->property("declarativeitem").value<QObject*>();
- QVERIFY(testObject2);
- QVERIFY(testObject2->parent() == object);
- //QCOMPARE(testObject2->metaObject()->className(), "QDeclarativeItem_QML_2");
- QCOMPARE(testObject2->property("x").value<int>(), 17);
- QCOMPARE(testObject2->property("y").value<int>(), 17);
- QCOMPARE(testObject2->property("testBool").value<bool>(), true);
- QCOMPARE(testObject2->property("testInt").value<int>(), 17);
- QCOMPARE(testObject2->property("testObject").value<QObject*>(), object);
- delete testObject2;
-
- QObject *testBindingObj = object->property("bindingTestObject").value<QObject*>();
- QVERIFY(testBindingObj);
- QCOMPARE(testBindingObj->parent(), object);
- QCOMPARE(testBindingObj->property("testValue").value<int>(), 300);
- object->setProperty("width", 150);
- QCOMPARE(testBindingObj->property("testValue").value<int>(), 150 * 3);
- delete testBindingObj;
-
- QObject *testBindingThisObj = object->property("bindingThisTestObject").value<QObject*>();
- QVERIFY(testBindingThisObj);
- QCOMPARE(testBindingThisObj->parent(), object);
- QCOMPARE(testBindingThisObj->property("testValue").value<int>(), 900);
- testBindingThisObj->setProperty("width", 200);
- QCOMPARE(testBindingThisObj->property("testValue").value<int>(), 200 * 3);
- delete testBindingThisObj;
-}
-
-QTEST_MAIN(tst_qdeclarativecomponent)
-
-#include "tst_qdeclarativecomponent.moc"
diff --git a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro
deleted file mode 100644
index bb863c5262..0000000000
--- a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeconnection
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeconnection.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
diff --git a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp
deleted file mode 100644
index 0474b4388e..0000000000
--- a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qdeclarativeconnections_p.h>
-#include <private/qquickitem_p.h>
-#include "../../shared/util.h"
-#include <QtDeclarative/qdeclarativescriptstring.h>
-
-class tst_qdeclarativeconnection : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeconnection();
-
-private slots:
- void defaultValues();
- void properties();
- void connection();
- void trimming();
- void targetChanged();
- void unknownSignals_data();
- void unknownSignals();
- void errors_data();
- void errors();
- void moduleApiTarget();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativeconnection::tst_qdeclarativeconnection()
-{
-}
-
-void tst_qdeclarativeconnection::defaultValues()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("test-connection3.qml"));
- QDeclarativeConnections *item = qobject_cast<QDeclarativeConnections*>(c.create());
-
- QVERIFY(item != 0);
- QVERIFY(item->target() == 0);
-
- delete item;
-}
-
-void tst_qdeclarativeconnection::properties()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("test-connection2.qml"));
- QDeclarativeConnections *item = qobject_cast<QDeclarativeConnections*>(c.create());
-
- QVERIFY(item != 0);
-
- QVERIFY(item != 0);
- QVERIFY(item->target() == item);
-
- delete item;
-}
-
-void tst_qdeclarativeconnection::connection()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("test-connection.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
-
- QVERIFY(item != 0);
-
- QCOMPARE(item->property("tested").toBool(), false);
- QCOMPARE(item->width(), 50.);
- emit item->setWidth(100.);
- QCOMPARE(item->width(), 100.);
- QCOMPARE(item->property("tested").toBool(), true);
-
- delete item;
-}
-
-void tst_qdeclarativeconnection::trimming()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("trimming.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
-
- QVERIFY(item != 0);
-
- QCOMPARE(item->property("tested").toString(), QString(""));
- int index = item->metaObject()->indexOfSignal("testMe(int,QString)");
- QMetaMethod method = item->metaObject()->method(index);
- method.invoke(item,
- Qt::DirectConnection,
- Q_ARG(int, 5),
- Q_ARG(QString, "worked"));
- QCOMPARE(item->property("tested").toString(), QString("worked5"));
-
- delete item;
-}
-
-// Confirm that target can be changed by one of our signal handlers
-void tst_qdeclarativeconnection::targetChanged()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("connection-targetchange.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
- QVERIFY(item != 0);
-
- QDeclarativeConnections *connections = item->findChild<QDeclarativeConnections*>("connections");
- QVERIFY(connections);
-
- QQuickItem *item1 = item->findChild<QQuickItem*>("item1");
- QVERIFY(item1);
-
- item1->setWidth(200);
-
- QQuickItem *item2 = item->findChild<QQuickItem*>("item2");
- QVERIFY(item2);
- QVERIFY(connections->target() == item2);
-
- // If we don't crash then we're OK
-
- delete item;
-}
-
-void tst_qdeclarativeconnection::unknownSignals_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("basic") << "connection-unknownsignals.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\"";
- QTest::newRow("parent") << "connection-unknownsignals-parent.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\"";
- QTest::newRow("ignored") << "connection-unknownsignals-ignored.qml" << ""; // should be NO error
- QTest::newRow("notarget") << "connection-unknownsignals-notarget.qml" << ""; // should be NO error
-}
-
-void tst_qdeclarativeconnection::unknownSignals()
-{
- QFETCH(QString, file);
- QFETCH(QString, error);
-
- QUrl url = testFileUrl(file);
- if (!error.isEmpty()) {
- QTest::ignoreMessage(QtWarningMsg, (url.toString() + error).toLatin1());
- } else {
- // QTest has no way to insist no message (i.e. fail)
- }
-
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, url);
- QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
- QVERIFY(item != 0);
-
- // check that connection is created (they are all runtime errors)
- QDeclarativeConnections *connections = item->findChild<QDeclarativeConnections*>("connections");
- QVERIFY(connections);
-
- if (file == "connection-unknownsignals-ignored.qml")
- QVERIFY(connections->ignoreUnknownSignals());
-
- delete item;
-}
-
-void tst_qdeclarativeconnection::errors_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("no \"on\"") << "error-property.qml" << "Cannot assign to non-existent property \"fakeProperty\"";
- QTest::newRow("3rd letter lowercase") << "error-property2.qml" << "Cannot assign to non-existent property \"onfakeProperty\"";
- QTest::newRow("child object") << "error-object.qml" << "Connections: nested objects not allowed";
- QTest::newRow("grouped object") << "error-syntax.qml" << "Connections: syntax error";
-}
-
-void tst_qdeclarativeconnection::errors()
-{
- QFETCH(QString, file);
- QFETCH(QString, error);
-
- QUrl url = testFileUrl(file);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, url);
- QVERIFY(c.isError() == true);
- QList<QDeclarativeError> errors = c.errors();
- QVERIFY(errors.count() == 1);
- QCOMPARE(errors.at(0).description(), error);
-}
-
-
-class MyTestModuleApi : public QObject
-{
-Q_OBJECT
-Q_PROPERTY(int intProp READ intProp WRITE setIntProp NOTIFY intPropChanged)
-
-public:
- MyTestModuleApi(QObject *parent = 0) : QObject(parent), m_intProp(0), m_changeCount(0) {}
- ~MyTestModuleApi() {}
-
- Q_INVOKABLE int otherMethod(int val) { return val + 4; }
-
- int intProp() const { return m_intProp; }
- void setIntProp(int val)
- {
- if (++m_changeCount % 3 == 0) emit otherSignal();
- m_intProp = val; emit intPropChanged();
- }
-
-signals:
- void intPropChanged();
- void otherSignal();
-
-private:
- int m_intProp;
- int m_changeCount;
-};
-
-static QObject *module_api_factory(QDeclarativeEngine *engine, QJSEngine *scriptEngine)
-{
- Q_UNUSED(engine)
- Q_UNUSED(scriptEngine)
- MyTestModuleApi *api = new MyTestModuleApi();
- return api;
-}
-
-// QTBUG-20937
-void tst_qdeclarativeconnection::moduleApiTarget()
-{
- qmlRegisterModuleApi("MyTestModuleApi", 1, 0, module_api_factory);
- QDeclarativeComponent component(&engine, testFileUrl("moduleapi-target.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 0);
- QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0);
-
- QMetaObject::invokeMethod(object, "setModuleIntProp");
- QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 1);
- QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0);
-
- QMetaObject::invokeMethod(object, "setModuleIntProp");
- QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 2);
- QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0);
-
- // the module API emits otherSignal every 3 times the int property changes.
- QMetaObject::invokeMethod(object, "setModuleIntProp");
- QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 3);
- QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 1);
-
- delete object;
-}
-
-QTEST_MAIN(tst_qdeclarativeconnection)
-
-#include "tst_qdeclarativeconnection.moc"
diff --git a/tests/auto/declarative/qdeclarativeconsole/data/tracing.qml b/tests/auto/declarative/qdeclarativeconsole/data/tracing.qml
deleted file mode 100644
index 0d1b76359e..0000000000
--- a/tests/auto/declarative/qdeclarativeconsole/data/tracing.qml
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-// moving lines in here requires fixing tst_qdeclarativeconsole.cpp
-QtObject {
- id: root
-
- function tracing()
- {
- console.trace();
- }
-
- Component.onCompleted: {
- tracing();
- }
-}
diff --git a/tests/auto/declarative/qdeclarativeconsole/qdeclarativeconsole.pro b/tests/auto/declarative/qdeclarativeconsole/qdeclarativeconsole.pro
deleted file mode 100644
index 0563491c1e..0000000000
--- a/tests/auto/declarative/qdeclarativeconsole/qdeclarativeconsole.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeconsole
-SOURCES += tst_qdeclarativeconsole.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += declarative testlib
diff --git a/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp b/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp
deleted file mode 100644
index f5788dcf55..0000000000
--- a/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QDebug>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include "../../shared/util.h"
-
-class tst_qdeclarativeconsole : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeconsole() {}
-
-private slots:
- void logging();
- void tracing();
- void profiling();
- void assert();
- void exception();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qdeclarativeconsole::logging()
-{
- QUrl testUrl = testFileUrl("logging.qml");
-
- QTest::ignoreMessage(QtDebugMsg, "console.debug");
- QTest::ignoreMessage(QtDebugMsg, "console.log");
- QTest::ignoreMessage(QtDebugMsg, "console.info");
- QTest::ignoreMessage(QtWarningMsg, "console.warn");
- QTest::ignoreMessage(QtCriticalMsg, "console.error");
-
- QTest::ignoreMessage(QtDebugMsg, "console.count: 1");
- QTest::ignoreMessage(QtDebugMsg, ": 1");
- QTest::ignoreMessage(QtDebugMsg, "console.count: 2");
- QTest::ignoreMessage(QtDebugMsg, ": 2");
-
- QTest::ignoreMessage(QtDebugMsg, "[1,2]");
- QTest::ignoreMessage(QtDebugMsg, "Object");
- QTest::ignoreMessage(QtDebugMsg, "undefined");
- QTest::ignoreMessage(QtDebugMsg, "12");
- QTest::ignoreMessage(QtDebugMsg, "function () { return 5;}");
- QTest::ignoreMessage(QtDebugMsg, "true");
- QTest::ignoreMessage(QtDebugMsg, "Object");
- QTest::ignoreMessage(QtDebugMsg, "Object");
- QTest::ignoreMessage(QtDebugMsg, "1 pong! Object");
- QTest::ignoreMessage(QtDebugMsg, "1 [ping,pong] Object 2");
-
- QDeclarativeComponent component(&engine, testUrl);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativeconsole::tracing()
-{
- QUrl testUrl = testFileUrl("tracing.qml");
-
- QString traceText =
- QString::fromLatin1("tracing (%1:%2:%3)\n").arg(testUrl.toString()).arg(50).arg(17) +
- QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(54).arg(9);
-
- QTest::ignoreMessage(QtDebugMsg, qPrintable(traceText));
-
- QDeclarativeComponent component(&engine, testUrl);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativeconsole::profiling()
-{
- QUrl testUrl = testFileUrl("profiling.qml");
-
- // profiling()
- QTest::ignoreMessage(QtDebugMsg, "Profiling started.");
- QTest::ignoreMessage(QtDebugMsg, "Profiling ended.");
-
- QDeclarativeComponent component(&engine, testUrl);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativeconsole::assert()
-{
- QUrl testUrl = testFileUrl("assert.qml");
-
- // assert()
- QString assert1 = "This will fail\n" +
- QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(54).arg(17);
-
- QString assert2 = "This will fail too\n" +
- QString::fromLatin1("assertFail (%1:%2:%3)\n").arg(testUrl.toString()).arg(47).arg(17) +
- QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(59).arg(9);
-
- QTest::ignoreMessage(QtCriticalMsg, qPrintable(assert1));
- QTest::ignoreMessage(QtCriticalMsg, qPrintable(assert2));
-
- QDeclarativeComponent component(&engine, testUrl);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativeconsole::exception()
-{
- QUrl testUrl = testFileUrl("exception.qml");
-
- // exception()
- QString exception1 = "Exception 1\n" +
- QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(51).arg(21);
-
- QString exception2 = "Exception 2\n" +
- QString::fromLatin1("exceptionFail (%1:%2:%3)\n").arg(testUrl.toString()).arg(46).arg(17) +
- QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(56).arg(9);
-
- QTest::ignoreMessage(QtCriticalMsg, qPrintable(exception1));
- QTest::ignoreMessage(QtCriticalMsg, qPrintable(exception2));
-
- QDeclarativeComponent component(&engine, testUrl);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-QTEST_MAIN(tst_qdeclarativeconsole)
-
-#include "tst_qdeclarativeconsole.moc"
diff --git a/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro b/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro
deleted file mode 100644
index 3e1cc01e09..0000000000
--- a/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativecontext
-SOURCES += tst_qdeclarativecontext.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private testlib v8-private
diff --git a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp
deleted file mode 100644
index 05db898045..0000000000
--- a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp
+++ /dev/null
@@ -1,652 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDebug>
-#include <QDeclarativeEngine>
-#include <QDeclarativeContext>
-#include <QDeclarativeComponent>
-#include <QDeclarativeExpression>
-#include <private/qdeclarativecontext_p.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativecontext : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativecontext() {}
-
-private slots:
- void baseUrl();
- void resolvedUrl();
- void engineMethod();
- void parentContext();
- void setContextProperty();
- void setContextObject();
- void destruction();
- void idAsContextProperty();
- void readOnlyContexts();
- void nameForObject();
-
- void refreshExpressions();
- void refreshExpressionsCrash();
- void refreshExpressionsRootContext();
-
- void qtbug_22535();
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qdeclarativecontext::baseUrl()
-{
- QDeclarativeContext ctxt(&engine);
-
- QCOMPARE(ctxt.baseUrl(), QUrl());
-
- ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
-
- QCOMPARE(ctxt.baseUrl(), QUrl("http://www.nokia.com/"));
-}
-
-void tst_qdeclarativecontext::resolvedUrl()
-{
- // Relative to the component
- {
- QDeclarativeContext ctxt(&engine);
- ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
-
- QCOMPARE(ctxt.resolvedUrl(QUrl("main.qml")), QUrl("http://www.nokia.com/main.qml"));
- }
-
- // Relative to a parent
- {
- QDeclarativeContext ctxt(&engine);
- ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
-
- QDeclarativeContext ctxt2(&ctxt);
- QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
- }
-
- // Relative to the engine
- {
- QDeclarativeContext ctxt(&engine);
- QCOMPARE(ctxt.resolvedUrl(QUrl("main.qml")), engine.baseUrl().resolved(QUrl("main.qml")));
- }
-
- // Relative to a deleted parent
- {
- QDeclarativeContext *ctxt = new QDeclarativeContext(&engine);
- ctxt->setBaseUrl(QUrl("http://www.nokia.com/"));
-
- QDeclarativeContext ctxt2(ctxt);
- QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
-
- delete ctxt; ctxt = 0;
-
- QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl());
- }
-
- // Absolute
- {
- QDeclarativeContext ctxt(&engine);
-
- QCOMPARE(ctxt.resolvedUrl(QUrl("http://www.nokia.com/main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
- QCOMPARE(ctxt.resolvedUrl(QUrl("file:///main2.qml")), QUrl("file:///main2.qml"));
- }
-}
-
-void tst_qdeclarativecontext::engineMethod()
-{
- QDeclarativeEngine *engine = new QDeclarativeEngine;
-
- QDeclarativeContext ctxt(engine);
- QDeclarativeContext ctxt2(&ctxt);
- QDeclarativeContext ctxt3(&ctxt2);
- QDeclarativeContext ctxt4(&ctxt2);
-
- QCOMPARE(ctxt.engine(), engine);
- QCOMPARE(ctxt2.engine(), engine);
- QCOMPARE(ctxt3.engine(), engine);
- QCOMPARE(ctxt4.engine(), engine);
-
- delete engine; engine = 0;
-
- QCOMPARE(ctxt.engine(), engine);
- QCOMPARE(ctxt2.engine(), engine);
- QCOMPARE(ctxt3.engine(), engine);
- QCOMPARE(ctxt4.engine(), engine);
-}
-
-void tst_qdeclarativecontext::parentContext()
-{
- QDeclarativeEngine *engine = new QDeclarativeEngine;
-
- QCOMPARE(engine->rootContext()->parentContext(), (QDeclarativeContext *)0);
-
- QDeclarativeContext *ctxt = new QDeclarativeContext(engine);
- QDeclarativeContext *ctxt2 = new QDeclarativeContext(ctxt);
- QDeclarativeContext *ctxt3 = new QDeclarativeContext(ctxt2);
- QDeclarativeContext *ctxt4 = new QDeclarativeContext(ctxt2);
- QDeclarativeContext *ctxt5 = new QDeclarativeContext(ctxt);
- QDeclarativeContext *ctxt6 = new QDeclarativeContext(engine);
- QDeclarativeContext *ctxt7 = new QDeclarativeContext(engine->rootContext());
-
- QCOMPARE(ctxt->parentContext(), engine->rootContext());
- QCOMPARE(ctxt2->parentContext(), ctxt);
- QCOMPARE(ctxt3->parentContext(), ctxt2);
- QCOMPARE(ctxt4->parentContext(), ctxt2);
- QCOMPARE(ctxt5->parentContext(), ctxt);
- QCOMPARE(ctxt6->parentContext(), engine->rootContext());
- QCOMPARE(ctxt7->parentContext(), engine->rootContext());
-
- delete ctxt2; ctxt2 = 0;
-
- QCOMPARE(ctxt->parentContext(), engine->rootContext());
- QCOMPARE(ctxt3->parentContext(), (QDeclarativeContext *)0);
- QCOMPARE(ctxt4->parentContext(), (QDeclarativeContext *)0);
- QCOMPARE(ctxt5->parentContext(), ctxt);
- QCOMPARE(ctxt6->parentContext(), engine->rootContext());
- QCOMPARE(ctxt7->parentContext(), engine->rootContext());
-
- delete engine; engine = 0;
-
- QCOMPARE(ctxt->parentContext(), (QDeclarativeContext *)0);
- QCOMPARE(ctxt3->parentContext(), (QDeclarativeContext *)0);
- QCOMPARE(ctxt4->parentContext(), (QDeclarativeContext *)0);
- QCOMPARE(ctxt5->parentContext(), (QDeclarativeContext *)0);
- QCOMPARE(ctxt6->parentContext(), (QDeclarativeContext *)0);
- QCOMPARE(ctxt7->parentContext(), (QDeclarativeContext *)0);
-
- delete ctxt7;
- delete ctxt6;
- delete ctxt5;
- delete ctxt4;
- delete ctxt3;
- delete ctxt;
-}
-
-class TestObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int a READ a NOTIFY aChanged)
- Q_PROPERTY(int b READ b NOTIFY bChanged)
- Q_PROPERTY(int c READ c NOTIFY cChanged)
-
-public:
- TestObject() : _a(10), _b(10), _c(10) {}
-
- int a() const { return _a; }
- void setA(int a) { _a = a; emit aChanged(); }
-
- int b() const { return _b; }
- void setB(int b) { _b = b; emit bChanged(); }
-
- int c() const { return _c; }
- void setC(int c) { _c = c; emit cChanged(); }
-
-signals:
- void aChanged();
- void bChanged();
- void cChanged();
-
-private:
- int _a;
- int _b;
- int _c;
-};
-
-#define TEST_CONTEXT_PROPERTY(ctxt, name, value) \
-{ \
- QDeclarativeComponent component(&engine); \
- component.setData("import QtQuick 2.0; QtObject { property variant test: " #name " }", QUrl()); \
-\
- QObject *obj = component.create(ctxt); \
-\
- QCOMPARE(obj->property("test"), value); \
-\
- delete obj; \
-}
-
-void tst_qdeclarativecontext::setContextProperty()
-{
- QDeclarativeContext ctxt(&engine);
- QDeclarativeContext ctxt2(&ctxt);
-
- TestObject obj1;
- obj1.setA(3345);
- TestObject obj2;
- obj2.setA(-19);
-
- // Static context properties
- ctxt.setContextProperty("a", QVariant(10));
- ctxt.setContextProperty("b", QVariant(9));
- ctxt2.setContextProperty("d", &obj2);
- ctxt2.setContextProperty("b", QVariant(19));
- ctxt2.setContextProperty("c", QVariant(QString("Hello World!")));
- ctxt.setContextProperty("d", &obj1);
- ctxt.setContextProperty("e", &obj1);
-
- TEST_CONTEXT_PROPERTY(&ctxt2, a, QVariant(10));
- TEST_CONTEXT_PROPERTY(&ctxt2, b, QVariant(19));
- TEST_CONTEXT_PROPERTY(&ctxt2, c, QVariant(QString("Hello World!")));
- TEST_CONTEXT_PROPERTY(&ctxt2, d.a, QVariant(-19));
- TEST_CONTEXT_PROPERTY(&ctxt2, e.a, QVariant(3345));
-
- ctxt.setContextProperty("a", QVariant(13));
- ctxt.setContextProperty("b", QVariant(4));
- ctxt2.setContextProperty("b", QVariant(8));
- ctxt2.setContextProperty("c", QVariant(QString("Hi World!")));
- ctxt2.setContextProperty("d", &obj1);
- obj1.setA(12);
-
- TEST_CONTEXT_PROPERTY(&ctxt2, a, QVariant(13));
- TEST_CONTEXT_PROPERTY(&ctxt2, b, QVariant(8));
- TEST_CONTEXT_PROPERTY(&ctxt2, c, QVariant(QString("Hi World!")));
- TEST_CONTEXT_PROPERTY(&ctxt2, d.a, QVariant(12));
- TEST_CONTEXT_PROPERTY(&ctxt2, e.a, QVariant(12));
-
- // Changes in context properties
- {
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl());
-
- QObject *obj = component.create(&ctxt2);
-
- QCOMPARE(obj->property("test"), QVariant(13));
- ctxt.setContextProperty("a", QVariant(19));
- QCOMPARE(obj->property("test"), QVariant(19));
-
- delete obj;
- }
- {
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { property variant test: b }", QUrl());
-
- QObject *obj = component.create(&ctxt2);
-
- QCOMPARE(obj->property("test"), QVariant(8));
- ctxt.setContextProperty("b", QVariant(5));
- QCOMPARE(obj->property("test"), QVariant(8));
- ctxt2.setContextProperty("b", QVariant(1912));
- QCOMPARE(obj->property("test"), QVariant(1912));
-
- delete obj;
- }
- {
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { property variant test: e.a }", QUrl());
-
- QObject *obj = component.create(&ctxt2);
-
- QCOMPARE(obj->property("test"), QVariant(12));
- obj1.setA(13);
- QCOMPARE(obj->property("test"), QVariant(13));
-
- delete obj;
- }
-
- // New context properties
- {
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl());
-
- QObject *obj = component.create(&ctxt2);
-
- QCOMPARE(obj->property("test"), QVariant(19));
- ctxt2.setContextProperty("a", QVariant(1945));
- QCOMPARE(obj->property("test"), QVariant(1945));
-
- delete obj;
- }
-
- // Setting an object-variant context property
- {
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { id: root; property int a: 10; property int test: ctxtProp.a; property variant obj: root; }", QUrl());
-
- QDeclarativeContext ctxt(engine.rootContext());
- ctxt.setContextProperty("ctxtProp", QVariant());
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:1: TypeError: Cannot read property 'a' of undefined");
- QObject *obj = component.create(&ctxt);
-
- QVariant v = obj->property("obj");
-
- ctxt.setContextProperty("ctxtProp", v);
-
- QCOMPARE(obj->property("test"), QVariant(10));
-
- delete obj;
- }
-}
-
-void tst_qdeclarativecontext::setContextObject()
-{
- QDeclarativeContext ctxt(&engine);
-
- TestObject to;
-
- to.setA(2);
- to.setB(192);
- to.setC(18);
-
- ctxt.setContextObject(&to);
- ctxt.setContextProperty("c", QVariant(9));
-
- // Static context properties
- TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(2));
- TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(192));
- TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(9));
-
- to.setA(12);
- to.setB(100);
- to.setC(7);
- ctxt.setContextProperty("c", QVariant(3));
-
- TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(12));
- TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(100));
- TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(3));
-
- // Changes in context properties
- {
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl());
-
- QObject *obj = component.create(&ctxt);
-
- QCOMPARE(obj->property("test"), QVariant(12));
- to.setA(14);
- QCOMPARE(obj->property("test"), QVariant(14));
-
- delete obj;
- }
-}
-
-void tst_qdeclarativecontext::destruction()
-{
- QDeclarativeContext *ctxt = new QDeclarativeContext(&engine);
-
- QObject obj;
- QDeclarativeEngine::setContextForObject(&obj, ctxt);
- QDeclarativeExpression expr(ctxt, 0, "a");
-
- QCOMPARE(ctxt, QDeclarativeEngine::contextForObject(&obj));
- QCOMPARE(ctxt, expr.context());
-
- delete ctxt; ctxt = 0;
-
- QCOMPARE(ctxt, QDeclarativeEngine::contextForObject(&obj));
- QCOMPARE(ctxt, expr.context());
-}
-
-void tst_qdeclarativecontext::idAsContextProperty()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { property variant a; a: QtObject { id: myObject } }", QUrl());
-
- QObject *obj = component.create();
- QVERIFY(obj);
-
- QVariant a = obj->property("a");
- QVERIFY(a.userType() == QMetaType::QObjectStar);
-
- QVariant ctxt = qmlContext(obj)->contextProperty("myObject");
- QVERIFY(ctxt.userType() == QMetaType::QObjectStar);
-
- QVERIFY(a == ctxt);
-
- delete obj;
-}
-
-// Internal contexts should be read-only
-void tst_qdeclarativecontext::readOnlyContexts()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { id: me }", QUrl());
-
- QObject *obj = component.create();
- QVERIFY(obj);
-
- QDeclarativeContext *context = qmlContext(obj);
- QVERIFY(context);
-
- QVERIFY(qvariant_cast<QObject*>(context->contextProperty("me")) == obj);
- QVERIFY(context->contextObject() == obj);
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeContext: Cannot set property on internal context.");
- context->setContextProperty("hello", 12);
- QVERIFY(context->contextProperty("hello") == QVariant());
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeContext: Cannot set property on internal context.");
- context->setContextProperty("hello", obj);
- QVERIFY(context->contextProperty("hello") == QVariant());
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeContext: Cannot set context object for internal context.");
- context->setContextObject(0);
- QVERIFY(context->contextObject() == obj);
-
- delete obj;
-}
-
-void tst_qdeclarativecontext::nameForObject()
-{
- QObject o1;
- QObject o2;
- QObject o3;
-
- QDeclarativeEngine engine;
-
- // As a context property
- engine.rootContext()->setContextProperty("o1", &o1);
- engine.rootContext()->setContextProperty("o2", &o2);
- engine.rootContext()->setContextProperty("o1_2", &o1);
-
- QCOMPARE(engine.rootContext()->nameForObject(&o1), QString("o1"));
- QCOMPARE(engine.rootContext()->nameForObject(&o2), QString("o2"));
- QCOMPARE(engine.rootContext()->nameForObject(&o3), QString());
-
- // As an id
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { id: root; property QtObject o: QtObject { id: nested } }", QUrl());
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(qmlContext(o)->nameForObject(o), QString("root"));
- QCOMPARE(qmlContext(o)->nameForObject(qvariant_cast<QObject*>(o->property("o"))), QString("nested"));
- QCOMPARE(qmlContext(o)->nameForObject(&o1), QString());
-
- delete o;
-}
-
-class DeleteCommand : public QObject
-{
-Q_OBJECT
-public:
- DeleteCommand() : object(0) {}
-
- QObject *object;
-
-public slots:
- void doCommand() { if (object) delete object; object = 0; }
-};
-
-// Calling refresh expressions would crash if an expression or context was deleted during
-// the refreshing
-void tst_qdeclarativecontext::refreshExpressionsCrash()
-{
- {
- QDeclarativeEngine engine;
-
- DeleteCommand command;
- engine.rootContext()->setContextProperty("deleteCommand", &command);
- // We use a fresh context here to bypass any root-context optimizations in
- // the engine
- QDeclarativeContext ctxt(engine.rootContext());
-
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { property var binding: deleteCommand.doCommand() }", QUrl());
- QVERIFY(component.isReady());
-
- QObject *o1 = component.create(&ctxt);
- QObject *o2 = component.create(&ctxt);
-
- command.object = o2;
-
- QDeclarativeContextData::get(&ctxt)->refreshExpressions();
-
- delete o1;
- }
- {
- QDeclarativeEngine engine;
-
- DeleteCommand command;
- engine.rootContext()->setContextProperty("deleteCommand", &command);
- // We use a fresh context here to bypass any root-context optimizations in
- // the engine
- QDeclarativeContext ctxt(engine.rootContext());
-
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { property var binding: deleteCommand.doCommand() }", QUrl());
- QVERIFY(component.isReady());
-
- QObject *o1 = component.create(&ctxt);
- QObject *o2 = component.create(&ctxt);
-
- command.object = o1;
-
- QDeclarativeContextData::get(&ctxt)->refreshExpressions();
-
- delete o2;
- }
-}
-
-class CountCommand : public QObject
-{
-Q_OBJECT
-public:
- CountCommand() : count(0) {}
-
- int count;
-
-public slots:
- void doCommand() { ++count; }
-};
-
-
-// Test that calling refresh expressions causes all the expressions to refresh
-void tst_qdeclarativecontext::refreshExpressions()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("refreshExpressions.qml"));
- QDeclarativeComponent component2(&engine, testFileUrl("RefreshExpressionsType.qml"));
-
- CountCommand command;
- engine.rootContext()->setContextProperty("countCommand", &command);
-
- // We use a fresh context here to bypass any root-context optimizations in
- // the engine
- QDeclarativeContext context(engine.rootContext());
- QDeclarativeContext context2(&context);
-
- QObject *o1 = component.create(&context);
- QObject *o2 = component.create(&context2);
- QObject *o3 = component2.create(&context);
-
- QCOMPARE(command.count, 5);
-
- QDeclarativeContextData::get(&context)->refreshExpressions();
-
- QCOMPARE(command.count, 10);
-
- delete o3;
- delete o2;
- delete o1;
-}
-
-// Test that updating the root context, only causes expressions in contexts with an
-// unresolved name to reevaluate
-void tst_qdeclarativecontext::refreshExpressionsRootContext()
-{
- QDeclarativeEngine engine;
-
- CountCommand command;
- engine.rootContext()->setContextProperty("countCommand", &command);
-
- QDeclarativeComponent component(&engine, testFileUrl("refreshExpressions.qml"));
- QDeclarativeComponent component2(&engine, testFileUrl("refreshExpressionsRootContext.qml"));
-
- QDeclarativeContext context(engine.rootContext());
- QDeclarativeContext context2(engine.rootContext());
-
- QString warning = component2.url().toString() + QLatin1String(":4: ReferenceError: Can't find variable: unresolvedName");
-
- QObject *o1 = component.create(&context);
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QObject *o2 = component2.create(&context2);
-
- QCOMPARE(command.count, 3);
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QDeclarativeContextData::get(engine.rootContext())->refreshExpressions();
-
- QCOMPARE(command.count, 4);
-
- delete o2;
- delete o1;
-}
-
-void tst_qdeclarativecontext::qtbug_22535()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_22535.qml"));
- QDeclarativeContext context(engine.rootContext());
-
- QObject *o = component.create(&context);
-
- // Don't crash!
- delete o;
-}
-
-QTEST_MAIN(tst_qdeclarativecontext)
-
-#include "tst_qdeclarativecontext.moc"
diff --git a/tests/auto/declarative/qdeclarativecpputils/qdeclarativecpputils.pro b/tests/auto/declarative/qdeclarativecpputils/qdeclarativecpputils.pro
deleted file mode 100644
index 3cae5c25f3..0000000000
--- a/tests/auto/declarative/qdeclarativecpputils/qdeclarativecpputils.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativecpputils
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativecpputils.cpp
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativecpputils/tst_qdeclarativecpputils.cpp b/tests/auto/declarative/qdeclarativecpputils/tst_qdeclarativecpputils.cpp
deleted file mode 100644
index dbd877b2d5..0000000000
--- a/tests/auto/declarative/qdeclarativecpputils/tst_qdeclarativecpputils.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <qsignalspy.h>
-#include <private/qdeclarativeglobal_p.h>
-
-class tst_qdeclarativecpputils : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativecpputils() {}
-
-private slots:
- void fastConnect();
-};
-
-class MyObject : public QObject {
- Q_OBJECT
-public:
- MyObject() : slotCount(0) {}
- friend class tst_qdeclarativecpputils;
-
- int slotCount;
-
-signals:
- void signal1();
- void signal2();
-
-public slots:
- void slot1() { slotCount++; }
-};
-
-void tst_qdeclarativecpputils::fastConnect()
-{
- {
- MyObject *obj = new MyObject;
- FAST_CONNECT(obj, SIGNAL(signal1()), obj, SLOT(slot1()));
-
- obj->signal1();
- QCOMPARE(obj->slotCount, 1);
-
- delete obj;
- }
-
- {
- MyObject obj;
- FAST_CONNECT(&obj, SIGNAL(signal1()), &obj, SLOT(slot1()))
-
- obj.signal1();
- QCOMPARE(obj.slotCount, 1);
- }
-
- {
- MyObject *obj = new MyObject;
- QSignalSpy spy(obj, SIGNAL(signal2()));
- FAST_CONNECT(obj, SIGNAL(signal1()), obj, SIGNAL(signal2()));
-
- obj->signal1();
- QCOMPARE(spy.count(), 1);
-
- delete obj;
- }
-}
-
-QTEST_MAIN(tst_qdeclarativecpputils)
-
-#include "tst_qdeclarativecpputils.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.var.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.var.qml
deleted file mode 100644
index 7b4463773c..0000000000
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.var.qml
+++ /dev/null
@@ -1,23 +0,0 @@
-import QtQuick 2.0
-import Qt.test 1.0
-
-// In this example, a common syntax error will only be "caught"
-// when the function is called via:
-// QDeclarativeVMEMetaObject::metaCall->invokeMetaMethod()
-// We would like to ensure that a useful error message is printed.
-
-QtObject {
- id: root
- property MyScarceResourceObject a: MyScarceResourceObject { id: scarceResourceProvider }
- property var scarceResourceCopy;
- property string srp_name: a.toString();
-
- function retrieveScarceResource() {
- root.scarceResourceCopy = scarceResourceProvider.scarceResource(); // common syntax error, should throw exception
- }
-
- function releaseScarceResource() {
- root.scarceResourceCopy = null;
- }
-}
-
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.variant.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.variant.qml
deleted file mode 100644
index 45acc53e63..0000000000
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunctionFail.variant.qml
+++ /dev/null
@@ -1,23 +0,0 @@
-import QtQuick 2.0
-import Qt.test 1.0
-
-// In this example, a common syntax error will only be "caught"
-// when the function is called via:
-// QDeclarativeVMEMetaObject::metaCall->invokeMetaMethod()
-// We would like to ensure that a useful error message is printed.
-
-QtObject {
- id: root
- property MyScarceResourceObject a: MyScarceResourceObject { id: scarceResourceProvider }
- property variant scarceResourceCopy;
- property string srp_name: a.toString();
-
- function retrieveScarceResource() {
- root.scarceResourceCopy = scarceResourceProvider.scarceResource(); // common syntax error, should throw exception
- }
-
- function releaseScarceResource() {
- root.scarceResourceCopy = null;
- }
-}
-
diff --git a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro
deleted file mode 100644
index f4c2638f95..0000000000
--- a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeecmascript
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeecmascript.cpp \
- testtypes.cpp \
- ../../shared/testhttpserver.cpp
-HEADERS += testtypes.h \
- ../../shared/testhttpserver.h
-INCLUDEPATH += ../../shared
-
-include (../../shared/util.pri)
-
-# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
-# LIBS += -lgcov
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private network widgets testlib
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
deleted file mode 100644
index c8f50535ef..0000000000
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "testtypes.h"
-#include <QWidget>
-#include <QPlainTextEdit>
-#include <QDeclarativeEngine>
-#include <QJSEngine>
-
-class BaseExtensionObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int baseExtendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged)
-public:
- BaseExtensionObject(QObject *parent) : QObject(parent), m_value(0) {}
-
- int extendedProperty() const { return m_value; }
- void setExtendedProperty(int v) { m_value = v; emit extendedPropertyChanged(); }
-
-signals:
- void extendedPropertyChanged();
-private:
- int m_value;
-};
-
-class ExtensionObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int extendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged)
-public:
- ExtensionObject(QObject *parent) : QObject(parent), m_value(0) {}
-
- int extendedProperty() const { return m_value; }
- void setExtendedProperty(int v) { m_value = v; emit extendedPropertyChanged(); }
-
-signals:
- void extendedPropertyChanged();
-private:
- int m_value;
-};
-
-class DefaultPropertyExtensionObject : public QObject
-{
- Q_OBJECT
- Q_CLASSINFO("DefaultProperty", "firstProperty")
-public:
- DefaultPropertyExtensionObject(QObject *parent) : QObject(parent) {}
-};
-
-class QWidgetDeclarativeUI : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
-
-signals:
- void widthChanged();
-
-public:
- QWidgetDeclarativeUI(QObject *other) : QObject(other) { }
-
-public:
- int width() const { return 0; }
- void setWidth(int) { }
-};
-
-void MyQmlObject::v8function(QDeclarativeV8Function *args)
-{
- const char *error = "Exception thrown from within QObject slot";
- v8::ThrowException(v8::Exception::Error(v8::String::New(error)));
-}
-
-static QJSValue script_api(QDeclarativeEngine *engine, QJSEngine *scriptEngine)
-{
- Q_UNUSED(engine)
-
- static int testProperty = 13;
- QJSValue v = scriptEngine->newObject();
- v.setProperty("scriptTestProperty", testProperty++);
- return v;
-}
-
-static QJSValue readonly_script_api(QDeclarativeEngine *engine, QJSEngine *scriptEngine)
-{
- Q_UNUSED(engine)
-
- static int testProperty = 42;
- QJSValue v = scriptEngine->newObject();
- v.setProperty("scriptTestProperty", testProperty++);
-
- // now freeze it so that it's read-only
- QJSValue freezeFunction = scriptEngine->evaluate("(function(obj) { return Object.freeze(obj); })");
- v = freezeFunction.call(QJSValueList() << v);
-
- return v;
-}
-
-static QObject *qobject_api(QDeclarativeEngine *engine, QJSEngine *scriptEngine)
-{
- Q_UNUSED(engine)
- Q_UNUSED(scriptEngine)
-
- testQObjectApi *o = new testQObjectApi();
- o->setQObjectTestProperty(20);
- o->setQObjectTestWritableProperty(50);
- return o;
-}
-
-static QObject *qobject_api_engine_parent(QDeclarativeEngine *engine, QJSEngine *scriptEngine)
-{
- Q_UNUSED(scriptEngine)
-
- static int testProperty = 26;
- testQObjectApi *o = new testQObjectApi(engine);
- o->setQObjectTestProperty(testProperty++);
- return o;
-}
-
-void registerTypes()
-{
- qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObjectAlias");
- qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject");
- qmlRegisterType<MyDeferredObject>("Qt.test", 1,0, "MyDeferredObject");
- qmlRegisterType<MyQmlContainer>("Qt.test", 1,0, "MyQmlContainer");
- qmlRegisterExtendedType<MyBaseExtendedObject, BaseExtensionObject>("Qt.test", 1,0, "MyBaseExtendedObject");
- qmlRegisterExtendedType<MyExtendedObject, ExtensionObject>("Qt.test", 1,0, "MyExtendedObject");
- qmlRegisterType<MyTypeObject>("Qt.test", 1,0, "MyTypeObject");
- qmlRegisterType<MyDerivedObject>("Qt.test", 1,0, "MyDerivedObject");
- qmlRegisterType<NumberAssignment>("Qt.test", 1,0, "NumberAssignment");
- qmlRegisterExtendedType<DefaultPropertyExtendedObject, DefaultPropertyExtensionObject>("Qt.test", 1,0, "DefaultPropertyExtendedObject");
- qmlRegisterType<OverrideDefaultPropertyObject>("Qt.test", 1,0, "OverrideDefaultPropertyObject");
- qmlRegisterType<MyRevisionedClass>("Qt.test",1,0,"MyRevisionedClass");
- qmlRegisterType<MyDeleteObject>("Qt.test", 1,0, "MyDeleteObject");
- qmlRegisterType<MyRevisionedClass,1>("Qt.test",1,1,"MyRevisionedClass");
-
- // test scarce resource property binding post-evaluation optimisation
- // and for testing memory usage in property var circular reference test
- qmlRegisterType<ScarceResourceObject>("Qt.test", 1,0, "MyScarceResourceObject");
-
- // Register the uncreatable base class
- qmlRegisterRevision<MyRevisionedBaseClassRegistered,1>("Qt.test",1,1);
- // MyRevisionedSubclass 1.0 uses MyRevisionedClass revision 0
- qmlRegisterType<MyRevisionedSubclass>("Qt.test",1,0,"MyRevisionedSubclass");
- // MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1
- qmlRegisterType<MyRevisionedSubclass,1>("Qt.test",1,1,"MyRevisionedSubclass");
-
- qmlRegisterExtendedType<QWidget,QWidgetDeclarativeUI>("Qt.test",1,0,"QWidget");
- qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit");
-
- qRegisterMetaType<MyQmlObject::MyType>("MyQmlObject::MyType");
-
- qmlRegisterModuleApi("Qt.test",1,0,script_api); // register (script) module API for an existing uri which contains elements
- qmlRegisterModuleApi("Qt.test",1,0,qobject_api); // register (qobject) for an existing uri for which another module API was previously regd. Should replace!
- qmlRegisterModuleApi("Qt.test.scriptApi",1,0,script_api); // register (script) module API for a uri which doesn't contain elements
- qmlRegisterModuleApi("Qt.test.scriptApi",2,0,readonly_script_api); // register (script) module API for a uri which doesn't contain elements - will be made read-only
- qmlRegisterModuleApi("Qt.test.qobjectApi",1,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements
- qmlRegisterModuleApi("Qt.test.qobjectApi",1,3,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, minor version set
- qmlRegisterModuleApi("Qt.test.qobjectApi",2,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, major version set
- qmlRegisterModuleApi("Qt.test.qobjectApiParented",1,0,qobject_api_engine_parent); // register (parented qobject) module API for a uri which doesn't contain elements
-
- qRegisterMetaType<MyQmlObject::MyType>("MyEnum2");
- qRegisterMetaType<Qt::MouseButtons>("Qt::MouseButtons");
-
- qmlRegisterType<CircularReferenceObject>("Qt.test", 1, 0, "CircularReferenceObject");
- qmlRegisterType<CircularReferenceHandle>("Qt.test", 1, 0, "CircularReferenceHandle");
-
- qmlRegisterType<MyDynamicCreationDestructionObject>("Qt.test", 1, 0, "MyDynamicCreationDestructionObject");
- qmlRegisterType<WriteCounter>("Qt.test", 1, 0, "WriteCounter");
-
- qmlRegisterType<MySequenceConversionObject>("Qt.test", 1, 0, "MySequenceConversionObject");
-}
-
-#include "testtypes.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
deleted file mode 100644
index a463d3f64a..0000000000
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
+++ /dev/null
@@ -1,1311 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QtCore/qobject.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qsize.h>
-#include <QtDeclarative/qdeclarativelist.h>
-#include <QtCore/qrect.h>
-#include <QtGui/qmatrix.h>
-#include <QtGui/qcolor.h>
-#include <QtGui/qvector3d.h>
-#include <QtGui/QPixmap>
-#include <QtCore/qdatetime.h>
-#include <QtDeclarative/qjsvalue.h>
-#include <QtDeclarative/qdeclarativescriptstring.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-
-#include <private/qdeclarativeengine_p.h>
-#include <private/qv8engine_p.h>
-
-class MyQmlAttachedObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value CONSTANT)
- Q_PROPERTY(int value2 READ value2 WRITE setValue2 NOTIFY value2Changed)
-public:
- MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {}
-
- int value() const { return 19; }
- int value2() const { return m_value2; }
- void setValue2(int v) { if (m_value2 == v) return; m_value2 = v; emit value2Changed(); }
-
- void emitMySignal() { emit mySignal(); }
-
-signals:
- void value2Changed();
- void mySignal();
-
-private:
- int m_value2;
-};
-
-class MyQmlObject : public QObject
-{
- Q_OBJECT
- Q_ENUMS(MyEnum)
- Q_ENUMS(MyEnum2)
- Q_PROPERTY(int deleteOnSet READ deleteOnSet WRITE setDeleteOnSet)
- Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT)
- Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT)
- Q_PROPERTY(int value READ value WRITE setValue)
- Q_PROPERTY(int console READ console CONSTANT)
- Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
- Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty NOTIFY urlChanged)
- Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged)
- 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)
- Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty NOTIFY intChanged)
-
-public:
- MyQmlObject(): myinvokableObject(0), m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13), m_intProperty(0) {}
-
- enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
- enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
-
- bool trueProperty() const { return true; }
- bool falseProperty() const { return false; }
-
- QString stringProperty() const { return m_string; }
- void setStringProperty(const QString &s)
- {
- if (s == m_string)
- return;
- m_string = s;
- emit stringChanged();
- }
-
- QUrl urlProperty() const { return m_url; }
- void setUrlProperty(const QUrl &url)
- {
- if (url == m_url)
- return;
- m_url = url;
- emit urlChanged();
- }
-
- QObject *objectProperty() const { return m_object; }
- void setObjectProperty(QObject *obj) {
- if (obj == m_object)
- return;
- m_object = obj;
- emit objectChanged();
- }
-
- QDeclarativeListProperty<QObject> objectListProperty() { return QDeclarativeListProperty<QObject>(this, m_objectQList); }
-
- bool methodCalled() const { return m_methodCalled; }
- bool methodIntCalled() const { return m_methodIntCalled; }
-
- QString string() const { return m_string; }
-
- static MyQmlAttachedObject *qmlAttachedProperties(QObject *o) {
- return new MyQmlAttachedObject(o);
- }
-
- int deleteOnSet() const { return 1; }
- void setDeleteOnSet(int v) { if(v) delete this; }
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; }
-
- int resettableProperty() const { return m_resetProperty; }
- void setResettableProperty(int v) { m_resetProperty = v; }
- void resetProperty() { m_resetProperty = 13; }
-
- QRegExp regExp() { return m_regExp; }
- 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; }
-
- struct MyType {
- int value;
- };
- QVariant variant() const { return m_variant; }
- QJSValue qjsvalue() const { return m_qjsvalue; }
-
- int intProperty() const { return m_intProperty; }
- void setIntProperty(int i) { m_intProperty = i; emit intChanged(); }
-
-signals:
- void basicSignal();
- void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e);
- void stringChanged();
- void urlChanged();
- void objectChanged();
- void anotherBasicSignal();
- void thirdBasicSignal();
- void signalWithUnknownType(const MyQmlObject::MyType &arg);
- void signalWithVariant(const QVariant &arg);
- void signalWithQJSValue(const QJSValue &arg);
- void intChanged();
-
-public slots:
- void deleteMe() { delete this; }
- 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; }
- void variantMethod(const QVariant &v) { m_variant = v; }
- void qjsvalueMethod(const QJSValue &v) { m_qjsvalue = v; }
- void v8function(QDeclarativeV8Function*);
-
-private:
- friend class tst_qdeclarativeecmascript;
- bool m_methodCalled;
- bool m_methodIntCalled;
-
- QObject *m_object;
- QString m_string;
- QUrl m_url;
- QList<QObject *> m_objectQList;
- int m_value;
- int m_resetProperty;
- QRegExp m_regExp;
- QVariant m_variant;
- QJSValue m_qjsvalue;
- int m_intProperty;
-};
-
-QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
-
-class MyQmlContainer : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<MyQmlObject> children READ children CONSTANT)
-public:
- MyQmlContainer() {}
-
- QDeclarativeListProperty<MyQmlObject> children() { return QDeclarativeListProperty<MyQmlObject>(this, m_children); }
-
-private:
- QList<MyQmlObject*> m_children;
-};
-
-
-class MyExpression : public QDeclarativeExpression
-{
- Q_OBJECT
-public:
- MyExpression(QDeclarativeContext *ctxt, const QString &expr)
- : QDeclarativeExpression(ctxt, 0, expr), changed(false)
- {
- QObject::connect(this, SIGNAL(valueChanged()), this, SLOT(expressionValueChanged()));
- setNotifyOnValueChanged(true);
- }
-
- bool changed;
-
-public slots:
- void expressionValueChanged() {
- changed = true;
- }
-};
-
-
-class MyDefaultObject1 : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int horseLegs READ horseLegs CONSTANT)
- Q_PROPERTY(int antLegs READ antLegs CONSTANT)
- Q_PROPERTY(int emuLegs READ emuLegs CONSTANT)
-public:
- int horseLegs() const { return 4; }
- int antLegs() const { return 6; }
- int emuLegs() const { return 2; }
-};
-
-class MyDefaultObject3 : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int antLegs READ antLegs CONSTANT)
- Q_PROPERTY(int humanLegs READ humanLegs CONSTANT)
-public:
- int antLegs() const { return 7; } // Mutant
- int humanLegs() const { return 2; }
- int millipedeLegs() const { return 1000; }
-};
-
-class MyDeferredObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
- Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
- Q_PROPERTY(QObject *objectProperty2 READ objectProperty2 WRITE setObjectProperty2)
- Q_CLASSINFO("DeferredPropertyNames", "value,objectProperty,objectProperty2")
-
-public:
- MyDeferredObject() : m_value(0), m_object(0), m_object2(0) {}
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; emit valueChanged(); }
-
- QObject *objectProperty() const { return m_object; }
- void setObjectProperty(QObject *obj) { m_object = obj; }
-
- QObject *objectProperty2() const { return m_object2; }
- void setObjectProperty2(QObject *obj) { m_object2 = obj; }
-
-signals:
- void valueChanged();
-
-private:
- int m_value;
- QObject *m_object;
- QObject *m_object2;
-};
-
-class MyBaseExtendedObject : public QObject
-{
-Q_OBJECT
-Q_PROPERTY(int baseProperty READ baseProperty WRITE setBaseProperty)
-public:
- MyBaseExtendedObject() : m_value(0) {}
-
- int baseProperty() const { return m_value; }
- void setBaseProperty(int v) { m_value = v; }
-
-private:
- int m_value;
-};
-
-class MyExtendedObject : public MyBaseExtendedObject
-{
-Q_OBJECT
-Q_PROPERTY(int coreProperty READ coreProperty WRITE setCoreProperty)
-public:
- MyExtendedObject() : m_value(0) {}
-
- int coreProperty() const { return m_value; }
- void setCoreProperty(int v) { m_value = v; }
-
-private:
- int m_value;
-};
-
-class MyTypeObject : public QObject
-{
- Q_OBJECT
- Q_ENUMS(MyEnum)
- Q_FLAGS(MyFlags)
-
- Q_PROPERTY(QString id READ id WRITE setId)
- Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
- Q_PROPERTY(QDeclarativeComponent *componentProperty READ componentProperty WRITE setComponentProperty)
- Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty)
- Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty)
- Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
- Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty)
- Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty)
- Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty)
- Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty)
- Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty)
- Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty)
- Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty)
- Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty)
- Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty)
- Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty)
- Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty)
- Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty)
- Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty)
- Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged)
- Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2)
- Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty)
- Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty)
- Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty)
- Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty)
- Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty)
-
- Q_PROPERTY(QDeclarativeScriptString scriptProperty READ scriptProperty WRITE setScriptProperty)
-
-public:
- MyTypeObject()
- : objectPropertyValue(0), componentPropertyValue(0) {}
-
- QString idValue;
- QString id() const {
- return idValue;
- }
- void setId(const QString &v) {
- idValue = v;
- }
-
- QObject *objectPropertyValue;
- QObject *objectProperty() const {
- return objectPropertyValue;
- }
- void setObjectProperty(QObject *v) {
- objectPropertyValue = v;
- }
-
- QDeclarativeComponent *componentPropertyValue;
- QDeclarativeComponent *componentProperty() const {
- return componentPropertyValue;
- }
- void setComponentProperty(QDeclarativeComponent *v) {
- componentPropertyValue = v;
- }
-
- enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
- Q_DECLARE_FLAGS(MyFlags, MyFlag)
- MyFlags flagPropertyValue;
- MyFlags flagProperty() const {
- return flagPropertyValue;
- }
- void setFlagProperty(MyFlags v) {
- flagPropertyValue = v;
- }
-
- enum MyEnum { EnumVal1, EnumVal2 };
- MyEnum enumPropertyValue;
- MyEnum enumProperty() const {
- return enumPropertyValue;
- }
- void setEnumProperty(MyEnum v) {
- enumPropertyValue = v;
- }
-
- QString stringPropertyValue;
- QString stringProperty() const {
- return stringPropertyValue;
- }
- void setStringProperty(const QString &v) {
- stringPropertyValue = v;
- }
-
- uint uintPropertyValue;
- uint uintProperty() const {
- return uintPropertyValue;
- }
- void setUintProperty(const uint &v) {
- uintPropertyValue = v;
- }
-
- int intPropertyValue;
- int intProperty() const {
- return intPropertyValue;
- }
- void setIntProperty(const int &v) {
- intPropertyValue = v;
- }
-
- qreal realPropertyValue;
- qreal realProperty() const {
- return realPropertyValue;
- }
- void setRealProperty(const qreal &v) {
- realPropertyValue = v;
- }
-
- double doublePropertyValue;
- double doubleProperty() const {
- return doublePropertyValue;
- }
- void setDoubleProperty(const double &v) {
- doublePropertyValue = v;
- }
-
- float floatPropertyValue;
- float floatProperty() const {
- return floatPropertyValue;
- }
- void setFloatProperty(const float &v) {
- floatPropertyValue = v;
- }
-
- QColor colorPropertyValue;
- QColor colorProperty() const {
- return colorPropertyValue;
- }
- void setColorProperty(const QColor &v) {
- colorPropertyValue = v;
- }
-
- QDate datePropertyValue;
- QDate dateProperty() const {
- return datePropertyValue;
- }
- void setDateProperty(const QDate &v) {
- datePropertyValue = v;
- }
-
- QTime timePropertyValue;
- QTime timeProperty() const {
- return timePropertyValue;
- }
- void setTimeProperty(const QTime &v) {
- timePropertyValue = v;
- }
-
- QDateTime dateTimePropertyValue;
- QDateTime dateTimeProperty() const {
- return dateTimePropertyValue;
- }
- void setDateTimeProperty(const QDateTime &v) {
- dateTimePropertyValue = v;
- }
-
- QPoint pointPropertyValue;
- QPoint pointProperty() const {
- return pointPropertyValue;
- }
- void setPointProperty(const QPoint &v) {
- pointPropertyValue = v;
- }
-
- QPointF pointFPropertyValue;
- QPointF pointFProperty() const {
- return pointFPropertyValue;
- }
- void setPointFProperty(const QPointF &v) {
- pointFPropertyValue = v;
- }
-
- QSize sizePropertyValue;
- QSize sizeProperty() const {
- return sizePropertyValue;
- }
- void setSizeProperty(const QSize &v) {
- sizePropertyValue = v;
- }
-
- QSizeF sizeFPropertyValue;
- QSizeF sizeFProperty() const {
- return sizeFPropertyValue;
- }
- void setSizeFProperty(const QSizeF &v) {
- sizeFPropertyValue = v;
- }
-
- QRect rectPropertyValue;
- QRect rectProperty() const {
- return rectPropertyValue;
- }
- void setRectProperty(const QRect &v) {
- rectPropertyValue = v;
- emit rectPropertyChanged();
- }
-
- QRect rectPropertyValue2;
- QRect rectProperty2() const {
- return rectPropertyValue2;
- }
- void setRectProperty2(const QRect &v) {
- rectPropertyValue2 = v;
- }
-
- QRectF rectFPropertyValue;
- QRectF rectFProperty() const {
- return rectFPropertyValue;
- }
- void setRectFProperty(const QRectF &v) {
- rectFPropertyValue = v;
- }
-
- bool boolPropertyValue;
- bool boolProperty() const {
- return boolPropertyValue;
- }
- void setBoolProperty(const bool &v) {
- boolPropertyValue = v;
- }
-
- QVariant variantPropertyValue;
- QVariant variantProperty() const {
- return variantPropertyValue;
- }
- void setVariantProperty(const QVariant &v) {
- variantPropertyValue = v;
- }
-
- QVector3D vectorPropertyValue;
- QVector3D vectorProperty() const {
- return vectorPropertyValue;
- }
- void setVectorProperty(const QVector3D &v) {
- vectorPropertyValue = v;
- }
-
- QUrl urlPropertyValue;
- QUrl urlProperty() const {
- return urlPropertyValue;
- }
- void setUrlProperty(const QUrl &v) {
- urlPropertyValue = v;
- }
-
- QDeclarativeScriptString scriptPropertyValue;
- QDeclarativeScriptString scriptProperty() const {
- return scriptPropertyValue;
- }
- void setScriptProperty(const QDeclarativeScriptString &v) {
- scriptPropertyValue = v;
- }
-
- void doAction() { emit action(); }
-signals:
- void action();
- void rectPropertyChanged();
-};
-Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
-
-class MyDerivedObject : public MyTypeObject
-{
- Q_OBJECT
-public:
- Q_INVOKABLE bool intProperty() const {
- return true;
- }
-};
-
-Q_DECLARE_METATYPE(QJSValue);
-class MyInvokableBaseObject : public QObject
-{
- Q_OBJECT
-public:
- inline ~MyInvokableBaseObject() = 0;
-
- Q_INVOKABLE inline void method_inherited(int a);
- Q_INVOKABLE inline void method_overload();
-};
-
-class MyInvokableObject : public MyInvokableBaseObject
-{
- Q_OBJECT
- Q_ENUMS(TestEnum)
-public:
- enum TestEnum { EnumValue1, EnumValue2 };
- MyInvokableObject() { reset(); }
-
- int invoked() const { return m_invoked; }
- bool error() const { return m_invokedError; }
- const QVariantList &actuals() const { return m_actuals; }
- void reset() { m_invoked = -1; m_invokedError = false; m_actuals.clear(); }
-
- Q_INVOKABLE QPointF method_get_QPointF() { return QPointF(99.3, -10.2); }
- Q_INVOKABLE QPoint method_get_QPoint() { return QPoint(9, 12); }
-
- Q_INVOKABLE void method_NoArgs() { invoke(0); }
- Q_INVOKABLE int method_NoArgs_int() { invoke(1); return 6; }
- Q_INVOKABLE qreal method_NoArgs_real() { invoke(2); return 19.75; }
- Q_INVOKABLE QPointF method_NoArgs_QPointF() { invoke(3); return QPointF(123, 4.5); }
- Q_INVOKABLE QObject *method_NoArgs_QObject() { invoke(4); return this; }
- Q_INVOKABLE MyInvokableObject *method_NoArgs_unknown() { invoke(5); return this; }
- Q_INVOKABLE QJSValue method_NoArgs_QScriptValue() { invoke(6); return QJSValue("Hello world"); }
- Q_INVOKABLE QVariant method_NoArgs_QVariant() { invoke(7); return QVariant("QML rocks"); }
-
- Q_INVOKABLE void method_int(int a) { invoke(8); m_actuals << a; }
- Q_INVOKABLE void method_intint(int a, int b) { invoke(9); m_actuals << a << b; }
- Q_INVOKABLE void method_real(qreal a) { invoke(10); m_actuals << a; }
- Q_INVOKABLE void method_QString(QString a) { invoke(11); m_actuals << a; }
- Q_INVOKABLE void method_QPointF(QPointF a) { invoke(12); m_actuals << a; }
- Q_INVOKABLE void method_QObject(QObject *a) { invoke(13); m_actuals << qVariantFromValue(a); }
- Q_INVOKABLE void method_QScriptValue(QJSValue a) { invoke(14); m_actuals << qVariantFromValue(a); }
- Q_INVOKABLE void method_intQScriptValue(int a, QJSValue b) { invoke(15); m_actuals << a << qVariantFromValue(b); }
-
- Q_INVOKABLE void method_overload(int a) { invoke(16); m_actuals << a; }
- Q_INVOKABLE void method_overload(int a, int b) { invoke(17); m_actuals << a << b; }
- Q_INVOKABLE void method_overload(QString a) { invoke(18); m_actuals << a; }
-
- Q_INVOKABLE void method_with_enum(TestEnum e) { invoke(19); m_actuals << (int)e; }
-
- Q_INVOKABLE int method_default(int a, int b = 19) { invoke(20); m_actuals << a << b; return b; }
-
- Q_INVOKABLE void method_QVariant(QVariant a, QVariant b = QVariant()) { invoke(21); m_actuals << a << b; }
-
-private:
- friend class MyInvokableBaseObject;
- void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;}
- int m_invoked;
- bool m_invokedError;
- QVariantList m_actuals;
-};
-
-MyInvokableBaseObject::~MyInvokableBaseObject() {}
-
-void MyInvokableBaseObject::method_inherited(int a)
-{
- static_cast<MyInvokableObject *>(this)->invoke(-3);
- static_cast<MyInvokableObject *>(this)->m_actuals << a;
-}
-
-// This is a hidden overload of the MyInvokableObject::method_overload() method
-void MyInvokableBaseObject::method_overload()
-{
- static_cast<MyInvokableObject *>(this)->invoke(-2);
-}
-
-class NumberAssignment : public QObject
-{
- Q_OBJECT
-public:
- 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)
- qreal _test2;
- qreal test2() const { return _test2; }
- void setTest2(qreal v) { _test2 = v; }
-
- 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)
- qreal _test4;
- qreal test4() const { return _test4; }
- void setTest4(qreal v) { _test4 = v; }
-
- 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)
- int _test6;
- int test6() const { return _test6; }
- void setTest6(int v) { _test6 = v; }
-
- 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)
- int _test8;
- int test8() const { return _test8; }
- void setTest8(int v) { _test8 = v; }
-
- 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)
- 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)
- 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)
- unsigned int _test12;
- unsigned int test12() const { return _test12; }
- void setTest12(unsigned int v) { _test12 = v; }
-};
-
-class DefaultPropertyExtendedObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QObject *firstProperty READ firstProperty WRITE setFirstProperty)
- Q_PROPERTY(QObject *secondProperty READ secondProperty WRITE setSecondProperty)
-public:
- DefaultPropertyExtendedObject(QObject *parent = 0) : QObject(parent), m_firstProperty(0), m_secondProperty(0) {}
-
- QObject *firstProperty() const { return m_firstProperty; }
- QObject *secondProperty() const { return m_secondProperty; }
- void setFirstProperty(QObject *property) { m_firstProperty = property; }
- void setSecondProperty(QObject *property) { m_secondProperty = property; }
-private:
- QObject* m_firstProperty;
- QObject* m_secondProperty;
-};
-
-class OverrideDefaultPropertyObject : public DefaultPropertyExtendedObject
-{
- Q_OBJECT
- Q_CLASSINFO("DefaultProperty", "secondProperty")
-public:
- OverrideDefaultPropertyObject() {}
-};
-
-class MyRevisionedBaseClassRegistered : public QObject
-{
-Q_OBJECT
- Q_PROPERTY(qreal propA READ propA WRITE setPropA NOTIFY propAChanged)
- Q_PROPERTY(qreal propB READ propB WRITE setPropB NOTIFY propBChanged REVISION 1)
-
-public:
- MyRevisionedBaseClassRegistered() : m_pa(1), m_pb(2) {}
-
- qreal propA() const { return m_pa; }
- void setPropA(qreal p) {
- if (p != m_pa) {
- m_pa = p;
- emit propAChanged();
- }
- }
- qreal propB() const { return m_pb; }
- void setPropB(qreal p) {
- if (p != m_pb) {
- m_pb = p;
- emit propBChanged();
- }
- }
-
- Q_INVOKABLE void methodA() { }
- Q_INVOKABLE Q_REVISION(1) void methodB() { }
-
-signals:
- void propAChanged();
- void propBChanged();
-
- void signalA();
- Q_REVISION(1) void signalB();
-
-protected:
- qreal m_pa;
- qreal m_pb;
-};
-
-class MyRevisionedBaseClassUnregistered : public MyRevisionedBaseClassRegistered
-{
-Q_OBJECT
- Q_PROPERTY(qreal propC READ propC WRITE setPropC NOTIFY propCChanged)
- Q_PROPERTY(qreal propD READ propD WRITE setPropD NOTIFY propDChanged REVISION 1)
-
-public:
- MyRevisionedBaseClassUnregistered() : m_pc(1), m_pd(2) {}
-
- qreal propC() const { return m_pc; }
- void setPropC(qreal p) {
- if (p != m_pc) {
- m_pc = p;
- emit propCChanged();
- }
- }
- qreal propD() const { return m_pd; }
- void setPropD(qreal p) {
- if (p != m_pd) {
- m_pd = p;
- emit propDChanged();
- }
- }
-
- Q_INVOKABLE void methodC() { }
- Q_INVOKABLE Q_REVISION(1) void methodD() { }
-
-signals:
- void propCChanged();
- void propDChanged();
-
- void signalC();
- Q_REVISION(1) void signalD();
-
-protected:
- qreal m_pc;
- qreal m_pd;
-};
-
-class MyRevisionedClass : public MyRevisionedBaseClassUnregistered
-{
- Q_OBJECT
- Q_PROPERTY(qreal prop1 READ prop1 WRITE setProp1 NOTIFY prop1Changed)
- Q_PROPERTY(qreal prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed REVISION 1)
-
-public:
- MyRevisionedClass() {}
-
- qreal prop1() const { return m_p1; }
- void setProp1(qreal p) {
- if (p != m_p1) {
- m_p1 = p;
- emit prop1Changed();
- }
- }
- qreal prop2() const { return m_p2; }
- void setProp2(qreal p) {
- if (p != m_p2) {
- m_p2 = p;
- emit prop2Changed();
- }
- }
-
- Q_INVOKABLE void method1() { }
- Q_INVOKABLE Q_REVISION(1) void method2() { }
-
-signals:
- void prop1Changed();
- void prop2Changed();
-
- void signal1();
- Q_REVISION(1) void signal2();
-
-protected:
- qreal m_p1;
- qreal m_p2;
-};
-
-class MyRevisionedSubclass : public MyRevisionedClass
-{
- Q_OBJECT
- Q_PROPERTY(qreal prop3 READ prop3 WRITE setProp3 NOTIFY prop3Changed)
- Q_PROPERTY(qreal prop4 READ prop4 WRITE setProp4 NOTIFY prop4Changed REVISION 1)
-
-public:
- MyRevisionedSubclass() : m_p3(3), m_p4(4) {}
-
- qreal prop3() const { return m_p3; }
- void setProp3(qreal p) {
- if (p != m_p3) {
- m_p3 = p;
- emit prop3Changed();
- }
- }
- qreal prop4() const { return m_p4; }
- void setProp4(qreal p) {
- if (p != m_p4) {
- m_p4 = p;
- emit prop4Changed();
- }
- }
-
- Q_INVOKABLE void method3() { }
- Q_INVOKABLE Q_REVISION(1) void method4() { }
-
-signals:
- void prop3Changed();
- void prop4Changed();
-
- void signal3();
- Q_REVISION(1) void signal4();
-
-protected:
- qreal m_p3;
- qreal m_p4;
-};
-
-QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered)
-QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered)
-QML_DECLARE_TYPE(MyRevisionedClass)
-QML_DECLARE_TYPE(MyRevisionedSubclass)
-Q_DECLARE_METATYPE(MyQmlObject::MyType)
-
-
-class ScarceResourceObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QPixmap scarceResource READ scarceResource WRITE setScarceResource NOTIFY scarceResourceChanged)
-public:
- ScarceResourceObject(QObject *parent = 0) : QObject(parent), m_value(100, 100) { m_value.fill(Qt::blue); }
- ~ScarceResourceObject() {}
-
- QPixmap scarceResource() const { return m_value; }
- void setScarceResource(QPixmap v) { m_value = v; emit scarceResourceChanged(); }
-
- bool scarceResourceIsDetached() const { return m_value.isDetached(); }
-
- // this particular one returns a new one each time
- // this means that every Scarce Resource Copy will
- // consume resources (so that we can track disposal
- // of v8 handles with circular references).
- Q_INVOKABLE QPixmap newScarceResource() const
- {
- QPixmap retn(800, 600);
- retn.fill(QColor(100, 110, 120, 45));
- return retn;
- }
-
-signals:
- void scarceResourceChanged();
-
-private:
- QPixmap m_value;
-};
-QML_DECLARE_TYPE(ScarceResourceObject)
-
-class testQObjectApi : public QObject
-{
- Q_OBJECT
- Q_ENUMS(MyEnum)
- Q_PROPERTY (int qobjectTestProperty READ qobjectTestProperty NOTIFY qobjectTestPropertyChanged)
- Q_PROPERTY (int qobjectTestWritableProperty READ qobjectTestWritableProperty WRITE setQObjectTestWritableProperty NOTIFY qobjectTestWritablePropertyChanged)
-
-public:
- testQObjectApi(QObject* parent = 0)
- : QObject(parent), m_testProperty(0), m_testWritableProperty(0), m_methodCallCount(0)
- {
- }
-
- ~testQObjectApi() {}
-
- enum MyEnum { EnumValue1 = 25, EnumValue2 = 42 };
- Q_INVOKABLE int qobjectEnumTestMethod(MyEnum val) { return (static_cast<int>(val) + 5); }
- Q_INVOKABLE int qobjectTestMethod(int increment = 1) { m_methodCallCount += increment; return m_methodCallCount; }
-
- int qobjectTestProperty() const { return m_testProperty; }
- void setQObjectTestProperty(int tp) { m_testProperty = tp; emit qobjectTestPropertyChanged(tp); }
-
- int qobjectTestWritableProperty() const { return m_testWritableProperty; }
- void setQObjectTestWritableProperty(int tp) { m_testWritableProperty = tp; emit qobjectTestWritablePropertyChanged(tp); }
-
-signals:
- void qobjectTestPropertyChanged(int testProperty);
- void qobjectTestWritablePropertyChanged(int testWritableProperty);
-
-private:
- int m_testProperty;
- int m_testWritableProperty;
- int m_methodCallCount;
-};
-
-class CircularReferenceObject : public QObject,
- public QV8GCCallback::Node
-{
- Q_OBJECT
-
-public:
- CircularReferenceObject(QObject *parent = 0)
- : QObject(parent), QV8GCCallback::Node(callback), m_referenced(0), m_dtorCount(0)
- {
- QV8GCCallback::addGcCallbackNode(this);
- }
-
- ~CircularReferenceObject()
- {
- if (m_dtorCount) *m_dtorCount = *m_dtorCount + 1;
- }
-
- Q_INVOKABLE void setDtorCount(int *dtorCount)
- {
- m_dtorCount = dtorCount;
- }
-
- Q_INVOKABLE CircularReferenceObject *generate(QObject *parent = 0)
- {
- CircularReferenceObject *retn = new CircularReferenceObject(parent);
- retn->m_dtorCount = m_dtorCount;
- retn->m_engine = m_engine;
- return retn;
- }
-
- Q_INVOKABLE void addReference(QObject *other)
- {
- m_referenced = other;
- }
-
- static void callback(QV8GCCallback::Node *n)
- {
- CircularReferenceObject *cro = static_cast<CircularReferenceObject*>(n);
- if (cro->m_referenced) {
- cro->m_engine->addRelationshipForGC(cro, cro->m_referenced);
- }
- }
-
- void setEngine(QDeclarativeEngine* declarativeEngine)
- {
- m_engine = QDeclarativeEnginePrivate::get(declarativeEngine)->v8engine();
- }
-
-private:
- QObject *m_referenced;
- int *m_dtorCount;
- QV8Engine* m_engine;
-};
-Q_DECLARE_METATYPE(CircularReferenceObject*)
-
-class CircularReferenceHandle : public QObject,
- public QV8GCCallback::Node
-{
- Q_OBJECT
-
-public:
- CircularReferenceHandle(QObject *parent = 0)
- : QObject(parent), QV8GCCallback::Node(gccallback), m_dtorCount(0), m_engine(0)
- {
- QV8GCCallback::addGcCallbackNode(this);
- }
-
- ~CircularReferenceHandle()
- {
- if (m_dtorCount) *m_dtorCount = *m_dtorCount + 1;
- }
-
- Q_INVOKABLE void setDtorCount(int *dtorCount)
- {
- m_dtorCount = dtorCount;
- }
-
- Q_INVOKABLE CircularReferenceHandle *generate(QObject *parent = 0)
- {
- CircularReferenceHandle *retn = new CircularReferenceHandle(parent);
- retn->m_dtorCount = m_dtorCount;
- retn->m_engine = m_engine;
- return retn;
- }
-
- Q_INVOKABLE void addReference(v8::Persistent<v8::Value> handle)
- {
- m_referenced = qPersistentNew(handle);
- m_referenced.MakeWeak(static_cast<void*>(this), wrcallback);
- }
-
- static void wrcallback(v8::Persistent<v8::Value> handle, void *params)
- {
- CircularReferenceHandle *crh = static_cast<CircularReferenceHandle*>(params);
- qPersistentDispose(handle);
- crh->m_referenced.Clear();
- }
-
- static void gccallback(QV8GCCallback::Node *n)
- {
- CircularReferenceHandle *crh = static_cast<CircularReferenceHandle*>(n);
- crh->m_engine->addRelationshipForGC(crh, crh->m_referenced);
- }
-
- void setEngine(QDeclarativeEngine* declarativeEngine)
- {
- m_engine = QDeclarativeEnginePrivate::get(declarativeEngine)->v8engine();
- }
-
-private:
- v8::Persistent<v8::Value> m_referenced;
- int *m_dtorCount;
- QV8Engine* m_engine;
-};
-Q_DECLARE_METATYPE(CircularReferenceHandle*)
-
-class MyDynamicCreationDestructionObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY (int intProperty READ intProperty WRITE setIntProperty NOTIFY intPropertyChanged)
-
-public:
- MyDynamicCreationDestructionObject(QObject *parent = 0) : QObject(parent), m_intProperty(0), m_dtorCount(0)
- {
- }
-
- ~MyDynamicCreationDestructionObject()
- {
- if (m_dtorCount) {
- (*m_dtorCount)++;
- }
- }
-
- int intProperty() const { return m_intProperty; }
- void setIntProperty(int val) { m_intProperty = val; emit intPropertyChanged(); }
-
- Q_INVOKABLE MyDynamicCreationDestructionObject *createNew()
- {
- // no parent == ownership transfers to JS; same dtor counter.
- MyDynamicCreationDestructionObject *retn = new MyDynamicCreationDestructionObject;
- retn->setDtorCount(m_dtorCount);
- return retn;
- }
-
- void setDtorCount(int *dtorCount)
- {
- m_dtorCount = dtorCount;
- }
-
-signals:
- void intPropertyChanged();
-
-private:
- int m_intProperty;
- int *m_dtorCount;
-};
-
-class WriteCounter : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue);
-public:
- WriteCounter() : m_value(0), m_count(0) {}
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; ++m_count; }
-
- int count() const { return m_count; }
-
-private:
- int m_value;
- int m_count;
-};
-
-class MySequenceConversionObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY (QList<int> intListProperty READ intListProperty WRITE setIntListProperty NOTIFY intListPropertyChanged)
- Q_PROPERTY (QList<int> intListProperty2 READ intListProperty2 WRITE setIntListProperty2 NOTIFY intListProperty2Changed)
- Q_PROPERTY (QList<qreal> qrealListProperty READ qrealListProperty WRITE setQrealListProperty NOTIFY qrealListPropertyChanged)
- Q_PROPERTY (QList<bool> boolListProperty READ boolListProperty WRITE setBoolListProperty NOTIFY boolListPropertyChanged)
- Q_PROPERTY (QList<QString> stringListProperty READ stringListProperty WRITE setStringListProperty NOTIFY stringListPropertyChanged)
- Q_PROPERTY (QList<QUrl> urlListProperty READ urlListProperty WRITE setUrlListProperty NOTIFY urlListPropertyChanged)
- Q_PROPERTY (QStringList qstringListProperty READ qstringListProperty WRITE setQStringListProperty NOTIFY qstringListPropertyChanged)
-
- Q_PROPERTY (QList<QPoint> pointListProperty READ pointListProperty WRITE setPointListProperty NOTIFY pointListPropertyChanged)
- Q_PROPERTY (QList<QVariant> variantListProperty READ variantListProperty WRITE setVariantListProperty NOTIFY variantListPropertyChanged)
-
- Q_PROPERTY (qint32 maxIndex READ maxIndex CONSTANT)
- Q_PROPERTY (quint32 tooBigIndex READ tooBigIndex CONSTANT)
- Q_PROPERTY (qint32 negativeIndex READ negativeIndex CONSTANT)
-
-public:
- MySequenceConversionObject()
- {
- m_intList << 1 << 2 << 3 << 4;
- m_intList2 << 1 << 2 << 3 << 4;
- m_qrealList << 1.1 << 2.2 << 3.3 << 4.4;
- m_boolList << true << false << true << false;
- m_stringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
- m_urlList << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com");
- m_qstringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
-
- m_pointList << QPoint(1, 2) << QPoint(3, 4) << QPoint(5, 6);
- m_variantList << QVariant(QLatin1String("one")) << QVariant(true) << QVariant(3);
- }
-
- ~MySequenceConversionObject() {}
-
- qint32 maxIndex() const
- {
- return INT_MAX;
- }
- quint32 tooBigIndex() const
- {
- quint32 retn = 7;
- retn += INT_MAX;
- return retn;
- }
- qint32 negativeIndex() const
- {
- return -5;
- }
-
- QList<int> intListProperty() const { return m_intList; }
- void setIntListProperty(const QList<int> &list) { m_intList = list; emit intListPropertyChanged(); }
- QList<int> intListProperty2() const { return m_intList2; }
- void setIntListProperty2(const QList<int> &list) { m_intList2 = list; emit intListProperty2Changed(); }
- QList<qreal> qrealListProperty() const { return m_qrealList; }
- void setQrealListProperty(const QList<qreal> &list) { m_qrealList = list; emit qrealListPropertyChanged(); }
- QList<bool> boolListProperty() const { return m_boolList; }
- void setBoolListProperty(const QList<bool> &list) { m_boolList = list; emit boolListPropertyChanged(); }
- QList<QString> stringListProperty() const { return m_stringList; }
- void setStringListProperty(const QList<QString> &list) { m_stringList = list; emit stringListPropertyChanged(); }
- QList<QUrl> urlListProperty() const { return m_urlList; }
- void setUrlListProperty(const QList<QUrl> &list) { m_urlList = list; emit urlListPropertyChanged(); }
- QStringList qstringListProperty() const { return m_qstringList; }
- void setQStringListProperty(const QStringList &list) { m_qstringList = list; emit qstringListPropertyChanged(); }
- QList<QPoint> pointListProperty() const { return m_pointList; }
- void setPointListProperty(const QList<QPoint> &list) { m_pointList = list; emit pointListPropertyChanged(); }
- QList<QVariant> variantListProperty() const { return m_variantList; }
- void setVariantListProperty(const QList<QVariant> &list) { m_variantList = list; emit variantListPropertyChanged(); }
-
- // now for "copy resource" sequences:
- Q_INVOKABLE QList<int> generateIntSequence() const { QList<int> retn; retn << 1 << 2 << 3; return retn; }
- Q_INVOKABLE QList<qreal> generateQrealSequence() const { QList<qreal> retn; retn << 1.1 << 2.2 << 3.3; return retn; }
- Q_INVOKABLE QList<bool> generateBoolSequence() const { QList<bool> retn; retn << true << false << true; return retn; }
- Q_INVOKABLE QList<QString> generateStringSequence() const { QList<QString> retn; retn << "one" << "two" << "three"; return retn; }
- Q_INVOKABLE QList<QUrl> generateUrlSequence() const { QList<QUrl> retn; retn << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com"); return retn; }
- Q_INVOKABLE QStringList generateQStringSequence() const { QStringList retn; retn << "one" << "two" << "three"; return retn; }
-
- // "reference resource" underlying qobject deletion test:
- Q_INVOKABLE MySequenceConversionObject *generateTestObject() const { return new MySequenceConversionObject; }
- Q_INVOKABLE void deleteTestObject(QObject *object) const { delete object; }
-
-signals:
- void intListPropertyChanged();
- void intListProperty2Changed();
- void qrealListPropertyChanged();
- void boolListPropertyChanged();
- void stringListPropertyChanged();
- void urlListPropertyChanged();
- void qstringListPropertyChanged();
- void pointListPropertyChanged();
- void variantListPropertyChanged();
-
-private:
- QList<int> m_intList;
- QList<int> m_intList2;
- QList<qreal> m_qrealList;
- QList<bool> m_boolList;
- QList<QString> m_stringList;
- QList<QUrl> m_urlList;
- QStringList m_qstringList;
-
- QList<QPoint> m_pointList; // not a supported sequence type
- QList<QVariant> m_variantList; // not a supported sequence type, but QVariantList support is hardcoded.
-};
-
-class MyDeleteObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QObject *nestedObject READ nestedObject NOTIFY nestedObjectChanged);
- Q_PROPERTY(int deleteNestedObject READ deleteNestedObject NOTIFY deleteNestedObjectChanged);
-
-public:
- MyDeleteObject() : m_nestedObject(new MyQmlObject) {}
-
- QObject *nestedObject() const { return m_nestedObject; }
- int deleteNestedObject() { delete m_nestedObject; m_nestedObject = 0; return 1; }
-
-signals:
- void nestedObjectChanged();
- void deleteNestedObjectChanged();
-
-private:
- MyQmlObject *m_nestedObject;
-};
-
-void registerTypes();
-
-#endif // TESTTYPES_H
-
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
deleted file mode 100644
index d30766f982..0000000000
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ /dev/null
@@ -1,6062 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qdebug.h>
-#include <QtDeclarative/private/qdeclarativeguard_p.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qnumeric.h>
-#include <private/qdeclarativeengine_p.h>
-#include <private/qdeclarativevmemetaobject_p.h>
-#include <private/qv4compiler_p.h>
-#include "testtypes.h"
-#include "testhttpserver.h"
-#include "../../shared/util.h"
-
-/*
-This test covers evaluation of ECMAScript expressions and bindings from within
-QML. This does not include static QML language issues.
-
-Static QML language issues are covered in qmllanguage
-*/
-
-class tst_qdeclarativeecmascript : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeecmascript() {}
-
-private slots:
- void initTestCase();
- void assignBasicTypes();
- void idShortcutInvalidates();
- void boolPropertiesEvaluateAsBool();
- void methods();
- void signalAssignment();
- void bindingLoop();
- void basicExpressions();
- void basicExpressions_data();
- void arrayExpressions();
- void contextPropertiesTriggerReeval();
- void objectPropertiesTriggerReeval();
- void deferredProperties();
- void deferredPropertiesErrors();
- void extensionObjects();
- void overrideExtensionProperties();
- void attachedProperties();
- void enums();
- void valueTypeFunctions();
- void constantsOverrideBindings();
- void outerBindingOverridesInnerBinding();
- void aliasPropertyAndBinding();
- void aliasPropertyReset();
- void nonExistentAttachedObject();
- void scope();
- void importScope();
- void signalParameterTypes();
- void objectsCompareAsEqual();
- void dynamicCreation_data();
- void dynamicCreation();
- void dynamicDestruction();
- void objectToString();
- void objectHasOwnProperty();
- void selfDeletingBinding();
- void extendedObjectPropertyLookup();
- void extendedObjectPropertyLookup2();
- void scriptErrors();
- void functionErrors();
- void propertyAssignmentErrors();
- void signalTriggeredBindings();
- void listProperties();
- void exceptionClearsOnReeval();
- void exceptionSlotProducesWarning();
- void exceptionBindingProducesWarning();
- void compileInvalidBinding();
- void transientErrors();
- void shutdownErrors();
- void compositePropertyType();
- void jsObject();
- void undefinedResetsProperty();
- void listToVariant();
- void listAssignment();
- void multiEngineObject();
- void deletedObject();
- void attachedPropertyScope();
- void scriptConnect();
- void scriptDisconnect();
- void ownership();
- void cppOwnershipReturnValue();
- void ownershipCustomReturnValue();
- void qlistqobjectMethods();
- void strictlyEquals();
- void compiled();
- void numberAssignment();
- void propertySplicing();
- void signalWithUnknownTypes();
- void signalWithJSValueInVariant_data();
- void signalWithJSValueInVariant();
- void signalWithJSValueInVariant_twoEngines_data();
- void signalWithJSValueInVariant_twoEngines();
- void signalWithQJSValue_data();
- void signalWithQJSValue();
- void moduleApi_data();
- void moduleApi();
- void importScripts_data();
- void importScripts();
- void scarceResources();
- void scarceResources_data();
- void scarceResources_other();
- void propertyChangeSlots();
- void propertyVar_data();
- void propertyVar();
- void propertyVarCpp();
- void propertyVarOwnership();
- void propertyVarImplicitOwnership();
- void propertyVarReparent();
- void propertyVarReparentNullContext();
- void propertyVarCircular();
- void propertyVarCircular2();
- void propertyVarInheritance();
- void propertyVarInheritance2();
- void elementAssign();
- void objectPassThroughSignals();
- void objectConversion();
- void booleanConversion();
- void handleReferenceManagement();
- void stringArg();
- void readonlyDeclaration();
- void sequenceConversionRead();
- void sequenceConversionWrite();
- void sequenceConversionArray();
- void sequenceConversionIndexes();
- void sequenceConversionThreads();
- void sequenceConversionBindings();
- void sequenceConversionCopy();
- void assignSequenceTypes();
- void qtbug_22464();
- void qtbug_21580();
-
- void bug1();
- void bug2();
- void dynamicCreationCrash();
- void dynamicCreationOwnership();
- void regExpBug();
- void nullObjectBinding();
- void deletedEngine();
- void libraryScriptAssert();
- void variantsAssignedUndefined();
- void qtbug_9792();
- void qtcreatorbug_1289();
- void noSpuriousWarningsAtShutdown();
- void canAssignNullToQObject();
- void functionAssignment_fromBinding();
- void functionAssignment_fromJS();
- void functionAssignment_fromJS_data();
- void functionAssignmentfromJS_invalid();
- void eval();
- void function();
- void functionException();
- void qtbug_10696();
- void qtbug_11606();
- void qtbug_11600();
- void qtbug_21864();
- void qobjectConnectionListExceptionHandling();
- void nonscriptable();
- void deleteLater();
- void in();
- void typeOf();
- void sharedAttachedObject();
- void objectName();
- void writeRemovesBinding();
- void aliasBindingsAssignCorrectly();
- void aliasBindingsOverrideTarget();
- void aliasWritesOverrideBindings();
- void aliasToCompositeElement();
- void realToInt();
- void urlProperty();
- void urlPropertyWithEncoding();
- void urlListPropertyWithEncoding();
- void dynamicString();
- void include();
- void signalHandlers();
- void doubleEvaluate();
- void forInLoop();
- void nonNotifyable();
- void deleteWhileBindingRunning();
- void callQtInvokables();
- void invokableObjectArg();
- void invokableObjectRet();
- void qtbug_20344();
- void qtbug_22679();
- void qtbug_22843_data();
- void qtbug_22843();
- void rewriteMultiLineStrings();
- void revisionErrors();
- void revision();
- void invokableWithQObjectDerived();
-
- void automaticSemicolon();
- void unaryExpression();
- void switchStatement();
- void withStatement();
- void tryStatement();
-
-private:
- static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
- QDeclarativeEngine engine;
-};
-
-void tst_qdeclarativeecmascript::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- registerTypes();
-}
-
-void tst_qdeclarativeecmascript::assignBasicTypes()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignBasicTypes.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
- QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
- QCOMPARE(object->stringProperty(), QString("Hello World!"));
- QCOMPARE(object->uintProperty(), uint(10));
- QCOMPARE(object->intProperty(), -19);
- QCOMPARE((float)object->realProperty(), float(23.2));
- QCOMPARE((float)object->doubleProperty(), float(-19.75));
- QCOMPARE((float)object->floatProperty(), float(8.5));
- QCOMPARE(object->colorProperty(), QColor("red"));
- QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
- QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
- QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
- QCOMPARE(object->pointProperty(), QPoint(99,13));
- QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
- QCOMPARE(object->sizeProperty(), QSize(99, 13));
- QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
- QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
- QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
- QCOMPARE(object->boolProperty(), true);
- QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
- QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
- QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml")));
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignBasicTypes.2.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
- QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
- QCOMPARE(object->stringProperty(), QString("Hello World!"));
- QCOMPARE(object->uintProperty(), uint(10));
- QCOMPARE(object->intProperty(), -19);
- QCOMPARE((float)object->realProperty(), float(23.2));
- QCOMPARE((float)object->doubleProperty(), float(-19.75));
- QCOMPARE((float)object->floatProperty(), float(8.5));
- QCOMPARE(object->colorProperty(), QColor("red"));
- QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
- QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
- QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
- QCOMPARE(object->pointProperty(), QPoint(99,13));
- QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
- QCOMPARE(object->sizeProperty(), QSize(99, 13));
- QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
- QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
- QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
- QCOMPARE(object->boolProperty(), true);
- QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
- QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
- QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml")));
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::idShortcutInvalidates()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("idShortcutInvalidates.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->objectProperty() != 0);
- delete object->objectProperty();
- QVERIFY(object->objectProperty() == 0);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("idShortcutInvalidates.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->objectProperty() != 0);
- delete object->objectProperty();
- QVERIFY(object->objectProperty() == 0);
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::boolPropertiesEvaluateAsBool()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("boolPropertiesEvaluateAsBool.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->stringProperty(), QLatin1String("pass"));
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("boolPropertiesEvaluateAsBool.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->stringProperty(), QLatin1String("pass"));
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::signalAssignment()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("signalAssignment.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->string(), QString());
- emit object->basicSignal();
- QCOMPARE(object->string(), QString("pass"));
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("signalAssignment.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->string(), QString());
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25 3 2"));
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::methods()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("methods.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->methodCalled(), false);
- QCOMPARE(object->methodIntCalled(), false);
- emit object->basicSignal();
- QCOMPARE(object->methodCalled(), true);
- QCOMPARE(object->methodIntCalled(), false);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("methods.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->methodCalled(), false);
- QCOMPARE(object->methodIntCalled(), false);
- emit object->basicSignal();
- QCOMPARE(object->methodCalled(), false);
- QCOMPARE(object->methodIntCalled(), true);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("methods.3.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toInt(), 19);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("methods.4.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toInt(), 19);
- QCOMPARE(object->property("test2").toInt(), 17);
- QCOMPARE(object->property("test3").toInt(), 16);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("methods.5.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toInt(), 9);
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::bindingLoop()
-{
- QDeclarativeComponent component(&engine, testFileUrl("bindingLoop.qml"));
- QString warning = component.url().toString() + ":5:9: QML MyQmlObject: Binding loop detected for property \"stringProperty\"";
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativeecmascript::basicExpressions_data()
-{
- QTest::addColumn<QString>("expression");
- QTest::addColumn<QVariant>("result");
- QTest::addColumn<bool>("nest");
-
- QTest::newRow("Syntax error (self test)") << "{console.log({'a':1'}.a)}" << QVariant() << false;
- QTest::newRow("Context property") << "a" << QVariant(1944) << false;
- QTest::newRow("Context property") << "a" << QVariant(1944) << true;
- QTest::newRow("Context property expression") << "a * 2" << QVariant(3888) << false;
- QTest::newRow("Context property expression") << "a * 2" << QVariant(3888) << true;
- QTest::newRow("Overridden context property") << "b" << QVariant("Milk") << false;
- QTest::newRow("Overridden context property") << "b" << QVariant("Cow") << true;
- QTest::newRow("Object property") << "object.stringProperty" << QVariant("Object1") << false;
- QTest::newRow("Object property") << "object.stringProperty" << QVariant("Object1") << true;
- QTest::newRow("Overridden object property") << "objectOverride.stringProperty" << QVariant("Object2") << false;
- QTest::newRow("Overridden object property") << "objectOverride.stringProperty" << QVariant("Object3") << true;
- QTest::newRow("Default object property") << "horseLegs" << QVariant(4) << false;
- QTest::newRow("Default object property") << "antLegs" << QVariant(6) << false;
- QTest::newRow("Default object property") << "emuLegs" << QVariant(2) << false;
- QTest::newRow("Nested default object property") << "horseLegs" << QVariant(4) << true;
- QTest::newRow("Nested default object property") << "antLegs" << QVariant(7) << true;
- QTest::newRow("Nested default object property") << "emuLegs" << QVariant(2) << true;
- QTest::newRow("Nested default object property") << "humanLegs" << QVariant(2) << true;
- QTest::newRow("Context property override default object property") << "millipedeLegs" << QVariant(100) << true;
-}
-
-void tst_qdeclarativeecmascript::basicExpressions()
-{
- QFETCH(QString, expression);
- QFETCH(QVariant, result);
- QFETCH(bool, nest);
-
- MyQmlObject object1;
- MyQmlObject object2;
- MyQmlObject object3;
- MyDefaultObject1 default1;
- MyDefaultObject3 default3;
- object1.setStringProperty("Object1");
- object2.setStringProperty("Object2");
- object3.setStringProperty("Object3");
-
- QDeclarativeContext context(engine.rootContext());
- QDeclarativeContext nestedContext(&context);
-
- context.setContextObject(&default1);
- context.setContextProperty("a", QVariant(1944));
- context.setContextProperty("b", QVariant("Milk"));
- context.setContextProperty("object", &object1);
- context.setContextProperty("objectOverride", &object2);
- nestedContext.setContextObject(&default3);
- nestedContext.setContextProperty("b", QVariant("Cow"));
- nestedContext.setContextProperty("objectOverride", &object3);
- nestedContext.setContextProperty("millipedeLegs", QVariant(100));
-
- MyExpression expr(nest?&nestedContext:&context, expression);
- QCOMPARE(expr.evaluate(), result);
-}
-
-void tst_qdeclarativeecmascript::arrayExpressions()
-{
- QObject obj1;
- QObject obj2;
- QObject obj3;
-
- QDeclarativeContext context(engine.rootContext());
- context.setContextProperty("a", &obj1);
- context.setContextProperty("b", &obj2);
- context.setContextProperty("c", &obj3);
-
- MyExpression expr(&context, "[a, b, c, 10]");
- QVariant result = expr.evaluate();
- QCOMPARE(result.userType(), qMetaTypeId<QList<QObject *> >());
- QList<QObject *> list = qvariant_cast<QList<QObject *> >(result);
- QCOMPARE(list.count(), 4);
- QCOMPARE(list.at(0), &obj1);
- QCOMPARE(list.at(1), &obj2);
- QCOMPARE(list.at(2), &obj3);
- QCOMPARE(list.at(3), (QObject *)0);
-}
-
-// Tests that modifying a context property will reevaluate expressions
-void tst_qdeclarativeecmascript::contextPropertiesTriggerReeval()
-{
- QDeclarativeContext context(engine.rootContext());
- MyQmlObject object1;
- MyQmlObject object2;
- MyQmlObject *object3 = new MyQmlObject;
-
- object1.setStringProperty("Hello");
- object2.setStringProperty("World");
-
- context.setContextProperty("testProp", QVariant(1));
- context.setContextProperty("testObj", &object1);
- context.setContextProperty("testObj2", object3);
-
- {
- MyExpression expr(&context, "testProp + 1");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.evaluate(), QVariant(2));
-
- context.setContextProperty("testProp", QVariant(2));
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.evaluate(), QVariant(3));
- }
-
- {
- MyExpression expr(&context, "testProp + testProp + testProp");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.evaluate(), QVariant(6));
-
- context.setContextProperty("testProp", QVariant(4));
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.evaluate(), QVariant(12));
- }
-
- {
- MyExpression expr(&context, "testObj.stringProperty");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.evaluate(), QVariant("Hello"));
-
- context.setContextProperty("testObj", &object2);
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.evaluate(), QVariant("World"));
- }
-
- {
- MyExpression expr(&context, "testObj.stringProperty /**/");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.evaluate(), QVariant("World"));
-
- context.setContextProperty("testObj", &object1);
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.evaluate(), QVariant("Hello"));
- }
-
- {
- MyExpression expr(&context, "testObj2");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.evaluate(), QVariant::fromValue((QObject *)object3));
- }
-
- delete object3;
-}
-
-void tst_qdeclarativeecmascript::objectPropertiesTriggerReeval()
-{
- QDeclarativeContext context(engine.rootContext());
- MyQmlObject object1;
- MyQmlObject object2;
- MyQmlObject object3;
- context.setContextProperty("testObj", &object1);
-
- object1.setStringProperty(QLatin1String("Hello"));
- object2.setStringProperty(QLatin1String("Dog"));
- object3.setStringProperty(QLatin1String("Cat"));
-
- {
- MyExpression expr(&context, "testObj.stringProperty");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.evaluate(), QVariant("Hello"));
-
- object1.setStringProperty(QLatin1String("World"));
- QCOMPARE(expr.changed, true);
- QCOMPARE(expr.evaluate(), QVariant("World"));
- }
-
- {
- MyExpression expr(&context, "testObj.objectProperty.stringProperty");
- QCOMPARE(expr.changed, false);
- QCOMPARE(expr.evaluate(), QVariant());
-
- object1.setObjectProperty(&object2);
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.evaluate(), QVariant("Dog"));
-
- object1.setObjectProperty(&object3);
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.evaluate(), QVariant("Cat"));
-
- object1.setObjectProperty(0);
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.evaluate(), QVariant());
-
- object1.setObjectProperty(&object3);
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.evaluate(), QVariant("Cat"));
-
- object3.setStringProperty("Donkey");
- QCOMPARE(expr.changed, true);
- expr.changed = false;
- QCOMPARE(expr.evaluate(), QVariant("Donkey"));
- }
-}
-
-void tst_qdeclarativeecmascript::deferredProperties()
-{
- QDeclarativeComponent component(&engine, testFileUrl("deferredProperties.qml"));
- MyDeferredObject *object =
- qobject_cast<MyDeferredObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->value(), 0);
- QVERIFY(object->objectProperty() == 0);
- QVERIFY(object->objectProperty2() != 0);
- qmlExecuteDeferred(object);
- QCOMPARE(object->value(), 10);
- QVERIFY(object->objectProperty() != 0);
- MyQmlObject *qmlObject =
- qobject_cast<MyQmlObject *>(object->objectProperty());
- QVERIFY(qmlObject != 0);
- QCOMPARE(qmlObject->value(), 10);
- object->setValue(19);
- QCOMPARE(qmlObject->value(), 19);
-
- delete object;
-}
-
-// Check errors on deferred properties are correctly emitted
-void tst_qdeclarativeecmascript::deferredPropertiesErrors()
-{
- QDeclarativeComponent component(&engine, testFileUrl("deferredPropertiesErrors.qml"));
- MyDeferredObject *object =
- qobject_cast<MyDeferredObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->value(), 0);
- QVERIFY(object->objectProperty() == 0);
- QVERIFY(object->objectProperty2() == 0);
-
- QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject*";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- qmlExecuteDeferred(object);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::extensionObjects()
-{
- QDeclarativeComponent component(&engine, testFileUrl("extensionObjects.qml"));
- MyExtendedObject *object =
- qobject_cast<MyExtendedObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->baseProperty(), 13);
- QCOMPARE(object->coreProperty(), 9);
- object->setProperty("extendedProperty", QVariant(11));
- object->setProperty("baseExtendedProperty", QVariant(92));
- QCOMPARE(object->coreProperty(), 11);
- QCOMPARE(object->baseProperty(), 92);
-
- MyExtendedObject *nested = qobject_cast<MyExtendedObject*>(qvariant_cast<QObject *>(object->property("nested")));
- QVERIFY(nested);
- QCOMPARE(nested->baseProperty(), 13);
- QCOMPARE(nested->coreProperty(), 9);
- nested->setProperty("extendedProperty", QVariant(11));
- nested->setProperty("baseExtendedProperty", QVariant(92));
- QCOMPARE(nested->coreProperty(), 11);
- QCOMPARE(nested->baseProperty(), 92);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::overrideExtensionProperties()
-{
- QDeclarativeComponent component(&engine, testFileUrl("extensionObjectsPropertyOverride.qml"));
- OverrideDefaultPropertyObject *object =
- qobject_cast<OverrideDefaultPropertyObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->secondProperty() != 0);
- QVERIFY(object->firstProperty() == 0);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::attachedProperties()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("attachedProperty.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("a").toInt(), 19);
- QCOMPARE(object->property("b").toInt(), 19);
- QCOMPARE(object->property("c").toInt(), 19);
- QCOMPARE(object->property("d").toInt(), 19);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("attachedProperty.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("a").toInt(), 26);
- QCOMPARE(object->property("b").toInt(), 26);
- QCOMPARE(object->property("c").toInt(), 26);
- QCOMPARE(object->property("d").toInt(), 26);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("writeAttachedProperty.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QMetaObject::invokeMethod(object, "writeValue2");
-
- MyQmlAttachedObject *attached =
- qobject_cast<MyQmlAttachedObject *>(qmlAttachedPropertiesObject<MyQmlObject>(object));
- QVERIFY(attached != 0);
-
- QCOMPARE(attached->value2(), 9);
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::enums()
-{
- // Existent enums
- {
- QDeclarativeComponent component(&engine, testFileUrl("enums.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("a").toInt(), 0);
- QCOMPARE(object->property("b").toInt(), 1);
- QCOMPARE(object->property("c").toInt(), 2);
- QCOMPARE(object->property("d").toInt(), 3);
- QCOMPARE(object->property("e").toInt(), 0);
- QCOMPARE(object->property("f").toInt(), 1);
- QCOMPARE(object->property("g").toInt(), 2);
- QCOMPARE(object->property("h").toInt(), 3);
- QCOMPARE(object->property("i").toInt(), 19);
- QCOMPARE(object->property("j").toInt(), 19);
-
- delete object;
- }
- // Non-existent enums
- {
- QDeclarativeComponent component(&engine, testFileUrl("enums.2.qml"));
-
- QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int";
- QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("a").toInt(), 0);
- QCOMPARE(object->property("b").toInt(), 0);
-
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::valueTypeFunctions()
-{
- QDeclarativeComponent component(&engine, testFileUrl("valueTypeFunctions.qml"));
- MyTypeObject *obj = qobject_cast<MyTypeObject*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->rectProperty(), QRect(0,0,100,100));
- QCOMPARE(obj->rectFProperty(), QRectF(0,0.5,100,99.5));
-
- delete obj;
-}
-
-/*
-Tests that writing a constant to a property with a binding on it disables the
-binding.
-*/
-void tst_qdeclarativeecmascript::constantsOverrideBindings()
-{
- // From ECMAScript
- {
- QDeclarativeComponent component(&engine, testFileUrl("constantsOverrideBindings.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c2").toInt(), 0);
- object->setProperty("c1", QVariant(9));
- QCOMPARE(object->property("c2").toInt(), 9);
-
- emit object->basicSignal();
-
- QCOMPARE(object->property("c2").toInt(), 13);
- object->setProperty("c1", QVariant(8));
- QCOMPARE(object->property("c2").toInt(), 13);
-
- delete object;
- }
-
- // During construction
- {
- QDeclarativeComponent component(&engine, testFileUrl("constantsOverrideBindings.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c1").toInt(), 0);
- QCOMPARE(object->property("c2").toInt(), 10);
- object->setProperty("c1", QVariant(9));
- QCOMPARE(object->property("c1").toInt(), 9);
- QCOMPARE(object->property("c2").toInt(), 10);
-
- delete object;
- }
-
-#if 0
- // From C++
- {
- QDeclarativeComponent component(&engine, testFileUrl("constantsOverrideBindings.3.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c2").toInt(), 0);
- object->setProperty("c1", QVariant(9));
- QCOMPARE(object->property("c2").toInt(), 9);
-
- object->setProperty("c2", QVariant(13));
- QCOMPARE(object->property("c2").toInt(), 13);
- object->setProperty("c1", QVariant(7));
- QCOMPARE(object->property("c1").toInt(), 7);
- QCOMPARE(object->property("c2").toInt(), 13);
-
- delete object;
- }
-#endif
-
- // Using an alias
- {
- QDeclarativeComponent component(&engine, testFileUrl("constantsOverrideBindings.4.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c1").toInt(), 0);
- QCOMPARE(object->property("c3").toInt(), 10);
- object->setProperty("c1", QVariant(9));
- QCOMPARE(object->property("c1").toInt(), 9);
- QCOMPARE(object->property("c3").toInt(), 10);
-
- delete object;
- }
-}
-
-/*
-Tests that assigning a binding to a property that already has a binding causes
-the original binding to be disabled.
-*/
-void tst_qdeclarativeecmascript::outerBindingOverridesInnerBinding()
-{
- QDeclarativeComponent component(&engine,
- testFileUrl("outerBindingOverridesInnerBinding.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c1").toInt(), 0);
- QCOMPARE(object->property("c2").toInt(), 0);
- QCOMPARE(object->property("c3").toInt(), 0);
-
- object->setProperty("c1", QVariant(9));
- QCOMPARE(object->property("c1").toInt(), 9);
- QCOMPARE(object->property("c2").toInt(), 0);
- QCOMPARE(object->property("c3").toInt(), 0);
-
- object->setProperty("c3", QVariant(8));
- QCOMPARE(object->property("c1").toInt(), 9);
- QCOMPARE(object->property("c2").toInt(), 8);
- QCOMPARE(object->property("c3").toInt(), 8);
-
- delete object;
-}
-
-/*
-Access a non-existent attached object.
-
-Tests for a regression where this used to crash.
-*/
-void tst_qdeclarativeecmascript::nonExistentAttachedObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("nonExistentAttachedObject.qml"));
-
- QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::scope()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("scope.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toInt(), 1);
- QCOMPARE(object->property("test2").toInt(), 2);
- QCOMPARE(object->property("test3").toString(), QString("1Test"));
- QCOMPARE(object->property("test4").toString(), QString("2Test"));
- QCOMPARE(object->property("test5").toInt(), 1);
- QCOMPARE(object->property("test6").toInt(), 1);
- QCOMPARE(object->property("test7").toInt(), 2);
- QCOMPARE(object->property("test8").toInt(), 2);
- QCOMPARE(object->property("test9").toInt(), 1);
- QCOMPARE(object->property("test10").toInt(), 3);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scope.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toInt(), 19);
- QCOMPARE(object->property("test2").toInt(), 19);
- QCOMPARE(object->property("test3").toInt(), 14);
- QCOMPARE(object->property("test4").toInt(), 14);
- QCOMPARE(object->property("test5").toInt(), 24);
- QCOMPARE(object->property("test6").toInt(), 24);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scope.3.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
- QCOMPARE(object->property("test3").toBool(), true);
-
- delete object;
- }
-
- // Signal argument scope
- {
- QDeclarativeComponent component(&engine, testFileUrl("scope.4.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 0);
- QCOMPARE(object->property("test2").toString(), QString());
-
- emit object->argumentSignal(13, "Argument Scope", 9, MyQmlObject::EnumValue4, Qt::RightButton);
-
- QCOMPARE(object->property("test").toInt(), 13);
- QCOMPARE(object->property("test2").toString(), QString("Argument Scope"));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scope.5.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scope.6.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-}
-
-// In 4.7, non-library javascript files that had no imports shared the imports of their
-// importing context
-void tst_qdeclarativeecmascript::importScope()
-{
- QDeclarativeComponent component(&engine, testFileUrl("importScope.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toInt(), 240);
-
- delete o;
-}
-
-/*
-Tests that "any" type passes through a synthesized signal parameter. This
-is essentially a test of QDeclarativeMetaType::copy()
-*/
-void tst_qdeclarativeecmascript::signalParameterTypes()
-{
- QDeclarativeComponent component(&engine, testFileUrl("signalParameterTypes.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- emit object->basicSignal();
-
- QCOMPARE(object->property("intProperty").toInt(), 10);
- QCOMPARE(object->property("realProperty").toReal(), 19.2);
- QVERIFY(object->property("colorProperty").value<QColor>() == QColor(255, 255, 0, 255));
- QVERIFY(object->property("variantProperty") == QVariant::fromValue(QColor(255, 0, 255, 255)));
- QVERIFY(object->property("enumProperty") == MyQmlObject::EnumValue3);
- QVERIFY(object->property("qtEnumProperty") == Qt::LeftButton);
-
- delete object;
-}
-
-/*
-Test that two JS objects for the same QObject compare as equal.
-*/
-void tst_qdeclarativeecmascript::objectsCompareAsEqual()
-{
- QDeclarativeComponent component(&engine, testFileUrl("objectsCompareAsEqual.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
- QCOMPARE(object->property("test3").toBool(), true);
- QCOMPARE(object->property("test4").toBool(), true);
- QCOMPARE(object->property("test5").toBool(), true);
-
- delete object;
-}
-
-/*
-Confirm bindings and alias properties can coexist.
-
-Tests for a regression where the binding would not reevaluate.
-*/
-void tst_qdeclarativeecmascript::aliasPropertyAndBinding()
-{
- QDeclarativeComponent component(&engine, testFileUrl("aliasPropertyAndBinding.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("c2").toInt(), 3);
- QCOMPARE(object->property("c3").toInt(), 3);
-
- object->setProperty("c2", QVariant(19));
-
- QCOMPARE(object->property("c2").toInt(), 19);
- QCOMPARE(object->property("c3").toInt(), 19);
-
- delete object;
-}
-
-/*
-Ensure that we can write undefined value to an alias property,
-and that the aliased property is reset correctly if possible.
-*/
-void tst_qdeclarativeecmascript::aliasPropertyReset()
-{
- QObject *object = 0;
-
- // test that a manual write (of undefined) to a resettable aliased property succeeds
- QDeclarativeComponent c1(&engine, testFileUrl("aliasreset/aliasPropertyReset.1.qml"));
- object = c1.create();
- QVERIFY(object != 0);
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() != 0);
- QCOMPARE(object->property("aliasIsUndefined"), QVariant(false));
- QMetaObject::invokeMethod(object, "resetAliased");
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 0);
- QCOMPARE(object->property("aliasIsUndefined"), QVariant(true));
- delete object;
-
- // test that a manual write (of undefined) to a resettable alias property succeeds
- QDeclarativeComponent c2(&engine, testFileUrl("aliasreset/aliasPropertyReset.2.qml"));
- object = c2.create();
- QVERIFY(object != 0);
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() != 0);
- QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(false));
- QMetaObject::invokeMethod(object, "resetAlias");
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 0);
- QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(true));
- delete object;
-
- // test that an alias to a bound property works correctly
- QDeclarativeComponent c3(&engine, testFileUrl("aliasreset/aliasPropertyReset.3.qml"));
- object = c3.create();
- QVERIFY(object != 0);
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() != 0);
- QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(false));
- QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false));
- QMetaObject::invokeMethod(object, "resetAlias");
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 0);
- QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(true));
- QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false));
- delete object;
-
- // test that a manual write (of undefined) to a resettable alias property
- // whose aliased property's object has been deleted, does not crash.
- QDeclarativeComponent c4(&engine, testFileUrl("aliasreset/aliasPropertyReset.4.qml"));
- object = c4.create();
- QVERIFY(object != 0);
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() != 0);
- QObject *loader = object->findChild<QObject*>("loader");
- QVERIFY(loader != 0);
- delete loader;
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 0); // deletion should have caused value unset.
- QMetaObject::invokeMethod(object, "resetAlias"); // shouldn't crash.
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 0);
- QMetaObject::invokeMethod(object, "setAlias"); // shouldn't crash, and shouldn't change value (since it's no longer referencing anything).
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 0);
- delete object;
-
- // test that binding an alias property to an undefined value works correctly
- QDeclarativeComponent c5(&engine, testFileUrl("aliasreset/aliasPropertyReset.5.qml"));
- object = c5.create();
- QVERIFY(object != 0);
- QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 0); // bound to undefined value.
- delete object;
-
- // test that a manual write (of undefined) to a non-resettable property fails properly
- QUrl url = testFileUrl("aliasreset/aliasPropertyReset.error.1.qml");
- QString warning1 = url.toString() + QLatin1String(":15: Error: Cannot assign [undefined] to int");
- QDeclarativeComponent e1(&engine, url);
- object = e1.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("intAlias").value<int>(), 12);
- QCOMPARE(object->property("aliasedIntIsUndefined"), QVariant(false));
- QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
- QMetaObject::invokeMethod(object, "resetAlias");
- QCOMPARE(object->property("intAlias").value<int>(), 12);
- QCOMPARE(object->property("aliasedIntIsUndefined"), QVariant(false));
- delete object;
-}
-
-void tst_qdeclarativeecmascript::dynamicCreation_data()
-{
- QTest::addColumn<QString>("method");
- QTest::addColumn<QString>("createdName");
-
- QTest::newRow("One") << "createOne" << "objectOne";
- QTest::newRow("Two") << "createTwo" << "objectTwo";
- QTest::newRow("Three") << "createThree" << "objectThree";
-}
-
-/*
-Test using createQmlObject to dynamically generate an item
-Also using createComponent is tested.
-*/
-void tst_qdeclarativeecmascript::dynamicCreation()
-{
- QFETCH(QString, method);
- QFETCH(QString, createdName);
-
- QDeclarativeComponent component(&engine, testFileUrl("dynamicCreation.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-
- QMetaObject::invokeMethod(object, method.toUtf8());
- QObject *created = object->objectProperty();
- QVERIFY(created);
- QCOMPARE(created->objectName(), createdName);
-
- delete object;
-}
-
-/*
- Tests the destroy function
-*/
-void tst_qdeclarativeecmascript::dynamicDestruction()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("dynamicDeletion.qml"));
- QDeclarativeGuard<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- QDeclarativeGuard<QObject> createdQmlObject = 0;
-
- QMetaObject::invokeMethod(object, "create");
- createdQmlObject = object->objectProperty();
- QVERIFY(createdQmlObject);
- QCOMPARE(createdQmlObject->objectName(), QString("emptyObject"));
-
- QMetaObject::invokeMethod(object, "killOther");
- QVERIFY(createdQmlObject);
-
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QVERIFY(createdQmlObject);
- for (int ii = 0; createdQmlObject && ii < 50; ++ii) { // After 5 seconds we should give up
- if (createdQmlObject) {
- QTest::qWait(100);
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- }
- }
- QVERIFY(!createdQmlObject);
-
- QDeclarativeEngine::setObjectOwnership(object, QDeclarativeEngine::JavaScriptOwnership);
- QMetaObject::invokeMethod(object, "killMe");
- QVERIFY(object);
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QVERIFY(!object);
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("dynamicDeletion.2.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0);
-
- QMetaObject::invokeMethod(o, "create");
-
- QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) != 0);
-
- QMetaObject::invokeMethod(o, "destroy");
-
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-
- QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0);
-
- delete o;
- }
-}
-
-/*
- tests that id.toString() works
-*/
-void tst_qdeclarativeecmascript::objectToString()
-{
- QDeclarativeComponent component(&engine, testFileUrl("declarativeToString.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "testToString");
- QVERIFY(object->stringProperty().startsWith("MyQmlObject_QML_"));
- QVERIFY(object->stringProperty().endsWith(", \"objName\")"));
-
- delete object;
-}
-
-/*
- tests that id.hasOwnProperty() works
-*/
-void tst_qdeclarativeecmascript::objectHasOwnProperty()
-{
- QUrl url = testFileUrl("declarativeHasOwnProperty.qml");
- QString warning1 = url.toString() + ":59: TypeError: Cannot call method 'hasOwnProperty' of undefined";
- QString warning2 = url.toString() + ":64: TypeError: Cannot call method 'hasOwnProperty' of undefined";
- QString warning3 = url.toString() + ":69: TypeError: Cannot call method 'hasOwnProperty' of undefined";
-
- QDeclarativeComponent component(&engine, url);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- // test QObjects in QML
- QMetaObject::invokeMethod(object, "testHasOwnPropertySuccess");
- QVERIFY(object->property("result").value<bool>() == true);
- QMetaObject::invokeMethod(object, "testHasOwnPropertyFailure");
- QVERIFY(object->property("result").value<bool>() == false);
-
- // now test other types in QML
- QObject *child = object->findChild<QObject*>("typeObj");
- QVERIFY(child != 0);
- QMetaObject::invokeMethod(child, "testHasOwnPropertySuccess");
- QCOMPARE(child->property("valueTypeHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("valueTypeHasOwnProperty2").toBool(), true);
- QCOMPARE(child->property("variantTypeHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("stringTypeHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("listTypeHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("emptyListTypeHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("enumTypeHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("typenameHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("typenameHasOwnProperty2").toBool(), true);
- QCOMPARE(child->property("moduleApiTypeHasOwnProperty").toBool(), true);
- QCOMPARE(child->property("moduleApiPropertyTypeHasOwnProperty").toBool(), true);
-
- QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
- QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureOne");
- QCOMPARE(child->property("enumNonValueHasOwnProperty").toBool(), false);
- QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
- QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureTwo");
- QCOMPARE(child->property("moduleApiNonPropertyHasOwnProperty").toBool(), false);
- QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
- QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureThree");
- QCOMPARE(child->property("listAtInvalidHasOwnProperty").toBool(), false);
-
- delete object;
-}
-
-/*
-Tests bindings that indirectly cause their own deletion work.
-
-This test is best run under valgrind to ensure no invalid memory access occur.
-*/
-void tst_qdeclarativeecmascript::selfDeletingBinding()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("selfDeletingBinding.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- object->setProperty("triggerDelete", true);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("selfDeletingBinding.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- object->setProperty("triggerDelete", true);
- delete object;
- }
-}
-
-/*
-Test that extended object properties can be accessed.
-
-This test a regression where this used to crash. The issue was specificially
-for extended objects that did not include a synthesized meta object (so non-root
-and no synthesiszed properties).
-*/
-void tst_qdeclarativeecmascript::extendedObjectPropertyLookup()
-{
- QDeclarativeComponent component(&engine, testFileUrl("extendedObjectPropertyLookup.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-/*
-Test that extended object properties can be accessed correctly.
-*/
-void tst_qdeclarativeecmascript::extendedObjectPropertyLookup2()
-{
- QDeclarativeComponent component(&engine, testFileUrl("extendedObjectPropertyLookup2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVariant returnValue;
- QVERIFY(QMetaObject::invokeMethod(object, "getValue", Q_RETURN_ARG(QVariant, returnValue)));
- QCOMPARE(returnValue.toInt(), 42);
-
- delete object;
-}
-/*
-Test file/lineNumbers for binding/Script errors.
-*/
-void tst_qdeclarativeecmascript::scriptErrors()
-{
- QDeclarativeComponent component(&engine, testFileUrl("scriptErrors.qml"));
- QString url = component.url().toString();
-
- QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\"";
- QString warning2 = url + ":5: ReferenceError: Can't find variable: a";
- QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\"";
- QString warning4 = url + ":13: ReferenceError: Can't find variable: a";
- QString warning5 = url + ":11: ReferenceError: Can't find variable: a";
- QString warning6 = url + ":10: Unable to assign [undefined] to int";
- QString warning7 = url + ":15: Error: Cannot assign to read-only property \"trueProperty\"";
- QString warning8 = url + ":16: Error: Cannot assign to non-existent property \"fakeProperty\"";
-
- QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning5.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning6.toLatin1().constData());
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QTest::ignoreMessage(QtWarningMsg, warning4.toLatin1().constData());
- emit object->basicSignal();
-
- QTest::ignoreMessage(QtWarningMsg, warning7.toLatin1().constData());
- emit object->anotherBasicSignal();
-
- QTest::ignoreMessage(QtWarningMsg, warning8.toLatin1().constData());
- emit object->thirdBasicSignal();
-
- delete object;
-}
-
-/*
-Test file/lineNumbers for inline functions.
-*/
-void tst_qdeclarativeecmascript::functionErrors()
-{
- QDeclarativeComponent component(&engine, testFileUrl("functionErrors.qml"));
- QString url = component.url().toString();
-
- QString warning = url + ":5: Error: Invalid write to global property \"a\"";
-
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
-
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-
- // test that if an exception occurs while invoking js function from cpp, it is reported as expected.
- QDeclarativeComponent componentTwo(&engine, testFileUrl("scarceResourceFunctionFail.var.qml"));
- url = componentTwo.url().toString();
- object = componentTwo.create();
- QVERIFY(object != 0);
-
- QString srpname = object->property("srp_name").toString();
-
- warning = url + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srpname
- + QLatin1String(" is not a function");
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); // we expect a meaningful warning to be printed.
- QMetaObject::invokeMethod(object, "retrieveScarceResource");
- delete object;
-}
-
-/*
-Test various errors that can occur when assigning a property from script
-*/
-void tst_qdeclarativeecmascript::propertyAssignmentErrors()
-{
- QDeclarativeComponent component(&engine, testFileUrl("propertyAssignmentErrors.qml"));
-
- QString url = component.url().toString();
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
-
- delete object;
-}
-
-/*
-Test bindings still work when the reeval is triggered from within
-a signal script.
-*/
-void tst_qdeclarativeecmascript::signalTriggeredBindings()
-{
- QDeclarativeComponent component(&engine, testFileUrl("signalTriggeredBindings.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("base").toReal(), 50.);
- QCOMPARE(object->property("test1").toReal(), 50.);
- QCOMPARE(object->property("test2").toReal(), 50.);
-
- object->basicSignal();
-
- QCOMPARE(object->property("base").toReal(), 200.);
- QCOMPARE(object->property("test1").toReal(), 200.);
- QCOMPARE(object->property("test2").toReal(), 200.);
-
- object->argumentSignal(10, QString(), 10, MyQmlObject::EnumValue4, Qt::RightButton);
-
- QCOMPARE(object->property("base").toReal(), 400.);
- QCOMPARE(object->property("test1").toReal(), 400.);
- QCOMPARE(object->property("test2").toReal(), 400.);
-
- delete object;
-}
-
-/*
-Test that list properties can be iterated from ECMAScript
-*/
-void tst_qdeclarativeecmascript::listProperties()
-{
- QDeclarativeComponent component(&engine, testFileUrl("listProperties.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toInt(), 21);
- QCOMPARE(object->property("test2").toInt(), 2);
- QCOMPARE(object->property("test3").toBool(), true);
- QCOMPARE(object->property("test4").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::exceptionClearsOnReeval()
-{
- QDeclarativeComponent component(&engine, testFileUrl("exceptionClearsOnReeval.qml"));
- QString url = component.url().toString();
-
- QString warning = url + ":4: TypeError: Cannot read property 'objectProperty' of null";
-
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), false);
-
- MyQmlObject object2;
- MyQmlObject object3;
- object2.setObjectProperty(&object3);
- object->setObjectProperty(&object2);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::exceptionSlotProducesWarning()
-{
- QDeclarativeComponent component(&engine, testFileUrl("exceptionProducesWarning.qml"));
- QString url = component.url().toString();
-
- QString warning = component.url().toString() + ":6: Error: JS exception";
-
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativeecmascript::exceptionBindingProducesWarning()
-{
- QDeclarativeComponent component(&engine, testFileUrl("exceptionProducesWarning2.qml"));
- QString url = component.url().toString();
-
- QString warning = component.url().toString() + ":5: Error: JS exception";
-
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativeecmascript::compileInvalidBinding()
-{
- // QTBUG-23387: ensure that invalid bindings don't cause a crash.
- QDeclarativeComponent component(&engine, testFileUrl("v8bindingException.qml"));
- QString warning = component.url().toString() + ":16: SyntaxError: Unexpected token ILLEGAL";
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-static int transientErrorsMsgCount = 0;
-static void transientErrorsMsgHandler(QtMsgType, const char *)
-{
- ++transientErrorsMsgCount;
-}
-
-// Check that transient binding errors are not displayed
-void tst_qdeclarativeecmascript::transientErrors()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("transientErrors.qml"));
-
- transientErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- qInstallMsgHandler(old);
-
- QCOMPARE(transientErrorsMsgCount, 0);
-
- delete object;
- }
-
- // One binding erroring multiple times, but then resolving
- {
- QDeclarativeComponent component(&engine, testFileUrl("transientErrors.2.qml"));
-
- transientErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- qInstallMsgHandler(old);
-
- QCOMPARE(transientErrorsMsgCount, 0);
-
- delete object;
- }
-}
-
-// Check that errors during shutdown are minimized
-void tst_qdeclarativeecmascript::shutdownErrors()
-{
- QDeclarativeComponent component(&engine, testFileUrl("shutdownErrors.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- transientErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
-
- delete object;
-
- qInstallMsgHandler(old);
- QCOMPARE(transientErrorsMsgCount, 0);
-}
-
-void tst_qdeclarativeecmascript::compositePropertyType()
-{
- QDeclarativeComponent component(&engine, testFileUrl("compositePropertyType.qml"));
-
- QTest::ignoreMessage(QtDebugMsg, "hello world");
- QObject *object = qobject_cast<QObject *>(component.create());
- delete object;
-}
-
-// QTBUG-5759
-void tst_qdeclarativeecmascript::jsObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("jsObject.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 92);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::undefinedResetsProperty()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("undefinedResetsProperty.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("resettableProperty").toInt(), 92);
-
- object->setProperty("setUndefined", true);
-
- QCOMPARE(object->property("resettableProperty").toInt(), 13);
-
- object->setProperty("setUndefined", false);
-
- QCOMPARE(object->property("resettableProperty").toInt(), 92);
-
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("undefinedResetsProperty.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("resettableProperty").toInt(), 19);
-
- QMetaObject::invokeMethod(object, "doReset");
-
- QCOMPARE(object->property("resettableProperty").toInt(), 13);
-
- delete object;
- }
-}
-
-// Aliases to variant properties should work
-void tst_qdeclarativeecmascript::qtbug_22464()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_22464.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::qtbug_21580()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_21580.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// QTBUG-6781
-void tst_qdeclarativeecmascript::bug1()
-{
- QDeclarativeComponent component(&engine, testFileUrl("bug.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 14);
-
- object->setProperty("a", 11);
-
- QCOMPARE(object->property("test").toInt(), 3);
-
- object->setProperty("b", true);
-
- QCOMPARE(object->property("test").toInt(), 9);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::bug2()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import Qt.test 1.0;\nQPlainTextEdit { width: 100 }", QUrl());
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- delete object;
-}
-
-// Don't crash in createObject when the component has errors.
-void tst_qdeclarativeecmascript::dynamicCreationCrash()
-{
- QDeclarativeComponent component(&engine, testFileUrl("dynamicCreation.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- QMetaObject::invokeMethod(object, "dontCrash");
- QObject *created = object->objectProperty();
- QVERIFY(created == 0);
-
- delete object;
-}
-
-// ownership transferred to JS, ensure that GC runs the dtor
-void tst_qdeclarativeecmascript::dynamicCreationOwnership()
-{
- int dtorCount = 0;
- int expectedDtorCount = 1; // start at 1 since we expect mdcdo to dtor too.
-
- // allow the engine to go out of scope too.
- {
- QDeclarativeEngine dcoEngine;
- QDeclarativeComponent component(&dcoEngine, testFileUrl("dynamicCreationOwnership.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- MyDynamicCreationDestructionObject *mdcdo = object->findChild<MyDynamicCreationDestructionObject*>("mdcdo");
- QVERIFY(mdcdo != 0);
- mdcdo->setDtorCount(&dtorCount);
-
- for (int i = 1; i < 105; ++i, ++expectedDtorCount) {
- QMetaObject::invokeMethod(object, "dynamicallyCreateJsOwnedObject");
- if (i % 90 == 0) {
- // we do this once manually, but it should be done automatically
- // when the engine goes out of scope (since it should gc in dtor)
- QMetaObject::invokeMethod(object, "performGc");
- }
- if (i % 10 == 0) {
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- }
- }
-
- delete object;
- }
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, expectedDtorCount);
-}
-
-void tst_qdeclarativeecmascript::regExpBug()
-{
- //QTBUG-9367
- {
- QDeclarativeComponent component(&engine, testFileUrl("regExp.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->regExp().pattern(), QLatin1String("[a-zA-z]"));
- delete object;
- }
-
- //QTBUG-23068
- {
- QString err = QString(QLatin1String("%1:6 Invalid property assignment: regular expression expected; use /pattern/ syntax\n")).arg(testFileUrl("regExp.2.qml").toString());
- QDeclarativeComponent component(&engine, testFileUrl("regExp.2.qml"));
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(!object);
- QCOMPARE(component.errorString(), err);
- }
-}
-
-static inline bool evaluate_error(QV8Engine *engine, v8::Handle<v8::Object> o, const char *source)
-{
- QString functionSource = QLatin1String("(function(object) { return ") +
- QLatin1String(source) + QLatin1String(" })");
- v8::TryCatch tc;
- v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource));
- if (tc.HasCaught())
- return false;
- v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run());
- if (function.IsEmpty())
- return false;
- v8::Handle<v8::Value> args[] = { o };
- function->Call(engine->global(), 1, args);
- return tc.HasCaught();
-}
-
-static inline bool evaluate_value(QV8Engine *engine, v8::Handle<v8::Object> o,
- const char *source, v8::Handle<v8::Value> result)
-{
- QString functionSource = QLatin1String("(function(object) { return ") +
- QLatin1String(source) + QLatin1String(" })");
- v8::TryCatch tc;
- v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource));
- if (tc.HasCaught())
- return false;
- v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run());
- if (function.IsEmpty())
- return false;
- v8::Handle<v8::Value> args[] = { o };
-
- v8::Handle<v8::Value> value = function->Call(engine->global(), 1, args);
-
- if (tc.HasCaught())
- return false;
-
- return value->StrictEquals(result);
-}
-
-static inline v8::Handle<v8::Value> evaluate(QV8Engine *engine, v8::Handle<v8::Object> o,
- const char *source)
-{
- QString functionSource = QLatin1String("(function(object) { return ") +
- QLatin1String(source) + QLatin1String(" })");
- v8::TryCatch tc;
- v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource));
- if (tc.HasCaught())
- return v8::Handle<v8::Value>();
- v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run());
- if (function.IsEmpty())
- return v8::Handle<v8::Value>();
- v8::Handle<v8::Value> args[] = { o };
-
- v8::Handle<v8::Value> value = function->Call(engine->global(), 1, args);
-
- if (tc.HasCaught())
- return v8::Handle<v8::Value>();
- return value;
-}
-
-#define EVALUATE_ERROR(source) evaluate_error(engine, object, source)
-#define EVALUATE_VALUE(source, result) evaluate_value(engine, object, source, result)
-#define EVALUATE(source) evaluate(engine, object, source)
-
-void tst_qdeclarativeecmascript::callQtInvokables()
-{
- MyInvokableObject o;
-
- QDeclarativeEngine qmlengine;
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(&qmlengine);
-
- QV8Engine *engine = ep->v8engine();
-
- v8::HandleScope handle_scope;
- v8::Context::Scope scope(engine->context());
-
- v8::Local<v8::Object> object = engine->newQObject(&o)->ToObject();
-
- // Non-existent methods
- o.reset();
- QVERIFY(EVALUATE_ERROR("object.method_nonexistent()"));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QVERIFY(EVALUATE_ERROR("object.method_nonexistent(10, 11)"));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- // Insufficient arguments
- o.reset();
- QVERIFY(EVALUATE_ERROR("object.method_int()"));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QVERIFY(EVALUATE_ERROR("object.method_intint(10)"));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- // Excessive arguments
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_int(10, 11)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(10));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_intint(10, 11, 12)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 9);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(10));
- QCOMPARE(o.actuals().at(1), QVariant(11));
-
- // Test return types
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_NoArgs()", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 0);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_NoArgs_int()", v8::Integer::New(6)));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_NoArgs_real()", v8::Number::New(19.75)));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 2);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- {
- v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QPointF()");
- QVERIFY(!ret.IsEmpty());
- QCOMPARE(engine->toVariant(ret, -1), QVariant(QPointF(123, 4.5)));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 3);
- QCOMPARE(o.actuals().count(), 0);
- }
-
- o.reset();
- {
- v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QObject()");
- QCOMPARE(engine->toQObject(ret), (QObject *)&o);
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 4);
- QCOMPARE(o.actuals().count(), 0);
- }
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_NoArgs_unknown()", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 5);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- {
- v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QScriptValue()");
- QVERIFY(ret->IsString());
- QCOMPARE(engine->toString(ret), QString("Hello world"));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 6);
- QCOMPARE(o.actuals().count(), 0);
- }
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_NoArgs_QVariant()", engine->toString("QML rocks")));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 7);
- QCOMPARE(o.actuals().count(), 0);
-
- // Test arg types
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_int(94)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(94));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_int(\"94\")", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(94));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_int(\"not a number\")", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_int(null)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_int(undefined)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_int(object)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 8);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_intint(122, 9)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 9);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(122));
- QCOMPARE(o.actuals().at(1), QVariant(9));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_real(94.3)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(94.3));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_real(\"94.3\")", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(94.3));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_real(\"not a number\")", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_real(null)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_real(undefined)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_real(object)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 10);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QString(\"Hello world\")", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant("Hello world"));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QString(19)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant("19"));
-
- o.reset();
- {
- QString expected = "MyInvokableObject(0x" + QString::number((quintptr)&o, 16) + ")";
- QVERIFY(EVALUATE_VALUE("object.method_QString(object)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(expected));
- }
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QString(null)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QString()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QString(undefined)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 11);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QString()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QPointF(0)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QPointF(null)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QPointF(undefined)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QPointF(object)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QPointF(object.method_get_QPointF())", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF(99.3, -10.2)));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QPointF(object.method_get_QPoint())", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 12);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QPointF(9, 12)));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QObject(0)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QObject(\"Hello world\")", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QObject(null)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QObject(undefined)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QObject(object)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 13);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)&o));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(null)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 14);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(0)).isNull());
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(undefined)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 14);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(0)).isUndefined());
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(19)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 14);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(0)).strictlyEquals(QJSValue(19)));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QScriptValue([19, 20])", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 14);
- QCOMPARE(o.actuals().count(), 1);
- QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(0)).isArray());
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(4, null)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 15);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(4));
- QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(1)).isNull());
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(8, undefined)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 15);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(8));
- QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(1)).isUndefined());
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(3, 19)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 15);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(3));
- QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(1)).strictlyEquals(QJSValue(19)));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(44, [19, 20])", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 15);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(44));
- QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(1)).isArray());
-
- o.reset();
- QVERIFY(EVALUATE_ERROR("object.method_overload()"));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -1);
- QCOMPARE(o.actuals().count(), 0);
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_overload(10)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 16);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(10));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_overload(10, 11)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 17);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(10));
- QCOMPARE(o.actuals().at(1), QVariant(11));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_overload(\"Hello\")", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 18);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(QString("Hello")));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_with_enum(9)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 19);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(9));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_default(10)", v8::Integer::New(19)));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 20);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(10));
- QCOMPARE(o.actuals().at(1), QVariant(19));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_default(10, 13)", v8::Integer::New(13)));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 20);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(10));
- QCOMPARE(o.actuals().at(1), QVariant(13));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_inherited(9)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), -3);
- QCOMPARE(o.actuals().count(), 1);
- QCOMPARE(o.actuals().at(0), QVariant(9));
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QVariant(9)", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 21);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(9));
- QCOMPARE(o.actuals().at(1), QVariant());
-
- o.reset();
- QVERIFY(EVALUATE_VALUE("object.method_QVariant(\"Hello\", \"World\")", v8::Undefined()));
- QCOMPARE(o.error(), false);
- QCOMPARE(o.invoked(), 21);
- QCOMPARE(o.actuals().count(), 2);
- QCOMPARE(o.actuals().at(0), QVariant(QString("Hello")));
- QCOMPARE(o.actuals().at(1), QVariant(QString("World")));
-}
-
-// QTBUG-13047 (check that you can pass registered object types as args)
-void tst_qdeclarativeecmascript::invokableObjectArg()
-{
- QDeclarativeComponent component(&engine, testFileUrl("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, testFileUrl("invokableObjectRet.qml"));
-
- QObject *o = component.create();
- QVERIFY(o);
- QCOMPARE(o->property("test").toBool(), true);
- delete o;
-}
-
-// QTBUG-5675
-void tst_qdeclarativeecmascript::listToVariant()
-{
- QDeclarativeComponent component(&engine, testFileUrl("listToVariant.qml"));
-
- MyQmlContainer container;
-
- QDeclarativeContext context(engine.rootContext());
- context.setContextObject(&container);
-
- QObject *object = component.create(&context);
- QVERIFY(object != 0);
-
- QVariant v = object->property("test");
- QCOMPARE(v.userType(), qMetaTypeId<QDeclarativeListReference>());
- QVERIFY(qvariant_cast<QDeclarativeListReference>(v).object() == &container);
-
- delete object;
-}
-
-// QTBUG-16316
-Q_DECLARE_METATYPE(QDeclarativeListProperty<MyQmlObject>)
-void tst_qdeclarativeecmascript::listAssignment()
-{
- QDeclarativeComponent component(&engine, testFileUrl("listAssignment.qml"));
- QObject *obj = component.create();
- QCOMPARE(obj->property("list1length").toInt(), 2);
- QDeclarativeListProperty<MyQmlObject> list1 = obj->property("list1").value<QDeclarativeListProperty<MyQmlObject> >();
- QDeclarativeListProperty<MyQmlObject> list2 = obj->property("list2").value<QDeclarativeListProperty<MyQmlObject> >();
- QCOMPARE(list1.count(&list1), list2.count(&list2));
- QCOMPARE(list1.at(&list1, 0), list2.at(&list2, 0));
- QCOMPARE(list1.at(&list1, 1), list2.at(&list2, 1));
- delete obj;
-}
-
-// QTBUG-7957
-void tst_qdeclarativeecmascript::multiEngineObject()
-{
- MyQmlObject obj;
- obj.setStringProperty("Howdy planet");
-
- QDeclarativeEngine e1;
- e1.rootContext()->setContextProperty("thing", &obj);
- QDeclarativeComponent c1(&e1, testFileUrl("multiEngineObject.qml"));
-
- QDeclarativeEngine e2;
- e2.rootContext()->setContextProperty("thing", &obj);
- QDeclarativeComponent c2(&e2, testFileUrl("multiEngineObject.qml"));
-
- QObject *o1 = c1.create();
- QObject *o2 = c2.create();
-
- QCOMPARE(o1->property("test").toString(), QString("Howdy planet"));
- QCOMPARE(o2->property("test").toString(), QString("Howdy planet"));
-
- delete o2;
- delete o1;
-}
-
-// Test that references to QObjects are cleanup when the object is destroyed
-void tst_qdeclarativeecmascript::deletedObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("deletedObject.qml"));
-
- QObject *object = component.create();
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
- QCOMPARE(object->property("test3").toBool(), true);
- QCOMPARE(object->property("test4").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::attachedPropertyScope()
-{
- QDeclarativeComponent component(&engine, testFileUrl("attachedPropertyScope.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- MyQmlAttachedObject *attached =
- qobject_cast<MyQmlAttachedObject *>(qmlAttachedPropertiesObject<MyQmlObject>(object));
- QVERIFY(attached != 0);
-
- QCOMPARE(object->property("value2").toInt(), 0);
-
- attached->emitMySignal();
-
- QCOMPARE(object->property("value2").toInt(), 9);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::scriptConnect()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.1.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.2.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.3.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.4.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->methodCalled(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->methodCalled(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.5.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->methodCalled(), false);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->methodCalled(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.6.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 2);
-
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::scriptDisconnect()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptDisconnect.1.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 2);
- emit object->basicSignal();
- QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 2);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptDisconnect.2.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 2);
- emit object->basicSignal();
- QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 2);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptDisconnect.3.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 2);
- emit object->basicSignal();
- QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 3);
-
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("scriptDisconnect.4.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 2);
- emit object->basicSignal();
- QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
- QCOMPARE(object->property("test").toInt(), 3);
-
- delete object;
- }
-}
-
-class OwnershipObject : public QObject
-{
- Q_OBJECT
-public:
- OwnershipObject() { object = new QObject; }
-
- QPointer<QObject> object;
-
-public slots:
- QObject *getObject() { return object; }
-};
-
-void tst_qdeclarativeecmascript::ownership()
-{
- OwnershipObject own;
- QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
- context->setContextObject(&own);
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("ownership.qml"));
-
- QVERIFY(own.object != 0);
-
- QObject *object = component.create(context);
-
- engine.collectGarbage();
-
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-
- QVERIFY(own.object == 0);
-
- delete object;
- }
-
- own.object = new QObject(&own);
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("ownership.qml"));
-
- QVERIFY(own.object != 0);
-
- QObject *object = component.create(context);
-
- engine.collectGarbage();
-
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-
- QVERIFY(own.object != 0);
-
- delete object;
- }
-
- delete context;
-}
-
-class CppOwnershipReturnValue : public QObject
-{
- Q_OBJECT
-public:
- CppOwnershipReturnValue() : value(0) {}
- ~CppOwnershipReturnValue() { delete value; }
-
- Q_INVOKABLE QObject *create() {
- value = new QObject;
- QDeclarativeEngine::setObjectOwnership(value, QDeclarativeEngine::CppOwnership);
- return value;
- }
-
- Q_INVOKABLE MyQmlObject *createQmlObject() {
- MyQmlObject *rv = new MyQmlObject;
- value = rv;
- return rv;
- }
-
- QPointer<QObject> value;
-};
-
-// QTBUG-15695.
-// Test setObjectOwnership(CppOwnership) works even when there is no QDeclarativeData
-void tst_qdeclarativeecmascript::cppOwnershipReturnValue()
-{
- CppOwnershipReturnValue source;
-
- {
- QDeclarativeEngine engine;
- engine.rootContext()->setContextProperty("source", &source);
-
- QVERIFY(source.value == 0);
-
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nQtObject {\nComponent.onCompleted: { var a = source.create(); }\n}\n", QUrl());
-
- QObject *object = component.create();
-
- QVERIFY(object != 0);
- QVERIFY(source.value != 0);
-
- delete object;
- }
-
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-
- QVERIFY(source.value != 0);
-}
-
-// QTBUG-15697
-void tst_qdeclarativeecmascript::ownershipCustomReturnValue()
-{
- CppOwnershipReturnValue source;
-
- {
- QDeclarativeEngine engine;
- engine.rootContext()->setContextProperty("source", &source);
-
- QVERIFY(source.value == 0);
-
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nQtObject {\nComponent.onCompleted: { var a = source.createQmlObject(); }\n}\n", QUrl());
-
- QObject *object = component.create();
-
- QVERIFY(object != 0);
- QVERIFY(source.value != 0);
-
- delete object;
- }
-
- engine.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-
- QVERIFY(source.value == 0);
-}
-
-class QListQObjectMethodsObject : public QObject
-{
- Q_OBJECT
-public:
- QListQObjectMethodsObject() {
- m_objects.append(new MyQmlObject());
- m_objects.append(new MyQmlObject());
- }
-
- ~QListQObjectMethodsObject() {
- qDeleteAll(m_objects);
- }
-
-public slots:
- QList<QObject *> getObjects() { return m_objects; }
-
-private:
- QList<QObject *> m_objects;
-};
-
-// Tests that returning a QList<QObject*> from a method works
-void tst_qdeclarativeecmascript::qlistqobjectMethods()
-{
- QListQObjectMethodsObject obj;
- QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
- context->setContextObject(&obj);
-
- QDeclarativeComponent component(&engine, testFileUrl("qlistqobjectMethods.qml"));
-
- QObject *object = component.create(context);
-
- QCOMPARE(object->property("test").toInt(), 2);
- QCOMPARE(object->property("test2").toBool(), true);
-
- delete object;
- delete context;
-}
-
-// QTBUG-9205
-void tst_qdeclarativeecmascript::strictlyEquals()
-{
- QDeclarativeComponent component(&engine, testFileUrl("strictlyEquals.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
- QCOMPARE(object->property("test3").toBool(), true);
- QCOMPARE(object->property("test4").toBool(), true);
- QCOMPARE(object->property("test5").toBool(), true);
- QCOMPARE(object->property("test6").toBool(), true);
- QCOMPARE(object->property("test7").toBool(), true);
- QCOMPARE(object->property("test8").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::compiled()
-{
- QDeclarativeComponent component(&engine, testFileUrl("compiled.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toReal(), qreal(15.7));
- QCOMPARE(object->property("test2").toReal(), qreal(-6.7));
- QCOMPARE(object->property("test3").toBool(), true);
- QCOMPARE(object->property("test4").toBool(), false);
- QCOMPARE(object->property("test5").toBool(), false);
- QCOMPARE(object->property("test6").toBool(), true);
-
- QCOMPARE(object->property("test7").toInt(), 185);
- QCOMPARE(object->property("test8").toInt(), 167);
- QCOMPARE(object->property("test9").toBool(), true);
- QCOMPARE(object->property("test10").toBool(), false);
- QCOMPARE(object->property("test11").toBool(), false);
- QCOMPARE(object->property("test12").toBool(), true);
-
- QCOMPARE(object->property("test13").toString(), QLatin1String("HelloWorld"));
- QCOMPARE(object->property("test14").toString(), QLatin1String("Hello World"));
- QCOMPARE(object->property("test15").toBool(), false);
- QCOMPARE(object->property("test16").toBool(), true);
-
- QCOMPARE(object->property("test17").toInt(), 5);
- QCOMPARE(object->property("test18").toReal(), qreal(176));
- QCOMPARE(object->property("test19").toInt(), 7);
- QCOMPARE(object->property("test20").toReal(), qreal(6.7));
- QCOMPARE(object->property("test21").toString(), QLatin1String("6.7"));
- QCOMPARE(object->property("test22").toString(), QLatin1String("!"));
- QCOMPARE(object->property("test23").toBool(), true);
- QCOMPARE(qvariant_cast<QColor>(object->property("test24")), QColor(0x11,0x22,0x33));
- QCOMPARE(qvariant_cast<QColor>(object->property("test25")), QColor(0x11,0x22,0x33,0xAA));
-
- delete object;
-}
-
-// Test that numbers assigned in bindings as strings work consistently
-void tst_qdeclarativeecmascript::numberAssignment()
-{
- QDeclarativeComponent component(&engine, testFileUrl("numberAssignment.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1"), QVariant((qreal)6.7));
- QCOMPARE(object->property("test2"), QVariant((qreal)6.7));
- QCOMPARE(object->property("test2"), QVariant((qreal)6.7));
- QCOMPARE(object->property("test3"), QVariant((qreal)6));
- QCOMPARE(object->property("test4"), QVariant((qreal)6));
-
- QCOMPARE(object->property("test5"), QVariant((int)7));
- QCOMPARE(object->property("test6"), QVariant((int)7));
- QCOMPARE(object->property("test7"), QVariant((int)6));
- QCOMPARE(object->property("test8"), QVariant((int)6));
-
- QCOMPARE(object->property("test9"), QVariant((unsigned int)7));
- QCOMPARE(object->property("test10"), QVariant((unsigned int)7));
- QCOMPARE(object->property("test11"), QVariant((unsigned int)6));
- QCOMPARE(object->property("test12"), QVariant((unsigned int)6));
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::propertySplicing()
-{
- QDeclarativeComponent component(&engine, testFileUrl("propertySplicing.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// QTBUG-16683
-void tst_qdeclarativeecmascript::signalWithUnknownTypes()
-{
- QDeclarativeComponent component(&engine, testFileUrl("signalWithUnknownTypes.qml"));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- MyQmlObject::MyType type;
- type.value = 0x8971123;
- emit object->signalWithUnknownType(type);
-
- MyQmlObject::MyType result = qvariant_cast<MyQmlObject::MyType>(object->variant());
-
- QCOMPARE(result.value, type.value);
-
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::signalWithJSValueInVariant_data()
-{
- QTest::addColumn<QString>("expression");
- QTest::addColumn<QString>("compare");
-
- QString compareStrict("(function(a, b) { return a === b; })");
- QTest::newRow("true") << "true" << compareStrict;
- QTest::newRow("undefined") << "undefined" << compareStrict;
- QTest::newRow("null") << "null" << compareStrict;
- QTest::newRow("123") << "123" << compareStrict;
- QTest::newRow("'ciao'") << "'ciao'" << compareStrict;
-
- QString comparePropertiesStrict(
- "(function(a, b) {"
- " if (typeof b != 'object')"
- " return a === b;"
- " var props = Object.getOwnPropertyNames(b);"
- " for (var i = 0; i < props.length; ++i) {"
- " var p = props[i];"
- " return arguments.callee(a[p], b[p]);"
- " }"
- "})");
- QTest::newRow("{ foo: 'bar' }") << "({ foo: 'bar' })" << comparePropertiesStrict;
- QTest::newRow("[10,20,30]") << "[10,20,30]" << comparePropertiesStrict;
-}
-
-void tst_qdeclarativeecmascript::signalWithJSValueInVariant()
-{
- QFETCH(QString, expression);
- QFETCH(QString, compare);
-
- QDeclarativeComponent component(&engine, testFileUrl("signalWithJSValueInVariant.qml"));
- QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
- QVERIFY(object != 0);
-
- QJSValue value = engine.evaluate(expression);
- QVERIFY(!engine.hasUncaughtException());
- object->setProperty("expression", expression);
- object->setProperty("compare", compare);
- object->setProperty("pass", false);
-
- emit object->signalWithVariant(QVariant::fromValue(value));
- QVERIFY(object->property("pass").toBool());
-}
-
-void tst_qdeclarativeecmascript::signalWithJSValueInVariant_twoEngines_data()
-{
- signalWithJSValueInVariant_data();
-}
-
-void tst_qdeclarativeecmascript::signalWithJSValueInVariant_twoEngines()
-{
- QFETCH(QString, expression);
- QFETCH(QString, compare);
-
- QDeclarativeComponent component(&engine, testFileUrl("signalWithJSValueInVariant.qml"));
- QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
- QVERIFY(object != 0);
-
- QJSEngine engine2;
- QJSValue value = engine2.evaluate(expression);
- QVERIFY(!engine2.hasUncaughtException());
- object->setProperty("expression", expression);
- object->setProperty("compare", compare);
- object->setProperty("pass", false);
-
- QTest::ignoreMessage(QtWarningMsg, "JSValue can't be rassigned to an another engine.");
- emit object->signalWithVariant(QVariant::fromValue(value));
- QVERIFY(!object->property("pass").toBool());
-}
-
-void tst_qdeclarativeecmascript::signalWithQJSValue_data()
-{
- signalWithJSValueInVariant_data();
-}
-
-void tst_qdeclarativeecmascript::signalWithQJSValue()
-{
- QFETCH(QString, expression);
- QFETCH(QString, compare);
-
- QDeclarativeComponent component(&engine, testFileUrl("signalWithQJSValue.qml"));
- QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
- QVERIFY(object != 0);
-
- QJSValue value = engine.evaluate(expression);
- QVERIFY(!engine.hasUncaughtException());
- object->setProperty("expression", expression);
- object->setProperty("compare", compare);
- object->setProperty("pass", false);
-
- emit object->signalWithQJSValue(value);
-
- QVERIFY(object->property("pass").toBool());
- QVERIFY(object->qjsvalue().strictlyEquals(value));
-}
-
-void tst_qdeclarativeecmascript::moduleApi_data()
-{
- QTest::addColumn<QUrl>("testfile");
- QTest::addColumn<QString>("errorMessage");
- QTest::addColumn<QStringList>("warningMessages");
- QTest::addColumn<QStringList>("readProperties");
- QTest::addColumn<QVariantList>("readExpectedValues");
- QTest::addColumn<QStringList>("writeProperties");
- QTest::addColumn<QVariantList>("writeValues");
- QTest::addColumn<QStringList>("readBackProperties");
- QTest::addColumn<QVariantList>("readBackExpectedValues");
-
- QTest::newRow("qobject, register + read + method")
- << testFileUrl("moduleapi/qobjectModuleApi.qml")
- << QString()
- << QStringList()
- << (QStringList() << "existingUriTest" << "qobjectTest" << "qobjectMethodTest"
- << "qobjectMinorVersionTest" << "qobjectMajorVersionTest" << "qobjectParentedTest")
- << (QVariantList() << 20 << 20 << 1 << 20 << 20 << 26)
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList();
-
- QTest::newRow("script, register + read")
- << testFileUrl("moduleapi/scriptModuleApi.qml")
- << QString()
- << QStringList()
- << (QStringList() << "scriptTest")
- << (QVariantList() << 13)
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList();
-
- QTest::newRow("qobject, caching + read")
- << testFileUrl("moduleapi/qobjectModuleApiCaching.qml")
- << QString()
- << QStringList()
- << (QStringList() << "existingUriTest" << "qobjectParentedTest")
- << (QVariantList() << 20 << 26) // 26, shouldn't have incremented to 27.
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList();
-
- QTest::newRow("script, caching + read")
- << testFileUrl("moduleapi/scriptModuleApiCaching.qml")
- << QString()
- << QStringList()
- << (QStringList() << "scriptTest")
- << (QVariantList() << 13) // 13, shouldn't have incremented to 14.
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList();
-
- QTest::newRow("qobject, writing + readonly constraints")
- << testFileUrl("moduleapi/qobjectModuleApiWriting.qml")
- << QString()
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/qobjectModuleApiWriting.qml").toLocalFile() + QLatin1String(":14: Error: Cannot assign to read-only property \"qobjectTestProperty\"")))
- << (QStringList() << "readOnlyProperty" << "writableProperty")
- << (QVariantList() << 20 << 50)
- << (QStringList() << "firstProperty" << "writableProperty")
- << (QVariantList() << 30 << 30)
- << (QStringList() << "readOnlyProperty" << "writableProperty")
- << (QVariantList() << 20 << 30);
-
- QTest::newRow("script, writing + readonly constraints")
- << testFileUrl("moduleapi/scriptModuleApiWriting.qml")
- << QString()
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/scriptModuleApiWriting.qml").toLocalFile() + QLatin1String(":21: Error: Cannot assign to read-only property \"scriptTestProperty\"")))
- << (QStringList() << "readBack" << "unchanged")
- << (QVariantList() << 13 << 42)
- << (QStringList() << "firstProperty" << "secondProperty")
- << (QVariantList() << 30 << 30)
- << (QStringList() << "readBack" << "unchanged")
- << (QVariantList() << 30 << 42);
-
- QTest::newRow("qobject module API enum values in JS")
- << testFileUrl("moduleapi/qobjectModuleApiEnums.qml")
- << QString()
- << QStringList()
- << (QStringList() << "enumValue" << "enumMethod")
- << (QVariantList() << 42 << 30)
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList();
-
- QTest::newRow("qobject, invalid major version fail")
- << testFileUrl("moduleapi/moduleApiMajorVersionFail.qml")
- << QString("QDeclarativeComponent: Component is not ready")
- << QStringList()
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList();
-
- QTest::newRow("qobject, invalid minor version fail")
- << testFileUrl("moduleapi/moduleApiMinorVersionFail.qml")
- << QString("QDeclarativeComponent: Component is not ready")
- << QStringList()
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList()
- << QStringList()
- << QVariantList();
-}
-
-void tst_qdeclarativeecmascript::moduleApi()
-{
- QFETCH(QUrl, testfile);
- QFETCH(QString, errorMessage);
- QFETCH(QStringList, warningMessages);
- QFETCH(QStringList, readProperties);
- QFETCH(QVariantList, readExpectedValues);
- QFETCH(QStringList, writeProperties);
- QFETCH(QVariantList, writeValues);
- QFETCH(QStringList, readBackProperties);
- QFETCH(QVariantList, readBackExpectedValues);
-
- QDeclarativeComponent component(&engine, testfile);
-
- if (!errorMessage.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, errorMessage.toAscii().constData());
-
- if (warningMessages.size())
- foreach (const QString &warning, warningMessages)
- QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
-
- QObject *object = component.create();
- if (!errorMessage.isEmpty()) {
- QVERIFY(object == 0);
- } else {
- QVERIFY(object != 0);
- for (int i = 0; i < readProperties.size(); ++i)
- QCOMPARE(object->property(readProperties.at(i).toAscii().constData()), readExpectedValues.at(i));
- for (int i = 0; i < writeProperties.size(); ++i)
- QVERIFY(object->setProperty(writeProperties.at(i).toAscii().constData(), writeValues.at(i)));
- for (int i = 0; i < readBackProperties.size(); ++i)
- QCOMPARE(object->property(readBackProperties.at(i).toAscii().constData()), readBackExpectedValues.at(i));
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::importScripts_data()
-{
- QTest::addColumn<QUrl>("testfile");
- QTest::addColumn<QString>("errorMessage");
- QTest::addColumn<QStringList>("warningMessages");
- QTest::addColumn<QStringList>("propertyNames");
- QTest::addColumn<QVariantList>("propertyValues");
-
- QTest::newRow("basic functionality")
- << testFileUrl("jsimport/testImport.qml")
- << QString()
- << QStringList()
- << (QStringList() << QLatin1String("importedScriptStringValue")
- << QLatin1String("importedScriptFunctionValue")
- << QLatin1String("importedModuleAttachedPropertyValue")
- << QLatin1String("importedModuleEnumValue"))
- << (QVariantList() << QVariant(QLatin1String("Hello, World!"))
- << QVariant(20)
- << QVariant(19)
- << QVariant(2));
-
- QTest::newRow("import scoping")
- << testFileUrl("jsimport/testImportScoping.qml")
- << QString()
- << QStringList()
- << (QStringList() << QLatin1String("componentError"))
- << (QVariantList() << QVariant(5));
-
- QTest::newRow("parent scope shouldn't be inherited by import with imports")
- << testFileUrl("jsimportfail/failOne.qml")
- << QString()
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failOne.qml").toLocalFile() + QLatin1String(":6: TypeError: Cannot call method 'greetingString' of undefined")))
- << (QStringList() << QLatin1String("importScriptFunctionValue"))
- << (QVariantList() << QVariant(QString()));
-
- QTest::newRow("javascript imports in an import should be private to the import scope")
- << testFileUrl("jsimportfail/failTwo.qml")
- << QString()
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failTwo.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: ImportOneJs")))
- << (QStringList() << QLatin1String("importScriptFunctionValue"))
- << (QVariantList() << QVariant(QString()));
-
- QTest::newRow("module imports in an import should be private to the import scope")
- << testFileUrl("jsimportfail/failThree.qml")
- << QString()
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failThree.qml").toLocalFile() + QLatin1String(":7: TypeError: Cannot read property 'JsQtTest' of undefined")))
- << (QStringList() << QLatin1String("importedModuleAttachedPropertyValue"))
- << (QVariantList() << QVariant(false));
-
- QTest::newRow("typenames in an import should be private to the import scope")
- << testFileUrl("jsimportfail/failFour.qml")
- << QString()
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failFour.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: JsQtTest")))
- << (QStringList() << QLatin1String("importedModuleEnumValue"))
- << (QVariantList() << QVariant(0));
-
- QTest::newRow("import with imports has it's own activation scope")
- << testFileUrl("jsimportfail/failFive.qml")
- << QString()
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importWithImports.js").toLocalFile() + QLatin1String(":8: ReferenceError: Can't find variable: Component")))
- << (QStringList() << QLatin1String("componentError"))
- << (QVariantList() << QVariant(0));
-
- QTest::newRow("import pragma library script")
- << testFileUrl("jsimport/testImportPragmaLibrary.qml")
- << QString()
- << QStringList()
- << (QStringList() << QLatin1String("testValue"))
- << (QVariantList() << QVariant(31));
-
- QTest::newRow("pragma library imports shouldn't inherit parent imports or scope")
- << testFileUrl("jsimportfail/testImportPragmaLibrary.qml")
- << QString()
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importPragmaLibrary.js").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: Component")))
- << (QStringList() << QLatin1String("testValue"))
- << (QVariantList() << QVariant(0));
-
- QTest::newRow("import pragma library script which has an import")
- << testFileUrl("jsimport/testImportPragmaLibraryWithImports.qml")
- << QString()
- << QStringList()
- << (QStringList() << QLatin1String("testValue"))
- << (QVariantList() << QVariant(55));
-
- QTest::newRow("import pragma library script which has a pragma library import")
- << testFileUrl("jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml")
- << QString()
- << QStringList()
- << (QStringList() << QLatin1String("testValue"))
- << (QVariantList() << QVariant(18));
-}
-
-void tst_qdeclarativeecmascript::importScripts()
-{
- QFETCH(QUrl, testfile);
- QFETCH(QString, errorMessage);
- QFETCH(QStringList, warningMessages);
- QFETCH(QStringList, propertyNames);
- QFETCH(QVariantList, propertyValues);
-
- QDeclarativeComponent component(&engine, testfile);
-
- if (!errorMessage.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, errorMessage.toAscii().constData());
-
- if (warningMessages.size())
- foreach (const QString &warning, warningMessages)
- QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
-
- QObject *object = component.create();
- if (!errorMessage.isEmpty()) {
- QVERIFY(object == 0);
- } else {
- QVERIFY(object != 0);
- for (int i = 0; i < propertyNames.size(); ++i)
- QCOMPARE(object->property(propertyNames.at(i).toAscii().constData()), propertyValues.at(i));
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::scarceResources_other()
-{
- /* These tests require knowledge of state, since we test values after
- performing signal or function invocation. */
-
- QPixmap origPixmap(100, 100);
- origPixmap.fill(Qt::blue);
- QString srp_name, expectedWarning;
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(&engine);
- ScarceResourceObject *eo = 0;
- QObject *srsc = 0;
- QObject *object = 0;
-
- /* property var semantics */
-
- // test that scarce resources are handled properly in signal invocation
- QDeclarativeComponent varComponentTen(&engine, testFileUrl("scarceResourceSignal.var.qml"));
- object = varComponentTen.create();
- srsc = object->findChild<QObject*>("srsc");
- QVERIFY(srsc);
- QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // hasn't been instantiated yet.
- QCOMPARE(srsc->property("width"), QVariant(5)); // default value is 5.
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- QMetaObject::invokeMethod(srsc, "testSignal");
- QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // still hasn't been instantiated
- QCOMPARE(srsc->property("width"), QVariant(10)); // but width was assigned to 10.
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should still be no other copies of it at this stage.
- QMetaObject::invokeMethod(srsc, "testSignal2"); // assigns scarceResourceCopy to the scarce pixmap.
- QVERIFY(srsc->property("scarceResourceCopy").isValid());
- QCOMPARE(srsc->property("scarceResourceCopy").value<QPixmap>(), origPixmap);
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(!(eo->scarceResourceIsDetached())); // should be another copy of the resource now.
- QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
- delete object;
-
- // test that scarce resources are handled properly from js functions in qml files
- QDeclarativeComponent varComponentEleven(&engine, testFileUrl("scarceResourceFunction.var.qml"));
- object = varComponentEleven.create();
- QVERIFY(object != 0);
- QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- QMetaObject::invokeMethod(object, "retrieveScarceResource");
- QVERIFY(object->property("scarceResourceCopy").isValid()); // assigned, so should be valid.
- QCOMPARE(object->property("scarceResourceCopy").value<QPixmap>(), origPixmap);
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(!eo->scarceResourceIsDetached()); // should be a copy of the resource at this stage.
- QMetaObject::invokeMethod(object, "releaseScarceResource");
- QVERIFY(!object->property("scarceResourceCopy").isValid()); // just released, so should not be valid
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
- delete object;
-
- // test that if an exception occurs while invoking js function from cpp, that the resources are released.
- QDeclarativeComponent varComponentTwelve(&engine, testFileUrl("scarceResourceFunctionFail.var.qml"));
- object = varComponentTwelve.create();
- QVERIFY(object != 0);
- QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- srp_name = object->property("srp_name").toString();
- expectedWarning = varComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srp_name + QLatin1String(" is not a function");
- QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed.
- QMetaObject::invokeMethod(object, "retrieveScarceResource");
- QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred.
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
- delete object;
-
- // test that if an Item which has JS ownership but has a scarce resource property is garbage collected,
- // that the scarce resource is removed from the engine's list of scarce resources to clean up.
- QDeclarativeComponent varComponentThirteen(&engine, testFileUrl("scarceResourceObjectGc.var.qml"));
- object = varComponentThirteen.create();
- QVERIFY(object != 0);
- QVERIFY(!object->property("varProperty").isValid()); // not assigned yet
- QMetaObject::invokeMethod(object, "assignVarProperty");
- QVERIFY(ep->scarceResources.isEmpty()); // the scarce resource is a VME property.
- QMetaObject::invokeMethod(object, "deassignVarProperty");
- QVERIFY(ep->scarceResources.isEmpty()); // should still be empty; the resource should have been released on gc.
- delete object;
-
- /* property variant semantics */
-
- // test that scarce resources are handled properly in signal invocation
- QDeclarativeComponent variantComponentTen(&engine, testFileUrl("scarceResourceSignal.variant.qml"));
- object = variantComponentTen.create();
- QVERIFY(object != 0);
- srsc = object->findChild<QObject*>("srsc");
- QVERIFY(srsc);
- QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // hasn't been instantiated yet.
- QCOMPARE(srsc->property("width"), QVariant(5)); // default value is 5.
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- QMetaObject::invokeMethod(srsc, "testSignal");
- QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // still hasn't been instantiated
- QCOMPARE(srsc->property("width"), QVariant(10)); // but width was assigned to 10.
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should still be no other copies of it at this stage.
- QMetaObject::invokeMethod(srsc, "testSignal2"); // assigns scarceResourceCopy to the scarce pixmap.
- QVERIFY(srsc->property("scarceResourceCopy").isValid());
- QCOMPARE(srsc->property("scarceResourceCopy").value<QPixmap>(), origPixmap);
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(!(eo->scarceResourceIsDetached())); // should be another copy of the resource now.
- QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
- delete object;
-
- // test that scarce resources are handled properly from js functions in qml files
- QDeclarativeComponent variantComponentEleven(&engine, testFileUrl("scarceResourceFunction.variant.qml"));
- object = variantComponentEleven.create();
- QVERIFY(object != 0);
- QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- QMetaObject::invokeMethod(object, "retrieveScarceResource");
- QVERIFY(object->property("scarceResourceCopy").isValid()); // assigned, so should be valid.
- QCOMPARE(object->property("scarceResourceCopy").value<QPixmap>(), origPixmap);
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(!eo->scarceResourceIsDetached()); // should be a copy of the resource at this stage.
- QMetaObject::invokeMethod(object, "releaseScarceResource");
- QVERIFY(!object->property("scarceResourceCopy").isValid()); // just released, so should not be valid
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
- delete object;
-
- // test that if an exception occurs while invoking js function from cpp, that the resources are released.
- QDeclarativeComponent variantComponentTwelve(&engine, testFileUrl("scarceResourceFunctionFail.variant.qml"));
- object = variantComponentTwelve.create();
- QVERIFY(object != 0);
- QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- srp_name = object->property("srp_name").toString();
- expectedWarning = variantComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srp_name + QLatin1String(" is not a function");
- QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed.
- QMetaObject::invokeMethod(object, "retrieveScarceResource");
- QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred.
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
- QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
- delete object;
-}
-
-void tst_qdeclarativeecmascript::scarceResources_data()
-{
- QTest::addColumn<QUrl>("qmlFile");
- QTest::addColumn<bool>("readDetachStatus");
- QTest::addColumn<bool>("expectedDetachStatus");
- QTest::addColumn<QStringList>("propertyNames");
- QTest::addColumn<QVariantList>("expectedValidity");
- QTest::addColumn<QVariantList>("expectedValues");
- QTest::addColumn<QStringList>("expectedErrors");
-
- QPixmap origPixmap(100, 100);
- origPixmap.fill(Qt::blue);
-
- /* property var semantics */
-
- // in the following three cases, the instance created from the component
- // has a property which is a copy of the scarce resource; hence, the
- // resource should NOT be detached prior to deletion of the object instance,
- // unless the resource is destroyed explicitly.
- QTest::newRow("var: import scarce resource copy directly")
- << testFileUrl("scarceResourceCopy.var.qml")
- << true
- << false // won't be detached, because assigned to property and not explicitly released
- << (QStringList() << QLatin1String("scarceResourceCopy"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << origPixmap)
- << QStringList();
-
- QTest::newRow("var: import scarce resource copy from JS")
- << testFileUrl("scarceResourceCopyFromJs.var.qml")
- << true
- << false // won't be detached, because assigned to property and not explicitly released
- << (QStringList() << QLatin1String("scarceResourceCopy"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << origPixmap)
- << QStringList();
-
- QTest::newRow("var: import released scarce resource copy from JS")
- << testFileUrl("scarceResourceDestroyedCopy.var.qml")
- << true
- << true // explicitly released, so it will be detached
- << (QStringList() << QLatin1String("scarceResourceCopy"))
- << (QList<QVariant>() << false)
- << (QList<QVariant>() << QVariant())
- << QStringList();
-
- // in the following three cases, no other copy should exist in memory,
- // and so it should be detached (unless explicitly preserved).
- QTest::newRow("var: import auto-release SR from JS in binding side-effect")
- << testFileUrl("scarceResourceTest.var.qml")
- << true
- << true // auto released, so it will be detached
- << (QStringList() << QLatin1String("scarceResourceTest"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << QVariant(100))
- << QStringList();
- QTest::newRow("var: import explicit-preserve SR from JS in binding side-effect")
- << testFileUrl("scarceResourceTestPreserve.var.qml")
- << true
- << false // won't be detached because we explicitly preserve it
- << (QStringList() << QLatin1String("scarceResourceTest"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << QVariant(100))
- << QStringList();
- QTest::newRow("var: import explicit-preserve SR from JS in binding side-effect")
- << testFileUrl("scarceResourceTestMultiple.var.qml")
- << true
- << true // will be detached because all resources were released manually or automatically.
- << (QStringList() << QLatin1String("scarceResourceTest"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << QVariant(100))
- << QStringList();
-
- // In the following three cases, test that scarce resources are handled
- // correctly for imports.
- QTest::newRow("var: import with no binding")
- << testFileUrl("scarceResourceCopyImportNoBinding.var.qml")
- << false // cannot check detach status.
- << false
- << QStringList()
- << QList<QVariant>()
- << QList<QVariant>()
- << QStringList();
- QTest::newRow("var: import with binding without explicit preserve")
- << testFileUrl("scarceResourceCopyImportNoBinding.var.qml")
- << false
- << false
- << (QStringList() << QLatin1String("scarceResourceCopy"))
- << (QList<QVariant>() << false) // will have been released prior to evaluation of binding.
- << (QList<QVariant>() << QVariant())
- << QStringList();
- QTest::newRow("var: import with explicit release after binding evaluation")
- << testFileUrl("scarceResourceCopyImport.var.qml")
- << false
- << false
- << (QStringList() << QLatin1String("scarceResourceImportedCopy") << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo") << QLatin1String("arePropertiesEqual"))
- << (QList<QVariant>() << false << false << false << true) // since property var = JS object reference, by releasing the provider's resource, all handles are invalidated.
- << (QList<QVariant>() << QVariant() << QVariant() << QVariant() << QVariant(true))
- << QStringList();
- QTest::newRow("var: import with different js objects")
- << testFileUrl("scarceResourceCopyImportDifferent.var.qml")
- << false
- << false
- << (QStringList() << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo") << QLatin1String("arePropertiesEqual"))
- << (QList<QVariant>() << false << true << true) // invalidating one shouldn't invalidate the other, because they're not references to the same JS object.
- << (QList<QVariant>() << QVariant() << QVariant(origPixmap) << QVariant(false))
- << QStringList();
- QTest::newRow("var: import with different js objects and explicit release")
- << testFileUrl("scarceResourceMultipleDifferentNoBinding.var.qml")
- << false
- << false
- << (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo"))
- << (QList<QVariant>() << true << false) // invalidating one shouldn't invalidate the other, because they're not references to the same JS object.
- << (QList<QVariant>() << QVariant(origPixmap) << QVariant())
- << QStringList();
- QTest::newRow("var: import with same js objects and explicit release")
- << testFileUrl("scarceResourceMultipleSameNoBinding.var.qml")
- << false
- << false
- << (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo"))
- << (QList<QVariant>() << false << false) // invalidating one should invalidate the other, because they're references to the same JS object.
- << (QList<QVariant>() << QVariant() << QVariant())
- << QStringList();
- QTest::newRow("var: binding with same js objects and explicit release")
- << testFileUrl("scarceResourceMultipleSameWithBinding.var.qml")
- << false
- << false
- << (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo"))
- << (QList<QVariant>() << false << false) // invalidating one should invalidate the other, because they're references to the same JS object.
- << (QList<QVariant>() << QVariant() << QVariant())
- << QStringList();
-
-
- /* property variant semantics */
-
- // in the following three cases, the instance created from the component
- // has a property which is a copy of the scarce resource; hence, the
- // resource should NOT be detached prior to deletion of the object instance,
- // unless the resource is destroyed explicitly.
- QTest::newRow("variant: import scarce resource copy directly")
- << testFileUrl("scarceResourceCopy.variant.qml")
- << true
- << false // won't be detached, because assigned to property and not explicitly released
- << (QStringList() << QLatin1String("scarceResourceCopy"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << origPixmap)
- << QStringList();
-
- QTest::newRow("variant: import scarce resource copy from JS")
- << testFileUrl("scarceResourceCopyFromJs.variant.qml")
- << true
- << false // won't be detached, because assigned to property and not explicitly released
- << (QStringList() << QLatin1String("scarceResourceCopy"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << origPixmap)
- << QStringList();
-
- QTest::newRow("variant: import released scarce resource copy from JS")
- << testFileUrl("scarceResourceDestroyedCopy.variant.qml")
- << true
- << true // explicitly released, so it will be detached
- << (QStringList() << QLatin1String("scarceResourceCopy"))
- << (QList<QVariant>() << false)
- << (QList<QVariant>() << QVariant())
- << QStringList();
-
- // in the following three cases, no other copy should exist in memory,
- // and so it should be detached (unless explicitly preserved).
- QTest::newRow("variant: import auto-release SR from JS in binding side-effect")
- << testFileUrl("scarceResourceTest.variant.qml")
- << true
- << true // auto released, so it will be detached
- << (QStringList() << QLatin1String("scarceResourceTest"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << QVariant(100))
- << QStringList();
- QTest::newRow("variant: import explicit-preserve SR from JS in binding side-effect")
- << testFileUrl("scarceResourceTestPreserve.variant.qml")
- << true
- << false // won't be detached because we explicitly preserve it
- << (QStringList() << QLatin1String("scarceResourceTest"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << QVariant(100))
- << QStringList();
- QTest::newRow("variant: import multiple scarce resources")
- << testFileUrl("scarceResourceTestMultiple.variant.qml")
- << true
- << true // will be detached because all resources were released manually or automatically.
- << (QStringList() << QLatin1String("scarceResourceTest"))
- << (QList<QVariant>() << true)
- << (QList<QVariant>() << QVariant(100))
- << QStringList();
-
- // In the following three cases, test that scarce resources are handled
- // correctly for imports.
- QTest::newRow("variant: import with no binding")
- << testFileUrl("scarceResourceCopyImportNoBinding.variant.qml")
- << false // cannot check detach status.
- << false
- << QStringList()
- << QList<QVariant>()
- << QList<QVariant>()
- << QStringList();
- QTest::newRow("variant: import with binding without explicit preserve")
- << testFileUrl("scarceResourceCopyImportNoBinding.variant.qml")
- << false
- << false
- << (QStringList() << QLatin1String("scarceResourceCopy"))
- << (QList<QVariant>() << false) // will have been released prior to evaluation of binding.
- << (QList<QVariant>() << QVariant())
- << QStringList();
- QTest::newRow("variant: import with explicit release after binding evaluation")
- << testFileUrl("scarceResourceCopyImport.variant.qml")
- << false
- << false
- << (QStringList() << QLatin1String("scarceResourceImportedCopy") << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo"))
- << (QList<QVariant>() << true << true << false) // since property variant = variant copy, releasing the provider's resource does not invalidate previously assigned copies.
- << (QList<QVariant>() << origPixmap << origPixmap << QVariant())
- << QStringList();
-}
-
-void tst_qdeclarativeecmascript::scarceResources()
-{
- QFETCH(QUrl, qmlFile);
- QFETCH(bool, readDetachStatus);
- QFETCH(bool, expectedDetachStatus);
- QFETCH(QStringList, propertyNames);
- QFETCH(QVariantList, expectedValidity);
- QFETCH(QVariantList, expectedValues);
- QFETCH(QStringList, expectedErrors);
-
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(&engine);
- ScarceResourceObject *eo = 0;
- QObject *object = 0;
-
- QDeclarativeComponent c(&engine, qmlFile);
- object = c.create();
- QVERIFY(object != 0);
- for (int i = 0; i < propertyNames.size(); ++i) {
- QString prop = propertyNames.at(i);
- bool validity = expectedValidity.at(i).toBool();
- QVariant value = expectedValues.at(i);
-
- QCOMPARE(object->property(prop.toLatin1().constData()).isValid(), validity);
- if (value.type() == QVariant::Int) {
- QCOMPARE(object->property(prop.toLatin1().constData()).toInt(), value.toInt());
- } else if (value.type() == QVariant::Pixmap) {
- QCOMPARE(object->property(prop.toLatin1().constData()).value<QPixmap>(), value.value<QPixmap>());
- }
- }
-
- if (readDetachStatus) {
- eo = qobject_cast<ScarceResourceObject*>(QDeclarativeProperty::read(object, "a").value<QObject*>());
- QCOMPARE(eo->scarceResourceIsDetached(), expectedDetachStatus);
- }
-
- QVERIFY(ep->scarceResources.isEmpty());
- delete object;
-}
-
-void tst_qdeclarativeecmascript::propertyChangeSlots()
-{
- // ensure that allowable property names are allowed and onPropertyNameChanged slots are generated correctly.
- QDeclarativeComponent component(&engine, testFileUrl("changeslots/propertyChangeSlots.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-
- // ensure that invalid property names fail properly.
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- QDeclarativeComponent e1(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.1.qml"));
- QString expectedErrorString = e1.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on_nameWithUnderscoreChanged\"");
- QCOMPARE(e1.errors().at(0).toString(), expectedErrorString);
- object = e1.create();
- QVERIFY(object == 0);
- delete object;
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- QDeclarativeComponent e2(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.2.qml"));
- expectedErrorString = e2.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on____nameWithUnderscoresChanged\"");
- QCOMPARE(e2.errors().at(0).toString(), expectedErrorString);
- object = e2.create();
- QVERIFY(object == 0);
- delete object;
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- QDeclarativeComponent e3(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.3.qml"));
- expectedErrorString = e3.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on$NameWithDollarsignChanged\"");
- QCOMPARE(e3.errors().at(0).toString(), expectedErrorString);
- object = e3.create();
- QVERIFY(object == 0);
- delete object;
-
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- QDeclarativeComponent e4(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.4.qml"));
- expectedErrorString = e4.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on_6NameWithUnderscoreNumberChanged\"");
- QCOMPARE(e4.errors().at(0).toString(), expectedErrorString);
- object = e4.create();
- QVERIFY(object == 0);
- delete object;
-}
-
-void tst_qdeclarativeecmascript::propertyVar_data()
-{
- QTest::addColumn<QUrl>("qmlFile");
-
- // valid
- QTest::newRow("non-bindable object subproperty changed") << testFileUrl("propertyVar.1.qml");
- QTest::newRow("non-bindable object changed") << testFileUrl("propertyVar.2.qml");
- QTest::newRow("primitive changed") << testFileUrl("propertyVar.3.qml");
- QTest::newRow("javascript array modification") << testFileUrl("propertyVar.4.qml");
- QTest::newRow("javascript map modification") << testFileUrl("propertyVar.5.qml");
- QTest::newRow("javascript array assignment") << testFileUrl("propertyVar.6.qml");
- QTest::newRow("javascript map assignment") << testFileUrl("propertyVar.7.qml");
- QTest::newRow("literal property assignment") << testFileUrl("propertyVar.8.qml");
- QTest::newRow("qobject property assignment") << testFileUrl("propertyVar.9.qml");
- QTest::newRow("base class var property assignment") << testFileUrl("propertyVar.10.qml");
-}
-
-void tst_qdeclarativeecmascript::propertyVar()
-{
- QFETCH(QUrl, qmlFile);
-
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Tests that we can write QVariant values to var properties from C++
-void tst_qdeclarativeecmascript::propertyVarCpp()
-{
- QObject *object = 0;
-
- // ensure that writing to and reading from a var property from cpp works as required.
- // Literal values stored in var properties can be read and written as QVariants
- // of a specific type, whereas object values are read as QVariantMaps.
- QDeclarativeComponent component(&engine, testFileUrl("propertyVarCpp.qml"));
- object = component.create();
- QVERIFY(object != 0);
- // assign int to property var that currently has int assigned
- QVERIFY(object->setProperty("varProperty", QVariant::fromValue(10)));
- QCOMPARE(object->property("varBound"), QVariant(15));
- QCOMPARE(object->property("intBound"), QVariant(15));
- QCOMPARE(object->property("varProperty").userType(), (int)QVariant::Int);
- QCOMPARE(object->property("varBound").userType(), (int)QVariant::Int);
- // assign string to property var that current has bool assigned
- QCOMPARE(object->property("varProperty2").userType(), (int)QVariant::Bool);
- QVERIFY(object->setProperty("varProperty2", QVariant(QLatin1String("randomString"))));
- QCOMPARE(object->property("varProperty2"), QVariant(QLatin1String("randomString")));
- QCOMPARE(object->property("varProperty2").userType(), (int)QVariant::String);
- // now enforce behaviour when accessing JavaScript objects from cpp.
- QCOMPARE(object->property("jsobject").userType(), (int)QVariant::Map);
- delete object;
-}
-
-static void gc(QDeclarativeEngine &engine)
-{
- engine.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-}
-
-void tst_qdeclarativeecmascript::propertyVarOwnership()
-{
- // Referenced JS objects are not collected
- {
- QDeclarativeComponent component(&engine, testFileUrl("propertyVarOwnership.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toBool(), false);
- QMetaObject::invokeMethod(object, "runTest");
- QCOMPARE(object->property("test").toBool(), true);
- delete object;
- }
- // Referenced JS objects are not collected
- {
- QDeclarativeComponent component(&engine, testFileUrl("propertyVarOwnership.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toBool(), false);
- QMetaObject::invokeMethod(object, "runTest");
- QCOMPARE(object->property("test").toBool(), true);
- delete object;
- }
- // Qt objects are not collected until they've been dereferenced
- {
- QDeclarativeComponent component(&engine, testFileUrl("propertyVarOwnership.3.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test2").toBool(), false);
- QCOMPARE(object->property("test2").toBool(), false);
-
- QMetaObject::invokeMethod(object, "runTest");
- QCOMPARE(object->property("test1").toBool(), true);
-
- QPointer<QObject> referencedObject = object->property("object").value<QObject*>();
- QVERIFY(!referencedObject.isNull());
- gc(engine);
- QVERIFY(!referencedObject.isNull());
-
- QMetaObject::invokeMethod(object, "runTest2");
- QCOMPARE(object->property("test2").toBool(), true);
- gc(engine);
- QVERIFY(referencedObject.isNull());
-
- delete object;
- }
- // Self reference does not prevent Qt object collection
- {
- QDeclarativeComponent component(&engine, testFileUrl("propertyVarOwnership.4.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- QPointer<QObject> referencedObject = object->property("object").value<QObject*>();
- QVERIFY(!referencedObject.isNull());
- gc(engine);
- QVERIFY(!referencedObject.isNull());
-
- QMetaObject::invokeMethod(object, "runTest");
- gc(engine);
- QVERIFY(referencedObject.isNull());
-
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::propertyVarImplicitOwnership()
-{
- // The childObject has a reference to a different QObject. We want to ensure
- // that the different item will not be cleaned up until required. IE, the childObject
- // has implicit ownership of the constructed QObject.
- QDeclarativeComponent component(&engine, testFileUrl("propertyVarImplicitOwnership.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "assignCircular");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QObject *rootObject = object->property("vp").value<QObject*>();
- QVERIFY(rootObject != 0);
- QObject *childObject = rootObject->findChild<QObject*>("text");
- QVERIFY(childObject != 0);
- QCOMPARE(rootObject->property("rectCanary").toInt(), 5);
- QCOMPARE(childObject->property("textCanary").toInt(), 10);
- QMetaObject::invokeMethod(childObject, "constructQObject"); // creates a reference to a constructed QObject.
- QWeakPointer<QObject> qobjectGuard(childObject->property("vp").value<QObject*>()); // get the pointer prior to processing deleteLater events.
- QVERIFY(!qobjectGuard.isNull());
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QVERIFY(!qobjectGuard.isNull());
- QMetaObject::invokeMethod(object, "deassignCircular");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QVERIFY(qobjectGuard.isNull()); // should have been collected now.
- delete object;
-}
-
-void tst_qdeclarativeecmascript::propertyVarReparent()
-{
- // ensure that nothing breaks if we re-parent objects
- QDeclarativeComponent component(&engine, testFileUrl("propertyVar.reparent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "assignVarProp");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QObject *rect = object->property("vp").value<QObject*>();
- QObject *text = rect->findChild<QObject*>("textOne");
- QObject *text2 = rect->findChild<QObject*>("textTwo");
- QWeakPointer<QObject> rectGuard(rect);
- QWeakPointer<QObject> textGuard(text);
- QWeakPointer<QObject> text2Guard(text2);
- QVERIFY(!rectGuard.isNull());
- QVERIFY(!textGuard.isNull());
- QVERIFY(!text2Guard.isNull());
- QCOMPARE(text->property("textCanary").toInt(), 11);
- QCOMPARE(text2->property("textCanary").toInt(), 12);
- // now construct an image which we will reparent.
- QMetaObject::invokeMethod(text2, "constructQObject");
- QObject *image = text2->property("vp").value<QObject*>();
- QWeakPointer<QObject> imageGuard(image);
- QVERIFY(!imageGuard.isNull());
- QCOMPARE(image->property("imageCanary").toInt(), 13);
- // now reparent the "Image" object (currently, it has JS ownership)
- image->setParent(text); // shouldn't be collected after deassignVp now, since has a parent.
- QMetaObject::invokeMethod(text2, "deassignVp");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QCOMPARE(text->property("textCanary").toInt(), 11);
- QCOMPARE(text2->property("textCanary").toInt(), 22);
- QVERIFY(!imageGuard.isNull()); // should still be alive.
- QCOMPARE(image->property("imageCanary").toInt(), 13); // still able to access var properties
- QMetaObject::invokeMethod(object, "deassignVarProp"); // now deassign the root-object's vp, causing gc of rect+text+text2
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QVERIFY(imageGuard.isNull()); // should now have been deleted, due to parent being deleted.
- delete object;
-}
-
-void tst_qdeclarativeecmascript::propertyVarReparentNullContext()
-{
- // sometimes reparenting can cause problems
- // (eg, if the ctxt is collected, varproperties are no longer available)
- // this test ensures that no crash occurs in that situation.
- QDeclarativeComponent component(&engine, testFileUrl("propertyVar.reparent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "assignVarProp");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QObject *rect = object->property("vp").value<QObject*>();
- QObject *text = rect->findChild<QObject*>("textOne");
- QObject *text2 = rect->findChild<QObject*>("textTwo");
- QWeakPointer<QObject> rectGuard(rect);
- QWeakPointer<QObject> textGuard(text);
- QWeakPointer<QObject> text2Guard(text2);
- QVERIFY(!rectGuard.isNull());
- QVERIFY(!textGuard.isNull());
- QVERIFY(!text2Guard.isNull());
- QCOMPARE(text->property("textCanary").toInt(), 11);
- QCOMPARE(text2->property("textCanary").toInt(), 12);
- // now construct an image which we will reparent.
- QMetaObject::invokeMethod(text2, "constructQObject");
- QObject *image = text2->property("vp").value<QObject*>();
- QWeakPointer<QObject> imageGuard(image);
- QVERIFY(!imageGuard.isNull());
- QCOMPARE(image->property("imageCanary").toInt(), 13);
- // now reparent the "Image" object (currently, it has JS ownership)
- image->setParent(object); // reparented to base object. after deassignVarProp, the ctxt will be invalid.
- QMetaObject::invokeMethod(object, "deassignVarProp"); // now deassign the root-object's vp, causing gc of rect+text+text2
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QVERIFY(!imageGuard.isNull()); // should still be alive.
- QVERIFY(!image->property("imageCanary").isValid()); // but varProperties won't be available (null context).
- delete object;
- QVERIFY(imageGuard.isNull()); // should now be dead.
-}
-
-void tst_qdeclarativeecmascript::propertyVarCircular()
-{
- // enforce behaviour regarding circular references - ensure qdvmemo deletion.
- QDeclarativeComponent component(&engine, testFileUrl("propertyVar.circular.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "assignCircular"); // cause assignment and gc
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QCOMPARE(object->property("canaryInt"), QVariant(5));
- QVariant canaryResourceVariant = object->property("canaryResource");
- QVERIFY(canaryResourceVariant.isValid());
- QPixmap canaryResourcePixmap = canaryResourceVariant.value<QPixmap>();
- canaryResourceVariant = QVariant(); // invalidate it to remove one copy of the pixmap from memory.
- QMetaObject::invokeMethod(object, "deassignCanaryResource"); // remove one copy of the pixmap from memory
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QVERIFY(!canaryResourcePixmap.isDetached()); // two copies extant - this and the propertyVar.vp.vp.vp.vp.memoryHog.
- QMetaObject::invokeMethod(object, "deassignCircular"); // cause deassignment and gc
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QCOMPARE(object->property("canaryInt"), QVariant(2));
- QCOMPARE(object->property("canaryResource"), QVariant(1));
- QVERIFY(canaryResourcePixmap.isDetached()); // now detached, since orig copy was member of qdvmemo which was deleted.
- delete object;
-}
-
-void tst_qdeclarativeecmascript::propertyVarCircular2()
-{
- // track deletion of JS-owned parent item with Cpp-owned child
- // where the child has a var property referencing its parent.
- QDeclarativeComponent component(&engine, testFileUrl("propertyVar.circular.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "assignCircular");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QObject *rootObject = object->property("vp").value<QObject*>();
- QVERIFY(rootObject != 0);
- QObject *childObject = rootObject->findChild<QObject*>("text");
- QVERIFY(childObject != 0);
- QWeakPointer<QObject> rootObjectTracker(rootObject);
- QVERIFY(!rootObjectTracker.isNull());
- QWeakPointer<QObject> childObjectTracker(childObject);
- QVERIFY(!childObjectTracker.isNull());
- gc(engine);
- QCOMPARE(rootObject->property("rectCanary").toInt(), 5);
- QCOMPARE(childObject->property("textCanary").toInt(), 10);
- QMetaObject::invokeMethod(object, "deassignCircular");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QVERIFY(rootObjectTracker.isNull()); // should have been collected
- QVERIFY(childObjectTracker.isNull()); // should have been collected
- delete object;
-}
-
-void tst_qdeclarativeecmascript::propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter)
-{
- *(int*)(parameter) += 1;
- qPersistentDispose(object);
-}
-
-void tst_qdeclarativeecmascript::propertyVarInheritance()
-{
- int propertyVarWeakRefCallbackCount = 0;
-
- // enforce behaviour regarding element inheritance - ensure handle disposal.
- // The particular component under test here has a chain of references.
- QDeclarativeComponent component(&engine, testFileUrl("propertyVar.inherit.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "assignCircular"); // cause assignment and gc
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- // we want to be able to track when the varProperties array of the last metaobject is disposed
- QObject *cco5 = object->property("varProperty").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>();
- QObject *ico5 = object->property("varProperty").value<QObject*>()->property("inheritanceVarProperty").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>();
- QDeclarativeVMEMetaObject *icovmemo = ((QDeclarativeVMEMetaObject *)(ico5->metaObject()));
- QDeclarativeVMEMetaObject *ccovmemo = ((QDeclarativeVMEMetaObject *)(cco5->metaObject()));
- v8::Persistent<v8::Value> icoCanaryHandle;
- v8::Persistent<v8::Value> ccoCanaryHandle;
- {
- v8::HandleScope hs;
- // XXX NOTE: this is very implementation dependent. QDVMEMO->vmeProperty() is the only
- // public function which can return us a handle to something in the varProperties array.
- icoCanaryHandle = qPersistentNew(icovmemo->vmeProperty(ico5->metaObject()->indexOfProperty("circ")));
- ccoCanaryHandle = qPersistentNew(ccovmemo->vmeProperty(cco5->metaObject()->indexOfProperty("circ")));
- // we make them weak and invoke the gc, but we should not hit the weak-callback yet
- // as the varproperties array of each vmemo still references the resource.
- icoCanaryHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback);
- ccoCanaryHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback);
- gc(engine);
- QVERIFY(propertyVarWeakRefCallbackCount == 0);
- }
- // now we deassign the var prop, which should trigger collection of item subtrees.
- QMetaObject::invokeMethod(object, "deassignCircular"); // cause deassignment and gc
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- // ensure that there are only weak handles to the underlying varProperties array remaining.
- gc(engine);
- QCOMPARE(propertyVarWeakRefCallbackCount, 2); // should have been called for both, since all refs should be weak.
- delete object;
- // since there are no parent vmemo's to keep implicit references alive, and the only handles
- // to what remains are weak, all varProperties arrays must have been collected.
-}
-
-void tst_qdeclarativeecmascript::propertyVarInheritance2()
-{
- int propertyVarWeakRefCallbackCount = 0;
-
- // The particular component under test here does NOT have a chain of references; the
- // only link between rootObject and childObject is that rootObject is the parent of childObject.
- QDeclarativeComponent component(&engine, testFileUrl("propertyVar.circular.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "assignCircular");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QObject *rootObject = object->property("vp").value<QObject*>();
- QVERIFY(rootObject != 0);
- QObject *childObject = rootObject->findChild<QObject*>("text");
- QVERIFY(childObject != 0);
- QCOMPARE(rootObject->property("rectCanary").toInt(), 5);
- QCOMPARE(childObject->property("textCanary").toInt(), 10);
- v8::Persistent<v8::Value> childObjectVarArrayValueHandle;
- {
- v8::HandleScope hs;
- propertyVarWeakRefCallbackCount = 0; // reset callback count.
- childObjectVarArrayValueHandle = qPersistentNew(((QDeclarativeVMEMetaObject *)(childObject->metaObject()))->vmeProperty(childObject->metaObject()->indexOfProperty("vp")));
- childObjectVarArrayValueHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback);
- gc(engine);
- QVERIFY(propertyVarWeakRefCallbackCount == 0); // should not have been collected yet.
- QCOMPARE(childObject->property("vp").value<QObject*>(), rootObject);
- QCOMPARE(childObject->property("textCanary").toInt(), 10);
- }
- QMetaObject::invokeMethod(object, "deassignCircular");
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
- QCoreApplication::processEvents();
- QVERIFY(propertyVarWeakRefCallbackCount == 1); // should have been collected now.
- delete object;
-}
-
-// Ensure that QObject type conversion works on binding assignment
-void tst_qdeclarativeecmascript::elementAssign()
-{
- QDeclarativeComponent component(&engine, testFileUrl("elementAssign.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// QTBUG-12457
-void tst_qdeclarativeecmascript::objectPassThroughSignals()
-{
- QDeclarativeComponent component(&engine, testFileUrl("objectsPassThroughSignals.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// QTBUG-21626
-void tst_qdeclarativeecmascript::objectConversion()
-{
- QDeclarativeComponent component(&engine, testFileUrl("objectConversion.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
- QVariant retn;
- QMetaObject::invokeMethod(object, "circularObject", Q_RETURN_ARG(QVariant, retn));
- QCOMPARE(retn.value<QVariantMap>().value("test"), QVariant(100));
-
- delete object;
-}
-
-
-// QTBUG-20242
-void tst_qdeclarativeecmascript::booleanConversion()
-{
- QDeclarativeComponent component(&engine, testFileUrl("booleanConversion.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test_true1").toBool(), true);
- QCOMPARE(object->property("test_true2").toBool(), true);
- QCOMPARE(object->property("test_true3").toBool(), true);
- QCOMPARE(object->property("test_true4").toBool(), true);
- QCOMPARE(object->property("test_true5").toBool(), true);
-
- QCOMPARE(object->property("test_false1").toBool(), false);
- QCOMPARE(object->property("test_false2").toBool(), false);
- QCOMPARE(object->property("test_false3").toBool(), false);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::handleReferenceManagement()
-{
-
- int dtorCount = 0;
- {
- // Linear QObject reference
- QDeclarativeEngine hrmEngine;
- QDeclarativeComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.object.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- CircularReferenceObject *cro = object->findChild<CircularReferenceObject*>("cro");
- cro->setEngine(&hrmEngine);
- cro->setDtorCount(&dtorCount);
- QMetaObject::invokeMethod(object, "createReference");
- gc(engine);
- QCOMPARE(dtorCount, 0); // second has JS ownership, kept alive by first's reference
- delete object;
- hrmEngine.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 3);
- }
-
- dtorCount = 0;
- {
- // Circular QObject reference
- QDeclarativeEngine hrmEngine;
- QDeclarativeComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.object.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- CircularReferenceObject *cro = object->findChild<CircularReferenceObject*>("cro");
- cro->setEngine(&hrmEngine);
- cro->setDtorCount(&dtorCount);
- QMetaObject::invokeMethod(object, "circularReference");
- gc(engine);
- QCOMPARE(dtorCount, 2); // both should be cleaned up, since circular references shouldn't keep alive.
- delete object;
- hrmEngine.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 3);
- }
-
- dtorCount = 0;
- {
- // Linear handle reference
- QDeclarativeEngine hrmEngine;
- QDeclarativeComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.handle.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- CircularReferenceHandle *crh = object->findChild<CircularReferenceHandle*>("crh");
- QVERIFY(crh != 0);
- crh->setEngine(&hrmEngine);
- crh->setDtorCount(&dtorCount);
- QMetaObject::invokeMethod(object, "createReference");
- CircularReferenceHandle *first = object->property("first").value<CircularReferenceHandle*>();
- CircularReferenceHandle *second = object->property("second").value<CircularReferenceHandle*>();
- QVERIFY(first != 0);
- QVERIFY(second != 0);
- first->addReference(QDeclarativeData::get(second)->v8object); // create reference
- // now we have to reparent second and make second owned by JS.
- second->setParent(0);
- QDeclarativeEngine::setObjectOwnership(second, QDeclarativeEngine::JavaScriptOwnership);
- gc(engine);
- QCOMPARE(dtorCount, 0); // due to reference from first to second, second shouldn't be collected.
- delete object;
- hrmEngine.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 3);
- }
-
- dtorCount = 0;
- {
- // Circular handle reference
- QDeclarativeEngine hrmEngine;
- QDeclarativeComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.handle.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- CircularReferenceHandle *crh = object->findChild<CircularReferenceHandle*>("crh");
- QVERIFY(crh != 0);
- crh->setEngine(&hrmEngine);
- crh->setDtorCount(&dtorCount);
- QMetaObject::invokeMethod(object, "circularReference");
- CircularReferenceHandle *first = object->property("first").value<CircularReferenceHandle*>();
- CircularReferenceHandle *second = object->property("second").value<CircularReferenceHandle*>();
- QVERIFY(first != 0);
- QVERIFY(second != 0);
- first->addReference(QDeclarativeData::get(second)->v8object); // create circular reference
- second->addReference(QDeclarativeData::get(first)->v8object); // note: must be weak.
- // now we have to reparent and change ownership.
- first->setParent(0);
- second->setParent(0);
- QDeclarativeEngine::setObjectOwnership(first, QDeclarativeEngine::JavaScriptOwnership);
- QDeclarativeEngine::setObjectOwnership(second, QDeclarativeEngine::JavaScriptOwnership);
- gc(engine);
- QCOMPARE(dtorCount, 2); // despite circular references, both will be collected.
- delete object;
- hrmEngine.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 3);
- }
-
- dtorCount = 0;
- {
- // multiple engine interaction - linear reference
- QDeclarativeEngine hrmEngine1;
- QDeclarativeEngine hrmEngine2;
- QDeclarativeComponent component1(&hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml"));
- QDeclarativeComponent component2(&hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml"));
- QObject *object1 = component1.create();
- QObject *object2 = component2.create();
- QVERIFY(object1 != 0);
- QVERIFY(object2 != 0);
- CircularReferenceHandle *crh1 = object1->findChild<CircularReferenceHandle*>("crh");
- CircularReferenceHandle *crh2 = object2->findChild<CircularReferenceHandle*>("crh");
- QVERIFY(crh1 != 0);
- QVERIFY(crh2 != 0);
- crh1->setEngine(&hrmEngine1);
- crh2->setEngine(&hrmEngine2);
- crh1->setDtorCount(&dtorCount);
- crh2->setDtorCount(&dtorCount);
- QMetaObject::invokeMethod(object1, "createReference");
- QMetaObject::invokeMethod(object2, "createReference");
- CircularReferenceHandle *first1 = object1->property("first").value<CircularReferenceHandle*>();
- CircularReferenceHandle *second1 = object1->property("second").value<CircularReferenceHandle*>();
- CircularReferenceHandle *first2 = object2->property("first").value<CircularReferenceHandle*>();
- CircularReferenceHandle *second2 = object2->property("second").value<CircularReferenceHandle*>();
- QVERIFY(first1 != 0);
- QVERIFY(second1 != 0);
- QVERIFY(first2 != 0);
- QVERIFY(second2 != 0);
- first1->addReference(QDeclarativeData::get(second2)->v8object); // create reference across engines
- // now we have to reparent second2 and make second2 owned by JS.
- second2->setParent(0);
- QDeclarativeEngine::setObjectOwnership(second2, QDeclarativeEngine::JavaScriptOwnership);
- gc(engine);
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 0); // due to reference from first1 to second2, second2 shouldn't be collected.
- delete object1;
- delete object2;
- hrmEngine1.collectGarbage();
- hrmEngine2.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 6);
- }
-
- dtorCount = 0;
- {
- // multiple engine interaction - circular reference
- QDeclarativeEngine hrmEngine1;
- QDeclarativeEngine hrmEngine2;
- QDeclarativeComponent component1(&hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml"));
- QDeclarativeComponent component2(&hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml"));
- QObject *object1 = component1.create();
- QObject *object2 = component2.create();
- QVERIFY(object1 != 0);
- QVERIFY(object2 != 0);
- CircularReferenceHandle *crh1 = object1->findChild<CircularReferenceHandle*>("crh");
- CircularReferenceHandle *crh2 = object2->findChild<CircularReferenceHandle*>("crh");
- QVERIFY(crh1 != 0);
- QVERIFY(crh2 != 0);
- crh1->setEngine(&hrmEngine1);
- crh2->setEngine(&hrmEngine2);
- crh1->setDtorCount(&dtorCount);
- crh2->setDtorCount(&dtorCount);
- QMetaObject::invokeMethod(object1, "createReference");
- QMetaObject::invokeMethod(object2, "createReference");
- CircularReferenceHandle *first1 = object1->property("first").value<CircularReferenceHandle*>();
- CircularReferenceHandle *second1 = object1->property("second").value<CircularReferenceHandle*>();
- CircularReferenceHandle *first2 = object2->property("first").value<CircularReferenceHandle*>();
- CircularReferenceHandle *second2 = object2->property("second").value<CircularReferenceHandle*>();
- QVERIFY(first1 != 0);
- QVERIFY(second1 != 0);
- QVERIFY(first2 != 0);
- QVERIFY(second2 != 0);
- first1->addReference(QDeclarativeData::get(second1)->v8object); // create linear reference within engine1
- second1->addReference(QDeclarativeData::get(second2)->v8object); // create linear reference across engines
- second2->addReference(QDeclarativeData::get(first2)->v8object); // create linear reference within engine2
- first2->addReference(QDeclarativeData::get(first1)->v8object); // close the loop - circular ref across engines
- // now we have to reparent and change ownership to JS.
- first1->setParent(0);
- second1->setParent(0);
- first2->setParent(0);
- second2->setParent(0);
- QDeclarativeEngine::setObjectOwnership(first1, QDeclarativeEngine::JavaScriptOwnership);
- QDeclarativeEngine::setObjectOwnership(second1, QDeclarativeEngine::JavaScriptOwnership);
- QDeclarativeEngine::setObjectOwnership(first2, QDeclarativeEngine::JavaScriptOwnership);
- QDeclarativeEngine::setObjectOwnership(second2, QDeclarativeEngine::JavaScriptOwnership);
- gc(engine);
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 4); // circular references shouldn't keep them alive.
- delete object1;
- delete object2;
- hrmEngine1.collectGarbage();
- hrmEngine2.collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 6);
- }
-
- dtorCount = 0;
- {
- // multiple engine interaction - linear reference with engine deletion
- QDeclarativeEngine *hrmEngine1 = new QDeclarativeEngine;
- QDeclarativeEngine *hrmEngine2 = new QDeclarativeEngine;
- QDeclarativeComponent component1(hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml"));
- QDeclarativeComponent component2(hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml"));
- QObject *object1 = component1.create();
- QObject *object2 = component2.create();
- QVERIFY(object1 != 0);
- QVERIFY(object2 != 0);
- CircularReferenceHandle *crh1 = object1->findChild<CircularReferenceHandle*>("crh");
- CircularReferenceHandle *crh2 = object2->findChild<CircularReferenceHandle*>("crh");
- QVERIFY(crh1 != 0);
- QVERIFY(crh2 != 0);
- crh1->setEngine(hrmEngine1);
- crh2->setEngine(hrmEngine2);
- crh1->setDtorCount(&dtorCount);
- crh2->setDtorCount(&dtorCount);
- QMetaObject::invokeMethod(object1, "createReference");
- QMetaObject::invokeMethod(object2, "createReference");
- CircularReferenceHandle *first1 = object1->property("first").value<CircularReferenceHandle*>();
- CircularReferenceHandle *second1 = object1->property("second").value<CircularReferenceHandle*>();
- CircularReferenceHandle *first2 = object2->property("first").value<CircularReferenceHandle*>();
- CircularReferenceHandle *second2 = object2->property("second").value<CircularReferenceHandle*>();
- QVERIFY(first1 != 0);
- QVERIFY(second1 != 0);
- QVERIFY(first2 != 0);
- QVERIFY(second2 != 0);
- first1->addReference(QDeclarativeData::get(second1)->v8object); // create linear reference within engine1
- second1->addReference(QDeclarativeData::get(second2)->v8object); // create linear reference across engines
- second2->addReference(QDeclarativeData::get(first2)->v8object); // create linear reference within engine2
- // now we have to reparent and change ownership to JS.
- first1->setParent(crh1);
- second1->setParent(0);
- first2->setParent(0);
- second2->setParent(0);
- QDeclarativeEngine::setObjectOwnership(second1, QDeclarativeEngine::JavaScriptOwnership);
- QDeclarativeEngine::setObjectOwnership(first2, QDeclarativeEngine::JavaScriptOwnership);
- QDeclarativeEngine::setObjectOwnership(second2, QDeclarativeEngine::JavaScriptOwnership);
- gc(engine);
- QCOMPARE(dtorCount, 0);
- delete hrmEngine2;
- gc(engine);
- QCOMPARE(dtorCount, 0);
- delete object1;
- delete object2;
- hrmEngine1->collectGarbage();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QCOMPARE(dtorCount, 6);
- delete hrmEngine1;
- }
-}
-
-void tst_qdeclarativeecmascript::stringArg()
-{
- QDeclarativeComponent component(&engine, testFileUrl("stringArg.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "success");
- QVERIFY(object->property("returnValue").toBool());
-
- QString w1 = testFileUrl("stringArg.qml").toString() + QLatin1String(":45: Error: String.arg(): Invalid arguments");
- QTest::ignoreMessage(QtWarningMsg, w1.toAscii().constData());
- QMetaObject::invokeMethod(object, "failure");
- QVERIFY(object->property("returnValue").toBool());
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::readonlyDeclaration()
-{
- QDeclarativeComponent component(&engine, testFileUrl("readonlyDeclaration.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-Q_DECLARE_METATYPE(QList<int>)
-Q_DECLARE_METATYPE(QList<qreal>)
-Q_DECLARE_METATYPE(QList<bool>)
-Q_DECLARE_METATYPE(QList<QString>)
-Q_DECLARE_METATYPE(QList<QUrl>)
-void tst_qdeclarativeecmascript::sequenceConversionRead()
-{
- {
- QUrl qmlFile = testFileUrl("sequenceConversion.read.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco");
- QVERIFY(seq != 0);
-
- QMetaObject::invokeMethod(object, "readSequences");
- QList<int> intList; intList << 1 << 2 << 3 << 4;
- QCOMPARE(object->property("intListLength").toInt(), intList.length());
- QCOMPARE(object->property("intList").value<QList<int> >(), intList);
- QList<qreal> qrealList; qrealList << 1.1 << 2.2 << 3.3 << 4.4;
- QCOMPARE(object->property("qrealListLength").toInt(), qrealList.length());
- QCOMPARE(object->property("qrealList").value<QList<qreal> >(), qrealList);
- QList<bool> boolList; boolList << true << false << true << false;
- QCOMPARE(object->property("boolListLength").toInt(), boolList.length());
- QCOMPARE(object->property("boolList").value<QList<bool> >(), boolList);
- QList<QString> stringList; stringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
- QCOMPARE(object->property("stringListLength").toInt(), stringList.length());
- QCOMPARE(object->property("stringList").value<QList<QString> >(), stringList);
- QList<QUrl> urlList; urlList << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com");
- QCOMPARE(object->property("urlListLength").toInt(), urlList.length());
- QCOMPARE(object->property("urlList").value<QList<QUrl> >(), urlList);
- QStringList qstringList; qstringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
- QCOMPARE(object->property("qstringListLength").toInt(), qstringList.length());
- QCOMPARE(object->property("qstringList").value<QStringList>(), qstringList);
-
- QMetaObject::invokeMethod(object, "readSequenceElements");
- QCOMPARE(object->property("intVal").toInt(), 2);
- QCOMPARE(object->property("qrealVal").toReal(), 2.2);
- QCOMPARE(object->property("boolVal").toBool(), false);
- QCOMPARE(object->property("stringVal").toString(), QString(QLatin1String("second")));
- QCOMPARE(object->property("urlVal").toUrl(), QUrl("http://www.example2.com"));
- QCOMPARE(object->property("qstringVal").toString(), QString(QLatin1String("second")));
-
- QMetaObject::invokeMethod(object, "enumerateSequenceElements");
- QCOMPARE(object->property("enumerationMatches").toBool(), true);
-
- intList.clear(); intList << 1 << 2 << 3 << 4 << 5; // set by the enumerateSequenceElements test.
- QDeclarativeProperty seqProp(seq, "intListProperty");
- QCOMPARE(seqProp.read().value<QList<int> >(), intList);
- QDeclarativeProperty seqProp2(seq, "intListProperty", &engine);
- QCOMPARE(seqProp2.read().value<QList<int> >(), intList);
-
- QMetaObject::invokeMethod(object, "testReferenceDeletion");
- QCOMPARE(object->property("referenceDeletion").toBool(), true);
-
- delete object;
- }
-
- {
- QUrl qmlFile = testFileUrl("sequenceConversion.read.error.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco");
- QVERIFY(seq != 0);
-
- // we haven't registered QList<QPoint> as a sequence type.
- QString warningOne = QLatin1String("QMetaProperty::read: Unable to handle unregistered datatype 'QList<QPoint>' for property 'MySequenceConversionObject::pointListProperty'");
- QString warningTwo = qmlFile.toString() + QLatin1String(":18: TypeError: Cannot read property 'length' of undefined");
- QTest::ignoreMessage(QtWarningMsg, warningOne.toAscii().constData());
- QTest::ignoreMessage(QtWarningMsg, warningTwo.toAscii().constData());
-
- QMetaObject::invokeMethod(object, "performTest");
-
- // QList<QPoint> has not been registered as a sequence type.
- QCOMPARE(object->property("pointListLength").toInt(), 0);
- QVERIFY(!object->property("pointList").isValid());
- QTest::ignoreMessage(QtWarningMsg, "QMetaProperty::read: Unable to handle unregistered datatype 'QList<QPoint>' for property 'MySequenceConversionObject::pointListProperty'");
- QDeclarativeProperty seqProp(seq, "pointListProperty", &engine);
- QVERIFY(!seqProp.read().isValid()); // not a valid/known sequence type
-
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::sequenceConversionWrite()
-{
- {
- QUrl qmlFile = testFileUrl("sequenceConversion.write.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco");
- QVERIFY(seq != 0);
-
- QMetaObject::invokeMethod(object, "writeSequences");
- QCOMPARE(object->property("success").toBool(), true);
-
- QMetaObject::invokeMethod(object, "writeSequenceElements");
- QCOMPARE(object->property("success").toBool(), true);
-
- QMetaObject::invokeMethod(object, "writeOtherElements");
- QCOMPARE(object->property("success").toBool(), true);
-
- QMetaObject::invokeMethod(object, "testReferenceDeletion");
- QCOMPARE(object->property("referenceDeletion").toBool(), true);
-
- delete object;
- }
-
- {
- QUrl qmlFile = testFileUrl("sequenceConversion.write.error.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco");
- QVERIFY(seq != 0);
-
- // we haven't registered QList<QPoint> as a sequence type, so writing shouldn't work.
- QString warningOne = qmlFile.toString() + QLatin1String(":16: Error: Cannot assign QVariantList to void");
- QTest::ignoreMessage(QtWarningMsg, warningOne.toAscii().constData());
-
- QMetaObject::invokeMethod(object, "performTest");
-
- QList<QPoint> pointList; pointList << QPoint(1, 2) << QPoint(3, 4) << QPoint(5, 6); // original values, shouldn't have changed
- QCOMPARE(seq->pointListProperty(), pointList);
-
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::sequenceConversionArray()
-{
- // ensure that in JS the returned sequences act just like normal JS Arrays.
- QUrl qmlFile = testFileUrl("sequenceConversion.array.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "indexedAccess");
- QVERIFY(object->property("success").toBool());
- QMetaObject::invokeMethod(object, "arrayOperations");
- QVERIFY(object->property("success").toBool());
- QMetaObject::invokeMethod(object, "testEqualitySemantics");
- QVERIFY(object->property("success").toBool());
- QMetaObject::invokeMethod(object, "testReferenceDeletion");
- QCOMPARE(object->property("referenceDeletion").toBool(), true);
- delete object;
-}
-
-
-void tst_qdeclarativeecmascript::sequenceConversionIndexes()
-{
- // ensure that we gracefully fail if unsupported index values are specified.
- // Qt container classes only support non-negative, signed integer index values.
- QUrl qmlFile = testFileUrl("sequenceConversion.indexes.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QString w1 = qmlFile.toString() + QLatin1String(":34: Index out of range during length set");
- QString w2 = qmlFile.toString() + QLatin1String(":41: Index out of range during indexed set");
- QString w3 = qmlFile.toString() + QLatin1String(":48: Index out of range during indexed get");
- QString w4 = qmlFile.toString() + QLatin1String(":78: std::bad_alloc during length set");
- QString w5 = qmlFile.toString() + QLatin1String(":83: std::bad_alloc during indexed set");
- QTest::ignoreMessage(QtWarningMsg, qPrintable(w1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(w2));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(w3));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(w4));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(w5));
- QMetaObject::invokeMethod(object, "indexedAccess");
- QVERIFY(object->property("success").toBool());
- delete object;
-}
-
-void tst_qdeclarativeecmascript::sequenceConversionThreads()
-{
- // ensure that sequence conversion operations work correctly in a worker thread
- // and that serialisation between the main and worker thread succeeds.
- QUrl qmlFile = testFileUrl("sequenceConversion.threads.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QMetaObject::invokeMethod(object, "testIntSequence");
- QTRY_VERIFY(object->property("finished").toBool());
- QVERIFY(object->property("success").toBool());
-
- QMetaObject::invokeMethod(object, "testQrealSequence");
- QTRY_VERIFY(object->property("finished").toBool());
- QVERIFY(object->property("success").toBool());
-
- QMetaObject::invokeMethod(object, "testBoolSequence");
- QTRY_VERIFY(object->property("finished").toBool());
- QVERIFY(object->property("success").toBool());
-
- QMetaObject::invokeMethod(object, "testStringSequence");
- QTRY_VERIFY(object->property("finished").toBool());
- QVERIFY(object->property("success").toBool());
-
- QMetaObject::invokeMethod(object, "testQStringSequence");
- QTRY_VERIFY(object->property("finished").toBool());
- QVERIFY(object->property("success").toBool());
-
- QMetaObject::invokeMethod(object, "testUrlSequence");
- QTRY_VERIFY(object->property("finished").toBool());
- QVERIFY(object->property("success").toBool());
-
- QMetaObject::invokeMethod(object, "testVariantSequence");
- QTRY_VERIFY(object->property("finished").toBool());
- QVERIFY(object->property("success").toBool());
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::sequenceConversionBindings()
-{
- {
- QUrl qmlFile = testFileUrl("sequenceConversion.bindings.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QList<int> intList; intList << 1 << 2 << 3 << 12 << 7;
- QCOMPARE(object->property("boundSequence").value<QList<int> >(), intList);
- QCOMPARE(object->property("boundElement").toInt(), intList.at(3));
- QList<int> intListTwo; intListTwo << 1 << 2 << 3 << 12 << 14;
- QCOMPARE(object->property("boundSequenceTwo").value<QList<int> >(), intListTwo);
- delete object;
- }
-
- {
- QUrl qmlFile = testFileUrl("sequenceConversion.bindings.error.qml");
- QString warning = QString(QLatin1String("%1:17: Unable to assign QList<int> to QList<bool>")).arg(qmlFile.toString());
- QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::sequenceConversionCopy()
-{
- QUrl qmlFile = testFileUrl("sequenceConversion.copy.qml");
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QMetaObject::invokeMethod(object, "testCopySequences");
- QCOMPARE(object->property("success").toBool(), true);
- QMetaObject::invokeMethod(object, "readSequenceCopyElements");
- QCOMPARE(object->property("success").toBool(), true);
- QMetaObject::invokeMethod(object, "testEqualitySemantics");
- QCOMPARE(object->property("success").toBool(), true);
- delete object;
-}
-
-void tst_qdeclarativeecmascript::assignSequenceTypes()
-{
- // test binding array to sequence type property
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.1.qml"));
- MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->intListProperty(), (QList<int>() << 1 << 2));
- QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1 << 2.2));
- QCOMPARE(object->boolListProperty(), (QList<bool>() << false << true));
- QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl("http://www.example1.com") << QUrl("http://www.example2.com")));
- QCOMPARE(object->stringListProperty(), (QList<QString>() << QLatin1String("one") << QLatin1String("two")));
- QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("one") << QLatin1String("two")));
- delete object;
- }
-
- // test binding literal to sequence type property
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.2.qml"));
- MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->intListProperty(), (QList<int>() << 1));
- QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
- QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
- QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl("http://www.example1.com")));
- QCOMPARE(object->stringListProperty(), (QList<QString>() << QLatin1String("one")));
- QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("two")));
- delete object;
- }
-
- // test binding single value to sequence type property
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.3.qml"));
- MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->intListProperty(), (QList<int>() << 1));
- QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
- QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
- QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
- delete object;
- }
-
- // test assigning array to sequence type property in js function
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.4.qml"));
- MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->intListProperty(), (QList<int>() << 1 << 2));
- QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1 << 2.2));
- QCOMPARE(object->boolListProperty(), (QList<bool>() << false << true));
- QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl("http://www.example1.com") << QUrl("http://www.example2.com")));
- QCOMPARE(object->stringListProperty(), (QList<QString>() << QLatin1String("one") << QLatin1String("two")));
- QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("one") << QLatin1String("two")));
- delete object;
- }
-
- // test assigning literal to sequence type property in js function
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.5.qml"));
- MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->intListProperty(), (QList<int>() << 1));
- QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
- QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
- QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl("http://www.example1.com")));
- QCOMPARE(object->stringListProperty(), (QList<QString>() << QLatin1String("one")));
- QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("two")));
- delete object;
- }
-
- // test assigning single value to sequence type property in js function
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.6.qml"));
- MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->intListProperty(), (QList<int>() << 1));
- QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
- QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
- QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
- delete object;
- }
-
- // test QList<QUrl> literal assignment and binding assignment causes url resolution when required
- {
- QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.7.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- MySequenceConversionObject *msco1 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco1"));
- MySequenceConversionObject *msco2 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco2"));
- MySequenceConversionObject *msco3 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco3"));
- MySequenceConversionObject *msco4 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco4"));
- MySequenceConversionObject *msco5 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco5"));
- QVERIFY(msco1 != 0 && msco2 != 0 && msco3 != 0 && msco4 != 0 && msco5 != 0);
- QCOMPARE(msco1->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
- QCOMPARE(msco2->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
- QCOMPARE(msco3->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
- QCOMPARE(msco4->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
- QCOMPARE(msco5->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
- delete object;
- }
-}
-
-// Test that assigning a null object works
-// Regressed with: df1788b4dbbb2826ae63f26bdf166342595343f4
-void tst_qdeclarativeecmascript::nullObjectBinding()
-{
- QDeclarativeComponent component(&engine, testFileUrl("nullObjectBinding.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVERIFY(object->property("test") == QVariant::fromValue((QObject *)0));
-
- delete object;
-}
-
-// Test that bindings don't evaluate once the engine has been destroyed
-void tst_qdeclarativeecmascript::deletedEngine()
-{
- QDeclarativeEngine *engine = new QDeclarativeEngine;
- QDeclarativeComponent component(engine, testFileUrl("deletedEngine.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("a").toInt(), 39);
- object->setProperty("b", QVariant(9));
- QCOMPARE(object->property("a").toInt(), 117);
-
- delete engine;
-
- QCOMPARE(object->property("a").toInt(), 117);
- object->setProperty("b", QVariant(10));
- QCOMPARE(object->property("a").toInt(), 117);
-
- delete object;
-}
-
-// Test the crashing part of QTBUG-9705
-void tst_qdeclarativeecmascript::libraryScriptAssert()
-{
- QDeclarativeComponent component(&engine, testFileUrl("libraryScriptAssert.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::variantsAssignedUndefined()
-{
- QDeclarativeComponent component(&engine, testFileUrl("variantsAssignedUndefined.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toInt(), 10);
- QCOMPARE(object->property("test2").toInt(), 11);
-
- object->setProperty("runTest", true);
-
- QCOMPARE(object->property("test1"), QVariant());
- QCOMPARE(object->property("test2"), QVariant());
-
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::qtbug_9792()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_9792.qml"));
-
- QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
-
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create(context));
- QVERIFY(object != 0);
-
- QTest::ignoreMessage(QtDebugMsg, "Hello world!");
- object->basicSignal();
-
- delete context;
-
- transientErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
-
- object->basicSignal();
-
- qInstallMsgHandler(old);
-
- QCOMPARE(transientErrorsMsgCount, 0);
-
- delete object;
-}
-
-// Verifies that QDeclarativeGuard<>s used in the vmemetaobject are cleaned correctly
-void tst_qdeclarativeecmascript::qtcreatorbug_1289()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtcreatorbug_1289.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QObject *nested = qvariant_cast<QObject *>(o->property("object"));
- QVERIFY(nested != 0);
-
- QVERIFY(qvariant_cast<QObject *>(nested->property("nestedObject")) == o);
-
- delete nested;
- nested = qvariant_cast<QObject *>(o->property("object"));
- QVERIFY(nested == 0);
-
- // If the bug is present, the next line will crash
- delete o;
-}
-
-// Test that we shut down without stupid warnings
-void tst_qdeclarativeecmascript::noSpuriousWarningsAtShutdown()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("noSpuriousWarningsAtShutdown.qml"));
-
- QObject *o = component.create();
-
- transientErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
-
- delete o;
-
- qInstallMsgHandler(old);
-
- QCOMPARE(transientErrorsMsgCount, 0);
- }
-
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("noSpuriousWarningsAtShutdown.2.qml"));
-
- QObject *o = component.create();
-
- transientErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
-
- delete o;
-
- qInstallMsgHandler(old);
-
- QCOMPARE(transientErrorsMsgCount, 0);
- }
-}
-
-void tst_qdeclarativeecmascript::canAssignNullToQObject()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("canAssignNullToQObject.1.qml"));
-
- MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(o != 0);
-
- QVERIFY(o->objectProperty() != 0);
-
- o->setProperty("runTest", true);
-
- QVERIFY(o->objectProperty() == 0);
-
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("canAssignNullToQObject.2.qml"));
-
- MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(o != 0);
-
- QVERIFY(o->objectProperty() == 0);
-
- delete o;
- }
-}
-
-void tst_qdeclarativeecmascript::functionAssignment_fromBinding()
-{
- QDeclarativeComponent component(&engine, testFileUrl("functionAssignment.1.qml"));
-
- QString url = component.url().toString();
- QString warning = url + ":4: Unable to assign a function to a property.";
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
-
- MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(o != 0);
-
- QVERIFY(!o->property("a").isValid());
-
- delete o;
-}
-
-void tst_qdeclarativeecmascript::functionAssignment_fromJS()
-{
- QFETCH(QString, triggerProperty);
-
- QDeclarativeComponent component(&engine, testFileUrl("functionAssignment.2.qml"));
- QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
-
- MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(o != 0);
- QVERIFY(!o->property("a").isValid());
-
- o->setProperty("aNumber", QVariant(5));
- o->setProperty(triggerProperty.toUtf8().constData(), true);
- QCOMPARE(o->property("a"), QVariant(50));
-
- o->setProperty("aNumber", QVariant(10));
- QCOMPARE(o->property("a"), QVariant(100));
-
- delete o;
-}
-
-void tst_qdeclarativeecmascript::functionAssignment_fromJS_data()
-{
- QTest::addColumn<QString>("triggerProperty");
-
- QTest::newRow("assign to property") << "assignToProperty";
- QTest::newRow("assign to property, from JS file") << "assignToPropertyFromJsFile";
-
- QTest::newRow("assign to value type") << "assignToValueType";
-
- QTest::newRow("use 'this'") << "assignWithThis";
- QTest::newRow("use 'this' from JS file") << "assignWithThisFromJsFile";
-}
-
-void tst_qdeclarativeecmascript::functionAssignmentfromJS_invalid()
-{
- QDeclarativeComponent component(&engine, testFileUrl("functionAssignment.2.qml"));
- QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
-
- MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(o != 0);
- QVERIFY(!o->property("a").isValid());
-
- o->setProperty("assignFuncWithoutReturn", true);
- QVERIFY(!o->property("a").isValid());
-
- QString url = component.url().toString();
- QString warning = url + ":67: Unable to assign QString to int";
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- o->setProperty("assignWrongType", true);
-
- warning = url + ":71: Unable to assign QString to int";
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
- o->setProperty("assignWrongTypeToValueType", true);
-
- delete o;
-}
-
-void tst_qdeclarativeecmascript::eval()
-{
- QDeclarativeComponent component(&engine, testFileUrl("eval.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test4").toBool(), true);
- QCOMPARE(o->property("test5").toBool(), true);
-
- delete o;
-}
-
-void tst_qdeclarativeecmascript::function()
-{
- QDeclarativeComponent component(&engine, testFileUrl("function.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
-
- delete o;
-}
-
-void tst_qdeclarativeecmascript::functionException()
-{
- // QTBUG-24037 - shouldn't crash.
- QString errstr = testFileUrl("v8functionException.qml").toString() + QLatin1String(":13: SyntaxError: Unexpected token ILLEGAL");
- QTest::ignoreMessage(QtWarningMsg, qPrintable(errstr));
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Exception occurred during compilation of function: dynamicSlot()");
- QDeclarativeComponent component(&engine, testFileUrl("v8functionException.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QMetaObject::invokeMethod(o, "dynamicSlot");
- delete o;
-}
-
-// Test the "Qt.include" method
-void tst_qdeclarativeecmascript::include()
-{
- // Non-library relative include
- {
- QDeclarativeComponent component(&engine, testFileUrl("include.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test0").toInt(), 99);
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test2_1").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test3_1").toBool(), true);
-
- delete o;
- }
-
- // Library relative include
- {
- QDeclarativeComponent component(&engine, testFileUrl("include_shared.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test0").toInt(), 99);
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test2_1").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test3_1").toBool(), true);
-
- delete o;
- }
-
- // Callback
- {
- QDeclarativeComponent component(&engine, testFileUrl("include_callback.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test4").toBool(), true);
- QCOMPARE(o->property("test5").toBool(), true);
- QCOMPARE(o->property("test6").toBool(), true);
-
- delete o;
- }
-
- // Including file with ".pragma library"
- {
- QDeclarativeComponent component(&engine, testFileUrl("include_pragma.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test1").toInt(), 100);
-
- delete o;
- }
-
- // Remote - success
- {
- TestHTTPServer server(8111);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
-
- QDeclarativeComponent component(&engine, testFileUrl("include_remote.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- 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);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test4").toBool(), true);
- QCOMPARE(o->property("test5").toBool(), true);
-
- QCOMPARE(o->property("test6").toBool(), true);
- QCOMPARE(o->property("test7").toBool(), true);
- QCOMPARE(o->property("test8").toBool(), true);
- QCOMPARE(o->property("test9").toBool(), true);
- QCOMPARE(o->property("test10").toBool(), true);
-
- delete o;
- }
-
- // Remote - error
- {
- TestHTTPServer server(8111);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
-
- QDeclarativeComponent component(&engine, testFileUrl("include_remote_missing.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QTRY_VERIFY(o->property("done").toBool() == true);
-
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
-
- delete o;
- }
-}
-
-void tst_qdeclarativeecmascript::signalHandlers()
-{
- QDeclarativeComponent component(&engine, testFileUrl("signalHandlers.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QVERIFY(o->property("count").toInt() == 0);
- QMetaObject::invokeMethod(o, "testSignalCall");
- QCOMPARE(o->property("count").toInt(), 1);
-
- QMetaObject::invokeMethod(o, "testSignalHandlerCall");
- QCOMPARE(o->property("count").toInt(), 1);
- QCOMPARE(o->property("errorString").toString(), QLatin1String("TypeError: Property 'onTestSignal' of object [object Object] is not a function"));
-
- QVERIFY(o->property("funcCount").toInt() == 0);
- QMetaObject::invokeMethod(o, "testSignalConnection");
- QCOMPARE(o->property("funcCount").toInt(), 1);
-
- QMetaObject::invokeMethod(o, "testSignalHandlerConnection");
- QCOMPARE(o->property("funcCount").toInt(), 2);
-
- QMetaObject::invokeMethod(o, "testSignalDefined");
- QCOMPARE(o->property("definedResult").toBool(), true);
-
- QMetaObject::invokeMethod(o, "testSignalHandlerDefined");
- QCOMPARE(o->property("definedHandlerResult").toBool(), true);
-
- delete o;
-}
-
-void tst_qdeclarativeecmascript::qtbug_10696()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_10696.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- delete o;
-}
-
-void tst_qdeclarativeecmascript::qtbug_11606()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_11606.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test").toBool(), true);
- delete o;
-}
-
-void tst_qdeclarativeecmascript::qtbug_11600()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_11600.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test").toBool(), true);
- delete o;
-}
-
-void tst_qdeclarativeecmascript::qtbug_21864()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_21864.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test").toBool(), true);
- delete o;
-}
-
-void tst_qdeclarativeecmascript::rewriteMultiLineStrings()
-{
- // QTBUG-23387
- QDeclarativeComponent component(&engine, testFileUrl("rewriteMultiLineStrings.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QTRY_COMPARE(o->property("test").toBool(), true);
- delete o;
-}
-
-void tst_qdeclarativeecmascript::qobjectConnectionListExceptionHandling()
-{
- // QTBUG-23375
- QDeclarativeComponent component(&engine, testFileUrl("qobjectConnectionListExceptionHandling.qml"));
- QString warning = component.url().toString() + QLatin1String(":13: TypeError: Cannot read property 'undefined' of undefined");
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test").toBool(), true);
- delete o;
-}
-
-// Reading and writing non-scriptable properties should fail
-void tst_qdeclarativeecmascript::nonscriptable()
-{
- QDeclarativeComponent component(&engine, testFileUrl("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, testFileUrl("deleteLater.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test").toBool(), true);
- delete o;
-}
-
-void tst_qdeclarativeecmascript::in()
-{
- QDeclarativeComponent component(&engine, testFileUrl("in.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- delete o;
-}
-
-void tst_qdeclarativeecmascript::typeOf()
-{
- QDeclarativeComponent component(&engine, testFileUrl("typeOf.qml"));
-
- // These warnings should not happen once QTBUG-21864 is fixed
- QString warning1 = component.url().toString() + QLatin1String(":16: Error: Cannot assign [undefined] to QString");
- QString warning2 = component.url().resolved(QUrl("typeOf.js")).toString() + QLatin1String(":1: ReferenceError: Can't find variable: a");
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QEXPECT_FAIL("", "QTBUG-21864", Abort);
- QCOMPARE(o->property("test1").toString(), QLatin1String("undefined"));
- QCOMPARE(o->property("test2").toString(), QLatin1String("object"));
- QCOMPARE(o->property("test3").toString(), QLatin1String("number"));
- QCOMPARE(o->property("test4").toString(), QLatin1String("string"));
- QCOMPARE(o->property("test5").toString(), QLatin1String("function"));
- QCOMPARE(o->property("test6").toString(), QLatin1String("object"));
- QCOMPARE(o->property("test7").toString(), QLatin1String("undefined"));
- QCOMPARE(o->property("test8").toString(), QLatin1String("boolean"));
- QCOMPARE(o->property("test9").toString(), QLatin1String("object"));
-
- delete o;
-}
-
-void tst_qdeclarativeecmascript::sharedAttachedObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("sharedAttachedObject.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- delete o;
-}
-
-// QTBUG-13999
-void tst_qdeclarativeecmascript::objectName()
-{
- QDeclarativeComponent component(&engine, testFileUrl("objectName.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toString(), QString("hello"));
- QCOMPARE(o->property("test2").toString(), QString("ell"));
-
- o->setObjectName("world");
-
- QCOMPARE(o->property("test1").toString(), QString("world"));
- QCOMPARE(o->property("test2").toString(), QString("orl"));
-
- delete o;
-}
-
-void tst_qdeclarativeecmascript::writeRemovesBinding()
-{
- QDeclarativeComponent component(&engine, testFileUrl("writeRemovesBinding.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
-}
-
-// Test bindings assigned to alias properties actually assign to the alias' target
-void tst_qdeclarativeecmascript::aliasBindingsAssignCorrectly()
-{
- QDeclarativeComponent component(&engine, testFileUrl("aliasBindingsAssignCorrectly.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
-}
-
-// Test bindings assigned to alias properties override a binding on the target (QTBUG-13719)
-void tst_qdeclarativeecmascript::aliasBindingsOverrideTarget()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.2.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.3.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
- }
-}
-
-// Test that writes to alias properties override bindings on the alias target (QTBUG-13719)
-void tst_qdeclarativeecmascript::aliasWritesOverrideBindings()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.2.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.3.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
- }
-}
-
-// Allow an alais to a composite element
-// QTBUG-20200
-void tst_qdeclarativeecmascript::aliasToCompositeElement()
-{
- QDeclarativeComponent component(&engine, testFileUrl("aliasToCompositeElement.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::qtbug_20344()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_20344.qml"));
-
- QString warning = component.url().toString() + ":5: Error: Exception thrown from within QObject slot";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::revisionErrors()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevisionErrors.qml"));
- QString url = component.url().toString();
-
- QString warning1 = url + ":8: ReferenceError: Can't find variable: prop2";
- QString warning2 = url + ":11: ReferenceError: Can't find variable: prop2";
- QString warning3 = url + ":13: ReferenceError: Can't find variable: method2";
-
- QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
- MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
- QVERIFY(object != 0);
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevisionErrors2.qml"));
- QString url = component.url().toString();
-
- // MyRevisionedSubclass 1.0 uses MyRevisionedClass revision 0
- // method2, prop2 from MyRevisionedClass not available
- // method4, prop4 from MyRevisionedSubclass not available
- QString warning1 = url + ":8: ReferenceError: Can't find variable: prop2";
- QString warning2 = url + ":14: ReferenceError: Can't find variable: prop2";
- QString warning3 = url + ":10: ReferenceError: Can't find variable: prop4";
- QString warning4 = url + ":16: ReferenceError: Can't find variable: prop4";
- QString warning5 = url + ":20: ReferenceError: Can't find variable: method2";
-
- QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning4.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning5.toLatin1().constData());
- MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
- QVERIFY(object != 0);
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevisionErrors3.qml"));
- QString url = component.url().toString();
-
- // MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1
- // All properties/methods available, except MyRevisionedBaseClassUnregistered rev 1
- QString warning1 = url + ":30: ReferenceError: Can't find variable: methodD";
- QString warning2 = url + ":10: ReferenceError: Can't find variable: propD";
- QString warning3 = url + ":20: ReferenceError: Can't find variable: propD";
- QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
- MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
- QVERIFY(object != 0);
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::revision()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevision.qml"));
- QString url = component.url().toString();
-
- MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
- QVERIFY(object != 0);
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevision2.qml"));
- QString url = component.url().toString();
-
- MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
- QVERIFY(object != 0);
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevision3.qml"));
- QString url = component.url().toString();
-
- MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
- QVERIFY(object != 0);
- delete object;
- }
- // Test that non-root classes can resolve revisioned methods
- {
- QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevision4.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toReal(), 11.);
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::realToInt()
-{
- QDeclarativeComponent component(&engine, testFileUrl("realToInt.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
-
- QMetaObject::invokeMethod(object, "test1");
- QCOMPARE(object->value(), int(4));
- QMetaObject::invokeMethod(object, "test2");
- QCOMPARE(object->value(), int(8));
-}
-
-void tst_qdeclarativeecmascript::urlProperty()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("urlProperty.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- object->setStringProperty("http://qt-project.org");
- QCOMPARE(object->urlProperty(), QUrl("http://qt-project.org/index.html"));
- QCOMPARE(object->intProperty(), 123);
- QCOMPARE(object->value(), 1);
- QCOMPARE(object->property("result").toBool(), true);
- }
-}
-
-void tst_qdeclarativeecmascript::urlPropertyWithEncoding()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("urlProperty.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- object->setStringProperty("http://qt-project.org");
- QUrl encoded;
- encoded.setEncodedUrl("http://qt-project.org/?get%3cDATA%3e", QUrl::TolerantMode);
- QCOMPARE(object->urlProperty(), encoded);
- QCOMPARE(object->value(), 0); // Interpreting URL as string yields canonicalised version
- QCOMPARE(object->property("result").toBool(), true);
- }
-}
-
-void tst_qdeclarativeecmascript::urlListPropertyWithEncoding()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("urlListProperty.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- MySequenceConversionObject *msco1 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco1"));
- MySequenceConversionObject *msco2 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco2"));
- MySequenceConversionObject *msco3 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco3"));
- MySequenceConversionObject *msco4 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco4"));
- QVERIFY(msco1 != 0 && msco2 != 0 && msco3 != 0 && msco4 != 0);
- QUrl encoded;
- encoded.setEncodedUrl("http://qt-project.org/?get%3cDATA%3e", QUrl::TolerantMode);
- QCOMPARE(msco1->urlListProperty(), (QList<QUrl>() << encoded));
- QCOMPARE(msco2->urlListProperty(), (QList<QUrl>() << encoded));
- QCOMPARE(msco3->urlListProperty(), (QList<QUrl>() << encoded << encoded));
- QCOMPARE(msco4->urlListProperty(), (QList<QUrl>() << encoded << encoded));
- delete object;
- }
-}
-
-void tst_qdeclarativeecmascript::dynamicString()
-{
- QDeclarativeComponent component(&engine, testFileUrl("dynamicString.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("stringProperty").toString(),
- QString::fromLatin1("string:Hello World false:0 true:1 uint32:100 int32:-100 double:3.14159 date:2011-02-11 05::30:50!"));
-}
-
-void tst_qdeclarativeecmascript::automaticSemicolon()
-{
- QDeclarativeComponent component(&engine, testFileUrl("automaticSemicolon.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-void tst_qdeclarativeecmascript::unaryExpression()
-{
- QDeclarativeComponent component(&engine, testFileUrl("unaryExpression.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-// Makes sure that a binding isn't double re-evaluated when it depends on the same variable twice
-void tst_qdeclarativeecmascript::doubleEvaluate()
-{
- QDeclarativeComponent component(&engine, testFileUrl("doubleEvaluate.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- WriteCounter *wc = qobject_cast<WriteCounter *>(object);
- QVERIFY(wc != 0);
- QCOMPARE(wc->count(), 1);
-
- wc->setProperty("x", 9);
-
- QCOMPARE(wc->count(), 2);
-
- delete object;
-}
-
-static QStringList messages;
-static void captureMsgHandler(QtMsgType, const char *msg)
-{
- messages.append(QLatin1String(msg));
-}
-
-void tst_qdeclarativeecmascript::nonNotifyable()
-{
- QV4Compiler::enableV4(false);
- QDeclarativeComponent component(&engine, testFileUrl("nonNotifyable.qml"));
- QV4Compiler::enableV4(true);
-
- QtMsgHandler old = qInstallMsgHandler(captureMsgHandler);
- messages.clear();
- QObject *object = component.create();
- qInstallMsgHandler(old);
-
- QVERIFY(object != 0);
-
- QString expected1 = QLatin1String("QDeclarativeExpression: Expression ") +
- component.url().toString() +
- QLatin1String(":5 depends on non-NOTIFYable properties:");
- QString expected2 = QLatin1String(" ") +
- QLatin1String(object->metaObject()->className()) +
- QLatin1String("::value");
-
- QCOMPARE(messages.length(), 2);
- QCOMPARE(messages.at(0), expected1);
- QCOMPARE(messages.at(1), expected2);
-
- delete object;
-}
-
-void tst_qdeclarativeecmascript::forInLoop()
-{
- QDeclarativeComponent component(&engine, testFileUrl("forInLoop.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QMetaObject::invokeMethod(object, "listProperty");
-
- QStringList r = object->property("listResult").toString().split("|", QString::SkipEmptyParts);
- QCOMPARE(r.size(), 3);
- QCOMPARE(r[0],QLatin1String("0=obj1"));
- QCOMPARE(r[1],QLatin1String("1=obj2"));
- QCOMPARE(r[2],QLatin1String("2=obj3"));
-
- //TODO: should test for in loop for other objects (such as QObjects) as well.
-
- delete object;
-}
-
-// An object the binding depends on is deleted while the binding is still running
-void tst_qdeclarativeecmascript::deleteWhileBindingRunning()
-{
- QDeclarativeComponent component(&engine, testFileUrl("deleteWhileBindingRunning.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativeecmascript::qtbug_22679()
-{
- MyQmlObject object;
- object.setStringProperty(QLatin1String("Please work correctly"));
- engine.rootContext()->setContextProperty("contextProp", &object);
-
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_22679.qml"));
- qRegisterMetaType<QList<QDeclarativeError> >("QList<QDeclarativeError>");
- QSignalSpy warningsSpy(&engine, SIGNAL(warnings(QList<QDeclarativeError>)));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(warningsSpy.count(), 0);
- delete o;
-}
-
-void tst_qdeclarativeecmascript::qtbug_22843_data()
-{
- QTest::addColumn<bool>("library");
-
- QTest::newRow("without .pragma library") << false;
- QTest::newRow("with .pragma library") << true;
-}
-
-void tst_qdeclarativeecmascript::qtbug_22843()
-{
- QFETCH(bool, library);
-
- QString fileName("qtbug_22843");
- if (library)
- fileName += QLatin1String(".library");
- fileName += QLatin1String(".qml");
-
- QDeclarativeComponent component(&engine, testFileUrl(fileName));
- QString url = component.url().toString();
- QString warning1 = url.left(url.length()-3) + QLatin1String("js:4: SyntaxError: Unexpected token )");
- QString warning2 = url + QLatin1String(":5: TypeError: Object [object Object] has no method 'func'");
-
- qRegisterMetaType<QList<QDeclarativeError> >("QList<QDeclarativeError>");
- QSignalSpy warningsSpy(&engine, SIGNAL(warnings(QList<QDeclarativeError>)));
- for (int x = 0; x < 3; ++x) {
- warningsSpy.clear();
- // For libraries, only the first import attempt should produce a
- // SyntaxError warning; subsequent component creation should not
- // attempt to reload the script.
- bool expectSyntaxError = !library || (x == 0);
- if (expectSyntaxError)
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(warningsSpy.count(), 1 + (expectSyntaxError?1:0));
- delete object;
- }
-}
-
-
-void tst_qdeclarativeecmascript::switchStatement()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("switchStatement.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- // `object->value()' is the number of executed statements
-
- object->setStringProperty("A");
- QCOMPARE(object->value(), 5);
-
- object->setStringProperty("S");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("D");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("F");
- QCOMPARE(object->value(), 4);
-
- object->setStringProperty("something else");
- QCOMPARE(object->value(), 1);
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("switchStatement.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- // `object->value()' is the number of executed statements
-
- object->setStringProperty("A");
- QCOMPARE(object->value(), 5);
-
- object->setStringProperty("S");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("D");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("F");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("something else");
- QCOMPARE(object->value(), 4);
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("switchStatement.3.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- // `object->value()' is the number of executed statements
-
- object->setStringProperty("A");
- QCOMPARE(object->value(), 5);
-
- object->setStringProperty("S");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("D");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("F");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("something else");
- QCOMPARE(object->value(), 6);
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("switchStatement.4.qml"));
-
- QString warning = component.url().toString() + ":4: Unable to assign [undefined] to int";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- // `object->value()' is the number of executed statements
-
- object->setStringProperty("A");
- QCOMPARE(object->value(), 5);
-
- object->setStringProperty("S");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("D");
- QCOMPARE(object->value(), 3);
-
- object->setStringProperty("F");
- QCOMPARE(object->value(), 3);
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- object->setStringProperty("something else");
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("switchStatement.5.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- // `object->value()' is the number of executed statements
-
- object->setStringProperty("A");
- QCOMPARE(object->value(), 1);
-
- object->setStringProperty("S");
- QCOMPARE(object->value(), 1);
-
- object->setStringProperty("D");
- QCOMPARE(object->value(), 1);
-
- object->setStringProperty("F");
- QCOMPARE(object->value(), 1);
-
- object->setStringProperty("something else");
- QCOMPARE(object->value(), 1);
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("switchStatement.6.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- // `object->value()' is the number of executed statements
-
- object->setStringProperty("A");
- QCOMPARE(object->value(), 123);
-
- object->setStringProperty("S");
- QCOMPARE(object->value(), 123);
-
- object->setStringProperty("D");
- QCOMPARE(object->value(), 321);
-
- object->setStringProperty("F");
- QCOMPARE(object->value(), 321);
-
- object->setStringProperty("something else");
- QCOMPARE(object->value(), 0);
- }
-}
-
-void tst_qdeclarativeecmascript::withStatement()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("withStatement.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->value(), 123);
- }
-}
-
-void tst_qdeclarativeecmascript::tryStatement()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("tryStatement.1.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->value(), 123);
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("tryStatement.2.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->value(), 321);
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("tryStatement.3.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->value(), 1);
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("tryStatement.4.qml"));
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->value(), 1);
- }
-}
-
-class CppInvokableWithQObjectDerived : public QObject
-{
- Q_OBJECT
-public:
- CppInvokableWithQObjectDerived() {}
- ~CppInvokableWithQObjectDerived() {}
-
- Q_INVOKABLE MyQmlObject *createMyQmlObject(QString data)
- {
- MyQmlObject *obj = new MyQmlObject();
- obj->setStringProperty(data);
- return obj;
- }
-
- Q_INVOKABLE QString getStringProperty(MyQmlObject *obj)
- {
- return obj->stringProperty();
- }
-};
-
-void tst_qdeclarativeecmascript::invokableWithQObjectDerived()
-{
- CppInvokableWithQObjectDerived invokable;
-
- {
- QDeclarativeEngine engine;
- engine.rootContext()->setContextProperty("invokable", &invokable);
-
- QDeclarativeComponent component(&engine, testFileUrl("qobjectDerivedArgument.qml"));
-
- QObject *object = component.create();
-
- QVERIFY(object != 0);
- QVERIFY(object->property("result").value<bool>() == true);
-
- delete object;
- }
-}
-
-QTEST_MAIN(tst_qdeclarativeecmascript)
-
-#include "tst_qdeclarativeecmascript.moc"
diff --git a/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro b/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro
deleted file mode 100644
index 547d56b3ad..0000000000
--- a/tests/auto/declarative/qdeclarativeengine/qdeclarativeengine.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeengine
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeengine.cpp
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private network testlib
diff --git a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
deleted file mode 100644
index 1de738f81f..0000000000
--- a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
+++ /dev/null
@@ -1,365 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeContext>
-#include <QNetworkAccessManager>
-#include <QPointer>
-#include <QDir>
-#include <QStandardPaths>
-#include <QDebug>
-#include <QDeclarativeComponent>
-#include <QDeclarativeNetworkAccessManagerFactory>
-#include <QDeclarativeExpression>
-
-class tst_qdeclarativeengine : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeengine() {}
-
-private slots:
- void rootContext();
- void networkAccessManager();
- void baseUrl();
- void contextForObject();
- void offlineStoragePath();
- void clearComponentCache();
- void outputWarningsToStandardError();
- void objectOwnership();
- void multipleEngines();
-};
-
-void tst_qdeclarativeengine::rootContext()
-{
- QDeclarativeEngine engine;
-
- QVERIFY(engine.rootContext());
-
- QCOMPARE(engine.rootContext()->engine(), &engine);
- QVERIFY(engine.rootContext()->parentContext() == 0);
-}
-
-class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory
-{
-public:
- NetworkAccessManagerFactory() : manager(0) {}
-
- QNetworkAccessManager *create(QObject *parent) {
- manager = new QNetworkAccessManager(parent);
- return manager;
- }
-
- QNetworkAccessManager *manager;
-};
-
-void tst_qdeclarativeengine::networkAccessManager()
-{
- QDeclarativeEngine *engine = new QDeclarativeEngine;
-
- // Test QDeclarativeEngine created manager
- QPointer<QNetworkAccessManager> manager = engine->networkAccessManager();
- QVERIFY(manager != 0);
- delete engine;
-
- // Test factory created manager
- engine = new QDeclarativeEngine;
- NetworkAccessManagerFactory factory;
- engine->setNetworkAccessManagerFactory(&factory);
- QVERIFY(engine->networkAccessManagerFactory() == &factory);
- QVERIFY(engine->networkAccessManager() == factory.manager);
- delete engine;
-}
-
-void tst_qdeclarativeengine::baseUrl()
-{
- QDeclarativeEngine engine;
-
- QUrl cwd = QUrl::fromLocalFile(QDir::currentPath() + QDir::separator());
-
- QCOMPARE(engine.baseUrl(), cwd);
- QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd.resolved(QUrl("main.qml")));
-
- QDir dir = QDir::current();
- dir.cdUp();
- QVERIFY(dir != QDir::current());
- QDir::setCurrent(dir.path());
- QVERIFY(QDir::current() == dir);
-
- QUrl cwd2 = QUrl::fromLocalFile(QDir::currentPath() + QDir::separator());
- QCOMPARE(engine.baseUrl(), cwd2);
- QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd2.resolved(QUrl("main.qml")));
-
- engine.setBaseUrl(cwd);
- QCOMPARE(engine.baseUrl(), cwd);
- QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd.resolved(QUrl("main.qml")));
-}
-
-void tst_qdeclarativeengine::contextForObject()
-{
- QDeclarativeEngine *engine = new QDeclarativeEngine;
-
- // Test null-object
- QVERIFY(QDeclarativeEngine::contextForObject(0) == 0);
-
- // Test an object with no context
- QObject object;
- QVERIFY(QDeclarativeEngine::contextForObject(&object) == 0);
-
- // Test setting null-object
- QDeclarativeEngine::setContextForObject(0, engine->rootContext());
-
- // Test setting null-context
- QDeclarativeEngine::setContextForObject(&object, 0);
-
- // Test setting context
- QDeclarativeEngine::setContextForObject(&object, engine->rootContext());
- QVERIFY(QDeclarativeEngine::contextForObject(&object) == engine->rootContext());
-
- QDeclarativeContext context(engine->rootContext());
-
- // Try changing context
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeEngine::setContextForObject(): Object already has a QDeclarativeContext");
- QDeclarativeEngine::setContextForObject(&object, &context);
- QVERIFY(QDeclarativeEngine::contextForObject(&object) == engine->rootContext());
-
- // Delete context
- delete engine; engine = 0;
- QVERIFY(QDeclarativeEngine::contextForObject(&object) == 0);
-}
-
-void tst_qdeclarativeengine::offlineStoragePath()
-{
- // Without these set, QDesktopServices::storageLocation returns
- // strings with extra "//" at the end. We set them to ignore this problem.
- qApp->setApplicationName("tst_qdeclarativeengine");
- qApp->setOrganizationName("Nokia");
- qApp->setOrganizationDomain("nokia.com");
-
- QDeclarativeEngine engine;
-
- QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
- dir.mkpath("QML");
- dir.cd("QML");
- dir.mkpath("OfflineStorage");
- dir.cd("OfflineStorage");
-
- QCOMPARE(QDir::fromNativeSeparators(engine.offlineStoragePath()), dir.path());
-
- engine.setOfflineStoragePath(QDir::homePath());
- QCOMPARE(engine.offlineStoragePath(), QDir::homePath());
-}
-
-void tst_qdeclarativeengine::clearComponentCache()
-{
- QDeclarativeEngine engine;
-
- // Create original qml file
- {
- QFile file("temp.qml");
- QVERIFY(file.open(QIODevice::WriteOnly));
- file.write("import QtQuick 2.0\nQtObject {\nproperty int test: 10\n}\n");
- file.close();
- }
-
- // Test "test" property
- {
- QDeclarativeComponent component(&engine, "temp.qml");
- QObject *obj = component.create();
- QVERIFY(obj != 0);
- QCOMPARE(obj->property("test").toInt(), 10);
- delete obj;
- }
-
- // Modify qml file
- {
- QFile file("temp.qml");
- QVERIFY(file.open(QIODevice::WriteOnly));
- file.write("import QtQuick 2.0\nQtObject {\nproperty int test: 11\n}\n");
- file.close();
- }
-
- // Test cache hit
- {
- QDeclarativeComponent component(&engine, "temp.qml");
- QObject *obj = component.create();
- QVERIFY(obj != 0);
- QCOMPARE(obj->property("test").toInt(), 10);
- delete obj;
- }
-
- // Clear cache
- engine.clearComponentCache();
-
- // Test cache refresh
- {
- QDeclarativeComponent component(&engine, "temp.qml");
- QObject *obj = component.create();
- QVERIFY(obj != 0);
- QCOMPARE(obj->property("test").toInt(), 11);
- delete obj;
- }
-}
-
-static QStringList warnings;
-static void msgHandler(QtMsgType, const char *warning)
-{
- warnings << QString::fromUtf8(warning);
-}
-
-void tst_qdeclarativeengine::outputWarningsToStandardError()
-{
- QDeclarativeEngine engine;
-
- QCOMPARE(engine.outputWarningsToStandardError(), true);
-
- QDeclarativeComponent c(&engine);
- c.setData("import QtQuick 2.0; QtObject { property int a: undefined }", QUrl());
-
- QVERIFY(c.isReady() == true);
-
- warnings.clear();
- QtMsgHandler old = qInstallMsgHandler(msgHandler);
-
- QObject *o = c.create();
-
- qInstallMsgHandler(old);
-
- QVERIFY(o != 0);
- delete o;
-
- QCOMPARE(warnings.count(), 1);
- QCOMPARE(warnings.at(0), QLatin1String("<Unknown File>:1: Unable to assign [undefined] to int"));
- warnings.clear();
-
-
- engine.setOutputWarningsToStandardError(false);
- QCOMPARE(engine.outputWarningsToStandardError(), false);
-
-
- old = qInstallMsgHandler(msgHandler);
-
- o = c.create();
-
- qInstallMsgHandler(old);
-
- QVERIFY(o != 0);
- delete o;
-
- QCOMPARE(warnings.count(), 0);
-}
-
-void tst_qdeclarativeengine::objectOwnership()
-{
- {
- QCOMPARE(QDeclarativeEngine::objectOwnership(0), QDeclarativeEngine::CppOwnership);
- QDeclarativeEngine::setObjectOwnership(0, QDeclarativeEngine::JavaScriptOwnership);
- QCOMPARE(QDeclarativeEngine::objectOwnership(0), QDeclarativeEngine::CppOwnership);
- }
-
- {
- QObject o;
- QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::CppOwnership);
- QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::CppOwnership);
- QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::CppOwnership);
- QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::JavaScriptOwnership);
- QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::JavaScriptOwnership);
- QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::CppOwnership);
- QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::CppOwnership);
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine);
- c.setData("import QtQuick 2.0; QtObject { property QtObject object: QtObject {} }", QUrl());
-
- QObject *o = c.create();
- QVERIFY(o != 0);
-
- QCOMPARE(QDeclarativeEngine::objectOwnership(o), QDeclarativeEngine::CppOwnership);
-
- QObject *o2 = qvariant_cast<QObject *>(o->property("object"));
- QCOMPARE(QDeclarativeEngine::objectOwnership(o2), QDeclarativeEngine::JavaScriptOwnership);
-
- delete o;
- }
-
-}
-
-// Test an object can be accessed by multiple engines
-void tst_qdeclarativeengine::multipleEngines()
-{
- QObject o;
- o.setObjectName("TestName");
-
- // Simultaneous engines
- {
- QDeclarativeEngine engine1;
- QDeclarativeEngine engine2;
- engine1.rootContext()->setContextProperty("object", &o);
- engine2.rootContext()->setContextProperty("object", &o);
-
- QDeclarativeExpression expr1(engine1.rootContext(), 0, QString("object.objectName"));
- QDeclarativeExpression expr2(engine2.rootContext(), 0, QString("object.objectName"));
-
- QCOMPARE(expr1.evaluate().toString(), QString("TestName"));
- QCOMPARE(expr2.evaluate().toString(), QString("TestName"));
- }
-
- // Serial engines
- {
- QDeclarativeEngine engine1;
- engine1.rootContext()->setContextProperty("object", &o);
- QDeclarativeExpression expr1(engine1.rootContext(), 0, QString("object.objectName"));
- QCOMPARE(expr1.evaluate().toString(), QString("TestName"));
- }
- {
- QDeclarativeEngine engine1;
- engine1.rootContext()->setContextProperty("object", &o);
- QDeclarativeExpression expr1(engine1.rootContext(), 0, QString("object.objectName"));
- QCOMPARE(expr1.evaluate().toString(), QString("TestName"));
- }
-}
-
-QTEST_MAIN(tst_qdeclarativeengine)
-
-#include "tst_qdeclarativeengine.moc"
diff --git a/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro b/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro
deleted file mode 100644
index 8acf46f7bc..0000000000
--- a/tests/auto/declarative/qdeclarativeerror/qdeclarativeerror.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeerror
-SOURCES += tst_qdeclarativeerror.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-CONFIG += parallel_test
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-QT += core-private gui-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp b/tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp
deleted file mode 100644
index 14aaa06106..0000000000
--- a/tests/auto/declarative/qdeclarativeerror/tst_qdeclarativeerror.cpp
+++ /dev/null
@@ -1,243 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeError>
-#include <QDebug>
-#include "../../shared/util.h"
-
-class tst_qdeclarativeerror : public QDeclarativeDataTest
-{
- Q_OBJECT
-private slots:
- void url();
- void description();
- void line();
- void column();
- void toString();
-
- void copy();
- void debug();
-};
-
-void tst_qdeclarativeerror::url()
-{
- QDeclarativeError error;
-
- QCOMPARE(error.url(), QUrl());
-
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
-
- QCOMPARE(error.url(), QUrl("http://www.nokia.com/main.qml"));
-
- QDeclarativeError error2 = error;
-
- QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
-
- error.setUrl(QUrl("http://qt.nokia.com/main.qml"));
-
- QCOMPARE(error.url(), QUrl("http://qt.nokia.com/main.qml"));
- QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
-}
-
-void tst_qdeclarativeerror::description()
-{
- QDeclarativeError error;
-
- QCOMPARE(error.description(), QString());
-
- error.setDescription("An Error");
-
- QCOMPARE(error.description(), QString("An Error"));
-
- QDeclarativeError error2 = error;
-
- QCOMPARE(error2.description(), QString("An Error"));
-
- error.setDescription("Another Error");
-
- QCOMPARE(error.description(), QString("Another Error"));
- QCOMPARE(error2.description(), QString("An Error"));
-}
-
-void tst_qdeclarativeerror::line()
-{
- QDeclarativeError error;
-
- QCOMPARE(error.line(), -1);
-
- error.setLine(102);
-
- QCOMPARE(error.line(), 102);
-
- QDeclarativeError error2 = error;
-
- QCOMPARE(error2.line(), 102);
-
- error.setLine(4);
-
- QCOMPARE(error.line(), 4);
- QCOMPARE(error2.line(), 102);
-}
-
-void tst_qdeclarativeerror::column()
-{
- QDeclarativeError error;
-
- QCOMPARE(error.column(), -1);
-
- error.setColumn(16);
-
- QCOMPARE(error.column(), 16);
-
- QDeclarativeError error2 = error;
-
- QCOMPARE(error2.column(), 16);
-
- error.setColumn(3);
-
- QCOMPARE(error.column(), 3);
- QCOMPARE(error2.column(), 16);
-}
-
-void tst_qdeclarativeerror::toString()
-{
- {
- QDeclarativeError error;
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
- error.setDescription("An Error");
- error.setLine(92);
- error.setColumn(13);
-
- QCOMPARE(error.toString(), QString("http://www.nokia.com/main.qml:92:13: An Error"));
- }
-
- {
- QDeclarativeError error;
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
- error.setDescription("An Error");
- error.setLine(92);
-
- QCOMPARE(error.toString(), QString("http://www.nokia.com/main.qml:92: An Error"));
- }
-}
-
-void tst_qdeclarativeerror::copy()
-{
- QDeclarativeError error;
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
- error.setDescription("An Error");
- error.setLine(92);
- error.setColumn(13);
-
- QDeclarativeError error2(error);
- QDeclarativeError error3;
- error3 = error;
-
- error.setUrl(QUrl("http://qt.nokia.com/main.qml"));
- error.setDescription("Another Error");
- error.setLine(2);
- error.setColumn(33);
-
- QCOMPARE(error.url(), QUrl("http://qt.nokia.com/main.qml"));
- QCOMPARE(error.description(), QString("Another Error"));
- QCOMPARE(error.line(), 2);
- QCOMPARE(error.column(), 33);
-
- QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
- QCOMPARE(error2.description(), QString("An Error"));
- QCOMPARE(error2.line(), 92);
- QCOMPARE(error2.column(), 13);
-
- QCOMPARE(error3.url(), QUrl("http://www.nokia.com/main.qml"));
- QCOMPARE(error3.description(), QString("An Error"));
- QCOMPARE(error3.line(), 92);
- QCOMPARE(error3.column(), 13);
-
-}
-
-void tst_qdeclarativeerror::debug()
-{
- {
- QDeclarativeError error;
- error.setUrl(QUrl("http://www.nokia.com/main.qml"));
- error.setDescription("An Error");
- error.setLine(92);
- error.setColumn(13);
-
- QTest::ignoreMessage(QtWarningMsg, "http://www.nokia.com/main.qml:92:13: An Error ");
- qWarning() << error;
- }
-
- {
- QUrl url(dataDirectoryUrl().resolved(QUrl("test.txt")));
- QDeclarativeError error;
- error.setUrl(url);
- error.setDescription("An Error");
- error.setLine(2);
- error.setColumn(5);
-
- QString out = url.toString() + ":2:5: An Error \n Line2 Content \n ^ ";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(out));
-
- qWarning() << error;
- }
-
- {
- QUrl url(dataDirectoryUrl().resolved(QUrl("foo.txt")));
- QDeclarativeError error;
- error.setUrl(url);
- error.setDescription("An Error");
- error.setLine(2);
- error.setColumn(5);
-
- QString out = url.toString() + ":2:5: An Error ";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(out));
-
- qWarning() << error;
- }
-}
-
-
-
-QTEST_MAIN(tst_qdeclarativeerror)
-
-#include "tst_qdeclarativeerror.moc"
diff --git a/tests/auto/declarative/qdeclarativeexpression/qdeclarativeexpression.pro b/tests/auto/declarative/qdeclarativeexpression/qdeclarativeexpression.pro
deleted file mode 100644
index bd32e6a9ac..0000000000
--- a/tests/auto/declarative/qdeclarativeexpression/qdeclarativeexpression.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeexpression
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeexpression.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativeexpression/tst_qdeclarativeexpression.cpp b/tests/auto/declarative/qdeclarativeexpression/tst_qdeclarativeexpression.cpp
deleted file mode 100644
index 10ddf8abad..0000000000
--- a/tests/auto/declarative/qdeclarativeexpression/tst_qdeclarativeexpression.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativescriptstring.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativeexpression : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeexpression() {}
-
-private slots:
- void scriptString();
- void syntaxError();
-};
-
-class TestObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeScriptString scriptString READ scriptString WRITE setScriptString)
- Q_PROPERTY(QDeclarativeScriptString scriptStringError READ scriptStringError WRITE setScriptStringError)
-public:
- TestObject(QObject *parent = 0) : QObject(parent) {}
-
- QDeclarativeScriptString scriptString() const { return m_scriptString; }
- void setScriptString(QDeclarativeScriptString scriptString) { m_scriptString = scriptString; }
-
- QDeclarativeScriptString scriptStringError() const { return m_scriptStringError; }
- void setScriptStringError(QDeclarativeScriptString scriptString) { m_scriptStringError = scriptString; }
-
-private:
- QDeclarativeScriptString m_scriptString;
- QDeclarativeScriptString m_scriptStringError;
-};
-
-QML_DECLARE_TYPE(TestObject)
-
-void tst_qdeclarativeexpression::scriptString()
-{
- qmlRegisterType<TestObject>("Test", 1, 0, "TestObject");
-
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("scriptString.qml"));
- TestObject *testObj = qobject_cast<TestObject*>(c.create());
- QVERIFY(testObj != 0);
-
- QDeclarativeScriptString script = testObj->scriptString();
- QCOMPARE(script.script(), QLatin1String("value1 + value2"));
-
- QDeclarativeExpression expression(script);
- QVariant value = expression.evaluate();
- QCOMPARE(value.toInt(), 15);
-
- QDeclarativeScriptString scriptError = testObj->scriptStringError();
- QCOMPARE(scriptError.script(), QLatin1String("value3 * 5"));
-
- //verify that the expression has the correct error location information
- QDeclarativeExpression expressionError(scriptError);
- QVariant valueError = expressionError.evaluate();
- QVERIFY(!valueError.isValid());
- QVERIFY(expressionError.hasError());
- QDeclarativeError error = expressionError.error();
- QCOMPARE(error.url(), c.url());
- QCOMPARE(error.line(), 8);
-}
-
-// QTBUG-21310 - crash test
-void tst_qdeclarativeexpression::syntaxError()
-{
- QDeclarativeEngine engine;
- QDeclarativeExpression expression(engine.rootContext(), 0, "asd asd");
- QVariant v = expression.evaluate();
- QCOMPARE(v, QVariant());
-}
-
-QTEST_MAIN(tst_qdeclarativeexpression)
-
-#include "tst_qdeclarativeexpression.moc"
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro b/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro
deleted file mode 100644
index 045d48a710..0000000000
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativefolderlistmodel
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativefolderlistmodel.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp
deleted file mode 100644
index 07eb6e87e1..0000000000
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qabstractitemmodel.h>
-#include <QDebug>
-#include "../../shared/util.h"
-
-// From qdeclarastivefolderlistmodel.h
-const int FileNameRole = Qt::UserRole+1;
-const int FilePathRole = Qt::UserRole+2;
-enum SortField { Unsorted, Name, Time, Size, Type };
-
-class tst_qdeclarativefolderlistmodel : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativefolderlistmodel() : removeStart(0), removeEnd(0) {}
-
-public slots:
- void removed(const QModelIndex &, int start, int end) {
- removeStart = start;
- removeEnd = end;
- }
-
-private slots:
- void basicProperties();
- void resetFiltering();
- void refresh();
-
-private:
- void checkNoErrors(const QDeclarativeComponent& component);
- QDeclarativeEngine engine;
-
- int removeStart;
- int removeEnd;
-};
-
-void tst_qdeclarativefolderlistmodel::checkNoErrors(const QDeclarativeComponent& component)
-{
- // Wait until the component is ready
- QTRY_VERIFY(component.isReady() || component.isError());
-
- if (component.isError()) {
- QList<QDeclarativeError> errors = component.errors();
- for (int ii = 0; ii < errors.count(); ++ii) {
- const QDeclarativeError &error = errors.at(ii);
- QByteArray errorStr = QByteArray::number(error.line()) + ":" +
- QByteArray::number(error.column()) + ":" +
- error.description().toUtf8();
- qWarning() << errorStr;
- }
- }
- QVERIFY(!component.isError());
-}
-
-void tst_qdeclarativefolderlistmodel::basicProperties()
-{
- QDeclarativeComponent component(&engine, testFileUrl("basic.qml"));
- checkNoErrors(component);
-
- QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
- QVERIFY(flm != 0);
-
- flm->setProperty("folder", dataDirectoryUrl());
- QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh
- QCOMPARE(flm->property("folder").toUrl(), dataDirectoryUrl());
- QCOMPARE(flm->property("parentFolder").toUrl(), QUrl::fromLocalFile(QDir(directory()).canonicalPath()));
- QCOMPARE(flm->property("sortField").toInt(), int(Name));
- QCOMPARE(flm->property("nameFilters").toStringList(), QStringList() << "*.qml");
- QCOMPARE(flm->property("sortReversed").toBool(), false);
- QCOMPARE(flm->property("showDirs").toBool(), true);
- QCOMPARE(flm->property("showDotAndDotDot").toBool(), false);
- QCOMPARE(flm->property("showOnlyReadable").toBool(), false);
- QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String("basic.qml"));
- QCOMPARE(flm->data(flm->index(1),FileNameRole).toString(), QLatin1String("dummy.qml"));
-
- flm->setProperty("folder",QUrl::fromLocalFile(""));
- QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(""));
-}
-
-void tst_qdeclarativefolderlistmodel::resetFiltering()
-{
- // see QTBUG-17837
- QDeclarativeComponent component(&engine, testFileUrl("resetFiltering.qml"));
- checkNoErrors(component);
-
- QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
- QVERIFY(flm != 0);
-
- connect(flm, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
- this, SLOT(removed(const QModelIndex&,int,int)));
-
- flm->setProperty("folder", testFileUrl("resetfiltering"));
- QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test.txt" visible
- int count = flm->rowCount();
- QCOMPARE(removeStart, 0);
- QCOMPARE(removeEnd, count-1);
-
- flm->setProperty("folder", testFileUrl("resetfiltering/innerdir"));
- QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test2.txt" visible
- count = flm->rowCount();
- QCOMPARE(removeStart, 0);
- QCOMPARE(removeEnd, count-1);
-
- flm->setProperty("folder", testFileUrl("resetfiltering"));
- QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test.txt" visible
- count = flm->rowCount();
- QCOMPARE(removeStart, 0);
- QCOMPARE(removeEnd, count-1);
-}
-
-void tst_qdeclarativefolderlistmodel::refresh()
-{
- QDeclarativeComponent component(&engine, testFileUrl("basic.qml"));
- checkNoErrors(component);
-
- QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
- QVERIFY(flm != 0);
-
- flm->setProperty("folder", dataDirectoryUrl());
- QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh
-
- int count = flm->rowCount();
-
- connect(flm, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
- this, SLOT(removed(const QModelIndex&,int,int)));
-
- flm->setProperty("sortReversed", true);
-
- QCOMPARE(removeStart, 0);
- QCOMPARE(removeEnd, count-1);
-}
-
-QTEST_MAIN(tst_qdeclarativefolderlistmodel)
-
-#include "tst_qdeclarativefolderlistmodel.moc"
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro b/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro
deleted file mode 100644
index 70b9a406b3..0000000000
--- a/tests/auto/declarative/qdeclarativeimageprovider/qdeclarativeimageprovider.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeimageprovider
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeimageprovider.cpp
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
deleted file mode 100644
index 14da99374b..0000000000
--- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
+++ /dev/null
@@ -1,424 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QtTest>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeimageprovider.h>
-#include <private/qquickimage_p.h>
-#include <QImageReader>
-#include <QWaitCondition>
-
-Q_DECLARE_METATYPE(QDeclarativeImageProvider*);
-
-class tst_qdeclarativeimageprovider : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeimageprovider()
- {
- }
-
-private slots:
- void requestImage_sync_data();
- void requestImage_sync();
- void requestImage_async_data();
- void requestImage_async();
-
- void requestPixmap_sync_data();
- void requestPixmap_sync();
- void requestPixmap_async();
-
- void removeProvider_data();
- void removeProvider();
-
- void threadTest();
-
-private:
- QString newImageFileName() const;
- void fillRequestTestsData(const QString &id);
- void runTest(bool async, QDeclarativeImageProvider *provider);
-};
-
-
-class TestQImageProvider : public QDeclarativeImageProvider
-{
-public:
- TestQImageProvider(bool *deleteWatch = 0)
- : QDeclarativeImageProvider(Image), deleteWatch(deleteWatch)
- {
- }
-
- ~TestQImageProvider()
- {
- if (deleteWatch)
- *deleteWatch = true;
- }
-
- QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize)
- {
- lastImageId = id;
-
- if (id == QLatin1String("no-such-file.png"))
- return QImage();
-
- int width = 100;
- int height = 100;
- QImage image(width, height, QImage::Format_RGB32);
- if (size)
- *size = QSize(width, height);
- if (requestedSize.isValid())
- image = image.scaled(requestedSize);
- return image;
- }
-
- bool *deleteWatch;
- QString lastImageId;
-};
-Q_DECLARE_METATYPE(TestQImageProvider*);
-
-
-class TestQPixmapProvider : public QDeclarativeImageProvider
-{
-public:
- TestQPixmapProvider(bool *deleteWatch = 0)
- : QDeclarativeImageProvider(Pixmap), deleteWatch(deleteWatch)
- {
- }
-
- ~TestQPixmapProvider()
- {
- if (deleteWatch)
- *deleteWatch = true;
- }
-
- QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize)
- {
- lastImageId = id;
-
- if (id == QLatin1String("no-such-file.png"))
- return QPixmap();
-
- int width = 100;
- int height = 100;
- QPixmap image(width, height);
- if (size)
- *size = QSize(width, height);
- if (requestedSize.isValid())
- image = image.scaled(requestedSize);
- return image;
- }
-
- bool *deleteWatch;
- QString lastImageId;
-};
-Q_DECLARE_METATYPE(TestQPixmapProvider*);
-
-
-QString tst_qdeclarativeimageprovider::newImageFileName() const
-{
- // need to generate new filenames each time or else images are loaded
- // from cache and we won't get loading status changes when testing
- // async loading
- static int count = 0;
- return QString("image://test/image-%1.png").arg(count++);
-}
-
-void tst_qdeclarativeimageprovider::fillRequestTestsData(const QString &id)
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<QString>("imageId");
- QTest::addColumn<QString>("properties");
- QTest::addColumn<QSize>("size");
- QTest::addColumn<QString>("error");
-
- QString fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " simple test"))
- << "image://test/" + fileName << fileName << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " simple test with capitalization"))//As it's a URL, should make no difference
- << "image://Test/" + fileName << fileName << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " url with no id"))
- << "image://test/" + fileName << "" + fileName << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " url with path"))
- << "image://test/test/path" + fileName << "test/path" + fileName << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " url with fragment"))
- << "image://test/faq.html?#question13" + fileName << "faq.html?#question13" + fileName << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " url with query"))
- << "image://test/cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName << "cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName
- << "" << QSize(100,100) << "";
-
- fileName = newImageFileName();
- QTest::newRow(QTest::toString(id + " scaled image"))
- << "image://test/" + fileName << fileName << "sourceSize: \"80x30\"" << QSize(80,30) << "";
-
- QTest::newRow(QTest::toString(id + " missing"))
- << "image://test/no-such-file.png" << "no-such-file.png" << "" << QSize(100,100)
- << "file::2:1: QML Image: Failed to get image from provider: image://test/no-such-file.png";
-
- QTest::newRow(QTest::toString(id + " unknown provider"))
- << "image://bogus/exists.png" << "" << "" << QSize()
- << "file::2:1: QML Image: Invalid image provider: image://bogus/exists.png";
-}
-
-void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvider *provider)
-{
- QFETCH(QString, source);
- QFETCH(QString, imageId);
- QFETCH(QString, properties);
- QFETCH(QSize, size);
- QFETCH(QString, error);
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- QDeclarativeEngine engine;
-
- engine.addImageProvider("test", provider);
- QVERIFY(engine.imageProvider("test") != 0);
-
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + source + "\"; "
- + (async ? "asynchronous: true; " : "")
- + properties + " }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
-
- if (async)
- QTRY_VERIFY(obj->status() == QQuickImage::Loading);
-
- QCOMPARE(obj->source(), QUrl(source));
-
- if (error.isEmpty()) {
- if (async)
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- else
- QVERIFY(obj->status() == QQuickImage::Ready);
- if (QByteArray(QTest::currentDataTag()).startsWith("qimage"))
- QCOMPARE(static_cast<TestQImageProvider*>(provider)->lastImageId, imageId);
- else
- QCOMPARE(static_cast<TestQPixmapProvider*>(provider)->lastImageId, imageId);
-
- QCOMPARE(obj->width(), qreal(size.width()));
- QCOMPARE(obj->height(), qreal(size.height()));
- QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
- QCOMPARE(obj->progress(), 1.0);
- } else {
- if (async)
- QTRY_VERIFY(obj->status() == QQuickImage::Error);
- else
- QVERIFY(obj->status() == QQuickImage::Error);
- }
-
- delete obj;
-}
-
-void tst_qdeclarativeimageprovider::requestImage_sync_data()
-{
- fillRequestTestsData("qimage|sync");
-}
-
-void tst_qdeclarativeimageprovider::requestImage_sync()
-{
- bool deleteWatch = false;
- runTest(false, new TestQImageProvider(&deleteWatch));
- QVERIFY(deleteWatch);
-}
-
-void tst_qdeclarativeimageprovider::requestImage_async_data()
-{
- fillRequestTestsData("qimage|async");
-}
-
-void tst_qdeclarativeimageprovider::requestImage_async()
-{
- bool deleteWatch = false;
- runTest(true, new TestQImageProvider(&deleteWatch));
- QVERIFY(deleteWatch);
-}
-
-void tst_qdeclarativeimageprovider::requestPixmap_sync_data()
-{
- fillRequestTestsData("qpixmap");
-}
-
-void tst_qdeclarativeimageprovider::requestPixmap_sync()
-{
- bool deleteWatch = false;
- runTest(false, new TestQPixmapProvider(&deleteWatch));
- QVERIFY(deleteWatch);
-}
-
-void tst_qdeclarativeimageprovider::requestPixmap_async()
-{
- QDeclarativeEngine engine;
- QDeclarativeImageProvider *provider = new TestQPixmapProvider();
-
- engine.addImageProvider("test", provider);
- QVERIFY(engine.imageProvider("test") != 0);
-
- // pixmaps are loaded synchronously regardless of 'asynchronous' value
- QString componentStr = "import QtQuick 2.0\nImage { asynchronous: true; source: \"image://test/pixmap-async-test.png\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
-
- delete obj;
-}
-
-void tst_qdeclarativeimageprovider::removeProvider_data()
-{
- QTest::addColumn<QDeclarativeImageProvider*>("provider");
-
- QTest::newRow("qimage") << static_cast<QDeclarativeImageProvider*>(new TestQImageProvider);
- QTest::newRow("qpixmap") << static_cast<QDeclarativeImageProvider*>(new TestQPixmapProvider);
-}
-
-void tst_qdeclarativeimageprovider::removeProvider()
-{
- QFETCH(QDeclarativeImageProvider*, provider);
-
- QDeclarativeEngine engine;
-
- engine.addImageProvider("test", provider);
- QVERIFY(engine.imageProvider("test") != 0);
-
- // add provider, confirm it works
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + newImageFileName() + "\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->status(), QQuickImage::Ready);
-
- // remove the provider and confirm
- QString fileName = newImageFileName();
- QString error("file::2:1: QML Image: Invalid image provider: " + fileName);
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- engine.removeImageProvider("test");
-
- obj->setSource(QUrl(fileName));
- QCOMPARE(obj->status(), QQuickImage::Error);
-
- 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 QtQuick 2.0\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<QQuickImage *> images = obj->findChildren<QQuickImage *>();
- QCOMPARE(images.count(), 4);
- QTest::qWait(100);
- foreach (QQuickImage *img, images) {
- QCOMPARE(img->status(), QQuickImage::Loading);
- }
- provider->ok = true;
- provider->cond.wakeAll();
- QTest::qWait(250);
- foreach (QQuickImage *img, images) {
- QTRY_VERIFY(img->status() == QQuickImage::Ready);
- }
-}
-
-
-QTEST_MAIN(tst_qdeclarativeimageprovider)
-
-#include "tst_qdeclarativeimageprovider.moc"
diff --git a/tests/auto/declarative/qdeclarativeincubator/qdeclarativeincubator.pro b/tests/auto/declarative/qdeclarativeincubator/qdeclarativeincubator.pro
deleted file mode 100644
index 90a6720bd7..0000000000
--- a/tests/auto/declarative/qdeclarativeincubator/qdeclarativeincubator.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeincubator
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeincubator.cpp \
- testtypes.cpp
-
-HEADERS += testtypes.h
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private network widgets testlib
diff --git a/tests/auto/declarative/qdeclarativeincubator/testtypes.cpp b/tests/auto/declarative/qdeclarativeincubator/testtypes.cpp
deleted file mode 100644
index 784c727cb7..0000000000
--- a/tests/auto/declarative/qdeclarativeincubator/testtypes.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "testtypes.h"
-#include <QtDeclarative/qdeclarative.h>
-
-SelfRegisteringType *SelfRegisteringType::m_me = 0;
-SelfRegisteringType::SelfRegisteringType()
-: m_v(0)
-{
- m_me = this;
-}
-
-SelfRegisteringType *SelfRegisteringType::me()
-{
- return m_me;
-}
-
-void SelfRegisteringType::clearMe()
-{
- m_me = 0;
-}
-
-CompletionRegisteringType *CompletionRegisteringType::m_me = 0;
-CompletionRegisteringType::CompletionRegisteringType()
-{
-}
-
-void CompletionRegisteringType::classBegin()
-{
-}
-
-void CompletionRegisteringType::componentComplete()
-{
- m_me = this;
-}
-
-CompletionRegisteringType *CompletionRegisteringType::me()
-{
- return m_me;
-}
-
-void CompletionRegisteringType::clearMe()
-{
- m_me = 0;
-}
-
-CallbackRegisteringType::callback CallbackRegisteringType::m_callback = 0;
-void *CallbackRegisteringType::m_data = 0;
-CallbackRegisteringType::CallbackRegisteringType()
-: m_v(0)
-{
-}
-
-void CallbackRegisteringType::clearCallback()
-{
- m_callback = 0;
- m_data = 0;
-}
-
-void CallbackRegisteringType::registerCallback(callback c, void *d)
-{
- m_callback = c;
- m_data = d;
-}
-
-CompletionCallbackType::callback CompletionCallbackType::m_callback = 0;
-void *CompletionCallbackType::m_data = 0;
-CompletionCallbackType::CompletionCallbackType()
-{
-}
-
-void CompletionCallbackType::classBegin()
-{
-}
-
-void CompletionCallbackType::componentComplete()
-{
- if (m_callback) m_callback(this, m_data);
-}
-
-void CompletionCallbackType::clearCallback()
-{
- m_callback = 0;
- m_data = 0;
-}
-
-void CompletionCallbackType::registerCallback(callback c, void *d)
-{
- m_callback = c;
- m_data = d;
-}
-
-void registerTypes()
-{
- qmlRegisterType<SelfRegisteringType>("Qt.test", 1,0, "SelfRegistering");
- qmlRegisterType<CompletionRegisteringType>("Qt.test", 1,0, "CompletionRegistering");
- qmlRegisterType<CallbackRegisteringType>("Qt.test", 1,0, "CallbackRegistering");
- qmlRegisterType<CompletionCallbackType>("Qt.test", 1,0, "CompletionCallback");
-}
diff --git a/tests/auto/declarative/qdeclarativeincubator/testtypes.h b/tests/auto/declarative/qdeclarativeincubator/testtypes.h
deleted file mode 100644
index 3e679d3119..0000000000
--- a/tests/auto/declarative/qdeclarativeincubator/testtypes.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QtCore/qobject.h>
-#include <QDeclarativeParserStatus>
-
-class SelfRegisteringType : public QObject
-{
-Q_OBJECT
-Q_PROPERTY(int value READ value WRITE setValue);
-public:
- SelfRegisteringType();
-
- int value() const { return m_v; }
- void setValue(int v) { m_v = v; }
-
- static SelfRegisteringType *me();
- static void clearMe();
-
-private:
- static SelfRegisteringType *m_me;
-
- int m_v;
-};
-
-class CallbackRegisteringType : public QObject
-{
-Q_OBJECT
-Q_PROPERTY(int value READ value WRITE setValue)
-public:
- CallbackRegisteringType();
-
- int value() const { return m_v; }
- void setValue(int v) { if (m_callback) m_callback(this, m_data); m_v = v; }
-
- typedef void (*callback)(CallbackRegisteringType *, void *);
- static void clearCallback();
- static void registerCallback(callback, void *);
-
-private:
- static callback m_callback;
- static void *m_data;
-
- int m_v;
-};
-
-class CompletionRegisteringType : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
-public:
- CompletionRegisteringType();
-
- virtual void classBegin();
- virtual void componentComplete();
-
- static CompletionRegisteringType *me();
- static void clearMe();
-
-private:
- static CompletionRegisteringType *m_me;
-};
-
-class CompletionCallbackType : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativeParserStatus)
-public:
- CompletionCallbackType();
-
- virtual void classBegin();
- virtual void componentComplete();
-
- typedef void (*callback)(CompletionCallbackType *, void *);
- static void clearCallback();
- static void registerCallback(callback, void *);
-
-private:
- static callback m_callback;
- static void *m_data;
-};
-
-void registerTypes();
-
-#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp b/tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp
deleted file mode 100644
index 7f68b9af95..0000000000
--- a/tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp
+++ /dev/null
@@ -1,1030 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "testtypes.h"
-
-#include <QUrl>
-#include <QDir>
-#include <QDebug>
-#include <qtest.h>
-#include <QPointer>
-#include <QFileInfo>
-#include <QDeclarativeEngine>
-#include <QDeclarativeContext>
-#include <QDeclarativeProperty>
-#include <QDeclarativeComponent>
-#include <QDeclarativeIncubator>
-#include "../../shared/util.h"
-
-class tst_qdeclarativeincubator : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeincubator() {}
-
-private slots:
- void initTestCase();
-
- void incubationMode();
- void objectDeleted();
- void clear();
- void noIncubationController();
- void forceCompletion();
- void setInitialState();
- void clearDuringCompletion();
- void objectDeletionAfterInit();
- void recursiveClear();
- void statusChanged();
- void asynchronousIfNested();
- void nestedComponent();
- void chainedAsynchronousIfNested();
- void chainedAsynchronousIfNestedOnCompleted();
- void selfDelete();
- void contextDelete();
-
-private:
- QDeclarativeIncubationController controller;
- QDeclarativeEngine engine;
-};
-
-#define VERIFY_ERRORS(component, errorfile) \
- if (!errorfile) { \
- if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
- qWarning() << "Unexpected Errors:" << component.errors(); \
- QVERIFY(!component.isError()); \
- QVERIFY(component.errors().isEmpty()); \
- } else { \
- QFile file(QDeclarativeDataTest::instance()->testFile(errorfile)); \
- QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \
- QByteArray data = file.readAll(); \
- file.close(); \
- QList<QByteArray> expected = data.split('\n'); \
- expected.removeAll(QByteArray("")); \
- QList<QDeclarativeError> errors = component.errors(); \
- QList<QByteArray> actual; \
- for (int ii = 0; ii < errors.count(); ++ii) { \
- const QDeclarativeError &error = errors.at(ii); \
- QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
- QByteArray::number(error.column()) + ":" + \
- error.description().toUtf8(); \
- actual << errorStr; \
- } \
- if (qgetenv("DEBUG") != "" && expected != actual) \
- qWarning() << "Expected:" << expected << "Actual:" << actual; \
- QCOMPARE(expected, actual); \
- }
-
-void tst_qdeclarativeincubator::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- registerTypes();
- engine.setIncubationController(&controller);
-}
-
-void tst_qdeclarativeincubator::incubationMode()
-{
- {
- QDeclarativeIncubator incubator;
- QCOMPARE(incubator.incubationMode(), QDeclarativeIncubator::Asynchronous);
- }
- {
- QDeclarativeIncubator incubator(QDeclarativeIncubator::Asynchronous);
- QCOMPARE(incubator.incubationMode(), QDeclarativeIncubator::Asynchronous);
- }
- {
- QDeclarativeIncubator incubator(QDeclarativeIncubator::Synchronous);
- QCOMPARE(incubator.incubationMode(), QDeclarativeIncubator::Synchronous);
- }
- {
- QDeclarativeIncubator incubator(QDeclarativeIncubator::AsynchronousIfNested);
- QCOMPARE(incubator.incubationMode(), QDeclarativeIncubator::AsynchronousIfNested);
- }
-}
-
-void tst_qdeclarativeincubator::objectDeleted()
-{
- SelfRegisteringType::clearMe();
-
- QDeclarativeComponent component(&engine, testFileUrl("objectDeleted.qml"));
- QVERIFY(component.isReady());
-
- QDeclarativeIncubator incubator;
- component.create(incubator);
-
- QCOMPARE(incubator.status(), QDeclarativeIncubator::Loading);
- QVERIFY(SelfRegisteringType::me() == 0);
-
- while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(SelfRegisteringType::me() != 0);
- QVERIFY(incubator.isLoading());
-
- delete SelfRegisteringType::me();
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isError());
- VERIFY_ERRORS(incubator, "objectDeleted.errors.txt");
- QVERIFY(incubator.object() == 0);
-}
-
-void tst_qdeclarativeincubator::clear()
-{
- SelfRegisteringType::clearMe();
-
- QDeclarativeComponent component(&engine, testFileUrl("clear.qml"));
- QVERIFY(component.isReady());
-
- // Clear in null state
- {
- QDeclarativeIncubator incubator;
- QVERIFY(incubator.isNull());
- incubator.clear(); // no effect
- QVERIFY(incubator.isNull());
- }
-
- // Clear in loading state
- {
- QDeclarativeIncubator incubator;
- component.create(incubator);
- QVERIFY(incubator.isLoading());
- incubator.clear();
- QVERIFY(incubator.isNull());
- }
-
- // Clear mid load
- {
- QDeclarativeIncubator incubator;
- component.create(incubator);
-
- while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isLoading());
- QVERIFY(SelfRegisteringType::me() != 0);
- QPointer<SelfRegisteringType> srt = SelfRegisteringType::me();
-
- incubator.clear();
- QVERIFY(incubator.isNull());
- QVERIFY(srt.isNull());
- }
-
- // Clear in ready state
- {
- QDeclarativeIncubator incubator;
- component.create(incubator);
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object() != 0);
- QPointer<QObject> obj = incubator.object();
-
- incubator.clear();
- QVERIFY(incubator.isNull());
- QVERIFY(incubator.object() == 0);
- QVERIFY(!obj.isNull());
-
- delete obj;
- QVERIFY(obj.isNull());
- }
-}
-
-void tst_qdeclarativeincubator::noIncubationController()
-{
- // All incubators should behave synchronously when there is no controller
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("noIncubationController.qml"));
-
- QVERIFY(component.isReady());
-
- {
- QDeclarativeIncubator incubator(QDeclarativeIncubator::Asynchronous);
- component.create(incubator);
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object());
- QCOMPARE(incubator.object()->property("testValue").toInt(), 1913);
- delete incubator.object();
- }
-
- {
- QDeclarativeIncubator incubator(QDeclarativeIncubator::AsynchronousIfNested);
- component.create(incubator);
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object());
- QCOMPARE(incubator.object()->property("testValue").toInt(), 1913);
- delete incubator.object();
- }
-
- {
- QDeclarativeIncubator incubator(QDeclarativeIncubator::Synchronous);
- component.create(incubator);
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object());
- QCOMPARE(incubator.object()->property("testValue").toInt(), 1913);
- delete incubator.object();
- }
-}
-
-void tst_qdeclarativeincubator::forceCompletion()
-{
- QDeclarativeComponent component(&engine, testFileUrl("forceCompletion.qml"));
- QVERIFY(component.isReady());
-
- {
- // forceCompletion on a null incubator does nothing
- QDeclarativeIncubator incubator;
- QVERIFY(incubator.isNull());
- incubator.forceCompletion();
- QVERIFY(incubator.isNull());
- }
-
- {
- // forceCompletion immediately after creating an asynchronous object completes it
- QDeclarativeIncubator incubator;
- QVERIFY(incubator.isNull());
- component.create(incubator);
- QVERIFY(incubator.isLoading());
-
- incubator.forceCompletion();
-
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object() != 0);
- QCOMPARE(incubator.object()->property("testValue").toInt(), 3499);
-
- delete incubator.object();
- }
-
- {
- // forceCompletion during creation completes it
- SelfRegisteringType::clearMe();
-
- QDeclarativeIncubator incubator;
- QVERIFY(incubator.isNull());
- component.create(incubator);
- QVERIFY(incubator.isLoading());
-
- while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(SelfRegisteringType::me() != 0);
- QVERIFY(incubator.isLoading());
-
- incubator.forceCompletion();
-
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object() != 0);
- QCOMPARE(incubator.object()->property("testValue").toInt(), 3499);
-
- delete incubator.object();
- }
-
- {
- // forceCompletion on a ready incubator has no effect
- QDeclarativeIncubator incubator;
- QVERIFY(incubator.isNull());
- component.create(incubator);
- QVERIFY(incubator.isLoading());
-
- incubator.forceCompletion();
-
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object() != 0);
- QCOMPARE(incubator.object()->property("testValue").toInt(), 3499);
-
- incubator.forceCompletion();
-
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object() != 0);
- QCOMPARE(incubator.object()->property("testValue").toInt(), 3499);
-
- delete incubator.object();
- }
-}
-
-void tst_qdeclarativeincubator::setInitialState()
-{
- QDeclarativeComponent component(&engine, testFileUrl("setInitialState.qml"));
- QVERIFY(component.isReady());
-
- struct MyIncubator : public QDeclarativeIncubator
- {
- MyIncubator(QDeclarativeIncubator::IncubationMode mode)
- : QDeclarativeIncubator(mode) {}
-
- virtual void setInitialState(QObject *o) {
- QDeclarativeProperty::write(o, "test2", 19);
- QDeclarativeProperty::write(o, "testData1", 201);
- }
- };
-
- {
- MyIncubator incubator(QDeclarativeIncubator::Asynchronous);
- component.create(incubator);
- QVERIFY(incubator.isLoading());
- bool b = true;
- controller.incubateWhile(&b);
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object());
- QCOMPARE(incubator.object()->property("myValueFunctionCalled").toBool(), false);
- QCOMPARE(incubator.object()->property("test1").toInt(), 502);
- QCOMPARE(incubator.object()->property("test2").toInt(), 19);
- delete incubator.object();
- }
-
- {
- MyIncubator incubator(QDeclarativeIncubator::Synchronous);
- component.create(incubator);
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object());
- QCOMPARE(incubator.object()->property("myValueFunctionCalled").toBool(), false);
- QCOMPARE(incubator.object()->property("test1").toInt(), 502);
- QCOMPARE(incubator.object()->property("test2").toInt(), 19);
- delete incubator.object();
- }
-}
-
-void tst_qdeclarativeincubator::clearDuringCompletion()
-{
- CompletionRegisteringType::clearMe();
- SelfRegisteringType::clearMe();
-
- QDeclarativeComponent component(&engine, testFileUrl("clearDuringCompletion.qml"));
- QVERIFY(component.isReady());
-
- QDeclarativeIncubator incubator;
- component.create(incubator);
-
- QCOMPARE(incubator.status(), QDeclarativeIncubator::Loading);
- QVERIFY(CompletionRegisteringType::me() == 0);
-
- while (CompletionRegisteringType::me() == 0 && incubator.isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(CompletionRegisteringType::me() != 0);
- QVERIFY(SelfRegisteringType::me() != 0);
- QVERIFY(incubator.isLoading());
-
- QPointer<QObject> srt = SelfRegisteringType::me();
-
- incubator.clear();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QVERIFY(incubator.isNull());
- QVERIFY(srt.isNull());
-}
-
-void tst_qdeclarativeincubator::objectDeletionAfterInit()
-{
- QDeclarativeComponent component(&engine, testFileUrl("clear.qml"));
- QVERIFY(component.isReady());
-
- struct MyIncubator : public QDeclarativeIncubator
- {
- MyIncubator(QDeclarativeIncubator::IncubationMode mode)
- : QDeclarativeIncubator(mode), obj(0) {}
-
- virtual void setInitialState(QObject *o) {
- obj = o;
- }
-
- QObject *obj;
- };
-
- SelfRegisteringType::clearMe();
- MyIncubator incubator(QDeclarativeIncubator::Asynchronous);
- component.create(incubator);
-
- while (!incubator.obj && incubator.isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isLoading());
- QVERIFY(SelfRegisteringType::me() != 0);
-
- delete incubator.obj;
-
- incubator.clear();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QVERIFY(incubator.isNull());
-}
-
-class Switcher : public QObject
-{
- Q_OBJECT
-public:
- Switcher(QDeclarativeEngine *e) : QObject(), engine(e) { }
-
- struct MyIncubator : public QDeclarativeIncubator
- {
- MyIncubator(QDeclarativeIncubator::IncubationMode mode, QObject *s)
- : QDeclarativeIncubator(mode), switcher(s) {}
-
- virtual void setInitialState(QObject *o) {
- if (o->objectName() == "switchMe")
- connect(o, SIGNAL(switchMe()), switcher, SLOT(switchIt()));
- }
-
- QObject *switcher;
- };
-
- void start()
- {
- incubator = new MyIncubator(QDeclarativeIncubator::Synchronous, this);
- component = new QDeclarativeComponent(engine, QDeclarativeDataTest::instance()->testFileUrl("recursiveClear.1.qml"));
- component->create(*incubator);
- }
-
- QDeclarativeEngine *engine;
- MyIncubator *incubator;
- QDeclarativeComponent *component;
-
-public slots:
- void switchIt() {
- component->deleteLater();
- incubator->clear();
- component = new QDeclarativeComponent(engine, QDeclarativeDataTest::instance()->testFileUrl("recursiveClear.2.qml"));
- component->create(*incubator);
- }
-};
-
-void tst_qdeclarativeincubator::recursiveClear()
-{
- Switcher switcher(&engine);
- switcher.start();
-}
-
-void tst_qdeclarativeincubator::statusChanged()
-{
- class MyIncubator : public QDeclarativeIncubator
- {
- public:
- MyIncubator(QDeclarativeIncubator::IncubationMode mode = QDeclarativeIncubator::Asynchronous)
- : QDeclarativeIncubator(mode) {}
-
- QList<int> statuses;
- protected:
- virtual void statusChanged(Status s) { statuses << s; }
- virtual void setInitialState(QObject *) { statuses << -1; }
- };
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("statusChanged.qml"));
- QVERIFY(component.isReady());
-
- MyIncubator incubator(QDeclarativeIncubator::Synchronous);
- component.create(incubator);
- QVERIFY(incubator.isReady());
- QCOMPARE(incubator.statuses.count(), 3);
- QCOMPARE(incubator.statuses.at(0), int(QDeclarativeIncubator::Loading));
- QCOMPARE(incubator.statuses.at(1), -1);
- QCOMPARE(incubator.statuses.at(2), int(QDeclarativeIncubator::Ready));
- delete incubator.object();
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("statusChanged.qml"));
- QVERIFY(component.isReady());
-
- MyIncubator incubator(QDeclarativeIncubator::Asynchronous);
- component.create(incubator);
- QVERIFY(incubator.isLoading());
- QCOMPARE(incubator.statuses.count(), 1);
- QCOMPARE(incubator.statuses.at(0), int(QDeclarativeIncubator::Loading));
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- QCOMPARE(incubator.statuses.count(), 3);
- QCOMPARE(incubator.statuses.at(0), int(QDeclarativeIncubator::Loading));
- QCOMPARE(incubator.statuses.at(1), -1);
- QCOMPARE(incubator.statuses.at(2), int(QDeclarativeIncubator::Ready));
- delete incubator.object();
- }
-
- {
- QDeclarativeComponent component2(&engine, testFileUrl("statusChanged.nested.qml"));
- QVERIFY(component2.isReady());
-
- MyIncubator incubator(QDeclarativeIncubator::Asynchronous);
- component2.create(incubator);
- QVERIFY(incubator.isLoading());
- QCOMPARE(incubator.statuses.count(), 1);
- QCOMPARE(incubator.statuses.at(0), int(QDeclarativeIncubator::Loading));
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isReady());
- QCOMPARE(incubator.statuses.count(), 3);
- QCOMPARE(incubator.statuses.at(0), int(QDeclarativeIncubator::Loading));
- QCOMPARE(incubator.statuses.at(1), -1);
- QCOMPARE(incubator.statuses.at(2), int(QDeclarativeIncubator::Ready));
- delete incubator.object();
- }
-}
-
-void tst_qdeclarativeincubator::asynchronousIfNested()
-{
- // Asynchronous if nested within a finalized context behaves synchronously
- {
- QDeclarativeComponent component(&engine, testFileUrl("asynchronousIfNested.1.qml"));
- QVERIFY(component.isReady());
-
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("a").toInt(), 10);
-
- QDeclarativeIncubator incubator(QDeclarativeIncubator::AsynchronousIfNested);
- component.create(incubator, 0, qmlContext(object));
-
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object());
- QCOMPARE(incubator.object()->property("a").toInt(), 10);
- delete incubator.object();
- delete object;
- }
-
- // Asynchronous if nested within an executing context behaves asynchronously, but prevents
- // the parent from finishing
- {
- SelfRegisteringType::clearMe();
-
- QDeclarativeComponent component(&engine, testFileUrl("asynchronousIfNested.2.qml"));
- QVERIFY(component.isReady());
-
- QDeclarativeIncubator incubator;
- component.create(incubator);
-
- QVERIFY(incubator.isLoading());
- QVERIFY(SelfRegisteringType::me() == 0);
- while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(SelfRegisteringType::me() != 0);
- QVERIFY(incubator.isLoading());
-
- QDeclarativeIncubator nested(QDeclarativeIncubator::AsynchronousIfNested);
- component.create(nested, 0, qmlContext(SelfRegisteringType::me()));
- QVERIFY(nested.isLoading());
-
- while (nested.isLoading()) {
- QVERIFY(incubator.isLoading());
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(nested.isReady());
- QVERIFY(incubator.isLoading());
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(nested.isReady());
- QVERIFY(incubator.isReady());
-
- delete nested.object();
- delete incubator.object();
- }
-
- // AsynchronousIfNested within a synchronous AsynchronousIfNested behaves synchronously
- {
- SelfRegisteringType::clearMe();
-
- QDeclarativeComponent component(&engine, testFileUrl("asynchronousIfNested.3.qml"));
- QVERIFY(component.isReady());
-
- struct CallbackData {
- CallbackData(QDeclarativeEngine *e) : engine(e), pass(false) {}
- QDeclarativeEngine *engine;
- bool pass;
- static void callback(CallbackRegisteringType *o, void *data) {
- CallbackData *d = (CallbackData *)data;
-
- QDeclarativeComponent c(d->engine, QDeclarativeDataTest::instance()->testFileUrl("asynchronousIfNested.1.qml"));
- if (!c.isReady()) return;
-
- QDeclarativeIncubator incubator(QDeclarativeIncubator::AsynchronousIfNested);
- c.create(incubator, 0, qmlContext(o));
-
- if (!incubator.isReady()) return;
-
- if (incubator.object()->property("a").toInt() != 10) return;
-
- d->pass = true;
- }
- };
-
- CallbackData cd(&engine);
- CallbackRegisteringType::registerCallback(&CallbackData::callback, &cd);
-
- QDeclarativeIncubator incubator(QDeclarativeIncubator::AsynchronousIfNested);
- component.create(incubator);
-
- QVERIFY(incubator.isReady());
- QCOMPARE(cd.pass, true);
-
- delete incubator.object();
- }
-}
-
-void tst_qdeclarativeincubator::nestedComponent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("nestedComponent.qml"));
- QVERIFY(component.isReady());
-
- QObject *object = component.create();
-
- QDeclarativeComponent *nested = object->property("c").value<QDeclarativeComponent*>();
- QVERIFY(nested);
- QVERIFY(nested->isReady());
-
- // Test without incubator
- {
- QObject *nestedObject = nested->create();
- QCOMPARE(nestedObject->property("value").toInt(), 19988);
- delete nestedObject;
- }
-
- // Test with incubator
- {
- QDeclarativeIncubator incubator(QDeclarativeIncubator::Synchronous);
- nested->create(incubator);
- QVERIFY(incubator.isReady());
- QVERIFY(incubator.object());
- QCOMPARE(incubator.object()->property("value").toInt(), 19988);
- delete incubator.object();
- }
-
- delete object;
-}
-
-// Checks that a new AsynchronousIfNested incubator can be correctly started in the
-// statusChanged() callback of another.
-void tst_qdeclarativeincubator::chainedAsynchronousIfNested()
-{
- SelfRegisteringType::clearMe();
-
- QDeclarativeComponent component(&engine, testFileUrl("chainedAsynchronousIfNested.qml"));
- QVERIFY(component.isReady());
-
- QDeclarativeIncubator incubator(QDeclarativeIncubator::Asynchronous);
- component.create(incubator);
-
- QVERIFY(incubator.isLoading());
- QVERIFY(SelfRegisteringType::me() == 0);
-
- while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(SelfRegisteringType::me() != 0);
- QVERIFY(incubator.isLoading());
-
- struct MyIncubator : public QDeclarativeIncubator {
- MyIncubator(MyIncubator *next, QDeclarativeComponent *component, QDeclarativeContext *ctxt)
- : QDeclarativeIncubator(AsynchronousIfNested), next(next), component(component), ctxt(ctxt) {}
-
- protected:
- virtual void statusChanged(Status s) {
- if (s == Ready && next)
- component->create(*next, 0, ctxt);
- }
-
- private:
- MyIncubator *next;
- QDeclarativeComponent *component;
- QDeclarativeContext *ctxt;
- };
-
- MyIncubator incubator2(0, &component, 0);
- MyIncubator incubator1(&incubator2, &component, qmlContext(SelfRegisteringType::me()));
-
- component.create(incubator1, 0, qmlContext(SelfRegisteringType::me()));
-
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isLoading());
- QVERIFY(incubator2.isNull());
-
- while (incubator1.isLoading()) {
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isLoading());
- QVERIFY(incubator2.isNull());
-
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isLoading());
-
- while (incubator2.isLoading()) {
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isLoading());
-
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isReady());
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isReady());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isReady());
-}
-
-// Checks that new AsynchronousIfNested incubators can be correctly chained if started in
-// componentCompleted().
-void tst_qdeclarativeincubator::chainedAsynchronousIfNestedOnCompleted()
-{
- SelfRegisteringType::clearMe();
-
- QDeclarativeComponent component(&engine, testFileUrl("chainInCompletion.qml"));
- QVERIFY(component.isReady());
-
- QDeclarativeComponent c1(&engine, testFileUrl("chainedAsynchronousIfNested.qml"));
- QVERIFY(c1.isReady());
-
- struct MyIncubator : public QDeclarativeIncubator {
- MyIncubator(MyIncubator *next, QDeclarativeComponent *component, QDeclarativeContext *ctxt)
- : QDeclarativeIncubator(AsynchronousIfNested), next(next), component(component), ctxt(ctxt) {}
-
- protected:
- virtual void statusChanged(Status s) {
- if (s == Ready && next) {
- component->create(*next, 0, ctxt);
- }
- }
-
- private:
- MyIncubator *next;
- QDeclarativeComponent *component;
- QDeclarativeContext *ctxt;
- };
-
- struct CallbackData {
- CallbackData(QDeclarativeComponent *c, MyIncubator *i, QDeclarativeContext *ct)
- : component(c), incubator(i), ctxt(ct) {}
- QDeclarativeComponent *component;
- MyIncubator *incubator;
- QDeclarativeContext *ctxt;
- static void callback(CompletionCallbackType *, void *data) {
- CallbackData *d = (CallbackData *)data;
- d->component->create(*d->incubator, 0, d->ctxt);
- }
- };
-
- QDeclarativeIncubator incubator(QDeclarativeIncubator::Asynchronous);
- component.create(incubator);
-
- QVERIFY(incubator.isLoading());
- QVERIFY(SelfRegisteringType::me() == 0);
-
- while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(SelfRegisteringType::me() != 0);
- QVERIFY(incubator.isLoading());
-
- MyIncubator incubator3(0, &c1, qmlContext(SelfRegisteringType::me()));
- MyIncubator incubator2(&incubator3, &c1, qmlContext(SelfRegisteringType::me()));
- MyIncubator incubator1(&incubator2, &c1, qmlContext(SelfRegisteringType::me()));
-
- // start incubator1 in componentComplete
- CallbackData cd(&c1, &incubator1, qmlContext(SelfRegisteringType::me()));
- CompletionCallbackType::registerCallback(&CallbackData::callback, &cd);
-
- while (!incubator1.isLoading()) {
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator2.isNull());
- QVERIFY(incubator3.isNull());
-
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isLoading());
- QVERIFY(incubator2.isNull());
- QVERIFY(incubator3.isNull());
-
- while (incubator1.isLoading()) {
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isLoading());
- QVERIFY(incubator2.isNull());
- QVERIFY(incubator3.isNull());
-
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isLoading());
- QVERIFY(incubator3.isNull());
-
- while (incubator2.isLoading()) {
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isLoading());
- QVERIFY(incubator3.isNull());
-
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isReady());
- QVERIFY(incubator3.isLoading());
-
- while (incubator3.isLoading()) {
- QVERIFY(incubator.isLoading());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isReady());
- QVERIFY(incubator3.isLoading());
-
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(incubator.isReady());
- QVERIFY(incubator1.isReady());
- QVERIFY(incubator2.isReady());
- QVERIFY(incubator3.isReady());
-}
-
-void tst_qdeclarativeincubator::selfDelete()
-{
- struct MyIncubator : public QDeclarativeIncubator {
- MyIncubator(bool *done, Status status, IncubationMode mode)
- : QDeclarativeIncubator(mode), done(done), status(status) {}
-
- protected:
- virtual void statusChanged(Status s) {
- if (s == status) {
- *done = true;
- if (s == Ready) delete object();
- delete this;
- }
- }
-
- private:
- bool *done;
- Status status;
- };
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("selfDelete.qml"));
-
-#define DELETE_TEST(status, mode) { \
- bool done = false; \
- component.create(*(new MyIncubator(&done, status, mode))); \
- bool True = true; \
- controller.incubateWhile(&True); \
- QVERIFY(done == true); \
- }
-
- DELETE_TEST(QDeclarativeIncubator::Loading, QDeclarativeIncubator::Synchronous);
- DELETE_TEST(QDeclarativeIncubator::Ready, QDeclarativeIncubator::Synchronous);
- DELETE_TEST(QDeclarativeIncubator::Loading, QDeclarativeIncubator::Asynchronous);
- DELETE_TEST(QDeclarativeIncubator::Ready, QDeclarativeIncubator::Asynchronous);
-
-#undef DELETE_TEST
- }
-
- // Delete within error status
- {
- SelfRegisteringType::clearMe();
-
- QDeclarativeComponent component(&engine, testFileUrl("objectDeleted.qml"));
- QVERIFY(component.isReady());
-
- bool done = false;
- MyIncubator *incubator = new MyIncubator(&done, QDeclarativeIncubator::Error,
- QDeclarativeIncubator::Asynchronous);
- component.create(*incubator);
-
- QCOMPARE(incubator->QDeclarativeIncubator::status(), QDeclarativeIncubator::Loading);
- QVERIFY(SelfRegisteringType::me() == 0);
-
- while (SelfRegisteringType::me() == 0 && incubator->isLoading()) {
- bool b = false;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(SelfRegisteringType::me() != 0);
- QVERIFY(incubator->isLoading());
-
- delete SelfRegisteringType::me();
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- QVERIFY(done);
- }
-}
-
-// Test that QML doesn't crash if the context is deleted prior to the incubator
-// first executing.
-void tst_qdeclarativeincubator::contextDelete()
-{
- QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
- QDeclarativeComponent component(&engine, testFileUrl("contextDelete.qml"));
-
- QDeclarativeIncubator incubator;
- component.create(incubator, context);
-
- delete context;
-
- {
- bool b = false;
- controller.incubateWhile(&b);
- }
-}
-
-QTEST_MAIN(tst_qdeclarativeincubator)
-
-#include "tst_qdeclarativeincubator.moc"
diff --git a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro
deleted file mode 100644
index af4667184f..0000000000
--- a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeinfo
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeinfo.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private widgets testlib
diff --git a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp
deleted file mode 100644
index 868cd901c0..0000000000
--- a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QTimer>
-#include <QDeclarativeContext>
-#include <qdeclarativeinfo.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativeinfo : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeinfo() {}
-
-private slots:
- void qmlObject();
- void nestedQmlObject();
- void nestedComponent();
- void nonQmlObject();
- void nullObject();
- void nonQmlContextedObject();
- void types();
- void chaining();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qdeclarativeinfo::qmlObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qmlObject.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QString message = component.url().toString() + ":3:1: QML QtObject: Test Message";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(object) << "Test Message";
-
- QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
- QVERIFY(nested != 0);
-
- message = component.url().toString() + ":6:13: QML QtObject: Second Test Message";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(nested) << "Second Test Message";
-}
-
-void tst_qdeclarativeinfo::nestedQmlObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("nestedQmlObject.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
- QVERIFY(nested != 0);
- QObject *nested2 = qvariant_cast<QObject *>(object->property("nested2"));
- QVERIFY(nested2 != 0);
-
- QString message = component.url().toString() + ":5:13: QML NestedObject: Outer Object";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(nested) << "Outer Object";
-
- message = testFileUrl("NestedObject.qml").toString() + ":6:14: QML QtObject: Inner Object";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(nested2) << "Inner Object";
-}
-
-void tst_qdeclarativeinfo::nestedComponent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("NestedComponent.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
- QVERIFY(nested != 0);
- QObject *nested2 = qvariant_cast<QObject *>(object->property("nested2"));
- QVERIFY(nested2 != 0);
-
- QString message = component.url().toString() + ":10:9: QML NestedObject: Complex Object";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(nested) << "Complex Object";
-
- message = component.url().toString() + ":16:9: QML Image: Simple Object";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- qmlInfo(nested2) << "Simple Object";
-}
-
-void tst_qdeclarativeinfo::nonQmlObject()
-{
- QObject object;
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML QtObject: Test Message");
- qmlInfo(&object) << "Test Message";
-
- QTimer nonQmlObject;
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML QTimer: Test Message");
- qmlInfo(&nonQmlObject) << "Test Message";
-}
-
-void tst_qdeclarativeinfo::nullObject()
-{
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Null Object Test Message");
- qmlInfo(0) << "Null Object Test Message";
-}
-
-void tst_qdeclarativeinfo::nonQmlContextedObject()
-{
- QObject object;
- QDeclarativeContext context(&engine);
- QDeclarativeEngine::setContextForObject(&object, &context);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML QtObject: Test Message");
- qmlInfo(&object) << "Test Message";
-}
-
-void tst_qdeclarativeinfo::types()
-{
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: false");
- qmlInfo(0) << false;
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 1.1");
- qmlInfo(0) << 1.1;
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 1.2");
- qmlInfo(0) << 1.2f;
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 15");
- qmlInfo(0) << 15;
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 'b'");
- qmlInfo(0) << QChar('b');
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: \"Qt\"");
- qmlInfo(0) << QByteArray("Qt");
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: true");
- qmlInfo(0) << bool(true);
-
- //### do we actually want QUrl to show up in the output?
- //### why the extra space at the end?
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QUrl(\"http://qt.nokia.com\") ");
- qmlInfo(0) << QUrl("http://qt.nokia.com");
-
- //### should this be quoted?
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: hello");
- qmlInfo(0) << QLatin1String("hello");
-
- //### should this be quoted?
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: World");
- QString str("Hello World");
- QStringRef ref(&str, 6, 5);
- qmlInfo(0) << ref;
-
- //### should this be quoted?
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Quick");
- qmlInfo(0) << QString ("Quick");
-}
-
-void tst_qdeclarativeinfo::chaining()
-{
- //### should more of these be automatically inserting spaces?
- QString str("Hello World");
- QStringRef ref(&str, 6, 5);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: false 1.1 1.2 15 hello 'b' QUrl(\"http://qt.nokia.com\") World \"Qt\" true Quick ");
- qmlInfo(0) << false << ' '
- << 1.1 << ' '
- << 1.2f << ' '
- << 15 << ' '
- << QLatin1String("hello") << ' '
- << QChar('b') << ' '
- << QUrl("http://qt.nokia.com")
- << ref
- << QByteArray("Qt")
- << bool(true)
- << QString ("Quick");
-}
-
-QTEST_MAIN(tst_qdeclarativeinfo)
-
-#include "tst_qdeclarativeinfo.moc"
diff --git a/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro b/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro
deleted file mode 100644
index 437b0869d1..0000000000
--- a/tests/auto/declarative/qdeclarativeinstruction/qdeclarativeinstruction.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeinstruction
-SOURCES += tst_qdeclarativeinstruction.cpp
-macx:CONFIG -= app_bundle
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
deleted file mode 100644
index 072718a95c..0000000000
--- a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
+++ /dev/null
@@ -1,678 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <private/qdeclarativecompiler_p.h>
-
-class tst_qdeclarativeinstruction : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeinstruction() {}
-
-private slots:
- void dump();
-
- void point();
- void pointf();
- void size();
- void sizef();
- void rect();
- void rectf();
- void vector3d();
- void vector4d();
- void time();
-};
-
-static QStringList messages;
-static void msgHandler(QtMsgType, const char *msg)
-{
- messages << QLatin1String(msg);
-}
-
-void tst_qdeclarativeinstruction::dump()
-{
- QDeclarativeEngine engine;
- QDeclarativeCompiledData *data = new QDeclarativeCompiledData(&engine);
-
- {
- QDeclarativeCompiledData::Instruction::Init i;
- i.bindingsSize = 0;
- i.parserStatusSize = 3;
- i.contextCache = -1;
- i.compiledBinding = -1;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::TypeReference ref;
- ref.className = "Test";
- data->types << ref;
-
- QDeclarativeCompiledData::Instruction::CreateCppObject i;
- i.type = 0;
- i.data = -1;
- i.column = 10;
- data->addInstruction(i);
- }
-
- {
- data->primitives << "testId";
-
- QDeclarativeCompiledData::Instruction::SetId i;
- i.value = data->primitives.count() - 1;
- i.index = 0;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::SetDefault i;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::CreateComponent i;
- i.count = 3;
- i.column = 4;
- i.endLine = 14;
- i.metaObject = 0;
-
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreMetaObject i;
- i.data = 3;
- i.aliasData = 6;
- i.propertyCache = 7;
-
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreFloat i;
- i.propertyIndex = 3;
- i.value = 11.3;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreDouble i;
- i.propertyIndex = 4;
- i.value = 14.8;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreInteger i;
- i.propertyIndex = 5;
- i.value = 9;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreBool i;
- i.propertyIndex = 6;
- i.value = true;
-
- data->addInstruction(i);
- }
-
- {
- data->primitives << "Test String";
- QDeclarativeCompiledData::Instruction::StoreString i;
- i.propertyIndex = 7;
- i.value = data->primitives.count() - 1;
- data->addInstruction(i);
- }
-
- {
- data->urls << QUrl("http://www.nokia.com");
- QDeclarativeCompiledData::Instruction::StoreUrl i;
- i.propertyIndex = 8;
- i.value = data->urls.count() - 1;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreColor i;
- i.propertyIndex = 9;
- i.value = 0xFF00FF00;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreDate i;
- i.propertyIndex = 10;
- i.value = 9;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreTime i;
- i.propertyIndex = 11;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreDateTime i;
- i.propertyIndex = 12;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StorePoint i;
- i.propertyIndex = 13;
- i.point.xp = 3;
- i.point.yp = 7;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StorePointF i;
- i.propertyIndex = 13;
- i.point.xp = 3;
- i.point.yp = 7;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreSize i;
- i.propertyIndex = 15;
- i.size.wd = 8;
- i.size.ht = 11;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreSizeF i;
- i.propertyIndex = 15;
- i.size.wd = 8;
- i.size.ht = 11;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreRect i;
- i.propertyIndex = 17;
- i.rect.x1 = 7;
- i.rect.y1 = 9;
- i.rect.x2 = 11;
- i.rect.y2 = 13;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreRectF i;
- i.propertyIndex = 18;
- i.rect.xp = 11.3;
- i.rect.yp = 9.8;
- i.rect.w = 3;
- i.rect.h = 2.1;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreVector3D i;
- i.propertyIndex = 19;
- i.vector.xp = 9;
- i.vector.yp = 3;
- i.vector.zp = 92;
- data->addInstruction(i);
- }
-
- {
- data->primitives << "color(1, 1, 1, 1)";
- QDeclarativeCompiledData::Instruction::StoreVariant i;
- i.propertyIndex = 20;
- i.value = data->primitives.count() - 1;
-
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreObject i;
- i.propertyIndex = 21;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreVariantObject i;
- i.propertyIndex = 22;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreInterface i;
- i.propertyIndex = 23;
- data->addInstruction(i);
- }
-
- {
- data->primitives << "console.log(1921)";
-
- QDeclarativeCompiledData::Instruction::StoreSignal i;
- i.signalIndex = 2;
- i.value = data->primitives.count() - 1;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreScriptString i;
- i.propertyIndex = 24;
- i.value = 3;
- i.scope = 1;
- i.bindingId = 4;
- data->addInstruction(i);
- }
-
- {
- data->primitives << "mySignal";
-
- QDeclarativeCompiledData::Instruction::AssignSignalObject i;
- i.signal = data->primitives.count() - 1;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::AssignCustomType i;
- i.propertyIndex = 25;
- i.primitive = 6;
- i.type = 9;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreBinding i;
- i.property.coreIndex = 26;
- i.value = 3;
- i.context = 2;
- i.owner = 0;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreV4Binding i;
- i.property = 27;
- i.value = 2;
- i.context = 4;
- i.owner = 0;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreValueSource i;
- i.property.coreIndex = 29;
- i.owner = 1;
- i.castValue = 4;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreValueInterceptor i;
- i.property.coreIndex = 30;
- i.owner = 2;
- i.castValue = -4;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::BeginObject i;
- i.castValue = 4;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreObjectQList i;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::AssignObjectList i;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::FetchAttached i;
- i.id = 23;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::FetchQList i;
- i.property = 32;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::FetchObject i;
- i.property = 33;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::FetchValueType i;
- i.property = 34;
- i.type = 6;
- i.bindingSkipList = 7;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::PopFetchedObject i;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::PopQList i;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::PopValueType i;
- i.property = 35;
- i.type = 8;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::Defer i;
- i.deferCount = 7;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::Defer i;
- i.deferCount = 7;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreImportedScript i;
- i.value = 2;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreVariantInteger i;
- i.value = 11;
- i.propertyIndex = 32;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreVariantDouble i;
- i.value = 33.7;
- i.propertyIndex = 19;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::Done i;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreTrString i;
- i.propertyIndex = 99;
- i.context = 3;
- i.text = 14;
- i.comment = 14;
- i.n = 2;
- data->addInstruction(i);
- }
-
- {
- QDeclarativeCompiledData::Instruction::StoreTrIdString i;
- i.propertyIndex = 78;
- i.text = 7;
- i.n = -1;
- data->addInstruction(i);
- }
-
- QStringList expect;
- expect
- << "Index\tOperation\t\tData1\tData2\tData3\tComments"
- << "-------------------------------------------------------------------------------"
- << "0\t\tINIT\t\t\t0\t3\t-1\t-1"
- << "1\t\tCREATECPP\t\t\t0\t\t\t\"Test\""
- << "2\t\tSETID\t\t\t0\t\t\t\"testId\""
- << "3\t\tSET_DEFAULT"
- << "4\t\tCREATE_COMPONENT\t3"
- << "5\t\tSTORE_META\t\t3"
- << "6\t\tSTORE_FLOAT\t\t3\t11.3"
- << "7\t\tSTORE_DOUBLE\t\t4\t14.8"
- << "8\t\tSTORE_INTEGER\t\t5\t9"
- << "9\t\tSTORE_BOOL\t\t6\ttrue"
- << "10\t\tSTORE_STRING\t\t7\t1\t\t\"Test String\""
- << "11\t\tSTORE_URL\t\t8\t0\t\tQUrl(\"http://www.nokia.com\") "
- << "12\t\tSTORE_COLOR\t\t9\t\t\t\"ff00ff00\""
- << "13\t\tSTORE_DATE\t\t10\t9"
- << "14\t\tSTORE_TIME\t\t11"
- << "15\t\tSTORE_DATETIME\t\t12"
- << "16\t\tSTORE_POINT\t\t13\t3\t7"
- << "17\t\tSTORE_POINTF\t\t13\t3\t7"
- << "18\t\tSTORE_SIZE\t\t15\t8\t11"
- << "19\t\tSTORE_SIZEF\t\t15\t8\t11"
- << "20\t\tSTORE_RECT\t\t17\t7\t9\t11\t13"
- << "21\t\tSTORE_RECTF\t\t18\t11.3\t9.8\t3\t2.1"
- << "22\t\tSTORE_VECTOR3D\t\t19\t9\t3\t92"
- << "23\t\tSTORE_VARIANT\t\t20\t2\t\t\"color(1, 1, 1, 1)\""
- << "24\t\tSTORE_OBJECT\t\t21"
- << "25\t\tSTORE_VARIANT_OBJECT\t22"
- << "26\t\tSTORE_INTERFACE\t\t23"
- << "27\t\tSTORE_SIGNAL\t\t2\t3\t\t\"console.log(1921)\""
- << "28\t\tSTORE_SCRIPT_STRING\t24\t3\t1\t4"
- << "29\t\tASSIGN_SIGNAL_OBJECT\t4\t\t\t\"mySignal\""
- << "30\t\tASSIGN_CUSTOMTYPE\t25\t6\t9"
- << "31\t\tSTORE_BINDING\t26\t3\t2"
- << "32\t\tSTORE_COMPILED_BINDING\t27\t2\t4"
- << "33\t\tSTORE_VALUE_SOURCE\t29\t4"
- << "34\t\tSTORE_VALUE_INTERCEPTOR\t30\t-4"
- << "35\t\tBEGIN\t\t\t4"
- << "36\t\tSTORE_OBJECT_QLIST"
- << "37\t\tASSIGN_OBJECT_LIST"
- << "38\t\tFETCH_ATTACHED\t\t23"
- << "39\t\tFETCH_QLIST\t\t32"
- << "40\t\tFETCH\t\t\t33"
- << "41\t\tFETCH_VALUE\t\t34\t6\t7"
- << "42\t\tPOP"
- << "43\t\tPOP_QLIST"
- << "44\t\tPOP_VALUE\t\t35\t8"
- << "45\t\tDEFER\t\t\t7"
- << "46\t\tDEFER\t\t\t7"
- << "47\t\tSTORE_IMPORTED_SCRIPT\t2"
- << "48\t\tSTORE_VARIANT_INTEGER\t\t32\t11"
- << "49\t\tSTORE_VARIANT_DOUBLE\t\t19\t33.7"
- << "50\t\tDONE"
- << "51\t\tSTORE_TR_STRING\t99\t3\t14\t14\t2"
- << "52\t\tSTORE_TRID_STRING\t78\t7\t-1"
- << "-------------------------------------------------------------------------------";
-
- messages = QStringList();
- QtMsgHandler old = qInstallMsgHandler(msgHandler);
-
- data->dumpInstructions();
- qInstallMsgHandler(old);
-
- QCOMPARE(messages.count(), expect.count());
- for (int ii = 0; ii < messages.count(); ++ii) {
- QCOMPARE(messages.at(ii), expect.at(ii));
- }
-
- data->release();
-}
-
-void tst_qdeclarativeinstruction::point()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storePoint::QPoint), sizeof(QPoint));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storePoint::QPoint), Q_ALIGNOF(QPoint));
-
- QDeclarativeInstruction i;
- i.storePoint.point.xp = 8;
- i.storePoint.point.yp = 11;
-
- const QPoint &point = (const QPoint &)(i.storePoint.point);
- QCOMPARE(point.x(), 8);
- QCOMPARE(point.y(), 11);
-}
-
-void tst_qdeclarativeinstruction::pointf()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storePointF::QPointF), sizeof(QPointF));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storePointF::QPointF), Q_ALIGNOF(QPointF));
-
- QDeclarativeInstruction i;
- i.storePointF.point.xp = 8.7;
- i.storePointF.point.yp = 11.3;
-
- const QPointF &point = (const QPointF &)(i.storePointF.point);
- QCOMPARE(point.x(), 8.7);
- QCOMPARE(point.y(), 11.3);
-}
-
-void tst_qdeclarativeinstruction::size()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeSize::QSize), sizeof(QSize));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeSize::QSize), Q_ALIGNOF(QSize));
-
- QDeclarativeInstruction i;
- i.storeSize.size.wd = 8;
- i.storeSize.size.ht = 11;
-
- const QSize &size = (const QSize &)(i.storeSize.size);
- QCOMPARE(size.width(), 8);
- QCOMPARE(size.height(), 11);
-}
-
-void tst_qdeclarativeinstruction::sizef()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeSizeF::QSizeF), sizeof(QSizeF));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeSizeF::QSizeF), Q_ALIGNOF(QSizeF));
-
- QDeclarativeInstruction i;
- i.storeSizeF.size.wd = 8;
- i.storeSizeF.size.ht = 11;
-
- const QSizeF &size = (const QSizeF &)(i.storeSizeF.size);
- QCOMPARE(size.width(), (qreal)8);
- QCOMPARE(size.height(), (qreal)11);
-}
-
-void tst_qdeclarativeinstruction::rect()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeRect::QRect), sizeof(QRect));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeRect::QRect), Q_ALIGNOF(QRect));
-
- QDeclarativeInstruction i;
- i.storeRect.rect.x1 = 8;
- i.storeRect.rect.y1 = 11;
- i.storeRect.rect.x2 = 13;
- i.storeRect.rect.y2 = 19;
-
- const QRect &rect = (const QRect &)(i.storeRect.rect);
- QCOMPARE(rect.left(), 8);
- QCOMPARE(rect.top(), 11);
- QCOMPARE(rect.right(), 13);
- QCOMPARE(rect.bottom(), 19);
-}
-
-void tst_qdeclarativeinstruction::rectf()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeRectF::QRectF), sizeof(QRectF));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeRectF::QRectF), Q_ALIGNOF(QRectF));
-
- QDeclarativeInstruction i;
- i.storeRectF.rect.xp = 8;
- i.storeRectF.rect.yp = 11;
- i.storeRectF.rect.w = 13;
- i.storeRectF.rect.h = 19;
-
- const QRectF &rect = (const QRectF &)(i.storeRectF.rect);
- QCOMPARE(rect.left(), (qreal)8);
- QCOMPARE(rect.top(), (qreal)11);
- QCOMPARE(rect.width(), (qreal)13);
- QCOMPARE(rect.height(), (qreal)19);
-}
-
-void tst_qdeclarativeinstruction::vector3d()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeVector3D::QVector3D), sizeof(QVector3D));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeVector3D::QVector3D), Q_ALIGNOF(QVector3D));
-
- QDeclarativeInstruction i;
- i.storeVector3D.vector.xp = 8.2;
- i.storeVector3D.vector.yp = 99.3;
- i.storeVector3D.vector.zp = 12.0;
-
- const QVector3D &vector = (const QVector3D &)(i.storeVector3D.vector);
- QCOMPARE(vector.x(), (qreal)(float)8.2);
- QCOMPARE(vector.y(), (qreal)(float)99.3);
- QCOMPARE(vector.z(), (qreal)(float)12.0);
-}
-
-void tst_qdeclarativeinstruction::vector4d()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeVector4D::QVector4D), sizeof(QVector4D));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeVector4D::QVector4D), Q_ALIGNOF(QVector4D));
-
- QDeclarativeInstruction i;
- i.storeVector4D.vector.xp = 8.2;
- i.storeVector4D.vector.yp = 99.3;
- i.storeVector4D.vector.zp = 12.0;
- i.storeVector4D.vector.wp = 121.1;
-
- const QVector4D &vector = (const QVector4D &)(i.storeVector4D.vector);
- QCOMPARE(vector.x(), (qreal)(float)8.2);
- QCOMPARE(vector.y(), (qreal)(float)99.3);
- QCOMPARE(vector.z(), (qreal)(float)12.0);
- QCOMPARE(vector.w(), (qreal)(float)121.1);
-}
-
-void tst_qdeclarativeinstruction::time()
-{
- QCOMPARE(sizeof(QDeclarativeInstruction::instr_storeTime::QTime), sizeof(QTime));
- QCOMPARE(Q_ALIGNOF(QDeclarativeInstruction::instr_storeTime::QTime), Q_ALIGNOF(QTime));
-}
-
-QTEST_MAIN(tst_qdeclarativeinstruction)
-
-#include "tst_qdeclarativeinstruction.moc"
diff --git a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro
deleted file mode 100644
index f79d1c99c9..0000000000
--- a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativelanguage
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativelanguage.cpp \
- testtypes.cpp
-HEADERS += testtypes.h
-
-INCLUDEPATH += ../../shared/
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += ../../shared/testhttpserver.cpp
-
-importFiles.files = data
-importFiles.path = .
-DEPLOYMENT += importFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private network testlib
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
deleted file mode 100644
index 4a37139056..0000000000
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h
+++ /dev/null
@@ -1,823 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QtCore/qobject.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qdatetime.h>
-#include <QtGui/qmatrix.h>
-#include <QtGui/qcolor.h>
-#include <QtGui/qvector3d.h>
-#include <QtGui/qvector4d.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeparserstatus.h>
-#include <QtDeclarative/qdeclarativepropertyvaluesource.h>
-#include <QtDeclarative/qdeclarativescriptstring.h>
-#include <QtDeclarative/qdeclarativeproperty.h>
-
-#include <private/qdeclarativecustomparser_p.h>
-
-QVariant myCustomVariantTypeConverter(const QString &data);
-
-class MyInterface
-{
-public:
- MyInterface() : id(913) {}
- int id;
-};
-
-QT_BEGIN_NAMESPACE
-Q_DECLARE_INTERFACE(MyInterface, "com.trolltech.Qt.Test.MyInterface");
-QT_END_NAMESPACE
-QML_DECLARE_INTERFACE(MyInterface);
-
-struct MyCustomVariantType
-{
- MyCustomVariantType() : a(0) {}
- int a;
-};
-Q_DECLARE_METATYPE(MyCustomVariantType);
-
-class MyAttachedObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
- Q_PROPERTY(int value2 READ value2 WRITE setValue2)
-public:
- MyAttachedObject(QObject *parent) : QObject(parent), m_value(0), m_value2(0) {}
-
- int value() const { return m_value; }
- void setValue(int v) { if (m_value != v) { m_value = v; emit valueChanged(); } }
-
- int value2() const { return m_value2; }
- void setValue2(int v) { m_value2 = v; }
-
-signals:
- void valueChanged();
-
-private:
- int m_value;
- int m_value2;
-};
-
-class MyQmlObject : public QObject, public MyInterface
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue FINAL)
- Q_PROPERTY(QString readOnlyString READ readOnlyString)
- Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
- Q_PROPERTY(QRect rect READ rect WRITE setRect)
- Q_PROPERTY(QMatrix matrix READ matrix WRITE setMatrix) //assumed to be unsupported by QML
- Q_PROPERTY(MyInterface *interfaceProperty READ interface WRITE setInterface)
- Q_PROPERTY(int onLiteralSignal READ onLiteralSignal WRITE setOnLiteralSignal)
- 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:
- MyQmlObject() : m_value(-1), m_interface(0), m_qmlobject(0) { qRegisterMetaType<MyCustomVariantType>("MyCustomVariantType"); }
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; }
-
- QString readOnlyString() const { return QLatin1String(""); }
-
- bool enabled() const { return false; }
- void setEnabled(bool) {}
-
- QRect rect() const { return QRect(); }
- void setRect(const QRect&) {}
-
- QMatrix matrix() const { return QMatrix(); }
- void setMatrix(const QMatrix&) {}
-
- MyInterface *interface() const { return m_interface; }
- void setInterface(MyInterface *iface) { m_interface = iface; }
-
- static MyAttachedObject *qmlAttachedProperties(QObject *other) {
- return new MyAttachedObject(other);
- }
- Q_CLASSINFO("DefaultMethod", "basicSlot()")
-
- int onLiteralSignal() const { return m_value; }
- void setOnLiteralSignal(int v) { m_value = v; }
-
- MyQmlObject *qmlobject() const { return m_qmlobject; }
- void setQmlobject(MyQmlObject *o) { m_qmlobject = o; }
-
- MyCustomVariantType customType() const { return m_custom; }
- void setCustomType(const MyCustomVariantType &v) { m_custom = v; }
-
- 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); }
-
-signals:
- void basicSignal();
- void basicParameterizedSignal(int parameter);
- void oddlyNamedNotifySignal();
-
-private:
- friend class tst_qdeclarativelanguage;
- int m_value;
- MyInterface *m_interface;
- MyQmlObject *m_qmlobject;
- MyCustomVariantType m_custom;
- int m_propertyWithNotify;
-};
-QML_DECLARE_TYPE(MyQmlObject)
-QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
-
-class MyGroupedObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript)
- Q_PROPERTY(int value READ value WRITE setValue)
-public:
- QDeclarativeScriptString script() const { return m_script; }
- void setScript(const QDeclarativeScriptString &s) { m_script = s; }
-
- int value() const { return m_value; }
- void setValue(int v) { m_value = v; }
-
-private:
- int m_value;
- QDeclarativeScriptString m_script;
-};
-
-
-class MyTypeObject : public QObject
-{
- Q_OBJECT
- Q_ENUMS(MyEnum)
- Q_FLAGS(MyFlags)
-
- Q_PROPERTY(QString id READ id WRITE setId)
- Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
- Q_PROPERTY(QDeclarativeComponent *componentProperty READ componentProperty WRITE setComponentProperty)
- Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty)
- Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty)
- Q_PROPERTY(MyEnum readOnlyEnumProperty READ readOnlyEnumProperty)
- Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
- Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty)
- Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty)
- Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty)
- Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty)
- Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty)
- Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty)
- Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty)
- Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty)
- Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty)
- Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty)
- Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty)
- Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty)
- Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty)
- Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged)
- Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2)
- Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty)
- Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty)
- Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty)
- Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty)
- Q_PROPERTY(QVector4D vector4Property READ vector4Property WRITE setVector4Property)
- Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty)
-
- Q_PROPERTY(QDeclarativeScriptString scriptProperty READ scriptProperty WRITE setScriptProperty)
- Q_PROPERTY(MyGroupedObject *grouped READ grouped CONSTANT)
- Q_PROPERTY(MyGroupedObject *nullGrouped READ nullGrouped CONSTANT)
-
-public:
- MyTypeObject()
- : objectPropertyValue(0), componentPropertyValue(0) {}
-
- QString idValue;
- QString id() const {
- return idValue;
- }
- void setId(const QString &v) {
- idValue = v;
- }
-
- QObject *objectPropertyValue;
- QObject *objectProperty() const {
- return objectPropertyValue;
- }
- void setObjectProperty(QObject *v) {
- objectPropertyValue = v;
- }
-
- QDeclarativeComponent *componentPropertyValue;
- QDeclarativeComponent *componentProperty() const {
- return componentPropertyValue;
- }
- void setComponentProperty(QDeclarativeComponent *v) {
- componentPropertyValue = v;
- }
-
- enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
- Q_DECLARE_FLAGS(MyFlags, MyFlag)
- MyFlags flagPropertyValue;
- MyFlags flagProperty() const {
- return flagPropertyValue;
- }
- void setFlagProperty(MyFlags v) {
- flagPropertyValue = v;
- }
-
- enum MyEnum { EnumVal1, EnumVal2 };
- MyEnum enumPropertyValue;
- MyEnum enumProperty() const {
- return enumPropertyValue;
- }
- void setEnumProperty(MyEnum v) {
- enumPropertyValue = v;
- }
-
- MyEnum readOnlyEnumProperty() const {
- return EnumVal1;
- }
-
- QString stringPropertyValue;
- QString stringProperty() const {
- return stringPropertyValue;
- }
- void setStringProperty(const QString &v) {
- stringPropertyValue = v;
- }
-
- uint uintPropertyValue;
- uint uintProperty() const {
- return uintPropertyValue;
- }
- void setUintProperty(const uint &v) {
- uintPropertyValue = v;
- }
-
- int intPropertyValue;
- int intProperty() const {
- return intPropertyValue;
- }
- void setIntProperty(const int &v) {
- intPropertyValue = v;
- }
-
- qreal realPropertyValue;
- qreal realProperty() const {
- return realPropertyValue;
- }
- void setRealProperty(const qreal &v) {
- realPropertyValue = v;
- }
-
- double doublePropertyValue;
- double doubleProperty() const {
- return doublePropertyValue;
- }
- void setDoubleProperty(const double &v) {
- doublePropertyValue = v;
- }
-
- float floatPropertyValue;
- float floatProperty() const {
- return floatPropertyValue;
- }
- void setFloatProperty(const float &v) {
- floatPropertyValue = v;
- }
-
- QColor colorPropertyValue;
- QColor colorProperty() const {
- return colorPropertyValue;
- }
- void setColorProperty(const QColor &v) {
- colorPropertyValue = v;
- }
-
- QDate datePropertyValue;
- QDate dateProperty() const {
- return datePropertyValue;
- }
- void setDateProperty(const QDate &v) {
- datePropertyValue = v;
- }
-
- QTime timePropertyValue;
- QTime timeProperty() const {
- return timePropertyValue;
- }
- void setTimeProperty(const QTime &v) {
- timePropertyValue = v;
- }
-
- QDateTime dateTimePropertyValue;
- QDateTime dateTimeProperty() const {
- return dateTimePropertyValue;
- }
- void setDateTimeProperty(const QDateTime &v) {
- dateTimePropertyValue = v;
- }
-
- QPoint pointPropertyValue;
- QPoint pointProperty() const {
- return pointPropertyValue;
- }
- void setPointProperty(const QPoint &v) {
- pointPropertyValue = v;
- }
-
- QPointF pointFPropertyValue;
- QPointF pointFProperty() const {
- return pointFPropertyValue;
- }
- void setPointFProperty(const QPointF &v) {
- pointFPropertyValue = v;
- }
-
- QSize sizePropertyValue;
- QSize sizeProperty() const {
- return sizePropertyValue;
- }
- void setSizeProperty(const QSize &v) {
- sizePropertyValue = v;
- }
-
- QSizeF sizeFPropertyValue;
- QSizeF sizeFProperty() const {
- return sizeFPropertyValue;
- }
- void setSizeFProperty(const QSizeF &v) {
- sizeFPropertyValue = v;
- }
-
- QRect rectPropertyValue;
- QRect rectProperty() const {
- return rectPropertyValue;
- }
- void setRectProperty(const QRect &v) {
- rectPropertyValue = v;
- emit rectPropertyChanged();
- }
-
- QRect rectPropertyValue2;
- QRect rectProperty2() const {
- return rectPropertyValue2;
- }
- void setRectProperty2(const QRect &v) {
- rectPropertyValue2 = v;
- }
-
- QRectF rectFPropertyValue;
- QRectF rectFProperty() const {
- return rectFPropertyValue;
- }
- void setRectFProperty(const QRectF &v) {
- rectFPropertyValue = v;
- }
-
- bool boolPropertyValue;
- bool boolProperty() const {
- return boolPropertyValue;
- }
- void setBoolProperty(const bool &v) {
- boolPropertyValue = v;
- }
-
- QVariant variantPropertyValue;
- QVariant variantProperty() const {
- return variantPropertyValue;
- }
- void setVariantProperty(const QVariant &v) {
- variantPropertyValue = v;
- }
-
- QVector3D vectorPropertyValue;
- QVector3D vectorProperty() const {
- return vectorPropertyValue;
- }
- void setVectorProperty(const QVector3D &v) {
- vectorPropertyValue = v;
- }
-
- QVector4D vector4PropertyValue;
- QVector4D vector4Property() const {
- return vector4PropertyValue;
- }
- void setVector4Property(const QVector4D &v) {
- vector4PropertyValue = v;
- }
-
- QUrl urlPropertyValue;
- QUrl urlProperty() const {
- return urlPropertyValue;
- }
- void setUrlProperty(const QUrl &v) {
- urlPropertyValue = v;
- }
-
- QDeclarativeScriptString scriptPropertyValue;
- QDeclarativeScriptString scriptProperty() const {
- return scriptPropertyValue;
- }
- void setScriptProperty(const QDeclarativeScriptString &v) {
- scriptPropertyValue = v;
- }
-
- MyGroupedObject groupedValue;
- MyGroupedObject *grouped() { return &groupedValue; }
-
- MyGroupedObject *nullGrouped() { return 0; }
-
- void doAction() { emit action(); }
-signals:
- void action();
- void rectPropertyChanged();
-};
-Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
-
-
-class MyContainer : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<QObject> children READ children)
- Q_PROPERTY(QDeclarativeListProperty<MyContainer> containerChildren READ containerChildren)
- Q_PROPERTY(QDeclarativeListProperty<MyInterface> qlistInterfaces READ qlistInterfaces)
- Q_CLASSINFO("DefaultProperty", "children")
-public:
- MyContainer() {}
-
- QDeclarativeListProperty<QObject> children() { return QDeclarativeListProperty<QObject>(this, m_children); }
- QDeclarativeListProperty<MyContainer> containerChildren() { return QDeclarativeListProperty<MyContainer>(this, m_containerChildren); }
- QList<QObject *> *getChildren() { return &m_children; }
- QDeclarativeListProperty<MyInterface> qlistInterfaces() { return QDeclarativeListProperty<MyInterface>(this, m_interfaces); }
- QList<MyInterface *> *getQListInterfaces() { return &m_interfaces; }
-
- QList<MyContainer*> m_containerChildren;
- QList<QObject*> m_children;
- QList<MyInterface *> m_interfaces;
-};
-
-
-class MyPropertyValueSource : public QObject, public QDeclarativePropertyValueSource
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativePropertyValueSource)
-public:
- MyPropertyValueSource()
- : QDeclarativePropertyValueSource() {}
-
- QDeclarativeProperty prop;
- virtual void setTarget(const QDeclarativeProperty &p)
- {
- prop = p;
- }
-};
-
-class UnavailableType : public QObject
-{
- Q_OBJECT
-public:
- UnavailableType() {}
-};
-
-class MyDotPropertyObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(MyQmlObject *obj READ obj)
- Q_PROPERTY(MyQmlObject *readWriteObj READ readWriteObj WRITE setReadWriteObj)
-public:
- MyDotPropertyObject() : m_rwobj(0), m_ownRWObj(false) {}
- ~MyDotPropertyObject()
- {
- if (m_ownRWObj)
- delete m_rwobj;
- }
-
- MyQmlObject *obj() { return 0; }
-
- MyQmlObject *readWriteObj()
- {
- if (!m_rwobj) {
- m_rwobj = new MyQmlObject;
- m_ownRWObj = true;
- }
- return m_rwobj;
- }
-
- void setReadWriteObj(MyQmlObject *obj)
- {
- if (m_ownRWObj) {
- delete m_rwobj;
- m_ownRWObj = false;
- }
-
- m_rwobj = obj;
- }
-
-private:
- MyQmlObject *m_rwobj;
- bool m_ownRWObj;
-};
-
-
-namespace MyNamespace {
- class MyNamespacedType : public QObject
- {
- Q_OBJECT
- };
-
- class MySecondNamespacedType : public QObject
- {
- Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<MyNamespace::MyNamespacedType> list READ list)
- public:
- QDeclarativeListProperty<MyNamespacedType> list() { return QDeclarativeListProperty<MyNamespacedType>(this, m_list); }
-
- private:
- QList<MyNamespacedType *> m_list;
- };
-}
-
-class MyCustomParserType : public QObject
-{
- Q_OBJECT
-};
-
-class MyCustomParserTypeParser : public QDeclarativeCustomParser
-{
-public:
- QByteArray compile(const QList<QDeclarativeCustomParserProperty> &) { return QByteArray(); }
- void setCustomData(QObject *, const QByteArray &) {}
-};
-
-class MyParserStatus : public QObject, public QDeclarativeParserStatus
-{
- Q_INTERFACES(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;
-};
-
-class MyRevisionedBaseClassRegistered : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(qreal propA READ propA WRITE setPropA NOTIFY propAChanged)
- Q_PROPERTY(qreal propB READ propB WRITE setPropB NOTIFY propBChanged REVISION 1)
-
-public:
- MyRevisionedBaseClassRegistered() : m_pa(1), m_pb(2) {}
-
- qreal propA() const { return m_pa; }
- void setPropA(qreal p) {
- if (p != m_pa) {
- m_pa = p;
- emit propAChanged();
- }
- }
- qreal propB() const { return m_pb; }
- void setPropB(qreal p) {
- if (p != m_pb) {
- m_pb = p;
- emit propBChanged();
- }
- }
-
- Q_INVOKABLE void methodA() { }
- Q_INVOKABLE Q_REVISION(1) void methodB() { }
-
-signals:
- void propAChanged();
- void propBChanged();
-
- void signalA();
- Q_REVISION(1) void signalB();
-
-protected:
- qreal m_pa;
- qreal m_pb;
-};
-
-class MyRevisionedIllegalOverload : public MyRevisionedBaseClassRegistered
-{
- Q_OBJECT
- Q_PROPERTY(qreal propA READ propA WRITE setPropA REVISION 1);
-};
-
-class MyRevisionedLegalOverload : public MyRevisionedBaseClassRegistered
-{
- Q_OBJECT
- Q_PROPERTY(qreal propB READ propB WRITE setPropB REVISION 1);
-};
-
-class MyRevisionedBaseClassUnregistered : public MyRevisionedBaseClassRegistered
-{
- Q_OBJECT
- Q_PROPERTY(qreal propC READ propC WRITE setPropC NOTIFY propCChanged)
- Q_PROPERTY(qreal propD READ propD WRITE setPropD NOTIFY propDChanged REVISION 1)
-
-public:
- MyRevisionedBaseClassUnregistered() : m_pc(1), m_pd(2) {}
-
- qreal propC() const { return m_pc; }
- void setPropC(qreal p) {
- if (p != m_pc) {
- m_pc = p;
- emit propCChanged();
- }
- }
- qreal propD() const { return m_pd; }
- void setPropD(qreal p) {
- if (p != m_pd) {
- m_pd = p;
- emit propDChanged();
- }
- }
-
- Q_INVOKABLE void methodC() { }
- Q_INVOKABLE Q_REVISION(1) void methodD() { }
-
-signals:
- void propCChanged();
- void propDChanged();
-
- void signalC();
- Q_REVISION(1) void signalD();
-
-protected:
- qreal m_pc;
- qreal m_pd;
-};
-
-class MyRevisionedClass : public MyRevisionedBaseClassUnregistered
-{
- Q_OBJECT
- Q_PROPERTY(qreal prop1 READ prop1 WRITE setProp1 NOTIFY prop1Changed)
- Q_PROPERTY(qreal prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed REVISION 1)
-
-public:
- MyRevisionedClass() : m_p1(1), m_p2(2) {}
-
- qreal prop1() const { return m_p1; }
- void setProp1(qreal p) {
- if (p != m_p1) {
- m_p1 = p;
- emit prop1Changed();
- }
- }
- qreal prop2() const { return m_p2; }
- void setProp2(qreal p) {
- if (p != m_p2) {
- m_p2 = p;
- emit prop2Changed();
- }
- }
-
- Q_INVOKABLE void method1() { }
- Q_INVOKABLE Q_REVISION(1) void method2() { }
-
-signals:
- void prop1Changed();
- void prop2Changed();
-
- void signal1();
- Q_REVISION(1) void signal2();
-
-protected:
- qreal m_p1;
- qreal m_p2;
-};
-
-class MyRevisionedSubclass : public MyRevisionedClass
-{
- Q_OBJECT
- Q_PROPERTY(qreal prop3 READ prop3 WRITE setProp3 NOTIFY prop3Changed)
- Q_PROPERTY(qreal prop4 READ prop4 WRITE setProp4 NOTIFY prop4Changed REVISION 1)
-
-public:
- MyRevisionedSubclass() : m_p3(3), m_p4(4) {}
-
- qreal prop3() const { return m_p3; }
- void setProp3(qreal p) {
- if (p != m_p3) {
- m_p3 = p;
- emit prop3Changed();
- }
- }
- qreal prop4() const { return m_p4; }
- void setProp4(qreal p) {
- if (p != m_p4) {
- m_p4 = p;
- emit prop4Changed();
- }
- }
-
- Q_INVOKABLE void method3() { }
- Q_INVOKABLE Q_REVISION(1) void method4() { }
-
-signals:
- void prop3Changed();
- void prop4Changed();
-
- void signal3();
- Q_REVISION(1) void signal4();
-
-protected:
- qreal m_p3;
- qreal m_p4;
-};
-
-class MySubclass : public MyRevisionedClass
-{
- Q_OBJECT
- Q_PROPERTY(qreal prop5 READ prop5 WRITE setProp5 NOTIFY prop5Changed)
-
-public:
- MySubclass() : m_p5(5) {}
-
- qreal prop5() const { return m_p5; }
- void setProp5(qreal p) {
- if (p != m_p5) {
- m_p5 = p;
- emit prop5Changed();
- }
- }
-
- Q_INVOKABLE void method5() { }
-
-signals:
- void prop5Changed();
-
-protected:
- qreal m_p5;
-};
-
-class MyVersion2Class : public QObject
-{
- Q_OBJECT
-};
-
-QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered)
-QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered)
-QML_DECLARE_TYPE(MyRevisionedClass)
-QML_DECLARE_TYPE(MyRevisionedSubclass)
-QML_DECLARE_TYPE(MySubclass)
-
-
-
-void registerTypes();
-
-#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
deleted file mode 100644
index 480a898ff0..0000000000
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ /dev/null
@@ -1,2289 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qdir.h>
-
-#include <private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativemetatype_p.h>
-#include <private/qdeclarativeglobal_p.h>
-
-#include "testtypes.h"
-#include "testhttpserver.h"
-
-DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES)
-
-/*
- Returns the path to some testdata file or directory.
-*/
-QString testdata(QString const& name = QString())
-{
- static const QString dataDirectory = QDir::currentPath() + QLatin1String("/data");
- QString result = dataDirectory;
- if (!name.isEmpty()) {
- result += QLatin1Char('/');
- result += name;
- }
- return result;
-}
-
-/*
-This test case covers QML language issues. This covers everything that does not
-involve evaluating ECMAScript expressions and bindings.
-
-Evaluation of expressions and bindings is covered in qmlecmascript
-*/
-class tst_qdeclarativelanguage : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativelanguage() {
- QDeclarativeMetaType::registerCustomStringConverter(qMetaTypeId<MyCustomVariantType>(), myCustomVariantTypeConverter);
- engine.addImportPath(testdata("lib"));
- }
-
-private slots:
- void initTestCase();
- void cleanupTestCase();
-
- void errors_data();
- void errors();
-
- void insertedSemicolon_data();
- void insertedSemicolon();
-
- void simpleObject();
- void simpleContainer();
- void interfaceProperty();
- void interfaceQList();
- void assignObjectToSignal();
- void assignObjectToVariant();
- void assignLiteralSignalProperty();
- void assignQmlComponent();
- void assignBasicTypes();
- void assignTypeExtremes();
- void assignCompositeToType();
- void assignLiteralToVariant();
- void assignLiteralToVar();
- void customParserTypes();
- void rootAsQmlComponent();
- void inlineQmlComponents();
- void idProperty();
- void autoNotifyConnection();
- void assignSignal();
- void dynamicProperties();
- void dynamicPropertiesNested();
- void listProperties();
- void dynamicObjectProperties();
- void dynamicSignalsAndSlots();
- void simpleBindings();
- void autoComponentCreation();
- void propertyValueSource();
- void attachedProperties();
- void dynamicObjects();
- void customVariantTypes();
- void valueTypes();
- void cppnamespace();
- void aliasProperties();
- void aliasPropertiesAndSignals();
- void aliasPropertyChangeSignals();
- void componentCompositeType();
- void i18n();
- void i18n_data();
- void onCompleted();
- void onDestruction();
- void scriptString();
- void defaultPropertyListOrder();
- void declaredPropertyValues();
- void dontDoubleCallClassBegin();
- void reservedWords_data();
- void reservedWords();
- void inlineAssignmentsOverrideBindings();
- void nestedComponentRoots();
- void registrationOrder();
- void readonly();
-
- void basicRemote_data();
- void basicRemote();
- void importsBuiltin_data();
- void importsBuiltin();
- void importsLocal_data();
- void importsLocal();
- void importsRemote_data();
- void importsRemote();
- void importsInstalled_data();
- void importsInstalled();
- void importsOrder_data();
- void importsOrder();
- void importIncorrectCase();
- void importJs_data();
- void importJs();
-
- void qmlAttachedPropertiesObjectMethod();
- void customOnProperty();
- void variantNotify();
-
- void revisions();
- void revisionOverloads();
-
- void propertyInit();
- void remoteLoadCrash();
-
- // regression tests for crashes
- void crash1();
- void crash2();
-
-private:
- QDeclarativeEngine engine;
- void testType(const QString& qml, const QString& type, const QString& error);
-};
-
-#define DETERMINE_ERRORS(errorfile,expected,actual)\
- QList<QByteArray> expected; \
- QList<QByteArray> actual; \
- do { \
- QFile file(testdata(QLatin1String(errorfile))); \
- QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \
- QByteArray data = file.readAll(); \
- file.close(); \
- expected = data.split('\n'); \
- expected.removeAll(QByteArray("")); \
- QList<QDeclarativeError> errors = component.errors(); \
- for (int ii = 0; ii < errors.count(); ++ii) { \
- const QDeclarativeError &error = errors.at(ii); \
- QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
- QByteArray::number(error.column()) + ":" + \
- error.description().toUtf8(); \
- actual << errorStr; \
- } \
- } while (false);
-
-#define VERIFY_ERRORS(errorfile) \
- if (!errorfile) { \
- if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
- qWarning() << "Unexpected Errors:" << component.errors(); \
- QVERIFY(!component.isError()); \
- QVERIFY(component.errors().isEmpty()); \
- } else { \
- DETERMINE_ERRORS(errorfile,actual,expected);\
- if (qgetenv("DEBUG") != "" && expected != actual) \
- qWarning() << "Expected:" << expected << "Actual:" << actual; \
- if (qgetenv("QDECLARATIVELANGUAGE_UPDATEERRORS") != "" && expected != actual) {\
- QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \
- QVERIFY(file.open(QIODevice::WriteOnly)); \
- for (int ii = 0; ii < actual.count(); ++ii) { \
- file.write(actual.at(ii)); file.write("\n"); \
- } \
- file.close(); \
- } else { \
- QCOMPARE(expected, actual); \
- } \
- }
-
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(testdata(filename));
-}
-
-inline QUrl TEST_FILE(const char *filename)
-{
- return TEST_FILE(QLatin1String(filename));
-}
-
-void tst_qdeclarativelanguage::cleanupTestCase()
-{
- QVERIFY(QFile::remove(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile()));
-}
-
-void tst_qdeclarativelanguage::insertedSemicolon_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("errorFile");
- QTest::addColumn<bool>("create");
-
- QTest::newRow("insertedSemicolon.1") << "insertedSemicolon.1.qml" << "insertedSemicolon.1.errors.txt" << false;
-}
-
-void tst_qdeclarativelanguage::insertedSemicolon()
-{
- QFETCH(QString, file);
- QFETCH(QString, errorFile);
- QFETCH(bool, create);
-
- QDeclarativeComponent component(&engine, TEST_FILE(file));
-
- if(create) {
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
-
- VERIFY_ERRORS(errorFile.toLatin1().constData());
-}
-
-void tst_qdeclarativelanguage::errors_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("errorFile");
- QTest::addColumn<bool>("create");
-
- QTest::newRow("nonexistantProperty.1") << "nonexistantProperty.1.qml" << "nonexistantProperty.1.errors.txt" << false;
- QTest::newRow("nonexistantProperty.2") << "nonexistantProperty.2.qml" << "nonexistantProperty.2.errors.txt" << false;
- QTest::newRow("nonexistantProperty.3") << "nonexistantProperty.3.qml" << "nonexistantProperty.3.errors.txt" << false;
- QTest::newRow("nonexistantProperty.4") << "nonexistantProperty.4.qml" << "nonexistantProperty.4.errors.txt" << false;
- QTest::newRow("nonexistantProperty.5") << "nonexistantProperty.5.qml" << "nonexistantProperty.5.errors.txt" << false;
- QTest::newRow("nonexistantProperty.6") << "nonexistantProperty.6.qml" << "nonexistantProperty.6.errors.txt" << false;
-
- QTest::newRow("wrongType (string for int)") << "wrongType.1.qml" << "wrongType.1.errors.txt" << false;
- QTest::newRow("wrongType (int for bool)") << "wrongType.2.qml" << "wrongType.2.errors.txt" << false;
- QTest::newRow("wrongType (bad rect)") << "wrongType.3.qml" << "wrongType.3.errors.txt" << false;
-
- QTest::newRow("wrongType (invalid enum)") << "wrongType.4.qml" << "wrongType.4.errors.txt" << false;
- QTest::newRow("wrongType (int for uint)") << "wrongType.5.qml" << "wrongType.5.errors.txt" << false;
- QTest::newRow("wrongType (string for real)") << "wrongType.6.qml" << "wrongType.6.errors.txt" << false;
- QTest::newRow("wrongType (int for color)") << "wrongType.7.qml" << "wrongType.7.errors.txt" << false;
- QTest::newRow("wrongType (int for date)") << "wrongType.8.qml" << "wrongType.8.errors.txt" << false;
- QTest::newRow("wrongType (int for time)") << "wrongType.9.qml" << "wrongType.9.errors.txt" << false;
- QTest::newRow("wrongType (int for datetime)") << "wrongType.10.qml" << "wrongType.10.errors.txt" << false;
- QTest::newRow("wrongType (string for point)") << "wrongType.11.qml" << "wrongType.11.errors.txt" << false;
- QTest::newRow("wrongType (color for size)") << "wrongType.12.qml" << "wrongType.12.errors.txt" << false;
- QTest::newRow("wrongType (number string for int)") << "wrongType.13.qml" << "wrongType.13.errors.txt" << false;
- QTest::newRow("wrongType (int for string)") << "wrongType.14.qml" << "wrongType.14.errors.txt" << false;
- QTest::newRow("wrongType (int for url)") << "wrongType.15.qml" << "wrongType.15.errors.txt" << false;
- QTest::newRow("wrongType (invalid object)") << "wrongType.16.qml" << "wrongType.16.errors.txt" << false;
- QTest::newRow("wrongType (int for enum)") << "wrongType.17.qml" << "wrongType.17.errors.txt" << false;
-
- QTest::newRow("readOnly.1") << "readOnly.1.qml" << "readOnly.1.errors.txt" << false;
- QTest::newRow("readOnly.2") << "readOnly.2.qml" << "readOnly.2.errors.txt" << false;
- QTest::newRow("readOnly.3") << "readOnly.3.qml" << "readOnly.3.errors.txt" << false;
- QTest::newRow("readOnly.4") << "readOnly.4.qml" << "readOnly.4.errors.txt" << false;
- QTest::newRow("readOnly.5") << "readOnly.5.qml" << "readOnly.5.errors.txt" << false;
-
- QTest::newRow("listAssignment.1") << "listAssignment.1.qml" << "listAssignment.1.errors.txt" << false;
- QTest::newRow("listAssignment.2") << "listAssignment.2.qml" << "listAssignment.2.errors.txt" << false;
- QTest::newRow("listAssignment.3") << "listAssignment.3.qml" << "listAssignment.3.errors.txt" << false;
-
- QTest::newRow("invalidID.1") << "invalidID.qml" << "invalidID.errors.txt" << false;
- QTest::newRow("invalidID.2") << "invalidID.2.qml" << "invalidID.2.errors.txt" << false;
- QTest::newRow("invalidID.3") << "invalidID.3.qml" << "invalidID.3.errors.txt" << false;
- QTest::newRow("invalidID.4") << "invalidID.4.qml" << "invalidID.4.errors.txt" << false;
- QTest::newRow("invalidID.5") << "invalidID.5.qml" << "invalidID.5.errors.txt" << false;
- QTest::newRow("invalidID.6") << "invalidID.6.qml" << "invalidID.6.errors.txt" << false;
- QTest::newRow("invalidID.7") << "invalidID.7.qml" << "invalidID.7.errors.txt" << false;
- QTest::newRow("invalidID.8") << "invalidID.8.qml" << "invalidID.8.errors.txt" << false;
- QTest::newRow("invalidID.9") << "invalidID.9.qml" << "invalidID.9.errors.txt" << false;
-
- QTest::newRow("scriptString.1") << "scriptString.1.qml" << "scriptString.1.errors.txt" << false;
- QTest::newRow("scriptString.2") << "scriptString.2.qml" << "scriptString.2.errors.txt" << false;
-
- QTest::newRow("unsupportedProperty") << "unsupportedProperty.qml" << "unsupportedProperty.errors.txt" << false;
- QTest::newRow("nullDotProperty") << "nullDotProperty.qml" << "nullDotProperty.errors.txt" << true;
- QTest::newRow("fakeDotProperty") << "fakeDotProperty.qml" << "fakeDotProperty.errors.txt" << false;
- QTest::newRow("duplicateIDs") << "duplicateIDs.qml" << "duplicateIDs.errors.txt" << false;
- QTest::newRow("unregisteredObject") << "unregisteredObject.qml" << "unregisteredObject.errors.txt" << false;
- QTest::newRow("empty") << "empty.qml" << "empty.errors.txt" << false;
- QTest::newRow("missingObject") << "missingObject.qml" << "missingObject.errors.txt" << false;
- QTest::newRow("failingComponent") << "failingComponentTest.qml" << "failingComponent.errors.txt" << false;
- QTest::newRow("missingSignal") << "missingSignal.qml" << "missingSignal.errors.txt" << false;
- QTest::newRow("finalOverride") << "finalOverride.qml" << "finalOverride.errors.txt" << false;
- QTest::newRow("customParserIdNotAllowed") << "customParserIdNotAllowed.qml" << "customParserIdNotAllowed.errors.txt" << false;
-
- QTest::newRow("invalidGroupedProperty.1") << "invalidGroupedProperty.1.qml" << "invalidGroupedProperty.1.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.2") << "invalidGroupedProperty.2.qml" << "invalidGroupedProperty.2.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.3") << "invalidGroupedProperty.3.qml" << "invalidGroupedProperty.3.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.4") << "invalidGroupedProperty.4.qml" << "invalidGroupedProperty.4.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.5") << "invalidGroupedProperty.5.qml" << "invalidGroupedProperty.5.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.6") << "invalidGroupedProperty.6.qml" << "invalidGroupedProperty.6.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.7") << "invalidGroupedProperty.7.qml" << "invalidGroupedProperty.7.errors.txt" << true;
- QTest::newRow("invalidGroupedProperty.8") << "invalidGroupedProperty.8.qml" << "invalidGroupedProperty.8.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.9") << "invalidGroupedProperty.9.qml" << "invalidGroupedProperty.9.errors.txt" << false;
- QTest::newRow("invalidGroupedProperty.10") << "invalidGroupedProperty.10.qml" << "invalidGroupedProperty.10.errors.txt" << false;
-
- QTest::newRow("importNamespaceConflict") << "importNamespaceConflict.qml" << "importNamespaceConflict.errors.txt" << false;
- QTest::newRow("importVersionMissing (builtin)") << "importVersionMissingBuiltIn.qml" << "importVersionMissingBuiltIn.errors.txt" << false;
- QTest::newRow("importVersionMissing (installed)") << "importVersionMissingInstalled.qml" << "importVersionMissingInstalled.errors.txt" << false;
- QTest::newRow("importNonExist (installed)") << "importNonExist.qml" << "importNonExist.errors.txt" << false;
- QTest::newRow("importNonExistOlder (installed)") << "importNonExistOlder.qml" << "importNonExistOlder.errors.txt" << false;
- QTest::newRow("importNewerVersion (installed)") << "importNewerVersion.qml" << "importNewerVersion.errors.txt" << false;
- QTest::newRow("invalidImportID") << "invalidImportID.qml" << "invalidImportID.errors.txt" << false;
- QTest::newRow("importFile") << "importFile.qml" << "importFile.errors.txt" << false;
-
- QTest::newRow("signal.1") << "signal.1.qml" << "signal.1.errors.txt" << false;
- QTest::newRow("signal.2") << "signal.2.qml" << "signal.2.errors.txt" << false;
- QTest::newRow("signal.3") << "signal.3.qml" << "signal.3.errors.txt" << false;
- QTest::newRow("signal.4") << "signal.4.qml" << "signal.4.errors.txt" << false;
-
- QTest::newRow("method.1") << "method.1.qml" << "method.1.errors.txt" << false;
-
- QTest::newRow("property.1") << "property.1.qml" << "property.1.errors.txt" << false;
- QTest::newRow("property.2") << "property.2.qml" << "property.2.errors.txt" << false;
- QTest::newRow("property.3") << "property.3.qml" << "property.3.errors.txt" << false;
- QTest::newRow("property.4") << "property.4.qml" << "property.4.errors.txt" << false;
- QTest::newRow("property.6") << "property.6.qml" << "property.6.errors.txt" << false;
- QTest::newRow("property.7") << "property.7.qml" << "property.7.errors.txt" << false;
-
- QTest::newRow("importScript.1") << "importscript.1.qml" << "importscript.1.errors.txt" << false;
-
- QTest::newRow("Component.1") << "component.1.qml" << "component.1.errors.txt" << false;
- QTest::newRow("Component.2") << "component.2.qml" << "component.2.errors.txt" << false;
- QTest::newRow("Component.3") << "component.3.qml" << "component.3.errors.txt" << false;
- QTest::newRow("Component.4") << "component.4.qml" << "component.4.errors.txt" << false;
- QTest::newRow("Component.5") << "component.5.qml" << "component.5.errors.txt" << false;
- QTest::newRow("Component.6") << "component.6.qml" << "component.6.errors.txt" << false;
- QTest::newRow("Component.7") << "component.7.qml" << "component.7.errors.txt" << false;
- QTest::newRow("Component.8") << "component.8.qml" << "component.8.errors.txt" << false;
- QTest::newRow("Component.9") << "component.9.qml" << "component.9.errors.txt" << false;
-
- QTest::newRow("MultiSet.1") << "multiSet.1.qml" << "multiSet.1.errors.txt" << false;
- QTest::newRow("MultiSet.2") << "multiSet.2.qml" << "multiSet.2.errors.txt" << false;
- QTest::newRow("MultiSet.3") << "multiSet.3.qml" << "multiSet.3.errors.txt" << false;
- QTest::newRow("MultiSet.4") << "multiSet.4.qml" << "multiSet.4.errors.txt" << false;
- QTest::newRow("MultiSet.5") << "multiSet.5.qml" << "multiSet.5.errors.txt" << false;
- QTest::newRow("MultiSet.6") << "multiSet.6.qml" << "multiSet.6.errors.txt" << false;
- QTest::newRow("MultiSet.7") << "multiSet.7.qml" << "multiSet.7.errors.txt" << false;
- QTest::newRow("MultiSet.8") << "multiSet.8.qml" << "multiSet.8.errors.txt" << false;
- QTest::newRow("MultiSet.9") << "multiSet.9.qml" << "multiSet.9.errors.txt" << false;
- QTest::newRow("MultiSet.10") << "multiSet.10.qml" << "multiSet.10.errors.txt" << false;
- QTest::newRow("MultiSet.11") << "multiSet.11.qml" << "multiSet.11.errors.txt" << false;
-
- QTest::newRow("dynamicMeta.1") << "dynamicMeta.1.qml" << "dynamicMeta.1.errors.txt" << false;
- QTest::newRow("dynamicMeta.2") << "dynamicMeta.2.qml" << "dynamicMeta.2.errors.txt" << false;
- QTest::newRow("dynamicMeta.3") << "dynamicMeta.3.qml" << "dynamicMeta.3.errors.txt" << false;
- QTest::newRow("dynamicMeta.4") << "dynamicMeta.4.qml" << "dynamicMeta.4.errors.txt" << false;
- QTest::newRow("dynamicMeta.5") << "dynamicMeta.5.qml" << "dynamicMeta.5.errors.txt" << false;
-
- QTest::newRow("invalidAlias.1") << "invalidAlias.1.qml" << "invalidAlias.1.errors.txt" << false;
- QTest::newRow("invalidAlias.2") << "invalidAlias.2.qml" << "invalidAlias.2.errors.txt" << false;
- QTest::newRow("invalidAlias.3") << "invalidAlias.3.qml" << "invalidAlias.3.errors.txt" << false;
- 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("invalidAlias.8") << "invalidAlias.8.qml" << "invalidAlias.8.errors.txt" << false;
- QTest::newRow("invalidAlias.9") << "invalidAlias.9.qml" << "invalidAlias.9.errors.txt" << false;
- QTest::newRow("invalidAlias.10") << "invalidAlias.10.qml" << "invalidAlias.10.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;
- QTest::newRow("invalidAttachedProperty.3") << "invalidAttachedProperty.3.qml" << "invalidAttachedProperty.3.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.4") << "invalidAttachedProperty.4.qml" << "invalidAttachedProperty.4.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.5") << "invalidAttachedProperty.5.qml" << "invalidAttachedProperty.5.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.6") << "invalidAttachedProperty.6.qml" << "invalidAttachedProperty.6.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.7") << "invalidAttachedProperty.7.qml" << "invalidAttachedProperty.7.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.8") << "invalidAttachedProperty.8.qml" << "invalidAttachedProperty.8.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.9") << "invalidAttachedProperty.9.qml" << "invalidAttachedProperty.9.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.10") << "invalidAttachedProperty.10.qml" << "invalidAttachedProperty.10.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.11") << "invalidAttachedProperty.11.qml" << "invalidAttachedProperty.11.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.12") << "invalidAttachedProperty.12.qml" << "invalidAttachedProperty.12.errors.txt" << false;
- QTest::newRow("invalidAttachedProperty.13") << "invalidAttachedProperty.13.qml" << "invalidAttachedProperty.13.errors.txt" << false;
-
- QTest::newRow("assignValueToSignal") << "assignValueToSignal.qml" << "assignValueToSignal.errors.txt" << false;
- QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false;
-
- QTest::newRow("nestedErrors") << "nestedErrors.qml" << "nestedErrors.errors.txt" << false;
- QTest::newRow("defaultGrouped") << "defaultGrouped.qml" << "defaultGrouped.errors.txt" << false;
- QTest::newRow("doubleSignal") << "doubleSignal.qml" << "doubleSignal.errors.txt" << false;
- QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false;
- QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false;
- QTest::newRow("enumTypes") << "enumTypes.qml" << "enumTypes.errors.txt" << false;
- QTest::newRow("noCreation") << "noCreation.qml" << "noCreation.errors.txt" << false;
- QTest::newRow("destroyedSignal") << "destroyedSignal.qml" << "destroyedSignal.errors.txt" << false;
- 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;
- QTest::newRow("notAvailable") << "notAvailable.qml" << "notAvailable.errors.txt" << false;
- QTest::newRow("singularProperty") << "singularProperty.qml" << "singularProperty.errors.txt" << false;
- QTest::newRow("singularProperty.2") << "singularProperty.2.qml" << "singularProperty.2.errors.txt" << false;
- QTest::newRow("incorrectCase") << "incorrectCase.qml"
-#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
- << "incorrectCase.errors.insensitive.txt"
-#else
- << "incorrectCase.errors.sensitive.txt"
-#endif
- << false;
-
- QTest::newRow("metaobjectRevision.1") << "metaobjectRevision.1.qml" << "metaobjectRevision.1.errors.txt" << false;
- QTest::newRow("metaobjectRevision.2") << "metaobjectRevision.2.qml" << "metaobjectRevision.2.errors.txt" << false;
- QTest::newRow("metaobjectRevision.3") << "metaobjectRevision.3.qml" << "metaobjectRevision.3.errors.txt" << false;
-
- QTest::newRow("invalidRoot.1") << "invalidRoot.1.qml" << "invalidRoot.1.errors.txt" << false;
- QTest::newRow("invalidRoot.2") << "invalidRoot.2.qml" << "invalidRoot.2.errors.txt" << false;
- QTest::newRow("invalidRoot.3") << "invalidRoot.3.qml" << "invalidRoot.3.errors.txt" << false;
- QTest::newRow("invalidRoot.4") << "invalidRoot.4.qml" << "invalidRoot.4.errors.txt" << false;
-
- QTest::newRow("invalidTypeName.1") << "invalidTypeName.1.qml" << "invalidTypeName.1.errors.txt" << false;
- QTest::newRow("invalidTypeName.2") << "invalidTypeName.2.qml" << "invalidTypeName.2.errors.txt" << false;
- QTest::newRow("invalidTypeName.3") << "invalidTypeName.3.qml" << "invalidTypeName.3.errors.txt" << false;
- QTest::newRow("invalidTypeName.4") << "invalidTypeName.4.qml" << "invalidTypeName.4.errors.txt" << false;
-
- QTest::newRow("Major version isolation") << "majorVersionIsolation.qml" << "majorVersionIsolation.errors.txt" << false;
-}
-
-
-void tst_qdeclarativelanguage::errors()
-{
- QFETCH(QString, file);
- QFETCH(QString, errorFile);
- QFETCH(bool, create);
-
- QDeclarativeComponent component(&engine, TEST_FILE(file));
-
- if(create) {
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
-
- VERIFY_ERRORS(errorFile.toLatin1().constData());
-}
-
-void tst_qdeclarativelanguage::simpleObject()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("simpleObject.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-void tst_qdeclarativelanguage::simpleContainer()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("simpleContainer.qml"));
- VERIFY_ERRORS(0);
- MyContainer *container= qobject_cast<MyContainer*>(component.create());
- QVERIFY(container != 0);
- QCOMPARE(container->getChildren()->count(),2);
-}
-
-void tst_qdeclarativelanguage::interfaceProperty()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("interfaceProperty.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->interface());
- QVERIFY(object->interface()->id == 913);
-}
-
-void tst_qdeclarativelanguage::interfaceQList()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("interfaceQList.qml"));
- VERIFY_ERRORS(0);
- MyContainer *container= qobject_cast<MyContainer*>(component.create());
- QVERIFY(container != 0);
- QVERIFY(container->getQListInterfaces()->count() == 2);
- for(int ii = 0; ii < 2; ++ii)
- QVERIFY(container->getQListInterfaces()->at(ii)->id == 913);
-}
-
-void tst_qdeclarativelanguage::assignObjectToSignal()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignObjectToSignal.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
- emit object->basicSignal();
-}
-
-void tst_qdeclarativelanguage::assignObjectToVariant()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignObjectToVariant.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QVariant v = object->property("a");
- QVERIFY(v.userType() == qMetaTypeId<QObject *>());
-}
-
-void tst_qdeclarativelanguage::assignLiteralSignalProperty()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignLiteralSignalProperty.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->onLiteralSignal(), 10);
-}
-
-// Test is an external component can be loaded and assigned (to a qlist)
-void tst_qdeclarativelanguage::assignQmlComponent()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignQmlComponent.qml"));
- VERIFY_ERRORS(0);
- MyContainer *object = qobject_cast<MyContainer *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->getChildren()->count() == 1);
- QObject *child = object->getChildren()->at(0);
- QCOMPARE(child->property("x"), QVariant(10));
- QCOMPARE(child->property("y"), QVariant(11));
-}
-
-// Test literal assignment to all the basic types
-void tst_qdeclarativelanguage::assignBasicTypes()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignBasicTypes.qml"));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
- QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
- QCOMPARE(object->stringProperty(), QString("Hello World!"));
- QCOMPARE(object->uintProperty(), uint(10));
- QCOMPARE(object->intProperty(), -19);
- QCOMPARE((float)object->realProperty(), float(23.2));
- QCOMPARE((float)object->doubleProperty(), float(-19.7));
- QCOMPARE((float)object->floatProperty(), float(8.5));
- QCOMPARE(object->colorProperty(), QColor("red"));
- QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
- QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
- QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
- QCOMPARE(object->pointProperty(), QPoint(99,13));
- QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
- QCOMPARE(object->sizeProperty(), QSize(99, 13));
- QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
- QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
- QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
- QCOMPARE(object->boolProperty(), true);
- QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
- QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
- QCOMPARE(object->vector4Property(), QVector4D(10, 1, 2.2, 2.3));
- QUrl encoded;
- encoded.setEncodedUrl("main.qml?with%3cencoded%3edata", QUrl::TolerantMode);
- QCOMPARE(object->urlProperty(), component.url().resolved(encoded));
- QVERIFY(object->objectProperty() != 0);
- MyTypeObject *child = qobject_cast<MyTypeObject *>(object->objectProperty());
- QVERIFY(child != 0);
- QCOMPARE(child->intProperty(), 8);
-}
-
-// Test edge case type assignments
-void tst_qdeclarativelanguage::assignTypeExtremes()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignTypeExtremes.qml"));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->uintProperty(), 0xEE6B2800);
- QCOMPARE(object->intProperty(), -0x77359400);
-}
-
-// Test that a composite type can assign to a property of its base type
-void tst_qdeclarativelanguage::assignCompositeToType()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignCompositeToType.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-// Test that literals are stored correctly in variant properties
-void tst_qdeclarativelanguage::assignLiteralToVariant()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignLiteralToVariant.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").userType(), (int)QVariant::Int);
- QCOMPARE(object->property("test2").userType(), (int)QMetaType::Double);
- QCOMPARE(object->property("test3").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test4").userType(), (int)QVariant::Color);
- QCOMPARE(object->property("test5").userType(), (int)QVariant::RectF);
- QCOMPARE(object->property("test6").userType(), (int)QVariant::PointF);
- QCOMPARE(object->property("test7").userType(), (int)QVariant::SizeF);
- QCOMPARE(object->property("test8").userType(), (int)QVariant::Vector3D);
- QCOMPARE(object->property("test9").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test10").userType(), (int)QVariant::Bool);
- QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool);
- QCOMPARE(object->property("test12").userType(), (int)QVariant::Vector4D);
-
- QVERIFY(object->property("test1") == QVariant(1));
- QVERIFY(object->property("test2") == QVariant((double)1.7));
- QVERIFY(object->property("test3") == QVariant(QString(QLatin1String("Hello world!"))));
- QVERIFY(object->property("test4") == QVariant(QColor::fromRgb(0xFF008800)));
- QVERIFY(object->property("test5") == QVariant(QRectF(10, 10, 10, 10)));
- QVERIFY(object->property("test6") == QVariant(QPointF(10, 10)));
- QVERIFY(object->property("test7") == QVariant(QSizeF(10, 10)));
- QVERIFY(object->property("test8") == QVariant(QVector3D(100, 100, 100)));
- QVERIFY(object->property("test9") == QVariant(QString(QLatin1String("#FF008800"))));
- QVERIFY(object->property("test10") == QVariant(bool(true)));
- QVERIFY(object->property("test11") == QVariant(bool(false)));
- QVERIFY(object->property("test12") == QVariant(QVector4D(100, 100, 100, 100)));
-
- delete object;
-}
-
-// Test that literals are stored correctly in "var" properties
-// Note that behaviour differs from "variant" properties in that
-// no conversion from "special strings" to QVariants is performed.
-void tst_qdeclarativelanguage::assignLiteralToVar()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignLiteralToVar.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").userType(), (int)QMetaType::Int);
- QCOMPARE(object->property("test2").userType(), (int)QMetaType::Double);
- QCOMPARE(object->property("test3").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test4").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test5").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test6").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test7").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test8").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test9").userType(), (int)QVariant::String);
- QCOMPARE(object->property("test10").userType(), (int)QVariant::Bool);
- QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool);
- QCOMPARE(object->property("test12").userType(), (int)QVariant::Color);
- QCOMPARE(object->property("test13").userType(), (int)QVariant::RectF);
- QCOMPARE(object->property("test14").userType(), (int)QVariant::PointF);
- QCOMPARE(object->property("test15").userType(), (int)QVariant::SizeF);
- QCOMPARE(object->property("test16").userType(), (int)QVariant::Vector3D);
- QCOMPARE(object->property("variantTest1Bound").userType(), (int)QMetaType::Int);
- QCOMPARE(object->property("test1Bound").userType(), (int)QMetaType::Int);
-
- QCOMPARE(object->property("test1"), QVariant(5));
- QCOMPARE(object->property("test2"), QVariant((double)1.7));
- QCOMPARE(object->property("test3"), QVariant(QString(QLatin1String("Hello world!"))));
- QCOMPARE(object->property("test4"), QVariant(QString(QLatin1String("#FF008800"))));
- QCOMPARE(object->property("test5"), QVariant(QString(QLatin1String("10,10,10x10"))));
- QCOMPARE(object->property("test6"), QVariant(QString(QLatin1String("10,10"))));
- QCOMPARE(object->property("test7"), QVariant(QString(QLatin1String("10x10"))));
- QCOMPARE(object->property("test8"), QVariant(QString(QLatin1String("100,100,100"))));
- QCOMPARE(object->property("test9"), QVariant(QString(QLatin1String("#FF008800"))));
- QCOMPARE(object->property("test10"), QVariant(bool(true)));
- QCOMPARE(object->property("test11"), QVariant(bool(false)));
- QCOMPARE(object->property("test12"), QVariant(QColor::fromRgbF(0.2, 0.3, 0.4, 0.5)));
- QCOMPARE(object->property("test13"), QVariant(QRectF(10, 10, 10, 10)));
- QCOMPARE(object->property("test14"), QVariant(QPointF(10, 10)));
- QCOMPARE(object->property("test15"), QVariant(QSizeF(10, 10)));
- QCOMPARE(object->property("test16"), QVariant(QVector3D(100, 100, 100)));
- QCOMPARE(object->property("variantTest1Bound"), QVariant(9));
- QCOMPARE(object->property("test1Bound"), QVariant(11));
-
- delete object;
-}
-
-// Tests that custom parser types can be instantiated
-void tst_qdeclarativelanguage::customParserTypes()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("customParserTypes.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QVERIFY(object->property("count") == QVariant(2));
-}
-
-// Tests that the root item can be a custom component
-void tst_qdeclarativelanguage::rootAsQmlComponent()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("rootAsQmlComponent.qml"));
- VERIFY_ERRORS(0);
- MyContainer *object = qobject_cast<MyContainer *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->property("x"), QVariant(11));
- QCOMPARE(object->getChildren()->count(), 2);
-}
-
-// Tests that components can be specified inline
-void tst_qdeclarativelanguage::inlineQmlComponents()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("inlineQmlComponents.qml"));
- VERIFY_ERRORS(0);
- MyContainer *object = qobject_cast<MyContainer *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->getChildren()->count(), 1);
- QDeclarativeComponent *comp = qobject_cast<QDeclarativeComponent *>(object->getChildren()->at(0));
- QVERIFY(comp != 0);
- MyQmlObject *compObject = qobject_cast<MyQmlObject *>(comp->create());
- QVERIFY(compObject != 0);
- QCOMPARE(compObject->value(), 11);
-}
-
-// Tests that types that have an id property have it set
-void tst_qdeclarativelanguage::idProperty()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("idProperty.qml"));
- VERIFY_ERRORS(0);
- MyContainer *object = qobject_cast<MyContainer *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->getChildren()->count(), 1);
- MyTypeObject *child =
- qobject_cast<MyTypeObject *>(object->getChildren()->at(0));
- QVERIFY(child != 0);
- QCOMPARE(child->id(), QString("myObjectId"));
- QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child));
-}
-
-// Tests automatic connection to notify signals if "onBlahChanged" syntax is used
-// even if the notify signal for "blah" is not called "blahChanged"
-void tst_qdeclarativelanguage::autoNotifyConnection()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("autoNotifyConnection.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QMetaProperty prop = object->metaObject()->property(object->metaObject()->indexOfProperty("receivedNotify"));
- QVERIFY(prop.isValid());
-
- QCOMPARE(prop.read(object), QVariant::fromValue(false));
- object->setPropertyWithNotify(1);
- QCOMPARE(prop.read(object), QVariant::fromValue(true));
-}
-
-// Tests that signals can be assigned to
-void tst_qdeclarativelanguage::assignSignal()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("assignSignal.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
- QVERIFY(object != 0);
- QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
- emit object->basicSignal();
- QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlotWithArgs(9)");
- emit object->basicParameterizedSignal(9);
-}
-
-// Tests the creation and assignment of dynamic properties
-void tst_qdeclarativelanguage::dynamicProperties()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicProperties.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("intProperty"), QVariant(10));
- QCOMPARE(object->property("boolProperty"), QVariant(false));
- QCOMPARE(object->property("doubleProperty"), QVariant(-10.1));
- QCOMPARE(object->property("realProperty"), QVariant((qreal)-19.9));
- QCOMPARE(object->property("stringProperty"), QVariant("Hello World!"));
- QCOMPARE(object->property("urlProperty"), QVariant(TEST_FILE("main.qml")));
- QCOMPARE(object->property("colorProperty"), QVariant(QColor("red")));
- QCOMPARE(object->property("dateProperty"), QVariant(QDate(1945, 9, 2)));
- QCOMPARE(object->property("varProperty"), QVariant("Hello World!"));
-}
-
-// Test that nested types can use dynamic properties
-void tst_qdeclarativelanguage::dynamicPropertiesNested()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicPropertiesNested.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("super_a").toInt(), 11); // Overridden
- QCOMPARE(object->property("super_c").toInt(), 14); // Inherited
- QCOMPARE(object->property("a").toInt(), 13); // New
- QCOMPARE(object->property("b").toInt(), 12); // New
-
- delete object;
-}
-
-// Tests the creation and assignment to dynamic list properties
-void tst_qdeclarativelanguage::listProperties()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("listProperties.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toInt(), 2);
-}
-
-// Tests the creation and assignment of dynamic object properties
-// ### Not complete
-void tst_qdeclarativelanguage::dynamicObjectProperties()
-{
- {
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicObjectProperties.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVERIFY(object->property("objectProperty") == qVariantFromValue((QObject*)0));
- QVERIFY(object->property("objectProperty2") != qVariantFromValue((QObject*)0));
- }
- {
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicObjectProperties.2.qml"));
- QEXPECT_FAIL("", "QTBUG-10822", Abort);
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVERIFY(object->property("objectProperty") != qVariantFromValue((QObject*)0));
- }
-}
-
-// Tests the declaration of dynamic signals and slots
-void tst_qdeclarativelanguage::dynamicSignalsAndSlots()
-{
- QTest::ignoreMessage(QtDebugMsg, "1921");
-
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicSignalsAndSlots.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QVERIFY(object->metaObject()->indexOfMethod("signal1()") != -1);
- QVERIFY(object->metaObject()->indexOfMethod("signal2()") != -1);
- QVERIFY(object->metaObject()->indexOfMethod("slot1()") != -1);
- QVERIFY(object->metaObject()->indexOfMethod("slot2()") != -1);
-
- QCOMPARE(object->property("test").toInt(), 0);
- QMetaObject::invokeMethod(object, "slot3", Qt::DirectConnection, Q_ARG(QVariant, QVariant(10)));
- QCOMPARE(object->property("test").toInt(), 10);
-}
-
-void tst_qdeclarativelanguage::simpleBindings()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("simpleBindings.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("value1"), QVariant(10));
- QCOMPARE(object->property("value2"), QVariant(10));
- QCOMPARE(object->property("value3"), QVariant(21));
- QCOMPARE(object->property("value4"), QVariant(10));
- QCOMPARE(object->property("objectProperty"), QVariant::fromValue(object));
-}
-
-void tst_qdeclarativelanguage::autoComponentCreation()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("autoComponentCreation.qml"));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->componentProperty() != 0);
- MyTypeObject *child = qobject_cast<MyTypeObject *>(object->componentProperty()->create());
- QVERIFY(child != 0);
- QCOMPARE(child->realProperty(), qreal(9));
-}
-
-void tst_qdeclarativelanguage::propertyValueSource()
-{
- {
- QDeclarativeComponent component(&engine, TEST_FILE("propertyValueSource.qml"));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QList<QObject *> valueSources;
- QObjectList allChildren = object->findChildren<QObject*>();
- foreach (QObject *child, allChildren) {
- if (qobject_cast<QDeclarativePropertyValueSource *>(child))
- valueSources.append(child);
- }
-
- QCOMPARE(valueSources.count(), 1);
- MyPropertyValueSource *valueSource =
- qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
- QVERIFY(valueSource != 0);
- QCOMPARE(valueSource->prop.object(), qobject_cast<QObject*>(object));
- QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty")));
- }
-
- {
- QDeclarativeComponent component(&engine, TEST_FILE("propertyValueSource.2.qml"));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QList<QObject *> valueSources;
- QObjectList allChildren = object->findChildren<QObject*>();
- foreach (QObject *child, allChildren) {
- if (qobject_cast<QDeclarativePropertyValueSource *>(child))
- valueSources.append(child);
- }
-
- QCOMPARE(valueSources.count(), 1);
- MyPropertyValueSource *valueSource =
- qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
- QVERIFY(valueSource != 0);
- QCOMPARE(valueSource->prop.object(), qobject_cast<QObject*>(object));
- QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty")));
- }
-}
-
-void tst_qdeclarativelanguage::attachedProperties()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("attachedProperties.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QObject *attached = qmlAttachedPropertiesObject<MyQmlObject>(object);
- QVERIFY(attached != 0);
- QCOMPARE(attached->property("value"), QVariant(10));
- QCOMPARE(attached->property("value2"), QVariant(13));
-}
-
-// Tests non-static object properties
-void tst_qdeclarativelanguage::dynamicObjects()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicObject.1.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-// Tests the registration of custom variant string converters
-void tst_qdeclarativelanguage::customVariantTypes()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("customVariantTypes.qml"));
- VERIFY_ERRORS(0);
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->customType().a, 10);
-}
-
-void tst_qdeclarativelanguage::valueTypes()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("valueTypes.qml"));
- VERIFY_ERRORS(0);
-
- QString message = component.url().toString() + ":2:1: QML MyTypeObject: Binding loop detected for property \"rectProperty.width\"";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
-
- MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
- QVERIFY(object != 0);
-
-
- QCOMPARE(object->rectProperty(), QRect(10, 11, 12, 13));
- QCOMPARE(object->rectProperty2(), QRect(10, 11, 12, 13));
- QCOMPARE(object->intProperty(), 10);
- object->doAction();
- QCOMPARE(object->rectProperty(), QRect(12, 11, 14, 13));
- QCOMPARE(object->rectProperty2(), QRect(12, 11, 14, 13));
- QCOMPARE(object->intProperty(), 12);
-
- // ###
-#if 0
- QDeclarativeProperty p(object, "rectProperty.x");
- QCOMPARE(p.read(), QVariant(12));
- p.write(13);
- QCOMPARE(p.read(), QVariant(13));
-
- quint32 r = QDeclarativePropertyPrivate::saveValueType(p.coreIndex(), p.valueTypeCoreIndex());
- QDeclarativeProperty p2;
- QDeclarativePropertyPrivate::restore(p2, r, object);
- QCOMPARE(p2.read(), QVariant(13));
-#endif
-}
-
-void tst_qdeclarativelanguage::cppnamespace()
-{
- {
- QDeclarativeComponent component(&engine, TEST_FILE("cppnamespace.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, TEST_FILE("cppnamespace.2.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
- }
-}
-
-void tst_qdeclarativelanguage::aliasProperties()
-{
- // Simple "int" alias
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.1.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- // Read through alias
- QCOMPARE(object->property("valueAlias").toInt(), 10);
- object->setProperty("value", QVariant(13));
- QCOMPARE(object->property("valueAlias").toInt(), 13);
-
- // Write through alias
- object->setProperty("valueAlias", QVariant(19));
- QCOMPARE(object->property("valueAlias").toInt(), 19);
- QCOMPARE(object->property("value").toInt(), 19);
-
- delete object;
- }
-
- // Complex object alias
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.2.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- // Read through alias
- MyQmlObject *v =
- qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
- QVERIFY(v != 0);
- QCOMPARE(v->value(), 10);
-
- // Write through alias
- MyQmlObject *v2 = new MyQmlObject();
- v2->setParent(object);
- object->setProperty("aliasObject", qVariantFromValue(v2));
- MyQmlObject *v3 =
- qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
- QVERIFY(v3 != 0);
- QCOMPARE(v3, v2);
-
- delete object;
- }
-
- // Nested aliases
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.3.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("value").toInt(), 1892);
- QCOMPARE(object->property("value2").toInt(), 1892);
-
- object->setProperty("value", QVariant(1313));
- QCOMPARE(object->property("value").toInt(), 1313);
- QCOMPARE(object->property("value2").toInt(), 1313);
-
- object->setProperty("value2", QVariant(8080));
- QCOMPARE(object->property("value").toInt(), 8080);
- QCOMPARE(object->property("value2").toInt(), 8080);
-
- delete object;
- }
-
- // Enum aliases
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.4.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("enumAlias").toInt(), 1);
-
- delete object;
- }
-
- // Id aliases
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.5.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVariant v = object->property("otherAlias");
- QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>());
- MyQmlObject *o = qvariant_cast<MyQmlObject*>(v);
- QCOMPARE(o->value(), 10);
-
- delete o;
-
- v = object->property("otherAlias");
- QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>());
- o = qvariant_cast<MyQmlObject*>(v);
- QVERIFY(o == 0);
-
- delete object;
- }
-
- // Nested aliases - this used to cause a crash
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.6.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("a").toInt(), 1923);
- }
-
- // Ptr Alias Cleanup - check that aliases to ptr types return 0
- // if the object aliased to is removed
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.7.qml"));
- VERIFY_ERRORS(0);
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *object1 = qvariant_cast<QObject *>(object->property("object"));
- QVERIFY(object1 != 0);
- QObject *object2 = qvariant_cast<QObject *>(object1->property("object"));
- QVERIFY(object2 != 0);
-
- QObject *alias = qvariant_cast<QObject *>(object->property("aliasedObject"));
- QVERIFY(alias == object2);
-
- delete object1;
-
- QObject *alias2 = object; // "Random" start value
- int status = -1;
- void *a[] = { &alias2, 0, &status };
- QMetaObject::metacall(object, QMetaObject::ReadProperty,
- object->metaObject()->indexOfProperty("aliasedObject"), a);
- QVERIFY(alias2 == 0);
- }
-
- // Simple composite type
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.8.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("value").toInt(), 10);
-
- delete object;
- }
-
- // Complex composite type
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.9.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("value").toInt(), 10);
-
- delete object;
- }
-
- // Valuetype alias
- // Simple "int" alias
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.10.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- // Read through alias
- QCOMPARE(object->property("valueAlias").toRect(), QRect(10, 11, 9, 8));
- object->setProperty("rectProperty", QVariant(QRect(33, 12, 99, 100)));
- QCOMPARE(object->property("valueAlias").toRect(), QRect(33, 12, 99, 100));
-
- // Write through alias
- object->setProperty("valueAlias", QVariant(QRect(3, 3, 4, 9)));
- QCOMPARE(object->property("valueAlias").toRect(), QRect(3, 3, 4, 9));
- QCOMPARE(object->property("rectProperty").toRect(), QRect(3, 3, 4, 9));
-
- delete object;
- }
-
- // Valuetype sub-alias
- {
- QDeclarativeComponent component(&engine, TEST_FILE("alias.11.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- // Read through alias
- QCOMPARE(object->property("aliasProperty").toInt(), 19);
- object->setProperty("rectProperty", QVariant(QRect(33, 8, 102, 111)));
- QCOMPARE(object->property("aliasProperty").toInt(), 33);
-
- // Write through alias
- object->setProperty("aliasProperty", QVariant(4));
- QCOMPARE(object->property("aliasProperty").toInt(), 4);
- QCOMPARE(object->property("rectProperty").toRect(), QRect(4, 8, 102, 111));
-
- delete object;
- }
-}
-
-// 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()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("componentCompositeType.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-class TestType : public QObject {
- Q_OBJECT
-public:
- TestType(QObject *p=0) : QObject(p) {}
-};
-
-class TestType2 : public QObject {
- Q_OBJECT
-public:
- TestType2(QObject *p=0) : QObject(p) {}
-};
-
-void tst_qdeclarativelanguage::i18n_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("stringProperty");
- QTest::newRow("i18nStrings") << "i18nStrings.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245 (5 accented 'a' letters)");
- QTest::newRow("i18nDeclaredPropertyNames") << "i18nDeclaredPropertyNames.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 10");
- QTest::newRow("i18nDeclaredPropertyUse") << "i18nDeclaredPropertyUse.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 15");
- QTest::newRow("i18nScript") << "i18nScript.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 20");
- QTest::newRow("i18nType") << "i18nType.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 30");
- QTest::newRow("i18nNameSpace") << "i18nNameSpace.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 40");
-}
-
-void tst_qdeclarativelanguage::i18n()
-{
- QFETCH(QString, file);
- QFETCH(QString, stringProperty);
- QDeclarativeComponent component(&engine, TEST_FILE(file));
- VERIFY_ERRORS(0);
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->stringProperty(), stringProperty);
-
- delete object;
-}
-
-// Check that the Component::onCompleted attached property works
-void tst_qdeclarativelanguage::onCompleted()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("onCompleted.qml"));
- VERIFY_ERRORS(0);
- QTest::ignoreMessage(QtDebugMsg, "Completed 6 10");
- QTest::ignoreMessage(QtDebugMsg, "Completed 6 10");
- QTest::ignoreMessage(QtDebugMsg, "Completed 10 11");
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-// Check that the Component::onDestruction attached property works
-void tst_qdeclarativelanguage::onDestruction()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("onDestruction.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QTest::ignoreMessage(QtDebugMsg, "Destruction 6 10");
- QTest::ignoreMessage(QtDebugMsg, "Destruction 6 10");
- QTest::ignoreMessage(QtDebugMsg, "Destruction 10 11");
- delete object;
-}
-
-// Check that assignments to QDeclarativeScriptString properties work
-void tst_qdeclarativelanguage::scriptString()
-{
- {
- QDeclarativeComponent component(&engine, TEST_FILE("scriptString.qml"));
- VERIFY_ERRORS(0);
-
- MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->scriptProperty().script(), QString("foo + bar"));
- QCOMPARE(object->scriptProperty().scopeObject(), qobject_cast<QObject*>(object));
- QCOMPARE(object->scriptProperty().context(), qmlContext(object));
-
- QVERIFY(object->grouped() != 0);
- QCOMPARE(object->grouped()->script().script(), QString("console.log(1921)"));
- QCOMPARE(object->grouped()->script().scopeObject(), qobject_cast<QObject*>(object));
- QCOMPARE(object->grouped()->script().context(), qmlContext(object));
- }
-
- {
- QDeclarativeComponent component(&engine, TEST_FILE("scriptString2.qml"));
- VERIFY_ERRORS(0);
-
- MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->scriptProperty().script(), QString("\"hello\\n\\\"world\\\"\""));
- }
-
- {
- QDeclarativeComponent component(&engine, TEST_FILE("scriptString3.qml"));
- VERIFY_ERRORS(0);
-
- MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->scriptProperty().script(), QString("12.345"));
- }
-
- {
- QDeclarativeComponent component(&engine, TEST_FILE("scriptString4.qml"));
- VERIFY_ERRORS(0);
-
- MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
- QVERIFY(object != 0);
- QCOMPARE(object->scriptProperty().script(), QString("true"));
- }
-}
-
-// Check that default property assignments are correctly spliced into explicit
-// property assignments
-void tst_qdeclarativelanguage::defaultPropertyListOrder()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("defaultPropertyListOrder.qml"));
- VERIFY_ERRORS(0);
-
- MyContainer *container = qobject_cast<MyContainer *>(component.create());
- QVERIFY(container != 0);
-
- QCOMPARE(container->getChildren()->count(), 6);
- QCOMPARE(container->getChildren()->at(0)->property("index"), QVariant(0));
- QCOMPARE(container->getChildren()->at(1)->property("index"), QVariant(1));
- QCOMPARE(container->getChildren()->at(2)->property("index"), QVariant(2));
- QCOMPARE(container->getChildren()->at(3)->property("index"), QVariant(3));
- QCOMPARE(container->getChildren()->at(4)->property("index"), QVariant(4));
- QCOMPARE(container->getChildren()->at(5)->property("index"), QVariant(5));
-}
-
-void tst_qdeclarativelanguage::declaredPropertyValues()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("declaredPropertyValues.qml"));
- 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;
-}
-
-void tst_qdeclarativelanguage::reservedWords_data()
-{
- QTest::addColumn<QByteArray>("word");
-
- QTest::newRow("abstract") << QByteArray("abstract");
- QTest::newRow("as") << QByteArray("as");
- QTest::newRow("boolean") << QByteArray("boolean");
- QTest::newRow("break") << QByteArray("break");
- QTest::newRow("byte") << QByteArray("byte");
- QTest::newRow("case") << QByteArray("case");
- QTest::newRow("catch") << QByteArray("catch");
- QTest::newRow("char") << QByteArray("char");
- QTest::newRow("class") << QByteArray("class");
- QTest::newRow("continue") << QByteArray("continue");
- QTest::newRow("const") << QByteArray("const");
- QTest::newRow("debugger") << QByteArray("debugger");
- QTest::newRow("default") << QByteArray("default");
- QTest::newRow("delete") << QByteArray("delete");
- QTest::newRow("do") << QByteArray("do");
- QTest::newRow("double") << QByteArray("double");
- QTest::newRow("else") << QByteArray("else");
- QTest::newRow("enum") << QByteArray("enum");
- QTest::newRow("export") << QByteArray("export");
- QTest::newRow("extends") << QByteArray("extends");
- QTest::newRow("false") << QByteArray("false");
- QTest::newRow("final") << QByteArray("final");
- QTest::newRow("finally") << QByteArray("finally");
- QTest::newRow("float") << QByteArray("float");
- QTest::newRow("for") << QByteArray("for");
- QTest::newRow("function") << QByteArray("function");
- QTest::newRow("goto") << QByteArray("goto");
- QTest::newRow("if") << QByteArray("if");
- QTest::newRow("implements") << QByteArray("implements");
- QTest::newRow("import") << QByteArray("import");
- QTest::newRow("in") << QByteArray("in");
- QTest::newRow("instanceof") << QByteArray("instanceof");
- QTest::newRow("int") << QByteArray("int");
- QTest::newRow("interface") << QByteArray("interface");
- QTest::newRow("long") << QByteArray("long");
- QTest::newRow("native") << QByteArray("native");
- QTest::newRow("new") << QByteArray("new");
- QTest::newRow("null") << QByteArray("null");
- QTest::newRow("package") << QByteArray("package");
- QTest::newRow("private") << QByteArray("private");
- QTest::newRow("protected") << QByteArray("protected");
- QTest::newRow("public") << QByteArray("public");
- QTest::newRow("return") << QByteArray("return");
- QTest::newRow("short") << QByteArray("short");
- QTest::newRow("static") << QByteArray("static");
- QTest::newRow("super") << QByteArray("super");
- QTest::newRow("switch") << QByteArray("switch");
- QTest::newRow("synchronized") << QByteArray("synchronized");
- QTest::newRow("this") << QByteArray("this");
- QTest::newRow("throw") << QByteArray("throw");
- QTest::newRow("throws") << QByteArray("throws");
- QTest::newRow("transient") << QByteArray("transient");
- QTest::newRow("true") << QByteArray("true");
- QTest::newRow("try") << QByteArray("try");
- QTest::newRow("typeof") << QByteArray("typeof");
- QTest::newRow("var") << QByteArray("var");
- QTest::newRow("void") << QByteArray("void");
- QTest::newRow("volatile") << QByteArray("volatile");
- QTest::newRow("while") << QByteArray("while");
- QTest::newRow("with") << QByteArray("with");
-}
-
-void tst_qdeclarativelanguage::reservedWords()
-{
- QFETCH(QByteArray, word);
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nQtObject { property string " + word + " }", QUrl());
- QCOMPARE(component.errorString(), QLatin1String(":2 Expected token `identifier'\n"));
-}
-
-// 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)
-{
- QDeclarativeComponent component(&engine);
- component.setData(qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports
-
- QTRY_VERIFY(!component.isLoading());
-
- if (type.isEmpty()) {
- QVERIFY(component.isError());
- QString actualerror;
- foreach (const QDeclarativeError e, component.errors()) {
- if (!actualerror.isEmpty())
- actualerror.append("; ");
- actualerror.append(e.description());
- }
- QCOMPARE(actualerror,expectederror);
- } else {
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(QString(object->metaObject()->className()), type);
- delete object;
- }
-}
-
-// QTBUG-17276
-void tst_qdeclarativelanguage::inlineAssignmentsOverrideBindings()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("inlineAssignmentsOverrideBindings.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test").toInt(), 11);
- delete o;
-}
-
-// QTBUG-19354
-void tst_qdeclarativelanguage::nestedComponentRoots()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("nestedComponentRoots.qml"));
-}
-
-// Import tests (QT-558)
-void tst_qdeclarativelanguage::importsBuiltin_data()
-{
- // QT-610
-
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
- QTest::addColumn<QString>("error");
-
- // import built-ins
- QTest::newRow("missing import")
- << "Test {}"
- << ""
- << "Test is not a type";
- QTest::newRow("not in version 0.0")
- << "import com.nokia.Test 0.0\n"
- "Test {}"
- << ""
- << "Test is not a type";
- QTest::newRow("version not installed")
- << "import com.nokia.Test 99.0\n"
- "Test {}"
- << ""
- << "module \"com.nokia.Test\" version 99.0 is not installed";
- QTest::newRow("in version 0.0")
- << "import com.nokia.Test 0.0\n"
- "TestTP {}"
- << "TestType"
- << "";
- QTest::newRow("qualified in version 0.0")
- << "import com.nokia.Test 0.0 as T\n"
- "T.TestTP {}"
- << "TestType"
- << "";
- QTest::newRow("in version 1.0")
- << "import com.nokia.Test 1.0\n"
- "Test {}"
- << "TestType"
- << "";
- QTest::newRow("qualified wrong")
- << "import com.nokia.Test 1.0 as T\n" // QT-610
- "Test {}"
- << ""
- << "Test is not a type";
- QTest::newRow("qualified right")
- << "import com.nokia.Test 1.0 as T\n"
- "T.Test {}"
- << "TestType"
- << "";
- QTest::newRow("qualified right but not in version 0.0")
- << "import com.nokia.Test 0.0 as T\n"
- "T.Test {}"
- << ""
- << "T.Test is not a type";
- QTest::newRow("in version 1.1")
- << "import com.nokia.Test 1.1\n"
- "Test {}"
- << "TestType"
- << "";
- QTest::newRow("in version 1.3")
- << "import com.nokia.Test 1.3\n"
- "Test {}"
- << "TestType"
- << "";
- QTest::newRow("in version 1.5")
- << "import com.nokia.Test 1.5\n"
- "Test {}"
- << "TestType"
- << "";
- QTest::newRow("changed in version 1.8")
- << "import com.nokia.Test 1.8\n"
- "Test {}"
- << "TestType2"
- << "";
- QTest::newRow("in version 1.12")
- << "import com.nokia.Test 1.12\n"
- "Test {}"
- << "TestType2"
- << "";
- QTest::newRow("old in version 1.9")
- << "import com.nokia.Test 1.9\n"
- "OldTest {}"
- << "TestType"
- << "";
- QTest::newRow("old in version 1.11")
- << "import com.nokia.Test 1.11\n"
- "OldTest {}"
- << "TestType"
- << "";
- QTest::newRow("multiversion 1")
- << "import com.nokia.Test 1.11\n"
- "import com.nokia.Test 1.12\n"
- "Test {}"
- << (!qmlCheckTypes()?"TestType2":"")
- << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11");
- QTest::newRow("multiversion 2")
- << "import com.nokia.Test 1.11\n"
- "import com.nokia.Test 1.12\n"
- "OldTest {}"
- << (!qmlCheckTypes()?"TestType":"")
- << (!qmlCheckTypes()?"":"OldTest is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11");
- QTest::newRow("qualified multiversion 3")
- << "import com.nokia.Test 1.0 as T0\n"
- "import com.nokia.Test 1.8 as T8\n"
- "T0.Test {}"
- << "TestType"
- << "";
- QTest::newRow("qualified multiversion 4")
- << "import com.nokia.Test 1.0 as T0\n"
- "import com.nokia.Test 1.8 as T8\n"
- "T8.Test {}"
- << "TestType2"
- << "";
-}
-
-void tst_qdeclarativelanguage::importsBuiltin()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- QFETCH(QString, error);
- testType(qml,type,error);
-}
-
-void tst_qdeclarativelanguage::importsLocal_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
- QTest::addColumn<QString>("error");
-
- // import locals
- QTest::newRow("local import")
- << "import \"subdir\"\n" // QT-613
- "Test {}"
- << "QQuickRectangle"
- << "";
- QTest::newRow("local import second")
- << "import QtQuick 2.0\nimport \"subdir\"\n"
- "Test {}"
- << "QQuickRectangle"
- << "";
- QTest::newRow("local import subsubdir")
- << "import QtQuick 2.0\nimport \"subdir/subsubdir\"\n"
- "SubTest {}"
- << "QQuickRectangle"
- << "";
- QTest::newRow("local import QTBUG-7721 A")
- << "subdir.Test {}" // no longer allowed (QTBUG-7721)
- << ""
- << "subdir.Test - subdir is not a namespace";
- QTest::newRow("local import QTBUG-7721 B")
- << "import \"subdir\" as X\n"
- "X.subsubdir.SubTest {}" // no longer allowed (QTBUG-7721)
- << ""
- << "X.subsubdir.SubTest - nested namespaces not allowed";
- QTest::newRow("local import as")
- << "import \"subdir\" as T\n"
- "T.Test {}"
- << "QQuickRectangle"
- << "";
- QTest::newRow("wrong local import as")
- << "import \"subdir\" as T\n"
- "Test {}"
- << ""
- << "Test is not a type";
- QTest::newRow("library precedence over local import")
- << "import \"subdir\"\n"
- "import com.nokia.Test 1.0\n"
- "Test {}"
- << (!qmlCheckTypes()?"TestType":"")
- << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test and in subdir");
-}
-
-void tst_qdeclarativelanguage::importsLocal()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- QFETCH(QString, error);
- testType(qml,type,error);
-}
-
-void tst_qdeclarativelanguage::basicRemote_data()
-{
- QTest::addColumn<QUrl>("url");
- QTest::addColumn<QString>("type");
- QTest::addColumn<QString>("error");
-
- QString serverdir = "http://127.0.0.1:14447/qtest/declarative/qmllanguage/";
-
- QTest::newRow("no need for qmldir") << QUrl(serverdir+"Test.qml") << "" << "";
- QTest::newRow("absent qmldir") << QUrl(serverdir+"/noqmldir/Test.qml") << "" << "";
- QTest::newRow("need qmldir") << QUrl(serverdir+"TestLocal.qml") << "" << "";
-}
-
-void tst_qdeclarativelanguage::basicRemote()
-{
- QFETCH(QUrl, url);
- QFETCH(QString, type);
- QFETCH(QString, error);
-
- TestHTTPServer server(14447);
- server.serveDirectory(testdata());
-
- QDeclarativeComponent component(&engine, url);
-
- QTRY_VERIFY(!component.isLoading());
-
- if (error.isEmpty()) {
- if (component.isError())
- qDebug() << component.errors();
- QVERIFY(!component.isError());
- } else {
- QVERIFY(component.isError());
- }
-}
-
-void tst_qdeclarativelanguage::importsRemote_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
- QTest::addColumn<QString>("error");
-
- QString serverdir = "http://127.0.0.1:14447/qtest/declarative/qmllanguage";
-
- QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QQuickRectangle"
- << "";
- QTest::newRow("remote import with subdir") << "import \""+serverdir+"\"\nTestSubDir {}" << "QQuickText"
- << "";
- QTest::newRow("remote import with local") << "import \""+serverdir+"\"\nTestLocal {}" << "QQuickImage"
- << "";
- QTest::newRow("wrong remote import with undeclared local") << "import \""+serverdir+"\"\nWrongTestLocal {}" << ""
- << "WrongTestLocal is not a type";
- QTest::newRow("wrong remote import of internal local") << "import \""+serverdir+"\"\nLocalInternal {}" << ""
- << "LocalInternal is not a type";
- QTest::newRow("wrong remote import of undeclared local") << "import \""+serverdir+"\"\nUndeclaredLocal {}" << ""
- << "UndeclaredLocal is not a type";
-}
-
-void tst_qdeclarativelanguage::importsRemote()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- QFETCH(QString, error);
-
- TestHTTPServer server(14447);
- server.serveDirectory(testdata());
-
- testType(qml,type,error);
-}
-
-void tst_qdeclarativelanguage::importsInstalled_data()
-{
- // QT-610
-
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
- QTest::addColumn<QString>("error");
-
- // import installed
- QTest::newRow("installed import 0")
- << "import com.nokia.installedtest0 0.0\n"
- "InstalledTestTP {}"
- << "QQuickRectangle"
- << "";
- QTest::newRow("installed import 0 as TP")
- << "import com.nokia.installedtest0 0.0 as TP\n"
- "TP.InstalledTestTP {}"
- << "QQuickRectangle"
- << "";
- QTest::newRow("installed import 1")
- << "import com.nokia.installedtest 1.0\n"
- "InstalledTest {}"
- << "QQuickRectangle"
- << "";
- QTest::newRow("installed import 2")
- << "import com.nokia.installedtest 1.3\n"
- "InstalledTest {}"
- << "QQuickRectangle"
- << "";
- QTest::newRow("installed import 3")
- << "import com.nokia.installedtest 1.4\n"
- "InstalledTest {}"
- << "QQuickText"
- << "";
- QTest::newRow("installed import minor version not available") // QTBUG-11936
- << "import com.nokia.installedtest 0.1\n"
- "InstalledTest {}"
- << ""
- << "module \"com.nokia.installedtest\" version 0.1 is not installed";
- QTest::newRow("installed import minor version not available") // QTBUG-9627
- << "import com.nokia.installedtest 1.10\n"
- "InstalledTest {}"
- << ""
- << "module \"com.nokia.installedtest\" version 1.10 is not installed";
- QTest::newRow("installed import major version not available") // QTBUG-9627
- << "import com.nokia.installedtest 9.0\n"
- "InstalledTest {}"
- << ""
- << "module \"com.nokia.installedtest\" version 9.0 is not installed";
- QTest::newRow("installed import visibility") // QT-614
- << "import com.nokia.installedtest 1.4\n"
- "PrivateType {}"
- << ""
- << "PrivateType is not a type";
-}
-
-void tst_qdeclarativelanguage::importsInstalled()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- QFETCH(QString, error);
- testType(qml,type,error);
-}
-
-
-void tst_qdeclarativelanguage::importsOrder_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("type");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("double import") <<
- "import com.nokia.installedtest 1.4\n"
- "import com.nokia.installedtest 1.4\n"
- "InstalledTest {}"
- << (!qmlCheckTypes()?"QQuickText":"")
- << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.4");
- QTest::newRow("installed import overrides 1") <<
- "import com.nokia.installedtest 1.0\n"
- "import com.nokia.installedtest 1.4\n"
- "InstalledTest {}"
- << (!qmlCheckTypes()?"QQuickText":"")
- << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0");
- QTest::newRow("installed import overrides 2") <<
- "import com.nokia.installedtest 1.4\n"
- "import com.nokia.installedtest 1.0\n"
- "InstalledTest {}"
- << (!qmlCheckTypes()?"QQuickRectangle":"")
- << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4");
- QTest::newRow("installed import re-overrides 1") <<
- "import com.nokia.installedtest 1.4\n"
- "import com.nokia.installedtest 1.0\n"
- "import com.nokia.installedtest 1.4\n"
- "InstalledTest {}"
- << (!qmlCheckTypes()?"QQuickText":"")
- << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0");
- QTest::newRow("installed import re-overrides 2") <<
- "import com.nokia.installedtest 1.4\n"
- "import com.nokia.installedtest 1.0\n"
- "import com.nokia.installedtest 1.4\n"
- "import com.nokia.installedtest 1.0\n"
- "InstalledTest {}"
- << (!qmlCheckTypes()?"QQuickRectangle":"")
- << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4");
-
- QTest::newRow("installed import versus builtin 1") <<
- "import com.nokia.installedtest 1.5\n"
- "import QtQuick 2.0\n"
- "Rectangle {}"
- << (!qmlCheckTypes()?"QQuickRectangle":"")
- << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in Qt and in lib/com/nokia/installedtest");
- QTest::newRow("installed import versus builtin 2") <<
- "import QtQuick 2.0\n"
- "import com.nokia.installedtest 1.5\n"
- "Rectangle {}"
- << (!qmlCheckTypes()?"QQuickText":"")
- << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in lib/com/nokia/installedtest and in Qt");
- QTest::newRow("namespaces cannot be overridden by types 1") <<
- "import QtQuick 2.0 as Rectangle\n"
- "import com.nokia.installedtest 1.5\n"
- "Rectangle {}"
- << ""
- << "Namespace Rectangle cannot be used as a type";
- QTest::newRow("namespaces cannot be overridden by types 2") <<
- "import QtQuick 2.0 as Rectangle\n"
- "import com.nokia.installedtest 1.5\n"
- "Rectangle.Image {}"
- << "QQuickImage"
- << "";
- QTest::newRow("local last 1") <<
- "LocalLast {}"
- << "QQuickText"
- << "";
- QTest::newRow("local last 2") <<
- "import com.nokia.installedtest 1.0\n"
- "LocalLast {}"
- << (!qmlCheckTypes()?"QQuickRectangle":"")// i.e. from com.nokia.installedtest, not data/LocalLast.qml
- << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/com/nokia/installedtest and in local directory");
-}
-
-void tst_qdeclarativelanguage::importsOrder()
-{
- QFETCH(QString, qml);
- QFETCH(QString, type);
- QFETCH(QString, error);
- testType(qml,type,error);
-}
-
-void tst_qdeclarativelanguage::importIncorrectCase()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("importIncorrectCase.qml"));
-
- QList<QDeclarativeError> errors = component.errors();
- QCOMPARE(errors.count(), 1);
-
-#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
- QString expectedError = QLatin1String("cannot load module \"com.Nokia.installedtest\": File name case mismatch for \"") + testdata("lib/com/Nokia/installedtest/qmldir") + QLatin1String("\"");
-#else
- QString expectedError = QLatin1String("module \"com.Nokia.installedtest\" is not installed");
-#endif
-
- QCOMPARE(errors.at(0).description(), expectedError);
-}
-
-void tst_qdeclarativelanguage::importJs_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("errorFile");
- QTest::addColumn<bool>("performTest");
-
- QTest::newRow("defaultVersion")
- << "importJs.1.qml"
- << "importJs.1.errors.txt"
- << true;
-
- QTest::newRow("specifiedVersion")
- << "importJs.2.qml"
- << "importJs.2.errors.txt"
- << true;
-
- QTest::newRow("excludeExcessiveVersion")
- << "importJs.3.qml"
- << "importJs.3.errors.txt"
- << false;
-
- QTest::newRow("includeAppropriateVersion")
- << "importJs.4.qml"
- << "importJs.4.errors.txt"
- << true;
-
- QTest::newRow("noDefaultVersion")
- << "importJs.5.qml"
- << "importJs.5.errors.txt"
- << false;
-
- QTest::newRow("repeatImportFails")
- << "importJs.6.qml"
- << "importJs.6.errors.txt"
- << false;
-
- QTest::newRow("multipleVersionImportFails")
- << "importJs.7.qml"
- << "importJs.7.errors.txt"
- << false;
-
- QTest::newRow("namespacedImport")
- << "importJs.8.qml"
- << "importJs.8.errors.txt"
- << true;
-
- QTest::newRow("namespacedVersionedImport")
- << "importJs.9.qml"
- << "importJs.9.errors.txt"
- << true;
-
- QTest::newRow("namespacedRepeatImport")
- << "importJs.10.qml"
- << "importJs.10.errors.txt"
- << true;
-}
-
-void tst_qdeclarativelanguage::importJs()
-{
- QFETCH(QString, file);
- QFETCH(QString, errorFile);
- QFETCH(bool, performTest);
-
- QDeclarativeComponent component(&engine, TEST_FILE(file));
-
- {
- DETERMINE_ERRORS(errorFile.toLatin1().constData(),expected,actual);
- QCOMPARE(expected.size(), actual.size());
- for (int i = 0; i < expected.size(); ++i)
- {
- size_t compareLen = std::min(expected.at(i).length(), actual.at(i).length());
- QCOMPARE(expected.at(i).left(compareLen), actual.at(i).left(compareLen));
- }
- }
-
- if (performTest) {
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("test").toBool(),true);
- delete object;
- }
-}
-
-void tst_qdeclarativelanguage::qmlAttachedPropertiesObjectMethod()
-{
- QObject object;
-
- QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, false), (QObject *)0);
- QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, true), (QObject *)0);
-
- {
- QDeclarativeComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.1.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(object, false), (QObject *)0);
- QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, true) != 0);
- }
-
- {
- QDeclarativeComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.2.qml"));
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, false) != 0);
- QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, true) != 0);
- }
-}
-
-void tst_qdeclarativelanguage::crash1()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nComponent {}", QUrl());
-}
-
-void tst_qdeclarativelanguage::crash2()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("crash2.qml"));
-}
-
-// QTBUG-8676
-void tst_qdeclarativelanguage::customOnProperty()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("customOnProperty.qml"));
-
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("on").toInt(), 10);
-
- 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::revisions()
-{
- {
- QDeclarativeComponent component(&engine, TEST_FILE("revisions11.qml"));
-
- VERIFY_ERRORS(0);
- MyRevisionedClass *object = qobject_cast<MyRevisionedClass*>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->prop2(), 10.0);
-
- delete object;
- }
- {
- QDeclarativeEngine myEngine;
- QDeclarativeComponent component(&myEngine, TEST_FILE("revisionssub11.qml"));
-
- VERIFY_ERRORS(0);
- MyRevisionedSubclass *object = qobject_cast<MyRevisionedSubclass*>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->prop1(), 10.0);
- QCOMPARE(object->prop2(), 10.0);
- QCOMPARE(object->prop3(), 10.0);
- QCOMPARE(object->prop4(), 10.0);
-
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, TEST_FILE("versionedbase.qml"));
- VERIFY_ERRORS(0);
- MySubclass *object = qobject_cast<MySubclass*>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->prop1(), 10.0);
- QCOMPARE(object->prop2(), 10.0);
-
- delete object;
- }
-}
-
-void tst_qdeclarativelanguage::revisionOverloads()
-{
- {
- QDeclarativeComponent component(&engine, TEST_FILE("allowedRevisionOverloads.qml"));
- VERIFY_ERRORS(0);
- }
- {
- QDeclarativeComponent component(&engine, TEST_FILE("disallowedRevisionOverloads.qml"));
- QEXPECT_FAIL("", "QTBUG-13849", Abort);
- QVERIFY(0);
- VERIFY_ERRORS("disallowedRevisionOverloads.errors.txt");
- }
-}
-
-void tst_qdeclarativelanguage::initTestCase()
-{
- QString testdataDir = QFileInfo(QFINDTESTDATA("data")).absolutePath();
- QVERIFY2(QDir::setCurrent(testdataDir), qPrintable("Could not chdir to " + testdataDir));
-
- registerTypes();
-
- // Registering the TestType class in other modules should have no adverse effects
- qmlRegisterType<TestType>("com.nokia.TestPre", 1, 0, "Test");
-
- qmlRegisterType<TestType>("com.nokia.Test", 0, 0, "TestTP");
- qmlRegisterType<TestType>("com.nokia.Test", 1, 0, "Test");
- qmlRegisterType<TestType>("com.nokia.Test", 1, 5, "Test");
- qmlRegisterType<TestType2>("com.nokia.Test", 1, 8, "Test");
- qmlRegisterType<TestType>("com.nokia.Test", 1, 9, "OldTest");
- qmlRegisterType<TestType2>("com.nokia.Test", 1, 12, "Test");
-
- // Registering the TestType class in other modules should have no adverse effects
- qmlRegisterType<TestType>("com.nokia.TestPost", 1, 0, "Test");
-
- // Create locale-specific file
- // For POSIX, this will just be data/I18nType.qml, since POSIX is 7-bit
- // For iso8859-1 locale, this will just be data/I18nType?????.qml where ????? is 5 8-bit characters
- // For utf-8 locale, this will be data/I18nType??????????.qml where ?????????? is 5 8-bit characters, UTF-8 encoded
- QFile in(TEST_FILE(QLatin1String("I18nType30.qml")).toLocalFile());
- QVERIFY2(in.open(QIODevice::ReadOnly), qPrintable(QString::fromLatin1("Cannot open '%1': %2").arg(in.fileName(), in.errorString())));
- QFile out(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile());
- QVERIFY2(out.open(QIODevice::WriteOnly), qPrintable(QString::fromLatin1("Cannot open '%1': %2").arg(out.fileName(), out.errorString())));
- out.write(in.readAll());
-}
-
-void tst_qdeclarativelanguage::aliasPropertyChangeSignals()
-{
- {
- QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertyChangeSignals.qml"));
-
- VERIFY_ERRORS(0);
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
- }
-
- // QTCREATORBUG-2769
- {
- QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertyChangeSignals.2.qml"));
-
- VERIFY_ERRORS(0);
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
- }
-}
-
-// Tests property initializers
-void tst_qdeclarativelanguage::propertyInit()
-{
- {
- QDeclarativeComponent component(&engine, TEST_FILE("propertyInit.1.qml"));
-
- VERIFY_ERRORS(0);
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toInt(), 1);
-
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, TEST_FILE("propertyInit.2.qml"));
-
- VERIFY_ERRORS(0);
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toInt(), 123);
-
- delete o;
- }
-}
-
-// Test that registration order doesn't break type availability
-// QTBUG-16878
-void tst_qdeclarativelanguage::registrationOrder()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("registrationOrder.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
- QVERIFY(o->metaObject() == &MyVersion2Class::staticMetaObject);
- delete o;
-}
-
-void tst_qdeclarativelanguage::readonly()
-{
- QDeclarativeComponent component(&engine, TEST_FILE("readonly.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toInt(), 10);
- QCOMPARE(o->property("test2").toInt(), 18);
- QCOMPARE(o->property("test3").toInt(), 13);
-
- o->setProperty("testData", 13);
-
- QCOMPARE(o->property("test1").toInt(), 10);
- QCOMPARE(o->property("test2").toInt(), 22);
- QCOMPARE(o->property("test3").toInt(), 13);
-
- o->setProperty("testData2", 2);
-
- QCOMPARE(o->property("test1").toInt(), 10);
- QCOMPARE(o->property("test2").toInt(), 22);
- QCOMPARE(o->property("test3").toInt(), 2);
-
- o->setProperty("test1", 11);
- o->setProperty("test2", 11);
- o->setProperty("test3", 11);
-
- QCOMPARE(o->property("test1").toInt(), 10);
- QCOMPARE(o->property("test2").toInt(), 22);
- QCOMPARE(o->property("test3").toInt(), 2);
-
- delete o;
-}
-
-// QTBUG-18268
-void tst_qdeclarativelanguage::remoteLoadCrash()
-{
- TestHTTPServer server(14448);
- server.serveDirectory(testdata());
-
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Text {}", QUrl("http://127.0.0.1:14448/remoteLoadCrash.qml"));
- while (component.isLoading())
- QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents, 50);
-
- QObject *o = component.create();
- delete o;
-}
-
-QTEST_MAIN(tst_qdeclarativelanguage)
-
-#include "tst_qdeclarativelanguage.moc"
diff --git a/tests/auto/declarative/qdeclarativelistcompositor/qdeclarativelistcompositor.pro b/tests/auto/declarative/qdeclarativelistcompositor/qdeclarativelistcompositor.pro
deleted file mode 100644
index 3936f4beff..0000000000
--- a/tests/auto/declarative/qdeclarativelistcompositor/qdeclarativelistcompositor.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativelistcompositor
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativelistcompositor.cpp
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/declarative/qdeclarativelistcompositor/tst_qdeclarativelistcompositor.cpp b/tests/auto/declarative/qdeclarativelistcompositor/tst_qdeclarativelistcompositor.cpp
deleted file mode 100644
index 1716bfe2c7..0000000000
--- a/tests/auto/declarative/qdeclarativelistcompositor/tst_qdeclarativelistcompositor.cpp
+++ /dev/null
@@ -1,1637 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <private/qdeclarativelistcompositor_p.h>
-
-template<typename T, int N> int lengthOf(const T (&)[N]) { return N; }
-
-typedef QDeclarativeListCompositor C;
-
-struct Range
-{
- Range() {}
- Range(void *list, int index, int count, int flags)
- : list(list), index(index), count(count), flags(flags) {}
- void *list;
- int index;
- int count;
- int flags;
-};
-
-template <typename T> struct Array
-{
- Array() : array(0), count(0) {}
- template<int N> Array(const T (&array)[N]) : array(array), count(N) {}
-
- T operator [](int index) const { return array[index]; }
-
- const T *array;
- int count;
-};
-
-typedef Array<int> IndexArray;
-typedef Array<const void *> ListArray;
-
-typedef QVector<QDeclarativeListCompositor::Remove> RemoveList;
-typedef QVector<QDeclarativeListCompositor::Insert> InsertList;
-typedef QVector<QDeclarativeListCompositor::Change> ChangeList;
-
-typedef QVector<Range> RangeList;
-
-Q_DECLARE_METATYPE(RangeList)
-Q_DECLARE_METATYPE(RemoveList)
-Q_DECLARE_METATYPE(InsertList)
-Q_DECLARE_METATYPE(ChangeList)
-Q_DECLARE_METATYPE(void *)
-Q_DECLARE_METATYPE(IndexArray)
-Q_DECLARE_METATYPE(ListArray)
-Q_DECLARE_METATYPE(C::Group)
-
-QT_BEGIN_NAMESPACE
-bool operator ==(const C::Change &left, const C::Change &right)
-{
- return left.index[3] == right.index[3]
- && left.index[2] == right.index[2]
- && left.index[1] == right.index[1]
- && left.index[0] == right.index[0]
- && left.count == right.count
- && left.groups() == right.groups()
- && left.inCache() == right.inCache()
- && (left.moveId == -1) == (right.moveId == -1);
-}
-QT_END_NAMESPACE
-
-static const C::Group Visible = C::Group(2);
-static const C::Group Selection = C::Group(3);
-
-class tst_qdeclarativelistcompositor : public QObject
-{
- Q_OBJECT
-
- enum {
- VisibleFlag = 0x04,
- SelectionFlag = 0x08
- };
-
- void populateChange(
- C::Change &change, int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId)
- {
- change.index[Selection] = sIndex;
- change.index[Visible] = vIndex;
- change.index[C::Default] = dIndex;
- change.index[C::Cache] = cIndex;
- change.count = count;
- change.flags = flags;
- change.moveId = moveId;
- }
-
- C::Remove Remove(
- int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId = -1)
- {
- C::Remove remove;
- populateChange(remove, sIndex, vIndex, dIndex, cIndex, count, flags, moveId);
- return remove;
- }
-
- C::Insert Insert(
- int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId = -1)
- {
- C::Insert insert;
- populateChange(insert, sIndex, vIndex, dIndex, cIndex, count, flags, moveId);
- return insert;
- }
-
- C::Change Change(
- int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId = -1)
- {
- C::Change change;
- populateChange(change, sIndex, vIndex, dIndex, cIndex, count, flags, moveId);
- return change;
- }
-
-private slots:
- void find_data();
- void find();
- void findInsertPosition_data();
- void findInsertPosition();
- void insert();
- void clearFlags_data();
- void clearFlags();
- void setFlags_data();
- void setFlags();
- void move_data();
- void move();
- void moveFromEnd();
- void clear();
- void listItemsInserted_data();
- void listItemsInserted();
- void listItemsRemoved_data();
- void listItemsRemoved();
- void listItemsMoved_data();
- void listItemsMoved();
- void listItemsChanged_data();
- void listItemsChanged();
-};
-
-void tst_qdeclarativelistcompositor::find_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<C::Group>("startGroup");
- QTest::addColumn<int>("startIndex");
- QTest::addColumn<C::Group>("group");
- QTest::addColumn<int>("index");
- QTest::addColumn<int>("selectionIndex");
- QTest::addColumn<int>("visibleIndex");
- QTest::addColumn<int>("defaultIndex");
- QTest::addColumn<int>("cacheIndex");
- QTest::addColumn<uint>("rangeFlags");
- QTest::addColumn<int>("rangeIndex");
-
- int listA; void *a = &listA;
-
- QTest::newRow("Start")
- << (RangeList()
- << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 1, 1, int(C::AppendFlag | C::PrependFlag | C::CacheFlag))
- << Range(0, 0, 1, int(VisibleFlag| C::CacheFlag)))
- << C::Cache << 2
- << Selection << 0
- << 0 << 0 << 0 << 0
- << uint(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag) << 0;
-}
-
-void tst_qdeclarativelistcompositor::find()
-{
- QFETCH(RangeList, ranges);
- QFETCH(C::Group, startGroup);
- QFETCH(int, startIndex);
- QFETCH(C::Group, group);
- QFETCH(int, index);
- QFETCH(int, cacheIndex);
- QFETCH(int, defaultIndex);
- QFETCH(int, visibleIndex);
- QFETCH(int, selectionIndex);
- QFETCH(uint, rangeFlags);
- QFETCH(int, rangeIndex);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- compositor.find(startGroup, startIndex);
-
- QDeclarativeListCompositor::iterator it = compositor.find(group, index);
- QCOMPARE(it.index[C::Cache], cacheIndex);
- QCOMPARE(it.index[C::Default], defaultIndex);
- QCOMPARE(it.index[Visible], visibleIndex);
- QCOMPARE(it.index[Selection], selectionIndex);
- QCOMPARE(it->flags, rangeFlags);
- QCOMPARE(it->index, rangeIndex);
-}
-
-void tst_qdeclarativelistcompositor::findInsertPosition_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<C::Group>("group");
- QTest::addColumn<int>("index");
- QTest::addColumn<int>("selectionIndex");
- QTest::addColumn<int>("visibleIndex");
- QTest::addColumn<int>("defaultIndex");
- QTest::addColumn<int>("cacheIndex");
- QTest::addColumn<uint>("rangeFlags");
- QTest::addColumn<int>("rangeIndex");
-
- int listA; void *a = &listA;
-
- QTest::newRow("Start")
- << (RangeList()
- << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 1, 1, int(C::AppendFlag | C::PrependFlag | C::CacheFlag))
- << Range(0, 0, 1, int(VisibleFlag| C::CacheFlag)))
- << Selection << 0
- << 0 << 0 << 0 << 0
- << uint(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag) << 0;
- QTest::newRow("1")
- << (RangeList()
- << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 1, 1, int(C::AppendFlag | C::PrependFlag | C::CacheFlag))
- << Range(0, 0, 1, int(VisibleFlag| C::CacheFlag)))
- << Selection << 1
- << 1 << 0 << 1 << 1
- << uint(C::AppendFlag | C::PrependFlag | C::CacheFlag) << 1;
-}
-
-void tst_qdeclarativelistcompositor::findInsertPosition()
-{
- QFETCH(RangeList, ranges);
- QFETCH(C::Group, group);
- QFETCH(int, index);
- QFETCH(int, cacheIndex);
- QFETCH(int, defaultIndex);
- QFETCH(int, visibleIndex);
- QFETCH(int, selectionIndex);
- QFETCH(uint, rangeFlags);
- QFETCH(int, rangeIndex);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- QDeclarativeListCompositor::insert_iterator it = compositor.findInsertPosition(group, index);
- QCOMPARE(it.index[C::Cache], cacheIndex);
- QCOMPARE(it.index[C::Default], defaultIndex);
- QCOMPARE(it.index[Visible], visibleIndex);
- QCOMPARE(it.index[Selection], selectionIndex);
- QCOMPARE(it->flags, rangeFlags);
- QCOMPARE(it->index, rangeIndex);
-}
-
-void tst_qdeclarativelistcompositor::insert()
-{
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- C::iterator it;
-
- int listA; int *a = &listA;
- int listB; int *b = &listB;
- int listC; int *c = &listC;
-
- {
- compositor.append(a, 0, 12, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
- const int indexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
- const int *lists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
- QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
- for (int i = 0; i < lengthOf(indexes); ++i) {
- it = compositor.find(C::Default, i);
- QCOMPARE(it.list<int>(), lists[i]);
- if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
- }
- } {
- compositor.append(b, 4, 4, C::DefaultFlag);
- const int indexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7};
- const int *lists[] = {a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b};
- QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
- for (int i = 0; i < lengthOf(indexes); ++i) {
- it = compositor.find(C::Default, i);
- QCOMPARE(it.list<int>(), lists[i]);
- if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
- }
- } { // Insert at end.
- compositor.insert(
- C::Default, 16, c, 2, 2, C::DefaultFlag);
- const int indexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
- const int *lists[] = {a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
- QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
- for (int i = 0; i < lengthOf(indexes); ++i) {
- it = compositor.find(C::Default, i);
- QCOMPARE(it.list<int>(), lists[i]);
- if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
- }
- } { // Insert at start
- compositor.insert(
- C::Default, 0, c, 6, 4, C::DefaultFlag);
- const int indexes[] = {6,7,8,9,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
- const int *lists[] = {c,c,c,c,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
- QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
- for (int i = 0; i < lengthOf(indexes); ++i) {
- it = compositor.find(C::Default, i);
- QCOMPARE(it.list<int>(), lists[i]);
- if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
- }
- } { // Insert after static range.
- compositor.insert(
- C::Default, 4, b, 0, 8, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
- const int indexes[] = {6,7,8,9,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
- const int *lists[] = {c,c,c,c,b,b,b,b,b,b,b,b,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
- QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
- for (int i = 0; i < lengthOf(indexes); ++i) {
- it = compositor.find(C::Default, i);
- QCOMPARE(it.list<int>(), lists[i]);
- if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
- }
- } { // Insert at end of dynamic range.
- compositor.insert(
- C::Default, 12, c, 0, 4, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
- const int indexes[] = {6,7,8,9,0,1,2,3,4,5,6,7,0,1,2,3,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
- const int *lists[] = {c,c,c,c,b,b,b,b,b,b,b,b,c,c,c,c,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
- QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
- for (int i = 0; i < lengthOf(indexes); ++i) {
- it = compositor.find(C::Default, i);
- QCOMPARE(it.list<int>(), lists[i]);
- if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
- }
- } { // Insert into range.
- compositor.insert(
- C::Default, 8, c, 0, 4, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
- const int indexes[] = {6,7,8,9,0,1,2,3,0,1,2,3,4,5,6,7,0,1,2,3,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
- const int *lists[] = {c,c,c,c,b,b,b,b,c,c,c,c,b,b,b,b,c,c,c,c,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
- QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
- for (int i = 0; i < lengthOf(indexes); ++i) {
- it = compositor.find(C::Default, i);
- QCOMPARE(it.list<int>(), lists[i]);
- if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
- }
- }
-}
-
-void tst_qdeclarativelistcompositor::clearFlags_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<C::Group>("group");
- QTest::addColumn<int>("index");
- QTest::addColumn<int>("count");
- QTest::addColumn<int>("flags");
- QTest::addColumn<RemoveList>("expectedRemoves");
- QTest::addColumn<IndexArray>("cacheIndexes");
- QTest::addColumn<ListArray>("cacheLists");
- QTest::addColumn<IndexArray>("defaultIndexes");
- QTest::addColumn<ListArray>("defaultLists");
- QTest::addColumn<IndexArray>("visibleIndexes");
- QTest::addColumn<ListArray>("visibleLists");
- QTest::addColumn<IndexArray>("selectionIndexes");
- QTest::addColumn<ListArray>("selectionLists");
-
- int listA; void *a = &listA;
-
- { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
- static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- static const int visibleIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
- static const void *visibleLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0,0};
- static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- QTest::newRow("Default, 2, 2, Selection")
- << (RangeList()
- << Range(a, 0, 12, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(0, 0, 4, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
- << C::Default << 2 << 2 << int(SelectionFlag)
- << (RemoveList()
- << Remove(2, 2, 2, 2, 2, SelectionFlag | C::CacheFlag))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray(selectionIndexes) << ListArray(selectionLists);
- } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
- static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,11,0,0,0,0};
- static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0,0};
- static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- QTest::newRow("Selection, 1, 2, Visible")
- << (RangeList()
- << Range(a, 0, 2, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 4, 8, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(0, 0, 4, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
- << Selection << 1 << 2 << int(VisibleFlag)
- << (RemoveList()
- << Remove(1, 1, 1, 1, 1, VisibleFlag | C::CacheFlag)
- << Remove(2, 3, 4, 4, 1, VisibleFlag | C::CacheFlag))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray(selectionIndexes) << ListArray(selectionLists);
- } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
- static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0};
- static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,11,0,0,0};
- static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0};
- static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0};
- static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0};
- QTest::newRow("Default, 13, 1, Prepend | Selection | Visible | Default")
- << (RangeList()
- << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 1, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 4, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 5, 7, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(0, 0, 4, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
- << C::Default << 13 << 1 << int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag)
- << (RemoveList()
- << Remove(11, 11, 13, 13, 1, SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray(selectionIndexes) << ListArray(selectionLists);
- } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,0};
- static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0};
- static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,11,0,0,0};
- static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0};
- static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0};
- static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0};
- QTest::newRow("Cache, 11, 4, Cache")
- << (RangeList()
- << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 1, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 4, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 5, 7, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(0, 0, 1, int(C::CacheFlag))
- << Range(0, 0, 3, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
- << C::Cache << 11 << 4 << int(C::CacheFlag)
- << (RemoveList())
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray(selectionIndexes) << ListArray(selectionLists);
- } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,0};
- static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,0};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a,0};
- static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,0};
- static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a,0};
- static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,0};
- static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a,0};
- QTest::newRow("Default, 11, 3, Default | Visible | Selection")
- << (RangeList()
- << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 1, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 4, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 5, 6, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << Range(a, 11, 1, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag))
- << Range(0, 0, 2, int(SelectionFlag | VisibleFlag | C::DefaultFlag))
- << Range(0, 0, 1, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
- << C::Default << 11 << 3 << int(C::DefaultFlag | VisibleFlag| SelectionFlag)
- << (RemoveList()
- << Remove(9, 9, 11, 11, 1, SelectionFlag | VisibleFlag | C::DefaultFlag)
- << Remove(9, 9, 11, 11, 2, SelectionFlag | VisibleFlag | C::DefaultFlag))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray(selectionIndexes) << ListArray(selectionLists);
- }
-}
-
-void tst_qdeclarativelistcompositor::clearFlags()
-{
- QFETCH(RangeList, ranges);
- QFETCH(C::Group, group);
- QFETCH(int, index);
- QFETCH(int, count);
- QFETCH(int, flags);
- QFETCH(RemoveList, expectedRemoves);
- QFETCH(IndexArray, cacheIndexes);
- QFETCH(ListArray, cacheLists);
- QFETCH(IndexArray, defaultIndexes);
- QFETCH(ListArray, defaultLists);
- QFETCH(IndexArray, visibleIndexes);
- QFETCH(ListArray, visibleLists);
- QFETCH(IndexArray, selectionIndexes);
- QFETCH(ListArray, selectionLists);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- QVector<C::Remove> removes;
- compositor.clearFlags(group, index, count, flags, &removes);
-
- QCOMPARE(removes, expectedRemoves);
-
- QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
- for (int i = 0; i < cacheIndexes.count; ++i) {
- C::iterator it = compositor.find(C::Cache, i);
- QCOMPARE(it->list, cacheLists[i]);
- if (cacheLists[i])
- QCOMPARE(it.modelIndex(), cacheIndexes[i]);
- }
- QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
- for (int i = 0; i < defaultIndexes.count; ++i) {
- C::iterator it = compositor.find(C::Default, i);
- QCOMPARE(it->list, defaultLists[i]);
- if (defaultLists[i])
- QCOMPARE(it.modelIndex(), defaultIndexes[i]);
- }
- QCOMPARE(compositor.count(Visible), visibleIndexes.count);
- for (int i = 0; i < visibleIndexes.count; ++i) {
- C::iterator it = compositor.find(Visible, i);
- QCOMPARE(it->list, visibleLists[i]);
- if (visibleLists[i])
- QCOMPARE(it.modelIndex(), visibleIndexes[i]);
- }
- QCOMPARE(compositor.count(Selection), selectionIndexes.count);
- for (int i = 0; i < selectionIndexes.count; ++i) {
- C::iterator it = compositor.find(Selection, i);
- QCOMPARE(it->list, selectionLists[i]);
- if (selectionLists[i])
- QCOMPARE(it.modelIndex(), selectionIndexes[i]);
- }
-}
-
-void tst_qdeclarativelistcompositor::setFlags_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<C::Group>("group");
- QTest::addColumn<int>("index");
- QTest::addColumn<int>("count");
- QTest::addColumn<int>("flags");
- QTest::addColumn<InsertList>("expectedInserts");
- QTest::addColumn<IndexArray>("cacheIndexes");
- QTest::addColumn<ListArray>("cacheLists");
- QTest::addColumn<IndexArray>("defaultIndexes");
- QTest::addColumn<ListArray>("defaultLists");
- QTest::addColumn<IndexArray>("visibleIndexes");
- QTest::addColumn<ListArray>("visibleLists");
- QTest::addColumn<IndexArray>("selectionIndexes");
- QTest::addColumn<ListArray>("selectionLists");
-
- int listA; void *a = &listA;
-
- { static const int cacheIndexes[] = {0,0,0,0};
- static const void *cacheLists[] = {0,0,0,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
- QTest::newRow("Default, 2, 2, Default")
- << (RangeList()
- << Range(a, 0, 12, C::DefaultFlag)
- << Range(0, 0, 4, C::CacheFlag))
- << C::Default << 2 << 2 << int(C::DefaultFlag)
- << (InsertList())
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray() << ListArray()
- << IndexArray() << ListArray();
- } { static const int cacheIndexes[] = {0,0,0,0};
- static const void *cacheLists[] = {0,0,0,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
- static const int visibleIndexes[] = {2,3};
- static const void *visibleLists[] = {a,a};
- QTest::newRow("Default, 2, 2, Visible")
- << (RangeList()
- << Range(a, 0, 12, C::DefaultFlag)
- << Range(0, 0, 4, C::CacheFlag))
- << C::Default << 2 << 2 << int(VisibleFlag)
- << (InsertList()
- << Insert(0, 0, 2, 0, 2, VisibleFlag))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray() << ListArray();
- } { static const int cacheIndexes[] = {3,6,0,0,0,0};
- static const void *cacheLists[] = {a,a,0,0,0,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
- static const int visibleIndexes[] = {2,3,6,7};
- static const void *visibleLists[] = {a,a,a,a};
- static const int selectionIndexes[] = {3,6};
- static const void *selectionLists[] = {a,a};
- QTest::newRow("Visible, 1, 2, Selection | Cache")
- << (RangeList()
- << Range(a, 0, 2, C::DefaultFlag)
- << Range(a, 2, 2, VisibleFlag | C::DefaultFlag)
- << Range(a, 4, 2, C::DefaultFlag)
- << Range(a, 6, 2, VisibleFlag | C::DefaultFlag)
- << Range(a, 8, 4, C::DefaultFlag)
- << Range(0, 0, 4, C::CacheFlag))
- << Visible << 1 << 2 << int(SelectionFlag | C::CacheFlag)
- << (InsertList()
- << Insert(0, 1, 3, 0, 1, SelectionFlag | C::CacheFlag)
- << Insert(1, 2, 6, 1, 1, SelectionFlag | C::CacheFlag))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray(selectionIndexes) << ListArray(selectionLists);
- } { static const int cacheIndexes[] = {3,6,0,0,0,0};
- static const void *cacheLists[] = {a,a,0,0,0,0};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
- static const int visibleIndexes[] = {2,3,6,7,0};
- static const void *visibleLists[] = {a,a,a,a,0};
- static const int selectionIndexes[] = {3,6};
- static const void *selectionLists[] = {a,a};
- QTest::newRow("Cache, 3, 1, Visible")
- << (RangeList()
- << Range(a, 0, 2, C::DefaultFlag)
- << Range(a, 2, 1, VisibleFlag | C::DefaultFlag)
- << Range(a, 3, 1, SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 4, 2, C::DefaultFlag)
- << Range(a, 6, 1, SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 7, 1, VisibleFlag | C::DefaultFlag)
- << Range(a, 8, 4, C::DefaultFlag)
- << Range(0, 0, 4, C::CacheFlag))
- << C::Cache << 3 << 1 << int(VisibleFlag)
- << (InsertList()
- << Insert(2, 4, 12, 3, 1, VisibleFlag | C::CacheFlag))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray(selectionIndexes) << ListArray(selectionLists);
- } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
- static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
- static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
- static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
- static const int visibleIndexes[] = {0,1,3,4,5,6,7,8,9,10,11};
- static const void *visibleLists[] = {a,a,a,a,a,a,a,a,a, a, a};
- static const int selectionIndexes[] = {2,6,7,8,9};
- static const void *selectionLists[] = {a,a,a,a,a};
- QTest::newRow("Existing flag, sparse selection")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 2, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 3, 3, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 6, 4, C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a,10, 2, C::AppendFlag | C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
- << C::Cache << 3 << 1 << int(VisibleFlag)
- << InsertList()
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray(selectionIndexes) << ListArray(selectionLists);
- }
-}
-
-void tst_qdeclarativelistcompositor::setFlags()
-{
- QFETCH(RangeList, ranges);
- QFETCH(C::Group, group);
- QFETCH(int, index);
- QFETCH(int, count);
- QFETCH(int, flags);
- QFETCH(InsertList, expectedInserts);
- QFETCH(IndexArray, cacheIndexes);
- QFETCH(ListArray, cacheLists);
- QFETCH(IndexArray, defaultIndexes);
- QFETCH(ListArray, defaultLists);
- QFETCH(IndexArray, visibleIndexes);
- QFETCH(ListArray, visibleLists);
- QFETCH(IndexArray, selectionIndexes);
- QFETCH(ListArray, selectionLists);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- QVector<C::Insert> inserts;
- compositor.setFlags(group, index, count, flags, &inserts);
-
- QCOMPARE(inserts, expectedInserts);
-
- QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
- for (int i = 0; i < cacheIndexes.count; ++i) {
- C::iterator it = compositor.find(C::Cache, i);
- QCOMPARE(it->list, cacheLists[i]);
- if (cacheLists[i])
- QCOMPARE(it.modelIndex(), cacheIndexes[i]);
- }
- QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
- for (int i = 0; i < defaultIndexes.count; ++i) {
- C::iterator it = compositor.find(C::Default, i);
- QCOMPARE(it->list, defaultLists[i]);
- if (defaultLists[i])
- QCOMPARE(it.modelIndex(), defaultIndexes[i]);
- }
- QCOMPARE(compositor.count(Visible), visibleIndexes.count);
- for (int i = 0; i < visibleIndexes.count; ++i) {
- C::iterator it = compositor.find(Visible, i);
- QCOMPARE(it->list, visibleLists[i]);
- if (visibleLists[i])
- QCOMPARE(it.modelIndex(), visibleIndexes[i]);
- }
- QCOMPARE(compositor.count(Selection), selectionIndexes.count);
- for (int i = 0; i < selectionIndexes.count; ++i) {
- C::iterator it = compositor.find(Selection, i);
- QCOMPARE(it->list, selectionLists[i]);
- if (selectionLists[i])
- QCOMPARE(it.modelIndex(), selectionIndexes[i]);
- }
-}
-
-void tst_qdeclarativelistcompositor::move_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<C::Group>("fromGroup");
- QTest::addColumn<int>("from");
- QTest::addColumn<C::Group>("toGroup");
- QTest::addColumn<int>("to");
- QTest::addColumn<int>("count");
- QTest::addColumn<RemoveList>("expectedRemoves");
- QTest::addColumn<InsertList>("expectedInserts");
- QTest::addColumn<IndexArray>("cacheIndexes");
- QTest::addColumn<ListArray>("cacheLists");
- QTest::addColumn<IndexArray>("defaultIndexes");
- QTest::addColumn<ListArray>("defaultLists");
- QTest::addColumn<IndexArray>("visibleIndexes");
- QTest::addColumn<ListArray>("visibleLists");
- QTest::addColumn<IndexArray>("selectionIndexes");
- QTest::addColumn<ListArray>("selectionLists");
-
- int listA; void *a = &listA;
- int listB; void *b = &listB;
- int listC; void *c = &listC;
-
- { static const int cacheIndexes[] = {0,0,0,0,2,3};
- static const void *cacheLists[] = {0,0,0,0,c,c};
- static const int defaultIndexes[] = {0,0,1,2,3,4,5,0,1,2,3,4,5,1,2,3,0,1,2,3,4,5};
- static const void *defaultLists[] = {0,a,a,a,a,a,a,b,b,b,b,b,b,0,0,0,c,c,c,c,c,c};
- QTest::newRow("15, 0, 1")
- << (RangeList()
- << Range(a, 0, 6, C::DefaultFlag)
- << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(0, 0, 4, C::DefaultFlag | C::CacheFlag)
- << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
- << C::Default << 15 << C::Default << 0 << 1
- << (RemoveList()
- << Remove(0, 0, 15, 3, 1, C::DefaultFlag | C::CacheFlag, 0))
- << (InsertList()
- << Insert(0, 0, 0, 0, 1, C::DefaultFlag | C::CacheFlag, 0))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray() << ListArray()
- << IndexArray() << ListArray();
- } { static const int cacheIndexes[] = {0,0,0,0,2,3};
- static const void *cacheLists[] = {0,0,0,0,c,c};
- static const int defaultIndexes[] = {0,1,0,1,2,3,4,5,0,1,2,3,4,5,2,3,0,1,2,3,4,5};
- static const void *defaultLists[] = {0,0,a,a,a,a,a,a,b,b,b,b,b,b,0,0,c,c,c,c,c,c};
- QTest::newRow("15, 1, 1")
- << (RangeList()
- << Range(0, 0, 1, C::DefaultFlag | C::CacheFlag)
- << Range(a, 0, 6, C::DefaultFlag)
- << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(0, 0, 3, C::DefaultFlag | C::CacheFlag)
- << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
- << C::Default << 15 << C::Default << 1 << 1
- << (RemoveList()
- << Remove(0, 0, 15, 3, 1, C::DefaultFlag | C::CacheFlag, 0))
- << (InsertList()
- << Insert(0, 0, 1, 1, 1, C::DefaultFlag | C::CacheFlag, 0))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray() << ListArray()
- << IndexArray() << ListArray();
- } { static const int cacheIndexes[] = {0,0,0,0,2,3};
- static const void *cacheLists[] = {0,0,0,0,c,c};
- static const int defaultIndexes[] = {0,1,2,0,1,3,4,5,0,1,2,3,4,5,2,3,0,1,2,3,4,5};
- static const void *defaultLists[] = {a,a,a,0,0,a,a,a,b,b,b,b,b,b,0,0,c,c,c,c,c,c};
- QTest::newRow("0, 3, 2")
- << (RangeList()
- << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
- << Range(a, 0, 6, C::DefaultFlag)
- << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
- << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
- << C::Default << 0 << C::Default << 3 << 2
- << (RemoveList()
- << Remove(0, 0, 0, 0, 2, C::DefaultFlag | C::CacheFlag, 0))
- << (InsertList()
- << Insert(0, 0, 3, 0, 2, C::DefaultFlag | C::CacheFlag, 0))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray() << ListArray()
- << IndexArray() << ListArray();
- } { static const int cacheIndexes[] = {0,0,0,0,2,3};
- static const void *cacheLists[] = {0,0,0,0,c,c};
- static const int defaultIndexes[] = {0,5,0,1,2,3,4,5,0,1,0,1,2,2,3,3,4,1,2,3,4,5};
- static const void *defaultLists[] = {a,a,b,b,b,b,b,b,0,0,c,a,a,0,0,a,a,c,c,c,c,c};
- QTest::newRow("7, 1, 10")
- << (RangeList()
- << Range(a, 0, 3, C::DefaultFlag)
- << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
- << Range(a, 3, 3, C::DefaultFlag)
- << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
- << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
- << C::Default << 7 << C::Default << 1 << 10
- << (RemoveList()
- << Remove(0, 0, 7, 2, 1, C::DefaultFlag, 0)
- << Remove(0, 0, 7, 2, 6, C::DefaultFlag, 1)
- << Remove(0, 0, 7, 2, 2, C::DefaultFlag | C::CacheFlag, 2)
- << Remove(0, 0, 7, 2, 1, C::DefaultFlag, 3))
- << (InsertList()
- << Insert(0, 0, 1, 0, 1, C::DefaultFlag, 0)
- << Insert(0, 0, 2, 0, 6, C::DefaultFlag, 1)
- << Insert(0, 0, 8, 0, 2, C::DefaultFlag | C::CacheFlag, 2)
- << Insert(0, 0, 10, 2, 1, C::DefaultFlag, 3))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray() << ListArray()
- << IndexArray() << ListArray();
- } { static const int cacheIndexes[] = {0,0,0,0,3,2};
- static const void *cacheLists[] = {0,0,0,0,c,c};
- static const int defaultIndexes[] = {0,5,0,1,2,3,4,5,0,1,0,1,2,2,3,3,4,3,4,5,1,2};
- static const void *defaultLists[] = {a,a,b,b,b,b,b,b,0,0,c,a,a,0,0,a,a,c,c,c,c,c};
- QTest::newRow("17, 20, 2")
- << (RangeList()
- << Range(a, 0, 1, C::DefaultFlag)
- << Range(a, 5, 1, C::DefaultFlag)
- << Range(b, 0, 6, C::DefaultFlag)
- << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
- << Range(c, 0, 1, C::DefaultFlag)
- << Range(a, 1, 2, C::DefaultFlag)
- << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
- << Range(a, 3, 2, C::DefaultFlag)
- << Range(b, 0, 6, C::AppendFlag | C::PrependFlag)
- << Range(c, 0, 1, C::PrependFlag)
- << Range(c, 1, 1, C::PrependFlag | C::DefaultFlag)
- << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
- << C::Default << 17 << C::Default << 20 << 2
- << (RemoveList()
- << Remove(0, 0, 17, 4, 1, C::DefaultFlag, 0)
- << Remove(0, 0, 17, 4, 1, C::DefaultFlag | C::CacheFlag, 1))
- << (InsertList()
- << Insert(0, 0, 20, 5, 1, C::DefaultFlag, 0)
- << Insert(0, 0, 21, 5, 1, C::DefaultFlag | C::CacheFlag, 1))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray() << ListArray()
- << IndexArray() << ListArray();
- } { static const int cacheIndexes[] = {8,9,10,4,11,0,1,2,3,5,6,7};
- static const void *cacheLists[] = {a,a, a,a, a,a,a,a,a,a,a,a};
- static const int defaultIndexes[] = {8,9,10,4,11,0,1,2,3,5,6,7};
- static const void *defaultLists[] = {a,a, a,a, a,a,a,a,a,a,a,a};
- static const int visibleIndexes[] = {8,9,10,4,11,0,1,2,3,5,6,7};
- static const void *visibleLists[] = {a,a, a,a, a,a,a,a,a,a,a,a};
- QTest::newRow("3, 4, 5")
- << (RangeList()
- << Range(a, 8, 4, VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 2, 1, C::PrependFlag)
- << Range(a, 2, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 3, 5, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 8, 4, C::AppendFlag | C::PrependFlag))
- << C::Default << 3 << C::Default << 4 << 5
- << (RemoveList()
- << Remove(0, 3, 3, 3, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 0)
- << Remove(0, 3, 3, 3, 2, VisibleFlag | C::DefaultFlag | C::CacheFlag, 1)
- << Remove(0, 3, 3, 3, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 2)
- << Remove(0, 3, 3, 3, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 3))
- << (InsertList()
- << Insert(0, 4, 4, 4, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 0)
- << Insert(0, 5, 5, 5, 2, VisibleFlag | C::DefaultFlag | C::CacheFlag, 1)
- << Insert(0, 7, 7, 7, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 2)
- << Insert(0, 8, 8, 8, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 3))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray(visibleIndexes) << ListArray(visibleLists)
- << IndexArray() << ListArray();
- } { static const int cacheIndexes[] = {0,1};
- static const void *cacheLists[] = {a,a};
- static const int defaultIndexes[] = {0,1};
- static const void *defaultLists[] = {a,a};
- QTest::newRow("0, 1, 1")
- << (RangeList()
- << Range(a, 0, 1, C::PrependFlag)
- << Range(a, 1, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 2, 0, C::AppendFlag | C::PrependFlag)
- << Range(a, 0, 1, C::DefaultFlag | C::CacheFlag))
- << C::Default << 0 << C::Default << 1 << 1
- << (RemoveList()
- << Remove(0, 0, 0, 0, 1, C::DefaultFlag | C::CacheFlag, 0))
- << (InsertList()
- << Insert(0, 0, 1, 1, 1, C::DefaultFlag | C::CacheFlag, 0))
- << IndexArray(cacheIndexes) << ListArray(cacheLists)
- << IndexArray(defaultIndexes) << ListArray(defaultLists)
- << IndexArray() << ListArray()
- << IndexArray() << ListArray();
- }
-}
-
-void tst_qdeclarativelistcompositor::move()
-{
- QFETCH(RangeList, ranges);
- QFETCH(C::Group, fromGroup);
- QFETCH(int, from);
- QFETCH(C::Group, toGroup);
- QFETCH(int, to);
- QFETCH(int, count);
- QFETCH(RemoveList, expectedRemoves);
- QFETCH(InsertList, expectedInserts);
- QFETCH(IndexArray, cacheIndexes);
- QFETCH(ListArray, cacheLists);
- QFETCH(IndexArray, defaultIndexes);
- QFETCH(ListArray, defaultLists);
- QFETCH(IndexArray, visibleIndexes);
- QFETCH(ListArray, visibleLists);
- QFETCH(IndexArray, selectionIndexes);
- QFETCH(ListArray, selectionLists);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- QVector<C::Remove> removes;
- QVector<C::Insert> inserts;
- compositor.move(fromGroup, from, toGroup, to, count, fromGroup, &removes, &inserts);
-
- QCOMPARE(removes, expectedRemoves);
- QCOMPARE(inserts, expectedInserts);
-
- QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
- for (int i = 0; i < cacheIndexes.count; ++i) {
- C::iterator it = compositor.find(C::Cache, i);
- QCOMPARE(it->list, cacheLists[i]);
- if (cacheLists[i])
- QCOMPARE(it.modelIndex(), cacheIndexes[i]);
- }
- QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
- for (int i = 0; i < defaultIndexes.count; ++i) {
- C::iterator it = compositor.find(C::Default, i);
- QCOMPARE(it->list, defaultLists[i]);
- if (defaultLists[i])
- QCOMPARE(it.modelIndex(), defaultIndexes[i]);
- }
- QCOMPARE(compositor.count(Visible), visibleIndexes.count);
- for (int i = 0; i < visibleIndexes.count; ++i) {
- C::iterator it = compositor.find(Visible, i);
- QCOMPARE(it->list, visibleLists[i]);
- if (visibleLists[i])
- QCOMPARE(it.modelIndex(), visibleIndexes[i]);
- }
- QCOMPARE(compositor.count(Selection), selectionIndexes.count);
- for (int i = 0; i < selectionIndexes.count; ++i) {
- C::iterator it = compositor.find(Selection, i);
- QCOMPARE(it->list, selectionLists[i]);
- if (selectionLists[i])
- QCOMPARE(it.modelIndex(), selectionIndexes[i]);
- }
-}
-
-void tst_qdeclarativelistcompositor::moveFromEnd()
-{
- int listA; void *a = &listA;
-
- QDeclarativeListCompositor compositor;
- compositor.append(a, 0, 1, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
-
- // Moving an item anchors it to that position.
- compositor.move(C::Default, 0, C::Default, 0, 1, C::Default);
-
- // The existing item is anchored at 0 so prepending an item to the source will append it here
- QVector<C::Insert> inserts;
- compositor.listItemsInserted(a, 0, 1, &inserts);
-
- QCOMPARE(inserts.count(), 1);
- QCOMPARE(inserts.at(0).index[1], 1);
- QCOMPARE(inserts.at(0).count, 1);
-
- C::iterator it;
- it = compositor.find(C::Default, 0);
- QCOMPARE(it.modelIndex(), 1);
-
- it = compositor.find(C::Default, 1);
- QCOMPARE(it.modelIndex(), 0);
-}
-
-void tst_qdeclarativelistcompositor::clear()
-{
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- int listA; void *a = &listA;
- int listB; void *b = &listB;
-
- compositor.append(a, 0, 8, C::AppendFlag | C::PrependFlag | VisibleFlag | C::DefaultFlag);
- compositor.append(b, 4, 5, VisibleFlag | C::DefaultFlag);
- compositor.append(0, 0, 3, VisibleFlag | C::DefaultFlag | C::CacheFlag);
-
- QCOMPARE(compositor.count(C::Default), 16);
- QCOMPARE(compositor.count(Visible), 16);
- QCOMPARE(compositor.count(C::Cache), 3);
-
- compositor.clear();
- QCOMPARE(compositor.count(C::Default), 0);
- QCOMPARE(compositor.count(Visible), 0);
- QCOMPARE(compositor.count(C::Cache), 0);
-}
-
-void tst_qdeclarativelistcompositor::listItemsInserted_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<void *>("list");
- QTest::addColumn<int>("index");
- QTest::addColumn<int>("count");
- QTest::addColumn<InsertList>("expectedInserts");
- QTest::addColumn<IndexArray>("cacheIndexes");
- QTest::addColumn<IndexArray>("defaultIndexes");
- QTest::addColumn<IndexArray>("visibleIndexes");
- QTest::addColumn<IndexArray>("selectionIndexes");
-
- int listA; void *a = &listA;
- int listB; void *b = &listB;
-
- { static const int defaultIndexes[] = {/*A*/0,1,5,6,/*B*/0,1,2,3,/*A*/2,3,4};
- QTest::newRow("A 10, 2")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 2, 3, C::PrependFlag)
- << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 2, 3, C::DefaultFlag))
- << a << 10 << 2
- << InsertList()
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int defaultIndexes[] = {/*A*/0,1,5,6,/*B*/0,1,2,3,/*A*/2,3,4};
- QTest::newRow("B 10, 2")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 2, 3, C::PrependFlag)
- << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 2, 3, C::DefaultFlag))
- << b << 10 << 2
- << InsertList()
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int defaultIndexes[] = {/*A*/0,1,2,3,7,8,/*B*/0,1,2,3,/*A*/4,5,6};
- static const int visibleIndexes[] = {/*A*/0,1};
- QTest::newRow("A 0, 2")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 2, 3, C::PrependFlag)
- << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 2, 3, C::DefaultFlag))
- << a << 0 << 2
- << (InsertList()
- << Insert(0, 0, 0, 0, 2, VisibleFlag | C::DefaultFlag))
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray(visibleIndexes)
- << IndexArray();
- } { static const int defaultIndexes[] = {/*A*/0,1,2,3,5,8,9,/*B*/0,1,2,3,/*A*/4,6,7};
- static const int visibleIndexes[] = {/*A*/0,1,5};
- QTest::newRow("A 5, 1")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag)
- << Range(a, 2, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 4, 3, C::PrependFlag)
- << Range(a, 7, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 4, 3, C::DefaultFlag))
- << a << 5 << 1
- << (InsertList()
- << Insert(0, 2, 4, 0, 1, VisibleFlag | C::DefaultFlag))
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray(visibleIndexes)
- << IndexArray();
- } { static const int defaultIndexes[] = {/*A*/0,1,2,3,5,8,9,10,11,/*B*/0,1,2,3,/*A*/4,6,7};
- static const int visibleIndexes[] = {/*A*/0,1,5,10,11};
- QTest::newRow("A 10, 2")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag)
- << Range(a, 2, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 4, 1, C::PrependFlag)
- << Range(a, 5, 1, C::PrependFlag | VisibleFlag | C::DefaultFlag)
- << Range(a, 6, 2, C::PrependFlag)
- << Range(a, 8, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 4, 1, C::DefaultFlag)
- << Range(a, 6, 2, C::DefaultFlag))
- << a << 10 << 2
- << (InsertList()
- << Insert(0, 3, 7, 0, 2, VisibleFlag | C::DefaultFlag))
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray(visibleIndexes)
- << IndexArray();
- } { static const int cacheIndexes[] = {/*A*/0,1,-1,-1,-1,2,5,6,7,8,9};
- static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7,8,9};
- static const int visibleIndexes[] = {/*A*/3,4};
- QTest::newRow("Insert after remove")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 2, 3, C::CacheFlag)
- << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
- << a << 3 << 2
- << (InsertList()
- << Insert(0, 0, 3, 6, 2, VisibleFlag | C::DefaultFlag))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray(visibleIndexes)
- << IndexArray();
- } { static const int cacheIndexes[] = {/*A*/0,1,2,3,4};
- static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6};
- static const int visibleIndexes[] = {/*A*/0,1,2,3,4,5,6};
- QTest::newRow("Consecutive appends")
- << (RangeList()
- << Range(a, 0, 5, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 5, 1, C::PrependFlag | VisibleFlag | C::DefaultFlag)
- << Range(a, 6, 0, C::AppendFlag | VisibleFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
- << a << 6 << 1
- << (InsertList()
- << Insert(0, 6, 6, 5, 1, VisibleFlag | C::DefaultFlag))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray(visibleIndexes)
- << IndexArray();
- }
-}
-
-void tst_qdeclarativelistcompositor::listItemsInserted()
-{
- QFETCH(RangeList, ranges);
- QFETCH(void *, list);
- QFETCH(int, index);
- QFETCH(int, count);
- QFETCH(InsertList, expectedInserts);
- QFETCH(IndexArray, cacheIndexes);
- QFETCH(IndexArray, defaultIndexes);
- QFETCH(IndexArray, visibleIndexes);
- QFETCH(IndexArray, selectionIndexes);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- QVector<C::Insert> inserts;
- compositor.listItemsInserted(list, index, count, &inserts);
-
- QCOMPARE(inserts, expectedInserts);
-
- QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
- for (int i = 0; i < cacheIndexes.count; ++i) {
- if (cacheIndexes[i] != -1) {
- QCOMPARE(compositor.find(C::Cache, i).modelIndex(), cacheIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
- for (int i = 0; i < defaultIndexes.count; ++i) {
- if (defaultIndexes[i] != -1) {
- QCOMPARE(compositor.find(C::Default, i).modelIndex(), defaultIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(Visible), visibleIndexes.count);
- for (int i = 0; i < visibleIndexes.count; ++i) {
- if (visibleIndexes[i] != -1) {
- QCOMPARE(compositor.find(Visible, i).modelIndex(), visibleIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(Selection), selectionIndexes.count);
- for (int i = 0; i < selectionIndexes.count; ++i) {
- if (selectionIndexes[i] != -1) {
- QCOMPARE(compositor.find(Selection, i).modelIndex(), selectionIndexes[i]);
- }
- }
-}
-
-void tst_qdeclarativelistcompositor::listItemsRemoved_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<void *>("list");
- QTest::addColumn<int>("index");
- QTest::addColumn<int>("count");
- QTest::addColumn<RemoveList>("expectedRemoves");
- QTest::addColumn<IndexArray>("cacheIndexes");
- QTest::addColumn<IndexArray>("defaultIndexes");
- QTest::addColumn<IndexArray>("visibleIndexes");
- QTest::addColumn<IndexArray>("selectionIndexes");
-
- int listA; void *a = &listA;
- int listB; void *b = &listB;
-
- { static const int defaultIndexes[] = {/*A*/0,1,5,6,/*B*/0,1,2,3,/*A*/2,3,4};
- QTest::newRow("12, 2")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 2, 3, C::PrependFlag)
- << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 2, 3, C::DefaultFlag))
- << a << 12 << 2
- << RemoveList()
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int defaultIndexes[] = {/*A*/0,1,/*B*/0,1,2,3,/*A*/2,3};
- QTest::newRow("4, 3")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 2, 3, C::PrependFlag)
- << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 2, 3, C::DefaultFlag))
- << a << 4 << 3
- << (RemoveList()
- << Remove(0, 0, 2, 0, 2, C::DefaultFlag)
- << Remove(0, 0, 8, 0, 1, C::DefaultFlag))
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int cacheIndexes[] = {/*A*/0,1,-1,-1,-1,2,-1,-1,3,4,5};
- static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5};
- QTest::newRow("Remove after remove")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 2, 3, C::CacheFlag)
- << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
- << a << 3 << 2
- << (RemoveList()
- << Remove(0, 0, 3, 6, 2, C::DefaultFlag | C::CacheFlag))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int cacheIndexes[] = {/*A*/-1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1};
- static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6};
- QTest::newRow("Sparse remove")
- << (RangeList()
- << Range(a, 0, 2, C::CacheFlag)
- << Range(a, 0, 1, C::DefaultFlag | C::CacheFlag)
- << Range(a, 0, 1, C::CacheFlag)
- << Range(a, 1, 5, C::DefaultFlag | C::CacheFlag)
- << Range(a, 0, 1, C::CacheFlag)
- << Range(a, 6, 2, C::DefaultFlag | C::CacheFlag)
- << Range(a, 0, 1, C::CacheFlag)
- << Range(a, 8, 3, C::DefaultFlag | C::CacheFlag)
- << Range(a, 0, 1, C::CacheFlag)
- << Range(a, 11, 1, C::DefaultFlag | C::CacheFlag)
- << Range(a, 12, 5, C::DefaultFlag))
- << a << 1 << 10
- << (RemoveList()
- << Remove(0, 0, 1, 4, 5, C::DefaultFlag | C::CacheFlag)
- << Remove(0, 0, 1,10, 2, C::DefaultFlag | C::CacheFlag)
- << Remove(0, 0, 1,13, 3, C::DefaultFlag | C::CacheFlag))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- }
-}
-
-void tst_qdeclarativelistcompositor::listItemsRemoved()
-{
- QFETCH(RangeList, ranges);
- QFETCH(void *, list);
- QFETCH(int, index);
- QFETCH(int, count);
- QFETCH(RemoveList, expectedRemoves);
- QFETCH(IndexArray, cacheIndexes);
- QFETCH(IndexArray, defaultIndexes);
- QFETCH(IndexArray, visibleIndexes);
- QFETCH(IndexArray, selectionIndexes);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- QVector<C::Remove> removes;
- compositor.listItemsRemoved(list, index, count, &removes);
-
- QCOMPARE(removes, expectedRemoves);
-
- QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
- for (int i = 0; i < cacheIndexes.count; ++i) {
- if (cacheIndexes[i] != -1) {
- QCOMPARE(compositor.find(C::Cache, i).modelIndex(), cacheIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
- for (int i = 0; i < defaultIndexes.count; ++i) {
- if (defaultIndexes[i] != -1) {
- QCOMPARE(compositor.find(C::Default, i).modelIndex(), defaultIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(Visible), visibleIndexes.count);
- for (int i = 0; i < visibleIndexes.count; ++i) {
- if (visibleIndexes[i] != -1) {
- QCOMPARE(compositor.find(Visible, i).modelIndex(), visibleIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(Selection), selectionIndexes.count);
- for (int i = 0; i < selectionIndexes.count; ++i) {
- if (selectionIndexes[i] != -1) {
- QCOMPARE(compositor.find(Selection, i).modelIndex(), selectionIndexes[i]);
- }
- }
-}
-
-void tst_qdeclarativelistcompositor::listItemsMoved_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<void *>("list");
- QTest::addColumn<int>("from");
- QTest::addColumn<int>("to");
- QTest::addColumn<int>("count");
- QTest::addColumn<RemoveList>("expectedRemoves");
- QTest::addColumn<InsertList>("expectedInserts");
- QTest::addColumn<IndexArray>("cacheIndexes");
- QTest::addColumn<IndexArray>("defaultIndexes");
- QTest::addColumn<IndexArray>("visibleIndexes");
- QTest::addColumn<IndexArray>("selectionIndexes");
-
- int listA; void *a = &listA;
- int listB; void *b = &listB;
-
- { static const int defaultIndexes[] = {/*A*/0,2,3,4,/*B*/0,1,2,3,/*A*/5,6,1};
- QTest::newRow("4, 1, 3")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 2, 3, C::PrependFlag)
- << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 2, 3, C::DefaultFlag))
- << a << 4 << 1 << 3
- << (RemoveList()
- << Remove(0, 0, 2, 0, 2, C::DefaultFlag, 0))
- << (InsertList()
- << Insert(0, 0, 1, 0, 2, C::DefaultFlag, 0))
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int defaultIndexes[] = {/*A*/1,2,3,6,/*B*/0,1,2,3,/*A*/4,5,0};
- QTest::newRow("0, 6, 1")
- << (RangeList()
- << Range(a, 0, 1, C::PrependFlag | C::DefaultFlag)
- << Range(a, 1, 1, C::PrependFlag)
- << Range(a, 2, 3, C::PrependFlag | C::DefaultFlag)
- << Range(a, 5, 2, C::PrependFlag)
- << Range(a, 7, 0, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 5, 2, C::DefaultFlag)
- << Range(a, 1, 1, C::DefaultFlag))
- << a << 0 << 6 << 1
- << (RemoveList()
- << Remove(0, 0, 0, 0, 1, C::DefaultFlag, 0))
- << (InsertList()
- << Insert(0, 0, 3, 0, 1, C::DefaultFlag, 0))
- << IndexArray()
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int cacheIndexes[] = {/*A*/0,1,3,4};
- static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7};
- QTest::newRow("6, 2, 1")
- << (RangeList()
- << Range(a, 0, 4, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 4, 4, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
- << a << 6 << 2 << 1
- << (RemoveList()
- << Remove(0, 0, 6, 4, 1, C::DefaultFlag, 0))
- << (InsertList()
- << Insert(0, 0, 2, 2, 1, C::DefaultFlag, 0))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int cacheIndexes[] = {/*A*/0,1,-1,-1,-1,2,3,4,5,6,7};
- static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7};
- QTest::newRow("Move after remove")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 2, 3, C::CacheFlag)
- << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
- << a << 4 << 2 << 2
- << (RemoveList()
- << Remove(0, 0, 4, 7, 2, C::DefaultFlag | C::CacheFlag, 0))
- << (InsertList()
- << Insert(0, 0, 2, 5, 2, C::DefaultFlag | C::CacheFlag, 0))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int cacheIndexes[] = {/*A*/0,1,5,6,7,8,9,10,11,12};
- static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7,8,9,10,11,12};
- QTest::newRow("Move merge tail")
- << (RangeList()
- << Range(a, 0, 10, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 10, 3, C::PrependFlag | C::DefaultFlag)
- << Range(a, 13, 0, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
- << a << 8 << 0 << 5
- << (RemoveList()
- << Remove(0, 0, 8, 8, 2, C::DefaultFlag | C::CacheFlag, 0)
- << Remove(0, 0, 8, 8, 3, C::DefaultFlag, 1))
- << (InsertList()
- << Insert(0, 0, 0, 0, 2, C::DefaultFlag | C::CacheFlag, 0)
- << Insert(0, 0, 2, 2, 3, C::DefaultFlag, 1))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- } { static const int cacheIndexes[] = {/*A*/0,1,2,3};
- static const int defaultIndexes[] = {/*A*/0,1,2,3};
- static const int selectionIndexes[] = {/*A*/3};
- QTest::newRow("Move selection")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 2, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 3, 1, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
- << a << 2 << 3 << 1
- << (RemoveList()
- << Remove(0, 0, 2, 2, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag, 0))
- << (InsertList()
- << Insert(0, 0, 3, 3, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag, 0))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray(selectionIndexes);
- } { static const int cacheIndexes[] = {/*A*/0,1,2,3,4,5,8,9};
- static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7,8,9,10,11};
- QTest::newRow("move mixed cached items")
- << (RangeList()
- << Range(a, 0, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 1, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 3, 7, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 10, 2, C::PrependFlag | C::DefaultFlag))
- << a << 1 << 6 << 3
- << (RemoveList()
- << Remove(0, 0, 1, 1, 2, C::PrependFlag | C::DefaultFlag, 0)
- << Remove(0, 0, 1, 1, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag, 1))
- << (InsertList()
- << Insert(0, 0, 6, 6, 2, C::PrependFlag | C::DefaultFlag, 0)
- << Insert(0, 0, 8, 6, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag, 1))
- << IndexArray(cacheIndexes)
- << IndexArray(defaultIndexes)
- << IndexArray()
- << IndexArray();
- }
-}
-
-void tst_qdeclarativelistcompositor::listItemsMoved()
-{
- QFETCH(RangeList, ranges);
- QFETCH(void *, list);
- QFETCH(int, from);
- QFETCH(int, to);
- QFETCH(int, count);
- QFETCH(RemoveList, expectedRemoves);
- QFETCH(InsertList, expectedInserts);
- QFETCH(IndexArray, cacheIndexes);
- QFETCH(IndexArray, defaultIndexes);
- QFETCH(IndexArray, visibleIndexes);
- QFETCH(IndexArray, selectionIndexes);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- QVector<C::Remove> removes;
- QVector<C::Insert> inserts;
- compositor.listItemsMoved(list, from, to, count, &removes, &inserts);
-
- QCOMPARE(removes, expectedRemoves);
- QCOMPARE(inserts, expectedInserts);
-
- QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
- for (int i = 0; i < cacheIndexes.count; ++i) {
- if (cacheIndexes[i] != -1) {
- QCOMPARE(compositor.find(C::Cache, i).modelIndex(), cacheIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
- for (int i = 0; i < defaultIndexes.count; ++i) {
- if (defaultIndexes[i] != -1) {
- QCOMPARE(compositor.find(C::Default, i).modelIndex(), defaultIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(Visible), visibleIndexes.count);
- for (int i = 0; i < visibleIndexes.count; ++i) {
- if (visibleIndexes[i] != -1) {
- QCOMPARE(compositor.find(Visible, i).modelIndex(), visibleIndexes[i]);
- }
- }
- QCOMPARE(compositor.count(Selection), selectionIndexes.count);
- for (int i = 0; i < selectionIndexes.count; ++i) {
- if (selectionIndexes[i] != -1) {
- QCOMPARE(compositor.find(Selection, i).modelIndex(), selectionIndexes[i]);
- }
- }
-}
-
-void tst_qdeclarativelistcompositor::listItemsChanged_data()
-{
- QTest::addColumn<RangeList>("ranges");
- QTest::addColumn<void *>("list");
- QTest::addColumn<int>("index");
- QTest::addColumn<int>("count");
- QTest::addColumn<ChangeList>("expectedChanges");
-
- int listA; void *a = &listA;
- int listB; void *b = &listB;
-
- QTest::newRow("overlapping")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
- << Range(a, 2, 3, C::PrependFlag)
- << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
- << Range(b, 0, 4, C::DefaultFlag)
- << Range(a, 2, 3, C::DefaultFlag))
- << a << 3 << 4
- << (ChangeList()
- << Change(0, 0, 2, 0, 2, C::DefaultFlag)
- << Change(0, 0, 9, 0, 2, C::DefaultFlag));
- QTest::newRow("Change after remove")
- << (RangeList()
- << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
- << Range(a, 2, 3, C::CacheFlag)
- << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
- << a << 3 << 2
- << (ChangeList()
- << Change(0, 0, 3, 6, 2, C::DefaultFlag | C::CacheFlag));
-}
-
-void tst_qdeclarativelistcompositor::listItemsChanged()
-{
- QFETCH(RangeList, ranges);
- QFETCH(void *, list);
- QFETCH(int, index);
- QFETCH(int, count);
- QFETCH(ChangeList, expectedChanges);
-
- QDeclarativeListCompositor compositor;
- compositor.setGroupCount(4);
- compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
-
- foreach (const Range &range, ranges)
- compositor.append(range.list, range.index, range.count, range.flags);
-
- QVector<C::Change> changes;
- compositor.listItemsChanged(list, index, count, &changes);
-
- QCOMPARE(changes, expectedChanges);
-}
-
-QTEST_MAIN(tst_qdeclarativelistcompositor)
-
-#include "tst_qdeclarativelistcompositor.moc"
-
-
diff --git a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro
deleted file mode 100644
index 25db0f9415..0000000000
--- a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativelistmodel
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativelistmodel.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
deleted file mode 100644
index 4eb723bf8e..0000000000
--- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
+++ /dev/null
@@ -1,1632 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QtDeclarative/private/qdeclarativeengine_p.h>
-#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
-#include <QtDeclarative/private/qdeclarativeexpression_p.h>
-#include <QDeclarativeComponent>
-
-#include <QtCore/qtimer.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qtranslator.h>
-#include <QSignalSpy>
-
-#include "../../shared/util.h"
-
-Q_DECLARE_METATYPE(QList<int>)
-Q_DECLARE_METATYPE(QList<QVariantHash>)
-
-#define RUNEVAL(object, string) \
- QVERIFY(QMetaObject::invokeMethod(object, "runEval", Q_ARG(QVariant, QString(string))));
-
-inline QVariant runexpr(QDeclarativeEngine *engine, const QString &str)
-{
- QDeclarativeExpression expr(engine->rootContext(), 0, str);
- return expr.evaluate();
-}
-
-#define RUNEXPR(string) runexpr(&engine, QString(string))
-
-static bool isValidErrorMessage(const QString &msg, bool dynamicRoleTest)
-{
- bool valid = true;
-
- if (msg.isEmpty()) {
- valid = false;
- } else if (dynamicRoleTest) {
- if (msg.contains("Can't assign to existing role") || msg.contains("Can't create role for unsupported data type"))
- valid = false;
- }
-
- return valid;
-}
-
-class tst_qdeclarativelistmodel : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativelistmodel() {}
-
-private:
- int roleFromName(const QDeclarativeListModel *model, const QString &roleName);
- QQuickItem *createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarativeListModel *model);
- void waitForWorker(QQuickItem *item);
-
- static bool compareVariantList(const QVariantList &testList, QVariant object);
-
-private slots:
- void static_types();
- void static_types_data();
- void static_i18n();
- void static_i18n_data();
- void static_nestedElements();
- void static_nestedElements_data();
- void dynamic_data();
- void dynamic();
- void dynamic_worker_data();
- void dynamic_worker();
- void dynamic_worker_sync_data();
- void dynamic_worker_sync();
- void enumerate();
- void error_data();
- void error();
- void syncError();
- void get();
- void set_data();
- void set();
- void get_data();
- void get_worker();
- void get_worker_data();
- void get_nested();
- void get_nested_data();
- void crash_model_with_multiple_roles();
- void set_model_cache();
- void property_changes();
- void property_changes_data();
- void property_changes_worker();
- void property_changes_worker_data();
- void clear_data();
- void clear();
- void signal_handlers_data();
- void signal_handlers();
- void worker_sync_data();
- void worker_sync();
- void worker_remove_element_data();
- void worker_remove_element();
- void worker_remove_list_data();
- void worker_remove_list();
- void role_mode_data();
- void role_mode();
- void dynamic_role();
- void dynamic_role_data();
-};
-
-bool tst_qdeclarativelistmodel::compareVariantList(const QVariantList &testList, QVariant object)
-{
- bool allOk = true;
-
- QDeclarativeListModel *model = qobject_cast<QDeclarativeListModel *>(object.value<QObject *>());
- if (model == 0)
- return false;
-
- if (model->count() != testList.count())
- return false;
-
- for (int i=0 ; i < testList.count() ; ++i) {
- const QVariant &testVariant = testList.at(i);
- if (testVariant.type() != QVariant::Map)
- return false;
- const QVariantMap &map = testVariant.toMap();
-
- const QList<int> &roles = model->roles();
-
- QVariantMap::const_iterator it = map.begin();
- QVariantMap::const_iterator end = map.end();
-
- while (it != end) {
- const QString &testKey = it.key();
- const QVariant &testData = it.value();
-
- int roleIndex = -1;
- for (int j=0 ; j < roles.count() ; ++j) {
- if (model->toString(roles[j]).compare(testKey) == 0) {
- roleIndex = j;
- break;
- }
- }
-
- if (roleIndex == -1)
- return false;
-
- const QVariant &modelData = model->data(i, roleIndex);
-
- if (testData.type() == QVariant::List) {
- const QVariantList &subList = testData.toList();
- allOk = allOk && compareVariantList(subList, modelData);
- } else {
- allOk = allOk && (testData == modelData);
- }
-
- ++it;
- }
- }
-
- return allOk;
-}
-
-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];
- }
- return -1;
-}
-
-QQuickItem *tst_qdeclarativelistmodel::createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarativeListModel *model)
-{
- QQuickItem *item = qobject_cast<QQuickItem*>(component->create());
- QDeclarativeEngine::setContextForObject(model, eng->rootContext());
- if (item)
- item->setProperty("model", qVariantFromValue(model));
- return item;
-}
-
-void tst_qdeclarativelistmodel::waitForWorker(QQuickItem *item)
-{
- QEventLoop loop;
- QTimer timer;
- timer.setSingleShot(true);
- connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
-
- QDeclarativeProperty prop(item, "done");
- QVERIFY(prop.isValid());
- QVERIFY(prop.connectNotifySignal(&loop, SLOT(quit())));
- timer.start(10000);
- loop.exec();
- QVERIFY(timer.isActive());
-}
-
-void tst_qdeclarativelistmodel::static_types_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QVariant>("value");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("string")
- << "ListElement { foo: \"bar\" }"
- << QVariant(QString("bar"))
- << QString();
-
- QTest::newRow("real")
- << "ListElement { foo: 10.5 }"
- << QVariant(10.5)
- << QString();
-
- QTest::newRow("real0")
- << "ListElement { foo: 0 }"
- << QVariant(double(0))
- << QString();
-
- QTest::newRow("bool")
- << "ListElement { foo: false }"
- << QVariant(false)
- << QString();
-
- QTest::newRow("bool")
- << "ListElement { foo: true }"
- << QVariant(true)
- << QString();
-
- QTest::newRow("enum")
- << "ListElement { foo: Text.AlignHCenter }"
- << QVariant(double(QQuickText::AlignHCenter))
- << QString();
-
- QTest::newRow("Qt enum")
- << "ListElement { foo: Qt.AlignBottom }"
- << QVariant(double(Qt::AlignBottom))
- << QString();
-
- QTest::newRow("role error")
- << "ListElement { foo: 1 } ListElement { foo: 'string' }"
- << QVariant()
- << QString("<Unknown File>: Can't assign to existing role 'foo' of different type [String -> Number]");
-
- QTest::newRow("list type error")
- << "ListElement { foo: 1 } ListElement { foo: ListElement { bar: 1 } }"
- << QVariant()
- << QString("<Unknown File>: Can't assign to existing role 'foo' of different type [List -> Number]");
-}
-
-void tst_qdeclarativelistmodel::static_types()
-{
- QFETCH(QString, qml);
- QFETCH(QVariant, value);
- QFETCH(QString, error);
-
- qml = "import QtQuick 2.0\nItem { property variant test: model.get(0).foo; ListModel { id: model; " + qml + " } }";
-
- if (!error.isEmpty()) {
- QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
- }
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(qml.toUtf8(),
- QUrl::fromLocalFile(QString("dummy.qml")));
-
- QVERIFY(!component.isError());
-
- QObject *obj = component.create();
- QVERIFY(obj != 0);
-
- if (error.isEmpty()) {
- QVariant actual = obj->property("test");
-
- QCOMPARE(actual, value);
- QCOMPARE(actual.toString(), value.toString());
- }
-
- delete obj;
-}
-
-void tst_qdeclarativelistmodel::static_i18n_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QVariant>("value");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("QT_TR_NOOP")
- << QString::fromUtf8("ListElement { foo: QT_TR_NOOP(\"na\303\257ve\") }")
- << QVariant(QString::fromUtf8("na\303\257ve"))
- << QString();
-
- QTest::newRow("QT_TRANSLATE_NOOP")
- << "ListElement { foo: QT_TRANSLATE_NOOP(\"MyListModel\", \"hello\") }"
- << QVariant(QString("hello"))
- << QString();
-
- QTest::newRow("QT_TRID_NOOP")
- << QString::fromUtf8("ListElement { foo: QT_TRID_NOOP(\"qtn_1st_text\") }")
- << QVariant(QString("qtn_1st_text"))
- << QString();
-
- QTest::newRow("QT_TR_NOOP extra param")
- << QString::fromUtf8("ListElement { foo: QT_TR_NOOP(\"hello\",\"world\") }")
- << QVariant(QString())
- << QString("ListElement: improperly specified QT_TR_NOOP");
-
- QTest::newRow("QT_TRANSLATE_NOOP missing params")
- << "ListElement { foo: QT_TRANSLATE_NOOP() }"
- << QVariant(QString())
- << QString("ListElement: improperly specified QT_TRANSLATE_NOOP");
-
- QTest::newRow("QT_TRID_NOOP missing param")
- << QString::fromUtf8("ListElement { foo: QT_TRID_NOOP() }")
- << QVariant(QString())
- << QString("ListElement: improperly specified QT_TRID_NOOP");
-}
-
-void tst_qdeclarativelistmodel::static_i18n()
-{
- QFETCH(QString, qml);
- QFETCH(QVariant, value);
- QFETCH(QString, error);
-
- qml = "import QtQuick 2.0\nItem { property variant test: model.get(0).foo; ListModel { id: model; " + qml + " } }";
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(qml.toUtf8(),
- QUrl::fromLocalFile(QString("dummy.qml")));
-
- if (!error.isEmpty()) {
- QVERIFY(component.isError());
- QCOMPARE(component.errors().at(0).description(), error);
- return;
- }
-
- QVERIFY(!component.isError());
-
- QObject *obj = component.create();
- QVERIFY(obj != 0);
-
- QVariant actual = obj->property("test");
-
- QCOMPARE(actual, value);
- QCOMPARE(actual.toString(), value.toString());
-
- delete obj;
-}
-
-void tst_qdeclarativelistmodel::static_nestedElements()
-{
- QFETCH(int, elementCount);
-
- QStringList elements;
- for (int i=0; i<elementCount; i++)
- elements.append("ListElement { a: 1; b: 2 }");
- QString elementsStr = elements.join(",\n") + "\n";
-
- QString componentStr =
- "import QtQuick 2.0\n"
- "Item {\n"
- " property variant count: model.get(0).attributes.count\n"
- " ListModel {\n"
- " id: model\n"
- " ListElement {\n"
- " attributes: [\n";
- componentStr += elementsStr.toUtf8().constData();
- componentStr +=
- " ]\n"
- " }\n"
- " }\n"
- "}";
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
-
- QObject *obj = component.create();
- QVERIFY(obj != 0);
-
- QVariant count = obj->property("count");
- QCOMPARE(count.type(), QVariant::Int);
- QCOMPARE(count.toInt(), elementCount);
-
- delete obj;
-}
-
-void tst_qdeclarativelistmodel::static_nestedElements_data()
-{
- QTest::addColumn<int>("elementCount");
-
- QTest::newRow("0 items") << 0;
- QTest::newRow("1 item") << 1;
- QTest::newRow("2 items") << 2;
- QTest::newRow("many items") << 5;
-}
-
-void tst_qdeclarativelistmodel::dynamic_data()
-{
- QTest::addColumn<QString>("script");
- QTest::addColumn<int>("result");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<bool>("dynamicRoles");
-
- for (int i=0 ; i < 2 ; ++i) {
- bool dr = (i != 0);
-
- // Simple flat model
- QTest::newRow("count") << "count" << 0 << "" << dr;
-
- QTest::newRow("get1") << "{get(0) === undefined}" << 1 << "" << dr;
- QTest::newRow("get2") << "{get(-1) === undefined}" << 1 << "" << dr;
- QTest::newRow("get3") << "{append({'foo':123});get(0) != undefined}" << 1 << "" << dr;
- QTest::newRow("get4") << "{append({'foo':123});get(0).foo}" << 123 << "" << dr;
- QTest::newRow("get-modify1") << "{append({'foo':123,'bar':456});get(0).foo = 333;get(0).foo}" << 333 << "" << dr;
- QTest::newRow("get-modify2") << "{append({'z':1});append({'foo':123,'bar':456});get(1).bar = 999;get(1).bar}" << 999 << "" << dr;
-
- QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << "" << dr;
- QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << "" << dr;
- QTest::newRow("append3a") << "{append({'foo':123});append({'foo':456});get(0).foo}" << 123 << "" << dr;
- QTest::newRow("append3b") << "{append({'foo':123});append({'foo':456});get(1).foo}" << 456 << "" << dr;
- QTest::newRow("append4a") << "{append(123)}" << 0 << "<Unknown File>: QML ListModel: append: value is not an object" << dr;
- QTest::newRow("append4b") << "{append([{'foo':123},{'foo':456},{'foo':789}]);count}" << 3 << "" << dr;
- QTest::newRow("append4c") << "{append([{'foo':123},{'foo':456},{'foo':789}]);get(1).foo}" << 456 << "" << dr;
-
- QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << "" << dr;
- QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << "" << dr;
- QTest::newRow("clear3") << "{append({'foo':123});clear()}" << 0 << "" << dr;
-
- QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << "" << dr;
- QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << "" << dr;
- QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << "" << dr;
- QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << "" << dr;
- QTest::newRow("remove3") << "{append({'foo':123});remove(0)}" << 0 << "" << dr;
- QTest::newRow("remove3a") << "{append({'foo':123});remove(-1);count}" << 1 << "<Unknown File>: QML ListModel: remove: indices [-1 - 0] out of range [0 - 1]" << dr;
- QTest::newRow("remove4a") << "{remove(0)}" << 0 << "<Unknown File>: QML ListModel: remove: indices [0 - 1] out of range [0 - 0]" << dr;
- QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0);count}" << 0 << "<Unknown File>: QML ListModel: remove: indices [0 - 1] out of range [0 - 0]" << dr;
- QTest::newRow("remove4c") << "{append({'foo':123});remove(1);count}" << 1 << "<Unknown File>: QML ListModel: remove: indices [1 - 2] out of range [0 - 1]" << dr;
- QTest::newRow("remove5a") << "{append({'foo':123});append({'foo':456});remove(0,2);count}" << 0 << "" << dr;
- QTest::newRow("remove5b") << "{append({'foo':123});append({'foo':456});remove(0,1);count}" << 1 << "" << dr;
- QTest::newRow("remove5c") << "{append({'foo':123});append({'foo':456});remove(1,1);count}" << 1 << "" << dr;
- QTest::newRow("remove5d") << "{append({'foo':123});append({'foo':456});remove(0,1);get(0).foo}" << 456 << "" << dr;
- QTest::newRow("remove5e") << "{append({'foo':123});append({'foo':456});remove(1,1);get(0).foo}" << 123 << "" << dr;
- QTest::newRow("remove5f") << "{append({'foo':123});append({'foo':456});append({'foo':789});remove(0,1);remove(1,1);get(0).foo}" << 456 << "" << dr;
- QTest::newRow("remove6a") << "{remove();count}" << 0 << "<Unknown File>: QML ListModel: remove: incorrect number of arguments" << dr;
- QTest::newRow("remove6b") << "{remove(1,2,3);count}" << 0 << "<Unknown File>: QML ListModel: remove: incorrect number of arguments" << dr;
- QTest::newRow("remove7a") << "{append({'foo':123});remove(0,0);count}" << 1 << "<Unknown File>: QML ListModel: remove: indices [0 - 0] out of range [0 - 1]" << dr;
- QTest::newRow("remove7b") << "{append({'foo':123});remove(0,-1);count}" << 1 << "<Unknown File>: QML ListModel: remove: indices [0 - -1] out of range [0 - 1]" << dr;
-
- QTest::newRow("insert1") << "{insert(0,{'foo':123});count}" << 1 << "" << dr;
- QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << "<Unknown File>: QML ListModel: insert: index 1 out of range" << dr;
- QTest::newRow("insert3a") << "{append({'foo':123});insert(1,{'foo':456});count}" << 2 << "" << dr;
- QTest::newRow("insert3b") << "{append({'foo':123});insert(1,{'foo':456});get(0).foo}" << 123 << "" << dr;
- QTest::newRow("insert3c") << "{append({'foo':123});insert(1,{'foo':456});get(1).foo}" << 456 << "" << dr;
- QTest::newRow("insert3d") << "{append({'foo':123});insert(0,{'foo':456});get(0).foo}" << 456 << "" << dr;
- QTest::newRow("insert3e") << "{append({'foo':123});insert(0,{'foo':456});get(1).foo}" << 123 << "" << dr;
- QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456});count}" << 1 << "<Unknown File>: QML ListModel: insert: index -1 out of range" << dr;
- QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << "<Unknown File>: QML ListModel: insert: value is not an object" << dr;
- QTest::newRow("insert5b") << "{insert(0,[{'foo':11},{'foo':22},{'foo':33}]);count}" << 3 << "" << dr;
- QTest::newRow("insert5c") << "{insert(0,[{'foo':11},{'foo':22},{'foo':33}]);get(2).foo}" << 33 << "" << dr;
-
- QTest::newRow("set1") << "{append({'foo':123});set(0,{'foo':456});count}" << 1 << "" << dr;
- QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << "" << dr;
- QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << "" << dr;
- QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << "" << dr;
- QTest::newRow("set4a") << "{set(0,{'foo':456});count}" << 1 << "" << dr;
- QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << "<Unknown File>: QML ListModel: set: index -1 out of range" << dr;
- QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123);count}" << 1 << "<Unknown File>: QML ListModel: set: value is not an object" << dr;
- QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << "<Unknown File>: QML ListModel: set: value is not an object" << dr;
- QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << "" << dr;
-
- QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << "" << dr;
- QTest::newRow("setprop2") << "{append({'foo':123});setProperty(0,'foo',456);get(0).foo}" << 456 << "" << dr;
- QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).foo}" << 999 << "" << dr;
- QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).bar}" << 456 << "" << dr;
- QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << "<Unknown File>: QML ListModel: set: index 0 out of range" << dr;
- QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << "<Unknown File>: QML ListModel: set: index -1 out of range" << dr;
- QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456);count}" << 1 << "<Unknown File>: QML ListModel: set: index 1 out of range" << dr;
- QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});setProperty(1,'bar',222);get(1).bar}" << 222 << "" << dr;
-
- QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << "" << dr;
- QTest::newRow("move1b") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(0).foo}" << 456 << "" << dr;
- QTest::newRow("move1c") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(1).foo}" << 123 << "" << dr;
- QTest::newRow("move1d") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(0).foo}" << 456 << "" << dr;
- QTest::newRow("move1e") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(1).foo}" << 123 << "" << dr;
- QTest::newRow("move2a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);count}" << 3 << "" << dr;
- QTest::newRow("move2b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(0).foo}" << 789 << "" << dr;
- QTest::newRow("move2c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(1).foo}" << 123 << "" << dr;
- QTest::newRow("move2d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(2).foo}" << 456 << "" << dr;
- QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range" << dr;
- QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range" << dr;
- QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range" << dr;
- QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range" << dr;
-
- QTest::newRow("large1") << "{append({'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8});get(0).h}" << 8 << "" << dr;
-
- QTest::newRow("datatypes1") << "{append({'a':1});append({'a':'string'});}" << 0 << "<Unknown File>: Can't assign to existing role 'a' of different type [String -> Number]" << dr;
-
- QTest::newRow("null") << "{append({'a':null});}" << 0 << "" << dr;
- QTest::newRow("setNull") << "{append({'a':1});set(0, {'a':null});}" << 0 << "" << dr;
- QTest::newRow("setString") << "{append({'a':'hello'});set(0, {'a':'world'});get(0).a == 'world'}" << 1 << "" << dr;
- QTest::newRow("setInt") << "{append({'a':5});set(0, {'a':10});get(0).a}" << 10 << "" << dr;
- QTest::newRow("setNumber") << "{append({'a':6});set(0, {'a':5.5});get(0).a < 5.6}" << 1 << "" << dr;
- QTest::newRow("badType0") << "{append({'a':'hello'});set(0, {'a':1});}" << 0 << "<Unknown File>: Can't assign to existing role 'a' of different type [Number -> String]" << dr;
- QTest::newRow("invalidInsert0") << "{insert(0);}" << 0 << "<Unknown File>: QML ListModel: insert: value is not an object" << dr;
- QTest::newRow("invalidAppend0") << "{append();}" << 0 << "<Unknown File>: QML ListModel: append: value is not an object" << dr;
- QTest::newRow("invalidInsert1") << "{insert(0, 34);}" << 0 << "<Unknown File>: QML ListModel: insert: value is not an object" << dr;
- QTest::newRow("invalidAppend1") << "{append(37);}" << 0 << "<Unknown File>: QML ListModel: append: value is not an object" << dr;
-
- // QObjects
- QTest::newRow("qobject0") << "{append({'a':dummyItem0});}" << 0 << "" << dr;
- QTest::newRow("qobject1") << "{append({'a':dummyItem0});set(0,{'a':dummyItem1});get(0).a == dummyItem1;}" << 1 << "" << dr;
- QTest::newRow("qobject2") << "{append({'a':dummyItem0});get(0).a == dummyItem0;}" << 1 << "" << dr;
- QTest::newRow("qobject3") << "{append({'a':dummyItem0});append({'b':1});}" << 0 << "" << dr;
-
- // JS objects
- QTest::newRow("js1") << "{append({'foo':{'prop':1}});count}" << 1 << "" << dr;
- QTest::newRow("js2") << "{append({'foo':{'prop':27}});get(0).foo.prop}" << 27 << "" << dr;
- QTest::newRow("js3") << "{append({'foo':{'prop':27}});append({'bar':1});count}" << 2 << "" << dr;
- QTest::newRow("js4") << "{append({'foo':{'prop':27}});append({'bar':1});set(0, {'foo':{'prop':28}});get(0).foo.prop}" << 28 << "" << dr;
- QTest::newRow("js5") << "{append({'foo':{'prop':27}});append({'bar':1});set(1, {'foo':{'prop':33}});get(1).foo.prop}" << 33 << "" << dr;
- QTest::newRow("js6") << "{append({'foo':{'prop':27}});clear();count}" << 0 << "" << dr;
- QTest::newRow("js7") << "{append({'foo':{'prop':27}});set(0, {'foo':null});count}" << 1 << "" << dr;
- QTest::newRow("js8") << "{append({'foo':{'prop':27}});set(0, {'foo':{'prop2':31}});get(0).foo.prop2}" << 31 << "" << dr;
-
- // Nested models
- QTest::newRow("nested-append1") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});count}" << 1 << "" << dr;
- QTest::newRow("nested-append2") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.get(1).a}" << 2 << "" << dr;
- QTest::newRow("nested-append3") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.append({'a':4});get(0).bars.get(3).a}" << 4 << "" << dr;
-
- QTest::newRow("nested-insert") << "{append({'foo':123});insert(0,{'bars':[{'a':1},{'b':2},{'c':3}]});get(0).bars.get(0).a}" << 1 << "" << dr;
- QTest::newRow("nested-set") << "{append({'foo':[{'x':1}]});set(0,{'foo':[{'x':123}]});get(0).foo.get(0).x}" << 123 << "" << dr;
-
- QTest::newRow("nested-count") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.count}" << 3 << "" << dr;
- QTest::newRow("nested-clear") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.clear(); get(0).bars.count}" << 0 << "" << dr;
- }
-}
-
-void tst_qdeclarativelistmodel::dynamic()
-{
- QFETCH(QString, script);
- QFETCH(int, result);
- QFETCH(QString, warning);
- QFETCH(bool, dynamicRoles);
-
- QQuickItem dummyItem0, dummyItem1;
- QDeclarativeEngine engine;
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine::setContextForObject(&model,engine.rootContext());
- engine.rootContext()->setContextObject(&model);
- engine.rootContext()->setContextProperty("dummyItem0", QVariant::fromValue(&dummyItem0));
- engine.rootContext()->setContextProperty("dummyItem1", QVariant::fromValue(&dummyItem1));
- QDeclarativeExpression e(engine.rootContext(), &model, script);
- if (isValidErrorMessage(warning, dynamicRoles))
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
-
- QSignalSpy spyCount(&model, SIGNAL(countChanged()));
-
- int actual = e.evaluate().toInt();
- if (e.hasError())
- qDebug() << e.error(); // errors not expected
-
- QCOMPARE(actual,result);
-
- if (model.count() > 0)
- QVERIFY(spyCount.count() > 0);
-}
-
-void tst_qdeclarativelistmodel::dynamic_worker_data()
-{
- dynamic_data();
-}
-
-void tst_qdeclarativelistmodel::dynamic_worker()
-{
- QFETCH(QString, script);
- QFETCH(int, result);
- QFETCH(QString, warning);
- QFETCH(bool, dynamicRoles);
-
- if (QByteArray(QTest::currentDataTag()).startsWith("qobject"))
- return;
-
- // This is same as dynamic() except it applies the test to a ListModel called
- // from a WorkerScript.
-
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("model.qml"));
- QQuickItem *item = createWorkerTest(&eng, &component, &model);
- QVERIFY(item != 0);
-
- QSignalSpy spyCount(&model, SIGNAL(countChanged()));
-
- 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 (isValidErrorMessage(warning, dynamicRoles))
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
-
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, operations)));
- waitForWorker(item);
- QCOMPARE(QDeclarativeProperty(item, "result").read().toInt(), result);
-
- if (model.count() > 0)
- QVERIFY(spyCount.count() > 0);
-
- 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);
- QFETCH(bool, dynamicRoles);
-
- if (QByteArray(QTest::currentDataTag()).startsWith("qobject"))
- return;
-
- // 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;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("model.qml"));
- QQuickItem *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 (isValidErrorMessage(warning, dynamicRoles))
- 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
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, operations.mid(0, operations.length()-1))));
- waitForWorker(item);
-
- QDeclarativeExpression e(eng.rootContext(), &model, operations.last().toString());
- QCOMPARE(e.evaluate().toInt(), result);
-
- delete item;
- qApp->processEvents();
-}
-
-void tst_qdeclarativelistmodel::enumerate()
-{
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("enumerate.qml"));
- QVERIFY(!component.isError());
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item != 0);
-
- QLatin1String expectedStrings[] = {
- QLatin1String("val1=1Y"),
- QLatin1String("val2=2Y"),
- QLatin1String("val3=strY"),
- QLatin1String("val4=falseN"),
- QLatin1String("val5=trueY")
- };
-
- int expectedStringCount = sizeof(expectedStrings) / sizeof(expectedStrings[0]);
-
- QStringList r = item->property("result").toString().split(":");
-
- int matchCount = 0;
- for (int i=0 ; i < expectedStringCount ; ++i) {
- const QLatin1String &expectedString = expectedStrings[i];
-
- QStringList::const_iterator it = r.begin();
- QStringList::const_iterator end = r.end();
-
- while (it != end) {
- if (it->compare(expectedString) == 0) {
- ++matchCount;
- break;
- }
- ++it;
- }
- }
-
- QVERIFY(matchCount == expectedStringCount);
-
- delete item;
-}
-
-void tst_qdeclarativelistmodel::error_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("id not allowed in ListElement")
- << "import QtQuick 2.0\nListModel { ListElement { id: fred } }"
- << "ListElement: cannot use reserved \"id\" property";
-
- QTest::newRow("id allowed in ListModel")
- << "import QtQuick 2.0\nListModel { id:model }"
- << "";
-
- QTest::newRow("random properties not allowed in ListModel")
- << "import QtQuick 2.0\nListModel { foo:123 }"
- << "ListModel: undefined property 'foo'";
-
- QTest::newRow("random properties allowed in ListElement")
- << "import QtQuick 2.0\nListModel { ListElement { foo:123 } }"
- << "";
-
- QTest::newRow("bindings not allowed in ListElement")
- << "import QtQuick 2.0\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }"
- << "ListElement: cannot use script for property value";
-
- QTest::newRow("random object list properties allowed in ListElement")
- << "import QtQuick 2.0\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }"
- << "";
-
- QTest::newRow("default properties not allowed in ListElement")
- << "import QtQuick 2.0\nListModel { ListElement { Item { } } }"
- << "ListElement: cannot contain nested elements";
-
- QTest::newRow("QML elements not allowed in ListElement")
- << "import QtQuick 2.0\nListModel { ListElement { a: Item { } } }"
- << "ListElement: cannot contain nested elements";
-
- QTest::newRow("qualified ListElement supported")
- << "import QtQuick 2.0 as Foo\nFoo.ListModel { Foo.ListElement { a: 123 } }"
- << "";
-
- QTest::newRow("qualified ListElement required")
- << "import QtQuick 2.0 as Foo\nFoo.ListModel { ListElement { a: 123 } }"
- << "ListElement is not a type";
-
- QTest::newRow("unknown qualified ListElement not allowed")
- << "import QtQuick 2.0\nListModel { Foo.ListElement { a: 123 } }"
- << "Foo.ListElement - Foo is not a namespace";
-}
-
-void tst_qdeclarativelistmodel::error()
-{
- QFETCH(QString, qml);
- QFETCH(QString, error);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(qml.toUtf8(),
- QUrl::fromLocalFile(QString("dummy.qml")));
- if (error.isEmpty()) {
- QVERIFY(!component.isError());
- } else {
- QVERIFY(component.isError());
- QList<QDeclarativeError> errors = component.errors();
- QCOMPARE(errors.count(),1);
- QCOMPARE(errors.at(0).description(),error);
- }
-}
-
-void tst_qdeclarativelistmodel::syncError()
-{
- QString qml = "import QtQuick 2.0\nListModel { id: lm; Component.onCompleted: lm.sync() }";
- QString error = "file:dummy.qml:2:1: QML ListModel: List sync() can only be called from a WorkerScript";
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(qml.toUtf8(),
- QUrl::fromLocalFile(QString("dummy.qml")));
- QTest::ignoreMessage(QtWarningMsg,error.toUtf8());
- QObject *obj = component.create();
- QVERIFY(obj);
- delete obj;
-}
-
-/*
- Test model changes from set() are available to the view
-*/
-void tst_qdeclarativelistmodel::set_data()
-{
- QTest::addColumn<bool>("dynamicRoles");
-
- QTest::newRow("staticRoles") << false;
- QTest::newRow("dynamicRoles") << true;
-}
-
-void tst_qdeclarativelistmodel::set()
-{
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeEngine engine;
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine::setContextForObject(&model,engine.rootContext());
- engine.rootContext()->setContextProperty("model", &model);
-
- RUNEXPR("model.append({test:false})");
- RUNEXPR("model.set(0, {test:true})");
-
- QCOMPARE(RUNEXPR("model.get(0).test").toBool(), true); // triggers creation of model cache
- QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(true));
-
- RUNEXPR("model.set(0, {test:false})");
- QCOMPARE(RUNEXPR("model.get(0).test").toBool(), false); // tests model cache is updated
- QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(false));
-
- QString warning = QString::fromLatin1("<Unknown File>: Can't create role for unsupported data type");
- if (isValidErrorMessage(warning, dynamicRoles))
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
- QVariant invalidData = QColor();
- model.setProperty(0, "test", invalidData);
-}
-
-/*
- 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);
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "ListModel {}\n", QUrl());
- QDeclarativeListModel *model = qobject_cast<QDeclarativeListModel*>(component.create());
- model->setDynamicRoles(dynamicRoles);
- engine.rootContext()->setContextProperty("model", model);
-
- RUNEXPR("model.append({roleA: 100})");
- RUNEXPR("model.append({roleA: 200, roleB: 400})");
- RUNEXPR("model.append({roleA: 200, roleB: 400})");
- RUNEXPR("model.append({roleC: {} })");
- RUNEXPR("model.append({roleD: [ { a:1, b:2 }, { c: 3 } ] })");
-
- QSignalSpy spy(model, SIGNAL(itemsChanged(int, int, QList<int>)));
- QDeclarativeExpression expr(engine.rootContext(), model, expression);
- expr.evaluate();
- QVERIFY(!expr.hasError());
-
- int role = roleFromName(model, roleName);
- QVERIFY(role >= 0);
-
- if (roleValue.type() == QVariant::List) {
- const QVariantList &list = roleValue.toList();
- QVERIFY(compareVariantList(list, model->data(index, role)));
- } 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
- QCOMPARE(spyResult.at(2).value<QList<int> >(), (QList<int>() << role));
-
- delete model;
-}
-
-void tst_qdeclarativelistmodel::get_data()
-{
- QTest::addColumn<QString>("expression");
- QTest::addColumn<int>("index");
- QTest::addColumn<QString>("roleName");
- QTest::addColumn<QVariant>("roleValue");
- QTest::addColumn<bool>("dynamicRoles");
-
- for (int i=0 ; i < 2 ; ++i) {
- bool dr = (i != 0);
-
- QTest::newRow("simple value") << "get(0).roleA = 500" << 0 << "roleA" << QVariant(500) << dr;
- QTest::newRow("simple value 2") << "get(1).roleB = 500" << 1 << "roleB" << QVariant(500) << dr;
-
- QVariantMap 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).roleD = [{'a': 50, 'b': 500}, {'c': 1000}]" << 2 << "roleD" << QVariant::fromValue(list) << dr;
- }
-}
-
-void tst_qdeclarativelistmodel::get_worker()
-{
- QFETCH(QString, expression);
- QFETCH(int, index);
- QFETCH(QString, roleName);
- QFETCH(QVariant, roleValue);
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("model.qml"));
- QQuickItem *item = createWorkerTest(&eng, &component, &model);
- QVERIFY(item != 0);
-
- // Add some values like get() test
- RUNEVAL(item, "model.append({roleA: 100})");
- RUNEVAL(item, "model.append({roleA: 200, roleB: 400})");
- RUNEVAL(item, "model.append({roleA: 200, roleB: 400})");
- RUNEVAL(item, "model.append({roleC: {} })");
- RUNEVAL(item, "model.append({roleD: [ { a:1, b:2 }, { c: 3 } ] })");
-
- int role = roleFromName(&model, roleName);
- QVERIFY(role >= 0);
-
- 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) {
- const QVariantList &list = roleValue.toList();
- QVERIFY(compareVariantList(list, model.data(index, role)));
- } 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);
- QFETCH(bool, dynamicRoles);
-
- if (roleValue.type() == QVariant::Map)
- return;
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "ListModel {}", QUrl());
- QDeclarativeListModel *model = qobject_cast<QDeclarativeListModel*>(component.create());
- model->setDynamicRoles(dynamicRoles);
- QVERIFY(component.errorString().isEmpty());
- QDeclarativeListModel *childModel;
- engine.rootContext()->setContextProperty("model", model);
-
- RUNEXPR("model.append({ listRoleA: [\n"
- "{ roleA: 100 },\n"
- "{ roleA: 200, roleB: 400 },\n"
- "{ roleA: 200, roleB: 400 }, \n"
- "{ roleC: {} }, \n"
- "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n"
- "] })\n");
-
- RUNEXPR("model.append({ listRoleA: [\n"
- "{ roleA: 100 },\n"
- "{ roleA: 200, roleB: 400 },\n"
- "{ roleA: 200, roleB: 400 }, \n"
- "{ roleC: {} }, \n"
- "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n"
- "],\n"
- "listRoleB: [\n"
- "{ roleA: 100 },\n"
- "{ roleA: 200, roleB: 400 },\n"
- "{ roleA: 200, roleB: 400 }, \n"
- "{ roleC: {} }, \n"
- "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n"
- "],\n"
- "listRoleC: [\n"
- "{ roleA: 100 },\n"
- "{ roleA: 200, roleB: 400 },\n"
- "{ roleA: 200, roleB: 400 }, \n"
- "{ roleC: {} }, \n"
- "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n"
- "] })\n");
-
- // 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);
- QVERIFY(outerListRole >= 0);
-
- 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(engine.rootContext(), model, extendedExpression);
-
- QSignalSpy spy(childModel, SIGNAL(itemsChanged(int, int, QList<int>)));
- expr.evaluate();
- QVERIFY(!expr.hasError());
-
- int role = roleFromName(childModel, roleName);
- QVERIFY(role >= 0);
- if (roleValue.type() == QVariant::List) {
- QVERIFY(compareVariantList(roleValue.toList(), childModel->data(index, role)));
- } else {
- 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));
- }
-
- delete model;
-}
-
-void tst_qdeclarativelistmodel::get_nested_data()
-{
- get_data();
-}
-
-//QTBUG-13754
-void tst_qdeclarativelistmodel::crash_model_with_multiple_roles()
-{
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("multipleroles.qml"));
- QObject *rootItem = component.create();
- QVERIFY(component.errorString().isEmpty());
- QVERIFY(rootItem != 0);
- QDeclarativeListModel *model = rootItem->findChild<QDeclarativeListModel*>("listModel");
- QVERIFY(model != 0);
-
- // used to cause a crash in QDeclarativeVisualDataModel
- model->setProperty(0, "black", true);
-
- delete rootItem;
-}
-
-//QTBUG-15190
-void tst_qdeclarativelistmodel::set_model_cache()
-{
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("setmodelcachelist.qml"));
- QObject *model = component.create();
- QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
- QVERIFY(model != 0);
- QVERIFY(model->property("ok").toBool());
-
- delete model;
-}
-
-void tst_qdeclarativelistmodel::property_changes()
-{
- QFETCH(QString, script_setup);
- QFETCH(QString, script_change);
- QFETCH(QString, roleName);
- QFETCH(int, listIndex);
- QFETCH(bool, itemsChanged);
- QFETCH(QString, testExpression);
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeEngine engine;
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine::setContextForObject(&model, engine.rootContext());
- engine.rootContext()->setContextObject(&model);
-
- QDeclarativeExpression expr(engine.rootContext(), &model, script_setup);
- expr.evaluate();
- QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString()));
-
- QString signalHandler = "on" + QString(roleName[0].toUpper()) + roleName.mid(1, roleName.length()) + "Changed:";
- QString qml = "import QtQuick 2.0\n"
- "Connections {\n"
- "property bool gotSignal: false\n"
- "target: model.get(" + QString::number(listIndex) + ")\n"
- + signalHandler + " gotSignal = true\n"
- "}\n";
-
- QDeclarativeComponent component(&engine);
- component.setData(qml.toUtf8(), QUrl::fromLocalFile(""));
- engine.rootContext()->setContextProperty("model", &model);
- QObject *connectionsObject = component.create();
- QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
-
- QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList<int>)));
-
- expr.setExpression(script_change);
- expr.evaluate();
- QVERIFY2(!expr.hasError(), QTest::toString(expr.error()));
-
- // test the object returned by get() emits the correct signals
- QCOMPARE(connectionsObject->property("gotSignal").toBool(), itemsChanged);
-
- // test itemsChanged() is emitted correctly
- if (itemsChanged) {
- QCOMPARE(spyItemsChanged.count(), 1);
- QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex);
- QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1);
- } else {
- QCOMPARE(spyItemsChanged.count(), 0);
- }
-
- expr.setExpression(testExpression);
- QCOMPARE(expr.evaluate().toBool(), true);
-
- delete connectionsObject;
-}
-
-void tst_qdeclarativelistmodel::property_changes_data()
-{
- QTest::addColumn<QString>("script_setup");
- QTest::addColumn<QString>("script_change");
- QTest::addColumn<QString>("roleName");
- QTest::addColumn<int>("listIndex");
- QTest::addColumn<bool>("itemsChanged");
- QTest::addColumn<QString>("testExpression");
- QTest::addColumn<bool>("dynamicRoles");
-
- for (int i=0 ; i < 2 ; ++i) {
- bool dr = (i != 0);
-
- QTest::newRow("set: plain") << "append({'a':123, 'b':456, 'c':789});" << "set(0,{'b':123});"
- << "b" << 0 << true << "get(0).b == 123" << dr;
- QTest::newRow("setProperty: plain") << "append({'a':123, 'b':456, 'c':789});" << "setProperty(0, 'b', 123);"
- << "b" << 0 << true << "get(0).b == 123" << dr;
-
- QTest::newRow("set: plain, no changes") << "append({'a':123, 'b':456, 'c':789});" << "set(0,{'b':456});"
- << "b" << 0 << false << "get(0).b == 456" << dr;
- QTest::newRow("setProperty: plain, no changes") << "append({'a':123, 'b':456, 'c':789});" << "setProperty(0, 'b', 456);"
- << "b" << 0 << false << "get(0).b == 456" << dr;
-
- QTest::newRow("set: inserted item")
- << "{append({'a':123, 'b':456, 'c':789}); get(0); insert(0, {'a':0, 'b':0, 'c':0});}"
- << "set(1, {'a':456});"
- << "a" << 1 << true << "get(1).a == 456" << dr;
- QTest::newRow("setProperty: inserted item")
- << "{append({'a':123, 'b':456, 'c':789}); get(0); insert(0, {'a':0, 'b':0, 'c':0});}"
- << "setProperty(1, 'a', 456);"
- << "a" << 1 << true << "get(1).a == 456" << dr;
- QTest::newRow("get: inserted item")
- << "{append({'a':123, 'b':456, 'c':789}); get(0); insert(0, {'a':0, 'b':0, 'c':0});}"
- << "get(1).a = 456;"
- << "a" << 1 << true << "get(1).a == 456" << dr;
- QTest::newRow("set: removed item")
- << "{append({'a':0, 'b':0, 'c':0}); append({'a':123, 'b':456, 'c':789}); get(1); remove(0);}"
- << "set(0, {'a':456});"
- << "a" << 0 << true << "get(0).a == 456" << dr;
- QTest::newRow("setProperty: removed item")
- << "{append({'a':0, 'b':0, 'c':0}); append({'a':123, 'b':456, 'c':789}); get(1); remove(0);}"
- << "setProperty(0, 'a', 456);"
- << "a" << 0 << true << "get(0).a == 456" << dr;
- QTest::newRow("get: removed item")
- << "{append({'a':0, 'b':0, 'c':0}); append({'a':123, 'b':456, 'c':789}); get(1); remove(0);}"
- << "get(0).a = 456;"
- << "a" << 0 << true << "get(0).a == 456" << dr;
-
- // Following tests only call set() since setProperty() only allows plain
- // values, not lists, as the argument.
- // Note that when a list is changed, itemsChanged() is currently always
- // emitted regardless of whether it actually changed or not.
-
- QTest::newRow("nested-set: list, new size") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2}]});"
- << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2" << dr;
-
- QTest::newRow("nested-set: list, empty -> non-empty") << "append({'a':123, 'b':[], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2},{'a':3}]});"
- << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2 && get(0).b.get(2).a == 3" << dr;
-
- QTest::newRow("nested-set: list, non-empty -> empty") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[]});"
- << "b" << 0 << true << "get(0).b.count == 0" << dr;
-
- QTest::newRow("nested-set: list, same size, different values") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':222},{'a':3}]});"
- << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 222 && get(0).b.get(2).a == 3" << dr;
-
- QTest::newRow("nested-set: list, no changes") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2},{'a':3}]});"
- << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2 && get(0).b.get(2).a == 3" << dr;
-
- QTest::newRow("nested-set: list, no changes, empty") << "append({'a':123, 'b':[], 'c':789});" << "set(0,{'b':[]});"
- << "b" << 0 << true << "get(0).b.count == 0" << dr;
- }
-}
-
-void tst_qdeclarativelistmodel::property_changes_worker()
-{
- QFETCH(QString, script_setup);
- QFETCH(QString, script_change);
- QFETCH(QString, roleName);
- QFETCH(int, listIndex);
- QFETCH(bool, itemsChanged);
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
- QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8());
- QQuickItem *item = createWorkerTest(&engine, &component, &model);
- QVERIFY(item != 0);
-
- QDeclarativeExpression expr(engine.rootContext(), &model, script_setup);
- expr.evaluate();
- QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString()));
-
- QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList<int>)));
-
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, QStringList(script_change))));
- waitForWorker(item);
-
- // test itemsChanged() is emitted correctly
- if (itemsChanged) {
- QCOMPARE(spyItemsChanged.count(), 1);
- QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex);
- QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1);
- } else {
- QCOMPARE(spyItemsChanged.count(), 0);
- }
-
- delete item;
- qApp->processEvents();
-}
-
-void tst_qdeclarativelistmodel::property_changes_worker_data()
-{
- property_changes_data();
-}
-
-void tst_qdeclarativelistmodel::clear_data()
-{
- QTest::addColumn<bool>("dynamicRoles");
-
- QTest::newRow("staticRoles") << false;
- QTest::newRow("dynamicRoles") << true;
-}
-
-void tst_qdeclarativelistmodel::clear()
-{
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeEngine engine;
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine::setContextForObject(&model, engine.rootContext());
- engine.rootContext()->setContextProperty("model", &model);
-
- model.clear();
- QCOMPARE(model.count(), 0);
-
- RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})");
- QCOMPARE(model.count(), 1);
-
- model.clear();
- QCOMPARE(model.count(), 0);
-
- RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})");
- RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})");
- QCOMPARE(model.count(), 2);
-
- model.clear();
- QCOMPARE(model.count(), 0);
-
- // clearing does not remove the roles
- RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\", propertyC: \"value c\"})");
- QList<int> roles = model.roles();
- model.clear();
- QCOMPARE(model.count(), 0);
- QCOMPARE(model.roles(), roles);
- QCOMPARE(model.toString(roles[0]), QString("propertyA"));
- QCOMPARE(model.toString(roles[1]), QString("propertyB"));
- QCOMPARE(model.toString(roles[2]), QString("propertyC"));
-}
-
-void tst_qdeclarativelistmodel::signal_handlers_data()
-{
- QTest::addColumn<bool>("dynamicRoles");
-
- QTest::newRow("staticRoles") << false;
- QTest::newRow("dynamicRoles") << true;
-}
-
-void tst_qdeclarativelistmodel::signal_handlers()
-{
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("signalhandlers.qml"));
- QObject *model = component.create();
- QDeclarativeListModel *lm = qobject_cast<QDeclarativeListModel *>(model);
- QVERIFY(lm != 0);
- lm->setDynamicRoles(dynamicRoles);
- QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
- QVERIFY(model != 0);
- QVERIFY(model->property("ok").toBool());
-
- delete model;
-}
-
-void tst_qdeclarativelistmodel::worker_sync_data()
-{
- QTest::addColumn<bool>("dynamicRoles");
-
- QTest::newRow("staticRoles") << false;
- QTest::newRow("dynamicRoles") << true;
-}
-
-void tst_qdeclarativelistmodel::worker_sync()
-{
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("workersync.qml"));
- QQuickItem *item = createWorkerTest(&eng, &component, &model);
- QVERIFY(item != 0);
-
- QVERIFY(model.count() == 0);
-
- QVERIFY(QMetaObject::invokeMethod(item, "addItem0"));
-
- QVERIFY(model.count() == 2);
- QVariant childData = model.data(0, 0);
- QDeclarativeListModel *childModel = qobject_cast<QDeclarativeListModel *>(childData.value<QObject *>());
- QVERIFY(childModel);
- QVERIFY(childModel->count() == 1);
-
- QSignalSpy spyModelInserted(&model, SIGNAL(itemsInserted(int,int)));
- QSignalSpy spyChildInserted(childModel, SIGNAL(itemsInserted(int,int)));
-
- QVERIFY(QMetaObject::invokeMethod(item, "addItemViaWorker"));
- waitForWorker(item);
-
- QVERIFY(model.count() == 2);
- QVERIFY(childModel->count() == 1);
- QVERIFY(spyModelInserted.count() == 0);
- QVERIFY(spyChildInserted.count() == 0);
-
- QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
- waitForWorker(item);
-
- QVERIFY(model.count() == 2);
- QVERIFY(childModel->count() == 2);
- QVERIFY(spyModelInserted.count() == 0);
- QVERIFY(spyChildInserted.count() == 1);
-
- QVERIFY(QMetaObject::invokeMethod(item, "addItemViaWorker"));
- waitForWorker(item);
-
- QVERIFY(model.count() == 2);
- QVERIFY(childModel->count() == 2);
- QVERIFY(spyModelInserted.count() == 0);
- QVERIFY(spyChildInserted.count() == 1);
-
- QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
- waitForWorker(item);
-
- QVERIFY(model.count() == 2);
- QVERIFY(childModel->count() == 3);
- QVERIFY(spyModelInserted.count() == 0);
- QVERIFY(spyChildInserted.count() == 2);
-
- delete item;
- qApp->processEvents();
-}
-
-void tst_qdeclarativelistmodel::worker_remove_element_data()
-{
- worker_sync_data();
-}
-
-void tst_qdeclarativelistmodel::worker_remove_element()
-{
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("workerremoveelement.qml"));
- QQuickItem *item = createWorkerTest(&eng, &component, &model);
- QVERIFY(item != 0);
-
- QSignalSpy spyModelRemoved(&model, SIGNAL(itemsRemoved(int,int)));
-
- QVERIFY(model.count() == 0);
- QVERIFY(spyModelRemoved.count() == 0);
-
- QVERIFY(QMetaObject::invokeMethod(item, "addItem"));
-
- QVERIFY(model.count() == 1);
-
- QVERIFY(QMetaObject::invokeMethod(item, "removeItemViaWorker"));
- waitForWorker(item);
-
- QVERIFY(model.count() == 1);
- QVERIFY(spyModelRemoved.count() == 0);
-
- QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
- waitForWorker(item);
-
- QVERIFY(model.count() == 0);
- QVERIFY(spyModelRemoved.count() == 1);
-
- delete item;
- qApp->processEvents();
-
- {
- //don't crash if model was deleted earlier
- QDeclarativeListModel* model = new QDeclarativeListModel;
- model->setDynamicRoles(dynamicRoles);
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("workerremoveelement.qml"));
- QQuickItem *item = createWorkerTest(&eng, &component, model);
- QVERIFY(item != 0);
-
- QVERIFY(QMetaObject::invokeMethod(item, "addItem"));
-
- QVERIFY(model->count() == 1);
-
- QVERIFY(QMetaObject::invokeMethod(item, "removeItemViaWorker"));
- QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
- delete model;
- qApp->processEvents(); //must not crash here
- waitForWorker(item);
-
- delete item;
- }
-}
-
-void tst_qdeclarativelistmodel::worker_remove_list_data()
-{
- worker_sync_data();
-}
-
-void tst_qdeclarativelistmodel::worker_remove_list()
-{
- QFETCH(bool, dynamicRoles);
-
- QDeclarativeListModel model;
- model.setDynamicRoles(dynamicRoles);
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("workerremovelist.qml"));
- QQuickItem *item = createWorkerTest(&eng, &component, &model);
- QVERIFY(item != 0);
-
- QSignalSpy spyModelRemoved(&model, SIGNAL(itemsRemoved(int,int)));
-
- QVERIFY(model.count() == 0);
- QVERIFY(spyModelRemoved.count() == 0);
-
- QVERIFY(QMetaObject::invokeMethod(item, "addList"));
-
- QVERIFY(model.count() == 1);
-
- QVERIFY(QMetaObject::invokeMethod(item, "removeListViaWorker"));
- waitForWorker(item);
-
- QVERIFY(model.count() == 1);
- QVERIFY(spyModelRemoved.count() == 0);
-
- QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
- waitForWorker(item);
-
- QVERIFY(model.count() == 0);
- QVERIFY(spyModelRemoved.count() == 1);
-
- delete item;
- qApp->processEvents();
-}
-
-void tst_qdeclarativelistmodel::role_mode_data()
-{
- QTest::addColumn<QString>("script");
- QTest::addColumn<int>("result");
- QTest::addColumn<QString>("warning");
-
- QTest::newRow("default0") << "{dynamicRoles}" << 0 << "";
- QTest::newRow("default1") << "{append({'a':1});dynamicRoles}" << 0 << "";
-
- QTest::newRow("enableDynamic0") << "{dynamicRoles=true;dynamicRoles}" << 1 << "";
- QTest::newRow("enableDynamic1") << "{append({'a':1});dynamicRoles=true;dynamicRoles}" << 0 << "<Unknown File>: QML ListModel: unable to enable dynamic roles as this model is not empty!";
- QTest::newRow("enableDynamic2") << "{dynamicRoles=true;append({'a':1});dynamicRoles=false;dynamicRoles}" << 1 << "<Unknown File>: QML ListModel: unable to enable static roles as this model is not empty!";
-}
-
-void tst_qdeclarativelistmodel::role_mode()
-{
- QFETCH(QString, script);
- QFETCH(int, result);
- QFETCH(QString, warning);
-
- QDeclarativeEngine engine;
- QDeclarativeListModel model;
- QDeclarativeEngine::setContextForObject(&model,engine.rootContext());
- engine.rootContext()->setContextObject(&model);
- QDeclarativeExpression e(engine.rootContext(), &model, script);
- if (!warning.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
-
- int actual = e.evaluate().toInt();
- if (e.hasError())
- qDebug() << e.error(); // errors not expected
-
- QCOMPARE(actual,result);
-}
-
-void tst_qdeclarativelistmodel::dynamic_role_data()
-{
- QTest::addColumn<QString>("preamble");
- QTest::addColumn<QString>("script");
- QTest::addColumn<int>("result");
-
- QTest::newRow("sync1") << "{append({'a':[{'b':1},{'b':2}]})}" << "{get(0).a = 'string';count}" << 1;
-}
-
-void tst_qdeclarativelistmodel::dynamic_role()
-{
- QFETCH(QString, preamble);
- QFETCH(QString, script);
- QFETCH(int, result);
-
- QDeclarativeListModel model;
- model.setDynamicRoles(true);
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
- QQuickItem *item = createWorkerTest(&engine, &component, &model);
- QVERIFY(item != 0);
-
- QDeclarativeExpression preExp(engine.rootContext(), &model, preamble);
- QCOMPARE(preExp.evaluate().toInt(), 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;
- }
-
- // execute a set of commands on the worker list model, then check the
- // changes are reflected in the list model in the main thread
- QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
- Q_ARG(QVariant, operations.mid(0, operations.length()-1))));
- waitForWorker(item);
-
- QDeclarativeExpression e(engine.rootContext(), &model, operations.last().toString());
- QCOMPARE(e.evaluate().toInt(), result);
-
- delete item;
- qApp->processEvents();
-}
-
-QTEST_MAIN(tst_qdeclarativelistmodel)
-
-#include "tst_qdeclarativelistmodel.moc"
diff --git a/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro b/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro
deleted file mode 100644
index 7900f3c554..0000000000
--- a/tests/auto/declarative/qdeclarativelistreference/qdeclarativelistreference.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativelistreference
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativelistreference.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp b/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp
deleted file mode 100644
index bfd2ea2f42..0000000000
--- a/tests/auto/declarative/qdeclarativelistreference/tst_qdeclarativelistreference.cpp
+++ /dev/null
@@ -1,570 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QUrl>
-#include <QFileInfo>
-#include <QDir>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QtDeclarative/qdeclarative.h>
-#include <QtDeclarative/qdeclarativeprivate.h>
-#include <QtDeclarative/qdeclarativeproperty.h>
-#include <QDebug>
-#include "../../shared/util.h"
-
-class tst_qdeclarativelistreference : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativelistreference() {}
-
-private slots:
- void initTestCase();
- void qmllistreference();
- void qmllistreference_invalid();
- void isValid();
- void object();
- void listElementType();
- void canAppend();
- void canAt();
- void canClear();
- void canCount();
- void append();
- void at();
- void clear();
- void count();
- void copy();
- void qmlmetaproperty();
- void engineTypes();
- void variantToList();
-};
-
-class TestType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<TestType> data READ dataProperty)
- Q_PROPERTY(int intProperty READ intProperty)
-
-public:
- TestType() : property(this, data) {}
- QDeclarativeListProperty<TestType> dataProperty() { return property; }
- int intProperty() const { return 10; }
-
- QList<TestType *> data;
- QDeclarativeListProperty<TestType> property;
-};
-
-void tst_qdeclarativelistreference::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- qmlRegisterType<TestType>();
-}
-
-void tst_qdeclarativelistreference::qmllistreference()
-{
- TestType tt;
-
- QDeclarativeListReference r(&tt, "data");
- QVERIFY(r.isValid() == true);
- QCOMPARE(r.count(), 0);
-
- tt.data.append(&tt);
- QCOMPARE(r.count(), 1);
-}
-
-void tst_qdeclarativelistreference::qmllistreference_invalid()
-{
- TestType tt;
-
- // Invalid
- {
- QDeclarativeListReference r;
- QVERIFY(r.isValid() == false);
- QVERIFY(r.object() == 0);
- QVERIFY(r.listElementType() == 0);
- QVERIFY(r.canAt() == false);
- QVERIFY(r.canClear() == false);
- QVERIFY(r.canCount() == false);
- QVERIFY(r.append(0) == false);
- QVERIFY(r.at(10) == 0);
- QVERIFY(r.clear() == false);
- QVERIFY(r.count() == 0);
- }
-
- // Non-property
- {
- QDeclarativeListReference r(&tt, "blah");
- QVERIFY(r.isValid() == false);
- QVERIFY(r.object() == 0);
- QVERIFY(r.listElementType() == 0);
- QVERIFY(r.canAt() == false);
- QVERIFY(r.canClear() == false);
- QVERIFY(r.canCount() == false);
- QVERIFY(r.append(0) == false);
- QVERIFY(r.at(10) == 0);
- QVERIFY(r.clear() == false);
- QVERIFY(r.count() == 0);
- }
-
- // Non-list property
- {
- QDeclarativeListReference r(&tt, "intProperty");
- QVERIFY(r.isValid() == false);
- QVERIFY(r.object() == 0);
- QVERIFY(r.listElementType() == 0);
- QVERIFY(r.canAt() == false);
- QVERIFY(r.canClear() == false);
- QVERIFY(r.canCount() == false);
- QVERIFY(r.append(0) == false);
- QVERIFY(r.at(10) == 0);
- QVERIFY(r.clear() == false);
- QVERIFY(r.count() == 0);
- }
-}
-
-void tst_qdeclarativelistreference::isValid()
-{
- TestType *tt = new TestType;
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.isValid() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.isValid() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.isValid() == true);
- delete tt;
- QVERIFY(ref.isValid() == false);
- }
-}
-
-void tst_qdeclarativelistreference::object()
-{
- TestType *tt = new TestType;
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.object() == 0);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.object() == 0);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.object() == tt);
- delete tt;
- QVERIFY(ref.object() == 0);
- }
-}
-
-void tst_qdeclarativelistreference::listElementType()
-{
- TestType *tt = new TestType;
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.listElementType() == 0);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.listElementType() == 0);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
- delete tt;
- QVERIFY(ref.listElementType() == 0);
- }
-}
-
-void tst_qdeclarativelistreference::canAppend()
-{
- TestType *tt = new TestType;
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.canAppend() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.canAppend() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.canAppend() == true);
- delete tt;
- QVERIFY(ref.canAppend() == false);
- }
-
- {
- TestType tt;
- tt.property.append = 0;
- QDeclarativeListReference ref(&tt, "data");
- QVERIFY(ref.canAppend() == false);
- }
-}
-
-void tst_qdeclarativelistreference::canAt()
-{
- TestType *tt = new TestType;
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.canAt() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.canAt() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.canAt() == true);
- delete tt;
- QVERIFY(ref.canAt() == false);
- }
-
- {
- TestType tt;
- tt.property.at = 0;
- QDeclarativeListReference ref(&tt, "data");
- QVERIFY(ref.canAt() == false);
- }
-}
-
-void tst_qdeclarativelistreference::canClear()
-{
- TestType *tt = new TestType;
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.canClear() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.canClear() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.canClear() == true);
- delete tt;
- QVERIFY(ref.canClear() == false);
- }
-
- {
- TestType tt;
- tt.property.clear = 0;
- QDeclarativeListReference ref(&tt, "data");
- QVERIFY(ref.canClear() == false);
- }
-}
-
-void tst_qdeclarativelistreference::canCount()
-{
- TestType *tt = new TestType;
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.canCount() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.canCount() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.canCount() == true);
- delete tt;
- QVERIFY(ref.canCount() == false);
- }
-
- {
- TestType tt;
- tt.property.count = 0;
- QDeclarativeListReference ref(&tt, "data");
- QVERIFY(ref.canCount() == false);
- }
-}
-
-void tst_qdeclarativelistreference::append()
-{
- TestType *tt = new TestType;
- QObject object;
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.append(tt) == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.append(tt) == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.append(tt) == true);
- QVERIFY(tt->data.count() == 1);
- QVERIFY(tt->data.at(0) == tt);
- QVERIFY(ref.append(&object) == false);
- QVERIFY(tt->data.count() == 1);
- QVERIFY(tt->data.at(0) == tt);
- QVERIFY(ref.append(0) == true);
- QVERIFY(tt->data.count() == 2);
- QVERIFY(tt->data.at(0) == tt);
- QVERIFY(tt->data.at(1) == 0);
- delete tt;
- QVERIFY(ref.append(0) == false);
- }
-
- {
- TestType tt;
- tt.property.append = 0;
- QDeclarativeListReference ref(&tt, "data");
- QVERIFY(ref.append(&tt) == false);
- }
-}
-
-void tst_qdeclarativelistreference::at()
-{
- TestType *tt = new TestType;
- tt->data.append(tt);
- tt->data.append(0);
- tt->data.append(tt);
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.at(0) == 0);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.at(0) == 0);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.at(0) == tt);
- QVERIFY(ref.at(1) == 0);
- QVERIFY(ref.at(2) == tt);
- delete tt;
- QVERIFY(ref.at(0) == 0);
- }
-
- {
- TestType tt;
- tt.data.append(&tt);
- tt.property.at = 0;
- QDeclarativeListReference ref(&tt, "data");
- QVERIFY(ref.at(0) == 0);
- }
-}
-
-void tst_qdeclarativelistreference::clear()
-{
- TestType *tt = new TestType;
- tt->data.append(tt);
- tt->data.append(0);
- tt->data.append(tt);
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.clear() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.clear() == false);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.clear() == true);
- QVERIFY(tt->data.count() == 0);
- delete tt;
- QVERIFY(ref.clear() == false);
- }
-
- {
- TestType tt;
- tt.property.clear = 0;
- QDeclarativeListReference ref(&tt, "data");
- QVERIFY(ref.clear() == false);
- }
-}
-
-void tst_qdeclarativelistreference::count()
-{
- TestType *tt = new TestType;
- tt->data.append(tt);
- tt->data.append(0);
- tt->data.append(tt);
-
- {
- QDeclarativeListReference ref;
- QVERIFY(ref.count() == 0);
- }
-
- {
- QDeclarativeListReference ref(tt, "blah");
- QVERIFY(ref.count() == 0);
- }
-
- {
- QDeclarativeListReference ref(tt, "data");
- QVERIFY(ref.count() == 3);
- tt->data.removeAt(1);
- QVERIFY(ref.count() == 2);
- delete tt;
- QVERIFY(ref.count() == 0);
- }
-
- {
- TestType tt;
- tt.data.append(&tt);
- tt.property.count = 0;
- QDeclarativeListReference ref(&tt, "data");
- QVERIFY(ref.count() == 0);
- }
-}
-
-void tst_qdeclarativelistreference::copy()
-{
- TestType tt;
- tt.data.append(&tt);
- tt.data.append(0);
- tt.data.append(&tt);
-
- QDeclarativeListReference *r1 = new QDeclarativeListReference(&tt, "data");
- QVERIFY(r1->count() == 3);
-
- QDeclarativeListReference r2(*r1);
- QDeclarativeListReference r3;
- r3 = *r1;
-
- QVERIFY(r2.count() == 3);
- QVERIFY(r3.count() == 3);
-
- delete r1;
-
- QVERIFY(r2.count() == 3);
- QVERIFY(r3.count() == 3);
-
- tt.data.removeAt(2);
-
- QVERIFY(r2.count() == 2);
- QVERIFY(r3.count() == 2);
-}
-
-void tst_qdeclarativelistreference::qmlmetaproperty()
-{
- TestType tt;
- tt.data.append(&tt);
- tt.data.append(0);
- tt.data.append(&tt);
-
- QDeclarativeProperty prop(&tt, QLatin1String("data"));
- QVariant v = prop.read();
- QVERIFY(v.userType() == qMetaTypeId<QDeclarativeListReference>());
- QDeclarativeListReference ref = qvariant_cast<QDeclarativeListReference>(v);
- QVERIFY(ref.count() == 3);
- QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
-}
-
-void tst_qdeclarativelistreference::engineTypes()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("engineTypes.qml"));
-
- QObject *o = component.create();
- QVERIFY(o);
-
- QDeclarativeProperty p1(o, QLatin1String("myList"));
- QVERIFY(p1.propertyTypeCategory() == QDeclarativeProperty::Normal);
-
- QDeclarativeProperty p2(o, QLatin1String("myList"), engine.rootContext());
- QVERIFY(p2.propertyTypeCategory() == QDeclarativeProperty::List);
- QVariant v = p2.read();
- QVERIFY(v.userType() == qMetaTypeId<QDeclarativeListReference>());
- QDeclarativeListReference ref = qvariant_cast<QDeclarativeListReference>(v);
- QVERIFY(ref.count() == 2);
- QVERIFY(ref.listElementType());
- QVERIFY(ref.listElementType() != &QObject::staticMetaObject);
-
- delete o;
-}
-
-void tst_qdeclarativelistreference::variantToList()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("variantToList.qml"));
-
- QObject *o = component.create();
- QVERIFY(o);
-
- QVERIFY(o->property("value").userType() == qMetaTypeId<QDeclarativeListReference>());
- QCOMPARE(o->property("test").toInt(), 1);
-
- delete o;
-}
-
-QTEST_MAIN(tst_qdeclarativelistreference)
-
-#include "tst_qdeclarativelistreference.moc"
diff --git a/tests/auto/declarative/qdeclarativelocale/qdeclarativelocale.pro b/tests/auto/declarative/qdeclarativelocale/qdeclarativelocale.pro
deleted file mode 100644
index 75ff0e9504..0000000000
--- a/tests/auto/declarative/qdeclarativelocale/qdeclarativelocale.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativelocale
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativelocale.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += declarative testlib
diff --git a/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp b/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp
deleted file mode 100644
index bf5c8c7af4..0000000000
--- a/tests/auto/declarative/qdeclarativelocale/tst_qdeclarativelocale.cpp
+++ /dev/null
@@ -1,1183 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QDebug>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtCore/QDateTime>
-#include <qcolor.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativelocale : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativelocale() { }
-
-private slots:
- void defaultLocale();
-
- void properties_data();
- void properties();
- void currencySymbol_data();
- void currencySymbol();
- void monthName_data();
- void monthName();
- void standaloneMonthName_data();
- void standaloneMonthName();
- void dayName_data();
- void dayName();
- void standaloneDayName_data();
- void standaloneDayName();
- void weekDays_data();
- void weekDays();
- void uiLanguages_data();
- void uiLanguages();
- void dateFormat_data();
- void dateFormat();
- void dateTimeFormat_data();
- void dateTimeFormat();
- void timeFormat_data();
- void timeFormat();
-
- void dateToLocaleString_data();
- void dateToLocaleString();
- void dateToLocaleStringFormatted_data();
- void dateToLocaleStringFormatted();
- void dateToLocaleDateString_data();
- void dateToLocaleDateString();
- void dateToLocaleDateStringFormatted_data();
- void dateToLocaleDateStringFormatted();
- void dateToLocaleTimeString_data();
- void dateToLocaleTimeString();
- void dateToLocaleTimeStringFormatted_data();
- void dateToLocaleTimeStringFormatted();
- void dateFromLocaleString_data();
- void dateFromLocaleString();
- void dateFromLocaleDateString_data();
- void dateFromLocaleDateString();
- void dateFromLocaleTimeString_data();
- void dateFromLocaleTimeString();
-
- void numberToLocaleString_data();
- void numberToLocaleString();
- void numberToLocaleCurrencyString_data();
- void numberToLocaleCurrencyString();
- void numberFromLocaleString_data();
- void numberFromLocaleString();
- void numberConstToLocaleString();
-
- void stringLocaleCompare_data();
- void stringLocaleCompare();
-
-private:
- void addPropertyData(const QString &l);
- QVariant getProperty(QObject *obj, const QString &locale, const QString &property);
- void addCurrencySymbolData(const QString &locale);
- void addStandardFormatData();
- void addFormatNameData(const QString &locale);
- void addDateTimeFormatData(const QString &l);
- void addDateFormatData(const QString &l);
- void addTimeFormatData(const QString &l);
- QDeclarativeEngine engine;
-};
-
-void tst_qdeclarativelocale::defaultLocale()
-{
- QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QCOMPARE(obj->property("name").toString(), QLocale().name());
-}
-
-#define LOCALE_PROP(type,prop) { #prop, QVariant(type(qlocale.prop())) }
-
-void tst_qdeclarativelocale::addPropertyData(const QString &l)
-{
- QLocale qlocale(l);
-
- struct {
- const char *name;
- QVariant value;
- }
- values[] = {
- LOCALE_PROP(QString,name),
- LOCALE_PROP(QString,amText),
- LOCALE_PROP(QString,pmText),
- LOCALE_PROP(QString,nativeLanguageName),
- LOCALE_PROP(QString,nativeCountryName),
- LOCALE_PROP(QString,decimalPoint),
- LOCALE_PROP(QString,groupSeparator),
- LOCALE_PROP(QString,percent),
- LOCALE_PROP(QString,zeroDigit),
- LOCALE_PROP(QString,negativeSign),
- LOCALE_PROP(QString,positiveSign),
- LOCALE_PROP(QString,exponential),
- LOCALE_PROP(int,firstDayOfWeek),
- LOCALE_PROP(int,measurementSystem),
- LOCALE_PROP(int,textDirection),
- { 0, QVariant() }
- };
-
- int i = 0;
- while (values[i].name) {
- QByteArray n = l.toLatin1() + ':' + values[i].name;
- QTest::newRow(n.constData()) << l << QByteArray(values[i].name) << values[i].value;
- ++i;
- }
-}
-
-void tst_qdeclarativelocale::properties_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<QByteArray>("property");
- QTest::addColumn<QVariant>("value");
-
- addPropertyData("en_US");
- addPropertyData("de_DE");
- addPropertyData("ar_SA");
- addPropertyData("hi_IN");
- addPropertyData("zh_CN");
- addPropertyData("th_TH");
-}
-
-void tst_qdeclarativelocale::properties()
-{
- QFETCH(QString, locale);
- QFETCH(QByteArray, property);
- QFETCH(QVariant, value);
-
- QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QCOMPARE(obj->property(property), value);
-
- delete obj;
-}
-
-void tst_qdeclarativelocale::addCurrencySymbolData(const QString &l)
-{
- QByteArray locale = l.toLatin1();
- QTest::newRow(locale.constData()) << l << -1;
- QByteArray t(locale);
- t += " CurrencyIsoCode";
- QTest::newRow(t.constData()) << l << (int)QLocale::CurrencyIsoCode;
- t = locale + " CurrencySymbol";
- QTest::newRow(t.constData()) << l << (int)QLocale::CurrencySymbol;
- t = locale + " CurrencyDisplayName";
- QTest::newRow(t.constData()) << l << (int)QLocale::CurrencyDisplayName;
-}
-
-void tst_qdeclarativelocale::currencySymbol_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<int>("param");
-
- addCurrencySymbolData("en_US");
- addCurrencySymbolData("de_DE");
- addCurrencySymbolData("ar_SA");
- addCurrencySymbolData("hi_IN");
- addCurrencySymbolData("zh_CN");
- addCurrencySymbolData("th_TH");
-}
-
-void tst_qdeclarativelocale::currencySymbol()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QVariant val;
- QLocale::CurrencySymbolFormat format = QLocale::CurrencySymbol;
-
- if (param >= 0)
- format = QLocale::CurrencySymbolFormat(param);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QMetaObject::invokeMethod(obj, "currencySymbol", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(int(format))));
-
- QCOMPARE(val.toString(), l.currencySymbol(format));
-
- delete obj;
-}
-
-void tst_qdeclarativelocale::addFormatNameData(const QString &l)
-{
- QByteArray locale = l.toLatin1();
- QTest::newRow(locale.constData()) << l << -1;
- QByteArray t(locale);
- t += " LongFormat";
- QTest::newRow(t.constData()) << l << (int)QLocale::LongFormat;
- t = locale + " ShortFormat";
- QTest::newRow(t.constData()) << l << (int)QLocale::ShortFormat;
- t = locale + " NarrowFormat";
- QTest::newRow(t.constData()) << l << (int)QLocale::NarrowFormat;
-}
-
-void tst_qdeclarativelocale::addStandardFormatData()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<int>("param");
-
- addFormatNameData("en_US");
- addFormatNameData("de_DE");
- addFormatNameData("ar_SA");
- addFormatNameData("hi_IN");
- addFormatNameData("zh_CN");
- addFormatNameData("th_TH");
-}
-
-void tst_qdeclarativelocale::monthName_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::monthName()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QVariant val;
- QLocale::FormatType format = QLocale::LongFormat;
- if (param >= 0)
- format = QLocale::FormatType(param);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- for (int i = 0; i <= 11; ++i) {
- QMetaObject::invokeMethod(obj, "monthName", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(i)),
- Q_ARG(QVariant, QVariant(int(format))));
-
- // QLocale January == 1, JS Date January == 0
- QCOMPARE(val.toString(), l.monthName(i+1, format));
- }
-
- delete obj;
-}
-
-void tst_qdeclarativelocale::standaloneMonthName_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::standaloneMonthName()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QVariant val;
- QLocale::FormatType format = QLocale::LongFormat;
- if (param >= 0)
- format = QLocale::FormatType(param);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- for (int i = 0; i <= 11; ++i) {
- QMetaObject::invokeMethod(obj, "standaloneMonthName", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(i)),
- Q_ARG(QVariant, QVariant(int(format))));
-
- // QLocale January == 1, JS Date January == 0
- QCOMPARE(val.toString(), l.standaloneMonthName(i+1, format));
- }
-
- delete obj;
-}
-
-void tst_qdeclarativelocale::dayName_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::dayName()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QVariant val;
- QLocale::FormatType format = QLocale::LongFormat;
- if (param >= 0)
- format = QLocale::FormatType(param);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- for (int i = 1; i <= 7; ++i) {
- QMetaObject::invokeMethod(obj, "dayName", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(i)),
- Q_ARG(QVariant, QVariant(int(format))));
-
- QCOMPARE(val.toString(), l.dayName(i, format));
- }
-
- delete obj;
-}
-
-void tst_qdeclarativelocale::standaloneDayName_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::standaloneDayName()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QVariant val;
- QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- for (int i = 1; i <= 7; ++i) {
- QMetaObject::invokeMethod(obj, "standaloneDayName", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(i)),
- Q_ARG(QVariant, QVariant(int(format))));
-
- QCOMPARE(val.toString(), l.standaloneDayName(i, format));
- }
-
- delete obj;
-}
-
-void tst_qdeclarativelocale::weekDays_data()
-{
- QTest::addColumn<QString>("locale");
-
- QTest::newRow("en_US") << "en_US";
- QTest::newRow("de_DE") << "de_DE";
- QTest::newRow("ar_SA") << "ar_SA";
- QTest::newRow("hi_IN") << "hi_IN";
- QTest::newRow("zh_CN") << "zh_CN";
- QTest::newRow("th_TH") << "th_TH";
-}
-
-void tst_qdeclarativelocale::weekDays()
-{
- QFETCH(QString, locale);
-
- QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QVariant val = obj->property("weekDays");
- QVERIFY(val.type() == QVariant::List);
-
- QList<QVariant> qmlDays = val.toList();
- QList<Qt::DayOfWeek> days = QLocale(locale).weekdays();
-
- QVERIFY(days.count() == qmlDays.count());
-
- for (int i = 0; i < days.count(); ++i) {
- int day = int(days.at(i));
- if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday)
- day = 0;
- QCOMPARE(day, qmlDays.at(i).toInt());
- }
-
- delete obj;
-}
-
-void tst_qdeclarativelocale::uiLanguages_data()
-{
- QTest::addColumn<QString>("locale");
-
- QTest::newRow("en_US") << "en_US";
- QTest::newRow("de_DE") << "de_DE";
- QTest::newRow("ar_SA") << "ar_SA";
- QTest::newRow("hi_IN") << "hi_IN";
- QTest::newRow("zh_CN") << "zh_CN";
- QTest::newRow("th_TH") << "th_TH";
-}
-
-void tst_qdeclarativelocale::uiLanguages()
-{
- QFETCH(QString, locale);
-
- QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QVariant val = obj->property("uiLanguages");
- QVERIFY(val.type() == QVariant::List);
-
- QList<QVariant> qmlLangs = val.toList();
- QStringList langs = QLocale(locale).uiLanguages();
-
- QVERIFY(langs.count() == qmlLangs.count());
-
- for (int i = 0; i < langs.count(); ++i) {
- QCOMPARE(langs.at(i), qmlLangs.at(i).toString());
- }
-
- delete obj;
-}
-
-
-void tst_qdeclarativelocale::dateTimeFormat_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::dateTimeFormat()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QVariant val;
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
- QMetaObject::invokeMethod(obj, "dateTimeFormat", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(param)));
-
- QCOMPARE(val.toString(), l.dateTimeFormat(format));
-}
-
-void tst_qdeclarativelocale::dateFormat_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::dateFormat()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QVariant val;
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
- QMetaObject::invokeMethod(obj, "dateFormat", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(param)));
-
- QCOMPARE(val.toString(), l.dateFormat(format));
-}
-
-void tst_qdeclarativelocale::timeFormat_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::timeFormat()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QVariant val;
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
- QMetaObject::invokeMethod(obj, "timeFormat", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(param)));
-
- QCOMPARE(val.toString(), l.timeFormat(format));
-}
-
-void tst_qdeclarativelocale::dateToLocaleString_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::dateToLocaleString()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
-
- QVariant val;
- QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(param)));
-
- QLocale l(locale);
- QCOMPARE(val.toString(), l.toString(dt, format));
-}
-
-void tst_qdeclarativelocale::addDateTimeFormatData(const QString &l)
-{
- const char *formats[] = {
- "hh:mm dd.MM.yyyy",
- "h:m:sap ddd MMMM d yy",
- "'The date and time is: 'H:mm:ss:zzz dd/MM/yy",
- "MMM d yyyy HH:mm t",
- 0
- };
- QByteArray locale = l.toLatin1();
- int i = 0;
- while (formats[i]) {
- QByteArray t(locale);
- t += " ";
- t += formats[i];
- QTest::newRow(t.constData()) << l << QString(formats[i]);
- ++i;
- }
-}
-
-void tst_qdeclarativelocale::dateToLocaleStringFormatted_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<QString>("format");
-
- addDateTimeFormatData("en_US");
- addDateTimeFormatData("de_DE");
- addDateTimeFormatData("ar_SA");
- addDateTimeFormatData("hi_IN");
- addDateTimeFormatData("zh_CN");
- addDateTimeFormatData("th_TH");
-}
-
-void tst_qdeclarativelocale::dateToLocaleStringFormatted()
-{
- QFETCH(QString, locale);
- QFETCH(QString, format);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QVariant val;
- QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(format)));
-
- QLocale l(locale);
- QCOMPARE(val.toString(), l.toString(dt, format));
-}
-
-void tst_qdeclarativelocale::dateToLocaleDateString_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::dateToLocaleDateString()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
-
- QVariant val;
- QMetaObject::invokeMethod(obj, "toLocaleDateString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(param)));
-
- QLocale l(locale);
- QCOMPARE(val.toString(), l.toString(dt.date(), format));
-}
-
-void tst_qdeclarativelocale::addDateFormatData(const QString &l)
-{
- const char *formats[] = {
- "dd.MM.yyyy",
- "ddd MMMM d yy",
- "'The date is: 'dd/MM/yy",
- "MMM d yyyy",
- 0
- };
- QByteArray locale = l.toLatin1();
- int i = 0;
- while (formats[i]) {
- QByteArray t(locale);
- t += " ";
- t += formats[i];
- QTest::newRow(t.constData()) << l << QString(formats[i]);
- ++i;
- }
-}
-
-void tst_qdeclarativelocale::dateToLocaleDateStringFormatted_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<QString>("format");
-
- addDateFormatData("en_US");
- addDateFormatData("de_DE");
- addDateFormatData("ar_SA");
- addDateFormatData("hi_IN");
- addDateFormatData("zh_CN");
- addDateFormatData("th_TH");
-}
-
-void tst_qdeclarativelocale::dateToLocaleDateStringFormatted()
-{
- QFETCH(QString, locale);
- QFETCH(QString, format);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QVariant val;
- QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(format)));
-
- QLocale l(locale);
- QCOMPARE(val.toString(), l.toString(dt.date(), format));
-}
-
-void tst_qdeclarativelocale::dateToLocaleTimeString_data()
-{
- addStandardFormatData();
-}
-
-void tst_qdeclarativelocale::dateToLocaleTimeString()
-{
- QFETCH(QString, locale);
- QFETCH(int, param);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
-
- QVariant val;
- QMetaObject::invokeMethod(obj, "toLocaleTimeString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(param)));
-
- QLocale l(locale);
- QCOMPARE(val.toString(), l.toString(dt.time(), format));
-}
-
-void tst_qdeclarativelocale::addTimeFormatData(const QString &l)
-{
- const char *formats[] = {
- "hh:mm",
- "h:m:sap",
- "'The time is: 'H:mm:ss:zzz",
- "HH:mm t",
- 0
- };
- QByteArray locale = l.toLatin1();
- int i = 0;
- while (formats[i]) {
- QByteArray t(locale);
- t += " ";
- t += formats[i];
- QTest::newRow(t.constData()) << l << QString(formats[i]);
- ++i;
- }
-}
-
-void tst_qdeclarativelocale::dateToLocaleTimeStringFormatted_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<QString>("format");
-
- addTimeFormatData("en_US");
- addTimeFormatData("de_DE");
- addTimeFormatData("ar_SA");
- addTimeFormatData("hi_IN");
- addTimeFormatData("zh_CN");
- addTimeFormatData("th_TH");
-}
-
-void tst_qdeclarativelocale::dateToLocaleTimeStringFormatted()
-{
- QFETCH(QString, locale);
- QFETCH(QString, format);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QVariant val;
- QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(format)));
-
- QLocale l(locale);
- QCOMPARE(val.toString(), l.toString(dt.time(), format));
-}
-
-void tst_qdeclarativelocale::dateFromLocaleString_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<QString>("format");
-
- QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP";
- QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat();
- QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat();
- QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat();
- QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat();
- QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat);
-}
-
-void tst_qdeclarativelocale::dateFromLocaleString()
-{
- QFETCH(QString, locale);
- QFETCH(QString, format);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7));
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale l(locale);
- QVariant val;
- QMetaObject::invokeMethod(obj, "fromLocaleString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(l.toString(dt, format))),
- Q_ARG(QVariant, QVariant(format)));
-
- QDateTime pd = l.toDateTime(l.toString(dt, format), format);
- QCOMPARE(val.toDateTime(), pd);
-}
-
-void tst_qdeclarativelocale::dateFromLocaleDateString_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<QString>("format");
-
- QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP";
- QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat();
- QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat();
- QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat();
- QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat();
- QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat);
-}
-
-void tst_qdeclarativelocale::dateFromLocaleDateString()
-{
- QFETCH(QString, locale);
- QFETCH(QString, format);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7));
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale l(locale);
- QVariant val;
- QMetaObject::invokeMethod(obj, "fromLocaleDateString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(l.toString(dt, format))),
- Q_ARG(QVariant, QVariant(format)));
-
- QDate pd = l.toDate(l.toString(dt, format), format);
- QCOMPARE(val.toDate(), pd);
-}
-
-void tst_qdeclarativelocale::dateFromLocaleTimeString_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<QString>("format");
-
- QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP";
- QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat();
- QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat();
- QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat();
- QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat);
- QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat();
- QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat);
-}
-
-void tst_qdeclarativelocale::dateFromLocaleTimeString()
-{
- QFETCH(QString, locale);
- QFETCH(QString, format);
-
- QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QDateTime dt;
- dt.setDate(QDate(2011, 10, 7));
- dt.setTime(QTime(18, 53, 48, 345));
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale l(locale);
- QVariant val;
- QMetaObject::invokeMethod(obj, "fromLocaleTimeString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(l.toString(dt, format))),
- Q_ARG(QVariant, QVariant(format)));
-
- QTime pd = l.toTime(l.toString(dt, format), format);
- QCOMPARE(val.toTime(), pd);
-}
-
-void tst_qdeclarativelocale::numberToLocaleString_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<char>("format");
- QTest::addColumn<int>("prec");
-
- QTest::newRow("en_US 1") << "en_US" << 'f' << 2;
- QTest::newRow("en_US 2") << "en_US" << 'g' << 3;
- QTest::newRow("en_US 3") << "en_US" << 'f' << 0;
- QTest::newRow("en_US 4") << "en_US" << 'f' << -1;
- QTest::newRow("de_DE 1") << "de_DE" << 'f' << 2;
- QTest::newRow("de_DE 2") << "de_DE" << 'g' << 3;
- QTest::newRow("ar_SA 1") << "ar_SA" << 'f' << 2;
- QTest::newRow("ar_SA 2") << "ar_SA" << 'g' << 3;
-}
-
-void tst_qdeclarativelocale::numberToLocaleString()
-{
- QFETCH(QString, locale);
- QFETCH(char, format);
- QFETCH(int, prec);
-
- QDeclarativeComponent c(&engine, testFileUrl("number.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- double number = 2344423.3289;
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale l(locale);
- QVariant val;
- QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(number)),
- Q_ARG(QVariant, QVariant(QString(format))),
- Q_ARG(QVariant, QVariant(prec)));
-
- if (prec < 0) prec = 2;
- QCOMPARE(val.toString(), l.toString(number, format, prec));
-}
-
-void tst_qdeclarativelocale::numberToLocaleCurrencyString_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<QString>("symbol");
-
- QTest::newRow("en_US 1") << "en_US" << QString();
- QTest::newRow("en_US 2") << "en_US" << "USD";
- QTest::newRow("de_DE") << "de_DE" << QString();
- QTest::newRow("ar_SA") << "ar_SA" << QString();
- QTest::newRow("hi_IN") << "hi_IN" << QString();
- QTest::newRow("zh_CN") << "zh_CN" << QString();
- QTest::newRow("th_TH") << "th_TH" << QString();
-}
-
-void tst_qdeclarativelocale::numberToLocaleCurrencyString()
-{
- QFETCH(QString, locale);
- QFETCH(QString, symbol);
-
- QDeclarativeComponent c(&engine, testFileUrl("number.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- double number = 2344423.3289;
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QLocale l(locale);
- QVariant val;
- QMetaObject::invokeMethod(obj, "toLocaleCurrencyString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(number)),
- Q_ARG(QVariant, QVariant(symbol)));
-
- QCOMPARE(val.toString(), l.toCurrencyString(number, symbol));
-}
-
-void tst_qdeclarativelocale::numberFromLocaleString_data()
-{
- QTest::addColumn<QString>("locale");
- QTest::addColumn<double>("number");
-
- QTest::newRow("en_US 1") << "en_US" << 1234567.2345;
- QTest::newRow("en_US 2") << "en_US" << 0.234;
- QTest::newRow("en_US 3") << "en_US" << 234.0;
- QTest::newRow("de_DE") << "de_DE" << 1234567.2345;
- QTest::newRow("ar_SA") << "ar_SA" << 1234567.2345;
- QTest::newRow("hi_IN") << "hi_IN" << 1234567.2345;
- QTest::newRow("zh_CN") << "zh_CN" << 1234567.2345;
- QTest::newRow("th_TH") << "th_TH" << 1234567.2345;
-}
-
-void tst_qdeclarativelocale::numberFromLocaleString()
-{
- QFETCH(QString, locale);
- QFETCH(double, number);
-
- QDeclarativeComponent c(&engine, testFileUrl("number.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QLocale l(locale);
- QString strNumber = l.toString(number, 'f');
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant(locale)));
-
- QVariant val;
- QMetaObject::invokeMethod(obj, "fromLocaleString", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, val),
- Q_ARG(QVariant, QVariant(strNumber)));
-
- QCOMPARE(val.toDouble(), l.toDouble(strNumber));
-}
-
-void tst_qdeclarativelocale::numberConstToLocaleString()
-{
- QDeclarativeComponent c(&engine, testFileUrl("number.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
- Q_ARG(QVariant, QVariant("en_US")));
-
- QLocale l("en_US");
- QCOMPARE(obj->property("const1").toString(), l.toString(1234.56, 'f', 2));
- QCOMPARE(obj->property("const2").toString(), l.toString(1234., 'f', 2));
-}
-
-void tst_qdeclarativelocale::stringLocaleCompare_data()
-{
- QTest::addColumn<QString>("string1");
- QTest::addColumn<QString>("string2");
-
- QTest::newRow("before") << "a" << "b";
- QTest::newRow("equal") << "a" << "a";
- QTest::newRow("after") << "b" << "a";
-
- // Copied from QString::localeAwareCompare tests
- // We don't actually change locale - we just care that String.localeCompare()
- // matches QString::localeAwareCompare();
- QTest::newRow("swedish1") << QString("\xe5") << QString("\xe4");
- QTest::newRow("swedish2") << QString("\xe4") << QString("\xf6");
- QTest::newRow("swedish3") << QString("\xe5") << QString("\xf6");
- QTest::newRow("swedish4") << QString("z") << QString("\xe5");
-
- QTest::newRow("german1") << QString("z") << QString("\xe4");
- QTest::newRow("german2") << QString("\xe4") << QString("\xf6");
- QTest::newRow("german3") << QString("z") << QString("\xf6");
-}
-
-void tst_qdeclarativelocale::stringLocaleCompare()
-{
- QFETCH(QString, string1);
- QFETCH(QString, string2);
-
- QDeclarativeComponent c(&engine, testFileUrl("localeCompare.qml"));
-
- QObject *obj = c.create();
- QVERIFY(obj);
-
- obj->setProperty("string1", string1);
- obj->setProperty("string2", string2);
-
- QCOMPARE(obj->property("comparison").toInt(), QString::localeAwareCompare(string1, string2));
-}
-
-QTEST_MAIN(tst_qdeclarativelocale)
-
-#include "tst_qdeclarativelocale.moc"
diff --git a/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro b/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro
deleted file mode 100644
index 8261f6d930..0000000000
--- a/tests/auto/declarative/qdeclarativemetatype/qdeclarativemetatype.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativemetatype
-SOURCES += tst_qdeclarativemetatype.cpp
-macx:CONFIG -= app_bundle
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private widgets testlib
diff --git a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
deleted file mode 100644
index e8748ee56a..0000000000
--- a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <qdeclarative.h>
-
-#include <private/qdeclarativemetatype_p.h>
-#include <private/qdeclarativepropertyvalueinterceptor_p.h>
-
-class tst_qdeclarativemetatype : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativemetatype() {}
-
-private slots:
- void initTestCase();
-
- void qmlParserStatusCast();
- void qmlPropertyValueSourceCast();
- void qmlPropertyValueInterceptorCast();
-
- void isList();
-
- void defaultObject();
-};
-
-class TestType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int foo READ foo)
-
- Q_CLASSINFO("DefaultProperty", "foo")
-public:
- int foo() { return 0; }
-};
-QML_DECLARE_TYPE(TestType);
-
-class ParserStatusTestType : public QObject, public QDeclarativeParserStatus
-{
- Q_OBJECT
- void classBegin(){}
- void componentComplete(){}
- Q_CLASSINFO("DefaultProperty", "foo") // Missing default property
- Q_INTERFACES(QDeclarativeParserStatus)
-};
-QML_DECLARE_TYPE(ParserStatusTestType);
-
-class ValueSourceTestType : public QObject, public QDeclarativePropertyValueSource
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativePropertyValueSource)
-public:
- virtual void setTarget(const QDeclarativeProperty &) {}
-};
-QML_DECLARE_TYPE(ValueSourceTestType);
-
-class ValueInterceptorTestType : public QObject, public QDeclarativePropertyValueInterceptor
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativePropertyValueInterceptor)
-public:
- virtual void setTarget(const QDeclarativeProperty &) {}
- virtual void write(const QVariant &) {}
-};
-QML_DECLARE_TYPE(ValueInterceptorTestType);
-
-void tst_qdeclarativemetatype::initTestCase()
-{
- qmlRegisterType<TestType>("Test", 1, 0, "TestType");
- qmlRegisterType<ParserStatusTestType>("Test", 1, 0, "ParserStatusTestType");
- qmlRegisterType<ValueSourceTestType>("Test", 1, 0, "ValueSourceTestType");
- qmlRegisterType<ValueInterceptorTestType>("Test", 1, 0, "ValueInterceptorTestType");
-}
-
-void tst_qdeclarativemetatype::qmlParserStatusCast()
-{
- QVERIFY(QDeclarativeMetaType::qmlType(QVariant::Int) == 0);
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
- QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>())->parserStatusCast(), -1);
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0);
- QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>())->parserStatusCast(), -1);
-
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
- int cast = QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->parserStatusCast();
- QVERIFY(cast != -1);
- QVERIFY(cast != 0);
-
- ParserStatusTestType t;
- QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QDeclarativeParserStatus *)&t));
-
- QDeclarativeParserStatus *status = reinterpret_cast<QDeclarativeParserStatus *>(reinterpret_cast<char *>((QObject *)&t) + cast);
- QCOMPARE(status, (QDeclarativeParserStatus*)&t);
-}
-
-void tst_qdeclarativemetatype::qmlPropertyValueSourceCast()
-{
- QVERIFY(QDeclarativeMetaType::qmlType(QVariant::Int) == 0);
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
- QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueSourceCast(), -1);
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
- QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->propertyValueSourceCast(), -1);
-
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0);
- int cast = QDeclarativeMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>())->propertyValueSourceCast();
- QVERIFY(cast != -1);
- QVERIFY(cast != 0);
-
- ValueSourceTestType t;
- QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QDeclarativePropertyValueSource *)&t));
-
- QDeclarativePropertyValueSource *source = reinterpret_cast<QDeclarativePropertyValueSource *>(reinterpret_cast<char *>((QObject *)&t) + cast);
- QCOMPARE(source, (QDeclarativePropertyValueSource*)&t);
-}
-
-void tst_qdeclarativemetatype::qmlPropertyValueInterceptorCast()
-{
- QVERIFY(QDeclarativeMetaType::qmlType(QVariant::Int) == 0);
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
- QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueInterceptorCast(), -1);
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
- QCOMPARE(QDeclarativeMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->propertyValueInterceptorCast(), -1);
-
- QVERIFY(QDeclarativeMetaType::qmlType(qMetaTypeId<ValueInterceptorTestType *>()) != 0);
- int cast = QDeclarativeMetaType::qmlType(qMetaTypeId<ValueInterceptorTestType *>())->propertyValueInterceptorCast();
- QVERIFY(cast != -1);
- QVERIFY(cast != 0);
-
- ValueInterceptorTestType t;
- QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QDeclarativePropertyValueInterceptor *)&t));
-
- QDeclarativePropertyValueInterceptor *interceptor = reinterpret_cast<QDeclarativePropertyValueInterceptor *>(reinterpret_cast<char *>((QObject *)&t) + cast);
- QCOMPARE(interceptor, (QDeclarativePropertyValueInterceptor*)&t);
-}
-
-void tst_qdeclarativemetatype::isList()
-{
- QCOMPARE(QDeclarativeMetaType::isList(QVariant::Invalid), false);
- QCOMPARE(QDeclarativeMetaType::isList(QVariant::Int), false);
-
- QDeclarativeListProperty<TestType> list;
-
- QCOMPARE(QDeclarativeMetaType::isList(qMetaTypeId<QDeclarativeListProperty<TestType> >()), true);
-}
-
-void tst_qdeclarativemetatype::defaultObject()
-{
- QVERIFY(QDeclarativeMetaType::defaultProperty(&QObject::staticMetaObject).name() == 0);
- QVERIFY(QDeclarativeMetaType::defaultProperty(&ParserStatusTestType::staticMetaObject).name() == 0);
- QCOMPARE(QString(QDeclarativeMetaType::defaultProperty(&TestType::staticMetaObject).name()), QString("foo"));
-
- QObject o;
- TestType t;
- ParserStatusTestType p;
-
- QVERIFY(QDeclarativeMetaType::defaultProperty((QObject *)0).name() == 0);
- QVERIFY(QDeclarativeMetaType::defaultProperty(&o).name() == 0);
- QVERIFY(QDeclarativeMetaType::defaultProperty(&p).name() == 0);
- QCOMPARE(QString(QDeclarativeMetaType::defaultProperty(&t).name()), QString("foo"));
-}
-
-QTEST_MAIN(tst_qdeclarativemetatype)
-
-#include "tst_qdeclarativemetatype.moc"
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.2.1.pro b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.2.1.pro
deleted file mode 100644
index 21835613af..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.2.1.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-SOURCES = plugin.cpp
-QT = core declarative
-DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType.2.1
-
-QT += core-private gui-private declarative-private
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp
deleted file mode 100644
index 27e0beb4be..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2.1/plugin.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QStringList>
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QDebug>
-
-class MyPluginType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue)
- Q_PROPERTY(int valueOnlyIn2 READ value WRITE setValue)
-
-public:
- MyPluginType(QObject *parent=0) : QObject(parent)
- {
- qWarning("import2.1 worked");
- }
-
- int value() const { return v; }
- void setValue(int i) { v = i; }
-
-private:
- int v;
-};
-
-
-class MyPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
-public:
- MyPlugin()
- {
- qWarning("plugin2.1 created");
- }
-
- void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType");
- qmlRegisterType<MyPluginType>(uri, 2, 1, "MyPluginType");
- }
-};
-
-#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.2.pro b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.2.pro
deleted file mode 100644
index 6d4f5fb301..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.2.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-SOURCES = plugin.cpp
-QT = core declarative
-DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType.2
-
-QT += core-private gui-private declarative-private
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp
deleted file mode 100644
index 904664ee0e..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin.2/plugin.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QStringList>
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QDebug>
-
-class MyPluginType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue)
- Q_PROPERTY(int valueOnlyIn2 READ value WRITE setValue)
-
-public:
- MyPluginType(QObject *parent=0) : QObject(parent)
- {
- qWarning("import2 worked");
- }
-
- int value() const { return v; }
- void setValue(int i) { v = i; }
-
-private:
- int v;
-};
-
-
-class MyPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
-public:
- MyPlugin()
- {
- qWarning("plugin2 created");
- }
-
- void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType");
- qmlRegisterType<MyPluginType>(uri, 2, 0, "MyPluginType");
- }
-};
-
-#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp
deleted file mode 100644
index 267535dd74..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QStringList>
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QDebug>
-
-class MyPluginType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue)
-
-public:
- MyPluginType(QObject *parent=0) : QObject(parent)
- {
- qWarning("import worked");
- }
-
- int value() const { return v; }
- void setValue(int i) { v = i; }
-
-private:
- int v;
-};
-
-
-class MyPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
-public:
- MyPlugin()
- {
- qWarning("plugin created");
- }
-
- void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType");
- qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType");
- }
-};
-
-#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro
deleted file mode 100644
index 61fab02109..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/plugin/plugin.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-SOURCES = plugin.cpp
-QT = core declarative
-DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType
-
-QT += core-private gui-private declarative-private
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp
deleted file mode 100644
index 0052c6ee53..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/plugin.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QStringList>
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QDebug>
-
-class BarPluginType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value)
-
-public:
- int value() const { return 16; }
-};
-
-
-class MyMixedPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
-public:
- MyMixedPlugin()
- {
- }
-
- void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlMixedPluginType");
- qmlRegisterType<BarPluginType>(uri, 1, 0, "Bar");
- }
-};
-
-#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, MyMixedPlugin);
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/pluginMixed.pro b/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/pluginMixed.pro
deleted file mode 100644
index f8b279cbf6..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginMixed/pluginMixed.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-SOURCES = plugin.cpp
-QT = core declarative
-DESTDIR = ../imports/com/nokia/AutoTestQmlMixedPluginType
-
-QT += core-private gui-private declarative-private
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp
deleted file mode 100644
index 6fc6eee1c7..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/plugin.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QStringList>
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QDebug>
-
-class FloorPluginType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value);
-
-public:
- int value() const { return 16; }
-};
-
-
-class MyMixedPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
-public:
- MyMixedPlugin()
- {
- }
-
- void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlVersionPluginType");
- qmlRegisterType<FloorPluginType>(uri, 1, 4, "Floor");
- }
-};
-
-#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, MyMixedPlugin);
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/pluginVersion.pro b/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/pluginVersion.pro
deleted file mode 100644
index 32e017e79d..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginVersion/pluginVersion.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-SOURCES = plugin.cpp
-QT = core declarative
-DESTDIR = ../imports/com/nokia/AutoTestQmlVersionPluginType
-
-QT += core-private gui-private declarative-private
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp
deleted file mode 100644
index 7cb0365abe..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/plugin.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QStringList>
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QDebug>
-
-class MyPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
-public:
- void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestPluginWithQmlFile");
- }
-};
-
-#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro
deleted file mode 100644
index 1b496d689a..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-SOURCES = plugin.cpp
-QT = core declarative
-DESTDIR = ../imports/com/nokia/AutoTestPluginWithQmlFile
-
-QT += core-private gui-private declarative-private
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp
deleted file mode 100644
index 2446c93bf9..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QStringList>
-#include <QtDeclarative/qdeclarativeextensionplugin.h>
-#include <QtDeclarative/qdeclarative.h>
-#include <QDebug>
-
-class MyPluginType : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int value READ value WRITE setValue)
-
-public:
- MyPluginType(QObject *parent=0) : QObject(parent)
- {
- qWarning("import worked");
- }
-
- int value() const { return v; }
- void setValue(int i) { v = i; }
-
-private:
- int v;
-};
-
-
-class MyPlugin : public QDeclarativeExtensionPlugin
-{
- Q_OBJECT
-public:
- MyPlugin()
- {
- qWarning("plugin created");
- }
-
- void registerTypes(const char *uri)
- {
- Q_ASSERT(QLatin1String(uri) == "com.nokia.WrongCase");
- qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType");
- }
-};
-
-#include "plugin.moc"
-
-Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro
deleted file mode 100644
index 5d21114a2f..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-SOURCES = plugin.cpp
-QT = core declarative
-TARGET = Plugin
-DESTDIR = ../imports/com/nokia/WrongCase
-
-QT += core-private gui-private declarative-private
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro
deleted file mode 100644
index 25c6c6ad56..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-QT = core
-TEMPLATE = subdirs
-SUBDIRS = plugin plugin.2 plugin.2.1 pluginWrongCase pluginWithQmlFile pluginMixed pluginVersion
-tst_qdeclarativemoduleplugin_pro.depends += plugin
-SUBDIRS += tst_qdeclarativemoduleplugin.pro
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
deleted file mode 100644
index 46e5358fab..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
+++ /dev/null
@@ -1,353 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <qdir.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QDebug>
-
-#include "../../shared/testhttpserver.h"
-#include "../../shared/util.h"
-
-#define SERVER_ADDR "http://127.0.0.1:14450"
-#define SERVER_PORT 14450
-
-
-class tst_qdeclarativemoduleplugin : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
-
-private slots:
- virtual void initTestCase();
- void importsPlugin();
- void importsPlugin2();
- void importsPlugin21();
- void importsMixedQmlCppPlugin();
- void incorrectPluginCase();
- void importPluginWithQmlFile();
- void remoteImportWithQuotedUrl();
- void remoteImportWithUnquotedUri();
- void versionNotInstalled();
- void versionNotInstalled_data();
- void implicitQmldir();
- void implicitQmldir_data();
-
-private:
- QString m_importsDirectory;
-};
-
-void tst_qdeclarativemoduleplugin::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- m_importsDirectory = directory() + QStringLiteral("/imports");
- QVERIFY2(QFileInfo(m_importsDirectory).isDir(),
- qPrintable(QString::fromLatin1("Imports directory '%1' does not exist.").arg(m_importsDirectory)));
-}
-
-#define VERIFY_ERRORS(errorfile) \
- if (!errorfile) { \
- if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
- qWarning() << "Unexpected Errors:" << component.errors(); \
- QVERIFY(!component.isError()); \
- QVERIFY(component.errors().isEmpty()); \
- } else { \
- QString verify_errors_file_name = testFile(errorfile); \
- QFile file(verify_errors_file_name); \
- QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \
- QByteArray data = file.readAll(); \
- file.close(); \
- QList<QByteArray> expected = data.split('\n'); \
- expected.removeAll(QByteArray("")); \
- QList<QDeclarativeError> errors = component.errors(); \
- QList<QByteArray> actual; \
- for (int ii = 0; ii < errors.count(); ++ii) { \
- const QDeclarativeError &error = errors.at(ii); \
- QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
- QByteArray::number(error.column()) + ":" + \
- error.description().toUtf8(); \
- actual << errorStr; \
- } \
- if (qgetenv("DEBUG") != "" && expected != actual) { \
- qWarning() << "Expected:" << expected << "Actual:" << actual; \
- } \
- if (qgetenv("QDECLARATIVELANGUAGE_UPDATEERRORS") != "" && expected != actual) {\
- QFile file(testFile(errorfile)); \
- QVERIFY(file.open(QIODevice::WriteOnly)); \
- for (int ii = 0; ii < actual.count(); ++ii) { \
- file.write(actual.at(ii)); file.write("\n"); \
- } \
- file.close(); \
- } else { \
- QCOMPARE(expected, actual); \
- } \
- }
-
-void tst_qdeclarativemoduleplugin::importsPlugin()
-{
- QDeclarativeEngine engine;
- engine.addImportPath(m_importsDirectory);
- QTest::ignoreMessage(QtWarningMsg, "plugin created");
- QTest::ignoreMessage(QtWarningMsg, "import worked");
- QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("works.qml")));
- foreach (QDeclarativeError err, component.errors())
- qWarning() << err;
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("value").toInt(),123);
- delete object;
-}
-
-void tst_qdeclarativemoduleplugin::importsPlugin2()
-{
- QDeclarativeEngine engine;
- engine.addImportPath(m_importsDirectory);
- QTest::ignoreMessage(QtWarningMsg, "plugin2 created");
- QTest::ignoreMessage(QtWarningMsg, "import2 worked");
- QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("works2.qml")));
- foreach (QDeclarativeError err, component.errors())
- qWarning() << err;
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("value").toInt(),123);
- delete object;
-}
-
-void tst_qdeclarativemoduleplugin::importsPlugin21()
-{
- QDeclarativeEngine engine;
- engine.addImportPath(m_importsDirectory);
- QTest::ignoreMessage(QtWarningMsg, "plugin2.1 created");
- QTest::ignoreMessage(QtWarningMsg, "import2.1 worked");
- QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("works21.qml")));
- foreach (QDeclarativeError err, component.errors())
- qWarning() << err;
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("value").toInt(),123);
- delete object;
-}
-
-void tst_qdeclarativemoduleplugin::incorrectPluginCase()
-{
- QDeclarativeEngine engine;
- engine.addImportPath(m_importsDirectory);
-
- QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("incorrectCase.qml")));
-
- QList<QDeclarativeError> errors = component.errors();
- QCOMPARE(errors.count(), 1);
-
-#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
-#if defined(Q_OS_MAC)
- QString libname = "libPluGin.dylib";
-#elif defined(Q_OS_WIN32)
- QString libname = "PluGin.dll";
-#endif
- QString expectedError = QLatin1String("plugin cannot be loaded for module \"com.nokia.WrongCase\": File name case mismatch for \"") + QDir(m_importsDirectory).filePath("com/nokia/WrongCase/" + libname) + QLatin1String("\"");
-#else
- QString expectedError = QLatin1String("module \"com.nokia.WrongCase\" plugin \"PluGin\" not found");
-#endif
-
- QCOMPARE(errors.at(0).description(), expectedError);
-}
-
-void tst_qdeclarativemoduleplugin::importPluginWithQmlFile()
-{
- QString path = m_importsDirectory;
-
- // QTBUG-16885: adding an import path with a lower-case "c:" causes assert failure
- // (this only happens if the plugin includes pure QML files)
- #ifdef Q_OS_WIN
- QVERIFY(path.at(0).isUpper() && path.at(1) == QLatin1Char(':'));
- path = path.at(0).toLower() + path.mid(1);
- #endif
-
- QDeclarativeEngine engine;
- engine.addImportPath(path);
-
- QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("pluginWithQmlFile.qml")));
- foreach (QDeclarativeError err, component.errors())
- qWarning() << err;
- VERIFY_ERRORS(0);
- QObject *object = component.create();
- QVERIFY(object != 0);
- delete object;
-}
-
-void tst_qdeclarativemoduleplugin::remoteImportWithQuotedUrl()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(m_importsDirectory);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData("import \"http://127.0.0.1:14450/com/nokia/PureQmlModule\" \nComponentA { width: 300; ComponentB{} }", QUrl());
-
- QTRY_COMPARE(component.status(), QDeclarativeComponent::Ready);
- QObject *object = component.create();
- QCOMPARE(object->property("width").toInt(), 300);
- QVERIFY(object != 0);
- delete object;
-
- foreach (QDeclarativeError err, component.errors())
- qWarning() << err;
- VERIFY_ERRORS(0);
-}
-
-void tst_qdeclarativemoduleplugin::remoteImportWithUnquotedUri()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(m_importsDirectory);
-
- QDeclarativeEngine engine;
- engine.addImportPath(m_importsDirectory);
- QDeclarativeComponent component(&engine);
- component.setData("import com.nokia.PureQmlModule 1.0 \nComponentA { width: 300; ComponentB{} }", QUrl());
-
-
- QTRY_COMPARE(component.status(), QDeclarativeComponent::Ready);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("width").toInt(), 300);
- delete object;
-
- foreach (QDeclarativeError err, component.errors())
- qWarning() << err;
- VERIFY_ERRORS(0);
-}
-
-// QTBUG-17324
-
-void tst_qdeclarativemoduleplugin::importsMixedQmlCppPlugin()
-{
- QDeclarativeEngine engine;
- engine.addImportPath(m_importsDirectory);
-
- {
- QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.qml")));
-
- QObject *o = component.create();
- QVERIFY2(o != 0, QDeclarativeDataTest::msgComponentError(component, &engine));
- QCOMPARE(o->property("test").toBool(), true);
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.2.qml")));
-
- QObject *o = component.create();
- QVERIFY2(o != 0, QDeclarativeDataTest::msgComponentError(component, &engine));
- QCOMPARE(o->property("test").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- delete o;
- }
-
-
-}
-
-void tst_qdeclarativemoduleplugin::versionNotInstalled_data()
-{
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("errorFile");
-
- QTest::newRow("versionNotInstalled") << "versionNotInstalled.qml" << "versionNotInstalled.errors.txt";
- QTest::newRow("versionNotInstalled") << "versionNotInstalled.2.qml" << "versionNotInstalled.2.errors.txt";
-}
-
-void tst_qdeclarativemoduleplugin::versionNotInstalled()
-{
- QFETCH(QString, file);
- QFETCH(QString, errorFile);
-
- QDeclarativeEngine engine;
- engine.addImportPath(m_importsDirectory);
-
- QDeclarativeComponent component(&engine, testFileUrl(file));
- VERIFY_ERRORS(errorFile.toLatin1().constData());
-}
-
-
-// test that errors are reporting correctly for plugin loading and qmldir parsing
-void tst_qdeclarativemoduleplugin::implicitQmldir_data()
-{
- QTest::addColumn<QString>("directory");
- QTest::addColumn<QString>("file");
- QTest::addColumn<QString>("errorFile");
-
- // parsing qmldir succeeds, but plugin specified in the qmldir file doesn't exist
- QTest::newRow("implicitQmldir") << "implicit1" << "temptest.qml" << "implicitQmldir.errors.txt";
-
- // parsing qmldir fails due to syntax errors, etc.
- QTest::newRow("implicitQmldir2") << "implicit2" << "temptest2.qml" << "implicitQmldir.2.errors.txt";
-}
-void tst_qdeclarativemoduleplugin::implicitQmldir()
-{
- QFETCH(QString, directory);
- QFETCH(QString, file);
- QFETCH(QString, errorFile);
-
- QString importPath = testFile(directory);
- QString fileName = directory + QDir::separator() + file;
- QString errorFileName = directory + QDir::separator() + errorFile;
- QUrl testUrl = testFileUrl(fileName);
-
- QDeclarativeEngine engine;
- engine.addImportPath(importPath);
-
- QDeclarativeComponent component(&engine, testUrl);
- QList<QDeclarativeError> errors = component.errors();
- VERIFY_ERRORS(errorFileName.toLatin1().constData());
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- QObject *obj = component.create();
- QVERIFY(!obj);
- delete obj;
-}
-
-
-QTEST_MAIN(tst_qdeclarativemoduleplugin)
-
-#include "tst_qdeclarativemoduleplugin.moc"
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro
deleted file mode 100644
index 58f329d095..0000000000
--- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativemoduleplugin
-
-HEADERS = ../../shared/testhttpserver.h
-SOURCES = tst_qdeclarativemoduleplugin.cpp \
- ../../shared/testhttpserver.cpp
-CONFIG -= app_bundle
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-testImportFiles.files = imports
-testImportFiles.path = .
-DEPLOYMENT += testImportFiles
-
-QT += core-private gui-private declarative-private network testlib
diff --git a/tests/auto/declarative/qdeclarativeparser/qdeclarativeparser.pro b/tests/auto/declarative/qdeclarativeparser/qdeclarativeparser.pro
deleted file mode 100644
index f864337fa7..0000000000
--- a/tests/auto/declarative/qdeclarativeparser/qdeclarativeparser.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeparser
-QT += qmldevtools-private testlib
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeparser.cpp
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
diff --git a/tests/auto/declarative/qdeclarativeparser/tst_qdeclarativeparser.cpp b/tests/auto/declarative/qdeclarativeparser/tst_qdeclarativeparser.cpp
deleted file mode 100644
index 8c3b93615d..0000000000
--- a/tests/auto/declarative/qdeclarativeparser/tst_qdeclarativeparser.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qdeclarativejsengine_p.h>
-#include <private/qdeclarativejsparser_p.h>
-#include <private/qdeclarativejslexer_p.h>
-#include <private/qdeclarativejsastvisitor_p.h>
-#include <private/qdeclarativejsast_p.h>
-
-#include <qtest.h>
-#include <QDir>
-#include <QDebug>
-#include <cstdlib>
-
-class tst_qdeclarativeparser : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeparser();
-
-private slots:
- void initTestCase();
- void qmlParser_data();
- void qmlParser();
-
-private:
- QStringList excludedDirs;
-
- QStringList findFiles(const QDir &);
-};
-
-namespace check {
-
-using namespace QDeclarativeJS;
-
-class Check: public AST::Visitor
-{
- Engine *engine;
- QList<AST::Node *> nodeStack;
-
-public:
- Check(Engine *engine)
- : engine(engine)
- {
- }
-
- void operator()(AST::Node *node)
- {
- AST::Node::accept(node, this);
- }
-
- void checkNode(AST::Node *node)
- {
- if (! nodeStack.isEmpty()) {
- AST::Node *parent = nodeStack.last();
- const quint32 parentBegin = parent->firstSourceLocation().begin();
- const quint32 parentEnd = parent->lastSourceLocation().end();
-
- QVERIFY(node->firstSourceLocation().begin() >= parentBegin);
- QVERIFY(node->lastSourceLocation().end() <= parentEnd);
- }
- }
-
- virtual bool preVisit(AST::Node *node)
- {
- checkNode(node);
- nodeStack.append(node);
- return true;
- }
-
- virtual void postVisit(AST::Node *)
- {
- nodeStack.removeLast();
- }
-};
-
-}
-
-tst_qdeclarativeparser::tst_qdeclarativeparser()
-{
-}
-
-void tst_qdeclarativeparser::initTestCase()
-{
- // Add directories you want excluded here
-
- // These snippets are not expected to run on their own.
- excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex";
- excludedDirs << "doc/src/snippets/declarative/qtbinding";
- excludedDirs << "doc/src/snippets/declarative/imports";
- excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex";
- excludedDirs << "doc/src/snippets/qtquick1/qtbinding";
- excludedDirs << "doc/src/snippets/qtquick1/imports";
-}
-
-QStringList tst_qdeclarativeparser::findFiles(const QDir &d)
-{
- for (int ii = 0; ii < excludedDirs.count(); ++ii) {
- QString s = excludedDirs.at(ii);
- if (d.absolutePath().endsWith(s))
- return QStringList();
- }
-
- QStringList rv;
-
- QStringList files = d.entryList(QStringList() << QLatin1String("*.qml") << QLatin1String("*.js"),
- QDir::Files);
- foreach (const QString &file, files) {
- rv << d.absoluteFilePath(file);
- }
-
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
- QDir::NoSymLinks);
- foreach (const QString &dir, dirs) {
- QDir sub = d;
- sub.cd(dir);
- rv << findFiles(sub);
- }
-
- return rv;
-}
-
-/*
-This test checks all the qml and js files in the declarative UI source tree
-and ensures that the subnode's source locations are inside parent node's source locations
-*/
-
-void tst_qdeclarativeparser::qmlParser_data()
-{
- QTest::addColumn<QString>("file");
-
- QString examples = QLatin1String(SRCDIR) + "/../../../../examples/";
- QString tests = QLatin1String(SRCDIR) + "/../../../../tests/";
-
- QStringList files;
- files << findFiles(QDir(examples));
- files << findFiles(QDir(tests));
-
- foreach (const QString &file, files)
- QTest::newRow(qPrintable(file)) << file;
-}
-
-void tst_qdeclarativeparser::qmlParser()
-{
- QFETCH(QString, file);
-
- using namespace QDeclarativeJS;
-
- QString code;
-
- QFile f(file);
- if (f.open(QFile::ReadOnly))
- code = QString::fromUtf8(f.readAll());
-
- const bool qmlMode = file.endsWith(QLatin1String(".qml"));
-
- Engine engine;
- Lexer lexer(&engine);
- lexer.setCode(code, 1, qmlMode);
- Parser parser(&engine);
- if (qmlMode)
- parser.parse();
- else
- parser.parseProgram();
-
- check::Check chk(&engine);
- chk(parser.rootNode());
-}
-
-QTEST_MAIN(tst_qdeclarativeparser)
-
-#include "tst_qdeclarativeparser.moc"
diff --git a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro
deleted file mode 100644
index 45b240b9bd..0000000000
--- a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeproperty
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeproperty.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private widgets testlib
diff --git a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp
deleted file mode 100644
index 9dfe8db09b..0000000000
--- a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp
+++ /dev/null
@@ -1,1721 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeproperty.h>
-#include <QtDeclarative/private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativebinding_p.h>
-#include <QtWidgets/QLineEdit>
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qdir.h>
-#include "../../shared/util.h"
-
-#include <QDebug>
-class MyQmlObject : public QObject
-{
- Q_OBJECT
-public:
- MyQmlObject() {}
-};
-
-QML_DECLARE_TYPE(MyQmlObject);
-
-class MyAttached : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int foo READ foo WRITE setFoo)
-public:
- MyAttached(QObject *parent) : QObject(parent), m_foo(13) {}
-
- int foo() const { return m_foo; }
- void setFoo(int f) { m_foo = f; }
-
-private:
- int m_foo;
-};
-
-class MyContainer : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<MyQmlObject> children READ children)
-public:
- MyContainer() {}
-
- QDeclarativeListProperty<MyQmlObject> children() { return QDeclarativeListProperty<MyQmlObject>(this, m_children); }
-
- static MyAttached *qmlAttachedProperties(QObject *o) {
- return new MyAttached(o);
- }
-
-private:
- QList<MyQmlObject*> m_children;
-};
-
-QML_DECLARE_TYPE(MyContainer);
-QML_DECLARE_TYPEINFO(MyContainer, QML_HAS_ATTACHED_PROPERTIES)
-
-class tst_qdeclarativeproperty : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeproperty() {}
-
-private slots:
- void initTestCase();
-
- // Constructors
- void qmlmetaproperty();
- void qmlmetaproperty_object();
- void qmlmetaproperty_object_string();
- void qmlmetaproperty_object_context();
- void qmlmetaproperty_object_string_context();
-
- // Methods
- void name();
- void read();
- void write();
- void reset();
-
- // Functionality
- void writeObjectToList();
- void writeListToList();
-
- //writeToReadOnly();
-
- void urlHandling_data();
- void urlHandling();
-
- void variantMapHandling_data();
- void variantMapHandling();
-
- // Bugs
- void crashOnValueProperty();
- void aliasPropertyBindings();
- void noContext();
- void assignEmptyVariantMap();
-
- void copy();
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qdeclarativeproperty::qmlmetaproperty()
-{
- QDeclarativeProperty prop;
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), -1);
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
-}
-
-class PropertyObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int defaultProperty READ defaultProperty)
- Q_PROPERTY(QRect rectProperty READ rectProperty)
- Q_PROPERTY(QRect wrectProperty READ wrectProperty WRITE setWRectProperty)
- Q_PROPERTY(QUrl url READ url WRITE setUrl)
- Q_PROPERTY(QVariantMap variantMap READ variantMap WRITE setVariantMap)
- Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
- Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
- Q_PROPERTY(MyQmlObject *qmlObject READ qmlObject)
-
- Q_CLASSINFO("DefaultProperty", "defaultProperty")
-public:
- PropertyObject() : m_resetProperty(9) {}
-
- int defaultProperty() { return 10; }
- QRect rectProperty() { return QRect(10, 10, 1, 209); }
-
- QRect wrectProperty() { return m_rect; }
- void setWRectProperty(const QRect &r) { m_rect = r; }
-
- QUrl url() { return m_url; }
- void setUrl(const QUrl &u) { m_url = u; }
-
- QVariantMap variantMap() const { return m_variantMap; }
- void setVariantMap(const QVariantMap &variantMap) { m_variantMap = variantMap; }
-
- int resettableProperty() const { return m_resetProperty; }
- void setResettableProperty(int r) { m_resetProperty = r; }
- void resetProperty() { m_resetProperty = 9; }
-
- int propertyWithNotify() const { return m_propertyWithNotify; }
- void setPropertyWithNotify(int i) { m_propertyWithNotify = i; emit oddlyNamedNotifySignal(); }
-
- MyQmlObject *qmlObject() { return &m_qmlObject; }
-
-signals:
- void clicked();
- void oddlyNamedNotifySignal();
-
-private:
- int m_resetProperty;
- QRect m_rect;
- QUrl m_url;
- QVariantMap m_variantMap;
- int m_propertyWithNotify;
- MyQmlObject m_qmlObject;
-};
-
-QML_DECLARE_TYPE(PropertyObject);
-
-void tst_qdeclarativeproperty::qmlmetaproperty_object()
-{
- QObject object; // Has no default property
- PropertyObject dobject; // Has default property
-
- {
- QDeclarativeProperty prop(&object);
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), -1);
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-
- {
- QDeclarativeProperty prop(&dobject);
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- binding.data()->setTarget(prop);
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("defaultProperty"));
- QCOMPARE(prop.read(), QVariant(10));
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), true);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Property);
- QCOMPARE(prop.isProperty(), true);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), true);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(prop.propertyType(), (int)QVariant::Int);
- QCOMPARE(prop.propertyTypeName(), "int");
- QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int");
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding != 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding.data());
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-}
-
-void tst_qdeclarativeproperty::qmlmetaproperty_object_string()
-{
- QObject object;
- PropertyObject dobject;
-
- {
- QDeclarativeProperty prop(&object, QString("defaultProperty"));
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), -1);
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-
- {
- QDeclarativeProperty prop(&dobject, QString("defaultProperty"));
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- binding.data()->setTarget(prop);
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("defaultProperty"));
- QCOMPARE(prop.read(), QVariant(10));
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), true);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Property);
- QCOMPARE(prop.isProperty(), true);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), true);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(prop.propertyType(), (int)QVariant::Int);
- QCOMPARE(prop.propertyTypeName(), "int");
- QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int");
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding != 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding.data());
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-
- {
- QDeclarativeProperty prop(&dobject, QString("onClicked"));
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- binding.data()->setTarget(prop);
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("onClicked"));
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant("Hello")), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
- QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), true);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QCOMPARE(prop.property().name(), (const char *)0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression != 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression.data());
- QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()"));
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-
- {
- QDeclarativeProperty prop(&dobject, QString("onPropertyWithNotifyChanged"));
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- binding.data()->setTarget(prop);
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("onOddlyNamedNotifySignal"));
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant("Hello")), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()"));
- QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), true);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QCOMPARE(prop.property().name(), (const char *)0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression != 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression.data());
- QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()"));
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-}
-
-void tst_qdeclarativeproperty::qmlmetaproperty_object_context()
-{
- QObject object; // Has no default property
- PropertyObject dobject; // Has default property
-
- {
- QDeclarativeProperty prop(&object, engine.rootContext());
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), -1);
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-
- {
- QDeclarativeProperty prop(&dobject, engine.rootContext());
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- binding.data()->setTarget(prop);
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("defaultProperty"));
- QCOMPARE(prop.read(), QVariant(10));
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), true);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Property);
- QCOMPARE(prop.isProperty(), true);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), true);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(prop.propertyType(), (int)QVariant::Int);
- QCOMPARE(prop.propertyTypeName(), "int");
- QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int");
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding != 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding.data());
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-}
-
-void tst_qdeclarativeproperty::qmlmetaproperty_object_string_context()
-{
- QObject object;
- PropertyObject dobject;
-
- {
- QDeclarativeProperty prop(&object, QString("defaultProperty"), engine.rootContext());
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString());
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Invalid);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), false);
- QCOMPARE(prop.object(), (QObject *)0);
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QVERIFY(prop.property().name() == 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), -1);
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-
- {
- QDeclarativeProperty prop(&dobject, QString("defaultProperty"), engine.rootContext());
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- binding.data()->setTarget(prop);
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("defaultProperty"));
- QCOMPARE(prop.read(), QVariant(10));
- QCOMPARE(prop.write(QVariant()), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), true);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QVERIFY(prop.method().signature() == 0);
- QCOMPARE(prop.type(), QDeclarativeProperty::Property);
- QCOMPARE(prop.isProperty(), true);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), true);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), false);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(prop.propertyType(), (int)QVariant::Int);
- QCOMPARE(prop.propertyTypeName(), "int");
- QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int");
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding != 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == binding.data());
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression == 0);
- QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-
- {
- QDeclarativeProperty prop(&dobject, QString("onClicked"), engine.rootContext());
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- binding.data()->setTarget(prop);
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("onClicked"));
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant("Hello")), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
- QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), true);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QCOMPARE(prop.property().name(), (const char *)0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression != 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression.data());
- QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()"));
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-
- {
- QDeclarativeProperty prop(&dobject, QString("onPropertyWithNotifyChanged"), engine.rootContext());
-
- QWeakPointer<QDeclarativeBinding> binding(new QDeclarativeBinding(QLatin1String("null"), 0, engine.rootContext()));
- binding.data()->setTarget(prop);
- QVERIFY(binding != 0);
- QWeakPointer<QDeclarativeExpression> expression(new QDeclarativeExpression());
- QVERIFY(expression != 0);
-
- QObject *obj = new QObject;
-
- QCOMPARE(prop.name(), QString("onOddlyNamedNotifySignal"));
- QCOMPARE(prop.read(), QVariant());
- QCOMPARE(prop.write(QVariant("Hello")), false);
- QCOMPARE(prop.hasNotifySignal(), false);
- QCOMPARE(prop.needsNotifySignal(), false);
- QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
- QCOMPARE(prop.connectNotifySignal(obj, 0), false);
- QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
- QCOMPARE(prop.connectNotifySignal(obj, -1), false);
- QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()"));
- QCOMPARE(prop.type(), QDeclarativeProperty::SignalProperty);
- QCOMPARE(prop.isProperty(), false);
- QCOMPARE(prop.isWritable(), false);
- QCOMPARE(prop.isDesignable(), false);
- QCOMPARE(prop.isResettable(), false);
- QCOMPARE(prop.isSignalProperty(), true);
- QCOMPARE(prop.isValid(), true);
- QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
- QCOMPARE(prop.propertyTypeCategory(), QDeclarativeProperty::InvalidCategory);
- QCOMPARE(prop.propertyType(), 0);
- QCOMPARE(prop.propertyTypeName(), (const char *)0);
- QCOMPARE(prop.property().name(), (const char *)0);
- QVERIFY(QDeclarativePropertyPrivate::binding(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setBinding(prop, binding.data()) == 0);
- QVERIFY(binding == 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == 0);
- QVERIFY(QDeclarativePropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
- QVERIFY(expression != 0);
- QVERIFY(QDeclarativePropertyPrivate::signalExpression(prop) == expression.data());
- QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()"));
- QCOMPARE(QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), -1);
-
- delete obj;
- }
-}
-
-void tst_qdeclarativeproperty::name()
-{
- {
- QDeclarativeProperty p;
- QCOMPARE(p.name(), QString());
- }
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o);
- QCOMPARE(p.name(), QString("defaultProperty"));
- }
-
- {
- QObject o;
- QDeclarativeProperty p(&o, QString("objectName"));
- QCOMPARE(p.name(), QString("objectName"));
- }
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "onClicked");
- QCOMPARE(p.name(), QString("onClicked"));
- }
-
- {
- QObject o;
- QDeclarativeProperty p(&o, "onClicked");
- QCOMPARE(p.name(), QString());
- }
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged");
- QCOMPARE(p.name(), QString("onOddlyNamedNotifySignal"));
- }
-
- {
- QObject o;
- QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged");
- QCOMPARE(p.name(), QString());
- }
-
- {
- QObject o;
- QDeclarativeProperty p(&o, "foo");
- QCOMPARE(p.name(), QString());
- }
-
- {
- QDeclarativeProperty p(0, "foo");
- QCOMPARE(p.name(), QString());
- }
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "rectProperty");
- QCOMPARE(p.name(), QString("rectProperty"));
- }
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "rectProperty.x");
- QCOMPARE(p.name(), QString("rectProperty.x"));
- }
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "rectProperty.foo");
- QCOMPARE(p.name(), QString());
- }
-}
-
-void tst_qdeclarativeproperty::read()
-{
- // Invalid
- {
- QDeclarativeProperty p;
- QCOMPARE(p.read(), QVariant());
- }
-
- // Default prop
- {
- PropertyObject o;
- QDeclarativeProperty p(&o);
- QCOMPARE(p.read(), QVariant(10));
- }
-
- // Invalid default prop
- {
- QObject o;
- QDeclarativeProperty p(&o);
- QCOMPARE(p.read(), QVariant());
- }
-
- // Value prop by name
- {
- QObject o;
-
- QDeclarativeProperty p(&o, "objectName");
- QCOMPARE(p.read(), QVariant(QString()));
-
- o.setObjectName("myName");
-
- QCOMPARE(p.read(), QVariant("myName"));
- }
-
- // Value prop by name (static)
- {
- QObject o;
-
- QCOMPARE(QDeclarativeProperty::read(&o, "objectName"), QVariant(QString()));
-
- o.setObjectName("myName");
-
- QCOMPARE(QDeclarativeProperty::read(&o, "objectName"), QVariant("myName"));
- }
-
- // Value-type prop
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "rectProperty.x");
- QCOMPARE(p.read(), QVariant(10));
- }
-
- // Invalid value-type prop
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "rectProperty.foo");
- QCOMPARE(p.read(), QVariant());
- }
-
- // Signal property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "onClicked");
- QCOMPARE(p.read(), QVariant());
-
- QVERIFY(0 == QDeclarativePropertyPrivate::setSignalExpression(p, new QDeclarativeExpression()));
- QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
-
- QCOMPARE(p.read(), QVariant());
- }
-
- // Automatic signal property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged");
- QCOMPARE(p.read(), QVariant());
-
- QVERIFY(0 == QDeclarativePropertyPrivate::setSignalExpression(p, new QDeclarativeExpression()));
- QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
-
- QCOMPARE(p.read(), QVariant());
- }
-
- // Deleted object
- {
- PropertyObject *o = new PropertyObject;
- QDeclarativeProperty p(o, "rectProperty.x");
- QCOMPARE(p.read(), QVariant(10));
- delete o;
- QCOMPARE(p.read(), QVariant());
- }
-
- // Object property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "qmlObject");
- QCOMPARE(p.propertyTypeCategory(), QDeclarativeProperty::Object);
- QCOMPARE(p.propertyType(), qMetaTypeId<MyQmlObject*>());
- QVariant v = p.read();
- QVERIFY(v.userType() == QMetaType::QObjectStar);
- QVERIFY(qvariant_cast<QObject *>(v) == o.qmlObject());
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("readSynthesizedObject.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QDeclarativeProperty p(object, "test", &engine);
-
- QCOMPARE(p.propertyTypeCategory(), QDeclarativeProperty::Object);
- QVERIFY(p.propertyType() != QMetaType::QObjectStar);
-
- QVariant v = p.read();
- QVERIFY(v.userType() == QMetaType::QObjectStar);
- QCOMPARE(qvariant_cast<QObject *>(v)->property("a").toInt(), 10);
- QCOMPARE(qvariant_cast<QObject *>(v)->property("b").toInt(), 19);
- }
- { // static
- QDeclarativeComponent component(&engine, testFileUrl("readSynthesizedObject.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVariant v = QDeclarativeProperty::read(object, "test", &engine);
- QVERIFY(v.userType() == QMetaType::QObjectStar);
- QCOMPARE(qvariant_cast<QObject *>(v)->property("a").toInt(), 10);
- QCOMPARE(qvariant_cast<QObject *>(v)->property("b").toInt(), 19);
- }
-
- // Attached property
- {
- QDeclarativeComponent component(&engine);
- component.setData("import Test 1.0\nMyContainer { }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QDeclarativeProperty p(object, "MyContainer.foo", qmlContext(object));
- QCOMPARE(p.read(), QVariant(13));
- delete object;
- }
- {
- QDeclarativeComponent component(&engine);
- component.setData("import Test 1.0\nMyContainer { MyContainer.foo: 10 }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QDeclarativeProperty p(object, "MyContainer.foo", qmlContext(object));
- QCOMPARE(p.read(), QVariant(10));
- delete object;
- }
- {
- QDeclarativeComponent component(&engine);
- component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QDeclarativeProperty p(object, "Foo.MyContainer.foo", qmlContext(object));
- QCOMPARE(p.read(), QVariant(10));
- delete object;
- }
- { // static
- QDeclarativeComponent component(&engine);
- component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(QDeclarativeProperty::read(object, "Foo.MyContainer.foo", qmlContext(object)), QVariant(10));
- delete object;
- }
-}
-
-void tst_qdeclarativeproperty::write()
-{
- // Invalid
- {
- QDeclarativeProperty p;
- QCOMPARE(p.write(QVariant(10)), false);
- }
-
- // Read-only default prop
- {
- PropertyObject o;
- QDeclarativeProperty p(&o);
- QCOMPARE(p.write(QVariant(10)), false);
- }
-
- // Invalid default prop
- {
- QObject o;
- QDeclarativeProperty p(&o);
- QCOMPARE(p.write(QVariant(10)), false);
- }
-
- // Read-only prop by name
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, QString("defaultProperty"));
- QCOMPARE(p.write(QVariant(10)), false);
- }
-
- // Writable prop by name
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, QString("objectName"));
- QCOMPARE(o.objectName(), QString());
- QCOMPARE(p.write(QVariant(QString("myName"))), true);
- QCOMPARE(o.objectName(), QString("myName"));
- }
-
- // Writable prop by name (static)
- {
- PropertyObject o;
- QCOMPARE(QDeclarativeProperty::write(&o, QString("objectName"), QVariant(QString("myName"))), true);
- QCOMPARE(o.objectName(), QString("myName"));
- }
-
- // Deleted object
- {
- PropertyObject *o = new PropertyObject;
- QDeclarativeProperty p(o, QString("objectName"));
- QCOMPARE(p.write(QVariant(QString("myName"))), true);
- QCOMPARE(o->objectName(), QString("myName"));
-
- delete o;
-
- QCOMPARE(p.write(QVariant(QString("myName"))), false);
- }
-
- // Signal property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "onClicked");
- QCOMPARE(p.write(QVariant("console.log(1921)")), false);
-
- QVERIFY(0 == QDeclarativePropertyPrivate::setSignalExpression(p, new QDeclarativeExpression()));
- QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
-
- QCOMPARE(p.write(QVariant("console.log(1921)")), false);
-
- QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
- }
-
- // Automatic signal property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged");
- QCOMPARE(p.write(QVariant("console.log(1921)")), false);
-
- QVERIFY(0 == QDeclarativePropertyPrivate::setSignalExpression(p, new QDeclarativeExpression()));
- QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
-
- QCOMPARE(p.write(QVariant("console.log(1921)")), false);
-
- QVERIFY(0 != QDeclarativePropertyPrivate::signalExpression(p));
- }
-
- // Value-type property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "wrectProperty");
-
- QCOMPARE(o.wrectProperty(), QRect());
- QCOMPARE(p.write(QRect(1, 13, 99, 8)), true);
- QCOMPARE(o.wrectProperty(), QRect(1, 13, 99, 8));
-
- QDeclarativeProperty p2(&o, "wrectProperty.x");
- QCOMPARE(p2.read(), QVariant(1));
- QCOMPARE(p2.write(QVariant(6)), true);
- QCOMPARE(p2.read(), QVariant(6));
- QCOMPARE(o.wrectProperty(), QRect(6, 13, 99, 8));
- }
-
- // URL-property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "url");
-
- QCOMPARE(p.write(QUrl("main.qml")), true);
- QCOMPARE(o.url(), QUrl("main.qml"));
-
- QDeclarativeProperty p2(&o, "url", engine.rootContext());
-
- QUrl result = engine.baseUrl().resolved(QUrl("main.qml"));
- QVERIFY(result != QUrl("main.qml"));
-
- QCOMPARE(p2.write(QUrl("main.qml")), true);
- QCOMPARE(o.url(), result);
- }
- { // static
- PropertyObject o;
-
- QCOMPARE(QDeclarativeProperty::write(&o, "url", QUrl("main.qml")), true);
- QCOMPARE(o.url(), QUrl("main.qml"));
-
- QUrl result = engine.baseUrl().resolved(QUrl("main.qml"));
- QVERIFY(result != QUrl("main.qml"));
-
- QCOMPARE(QDeclarativeProperty::write(&o, "url", QUrl("main.qml"), engine.rootContext()), true);
- QCOMPARE(o.url(), result);
- }
-
- // VariantMap-property
- QVariantMap vm;
- vm.insert("key", "value");
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "variantMap");
-
- QCOMPARE(p.write(vm), true);
- QCOMPARE(o.variantMap(), vm);
-
- QDeclarativeProperty p2(&o, "variantMap", engine.rootContext());
-
- QCOMPARE(p2.write(vm), true);
- QCOMPARE(o.variantMap(), vm);
- }
- { // static
- PropertyObject o;
-
- QCOMPARE(QDeclarativeProperty::write(&o, "variantMap", vm), true);
- QCOMPARE(o.variantMap(), vm);
-
- QCOMPARE(QDeclarativeProperty::write(&o, "variantMap", vm, engine.rootContext()), true);
- QCOMPARE(o.variantMap(), vm);
- }
-
- // Attached property
- {
- QDeclarativeComponent component(&engine);
- component.setData("import Test 1.0\nMyContainer { }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QDeclarativeProperty p(object, "MyContainer.foo", qmlContext(object));
- p.write(QVariant(99));
- QCOMPARE(p.read(), QVariant(99));
- delete object;
- }
- {
- QDeclarativeComponent component(&engine);
- component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QDeclarativeProperty p(object, "Foo.MyContainer.foo", qmlContext(object));
- p.write(QVariant(99));
- QCOMPARE(p.read(), QVariant(99));
- delete object;
- }
-}
-
-void tst_qdeclarativeproperty::reset()
-{
- // Invalid
- {
- QDeclarativeProperty p;
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Read-only default prop
- {
- PropertyObject o;
- QDeclarativeProperty p(&o);
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Invalid default prop
- {
- QObject o;
- QDeclarativeProperty p(&o);
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Non-resettable-only prop by name
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, QString("defaultProperty"));
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Resettable prop by name
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, QString("resettableProperty"));
-
- QCOMPARE(p.read(), QVariant(9));
- QCOMPARE(p.write(QVariant(11)), true);
- QCOMPARE(p.read(), QVariant(11));
-
- QCOMPARE(p.isResettable(), true);
- QCOMPARE(p.reset(), true);
-
- QCOMPARE(p.read(), QVariant(9));
- }
-
- // Deleted object
- {
- PropertyObject *o = new PropertyObject;
-
- QDeclarativeProperty p(o, QString("resettableProperty"));
-
- QCOMPARE(p.isResettable(), true);
- QCOMPARE(p.reset(), true);
-
- delete o;
-
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Signal property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "onClicked");
-
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-
- // Automatic signal property
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "onPropertyWithNotifyChanged");
-
- QCOMPARE(p.isResettable(), false);
- QCOMPARE(p.reset(), false);
- }
-}
-
-void tst_qdeclarativeproperty::writeObjectToList()
-{
- QDeclarativeComponent containerComponent(&engine);
- containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
- MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
- QVERIFY(container != 0);
- QDeclarativeListReference list(container, "children");
- QVERIFY(list.count() == 1);
-
- MyQmlObject *object = new MyQmlObject;
- QDeclarativeProperty prop(container, "children");
- prop.write(qVariantFromValue(object));
- QCOMPARE(list.count(), 1);
- QCOMPARE(list.at(0), qobject_cast<QObject*>(object));
-}
-
-void tst_qdeclarativeproperty::writeListToList()
-{
- QDeclarativeComponent containerComponent(&engine);
- containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
- MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
- QVERIFY(container != 0);
- QDeclarativeListReference list(container, "children");
- QVERIFY(list.count() == 1);
-
- QList<QObject*> objList;
- objList << new MyQmlObject() << new MyQmlObject() << new MyQmlObject() << new MyQmlObject();
- QDeclarativeProperty prop(container, "children");
- prop.write(qVariantFromValue(objList));
- QCOMPARE(list.count(), 4);
-
- //XXX need to try this with read/write prop (for read-only it correctly doesn't write)
- /*QList<MyQmlObject*> typedObjList;
- typedObjList << new MyQmlObject();
- prop.write(qVariantFromValue(&typedObjList));
- QCOMPARE(container->children()->size(), 1);*/
-}
-
-void tst_qdeclarativeproperty::urlHandling_data()
-{
- QTest::addColumn<QByteArray>("input");
- QTest::addColumn<QString>("scheme");
- QTest::addColumn<QString>("path");
- QTest::addColumn<QByteArray>("encoded");
-
- QTest::newRow("unspecifiedFile")
- << QByteArray("main.qml")
- << QString("")
- << QString("main.qml")
- << QByteArray("main.qml");
-
- QTest::newRow("specifiedFile")
- << QByteArray("file:///main.qml")
- << QString("file")
- << QString("/main.qml")
- << QByteArray("file:///main.qml");
-
- QTest::newRow("httpFile")
- << QByteArray("http://www.example.com/main.qml")
- << QString("http")
- << QString("/main.qml")
- << QByteArray("http://www.example.com/main.qml");
-
- QTest::newRow("pathFile")
- << QByteArray("http://www.example.com/resources/main.qml")
- << QString("http")
- << QString("/resources/main.qml")
- << QByteArray("http://www.example.com/resources/main.qml");
-
- QTest::newRow("encodableName")
- << QByteArray("http://www.example.com/main file.qml")
- << QString("http")
- << QString("/main file.qml")
- << QByteArray("http://www.example.com/main%20file.qml");
-
- QTest::newRow("preencodedName")
- << QByteArray("http://www.example.com/resources%7cmain%20file.qml")
- << QString("http")
- << QString("/resources|main file.qml")
- << QByteArray("http://www.example.com/resources%7cmain%20file.qml");
-
- QTest::newRow("encodableQuery")
- << QByteArray("http://www.example.com/main.qml?type=text/qml&comment=now working?")
- << QString("http")
- << QString("/main.qml")
- << QByteArray("http://www.example.com/main.qml?type=text/qml&comment=now%20working?");
-
- QTest::newRow("preencodedQuery")
- << QByteArray("http://www.example.com/main.qml?type=text%2fqml&comment=now working%3f")
- << QString("http")
- << QString("/main.qml")
- << QByteArray("http://www.example.com/main.qml?type=text%2fqml&comment=now%20working%3f");
-
- QTest::newRow("encodableFragment")
- << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000|volume+50%")
- << QString("http")
- << QString("/main.qml")
- << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000%7Cvolume+50%25");
-
- QTest::newRow("preencodedFragment")
- << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000%7cvolume%2b50%")
- << QString("http")
- << QString("/main.qml")
- << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000%7cvolume%2b50%25");
-}
-
-void tst_qdeclarativeproperty::urlHandling()
-{
- QFETCH(QByteArray, input);
- QFETCH(QString, scheme);
- QFETCH(QString, path);
- QFETCH(QByteArray, encoded);
-
- QString inputString(QString::fromUtf8(input));
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "url");
-
- // Test url written as QByteArray
- QCOMPARE(p.write(input), true);
- QUrl byteArrayResult(o.url());
-
- QCOMPARE(byteArrayResult.scheme(), scheme);
- QCOMPARE(byteArrayResult.path(), path);
- QCOMPARE(byteArrayResult.toEncoded(), encoded);
- }
-
- {
- PropertyObject o;
- QDeclarativeProperty p(&o, "url");
-
- // Test url written as QString
- QCOMPARE(p.write(inputString), true);
- QUrl stringResult(o.url());
-
- QCOMPARE(stringResult.scheme(), scheme);
- QCOMPARE(stringResult.path(), path);
- QCOMPARE(stringResult.toEncoded(), encoded);
- }
-}
-
-void tst_qdeclarativeproperty::variantMapHandling_data()
-{
- QTest::addColumn<QVariantMap>("vm");
-
- // Object literals
- {
- QVariantMap m;
- QTest::newRow("{}") << m;
- }
- {
- QVariantMap m;
- m["a"] = QVariantMap();
- QTest::newRow("{ a:{} }") << m;
- }
- {
- QVariantMap m, m2;
- m2["b"] = 10;
- m2["c"] = 20;
- m["a"] = m2;
- QTest::newRow("{ a:{b:10, c:20} }") << m;
- }
- {
- QVariantMap m;
- m["a"] = 10;
- m["b"] = QVariantList() << 20 << 30;
- QTest::newRow("{ a:10, b:[20, 30]}") << m;
- }
-
- // Cyclic objects
- {
- QVariantMap m;
- m["p"] = QVariantMap();
- QTest::newRow("var o={}; o.p=o") << m;
- }
- {
- QVariantMap m;
- m["p"] = 123;
- m["q"] = QVariantMap();
- QTest::newRow("var o={}; o.p=123; o.q=o") << m;
- }
-}
-
-void tst_qdeclarativeproperty::variantMapHandling()
-{
- QFETCH(QVariantMap, vm);
-
- PropertyObject o;
- QDeclarativeProperty p(&o, "variantMap");
-
- QCOMPARE(p.write(vm), true);
- QCOMPARE(o.variantMap(), vm);
-}
-
-void tst_qdeclarativeproperty::crashOnValueProperty()
-{
- QDeclarativeEngine *engine = new QDeclarativeEngine;
- QDeclarativeComponent component(engine);
-
- component.setData("import Test 1.0\nPropertyObject { wrectProperty.x: 10 }", QUrl());
- PropertyObject *obj = qobject_cast<PropertyObject*>(component.create());
- QVERIFY(obj != 0);
-
- QDeclarativeProperty p(obj, "wrectProperty.x", qmlContext(obj));
- QCOMPARE(p.name(), QString("wrectProperty.x"));
-
- QCOMPARE(p.read(), QVariant(10));
-
- //don't crash once the engine is deleted
- delete engine;
- engine = 0;
-
- QCOMPARE(p.propertyTypeName(), "int");
- QCOMPARE(p.read(), QVariant(10));
- p.write(QVariant(20));
- QCOMPARE(p.read(), QVariant(20));
-}
-
-// QTBUG-13719
-void tst_qdeclarativeproperty::aliasPropertyBindings()
-{
- QDeclarativeComponent component(&engine, testFileUrl("aliasPropertyBindings.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("realProperty").toReal(), 90.);
- QCOMPARE(object->property("aliasProperty").toReal(), 90.);
-
- object->setProperty("test", 10);
-
- QCOMPARE(object->property("realProperty").toReal(), 110.);
- QCOMPARE(object->property("aliasProperty").toReal(), 110.);
-
- QDeclarativeProperty realProperty(object, QLatin1String("realProperty"));
- QDeclarativeProperty aliasProperty(object, QLatin1String("aliasProperty"));
-
- // Check there is a binding on these two properties
- QVERIFY(QDeclarativePropertyPrivate::binding(realProperty) != 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(aliasProperty) != 0);
-
- // Check that its the same binding on these two properties
- QCOMPARE(QDeclarativePropertyPrivate::binding(realProperty),
- QDeclarativePropertyPrivate::binding(aliasProperty));
-
- // Change the binding
- object->setProperty("state", QString("switch"));
-
- QVERIFY(QDeclarativePropertyPrivate::binding(realProperty) != 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(aliasProperty) != 0);
- QCOMPARE(QDeclarativePropertyPrivate::binding(realProperty),
- QDeclarativePropertyPrivate::binding(aliasProperty));
-
- QCOMPARE(object->property("realProperty").toReal(), 96.);
- QCOMPARE(object->property("aliasProperty").toReal(), 96.);
-
- // Check the old binding really has not effect any more
- object->setProperty("test", 4);
-
- QCOMPARE(object->property("realProperty").toReal(), 96.);
- QCOMPARE(object->property("aliasProperty").toReal(), 96.);
-
- object->setProperty("test2", 9);
-
- QCOMPARE(object->property("realProperty").toReal(), 288.);
- QCOMPARE(object->property("aliasProperty").toReal(), 288.);
-
- // Revert
- object->setProperty("state", QString(""));
-
- QVERIFY(QDeclarativePropertyPrivate::binding(realProperty) != 0);
- QVERIFY(QDeclarativePropertyPrivate::binding(aliasProperty) != 0);
- QCOMPARE(QDeclarativePropertyPrivate::binding(realProperty),
- QDeclarativePropertyPrivate::binding(aliasProperty));
-
- QCOMPARE(object->property("realProperty").toReal(), 20.);
- QCOMPARE(object->property("aliasProperty").toReal(), 20.);
-
- object->setProperty("test2", 3);
-
- QCOMPARE(object->property("realProperty").toReal(), 20.);
- QCOMPARE(object->property("aliasProperty").toReal(), 20.);
-
- delete object;
-}
-
-void tst_qdeclarativeproperty::copy()
-{
- PropertyObject object;
-
- QDeclarativeProperty *property = new QDeclarativeProperty(&object, QLatin1String("defaultProperty"));
- QCOMPARE(property->name(), QString("defaultProperty"));
- QCOMPARE(property->read(), QVariant(10));
- QCOMPARE(property->type(), QDeclarativeProperty::Property);
- QCOMPARE(property->propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(property->propertyType(), (int)QVariant::Int);
-
- QDeclarativeProperty p1(*property);
- QCOMPARE(p1.name(), QString("defaultProperty"));
- QCOMPARE(p1.read(), QVariant(10));
- QCOMPARE(p1.type(), QDeclarativeProperty::Property);
- QCOMPARE(p1.propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(p1.propertyType(), (int)QVariant::Int);
-
- QDeclarativeProperty p2(&object, QLatin1String("url"));
- QCOMPARE(p2.name(), QString("url"));
- p2 = *property;
- QCOMPARE(p2.name(), QString("defaultProperty"));
- QCOMPARE(p2.read(), QVariant(10));
- QCOMPARE(p2.type(), QDeclarativeProperty::Property);
- QCOMPARE(p2.propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(p2.propertyType(), (int)QVariant::Int);
-
- delete property; property = 0;
-
- QCOMPARE(p1.name(), QString("defaultProperty"));
- QCOMPARE(p1.read(), QVariant(10));
- QCOMPARE(p1.type(), QDeclarativeProperty::Property);
- QCOMPARE(p1.propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(p1.propertyType(), (int)QVariant::Int);
-
- QCOMPARE(p2.name(), QString("defaultProperty"));
- QCOMPARE(p2.read(), QVariant(10));
- QCOMPARE(p2.type(), QDeclarativeProperty::Property);
- QCOMPARE(p2.propertyTypeCategory(), QDeclarativeProperty::Normal);
- QCOMPARE(p2.propertyType(), (int)QVariant::Int);
-}
-
-void tst_qdeclarativeproperty::noContext()
-{
- QDeclarativeComponent compA(&engine, testFileUrl("NoContextTypeA.qml"));
- QDeclarativeComponent compB(&engine, testFileUrl("NoContextTypeB.qml"));
-
- QObject *a = compA.create();
- QVERIFY(a != 0);
- QObject *b = compB.create();
- QVERIFY(b != 0);
-
- QVERIFY(QDeclarativeProperty::write(b, "myTypeA", QVariant::fromValue(a), &engine));
-
- delete a;
- delete b;
-}
-
-void tst_qdeclarativeproperty::assignEmptyVariantMap()
-{
- PropertyObject o;
-
- QVariantMap map;
- map.insert("key", "value");
- o.setVariantMap(map);
- QCOMPARE(o.variantMap().count(), 1);
- QCOMPARE(o.variantMap().isEmpty(), false);
-
- QDeclarativeContext context(&engine);
- context.setContextProperty("o", &o);
-
- QDeclarativeComponent component(&engine, testFileUrl("assignEmptyVariantMap.qml"));
- QObject *obj = component.create(&context);
- QVERIFY(obj);
-
- QCOMPARE(o.variantMap().count(), 0);
- QCOMPARE(o.variantMap().isEmpty(), true);
-
- delete obj;
-}
-
-void tst_qdeclarativeproperty::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- qmlRegisterType<MyQmlObject>("Test",1,0,"MyQmlObject");
- qmlRegisterType<PropertyObject>("Test",1,0,"PropertyObject");
- qmlRegisterType<MyContainer>("Test",1,0,"MyContainer");
-}
-
-QTEST_MAIN(tst_qdeclarativeproperty)
-
-#include "tst_qdeclarativeproperty.moc"
diff --git a/tests/auto/declarative/qdeclarativepropertycache/qdeclarativepropertycache.pro b/tests/auto/declarative/qdeclarativepropertycache/qdeclarativepropertycache.pro
deleted file mode 100644
index 4b47a2cae9..0000000000
--- a/tests/auto/declarative/qdeclarativepropertycache/qdeclarativepropertycache.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativepropertycache
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativepropertycache.cpp
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private testlib v8-private
diff --git a/tests/auto/declarative/qdeclarativepropertycache/tst_qdeclarativepropertycache.cpp b/tests/auto/declarative/qdeclarativepropertycache/tst_qdeclarativepropertycache.cpp
deleted file mode 100644
index 495f8a5f20..0000000000
--- a/tests/auto/declarative/qdeclarativepropertycache/tst_qdeclarativepropertycache.cpp
+++ /dev/null
@@ -1,281 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <private/qdeclarativepropertycache_p.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativepropertycache : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativepropertycache() {}
-
-private slots:
- void properties();
- void propertiesDerived();
- void methods();
- void methodsDerived();
- void signalHandlers();
- void signalHandlersDerived();
-
-private:
- QDeclarativeEngine engine;
-};
-
-class BaseObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int propertyA READ propertyA NOTIFY propertyAChanged)
- Q_PROPERTY(QString propertyB READ propertyB NOTIFY propertyBChanged)
-public:
- BaseObject(QObject *parent = 0) : QObject(parent) {}
-
- int propertyA() const { return 0; }
- QString propertyB() const { return QString(); }
-
-public Q_SLOTS:
- void slotA() {}
-
-Q_SIGNALS:
- void propertyAChanged();
- void propertyBChanged();
- void signalA();
-};
-
-class DerivedObject : public BaseObject
-{
- Q_OBJECT
- Q_PROPERTY(int propertyC READ propertyC NOTIFY propertyCChanged)
- Q_PROPERTY(QString propertyD READ propertyD NOTIFY propertyDChanged)
-public:
- DerivedObject(QObject *parent = 0) : BaseObject(parent) {}
-
- int propertyC() const { return 0; }
- QString propertyD() const { return QString(); }
-
-public Q_SLOTS:
- void slotB() {}
-
-Q_SIGNALS:
- void propertyCChanged();
- void propertyDChanged();
- void signalB();
-};
-
-void tst_qdeclarativepropertycache::properties()
-{
- QDeclarativeEngine engine;
- DerivedObject object;
- const QMetaObject *metaObject = object.metaObject();
-
- QDeclarativeRefPointer<QDeclarativePropertyCache> cache(new QDeclarativePropertyCache(&engine, metaObject));
- QDeclarativePropertyData *data;
-
- QVERIFY(data = cache->property(QLatin1String("propertyA")));
- QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyA"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyB")));
- QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyB"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyC")));
- QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyC"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyD")));
- QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyD"));
-}
-
-void tst_qdeclarativepropertycache::propertiesDerived()
-{
- QDeclarativeEngine engine;
- DerivedObject object;
- const QMetaObject *metaObject = object.metaObject();
-
- QDeclarativeRefPointer<QDeclarativePropertyCache> parentCache(new QDeclarativePropertyCache(&engine, &BaseObject::staticMetaObject));
- QDeclarativeRefPointer<QDeclarativePropertyCache> cache(parentCache->copy());
- cache->append(&engine, object.metaObject());
- QDeclarativePropertyData *data;
-
- QVERIFY(data = cache->property(QLatin1String("propertyA")));
- QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyA"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyB")));
- QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyB"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyC")));
- QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyC"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyD")));
- QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyD"));
-}
-
-void tst_qdeclarativepropertycache::methods()
-{
- QDeclarativeEngine engine;
- DerivedObject object;
- const QMetaObject *metaObject = object.metaObject();
-
- QDeclarativeRefPointer<QDeclarativePropertyCache> cache(new QDeclarativePropertyCache(&engine, metaObject));
- QDeclarativePropertyData *data;
-
- QVERIFY(data = cache->property(QLatin1String("slotA")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotA()"));
-
- QVERIFY(data = cache->property(QLatin1String("slotB")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotB()"));
-
- QVERIFY(data = cache->property(QLatin1String("signalA")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
-
- QVERIFY(data = cache->property(QLatin1String("signalB")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyAChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyBChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyCChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyDChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
-}
-
-void tst_qdeclarativepropertycache::methodsDerived()
-{
- QDeclarativeEngine engine;
- DerivedObject object;
- const QMetaObject *metaObject = object.metaObject();
-
- QDeclarativeRefPointer<QDeclarativePropertyCache> parentCache(new QDeclarativePropertyCache(&engine, &BaseObject::staticMetaObject));
- QDeclarativeRefPointer<QDeclarativePropertyCache> cache(parentCache->copy());
- cache->append(&engine, object.metaObject());
- QDeclarativePropertyData *data;
-
- QVERIFY(data = cache->property(QLatin1String("slotA")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotA()"));
-
- QVERIFY(data = cache->property(QLatin1String("slotB")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotB()"));
-
- QVERIFY(data = cache->property(QLatin1String("signalA")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
-
- QVERIFY(data = cache->property(QLatin1String("signalB")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyAChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyBChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyCChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("propertyDChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
-}
-
-void tst_qdeclarativepropertycache::signalHandlers()
-{
- QDeclarativeEngine engine;
- DerivedObject object;
- const QMetaObject *metaObject = object.metaObject();
-
- QDeclarativeRefPointer<QDeclarativePropertyCache> cache(new QDeclarativePropertyCache(&engine, metaObject));
- QDeclarativePropertyData *data;
-
- QVERIFY(data = cache->property(QLatin1String("onSignalA")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
-
- QVERIFY(data = cache->property(QLatin1String("onSignalB")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
-
- QVERIFY(data = cache->property(QLatin1String("onPropertyAChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("onPropertyBChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("onPropertyCChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("onPropertyDChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
-}
-
-void tst_qdeclarativepropertycache::signalHandlersDerived()
-{
- QDeclarativeEngine engine;
- DerivedObject object;
- const QMetaObject *metaObject = object.metaObject();
-
- QDeclarativeRefPointer<QDeclarativePropertyCache> parentCache(new QDeclarativePropertyCache(&engine, &BaseObject::staticMetaObject));
- QDeclarativeRefPointer<QDeclarativePropertyCache> cache(parentCache->copy());
- cache->append(&engine, object.metaObject());
- QDeclarativePropertyData *data;
-
- QVERIFY(data = cache->property(QLatin1String("onSignalA")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
-
- QVERIFY(data = cache->property(QLatin1String("onSignalB")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
-
- QVERIFY(data = cache->property(QLatin1String("onPropertyAChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("onPropertyBChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("onPropertyCChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
-
- QVERIFY(data = cache->property(QLatin1String("onPropertyDChanged")));
- QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
-}
-
-QTEST_MAIN(tst_qdeclarativepropertycache)
-
-#include "tst_qdeclarativepropertycache.moc"
diff --git a/tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro b/tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro
deleted file mode 100644
index f94405c770..0000000000
--- a/tests/auto/declarative/qdeclarativepropertymap/qdeclarativepropertymap.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativepropertymap
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativepropertymap.cpp
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp b/tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp
deleted file mode 100644
index 32c2e79b8b..0000000000
--- a/tests/auto/declarative/qdeclarativepropertymap/tst_qdeclarativepropertymap.cpp
+++ /dev/null
@@ -1,241 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativepropertymap.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QSignalSpy>
-
-class tst_QDeclarativePropertyMap : public QObject
-{
- Q_OBJECT
-public:
- tst_QDeclarativePropertyMap() {}
-
-private slots:
- void insert();
- void operatorInsert();
- void operatorValue();
- void clear();
- void changed();
- void count();
-
- void crashBug();
- void QTBUG_17868();
-};
-
-void tst_QDeclarativePropertyMap::insert()
-{
- QDeclarativePropertyMap map;
- map.insert(QLatin1String("key1"),100);
- map.insert(QLatin1String("key2"),200);
- QVERIFY(map.keys().count() == 2);
- QVERIFY(map.contains(QLatin1String("key1")));
-
- QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
- QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
-
- map.insert(QLatin1String("key1"),"Hello World");
- QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
-
- //inserting property names same with existing method(signal, slot, method) names is not allowed
- //QDeclarativePropertyMap has an invokable keys() method
- QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"keys\" is not permitted, conflicts with internal symbols. ");
- map.insert(QLatin1String("keys"), 1);
- QVERIFY(map.keys().count() == 2);
- QVERIFY(!map.contains(QLatin1String("keys")));
- QVERIFY(map.value(QLatin1String("keys")).isNull());
-
- //QDeclarativePropertyMap has a deleteLater() slot
- QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"deleteLater\" is not permitted, conflicts with internal symbols. ");
- map.insert(QLatin1String("deleteLater"), 1);
- QVERIFY(map.keys().count() == 2);
- QVERIFY(!map.contains(QLatin1String("deleteLater")));
- QVERIFY(map.value(QLatin1String("deleteLater")).isNull());
-
- //QDeclarativePropertyMap has an valueChanged() signal
- QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"valueChanged\" is not permitted, conflicts with internal symbols. ");
- map.insert(QLatin1String("valueChanged"), 1);
- QVERIFY(map.keys().count() == 2);
- QVERIFY(!map.contains(QLatin1String("valueChanged")));
- QVERIFY(map.value(QLatin1String("valueChanged")).isNull());
-
- //but 'valueChange' should be ok
- map.insert(QLatin1String("valueChange"), 1);
- QVERIFY(map.keys().count() == 3);
- QVERIFY(map.contains(QLatin1String("valueChange")));
- QCOMPARE(map.value(QLatin1String("valueChange")), QVariant(1));
-
- //'valueCHANGED' should be ok, too
- map.insert(QLatin1String("valueCHANGED"), 1);
- QVERIFY(map.keys().count() == 4);
- QVERIFY(map.contains(QLatin1String("valueCHANGED")));
- QCOMPARE(map.value(QLatin1String("valueCHANGED")), QVariant(1));
-}
-
-void tst_QDeclarativePropertyMap::operatorInsert()
-{
- QDeclarativePropertyMap map;
- map[QLatin1String("key1")] = 100;
- map[QLatin1String("key2")] = 200;
- QVERIFY(map.keys().count() == 2);
-
- QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
- QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
-
- map[QLatin1String("key1")] = "Hello World";
- QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
-}
-
-void tst_QDeclarativePropertyMap::operatorValue()
-{
- QDeclarativePropertyMap map;
- map.insert(QLatin1String("key1"),100);
- map.insert(QLatin1String("key2"),200);
- QVERIFY(map.count() == 2);
- QVERIFY(map.contains(QLatin1String("key1")));
-
- const QDeclarativePropertyMap &constMap = map;
-
- QCOMPARE(constMap.value(QLatin1String("key1")), QVariant(100));
- QCOMPARE(constMap.value(QLatin1String("key2")), QVariant(200));
- QCOMPARE(constMap[QLatin1String("key1")], constMap.value(QLatin1String("key1")));
- QCOMPARE(constMap[QLatin1String("key2")], constMap.value(QLatin1String("key2")));
-}
-
-void tst_QDeclarativePropertyMap::clear()
-{
- QDeclarativePropertyMap map;
- map.insert(QLatin1String("key1"),100);
- QVERIFY(map.keys().count() == 1);
-
- QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
-
- map.clear(QLatin1String("key1"));
- QVERIFY(map.keys().count() == 1);
- QVERIFY(map.contains(QLatin1String("key1")));
- QCOMPARE(map.value(QLatin1String("key1")), QVariant());
-}
-
-void tst_QDeclarativePropertyMap::changed()
-{
- QDeclarativePropertyMap map;
- QSignalSpy spy(&map, SIGNAL(valueChanged(const QString&, const QVariant&)));
- map.insert(QLatin1String("key1"),100);
- map.insert(QLatin1String("key2"),200);
- QCOMPARE(spy.count(), 0);
-
- map.clear(QLatin1String("key1"));
- QCOMPARE(spy.count(), 0);
-
- //make changes in QML
- QDeclarativeEngine engine;
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty(QLatin1String("testdata"), &map);
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nText { text: { testdata.key1 = 'Hello World'; 'X' } }",
- QUrl::fromLocalFile(""));
- QVERIFY(component.isReady());
- QQuickText *txt = qobject_cast<QQuickText*>(component.create());
- QVERIFY(txt);
- QCOMPARE(txt->text(), QString('X'));
- QCOMPARE(spy.count(), 1);
- QList<QVariant> arguments = spy.takeFirst();
- QCOMPARE(arguments.count(), 2);
- QCOMPARE(arguments.at(0).toString(),QLatin1String("key1"));
- QCOMPARE(arguments.at(1).value<QVariant>(),QVariant("Hello World"));
- QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
-}
-
-void tst_QDeclarativePropertyMap::count()
-{
- QDeclarativePropertyMap map;
- QCOMPARE(map.isEmpty(), true);
- map.insert(QLatin1String("key1"),100);
- map.insert(QLatin1String("key2"),200);
- QCOMPARE(map.count(), 2);
- QCOMPARE(map.isEmpty(), false);
-
- map.insert(QLatin1String("key3"),"Hello World");
- QCOMPARE(map.count(), 3);
-
- //clearing doesn't remove the key
- map.clear(QLatin1String("key3"));
- QCOMPARE(map.count(), 3);
- QCOMPARE(map.size(), map.count());
-}
-
-void tst_QDeclarativePropertyMap::crashBug()
-{
- QDeclarativePropertyMap map;
-
- QDeclarativeEngine engine;
- QDeclarativeContext context(&engine);
- context.setContextProperty("map", &map);
-
- QDeclarativeComponent c(&engine);
- c.setData("import QtQuick 2.0\nBinding { target: map; property: \"myProp\"; value: 10 + 23 }",QUrl());
- QObject *obj = c.create(&context);
- delete obj;
-}
-
-void tst_QDeclarativePropertyMap::QTBUG_17868()
-{
- QDeclarativePropertyMap map;
-
- QDeclarativeEngine engine;
- QDeclarativeContext context(&engine);
- context.setContextProperty("map", &map);
- map.insert("key", 1);
- QDeclarativeComponent c(&engine);
- c.setData("import QtQuick 2.0\nItem {property bool error:false; Component.onCompleted: {try{ map.keys(); }catch(e) {error=true;}}}",QUrl());
- QObject *obj = c.create(&context);
- QVERIFY(obj);
- QVERIFY(!obj->property("error").toBool());
- delete obj;
-
-}
-
-QTEST_MAIN(tst_QDeclarativePropertyMap)
-
-#include "tst_qdeclarativepropertymap.moc"
diff --git a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro
deleted file mode 100644
index 5ed808831c..0000000000
--- a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeqt
-SOURCES += tst_qdeclarativeqt.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private testlib
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
deleted file mode 100644
index c88e56476e..0000000000
--- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
+++ /dev/null
@@ -1,732 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <private/qdeclarativeengine_p.h>
-
-#include <qtest.h>
-#include <QDebug>
-#include <QDeclarativeEngine>
-#include <QFontDatabase>
-#include <QFileInfo>
-#include <QDeclarativeComponent>
-#include <QDesktopServices>
-#include <QDir>
-#include <QVector3D>
-#include <QCryptographicHash>
-#include <QtQuick/QQuickItem>
-#include <QSignalSpy>
-#include "../../shared/util.h"
-
-class tst_qdeclarativeqt : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeqt() {}
-
-private slots:
- void enums();
- void rgba();
- void hsla();
- void rect();
- void point();
- void size();
- void vector();
- void vector4d();
- void lighter();
- void darker();
- void tint();
- void openUrlExternally();
- void openUrlExternally_pragmaLibrary();
- void md5();
- void createComponent();
- void createComponent_pragmaLibrary();
- void createQmlObject();
- void dateTimeConversion();
- void dateTimeFormatting();
- void dateTimeFormatting_data();
- void dateTimeFormattingVariants();
- void dateTimeFormattingVariants_data();
- void isQtObject();
- void btoa();
- void atob();
- void fontFamilies();
- void quit();
- void resolvedUrl();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qdeclarativeqt::enums()
-{
- QDeclarativeComponent component(&engine, testFileUrl("enums.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toInt(), (int)Qt::Key_Escape);
- QCOMPARE(object->property("test2").toInt(), (int)Qt::DescendingOrder);
- QCOMPARE(object->property("test3").toInt(), (int)Qt::ElideMiddle);
- QCOMPARE(object->property("test4").toInt(), (int)Qt::AlignRight);
-
- delete object;
-}
-
-void tst_qdeclarativeqt::rgba()
-{
- QDeclarativeComponent component(&engine, testFileUrl("rgba.qml"));
-
- QString warning1 = component.url().toString() + ":6: Error: Qt.rgba(): Invalid arguments";
- QString warning2 = component.url().toString() + ":7: Error: Qt.rgba(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
-
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0, 0, 0.8));
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0.5, 0.3, 1));
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromRgbF(1, 1, 1, 1));
- QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor::fromRgbF(0, 0, 0, 0));
-
- delete object;
-}
-
-void tst_qdeclarativeqt::hsla()
-{
- QDeclarativeComponent component(&engine, testFileUrl("hsla.qml"));
-
- QString warning1 = component.url().toString() + ":6: Error: Qt.hsla(): Invalid arguments";
- QString warning2 = component.url().toString() + ":7: Error: Qt.hsla(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromHslF(1, 0, 0, 0.8));
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHslF(1, 0.5, 0.3, 1));
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromHslF(1, 1, 1, 1));
- QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor::fromHslF(0, 0, 0, 0));
-
- delete object;
-}
-
-void tst_qdeclarativeqt::rect()
-{
- QDeclarativeComponent component(&engine, testFileUrl("rect.qml"));
-
- QString warning1 = component.url().toString() + ":6: Error: Qt.rect(): Invalid arguments";
- QString warning2 = component.url().toString() + ":7: Error: Qt.rect(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QRectF>(object->property("test1")), QRectF(10, 13, 100, 109));
- QCOMPARE(qvariant_cast<QRectF>(object->property("test2")), QRectF(-10, 13, 100, 109.6));
- QCOMPARE(qvariant_cast<QRectF>(object->property("test3")), QRectF());
- QCOMPARE(qvariant_cast<QRectF>(object->property("test4")), QRectF());
- QCOMPARE(qvariant_cast<QRectF>(object->property("test5")), QRectF(10, 13, 100, -109));
-
- delete object;
-}
-
-void tst_qdeclarativeqt::point()
-{
- QDeclarativeComponent component(&engine, testFileUrl("point.qml"));
-
- QString warning1 = component.url().toString() + ":6: Error: Qt.point(): Invalid arguments";
- QString warning2 = component.url().toString() + ":7: Error: Qt.point(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QPointF>(object->property("test1")), QPointF(19, 34));
- QCOMPARE(qvariant_cast<QPointF>(object->property("test2")), QPointF(-3, 109.2));
- QCOMPARE(qvariant_cast<QPointF>(object->property("test3")), QPointF());
- QCOMPARE(qvariant_cast<QPointF>(object->property("test4")), QPointF());
-
- delete object;
-}
-
-void tst_qdeclarativeqt::size()
-{
- QDeclarativeComponent component(&engine, testFileUrl("size.qml"));
-
- QString warning1 = component.url().toString() + ":7: Error: Qt.size(): Invalid arguments";
- QString warning2 = component.url().toString() + ":8: Error: Qt.size(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QSizeF>(object->property("test1")), QSizeF(19, 34));
- QCOMPARE(qvariant_cast<QSizeF>(object->property("test2")), QSizeF(3, 109.2));
- QCOMPARE(qvariant_cast<QSizeF>(object->property("test3")), QSizeF(-3, 10));
- QCOMPARE(qvariant_cast<QSizeF>(object->property("test4")), QSizeF());
- QCOMPARE(qvariant_cast<QSizeF>(object->property("test5")), QSizeF());
-
- delete object;
-}
-
-void tst_qdeclarativeqt::vector()
-{
- QDeclarativeComponent component(&engine, testFileUrl("vector.qml"));
-
- QString warning1 = component.url().toString() + ":6: Error: Qt.vector(): Invalid arguments";
- QString warning2 = component.url().toString() + ":7: Error: Qt.vector(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QVector3D>(object->property("test1")), QVector3D(1, 0, 0.9));
- QCOMPARE(qvariant_cast<QVector3D>(object->property("test2")), QVector3D(102, -10, -982.1));
- QCOMPARE(qvariant_cast<QVector3D>(object->property("test3")), QVector3D());
- QCOMPARE(qvariant_cast<QVector3D>(object->property("test4")), QVector3D());
-
- delete object;
-}
-
-void tst_qdeclarativeqt::vector4d()
-{
- QDeclarativeComponent component(&engine, testFileUrl("vector4.qml"));
-
- QString warning1 = component.url().toString() + ":6: Error: Qt.vector4d(): Invalid arguments";
- QString warning2 = component.url().toString() + ":7: Error: Qt.vector4d(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QVector4D>(object->property("test1")), QVector4D(1, 0, 0.9, 0.6));
- QCOMPARE(qvariant_cast<QVector4D>(object->property("test2")), QVector4D(102, -10, -982.1, 10));
- QCOMPARE(qvariant_cast<QVector4D>(object->property("test3")), QVector4D());
- QCOMPARE(qvariant_cast<QVector4D>(object->property("test4")), QVector4D());
-
- delete object;
-}
-
-void tst_qdeclarativeqt::lighter()
-{
- QDeclarativeComponent component(&engine, testFileUrl("lighter.qml"));
-
- QString warning1 = component.url().toString() + ":5: Error: Qt.lighter(): Invalid arguments";
- QString warning2 = component.url().toString() + ":10: Error: Qt.lighter(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).lighter());
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).lighter(180));
- QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").lighter());
- QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
-
- delete object;
-}
-
-void tst_qdeclarativeqt::darker()
-{
- QDeclarativeComponent component(&engine, testFileUrl("darker.qml"));
-
- QString warning1 = component.url().toString() + ":5: Error: Qt.darker(): Invalid arguments";
- QString warning2 = component.url().toString() + ":10: Error: Qt.darker(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).darker());
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).darker(280));
- QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").darker());
- QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
-
- delete object;
-}
-
-void tst_qdeclarativeqt::tint()
-{
- QDeclarativeComponent component(&engine, testFileUrl("tint.qml"));
-
- QString warning1 = component.url().toString() + ":7: Error: Qt.tint(): Invalid arguments";
- QString warning2 = component.url().toString() + ":8: Error: Qt.tint(): Invalid arguments";
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(0, 0, 1));
- QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0, 0));
- QColor test3 = qvariant_cast<QColor>(object->property("test3"));
- QCOMPARE(test3.rgba(), 0xFF7F0080);
- QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
- QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
-
- delete object;
-}
-
-class MyUrlHandler : public QObject
-{
- Q_OBJECT
-public:
- MyUrlHandler() : called(0) { }
- int called;
- QUrl last;
-
-public slots:
- void noteCall(const QUrl &url) { called++; last = url; }
-};
-
-void tst_qdeclarativeqt::openUrlExternally()
-{
- MyUrlHandler handler;
-
- QDesktopServices::setUrlHandler("test", &handler, "noteCall");
- QDesktopServices::setUrlHandler("file", &handler, "noteCall");
-
- QDeclarativeComponent component(&engine, testFileUrl("openUrlExternally.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(handler.called,1);
- QCOMPARE(handler.last, QUrl("test:url"));
-
- object->setProperty("testFile", true);
-
- QCOMPARE(handler.called,2);
- QCOMPARE(handler.last, testFileUrl("test.html"));
-
- QDesktopServices::unsetUrlHandler("test");
- QDesktopServices::unsetUrlHandler("file");
-}
-
-void tst_qdeclarativeqt::openUrlExternally_pragmaLibrary()
-{
- MyUrlHandler handler;
-
- QDesktopServices::setUrlHandler("test", &handler, "noteCall");
- QDesktopServices::setUrlHandler("file", &handler, "noteCall");
-
- QDeclarativeComponent component(&engine, testFileUrl("openUrlExternally_lib.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(handler.called,1);
- QCOMPARE(handler.last, QUrl("test:url"));
-
- object->setProperty("testFile", true);
-
- QCOMPARE(handler.called,2);
- QCOMPARE(handler.last, testFileUrl("test.html"));
-
- QDesktopServices::unsetUrlHandler("test");
- QDesktopServices::unsetUrlHandler("file");
-}
-
-void tst_qdeclarativeqt::md5()
-{
- QDeclarativeComponent component(&engine, testFileUrl("md5.qml"));
-
- QString warning1 = component.url().toString() + ":4: Error: Qt.md5(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test2").toString(), QLatin1String(QCryptographicHash::hash("Hello World", QCryptographicHash::Md5).toHex()));
-
- delete object;
-}
-
-void tst_qdeclarativeqt::createComponent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("createComponent.qml"));
-
- QString warning1 = component.url().toString() + ":9: Error: Qt.createComponent(): Invalid arguments";
- QString warning2 = component.url().toString() + ":10: Error: Qt.createComponent(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("absoluteUrl").toString(), QString("http://www.example.com/test.qml"));
- QCOMPARE(object->property("relativeUrl").toString(), testFileUrl("createComponentData.qml").toString());
-
- delete object;
-}
-
-void tst_qdeclarativeqt::createComponent_pragmaLibrary()
-{
- // Currently, just loading createComponent_lib.qml causes crash on some platforms
- QDeclarativeComponent component(&engine, testFileUrl("createComponent_lib.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("status").toInt(), int(QDeclarativeComponent::Ready));
- QCOMPARE(object->property("readValue").toInt(), int(1913));
- delete object;
-}
-
-void tst_qdeclarativeqt::createQmlObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("createQmlObject.qml"));
-
- QString warning1 = component.url().toString() + ":7: Error: Qt.createQmlObject(): Invalid arguments";
- QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("inline").toString() + ":2:10: Blah is not a type";
- QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("main.qml").toString() + ":4:14: Duplicate property name";
- QString warning4 = component.url().toString()+ ":9: Error: Qt.createQmlObject(): Missing parent object";
- QString warning5 = component.url().toString()+ ":8: Error: Qt.createQmlObject(): Invalid arguments";
- QString warning6 = "RunTimeError: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("inline").toString() + ":3: Cannot assign object type QObject with no default method";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning5));
- QTest::ignoreMessage(QtDebugMsg, qPrintable(warning6));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("emptyArg").toBool(), true);
- QCOMPARE(object->property("success").toBool(), true);
-
- QQuickItem *item = qobject_cast<QQuickItem *>(object);
- QVERIFY(item != 0);
- QVERIFY(item->childItems().count() == 1);
-
- delete object;
-}
-
-
-void tst_qdeclarativeqt::dateTimeConversion()
-{
- QDate date(2008,12,24);
- QTime time(14,15,38,200);
- QDateTime dateTime(date, time);
- //Note that when converting Date to QDateTime they can argue over historical DST data when converting to local time.
- //Tests should use UTC or recent dates.
- QDateTime dateTime2(QDate(2852,12,31), QTime(23,59,59,500));
- QDateTime dateTime3(QDate(2000,1,1), QTime(0,0,0,0));
- QDateTime dateTime4(QDate(2001,2,2), QTime(0,0,0,0));
- QDateTime dateTime5(QDate(1999,1,1), QTime(2,3,4,0));
- QDateTime dateTime6(QDate(2008,2,24), QTime(14,15,38,200));
-
- QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, testFileUrl("dateTimeConversion.qml"));
- QObject *obj = component.create();
-
- QCOMPARE(obj->property("qdate").toDate(), date);
- QCOMPARE(obj->property("qtime").toTime(), time);
- QCOMPARE(obj->property("qdatetime").toDateTime(), dateTime);
- QCOMPARE(obj->property("qdatetime2").toDateTime(), dateTime2);
- QCOMPARE(obj->property("qdatetime3").toDateTime(), dateTime3);
- QCOMPARE(obj->property("qdatetime4").toDateTime(), dateTime4);
- QCOMPARE(obj->property("qdatetime5").toDateTime(), dateTime5);
- QCOMPARE(obj->property("qdatetime6").toDateTime(), dateTime6);
-}
-
-void tst_qdeclarativeqt::dateTimeFormatting()
-{
- QFETCH(QString, method);
- QFETCH(QStringList, inputProperties);
- QFETCH(QStringList, expectedResults);
-
- QDate date(2008,12,24);
- QTime time(14,15,38,200);
- QDateTime dateTime(date, time);
-
- QDeclarativeEngine eng;
-
- eng.rootContext()->setContextProperty("qdate", date);
- eng.rootContext()->setContextProperty("qtime", time);
- eng.rootContext()->setContextProperty("qdatetime", dateTime);
-
- QDeclarativeComponent component(&eng, testFileUrl("formatting.qml"));
-
- QStringList warnings;
- warnings << component.url().toString() + ":37: Error: Qt.formatDate(): Invalid date format"
- << component.url().toString() + ":36: Error: Qt.formatDate(): Invalid arguments"
- << component.url().toString() + ":40: Error: Qt.formatTime(): Invalid time format"
- << component.url().toString() + ":39: Error: Qt.formatTime(): Invalid arguments"
- << component.url().toString() + ":43: Error: Qt.formatDateTime(): Invalid datetime format"
- << component.url().toString() + ":42: Error: Qt.formatDateTime(): Invalid arguments";
-
- foreach (const QString &warning, warnings)
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- QObject *object = component.create();
- QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
- QVERIFY(object != 0);
-
- QVERIFY(inputProperties.count() > 0);
- QVariant result;
- foreach(const QString &prop, inputProperties) {
- QVERIFY(QMetaObject::invokeMethod(object, method.toUtf8().constData(),
- Q_RETURN_ARG(QVariant, result),
- Q_ARG(QVariant, prop)));
- QStringList output = result.toStringList();
- QCOMPARE(output.size(), expectedResults.size());
- for (int i=0; i<output.count(); i++)
- QCOMPARE(output[i], expectedResults[i]);
- }
-
- delete object;
-}
-
-void tst_qdeclarativeqt::dateTimeFormatting_data()
-{
- QTest::addColumn<QString>("method");
- QTest::addColumn<QStringList>("inputProperties");
- QTest::addColumn<QStringList>("expectedResults");
-
- QDate date(2008,12,24);
- QTime time(14,15,38,200);
- QDateTime dateTime(date, time);
-
- QTest::newRow("formatDate")
- << "formatDate"
- << (QStringList() << "dateFromString" << "jsdate" << "qdate" << "qdatetime")
- << (QStringList() << date.toString(Qt::DefaultLocaleShortDate)
- << date.toString(Qt::DefaultLocaleLongDate)
- << date.toString("ddd MMMM d yy"));
-
- QTest::newRow("formatTime")
- << "formatTime"
- << (QStringList() << "jsdate" << "qtime" << "qdatetime")
- << (QStringList() << time.toString(Qt::DefaultLocaleShortDate)
- << time.toString(Qt::DefaultLocaleLongDate)
- << time.toString("H:m:s a")
- << time.toString("hh:mm:ss.zzz"));
-
- QTest::newRow("formatDateTime")
- << "formatDateTime"
- << (QStringList() << "jsdate" << "qdatetime")
- << (QStringList() << dateTime.toString(Qt::DefaultLocaleShortDate)
- << dateTime.toString(Qt::DefaultLocaleLongDate)
- << dateTime.toString("M/d/yy H:m:s a"));
-}
-
-void tst_qdeclarativeqt::dateTimeFormattingVariants()
-{
- QFETCH(QString, method);
- QFETCH(QVariant, variant);
- QFETCH(QStringList, expectedResults);
-
- QDeclarativeEngine eng;
- eng.rootContext()->setContextProperty("qvariant", variant);
- QDeclarativeComponent component(&eng, testFileUrl("formatting.qml"));
-
- QStringList warnings;
- warnings << component.url().toString() + ":37: Error: Qt.formatDate(): Invalid date format"
- << component.url().toString() + ":36: Error: Qt.formatDate(): Invalid arguments"
- << component.url().toString() + ":40: Error: Qt.formatTime(): Invalid time format"
- << component.url().toString() + ":39: Error: Qt.formatTime(): Invalid arguments"
- << component.url().toString() + ":43: Error: Qt.formatDateTime(): Invalid datetime format"
- << component.url().toString() + ":42: Error: Qt.formatDateTime(): Invalid arguments";
-
- foreach (const QString &warning, warnings)
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- QObject *object = component.create();
- QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
- QVERIFY(object != 0);
-
- QVariant result;
- QVERIFY(QMetaObject::invokeMethod(object, method.toUtf8().constData(),
- Q_RETURN_ARG(QVariant, result),
- Q_ARG(QVariant, QString(QLatin1String("qvariant")))));
- QStringList output = result.toStringList();
- QCOMPARE(output, expectedResults);
-
- delete object;
-}
-
-void tst_qdeclarativeqt::dateTimeFormattingVariants_data()
-{
- QTest::addColumn<QString>("method");
- QTest::addColumn<QVariant>("variant");
- QTest::addColumn<QStringList>("expectedResults");
-
- QDateTime temporary;
-
- QTime time(11, 16, 39, 755);
- temporary = QDateTime(QDate(1970,1,1), time);
- QTest::newRow("formatDate, qtime") << "formatDate" << QVariant::fromValue(time) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
- QTest::newRow("formatDateTime, qtime") << "formatDateTime" << QVariant::fromValue(time) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
- QTest::newRow("formatTime, qtime") << "formatTime" << QVariant::fromValue(time) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
-
- QDate date(2011,5,31);
- temporary = QDateTime(date);
- QTest::newRow("formatDate, qdate") << "formatDate" << QVariant::fromValue(date) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
- QTest::newRow("formatDateTime, qdate") << "formatDateTime" << QVariant::fromValue(date) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
- QTest::newRow("formatTime, qdate") << "formatTime" << QVariant::fromValue(date) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
-
- QDateTime dateTime(date, time);
- temporary = dateTime;
- QTest::newRow("formatDate, qdatetime") << "formatDate" << QVariant::fromValue(dateTime) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
- QTest::newRow("formatDateTime, qdatetime") << "formatDateTime" << QVariant::fromValue(dateTime) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
- QTest::newRow("formatTime, qdatetime") << "formatTime" << QVariant::fromValue(dateTime) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
-
- QString string(QLatin1String("2011/05/31 11:16:39.755"));
- temporary = QDateTime::fromString(string, "yyyy/MM/dd HH:mm:ss.zzz");
- QTest::newRow("formatDate, qstring") << "formatDate" << QVariant::fromValue(string) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
- QTest::newRow("formatDateTime, qstring") << "formatDateTime" << QVariant::fromValue(string) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
- QTest::newRow("formatTime, qstring") << "formatTime" << QVariant::fromValue(string) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
-
- QColor color(Qt::red);
- temporary = QVariant::fromValue(color).toDateTime();
- QTest::newRow("formatDate, qcolor") << "formatDate" << QVariant::fromValue(color) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
- QTest::newRow("formatDateTime, qcolor") << "formatDateTime" << QVariant::fromValue(color) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
- QTest::newRow("formatTime, qcolor") << "formatTime" << QVariant::fromValue(color) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
-
- int integer(4);
- temporary = QVariant::fromValue(integer).toDateTime();
- QTest::newRow("formatDate, int") << "formatDate" << QVariant::fromValue(integer) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
- QTest::newRow("formatDateTime, int") << "formatDateTime" << QVariant::fromValue(integer) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
- QTest::newRow("formatTime, int") << "formatTime" << QVariant::fromValue(integer) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
-}
-
-void tst_qdeclarativeqt::isQtObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("isQtObject.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), false);
- QCOMPARE(object->property("test3").toBool(), false);
- QCOMPARE(object->property("test4").toBool(), false);
- QCOMPARE(object->property("test5").toBool(), false);
-
- delete object;
-}
-
-void tst_qdeclarativeqt::btoa()
-{
- QDeclarativeComponent component(&engine, testFileUrl("btoa.qml"));
-
- QString warning1 = component.url().toString() + ":4: Error: Qt.btoa(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test2").toString(), QString("SGVsbG8gd29ybGQh"));
-
- delete object;
-}
-
-void tst_qdeclarativeqt::atob()
-{
- QDeclarativeComponent component(&engine, testFileUrl("atob.qml"));
-
- QString warning1 = component.url().toString() + ":4: Error: Qt.atob(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test2").toString(), QString("Hello world!"));
-
- delete object;
-}
-
-void tst_qdeclarativeqt::fontFamilies()
-{
- QDeclarativeComponent component(&engine, testFileUrl("fontFamilies.qml"));
-
- QString warning1 = component.url().toString() + ":4: Error: Qt.fontFamilies(): Invalid arguments";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QFontDatabase database;
- QCOMPARE(object->property("test2"), QVariant::fromValue(database.families()));
-
- delete object;
-}
-
-void tst_qdeclarativeqt::quit()
-{
- QDeclarativeComponent component(&engine, testFileUrl("quit.qml"));
-
- QSignalSpy spy(&engine, SIGNAL(quit()));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(spy.count(), 1);
-
- delete object;
-}
-
-void tst_qdeclarativeqt::resolvedUrl()
-{
- QDeclarativeComponent component(&engine, testFileUrl("resolvedUrl.qml"));
-
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("result").toString(), component.url().toString());
- QCOMPARE(object->property("isString").toBool(), true);
-
- delete object;
-}
-
-QTEST_MAIN(tst_qdeclarativeqt)
-
-#include "tst_qdeclarativeqt.moc"
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro b/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro
deleted file mode 100644
index cc27d173ab..0000000000
--- a/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativesqldatabase
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativesqldatabase.cpp
-
-include (../../shared/util.pri)
-
-CONFIG += parallel_test
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-QT += core-private gui-private v8-private declarative-private quick-private sql testlib
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp b/tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp
deleted file mode 100644
index cf4daed2f9..0000000000
--- a/tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp
+++ /dev/null
@@ -1,243 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <private/qdeclarativeengine_p.h>
-#include <QtCore/qcryptographichash.h>
-/*
-#include <QtWebKit/qwebpage.h>
-#include <QtWebKit/qwebframe.h>
-#include <QtWebKit/qwebdatabase.h>
-#include <QtWebKit/qwebsecurityorigin.h>
-*/
-#include <QtSql/qsqldatabase.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qfile.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativesqldatabase : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativesqldatabase()
- {
- qApp->setApplicationName("tst_qdeclarativesqldatabase");
- qApp->setOrganizationName("Nokia");
- qApp->setOrganizationDomain("nokia.com");
- engine = new QDeclarativeEngine;
- }
-
- ~tst_qdeclarativesqldatabase()
- {
- delete engine;
- }
-
-private slots:
- void initTestCase();
-
- void checkDatabasePath();
-
- void testQml_data();
- void testQml();
- void testQml_cleanopen_data();
- void testQml_cleanopen();
- void totalDatabases();
-
- void cleanupTestCase();
-
-private:
- QString dbDir() const;
- QDeclarativeEngine *engine;
-};
-
-void removeRecursive(const QString& dirname)
-{
- QDir dir(dirname);
- QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot));
- for (int i = 0; i < entries.count(); ++i)
- if (entries[i].isDir())
- removeRecursive(entries[i].filePath());
- else
- dir.remove(entries[i].fileName());
- QDir().rmdir(dirname);
-}
-
-void tst_qdeclarativesqldatabase::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- removeRecursive(dbDir());
- QDir().mkpath(dbDir());
-}
-
-void tst_qdeclarativesqldatabase::cleanupTestCase()
-{
- removeRecursive(dbDir());
-}
-
-QString tst_qdeclarativesqldatabase::dbDir() const
-{
- static QString tmpd = QDir::tempPath()+"/tst_qdeclarativesqldatabase_output-"
- + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss"));
- return tmpd;
-}
-
-void tst_qdeclarativesqldatabase::checkDatabasePath()
-{
- // Check default storage path (we can't use it since we don't want to mess with user's data)
- QVERIFY(engine->offlineStoragePath().contains("tst_qdeclarativesqldatabase"));
- QVERIFY(engine->offlineStoragePath().contains("OfflineStorage"));
-}
-
-static const int total_databases_created_by_tests = 12;
-void tst_qdeclarativesqldatabase::testQml_data()
-{
- QTest::addColumn<QString>("jsfile"); // The input file
-
- // Each test should use a newly named DB to avoid inter-test dependencies
- QTest::newRow("creation") << "creation.js";
- QTest::newRow("creation-a") << "creation-a.js";
- QTest::newRow("creation") << "creation.js";
- QTest::newRow("error-creation") << "error-creation.js"; // re-uses above DB
- QTest::newRow("changeversion") << "changeversion.js";
- QTest::newRow("readonly") << "readonly.js";
- QTest::newRow("readonly-error") << "readonly-error.js";
- QTest::newRow("selection") << "selection.js";
- QTest::newRow("selection-bindnames") << "selection-bindnames.js";
- QTest::newRow("iteration") << "iteration.js";
- QTest::newRow("iteration-forwardonly") << "iteration-forwardonly.js";
- QTest::newRow("error-a") << "error-a.js";
- QTest::newRow("error-notransaction") << "error-notransaction.js";
- QTest::newRow("error-outsidetransaction") << "error-outsidetransaction.js"; // reuse above
- QTest::newRow("reopen1") << "reopen1.js";
- QTest::newRow("reopen2") << "reopen2.js"; // re-uses above DB
-
- // If you add a test, you should usually use a new database in the
- // test - in which case increment total_databases_created_by_tests above.
-}
-
-/*
-class QWebPageWithJavaScriptConsoleMessages : public QWebPage {
-public:
- void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID)
- {
- qWarning() << sourceID << ":" << lineNumber << ":" << message;
- }
-};
-
-void tst_qdeclarativesqldatabase::validateAgainstWebkit()
-{
- // Validates tests against WebKit (HTML5) support.
- //
- QFETCH(QString, jsfile);
- QFETCH(QString, result);
- QFETCH(int, databases);
-
- QFile f(jsfile);
- QVERIFY(f.open(QIODevice::ReadOnly));
- QString js=f.readAll();
-
- QWebPageWithJavaScriptConsoleMessages webpage;
- webpage.settings()->setOfflineStoragePath(dbDir());
- webpage.settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true);
-
- QEXPECT_FAIL("","WebKit doesn't support openDatabaseSync yet", Continue);
- QCOMPARE(webpage.mainFrame()->evaluateJavaScript(js).toString(),result);
-
- QTest::qWait(100); // WebKit crashes if you quit it too fast
-
- QWebSecurityOrigin origin = webpage.mainFrame()->securityOrigin();
- QList<QWebDatabase> dbs = origin.databases();
- QCOMPARE(dbs.count(), databases);
-}
-*/
-
-void tst_qdeclarativesqldatabase::testQml()
-{
- // Tests QML SQL Database support with tests
- // that have been validated against Webkit.
- //
- QFETCH(QString, jsfile);
-
- QString qml=
- "import QtQuick 2.0\n"
- "import \""+jsfile+"\" as JS\n"
- "Text { text: JS.test() }";
-
- engine->setOfflineStoragePath(dbDir());
- QDeclarativeComponent component(engine);
- component.setData(qml.toUtf8(), testFileUrl("empty.qml")); // just a file for relative local imports
- QVERIFY(!component.isError());
- QQuickText *text = qobject_cast<QQuickText*>(component.create());
- QVERIFY(text != 0);
- QCOMPARE(text->text(),QString("passed"));
-}
-
-void tst_qdeclarativesqldatabase::testQml_cleanopen_data()
-{
- QTest::addColumn<QString>("jsfile"); // The input file
- QTest::newRow("reopen1") << "reopen1.js";
- QTest::newRow("reopen2") << "reopen2.js";
- QTest::newRow("error-creation") << "error-creation.js"; // re-uses creation DB
-}
-
-void tst_qdeclarativesqldatabase::testQml_cleanopen()
-{
- // Same as testQml, but clean connections between tests,
- // making it more like the tests are running in new processes.
- testQml();
-
- engine->collectGarbage();
-
- foreach (QString dbname, QSqlDatabase::connectionNames()) {
- QSqlDatabase::removeDatabase(dbname);
- }
-}
-
-void tst_qdeclarativesqldatabase::totalDatabases()
-{
- QCOMPARE(QDir(dbDir()+"/Databases").entryInfoList(QDir::Files|QDir::NoDotAndDotDot).count(), total_databases_created_by_tests*2);
-}
-
-QTEST_MAIN(tst_qdeclarativesqldatabase)
-
-#include "tst_qdeclarativesqldatabase.moc"
diff --git a/tests/auto/declarative/qdeclarativetranslation/qdeclarativetranslation.pro b/tests/auto/declarative/qdeclarativetranslation/qdeclarativetranslation.pro
deleted file mode 100644
index d6f067e440..0000000000
--- a/tests/auto/declarative/qdeclarativetranslation/qdeclarativetranslation.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativetranslation
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativetranslation.cpp
-RESOURCES += data/translation.qrc
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativetranslation/tst_qdeclarativetranslation.cpp b/tests/auto/declarative/qdeclarativetranslation/tst_qdeclarativetranslation.cpp
deleted file mode 100644
index ced1478649..0000000000
--- a/tests/auto/declarative/qdeclarativetranslation/tst_qdeclarativetranslation.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QTranslator>
-#include "../../shared/util.h"
-
-class tst_qdeclarativetranslation : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativetranslation() {}
-
-private slots:
- void translation();
- void idTranslation();
- void translationInQrc();
-};
-
-void tst_qdeclarativetranslation::translation()
-{
- QTranslator translator;
- translator.load(QLatin1String("qml_fr"), dataDirectory());
- QCoreApplication::installTranslator(&translator);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("translation.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("basic").toString(), QLatin1String("bonjour"));
- QCOMPARE(object->property("basic2").toString(), QLatin1String("au revoir"));
- QCOMPARE(object->property("basic3").toString(), QLatin1String("bonjour"));
- QCOMPARE(object->property("disambiguation").toString(), QLatin1String("salut"));
- QCOMPARE(object->property("disambiguation2").toString(), QString::fromUtf8("\xc3\xa0 plus tard"));
- QCOMPARE(object->property("disambiguation3").toString(), QLatin1String("salut"));
- QCOMPARE(object->property("noop").toString(), QLatin1String("bonjour"));
- QCOMPARE(object->property("noop2").toString(), QLatin1String("au revoir"));
- QCOMPARE(object->property("singular").toString(), QLatin1String("1 canard"));
- QCOMPARE(object->property("singular2").toString(), QLatin1String("1 canard"));
- QCOMPARE(object->property("plural").toString(), QLatin1String("2 canards"));
- QCOMPARE(object->property("plural2").toString(), QLatin1String("2 canards"));
-
- QCoreApplication::removeTranslator(&translator);
- delete object;
-}
-
-void tst_qdeclarativetranslation::idTranslation()
-{
- QTranslator translator;
- translator.load(QLatin1String("qmlid_fr"), dataDirectory());
- QCoreApplication::installTranslator(&translator);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("idtranslation.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("idTranslation").toString(), QLatin1String("bonjour tout le monde"));
- QCOMPARE(object->property("idTranslation2").toString(), QLatin1String("bonjour tout le monde"));
- QCOMPARE(object->property("idTranslation3").toString(), QLatin1String("bonjour tout le monde"));
-
- QCoreApplication::removeTranslator(&translator);
- delete object;
-}
-
-void tst_qdeclarativetranslation::translationInQrc()
-{
- QTranslator translator;
- translator.load(":/qml_fr.qm");
- QCoreApplication::installTranslator(&translator);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl("qrc:/translation.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("basic").toString(), QLatin1String("bonjour"));
- QCOMPARE(object->property("basic2").toString(), QLatin1String("au revoir"));
- QCOMPARE(object->property("basic3").toString(), QLatin1String("bonjour"));
- QCOMPARE(object->property("disambiguation").toString(), QLatin1String("salut"));
- QCOMPARE(object->property("disambiguation2").toString(), QString::fromUtf8("\xc3\xa0 plus tard"));
- QCOMPARE(object->property("disambiguation3").toString(), QLatin1String("salut"));
- QCOMPARE(object->property("noop").toString(), QLatin1String("bonjour"));
- QCOMPARE(object->property("noop2").toString(), QLatin1String("au revoir"));
- QCOMPARE(object->property("singular").toString(), QLatin1String("1 canard"));
- QCOMPARE(object->property("singular2").toString(), QLatin1String("1 canard"));
- QCOMPARE(object->property("plural").toString(), QLatin1String("2 canards"));
- QCOMPARE(object->property("plural2").toString(), QLatin1String("2 canards"));
-
- QCoreApplication::removeTranslator(&translator);
- delete object;
-}
-
-QTEST_MAIN(tst_qdeclarativetranslation)
-
-#include "tst_qdeclarativetranslation.moc"
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro
deleted file mode 100644
index 2968c8812b..0000000000
--- a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativevaluetypes
-macx:CONFIG -= app_bundle
-
-HEADERS += testtypes.h
-
-SOURCES += tst_qdeclarativevaluetypes.cpp \
- testtypes.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
deleted file mode 100644
index ff0e84ceaf..0000000000
--- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef TESTTYPES_H
-#define TESTTYPES_H
-
-#include <QObject>
-#include <QPoint>
-#include <QPointF>
-#include <QSize>
-#include <QSizeF>
-#include <QRect>
-#include <QRectF>
-#include <QVector2D>
-#include <QVector3D>
-#include <QVector4D>
-#include <QQuaternion>
-#include <QMatrix4x4>
-#include <QFont>
-#include <QColor>
-#include <qdeclarative.h>
-#include <QDeclarativePropertyValueSource>
-#include <QDeclarativeProperty>
-#include <private/qdeclarativeproperty_p.h>
-#include <private/qdeclarativepropertyvalueinterceptor_p.h>
-
-class MyTypeObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QPoint point READ point WRITE setPoint NOTIFY changed)
- Q_PROPERTY(QPointF pointf READ pointf WRITE setPointf NOTIFY changed)
- Q_PROPERTY(QPointF pointfpoint READ pointfpoint WRITE setPointfpoint NOTIFY changed)
- Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY changed)
- Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed)
- Q_PROPERTY(QSizeF sizefsize READ sizefsize WRITE setSizefsize NOTIFY changed)
- Q_PROPERTY(QSize sizereadonly READ size NOTIFY changed)
- Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed)
- Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed)
- Q_PROPERTY(QRectF rectfrect READ rectfrect WRITE setRectfrect NOTIFY changed)
- Q_PROPERTY(QVector2D vector2 READ vector2 WRITE setVector2 NOTIFY changed)
- Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed)
- Q_PROPERTY(QVector4D vector4 READ vector4 WRITE setVector4 NOTIFY changed)
- Q_PROPERTY(QQuaternion quaternion READ quaternion WRITE setQuaternion NOTIFY changed)
- Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY changed)
- Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed)
- Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY changed)
- Q_PROPERTY(QVariant variant READ variant NOTIFY changed)
-
-public:
- MyTypeObject() :
- m_point(10, 4),
- m_pointf(11.3, -10.9),
- m_pointfpoint(10.0, 4.0),
- m_size(1912, 1913),
- m_sizef(0.1, 100923.2),
- m_sizefsize(1912.0, 1913.0),
- m_rect(2, 3, 109, 102),
- m_rectf(103.8, 99.2, 88.1, 77.6),
- m_rectfrect(2.0, 3.0, 109.0, 102.0),
- m_vector2(32.88, 1.3),
- m_vector(23.88, 3.1, 4.3),
- m_vector4(54.2, 23.88, 3.1, 4.3),
- m_quaternion(4.3, 54.2, 23.88, 3.1),
- m_matrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
- {
- m_font.setFamily("Arial");
- m_font.setBold(true);
- m_font.setWeight(QFont::DemiBold);
- m_font.setItalic(true);
- m_font.setUnderline(true);
- m_font.setOverline(true);
- m_font.setStrikeOut(true);
- m_font.setPointSize(29);
- m_font.setCapitalization(QFont::AllLowercase);
- m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2);
- m_font.setWordSpacing(19.7);
- m_color.setRedF(0.2);
- m_color.setGreenF(0.88);
- m_color.setBlueF(0.6);
- m_color.setAlphaF(0.34);
- }
-
- QPoint m_point;
- QPoint point() const { return m_point; }
- void setPoint(const QPoint &v) { m_point = v; emit changed(); }
-
- QPointF m_pointf;
- QPointF pointf() const { return m_pointf; }
- void setPointf(const QPointF &v) { m_pointf = v; emit changed(); }
-
- QPointF m_pointfpoint;
- QPointF pointfpoint() const { return m_pointfpoint; }
- void setPointfpoint(const QPointF &v) { m_pointfpoint = v; emit changed(); }
-
- QSize m_size;
- QSize size() const { return m_size; }
- void setSize(const QSize &v) { m_size = v; emit changed(); }
-
- QSizeF m_sizef;
- QSizeF sizef() const { return m_sizef; }
- void setSizef(const QSizeF &v) { m_sizef = v; emit changed(); }
-
- QSizeF m_sizefsize;
- QSizeF sizefsize() const { return m_sizefsize; }
- void setSizefsize(const QSizeF &v) { m_sizefsize = v; emit changed(); }
-
- QRect m_rect;
- QRect rect() const { return m_rect; }
- void setRect(const QRect &v) { m_rect = v; emit changed(); }
-
- QRectF m_rectf;
- QRectF rectf() const { return m_rectf; }
- void setRectf(const QRectF &v) { m_rectf = v; emit changed(); }
-
- QRectF m_rectfrect;
- QRectF rectfrect() const { return m_rectfrect; }
- void setRectfrect(const QRectF &v) { m_rectfrect = v; emit changed(); }
-
- QVector2D m_vector2;
- QVector2D vector2() const { return m_vector2; }
- void setVector2(const QVector2D &v) { m_vector2 = v; emit changed(); }
-
- QVector3D m_vector;
- QVector3D vector() const { return m_vector; }
- void setVector(const QVector3D &v) { m_vector = v; emit changed(); }
-
- QVector4D m_vector4;
- QVector4D vector4() const { return m_vector4; }
- void setVector4(const QVector4D &v) { m_vector4 = v; emit changed(); }
-
- QQuaternion m_quaternion;
- QQuaternion quaternion() const { return m_quaternion; }
- void setQuaternion(const QQuaternion &v) { m_quaternion = v; emit changed(); }
-
- QMatrix4x4 m_matrix;
- QMatrix4x4 matrix() const { return m_matrix; }
- void setMatrix(const QMatrix4x4 &v) { m_matrix = v; emit changed(); }
-
- QFont m_font;
- QFont font() const { return m_font; }
- void setFont(const QFont &v) { m_font = v; emit changed(); }
-
- QColor m_color;
- QColor color() const { return m_color; }
- void setColor(const QColor &v) { m_color = v; emit changed(); }
-
- QVariant variant() const { return sizef(); }
-
- void emitRunScript() { emit runScript(); }
-
-signals:
- void changed();
- void runScript();
-
-public slots:
- QSize method() { return QSize(13, 14); }
-};
-
-class MyConstantValueSource : public QObject, public QDeclarativePropertyValueSource
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativePropertyValueSource)
-public:
- virtual void setTarget(const QDeclarativeProperty &p) { p.write(3345); }
-};
-
-class MyOffsetValueInterceptor : public QObject, public QDeclarativePropertyValueInterceptor
-{
- Q_OBJECT
- Q_INTERFACES(QDeclarativePropertyValueInterceptor)
-public:
- virtual void setTarget(const QDeclarativeProperty &p) { prop = p; }
- virtual void write(const QVariant &value) { QDeclarativePropertyPrivate::write(prop, value.toInt() + 13, QDeclarativePropertyPrivate::BypassInterceptor); }
-
-private:
- QDeclarativeProperty prop;
-};
-
-void registerTypes();
-
-#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
deleted file mode 100644
index 72ec7a5abf..0000000000
--- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
+++ /dev/null
@@ -1,1306 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QDebug>
-#include <private/qdeclarativevaluetype_p.h>
-#include "../../shared/util.h"
-#include "testtypes.h"
-
-QT_BEGIN_NAMESPACE
-extern int qt_defaultDpi();
-QT_END_NAMESPACE
-
-class tst_qdeclarativevaluetypes : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativevaluetypes() {}
-
-private slots:
- void initTestCase();
-
- void point();
- void pointf();
- void size();
- void sizef();
- void sizereadonly();
- void rect();
- void rectf();
- void vector2d();
- void vector3d();
- void vector4d();
- void quaternion();
- void matrix4x4();
- void font();
- void color();
- void variant();
-
- void bindingAssignment();
- void bindingRead();
- void staticAssignment();
- void scriptAccess();
- void autoBindingRemoval();
- void valueSources();
- void valueInterceptors();
- void bindingConflict();
- void deletedObject();
- void bindingVariantCopy();
- void scriptVariantCopy();
- void cppClasses();
- void enums();
- void conflictingBindings();
- void returnValues();
- void varAssignment();
- void bindingsSpliceCorrectly();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qdeclarativevaluetypes::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- registerTypes();
-}
-
-void tst_qdeclarativevaluetypes::point()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("point_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("p_x").toInt(), 10);
- QCOMPARE(object->property("p_y").toInt(), 4);
- QCOMPARE(object->property("copy"), QVariant(QPoint(10, 4)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("point_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->point(), QPoint(11, 12));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("point_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QPoint(10, 4)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), true);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
- QCOMPARE(object->property("equalsOther").toBool(), false);
- QCOMPARE(object->property("pointEqualsPointf").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::pointf()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("pointf_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(float(object->property("p_x").toDouble()), float(11.3));
- QCOMPARE(float(object->property("p_y").toDouble()), float(-10.9));
- QCOMPARE(object->property("copy"), QVariant(QPointF(11.3, -10.9)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("pointf_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->pointf(), QPointF(6.8, 9.3));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("pointf_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QPointF(11.3, -10.9)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), true);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
- QCOMPARE(object->property("equalsOther").toBool(), false);
- QCOMPARE(object->property("pointfEqualsPoint").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::size()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("size_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("s_width").toInt(), 1912);
- QCOMPARE(object->property("s_height").toInt(), 1913);
- QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("size_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->size(), QSize(13, 88));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("size_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QSize(1912, 1913)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), true);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
- QCOMPARE(object->property("equalsOther").toBool(), false);
- QCOMPARE(object->property("sizeEqualsSizef").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::sizef()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("sizef_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(float(object->property("s_width").toDouble()), float(0.1));
- QCOMPARE(float(object->property("s_height").toDouble()), float(100923.2));
- QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("sizef_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->sizef(), QSizeF(44.3, 92.8));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("sizef_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QSizeF(0.1, 100923)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), true);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
- QCOMPARE(object->property("equalsOther").toBool(), false);
- QCOMPARE(object->property("sizefEqualsSize").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::variant()
-{
- QDeclarativeComponent component(&engine, testFileUrl("variant_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(float(object->property("s_width").toDouble()), float(0.1));
- QCOMPARE(float(object->property("s_height").toDouble()), float(100923.2));
- QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2)));
-
- delete object;
-}
-
-void tst_qdeclarativevaluetypes::sizereadonly()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("s_width").toInt(), 1912);
- QCOMPARE(object->property("s_height").toInt(), 1913);
- QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_writeerror.qml"));
- QVERIFY(component.isError());
- QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_writeerror2.qml"));
- QVERIFY(component.isError());
- QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_writeerror3.qml"));
- QVERIFY(component.isError());
- QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_writeerror4.qml"));
-
- QObject *object = component.create();
- QVERIFY(object);
-
- QCOMPARE(object->property("sizereadonly").toSize(), QSize(1912, 1913));
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::rect()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("rect_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("r_x").toInt(), 2);
- QCOMPARE(object->property("r_y").toInt(), 3);
- QCOMPARE(object->property("r_width").toInt(), 109);
- QCOMPARE(object->property("r_height").toInt(), 102);
- QCOMPARE(object->property("copy"), QVariant(QRect(2, 3, 109, 102)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("rect_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect(), QRect(1234, 7, 56, 63));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("rect_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QRect(2, 3, 109, 102)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), true);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
- QCOMPARE(object->property("equalsOther").toBool(), false);
- QCOMPARE(object->property("rectEqualsRectf").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::rectf()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("rectf_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(float(object->property("r_x").toDouble()), float(103.8));
- QCOMPARE(float(object->property("r_y").toDouble()), float(99.2));
- QCOMPARE(float(object->property("r_width").toDouble()), float(88.1));
- QCOMPARE(float(object->property("r_height").toDouble()), float(77.6));
- QCOMPARE(object->property("copy"), QVariant(QRectF(103.8, 99.2, 88.1, 77.6)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("rectf_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rectf(), QRectF(70.1, -113.2, 80924.8, 99.2));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("rectf_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QRectF(103.8, 99.2, 88.1, 77.6)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), true);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
- QCOMPARE(object->property("equalsOther").toBool(), false);
- QCOMPARE(object->property("rectfEqualsRect").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::vector2d()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector2d_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE((float)object->property("v_x").toDouble(), (float)32.88);
- QCOMPARE((float)object->property("v_y").toDouble(), (float)1.3);
- QCOMPARE(object->property("copy"), QVariant(QVector2D(32.88, 1.3)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector2d_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->vector2(), QVector2D(-0.3, -12.9));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector2d_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QVector2D(32.88, 1.3)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::vector3d()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector3d_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE((float)object->property("v_x").toDouble(), (float)23.88);
- QCOMPARE((float)object->property("v_y").toDouble(), (float)3.1);
- QCOMPARE((float)object->property("v_z").toDouble(), (float)4.3);
- QCOMPARE(object->property("copy"), QVariant(QVector3D(23.88, 3.1, 4.3)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector3d_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->vector(), QVector3D(-0.3, -12.9, 907.4));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector3d_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QVector3D(23.88, 3.1, 4.3)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), true);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
- QCOMPARE(object->property("equalsOther").toBool(), false);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::vector4d()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector4d_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE((float)object->property("v_x").toDouble(), (float)54.2);
- QCOMPARE((float)object->property("v_y").toDouble(), (float)23.88);
- QCOMPARE((float)object->property("v_z").toDouble(), (float)3.1);
- QCOMPARE((float)object->property("v_w").toDouble(), (float)4.3);
- QCOMPARE(object->property("copy"), QVariant(QVector4D(54.2, 23.88, 3.1, 4.3)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector4d_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->vector4(), QVector4D(-0.3, -12.9, 907.4, 88.5));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("vector4d_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QVector4D(54.2, 23.88, 3.1, 4.3)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::quaternion()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("quaternion_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE((float)object->property("v_scalar").toDouble(), (float)4.3);
- QCOMPARE((float)object->property("v_x").toDouble(), (float)54.2);
- QCOMPARE((float)object->property("v_y").toDouble(), (float)23.88);
- QCOMPARE((float)object->property("v_z").toDouble(), (float)3.1);
- QCOMPARE(object->property("copy"), QVariant(QQuaternion(4.3, 54.2, 23.88, 3.1)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("quaternion_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->quaternion(), QQuaternion(88.5, -0.3, -12.9, 907.4));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("quaternion_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QQuaternion(4.3, 54.2, 23.88, 3.1)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::matrix4x4()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("matrix4x4_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE((float)object->property("v_m11").toDouble(), (float)1);
- QCOMPARE((float)object->property("v_m12").toDouble(), (float)2);
- QCOMPARE((float)object->property("v_m13").toDouble(), (float)3);
- QCOMPARE((float)object->property("v_m14").toDouble(), (float)4);
- QCOMPARE((float)object->property("v_m21").toDouble(), (float)5);
- QCOMPARE((float)object->property("v_m22").toDouble(), (float)6);
- QCOMPARE((float)object->property("v_m23").toDouble(), (float)7);
- QCOMPARE((float)object->property("v_m24").toDouble(), (float)8);
- QCOMPARE((float)object->property("v_m31").toDouble(), (float)9);
- QCOMPARE((float)object->property("v_m32").toDouble(), (float)10);
- QCOMPARE((float)object->property("v_m33").toDouble(), (float)11);
- QCOMPARE((float)object->property("v_m34").toDouble(), (float)12);
- QCOMPARE((float)object->property("v_m41").toDouble(), (float)13);
- QCOMPARE((float)object->property("v_m42").toDouble(), (float)14);
- QCOMPARE((float)object->property("v_m43").toDouble(), (float)15);
- QCOMPARE((float)object->property("v_m44").toDouble(), (float)16);
- QCOMPARE(object->property("copy"),
- QVariant(QMatrix4x4(1, 2, 3, 4,
- 5, 6, 7, 8,
- 9, 10, 11, 12,
- 13, 14, 15, 16)));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("matrix4x4_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->matrix(), QMatrix4x4(11, 12, 13, 14,
- 21, 22, 23, 24,
- 31, 32, 33, 34,
- 41, 42, 43, 44));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("matrix4x4_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QMatrix4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)");
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::font()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("font_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("f_family").toString(), object->font().family());
- QCOMPARE(object->property("f_bold").toBool(), object->font().bold());
- QCOMPARE(object->property("f_weight").toInt(), object->font().weight());
- QCOMPARE(object->property("f_italic").toBool(), object->font().italic());
- QCOMPARE(object->property("f_underline").toBool(), object->font().underline());
- QCOMPARE(object->property("f_overline").toBool(), object->font().overline());
- QCOMPARE(object->property("f_strikeout").toBool(), object->font().strikeOut());
- QCOMPARE(object->property("f_pointSize").toDouble(), object->font().pointSizeF());
- QCOMPARE(object->property("f_pixelSize").toInt(), int((object->font().pointSizeF() * qt_defaultDpi()) / qreal(72.)));
- QCOMPARE(object->property("f_capitalization").toInt(), (int)object->font().capitalization());
- QCOMPARE(object->property("f_letterSpacing").toDouble(), object->font().letterSpacing());
- QCOMPARE(object->property("f_wordSpacing").toDouble(), object->font().wordSpacing());
-
- QCOMPARE(object->property("copy"), QVariant(object->font()));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("font_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QFont font;
- font.setFamily("Helvetica");
- font.setBold(false);
- font.setWeight(QFont::Normal);
- font.setItalic(false);
- font.setUnderline(false);
- font.setStrikeOut(false);
- font.setPointSize(15);
- font.setCapitalization(QFont::AllLowercase);
- font.setLetterSpacing(QFont::AbsoluteSpacing, 9.7);
- font.setWordSpacing(11.2);
-
- QFont f = object->font();
- QCOMPARE(f.family(), font.family());
- QCOMPARE(f.bold(), font.bold());
- QCOMPARE(f.weight(), font.weight());
- QCOMPARE(f.italic(), font.italic());
- QCOMPARE(f.underline(), font.underline());
- QCOMPARE(f.strikeOut(), font.strikeOut());
- QCOMPARE(f.pointSize(), font.pointSize());
- QCOMPARE(f.capitalization(), font.capitalization());
- QCOMPARE(f.letterSpacing(), font.letterSpacing());
- QCOMPARE(f.wordSpacing(), font.wordSpacing());
-
- delete object;
- }
-
- // Test pixelSize
- {
- QDeclarativeComponent component(&engine, testFileUrl("font_write.2.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->font().pixelSize(), 10);
-
- delete object;
- }
-
- // Test pixelSize and pointSize
- {
- QDeclarativeComponent component(&engine, testFileUrl("font_write.3.qml"));
- QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. ");
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->font().pixelSize(), 10);
-
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("font_write.4.qml"));
- QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. ");
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->font().pixelSize(), 10);
-
- delete object;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("font_write.5.qml"));
- QObject *object = qobject_cast<QObject *>(component.create());
- QVERIFY(object != 0);
- MyTypeObject *object1 = object->findChild<MyTypeObject *>("object1");
- QVERIFY(object1 != 0);
- MyTypeObject *object2 = object->findChild<MyTypeObject *>("object2");
- QVERIFY(object2 != 0);
-
- QCOMPARE(object1->font().pixelSize(), 19);
- QCOMPARE(object2->font().pointSize(), 14);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("font_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QString tostring = QLatin1String("QFont(") + object->font().toString() + QLatin1Char(')');
- QCOMPARE(object->property("tostring").toString(), tostring);
- QCOMPARE(object->property("equalsString").toBool(), true);
- QCOMPARE(object->property("equalsColor").toBool(), false);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
- QCOMPARE(object->property("equalsSelf").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::color()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("color_read.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE((float)object->property("v_r").toDouble(), (float)0.2);
- QCOMPARE((float)object->property("v_g").toDouble(), (float)0.88);
- QCOMPARE((float)object->property("v_b").toDouble(), (float)0.6);
- QCOMPARE((float)object->property("v_a").toDouble(), (float)0.34);
- QColor comparison;
- comparison.setRedF(0.2);
- comparison.setGreenF(0.88);
- comparison.setBlueF(0.6);
- comparison.setAlphaF(0.34);
- QCOMPARE(object->property("copy"), QVariant(comparison));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("color_write.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QColor newColor;
- newColor.setRedF(0.5);
- newColor.setGreenF(0.38);
- newColor.setBlueF(0.3);
- newColor.setAlphaF(0.7);
- QCOMPARE(object->color(), newColor);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("color_compare.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QString colorString("#33e199");
- QCOMPARE(object->property("colorToString").toString(), colorString);
- QCOMPARE(object->property("colorEqualsIdenticalRgba").toBool(), true);
- QCOMPARE(object->property("colorEqualsDifferentAlpha").toBool(), false);
- QCOMPARE(object->property("colorEqualsDifferentRgba").toBool(), false);
- QCOMPARE(object->property("colorToStringEqualsColorString").toBool(), true);
- QCOMPARE(object->property("colorToStringEqualsDifferentAlphaString").toBool(), true);
- QCOMPARE(object->property("colorToStringEqualsDifferentRgbaString").toBool(), false);
- QCOMPARE(object->property("colorEqualsColorString").toBool(), true); // maintaining behaviour with QtQuick 1.0
- QCOMPARE(object->property("colorEqualsDifferentAlphaString").toBool(), true); // maintaining behaviour with QtQuick 1.0
- QCOMPARE(object->property("colorEqualsDifferentRgbaString").toBool(), false);
-
- QCOMPARE(object->property("equalsColor").toBool(), true);
- QCOMPARE(object->property("equalsVector3d").toBool(), false);
- QCOMPARE(object->property("equalsSize").toBool(), false);
- QCOMPARE(object->property("equalsPoint").toBool(), false);
- QCOMPARE(object->property("equalsRect").toBool(), false);
-
- // Color == Property and Property == Color should return the same result.
- QCOMPARE(object->property("equalsColorRHS").toBool(), object->property("equalsColor").toBool());
- QCOMPARE(object->property("colorEqualsCopy").toBool(), true);
- QCOMPARE(object->property("copyEqualsColor").toBool(), object->property("colorEqualsCopy").toBool());
-
- delete object;
- }
-}
-
-// Test bindings can write to value types
-void tst_qdeclarativevaluetypes::bindingAssignment()
-{
- QDeclarativeComponent component(&engine, testFileUrl("bindingAssignment.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 10);
-
- object->setProperty("value", QVariant(92));
-
- QCOMPARE(object->rect().x(), 92);
-
- delete object;
-}
-
-// Test bindings can read from value types
-void tst_qdeclarativevaluetypes::bindingRead()
-{
- QDeclarativeComponent component(&engine, testFileUrl("bindingRead.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("value").toInt(), 2);
-
- object->setRect(QRect(19, 3, 88, 2));
-
- QCOMPARE(object->property("value").toInt(), 19);
-
- delete object;
-}
-
-// Test static values can assign to value types
-void tst_qdeclarativevaluetypes::staticAssignment()
-{
- QDeclarativeComponent component(&engine, testFileUrl("staticAssignment.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 9);
-
- delete object;
-}
-
-// Test scripts can read/write value types
-void tst_qdeclarativevaluetypes::scriptAccess()
-{
- QDeclarativeComponent component(&engine, testFileUrl("scriptAccess.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("valuePre").toInt(), 2);
- QCOMPARE(object->rect().x(), 19);
- QCOMPARE(object->property("valuePost").toInt(), 19);
-
- delete object;
-}
-
-// Test that assigning a constant from script removes any binding
-void tst_qdeclarativevaluetypes::autoBindingRemoval()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("autoBindingRemoval.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 10);
-
- object->setProperty("value", QVariant(13));
-
- QCOMPARE(object->rect().x(), 13);
-
- object->emitRunScript();
-
- QCOMPARE(object->rect().x(), 42);
-
- object->setProperty("value", QVariant(92));
-
- QCOMPARE(object->rect().x(), 42);
-
- delete object;
- }
-
- /*
- {
- QDeclarativeComponent component(&engine, testFileUrl("autoBindingRemoval.2.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 10);
-
- object->setProperty("value", QVariant(13));
-
- QCOMPARE(object->rect().x(), 13);
-
- object->emitRunScript();
-
- QCOMPARE(object->rect(), QRect(10, 10, 10, 10));
-
- object->setProperty("value", QVariant(92));
-
- QCOMPARE(object->rect(), QRect(10, 10, 10, 10));
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("autoBindingRemoval.3.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- object->setProperty("value", QVariant(QRect(9, 22, 33, 44)));
-
- QCOMPARE(object->rect(), QRect(9, 22, 33, 44));
-
- object->emitRunScript();
-
- QCOMPARE(object->rect(), QRect(44, 22, 33, 44));
-
- object->setProperty("value", QVariant(QRect(19, 3, 4, 8)));
-
- QCOMPARE(object->rect(), QRect(44, 22, 33, 44));
-
- delete object;
- }
-*/
-}
-
-// Test that property value sources assign to value types
-void tst_qdeclarativevaluetypes::valueSources()
-{
- QDeclarativeComponent component(&engine, testFileUrl("valueSources.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 3345);
-
- delete object;
-}
-
-static void checkNoErrors(QDeclarativeComponent& component)
-{
- QList<QDeclarativeError> errors = component.errors();
- if (errors.isEmpty())
- return;
- for (int ii = 0; ii < errors.count(); ++ii) {
- const QDeclarativeError &error = errors.at(ii);
- qWarning("%d:%d:%s",error.line(),error.column(),error.description().toUtf8().constData());
- }
-}
-
-// Test that property value interceptors can be applied to value types
-void tst_qdeclarativevaluetypes::valueInterceptors()
-{
- QDeclarativeComponent component(&engine, testFileUrl("valueInterceptors.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- checkNoErrors(component);
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect().x(), 13);
-
- object->setProperty("value", 99);
-
- QCOMPARE(object->rect().x(), 112);
-
- delete object;
-}
-
-// Test that you can't assign a binding to the "root" value type, and a sub-property
-void tst_qdeclarativevaluetypes::bindingConflict()
-{
- QDeclarativeComponent component(&engine, testFileUrl("bindingConflict.qml"));
- QCOMPARE(component.isError(), true);
-}
-
-#define CPP_TEST(type, v) \
-{ \
- type *t = new type; \
- QVariant value(v); \
- t->setValue(value); \
- QCOMPARE(t->value(), value); \
- delete t; \
-}
-
-// Test that accessing a reference to a valuetype after the owning object is deleted
-// doesn't crash
-void tst_qdeclarativevaluetypes::deletedObject()
-{
- QDeclarativeComponent component(&engine, testFileUrl("deletedObject.qml"));
- QTest::ignoreMessage(QtDebugMsg, "Test: 2");
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QObject *dObject = qvariant_cast<QObject *>(object->property("object"));
- QVERIFY(dObject != 0);
- delete dObject;
-
- QTest::ignoreMessage(QtDebugMsg, "Test: undefined");
- object->emitRunScript();
-
- delete object;
-}
-
-// Test that value types can be assigned to another value type property in a binding
-void tst_qdeclarativevaluetypes::bindingVariantCopy()
-{
- QDeclarativeComponent component(&engine, testFileUrl("bindingVariantCopy.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect(), QRect(19, 33, 5, 99));
-
- delete object;
-}
-
-// Test that value types can be assigned to another value type property in script
-void tst_qdeclarativevaluetypes::scriptVariantCopy()
-{
- QDeclarativeComponent component(&engine, testFileUrl("scriptVariantCopy.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
-
- QCOMPARE(object->rect(), QRect(2, 3, 109, 102));
-
- object->emitRunScript();
-
- QCOMPARE(object->rect(), QRect(19, 33, 5, 99));
-
- delete object;
-}
-
-
-// Test that the value type classes can be used manually
-void tst_qdeclarativevaluetypes::cppClasses()
-{
- CPP_TEST(QDeclarativePointValueType, QPoint(19, 33));
- CPP_TEST(QDeclarativePointFValueType, QPointF(33.6, -23));
- CPP_TEST(QDeclarativeSizeValueType, QSize(-100, 18));
- CPP_TEST(QDeclarativeSizeFValueType, QSizeF(-100.7, 18.2));
- CPP_TEST(QDeclarativeRectValueType, QRect(13, 39, 10928, 88));
- CPP_TEST(QDeclarativeRectFValueType, QRectF(88.2, -90.1, 103.2, 118));
- CPP_TEST(QDeclarativeVector2DValueType, QVector2D(19.7, 1002));
- CPP_TEST(QDeclarativeVector3DValueType, QVector3D(18.2, 19.7, 1002));
- CPP_TEST(QDeclarativeVector4DValueType, QVector4D(18.2, 19.7, 1002, 54));
- CPP_TEST(QDeclarativeQuaternionValueType, QQuaternion(18.2, 19.7, 1002, 54));
- CPP_TEST(QDeclarativeMatrix4x4ValueType,
- QMatrix4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16));
- CPP_TEST(QDeclarativeFontValueType, QFont("Helvetica"));
-
-}
-
-void tst_qdeclarativevaluetypes::enums()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("enums.1.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->font().capitalization() == QFont::AllUppercase);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("enums.2.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->font().capitalization() == QFont::AllUppercase);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("enums.3.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->font().capitalization() == QFont::AllUppercase);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("enums.4.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->font().capitalization() == QFont::AllUppercase);
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("enums.5.qml"));
- MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
- QVERIFY(object != 0);
- QVERIFY(object->font().capitalization() == QFont::AllUppercase);
- delete object;
- }
-}
-
-// Tests switching between "conflicting" bindings (eg. a binding on the core
-// property, to a binding on the value-type sub-property)
-void tst_qdeclarativevaluetypes::conflictingBindings()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("conflicting.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
-
- QMetaObject::invokeMethod(object, "toggle");
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6);
-
- QMetaObject::invokeMethod(object, "toggle");
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("conflicting.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6);
-
- QMetaObject::invokeMethod(object, "toggle");
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
-
- QMetaObject::invokeMethod(object, "toggle");
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("conflicting.3.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
-
- QMetaObject::invokeMethod(object, "toggle");
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 24);
-
- QMetaObject::invokeMethod(object, "toggle");
-
- QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
-
- delete object;
- }
-}
-
-void tst_qdeclarativevaluetypes::returnValues()
-{
- QDeclarativeComponent component(&engine, testFileUrl("returnValues.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test1").toBool(), true);
- QCOMPARE(object->property("test2").toBool(), true);
- QCOMPARE(object->property("size").toSize(), QSize(13, 14));
-
- delete object;
-}
-
-void tst_qdeclarativevaluetypes::varAssignment()
-{
- QDeclarativeComponent component(&engine, testFileUrl("varAssignment.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("x").toInt(), 1);
- QCOMPARE(object->property("y").toInt(), 2);
- QCOMPARE(object->property("z").toInt(), 3);
-
- delete object;
-}
-
-// Test bindings splice together correctly
-void tst_qdeclarativevaluetypes::bindingsSpliceCorrectly()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.3.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.4.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.5.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
- }
-}
-
-QTEST_MAIN(tst_qdeclarativevaluetypes)
-
-#include "tst_qdeclarativevaluetypes.moc"
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro
deleted file mode 100644
index 9e5cc43f20..0000000000
--- a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeworkerscript
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeworkerscript.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private testlib
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
deleted file mode 100644
index 92e5df127a..0000000000
--- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
+++ /dev/null
@@ -1,300 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qtimer.h>
-#include <QtCore/qdir.h>
-#include <QtCore/qfileinfo.h>
-#include <QtDeclarative/qjsengine.h>
-
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-
-#include <private/qdeclarativeworkerscript_p.h>
-#include <private/qdeclarativeengine_p.h>
-#include "../../shared/util.h"
-
-class tst_QDeclarativeWorkerScript : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QDeclarativeWorkerScript() {}
-private slots:
- void source();
- void messaging();
- void messaging_data();
- void messaging_sendQObjectList();
- void messaging_sendJsObject();
- void messaging_sendExternalObject();
- void script_with_pragma();
- void script_included();
- void scriptError_onLoad();
- void scriptError_onCall();
- void stressDispose();
-
-private:
- void waitForEchoMessage(QDeclarativeWorkerScript *worker) {
- QEventLoop loop;
- QVERIFY(connect(worker, SIGNAL(done()), &loop, SLOT(quit())));
- QTimer timer;
- timer.setSingleShot(true);
- connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
- timer.start(10000);
- loop.exec();
- QVERIFY(timer.isActive());
- }
-
- QDeclarativeEngine m_engine;
-};
-
-void tst_QDeclarativeWorkerScript::source()
-{
- QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml"));
- QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(worker != 0);
- const QMetaObject *mo = worker->metaObject();
-
- QVariant value(100);
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
- waitForEchoMessage(worker);
- QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
-
- QUrl source = testFileUrl("script_fixed_return.js");
- worker->setSource(source);
- QCOMPARE(worker->source(), source);
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
- waitForEchoMessage(worker);
- QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), qVariantFromValue(QString("Hello_World")));
-
- qApp->processEvents();
- delete worker;
-}
-
-void tst_QDeclarativeWorkerScript::messaging()
-{
- QFETCH(QVariant, value);
-
- QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml"));
- QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(worker != 0);
-
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
- waitForEchoMessage(worker);
-
- const QMetaObject *mo = worker->metaObject();
- QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
-
- qApp->processEvents();
- delete worker;
-}
-
-void tst_QDeclarativeWorkerScript::messaging_data()
-{
- QTest::addColumn<QVariant>("value");
-
- QTest::newRow("invalid") << QVariant();
- QTest::newRow("bool") << qVariantFromValue(true);
- QTest::newRow("int") << qVariantFromValue(1001);
- QTest::newRow("real") << qVariantFromValue(10334.375);
- QTest::newRow("string") << qVariantFromValue(QString("More cheeeese, Gromit!"));
- QTest::newRow("variant list") << qVariantFromValue((QVariantList() << "a" << "b" << "c"));
- QTest::newRow("date time") << qVariantFromValue(QDateTime::currentDateTime());
-#ifndef QT_NO_REGEXP
- // QtScript's QScriptValue -> QRegExp uses RegExp2 pattern syntax
- QTest::newRow("regexp") << qVariantFromValue(QRegExp("^\\d\\d?$", Qt::CaseInsensitive, QRegExp::RegExp2));
-#endif
-}
-
-void tst_QDeclarativeWorkerScript::messaging_sendQObjectList()
-{
- // Not allowed to send QObjects other than QDeclarativeWorkerListModelAgent
- // instances. If objects are sent in a list, they will be sent as 'undefined'
- // js values.
-
- QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml"));
- QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(worker != 0);
-
- QVariantList objects;
- for (int i=0; i<3; i++)
- objects << qVariantFromValue(new QObject(this));
-
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, qVariantFromValue(objects))));
- waitForEchoMessage(worker);
-
- const QMetaObject *mo = worker->metaObject();
- QVariantList result = mo->property(mo->indexOfProperty("response")).read(worker).value<QVariantList>();
- QCOMPARE(result, (QVariantList() << QVariant() << QVariant() << QVariant()));
-
- qApp->processEvents();
- delete worker;
-}
-
-void tst_QDeclarativeWorkerScript::messaging_sendJsObject()
-{
- QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml"));
- QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(worker != 0);
-
- // Properties are in alphabetical order to enable string-based comparison after
- // QVariant roundtrip, since the properties will be stored in a QVariantMap.
- QString jsObject = "{'haste': 1125, 'name': 'zyz', 'spell power': 3101}";
-
- QVariantMap map;
- map.insert("haste", 1125);
- map.insert("name", "zyz");
- map.insert("spell power", 3101);
-
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, qVariantFromValue(map))));
- waitForEchoMessage(worker);
-
- QVariant result = qVariantFromValue(false);
- QVERIFY(QMetaObject::invokeMethod(worker, "compareLiteralResponse", Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, jsObject)));
- QVERIFY(result.toBool());
-
- qApp->processEvents();
- delete worker;
-}
-
-void tst_QDeclarativeWorkerScript::messaging_sendExternalObject()
-{
- QDeclarativeComponent component(&m_engine, testFileUrl("externalObjectWorker.qml"));
- QObject *obj = component.create();
- QVERIFY(obj);
- QMetaObject::invokeMethod(obj, "testExternalObject");
- QTest::qWait(100); // shouldn't crash.
- delete obj;
-}
-
-void tst_QDeclarativeWorkerScript::script_with_pragma()
-{
- QVariant value(100);
-
- QDeclarativeComponent component(&m_engine, testFileUrl("worker_pragma.qml"));
- QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(worker != 0);
-
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
- waitForEchoMessage(worker);
-
- const QMetaObject *mo = worker->metaObject();
- QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
-
- qApp->processEvents();
- delete worker;
-}
-
-void tst_QDeclarativeWorkerScript::script_included()
-{
- QDeclarativeComponent component(&m_engine, testFileUrl("worker_include.qml"));
- QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(worker != 0);
-
- QString value("Hello");
-
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
- waitForEchoMessage(worker);
-
- const QMetaObject *mo = worker->metaObject();
- QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).toString(), value + " World");
-
- qApp->processEvents();
- delete worker;
-}
-
-static QString qdeclarativeworkerscript_lastWarning;
-static void qdeclarativeworkerscript_warningsHandler(QtMsgType type, const char *msg)
-{
- if (type == QtWarningMsg)
- qdeclarativeworkerscript_lastWarning = QString::fromUtf8(msg);
-}
-
-void tst_QDeclarativeWorkerScript::scriptError_onLoad()
-{
- QDeclarativeComponent component(&m_engine, testFileUrl("worker_error_onLoad.qml"));
-
- QtMsgHandler previousMsgHandler = qInstallMsgHandler(qdeclarativeworkerscript_warningsHandler);
- QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(worker != 0);
-
- QTRY_COMPARE(qdeclarativeworkerscript_lastWarning,
- testFileUrl("script_error_onLoad.js").toString() + QLatin1String(":3: SyntaxError: Unexpected identifier"));
-
- qInstallMsgHandler(previousMsgHandler);
- qApp->processEvents();
- delete worker;
-}
-
-void tst_QDeclarativeWorkerScript::scriptError_onCall()
-{
- QDeclarativeComponent component(&m_engine, testFileUrl("worker_error_onCall.qml"));
- QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
- QVERIFY(worker != 0);
-
- QtMsgHandler previousMsgHandler = qInstallMsgHandler(qdeclarativeworkerscript_warningsHandler);
- QVariant value;
- QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
-
- QTRY_COMPARE(qdeclarativeworkerscript_lastWarning,
- testFileUrl("script_error_onCall.js").toString() + QLatin1String(":4: ReferenceError: Can't find variable: getData"));
-
- qInstallMsgHandler(previousMsgHandler);
- qApp->processEvents();
- delete worker;
-}
-
-// Rapidly create and destroy worker scripts to test resources are being disposed
-// in the correct isolate
-void tst_QDeclarativeWorkerScript::stressDispose()
-{
- for (int ii = 0; ii < 100; ++ii) {
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("stressDispose.qml"));
- QObject *o = component.create();
- QVERIFY(o);
- delete o;
- }
-}
-
-QTEST_MAIN(tst_QDeclarativeWorkerScript)
-
-#include "tst_qdeclarativeworkerscript.moc"
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro
deleted file mode 100644
index b8f09f8722..0000000000
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativexmlhttprequest
-macx:CONFIG -= app_bundle
-
-INCLUDEPATH += ../../shared/
-HEADERS += ../../shared/testhttpserver.h
-
-SOURCES += tst_qdeclarativexmlhttprequest.cpp \
- ../../shared/testhttpserver.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private network testlib
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
deleted file mode 100644
index f3c3b57725..0000000000
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
+++ /dev/null
@@ -1,1160 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDeclarativeEngine>
-#include <QDeclarativeComponent>
-#include <QDebug>
-#include <QScopedPointer>
-#include <QNetworkCookieJar>
-#include "testhttpserver.h"
-#include "../../shared/util.h"
-
-#define SERVER_PORT 14445
-
-class tst_qdeclarativexmlhttprequest : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativexmlhttprequest() {}
-
-private slots:
- void domExceptionCodes();
- void callbackException();
- void callbackException_data();
- void staticStateValues();
- void instanceStateValues();
- void constructor();
- void defaultState();
- void open();
- void open_data();
- void open_invalid_method();
- void open_sync();
- void open_arg_count();
- void setRequestHeader();
- void setRequestHeader_caseInsensitive();
- void setRequestHeader_unsent();
- void setRequestHeader_illegalName_data();
- void setRequestHeader_illegalName();
- void setRequestHeader_sent();
- void setRequestHeader_args();
- void send_unsent();
- void send_alreadySent();
- void send_ignoreData();
- void send_withdata();
- void send_withdata_data();
- void abort();
- void abort_unsent();
- void abort_opened();
- void getResponseHeader();
- void getResponseHeader_unsent();
- void getResponseHeader_sent();
- void getResponseHeader_args();
- void getAllResponseHeaders();
- void getAllResponseHeaders_unsent();
- void getAllResponseHeaders_sent();
- void getAllResponseHeaders_args();
- void status();
- void status_data();
- void statusText();
- void statusText_data();
- void responseText();
- void responseText_data();
- void responseXML_invalid();
- void invalidMethodUsage();
- void redirects();
- void nonUtf8();
- void nonUtf8_data();
-
- // Attributes
- void document();
- void element();
- void attr();
- void text();
- void cdata();
-
- // Crashes
- // void outstanding_request_at_shutdown();
-
- // void network_errors()
- // void readyState()
-
-private:
- QDeclarativeEngine engine;
-};
-
-// Test that the dom exception codes are correct
-void tst_qdeclarativexmlhttprequest::domExceptionCodes()
-{
- QDeclarativeComponent component(&engine, testFileUrl("domExceptionCodes.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("index_size_err").toInt(), 1);
- QCOMPARE(object->property("domstring_size_err").toInt(), 2);
- QCOMPARE(object->property("hierarchy_request_err").toInt(), 3);
- QCOMPARE(object->property("wrong_document_err").toInt(), 4);
- QCOMPARE(object->property("invalid_character_err").toInt(), 5);
- QCOMPARE(object->property("no_data_allowed_err").toInt(), 6);
- QCOMPARE(object->property("no_modification_allowed_err").toInt(), 7);
- QCOMPARE(object->property("not_found_err").toInt(), 8);
- QCOMPARE(object->property("not_supported_err").toInt(), 9);
- QCOMPARE(object->property("inuse_attribute_err").toInt(), 10);
- QCOMPARE(object->property("invalid_state_err").toInt(), 11);
- QCOMPARE(object->property("syntax_err").toInt(), 12);
- QCOMPARE(object->property("invalid_modification_err").toInt(), 13);
- QCOMPARE(object->property("namespace_err").toInt(), 14);
- QCOMPARE(object->property("invalid_access_err").toInt(), 15);
- QCOMPARE(object->property("validation_err").toInt(), 16);
- QCOMPARE(object->property("type_mismatch_err").toInt(), 17);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::callbackException_data()
-{
- QTest::addColumn<QString>("which");
- QTest::addColumn<int>("line");
-
- QTest::newRow("on-opened") << "1" << 15;
- QTest::newRow("on-loading") << "3" << 15;
- QTest::newRow("on-done") << "4" << 15;
-}
-
-void tst_qdeclarativexmlhttprequest::callbackException()
-{
- // Test exception reporting for exceptions thrown at various points.
-
- QFETCH(QString, which);
- QFETCH(int, line);
-
- QString expect = testFileUrl("callbackException.qml").toString() + ":"+QString::number(line)+": Error: Exception from Callback";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
-
- QDeclarativeComponent component(&engine, testFileUrl("callbackException.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "testdocument.html");
- object->setProperty("which", which);
- component.completeCreate();
-
- QTRY_VERIFY(object->property("threw").toBool() == true);
-
- delete object;
-}
-
-// Test that the state value properties on the XMLHttpRequest constructor have the correct values.
-// ### WebKit does not do this, but it seems to fit the standard and QML better
-void tst_qdeclarativexmlhttprequest::staticStateValues()
-{
- QDeclarativeComponent component(&engine, testFileUrl("staticStateValues.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("unsent").toInt(), 0);
- QCOMPARE(object->property("opened").toInt(), 1);
- QCOMPARE(object->property("headers_received").toInt(), 2);
- QCOMPARE(object->property("loading").toInt(), 3);
- QCOMPARE(object->property("done").toInt(), 4);
-
- delete object;
-}
-
-// Test that the state value properties on instances have the correct values.
-void tst_qdeclarativexmlhttprequest::instanceStateValues()
-{
- QDeclarativeComponent component(&engine, testFileUrl("instanceStateValues.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("unsent").toInt(), 0);
- QCOMPARE(object->property("opened").toInt(), 1);
- QCOMPARE(object->property("headers_received").toInt(), 2);
- QCOMPARE(object->property("loading").toInt(), 3);
- QCOMPARE(object->property("done").toInt(), 4);
-
- delete object;
-}
-
-// Test calling constructor
-void tst_qdeclarativexmlhttprequest::constructor()
-{
- QDeclarativeComponent component(&engine, testFileUrl("constructor.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("calledAsConstructor").toBool(), true);
- QCOMPARE(object->property("calledAsFunction").toBool(), true);
-
- delete object;
-}
-
-// Test that all the properties are set correctly before any request is sent
-void tst_qdeclarativexmlhttprequest::defaultState()
-{
- QDeclarativeComponent component(&engine, testFileUrl("defaultState.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("readState").toInt(), 0);
- QCOMPARE(object->property("statusIsException").toBool(), true);
- QCOMPARE(object->property("statusTextIsException").toBool(), true);
- QCOMPARE(object->property("responseText").toString(), QString());
- QCOMPARE(object->property("responseXMLIsNull").toBool(), true);
-
- delete object;
-}
-
-// Test valid XMLHttpRequest.open() calls
-void tst_qdeclarativexmlhttprequest::open()
-{
- QFETCH(QUrl, qmlFile);
- QFETCH(QString, url);
- QFETCH(bool, remote);
-
- QScopedPointer<TestHTTPServer> server; // ensure deletion in case test fails
- if (remote) {
- server.reset(new TestHTTPServer(SERVER_PORT));
- QVERIFY(server->isValid());
- QVERIFY(server->wait(testFileUrl("open_network.expect"),
- testFileUrl("open_network.reply"),
- testFileUrl("testdocument.html")));
- }
-
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", url);
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::open_data()
-{
- QTest::addColumn<QUrl>("qmlFile");
- QTest::addColumn<QString>("url");
- QTest::addColumn<bool>("remote");
-
- QTest::newRow("Relative url)") << testFileUrl("open.qml") << "testdocument.html" << false;
- QTest::newRow("Absolute url)") << testFileUrl("open.qml") << testFileUrl("testdocument.html").toString() << false;
- QTest::newRow("Absolute network url)") << testFileUrl("open.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
-
- // ### Check that the username/password were sent to the server
- QTest::newRow("User/pass") << testFileUrl("open_user.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
-}
-
-// Test that calling XMLHttpRequest.open() with an invalid method raises an exception
-void tst_qdeclarativexmlhttprequest::open_invalid_method()
-{
- QDeclarativeComponent component(&engine, testFileUrl("open_invalid_method.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("exceptionThrown").toBool(), true);
-
- delete object;
-}
-
-// Test that calling XMLHttpRequest.open() with sync raises an exception
-void tst_qdeclarativexmlhttprequest::open_sync()
-{
- QDeclarativeComponent component(&engine, testFileUrl("open_sync.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("exceptionThrown").toBool(), true);
-
- delete object;
-}
-
-// Calling with incorrect arg count raises an exception
-void tst_qdeclarativexmlhttprequest::open_arg_count()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("open_arg_count.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("exceptionThrown").toBool(), true);
-
- delete object;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("open_arg_count.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("exceptionThrown").toBool(), true);
-
- delete object;
- }
-}
-
-// Test valid setRequestHeader() calls
-void tst_qdeclarativexmlhttprequest::setRequestHeader()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"),
- testFileUrl("setRequestHeader.reply"),
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test valid setRequestHeader() calls with different header cases
-void tst_qdeclarativexmlhttprequest::setRequestHeader_caseInsensitive()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"),
- testFileUrl("setRequestHeader.reply"),
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_caseInsensitive.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-// Test setting headers before open() throws exception
-void tst_qdeclarativexmlhttprequest::setRequestHeader_unsent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_unsent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::setRequestHeader_illegalName_data()
-{
- QTest::addColumn<QString>("name");
-
- QTest::newRow("Accept-Charset") << "AccePT-CHArset";
- QTest::newRow("Accept-Encoding") << "AccEpt-EnCOding";
- QTest::newRow("Connection") << "ConnECtion";
- QTest::newRow("Content-Length") << "ContEnt-LenGth";
- QTest::newRow("Cookie") << "CookIe";
- QTest::newRow("Cookie2") << "CoOkie2";
- QTest::newRow("Content-Transfer-Encoding") << "ConteNT-tRANSFER-eNCOding";
- QTest::newRow("Date") << "DaTE";
- QTest::newRow("Expect") << "ExPect";
- QTest::newRow("Host") << "HoST";
- QTest::newRow("Keep-Alive") << "KEEP-aLive";
- QTest::newRow("Referer") << "ReferEr";
- QTest::newRow("TE") << "Te";
- QTest::newRow("Trailer") << "TraILEr";
- QTest::newRow("Transfer-Encoding") << "tRANsfer-Encoding";
- QTest::newRow("Upgrade") << "UpgrADe";
- QTest::newRow("User-Agent") << "uSEr-Agent";
- QTest::newRow("Via") << "vIa";
- QTest::newRow("Proxy-") << "ProXy-";
- QTest::newRow("Sec-") << "SeC-";
- QTest::newRow("Proxy-*") << "Proxy-BLAH";
- QTest::newRow("Sec-*") << "Sec-F";
-}
-
-// Tests that using illegal header names has no effect
-void tst_qdeclarativexmlhttprequest::setRequestHeader_illegalName()
-{
- QFETCH(QString, name);
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("open_network.expect"),
- testFileUrl("open_network.reply"),
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_illegalName.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("header", name);
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test that attempting to set a header after a request is sent throws an exception
-void tst_qdeclarativexmlhttprequest::setRequestHeader_sent()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("open_network.expect"),
- testFileUrl("open_network.reply"),
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_sent.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("test").toBool(), true);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Invalid arg count throws exception
-void tst_qdeclarativexmlhttprequest::setRequestHeader_args()
-{
- QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_args.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("exceptionThrown").toBool(), true);
-
- delete object;
-}
-
-// Test that calling send() in UNSENT state throws an exception
-void tst_qdeclarativexmlhttprequest::send_unsent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("send_unsent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Test attempting to resend a sent request throws an exception
-void tst_qdeclarativexmlhttprequest::send_alreadySent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("send_alreadySent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test that sends for GET, HEAD and DELETE ignore data
-void tst_qdeclarativexmlhttprequest::send_ignoreData()
-{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("send_ignoreData_GET.expect"),
- testFileUrl("send_ignoreData.reply"),
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("send_ignoreData.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("reqType", "GET");
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("send_ignoreData_HEAD.expect"),
- testFileUrl("send_ignoreData.reply"),
- QUrl()));
-
- QDeclarativeComponent component(&engine, testFileUrl("send_ignoreData.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("reqType", "HEAD");
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("send_ignoreData_DELETE.expect"),
- testFileUrl("send_ignoreData.reply"),
- QUrl()));
-
- QDeclarativeComponent component(&engine, testFileUrl("send_ignoreData.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("reqType", "DELETE");
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
- }
-}
-
-// Test that send()'ing data works
-void tst_qdeclarativexmlhttprequest::send_withdata()
-{
- QFETCH(QString, file_expected);
- QFETCH(QString, file_qml);
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl(file_expected),
- testFileUrl("send_data.reply"),
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl(file_qml));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::send_withdata_data()
-{
- QTest::addColumn<QString>("file_expected");
- QTest::addColumn<QString>("file_qml");
-
- QTest::newRow("No content-type") << "send_data.1.expect" << "send_data.1.qml";
- QTest::newRow("Correct content-type") << "send_data.1.expect" << "send_data.2.qml";
- QTest::newRow("Incorrect content-type") << "send_data.1.expect" << "send_data.3.qml";
- QTest::newRow("Correct content-type - out of order") << "send_data.4.expect" << "send_data.4.qml";
- QTest::newRow("Incorrect content-type - out of order") << "send_data.4.expect" << "send_data.5.qml";
- QTest::newRow("PUT") << "send_data.6.expect" << "send_data.6.qml";
- QTest::newRow("Correct content-type - no charset") << "send_data.1.expect" << "send_data.7.qml";
-}
-
-// Test abort() has no effect in unsent state
-void tst_qdeclarativexmlhttprequest::abort_unsent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("abort_unsent.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test abort() cancels an open (but unsent) request
-void tst_qdeclarativexmlhttprequest::abort_opened()
-{
- QDeclarativeComponent component(&engine, testFileUrl("abort_opened.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-// Test abort() aborts in progress send
-void tst_qdeclarativexmlhttprequest::abort()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("abort.expect"),
- testFileUrl("abort.reply"),
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("abort.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("urlDummy", "http://127.0.0.1:14449/testdocument.html");
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("seenDone").toBool(), true);
- QCOMPARE(object->property("didNotSeeUnsent").toBool(), true);
- QCOMPARE(object->property("endStateUnsent").toBool(), true);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::getResponseHeader()
-{
- QDeclarativeEngine engine; // Avoid cookie contamination
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"),
- testFileUrl("getResponseHeader.reply"),
- testFileUrl("testdocument.html")));
-
-
- QDeclarativeComponent component(&engine, testFileUrl("getResponseHeader.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("headersReceivedState").toBool(), true);
- QCOMPARE(object->property("headersReceivedNullHeader").toBool(), true);
- QCOMPARE(object->property("headersReceivedValidHeader").toBool(), true);
- QCOMPARE(object->property("headersReceivedMultiValidHeader").toBool(), true);
- QCOMPARE(object->property("headersReceivedCookieHeader").toBool(), true);
-
- QCOMPARE(object->property("doneState").toBool(), true);
- QCOMPARE(object->property("doneNullHeader").toBool(), true);
- QCOMPARE(object->property("doneValidHeader").toBool(), true);
- QCOMPARE(object->property("doneMultiValidHeader").toBool(), true);
- QCOMPARE(object->property("doneCookieHeader").toBool(), true);
-
- delete object;
-}
-
-// Test getResponseHeader throws an exception in an invalid state
-void tst_qdeclarativexmlhttprequest::getResponseHeader_unsent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("getResponseHeader_unsent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Test getResponseHeader throws an exception in an invalid state
-void tst_qdeclarativexmlhttprequest::getResponseHeader_sent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("getResponseHeader_sent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Invalid arg count throws exception
-void tst_qdeclarativexmlhttprequest::getResponseHeader_args()
-{
- QDeclarativeComponent component(&engine, testFileUrl("getResponseHeader_args.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QTRY_VERIFY(object->property("exceptionThrown").toBool() == true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::getAllResponseHeaders()
-{
- QDeclarativeEngine engine; // Avoid cookie contamination
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"),
- testFileUrl("getResponseHeader.reply"),
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("getAllResponseHeaders.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- component.completeCreate();
-
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("openedState").toBool(), true);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("headersReceivedState").toBool(), true);
- QCOMPARE(object->property("headersReceivedHeader").toBool(), true);
-
- QCOMPARE(object->property("doneState").toBool(), true);
- QCOMPARE(object->property("doneHeader").toBool(), true);
-
- delete object;
-}
-
-// Test getAllResponseHeaders throws an exception in an invalid state
-void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_unsent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("getAllResponseHeaders_unsent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Test getAllResponseHeaders throws an exception in an invalid state
-void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_sent()
-{
- QDeclarativeComponent component(&engine, testFileUrl("getAllResponseHeaders_sent.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("test").toBool(), true);
-
- delete object;
-}
-
-// Invalid arg count throws exception
-void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_args()
-{
- QDeclarativeComponent component(&engine, testFileUrl("getAllResponseHeaders_args.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QTRY_VERIFY(object->property("exceptionThrown").toBool() == true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::status()
-{
- QFETCH(QUrl, replyUrl);
- QFETCH(int, status);
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("status.expect"),
- replyUrl,
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("status.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedStatus", status);
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("sentException").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("resetException").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::status_data()
-{
- QTest::addColumn<QUrl>("replyUrl");
- QTest::addColumn<int>("status");
-
- QTest::newRow("OK") << testFileUrl("status.200.reply") << 200;
- QTest::newRow("Not Found") << testFileUrl("status.404.reply") << 404;
- QTest::newRow("Bad Request") << testFileUrl("status.400.reply") << 400;
-}
-
-void tst_qdeclarativexmlhttprequest::statusText()
-{
- QFETCH(QUrl, replyUrl);
- QFETCH(QString, statusText);
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("status.expect"),
- replyUrl,
- testFileUrl("testdocument.html")));
-
- QDeclarativeComponent component(&engine, testFileUrl("statusText.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedStatus", statusText);
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("unsentException").toBool(), true);
- QCOMPARE(object->property("openedException").toBool(), true);
- QCOMPARE(object->property("sentException").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("resetException").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::statusText_data()
-{
- QTest::addColumn<QUrl>("replyUrl");
- QTest::addColumn<QString>("statusText");
-
- QTest::newRow("OK") << testFileUrl("status.200.reply") << "OK";
- QTest::newRow("Not Found") << testFileUrl("status.404.reply") << "Document not found";
- QTest::newRow("Bad Request") << testFileUrl("status.400.reply") << "Bad request";
-}
-
-void tst_qdeclarativexmlhttprequest::responseText()
-{
- QFETCH(QUrl, replyUrl);
- QFETCH(QUrl, bodyUrl);
- QFETCH(QString, responseText);
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- QVERIFY(server.wait(testFileUrl("status.expect"),
- replyUrl,
- bodyUrl));
-
- QDeclarativeComponent component(&engine, testFileUrl("responseText.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
- object->setProperty("expectedText", responseText);
- component.completeCreate();
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("unsent").toBool(), true);
- QCOMPARE(object->property("opened").toBool(), true);
- QCOMPARE(object->property("sent").toBool(), true);
- QCOMPARE(object->property("headersReceived").toBool(), true);
- QCOMPARE(object->property("loading").toBool(), true);
- QCOMPARE(object->property("done").toBool(), true);
- QCOMPARE(object->property("reset").toBool(), true);
-
- delete object;
-}
-
-void tst_qdeclarativexmlhttprequest::responseText_data()
-{
- QTest::addColumn<QUrl>("replyUrl");
- QTest::addColumn<QUrl>("bodyUrl");
- QTest::addColumn<QString>("responseText");
-
- QTest::newRow("OK") << testFileUrl("status.200.reply") << testFileUrl("testdocument.html") << "QML Rocks!\n";
- QTest::newRow("empty body") << testFileUrl("status.200.reply") << QUrl() << "";
- QTest::newRow("Not Found") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << "";
- QTest::newRow("Bad Request") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << "";
-}
-
-void tst_qdeclarativexmlhttprequest::nonUtf8()
-{
- QFETCH(QString, fileName);
- QFETCH(QString, responseText);
- QFETCH(QString, xmlRootNodeValue);
-
- QDeclarativeComponent component(&engine, testFileUrl("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);
-
- 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
-// throws an exception
-void tst_qdeclarativexmlhttprequest::invalidMethodUsage()
-{
- QDeclarativeComponent component(&engine, testFileUrl("invalidMethodUsage.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QCOMPARE(object->property("readyState").toBool(), true);
- QCOMPARE(object->property("status").toBool(), true);
- QCOMPARE(object->property("statusText").toBool(), true);
- QCOMPARE(object->property("responseText").toBool(), true);
- QCOMPARE(object->property("responseXML").toBool(), true);
-
- QCOMPARE(object->property("open").toBool(), true);
- QCOMPARE(object->property("setRequestHeader").toBool(), true);
- QCOMPARE(object->property("send").toBool(), true);
- QCOMPARE(object->property("abort").toBool(), true);
- QCOMPARE(object->property("getResponseHeader").toBool(), true);
- QCOMPARE(object->property("getAllResponseHeaders").toBool(), true);
-
- delete object;
-}
-
-// Test that XMLHttpRequest transparently redirects
-void tst_qdeclarativexmlhttprequest::redirects()
-{
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirecttarget.html");
- server.serveDirectory(dataDirectory());
-
- QDeclarativeComponent component(&engine, testFileUrl("redirects.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
- object->setProperty("expectedText", "");
- component.completeCreate();
-
- QTRY_VERIFY(object->property("done").toBool() == true);
- QCOMPARE(object->property("dataOK").toBool(), true);
-
- delete object;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirectmissing.html");
- server.serveDirectory(dataDirectory());
-
- QDeclarativeComponent component(&engine, testFileUrl("redirectError.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
- object->setProperty("expectedText", "");
- component.completeCreate();
-
- QTRY_VERIFY(object->property("done").toBool() == true);
- QCOMPARE(object->property("dataOK").toBool(), true);
-
- delete object;
- }
-
- {
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirect.html");
- server.serveDirectory(dataDirectory());
-
- QDeclarativeComponent component(&engine, testFileUrl("redirectRecur.qml"));
- QObject *object = component.beginCreate(engine.rootContext());
- QVERIFY(object != 0);
- object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
- object->setProperty("expectedText", "");
- component.completeCreate();
-
- for (int ii = 0; ii < 60; ++ii) {
- if (object->property("done").toBool()) break;
- QTest::qWait(50);
- }
- QVERIFY(object->property("done").toBool() == true);
-
- QCOMPARE(object->property("dataOK").toBool(), true);
-
- delete object;
- }
-}
-
-void tst_qdeclarativexmlhttprequest::responseXML_invalid()
-{
- QDeclarativeComponent component(&engine, testFileUrl("responseXML_invalid.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlNull").toBool(), true);
-
- delete object;
-}
-
-// Test the Document DOM element
-void tst_qdeclarativexmlhttprequest::document()
-{
- QDeclarativeComponent component(&engine, testFileUrl("document.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-// Test the Element DOM element
-void tst_qdeclarativexmlhttprequest::element()
-{
- QDeclarativeComponent component(&engine, testFileUrl("element.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-// Test the Attr DOM element
-void tst_qdeclarativexmlhttprequest::attr()
-{
- QDeclarativeComponent component(&engine, testFileUrl("attr.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-// Test the Text DOM element
-void tst_qdeclarativexmlhttprequest::text()
-{
- QDeclarativeComponent component(&engine, testFileUrl("text.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-// Test the CDataSection DOM element
-void tst_qdeclarativexmlhttprequest::cdata()
-{
- QDeclarativeComponent component(&engine, testFileUrl("cdata.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QTRY_VERIFY(object->property("dataOK").toBool() == true);
-
- QCOMPARE(object->property("xmlTest").toBool(), true);
-
- delete object;
-}
-
-QTEST_MAIN(tst_qdeclarativexmlhttprequest)
-
-#include "tst_qdeclarativexmlhttprequest.moc"
diff --git a/tests/auto/declarative/qjsengine/qjsengine.pro b/tests/auto/declarative/qjsengine/qjsengine.pro
deleted file mode 100644
index dd6234acd8..0000000000
--- a/tests/auto/declarative/qjsengine/qjsengine.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qjsengine
-QT += declarative widgets testlib
-macx:CONFIG -= app_bundle
-SOURCES += tst_qjsengine.cpp
-wince* {
- addFiles.files = script
- addFiles.path = .
- DEPLOYMENT += addFiles
- DEFINES += SRCDIR=\\\"./\\\"
-} else {
- DEFINES += SRCDIR=\\\"$$PWD\\\"
-}
diff --git a/tests/auto/declarative/qjsvalue/qjsvalue.pro b/tests/auto/declarative/qjsvalue/qjsvalue.pro
deleted file mode 100644
index 3b40e92e67..0000000000
--- a/tests/auto/declarative/qjsvalue/qjsvalue.pro
+++ /dev/null
@@ -1,6 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qjsvalue
-macx:CONFIG -= app_bundle
-QT += declarative widgets testlib
-SOURCES += tst_qjsvalue.cpp
-HEADERS += tst_qjsvalue.h
diff --git a/tests/auto/declarative/qjsvalueiterator/qjsvalueiterator.pro b/tests/auto/declarative/qjsvalueiterator/qjsvalueiterator.pro
deleted file mode 100644
index 9f991c0ab6..0000000000
--- a/tests/auto/declarative/qjsvalueiterator/qjsvalueiterator.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qjsvalueiterator
-macx:CONFIG -= app_bundle
-QT = core declarative testlib
-SOURCES += tst_qjsvalueiterator.cpp
-
-
diff --git a/tests/auto/declarative/qmlmin/qmlmin.pro b/tests/auto/declarative/qmlmin/qmlmin.pro
deleted file mode 100644
index 61d2330b06..0000000000
--- a/tests/auto/declarative/qmlmin/qmlmin.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qmlmin
-QT += declarative testlib
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qmlmin.cpp
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
diff --git a/tests/auto/declarative/qmlmin/tst_qmlmin.cpp b/tests/auto/declarative/qmlmin/tst_qmlmin.cpp
deleted file mode 100644
index c6b019071e..0000000000
--- a/tests/auto/declarative/qmlmin/tst_qmlmin.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QLibraryInfo>
-#include <QDir>
-#include <QProcess>
-#include <QDebug>
-#include <QDeclarativeError>
-#include <cstdlib>
-
-class tst_qmlmin : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlmin();
-
-private slots:
- void initTestCase();
- void qmlMinify_data();
- void qmlMinify();
-
-private:
- QString qmlminPath;
- QStringList excludedDirs;
- QStringList invalidFiles;
-
- QStringList findFiles(const QDir &);
- bool isInvalidFile(const QFileInfo &fileName) const;
-};
-
-tst_qmlmin::tst_qmlmin()
-{
-}
-
-void tst_qmlmin::initTestCase()
-{
- qmlminPath = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/qmlmin");
-#ifdef Q_OS_WIN
- qmlminPath += QLatin1String(".exe");
-#endif
- if (!QFileInfo(qmlminPath).exists()) {
- QString message = QString::fromLatin1("qmlmin executable not found (looked for %0)")
- .arg(qmlminPath);
- QFAIL(qPrintable(message));
- }
-
- // Add directories you want excluded here
-
- // These snippets are not expected to run on their own.
- excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex";
- excludedDirs << "doc/src/snippets/declarative/qtbinding";
- excludedDirs << "doc/src/snippets/declarative/imports";
- excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex";
- excludedDirs << "doc/src/snippets/qtquick1/qtbinding";
- excludedDirs << "doc/src/snippets/qtquick1/imports";
-
- // Add invalid files (i.e. files with syntax errors)
- invalidFiles << "tests/auto/qtquick2/qquickloader/data/InvalidSourceComponent.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/property.4.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/empty.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml";
- invalidFiles << "tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.js";
- invalidFiles << "tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.js";
- invalidFiles << "tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onLoad.js";
- invalidFiles << "tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js";
-}
-
-QStringList tst_qmlmin::findFiles(const QDir &d)
-{
- for (int ii = 0; ii < excludedDirs.count(); ++ii) {
- QString s = excludedDirs.at(ii);
- if (d.absolutePath().endsWith(s))
- return QStringList();
- }
-
- QStringList rv;
-
- QStringList files = d.entryList(QStringList() << QLatin1String("*.qml") << QLatin1String("*.js"),
- QDir::Files);
- foreach (const QString &file, files) {
- rv << d.absoluteFilePath(file);
- }
-
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
- QDir::NoSymLinks);
- foreach (const QString &dir, dirs) {
- QDir sub = d;
- sub.cd(dir);
- rv << findFiles(sub);
- }
-
- return rv;
-}
-
-bool tst_qmlmin::isInvalidFile(const QFileInfo &fileName) const
-{
- foreach (const QString &invalidFile, invalidFiles) {
- if (fileName.absoluteFilePath().endsWith(invalidFile))
- return true;
- }
- return false;
-}
-
-/*
-This test runs all the examples in the declarative UI source tree and ensures
-that they start and exit cleanly.
-
-Examples are any .qml files under the examples/ directory that start
-with a lower case letter.
-*/
-
-void tst_qmlmin::qmlMinify_data()
-{
- QTest::addColumn<QString>("file");
-
- QString examples = QLatin1String(SRCDIR) + "/../../../../examples/";
- QString tests = QLatin1String(SRCDIR) + "/../../../../tests/";
-
- QStringList files;
- files << findFiles(QDir(examples));
- files << findFiles(QDir(tests));
-
- foreach (const QString &file, files)
- QTest::newRow(qPrintable(file)) << file;
-}
-
-void tst_qmlmin::qmlMinify()
-{
- QFETCH(QString, file);
-
- QProcess qmlminify;
- qmlminify.start(qmlminPath, QStringList() << QLatin1String("--verify-only") << file);
- qmlminify.waitForFinished();
-
- QCOMPARE(qmlminify.error(), QProcess::UnknownError);
- QCOMPARE(qmlminify.exitStatus(), QProcess::NormalExit);
-
- if (isInvalidFile(file))
- QCOMPARE(qmlminify.exitCode(), EXIT_FAILURE); // cannot minify files with syntax errors
- else
- QCOMPARE(qmlminify.exitCode(), 0);
-}
-
-QTEST_MAIN(tst_qmlmin)
-
-#include "tst_qmlmin.moc"
diff --git a/tests/auto/declarative/runall.sh b/tests/auto/declarative/runall.sh
deleted file mode 100755
index 621791b6ab..0000000000
--- a/tests/auto/declarative/runall.sh
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/bin/bash
-#
-#############################################################################
-##
-## Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-## Contact: http://www.qt-project.org/
-##
-## This file is part of the test suite of the Qt Toolkit.
-##
-## $QT_BEGIN_LICENSE:LGPL$
-## GNU Lesser General Public License Usage
-## 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.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU General
-## Public License version 3.0 as published by the Free Software Foundation
-## and appearing in the file LICENSE.GPL included in the packaging of this
-## file. Please review the following information to ensure the GNU General
-## Public License version 3.0 requirements will be met:
-## http://www.gnu.org/copyleft/gpl.html.
-##
-## Other Usage
-## Alternatively, this file may be used in accordance with the terms and
-## conditions contained in a signed written agreement between you and Nokia.
-##
-##
-##
-##
-##
-##
-## $QT_END_LICENSE$
-##
-############################################################################/
-
-if [ "$(uname)" = Linux ]
-then
- Xnest :7 2>/dev/null &
- sleep 1
- trap "kill $!" EXIT
- export DISPLAY=:7
- export LANG=en_US
- kwin 2>/dev/null &
- sleep 1
-fi
-
-function filter
-{
- exe=$1
- skip=0
- while read line
- do
- if [ $skip != 0 ]
- then
- let skip=skip-1
- else
- case "$line" in
- make*Error) echo "$line";;
- make*Stop) echo "$line";;
- /*/bin/make*) ;;
- make*) ;;
- install*) ;;
- QDeclarativeDebugServer:*Waiting*) ;;
- QDeclarativeDebugServer:*Connection*) ;;
- */qmake*) ;;
- */bin/moc*) ;;
- *targ.debug*) ;;
- g++*) ;;
- cd*) ;;
- XFAIL*) skip=1;;
- SKIP*) skip=1;;
- PASS*) ;;
- QDEBUG*) ;;
- Makefile*) ;;
- Config*) ;;
- Totals*) ;;
- \**) ;;
- ./*) ;;
- *tst_*) echo "$line" ;;
- *) echo "$exe: $line"
- esac
- fi
- done
-}
-
-make -k -j1 install 2>&1 | filter build
-for exe in $(make install | sed -n 's/^install .* "\([^"]*qt4\/tst_[^"]*\)".*/\1/p')
-do
- echo $exe
- $exe 2>&1 | filter $exe
-done
-
diff --git a/tests/auto/declarative/v4/testtypes.cpp b/tests/auto/declarative/v4/testtypes.cpp
deleted file mode 100644
index 6bfd5dc43e..0000000000
--- a/tests/auto/declarative/v4/testtypes.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "testtypes.h"
-
-#include <QtDeclarative/qdeclarative.h>
-
-void registerTypes()
-{
- qmlRegisterType<ResultObject>("Qt.v4", 1,0, "Result");
- qmlRegisterType<NestedObject>();
-}
diff --git a/tests/auto/declarative/v4/tst_v4.cpp b/tests/auto/declarative/v4/tst_v4.cpp
deleted file mode 100644
index 927dc0f082..0000000000
--- a/tests/auto/declarative/v4/tst_v4.cpp
+++ /dev/null
@@ -1,353 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtCore/qobject.h>
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qdir.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtCore/qdebug.h>
-
-#include <private/qv4compiler_p.h>
-
-#include "../../shared/util.h"
-#include "testtypes.h"
-
-class tst_v4 : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_v4() {}
-
-private slots:
- void initTestCase();
-
- void unnecessaryReeval();
- void logicalOr();
- void nestedLogicalOr();
- void conditionalExpr();
- void qtscript();
- void qtscript_data();
- void nestedObjectAccess();
- void subscriptionsInConditionalExpressions();
- void qtbug_21883();
- void qtbug_22816();
- void stringComparison();
- void unaryMinus();
- void unaryPlus();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_v4::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- registerTypes();
-}
-
-static int v4ErrorsMsgCount = 0;
-static void v4ErrorsMsgHandler(QtMsgType, const char *message)
-{
- QByteArray m(message);
- if (m.contains("QV4"))
- v4ErrorsMsgCount++;
-}
-
-void tst_v4::qtscript()
-{
- QFETCH(QString, file);
- QV4Compiler::enableBindingsTest(true);
-
- QDeclarativeComponent component(&engine, testFileUrl(file));
-
- v4ErrorsMsgCount = 0;
- QtMsgHandler old = qInstallMsgHandler(v4ErrorsMsgHandler);
-
- QObject *o = component.create();
- delete o;
-
- qInstallMsgHandler(old);
-
- QCOMPARE(v4ErrorsMsgCount, 0);
-
- QV4Compiler::enableBindingsTest(false);
-}
-
-void tst_v4::qtscript_data()
-{
- QTest::addColumn<QString>("file");
-
- QTest::newRow("qreal -> int rounding") << "qrealToIntRounding.qml";
- QTest::newRow("exception on fetch") << "fetchException.qml";
- QTest::newRow("logical or") << "logicalOr.qml";
- QTest::newRow("conditional expressions") << "conditionalExpr.qml";
- QTest::newRow("double bool jump") << "doubleBoolJump.qml";
- QTest::newRow("unary minus") << "unaryMinus.qml";
- QTest::newRow("null qobject") << "nullQObject.qml";
-}
-
-void tst_v4::unnecessaryReeval()
-{
- QDeclarativeComponent component(&engine, testFileUrl("unnecessaryReeval.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- ResultObject *ro = qobject_cast<ResultObject *>(o);
- QVERIFY(ro != 0);
-
- QCOMPARE(ro->resultCounter(), 1);
- QCOMPARE(ro->result(), 19);
- ro->resetResultCounter();
-
- ro->setProperty("b", 6);
-
- QCOMPARE(ro->resultCounter(), 1);
- QCOMPARE(ro->result(), 6);
- ro->resetResultCounter();
-
- ro->setProperty("a", 14);
-
- QCOMPARE(ro->resultCounter(), 1);
- QCOMPARE(ro->result(), 7);
- ro->resetResultCounter();
-
- ro->setProperty("b", 14);
- QCOMPARE(ro->resultCounter(), 0);
- QCOMPARE(ro->result(), 7);
-
- delete o;
-}
-
-void tst_v4::logicalOr()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("logicalOr.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- ResultObject *ro = qobject_cast<ResultObject *>(o);
- QVERIFY(ro != 0);
-
- QCOMPARE(ro->result(), 0);
- delete o;
- }
-
- {
- QDeclarativeComponent component(&engine, testFileUrl("logicalOr.2.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- ResultObject *ro = qobject_cast<ResultObject *>(o);
- QVERIFY(ro != 0);
-
- QCOMPARE(ro->result(), 1);
- delete o;
- }
-}
-
-void tst_v4::nestedLogicalOr()
-{
- //we are primarily testing that v4 does not get caught in a loop (QTBUG-24038)
- QDeclarativeComponent component(&engine, testFileUrl("nestedLogicalOr.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- ResultObject *ro = qobject_cast<ResultObject *>(o);
- QVERIFY(ro != 0);
-
- QCOMPARE(ro->result(), 1);
- delete o;
-}
-
-void tst_v4::conditionalExpr()
-{
- {
- QDeclarativeComponent component(&engine, testFileUrl("conditionalExpr.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- ResultObject *ro = qobject_cast<ResultObject *>(o);
- QVERIFY(ro != 0);
-
- QCOMPARE(ro->result(), 0);
- delete o;
- }
-}
-
-// This would previously use the metaObject of the root element to result the nested access.
-// That is, the index for accessing "result" would have been RootObject::result, instead of
-// NestedObject::result.
-void tst_v4::nestedObjectAccess()
-{
- QDeclarativeComponent component(&engine, testFileUrl("nestedObjectAccess.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- ResultObject *ro = qobject_cast<ResultObject *>(o);
- QVERIFY(ro != 0);
-
- QCOMPARE(ro->result(), 37);
-
- delete o;
-}
-
-void tst_v4::subscriptionsInConditionalExpressions()
-{
- QDeclarativeComponent component(&engine, testFileUrl("subscriptionsInConditionalExpressions.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QObject *ro = qobject_cast<QObject *>(o);
- QVERIFY(ro != 0);
-
- QCOMPARE(ro->property("result").toReal(), qreal(2));
-
- delete o;
-}
-
-// Crash test
-void tst_v4::qtbug_21883()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_21883.qml"));
-
- QString warning = component.url().toString() + ":4: Unable to assign null to ResultObject*";
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
-
- QObject *o = component.create();
- QVERIFY(o != 0);
- delete o;
-}
-
-void tst_v4::qtbug_22816()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_22816.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test1").toBool(), false);
- QCOMPARE(o->property("test2").toBool(), false);
- delete o;
-}
-
-void tst_v4::stringComparison()
-{
- QDeclarativeComponent component(&engine, testFileUrl("stringComparison.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test4").toBool(), true);
- QCOMPARE(o->property("test5").toBool(), true);
- QCOMPARE(o->property("test6").toBool(), true);
- QCOMPARE(o->property("test7").toBool(), true);
- QCOMPARE(o->property("test8").toBool(), true);
- QCOMPARE(o->property("test9").toBool(), true);
- QCOMPARE(o->property("test10").toBool(), true);
- QCOMPARE(o->property("test11").toBool(), true);
- QCOMPARE(o->property("test12").toBool(), true);
- QCOMPARE(o->property("test13").toBool(), true);
- QCOMPARE(o->property("test14").toBool(), true);
- QCOMPARE(o->property("test15").toBool(), true);
- QCOMPARE(o->property("test16").toBool(), true);
- QCOMPARE(o->property("test17").toBool(), true);
- QCOMPARE(o->property("test18").toBool(), true);
- QCOMPARE(o->property("test19").toBool(), true);
- QCOMPARE(o->property("test20").toBool(), true);
- QCOMPARE(o->property("test21").toBool(), true);
- QCOMPARE(o->property("test22").toBool(), true);
- delete o;
-}
-
-void tst_v4::unaryMinus()
-{
- QDeclarativeComponent component(&engine, testFileUrl("unaryMinus.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toReal(), qreal(-18));
- QCOMPARE(o->property("test2").toInt(), -18);
- QCOMPARE(o->property("test3").toReal(), qreal(3.7));
- QCOMPARE(o->property("test4").toInt(), 4);
- QCOMPARE(o->property("test5").toReal(), qreal(3.3));
- QCOMPARE(o->property("test6").toInt(), 3);
- QCOMPARE(o->property("test7").toReal(), qreal(7));
- QCOMPARE(o->property("test8").toInt(), 7);
- QCOMPARE(o->property("test9").toReal(), qreal(-4.4));
- QCOMPARE(o->property("test10").toInt(), -4);
-
- delete o;
-}
-
-void tst_v4::unaryPlus()
-{
- QDeclarativeComponent component(&engine, testFileUrl("unaryPlus.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toReal(), qreal(18));
- QCOMPARE(o->property("test2").toInt(), 18);
- QCOMPARE(o->property("test3").toReal(), qreal(-3.7));
- QCOMPARE(o->property("test4").toInt(), -4);
- QCOMPARE(o->property("test5").toReal(), qreal(-3.3));
- QCOMPARE(o->property("test6").toInt(), -3);
- QCOMPARE(o->property("test7").toReal(), qreal(-7));
- QCOMPARE(o->property("test8").toInt(), -7);
- QCOMPARE(o->property("test9").toReal(), qreal(4.4));
- QCOMPARE(o->property("test10").toInt(), 4);
-
- delete o;
-}
-
-QTEST_MAIN(tst_v4)
-
-#include "tst_v4.moc"
diff --git a/tests/auto/declarative/v4/v4.pro b/tests/auto/declarative/v4/v4.pro
deleted file mode 100644
index 81d12f89be..0000000000
--- a/tests/auto/declarative/v4/v4.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativev4
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_v4.cpp \
- testtypes.cpp
-HEADERS += testtypes.h
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private network testlib
diff --git a/tests/auto/headersclean/headersclean.pro b/tests/auto/headersclean/headersclean.pro
index 16802b7e06..4ce05fe512 100644
--- a/tests/auto/headersclean/headersclean.pro
+++ b/tests/auto/headersclean/headersclean.pro
@@ -3,4 +3,4 @@ TARGET = tst_headersclean
SOURCES += tst_headersclean.cpp
QT = core testlib
-contains(QT_CONFIG,declarative): QT += declarative declarative-private
+contains(QT_CONFIG,qml): QT += qml qml-private
diff --git a/tests/auto/headersclean/tst_headersclean.cpp b/tests/auto/headersclean/tst_headersclean.cpp
index 132eb90231..d5131f96cd 100644
--- a/tests/auto/headersclean/tst_headersclean.cpp
+++ b/tests/auto/headersclean/tst_headersclean.cpp
@@ -49,7 +49,7 @@
#include <QtCore/QtCore>
#include <QtTest/QtTest>
-#include <QtDeclarative/QtDeclarative>
+#include <QtQml/QtQml>
class tst_HeadersClean: public QObject
{
diff --git a/tests/auto/particles/qquickage/qquickage.pro b/tests/auto/particles/qquickage/qquickage.pro
index 99c52dfdae..6616ec45ee 100644
--- a/tests/auto/particles/qquickage/qquickage.pro
+++ b/tests/auto/particles/qquickage/qquickage.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickangleddirection/qquickangleddirection.pro b/tests/auto/particles/qquickangleddirection/qquickangleddirection.pro
index 235f0d81b0..ac37973695 100644
--- a/tests/auto/particles/qquickangleddirection/qquickangleddirection.pro
+++ b/tests/auto/particles/qquickangleddirection/qquickangleddirection.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro b/tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro
index 09fe1aa06a..42029ce721 100644
--- a/tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro
+++ b/tests/auto/particles/qquickcumulativedirection/qquickcumulativedirection.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro b/tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro
index 6d3ecaa6f4..fdc2445bd1 100644
--- a/tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro
+++ b/tests/auto/particles/qquickcustomaffector/qquickcustomaffector.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro b/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro
index e9bcc1e373..a12c1af62c 100644
--- a/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro
+++ b/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro b/tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro
index 803a366429..48d01201ce 100644
--- a/tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro
+++ b/tests/auto/particles/qquickellipseextruder/qquickellipseextruder.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickfriction/qquickfriction.pro b/tests/auto/particles/qquickfriction/qquickfriction.pro
index 889b2d9505..85b5263d36 100644
--- a/tests/auto/particles/qquickfriction/qquickfriction.pro
+++ b/tests/auto/particles/qquickfriction/qquickfriction.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickgravity/qquickgravity.pro b/tests/auto/particles/qquickgravity/qquickgravity.pro
index 3bdd8c1efa..5340b32cab 100644
--- a/tests/auto/particles/qquickgravity/qquickgravity.pro
+++ b/tests/auto/particles/qquickgravity/qquickgravity.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro b/tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro
index 8e7d5ae021..623993c2de 100644
--- a/tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro
+++ b/tests/auto/particles/qquickgroupgoal/qquickgroupgoal.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private opengl-private testlib
diff --git a/tests/auto/particles/qquickimageparticle/qquickimageparticle.pro b/tests/auto/particles/qquickimageparticle/qquickimageparticle.pro
index fa43b28407..1241467ba1 100644
--- a/tests/auto/particles/qquickimageparticle/qquickimageparticle.pro
+++ b/tests/auto/particles/qquickimageparticle/qquickimageparticle.pro
@@ -7,4 +7,4 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickitemparticle/qquickitemparticle.pro b/tests/auto/particles/qquickitemparticle/qquickitemparticle.pro
index c36dabbc14..262ebdd5b2 100644
--- a/tests/auto/particles/qquickitemparticle/qquickitemparticle.pro
+++ b/tests/auto/particles/qquickitemparticle/qquickitemparticle.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquicklineextruder/qquicklineextruder.pro b/tests/auto/particles/qquicklineextruder/qquicklineextruder.pro
index fae5203961..3b87f00320 100644
--- a/tests/auto/particles/qquicklineextruder/qquicklineextruder.pro
+++ b/tests/auto/particles/qquicklineextruder/qquicklineextruder.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro b/tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro
index d82adf8b4a..33d6f2e41e 100644
--- a/tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro
+++ b/tests/auto/particles/qquickmaskextruder/qquickmaskextruder.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro b/tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro
index 27547c16b1..594b704bd5 100644
--- a/tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro
+++ b/tests/auto/particles/qquickparticlegroup/qquickparticlegroup.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro b/tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro
index 6fd13ec01e..ea5642aaa9 100644
--- a/tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro
+++ b/tests/auto/particles/qquickparticlesystem/qquickparticlesystem.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickpointattractor/qquickpointattractor.pro b/tests/auto/particles/qquickpointattractor/qquickpointattractor.pro
index a9d390aab8..4a93555f5c 100644
--- a/tests/auto/particles/qquickpointattractor/qquickpointattractor.pro
+++ b/tests/auto/particles/qquickpointattractor/qquickpointattractor.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickpointdirection/qquickpointdirection.pro b/tests/auto/particles/qquickpointdirection/qquickpointdirection.pro
index 04fe1617de..093e7a743f 100644
--- a/tests/auto/particles/qquickpointdirection/qquickpointdirection.pro
+++ b/tests/auto/particles/qquickpointdirection/qquickpointdirection.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro b/tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro
index e45c43a587..1b5da6165c 100644
--- a/tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro
+++ b/tests/auto/particles/qquickrectangleextruder/qquickrectangleextruder.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickspritegoal/qquickspritegoal.pro b/tests/auto/particles/qquickspritegoal/qquickspritegoal.pro
index d335a91537..9908f220d2 100644
--- a/tests/auto/particles/qquickspritegoal/qquickspritegoal.pro
+++ b/tests/auto/particles/qquickspritegoal/qquickspritegoal.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private opengl-private testlib
diff --git a/tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro b/tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro
index 0a887d1fb3..226cd9d139 100644
--- a/tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro
+++ b/tests/auto/particles/qquicktargetdirection/qquicktargetdirection.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro b/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro
index 9139dd39fb..67b14c86c3 100644
--- a/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro
+++ b/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickturbulence/qquickturbulence.pro b/tests/auto/particles/qquickturbulence/qquickturbulence.pro
index 16d85445f5..d8de625b9c 100644
--- a/tests/auto/particles/qquickturbulence/qquickturbulence.pro
+++ b/tests/auto/particles/qquickturbulence/qquickturbulence.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/particles/qquickwander/qquickwander.pro b/tests/auto/particles/qquickwander/qquickwander.pro
index a9c48ece78..ceb1d9f2c2 100644
--- a/tests/auto/particles/qquickwander/qquickwander.pro
+++ b/tests/auto/particles/qquickwander/qquickwander.pro
@@ -7,5 +7,5 @@ testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/declarative/animation/animation.pro b/tests/auto/qml/animation/animation.pro
index a9c0cee309..a9c0cee309 100644
--- a/tests/auto/declarative/animation/animation.pro
+++ b/tests/auto/qml/animation/animation.pro
diff --git a/tests/auto/qml/animation/qabstractanimationjob/qabstractanimationjob.pro b/tests/auto/qml/animation/qabstractanimationjob/qabstractanimationjob.pro
new file mode 100644
index 0000000000..6d3a05e923
--- /dev/null
+++ b/tests/auto/qml/animation/qabstractanimationjob/qabstractanimationjob.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase parallel_test
+macx:CONFIG -= app_bundle
+TARGET = tst_qabstractanimationjob
+QT = core-private qml-private testlib
+SOURCES = tst_qabstractanimationjob.cpp
diff --git a/tests/auto/qml/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp b/tests/auto/qml/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp
new file mode 100644
index 0000000000..ea347ab2bd
--- /dev/null
+++ b/tests/auto/qml/animation/qabstractanimationjob/tst_qabstractanimationjob.cpp
@@ -0,0 +1,229 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtQml/private/qabstractanimationjob_p.h>
+#include <QtQml/private/qanimationgroupjob_p.h>
+#include <QtTest>
+
+class tst_QAbstractAnimationJob : public QObject
+{
+ Q_OBJECT
+private slots:
+ void construction();
+ void destruction();
+ void currentLoop();
+ void currentLoopTime();
+ void currentTime();
+ void direction();
+ void group();
+ void loopCount();
+ void state();
+ void totalDuration();
+ void avoidJumpAtStart();
+ void avoidJumpAtStartWithStop();
+ void avoidJumpAtStartWithRunning();
+};
+
+class TestableQAbstractAnimation : public QAbstractAnimationJob
+{
+public:
+ TestableQAbstractAnimation() : m_duration(10) {}
+ virtual ~TestableQAbstractAnimation() {};
+
+ int duration() const { return m_duration; }
+ virtual void updateCurrentTime(int) {}
+
+ void setDuration(int duration) { m_duration = duration; }
+private:
+ int m_duration;
+};
+
+class DummyQAnimationGroup : public QAnimationGroupJob
+{
+public:
+ int duration() const { return 10; }
+ virtual void updateCurrentTime(int) {}
+};
+
+void tst_QAbstractAnimationJob::construction()
+{
+ TestableQAbstractAnimation anim;
+}
+
+void tst_QAbstractAnimationJob::destruction()
+{
+ TestableQAbstractAnimation *anim = new TestableQAbstractAnimation;
+ delete anim;
+}
+
+void tst_QAbstractAnimationJob::currentLoop()
+{
+ TestableQAbstractAnimation anim;
+ QCOMPARE(anim.currentLoop(), 0);
+}
+
+void tst_QAbstractAnimationJob::currentLoopTime()
+{
+ TestableQAbstractAnimation anim;
+ QCOMPARE(anim.currentLoopTime(), 0);
+}
+
+void tst_QAbstractAnimationJob::currentTime()
+{
+ TestableQAbstractAnimation anim;
+ QCOMPARE(anim.currentTime(), 0);
+ anim.setCurrentTime(10);
+ QCOMPARE(anim.currentTime(), 10);
+}
+
+void tst_QAbstractAnimationJob::direction()
+{
+ TestableQAbstractAnimation anim;
+ QCOMPARE(anim.direction(), QAbstractAnimationJob::Forward);
+ anim.setDirection(QAbstractAnimationJob::Backward);
+ QCOMPARE(anim.direction(), QAbstractAnimationJob::Backward);
+ anim.setDirection(QAbstractAnimationJob::Forward);
+ QCOMPARE(anim.direction(), QAbstractAnimationJob::Forward);
+}
+
+void tst_QAbstractAnimationJob::group()
+{
+ TestableQAbstractAnimation *anim = new TestableQAbstractAnimation;
+ DummyQAnimationGroup group;
+ group.appendAnimation(anim);
+ QCOMPARE(anim->group(), &group);
+}
+
+void tst_QAbstractAnimationJob::loopCount()
+{
+ TestableQAbstractAnimation anim;
+ QCOMPARE(anim.loopCount(), 1);
+ anim.setLoopCount(10);
+ QCOMPARE(anim.loopCount(), 10);
+}
+
+void tst_QAbstractAnimationJob::state()
+{
+ TestableQAbstractAnimation anim;
+ QCOMPARE(anim.state(), QAbstractAnimationJob::Stopped);
+}
+
+void tst_QAbstractAnimationJob::totalDuration()
+{
+ TestableQAbstractAnimation anim;
+ QCOMPARE(anim.duration(), 10);
+ anim.setLoopCount(5);
+ QCOMPARE(anim.totalDuration(), 50);
+}
+
+void tst_QAbstractAnimationJob::avoidJumpAtStart()
+{
+ TestableQAbstractAnimation anim;
+ anim.setDuration(1000);
+
+ /*
+ the timer shouldn't actually start until we hit the event loop,
+ so the sleep should have no effect
+ */
+ anim.start();
+ QTest::qSleep(300);
+ QCoreApplication::processEvents();
+ QVERIFY(anim.currentTime() < 50);
+}
+
+void tst_QAbstractAnimationJob::avoidJumpAtStartWithStop()
+{
+ TestableQAbstractAnimation anim;
+ anim.setDuration(1000);
+
+ TestableQAbstractAnimation anim2;
+ anim2.setDuration(1000);
+
+ TestableQAbstractAnimation anim3;
+ anim3.setDuration(1000);
+
+ anim.start();
+ QTest::qWait(300);
+ anim.stop();
+
+ /*
+ same test as avoidJumpAtStart, but after there is a
+ running animation that is stopped
+ */
+ anim2.start();
+ QTest::qSleep(300);
+ anim3.start();
+ QCoreApplication::processEvents();
+ QVERIFY(anim2.currentTime() < 50);
+ QVERIFY(anim3.currentTime() < 50);
+}
+
+void tst_QAbstractAnimationJob::avoidJumpAtStartWithRunning()
+{
+ TestableQAbstractAnimation anim;
+ anim.setDuration(2000);
+
+ TestableQAbstractAnimation anim2;
+ anim2.setDuration(1000);
+
+ TestableQAbstractAnimation anim3;
+ anim3.setDuration(1000);
+
+ anim.start();
+ QTest::qWait(300); //make sure timer has started
+
+ /*
+ same test as avoidJumpAtStart, but with an
+ existing running animation
+ */
+ anim2.start();
+ QTest::qSleep(300); //force large delta for next tick
+ anim3.start();
+ QCoreApplication::processEvents();
+ QVERIFY(anim2.currentTime() < 50);
+ QVERIFY(anim3.currentTime() < 50);
+}
+
+
+QTEST_MAIN(tst_QAbstractAnimationJob)
+
+#include "tst_qabstractanimationjob.moc"
diff --git a/tests/auto/qml/animation/qanimationgroupjob/qanimationgroupjob.pro b/tests/auto/qml/animation/qanimationgroupjob/qanimationgroupjob.pro
new file mode 100644
index 0000000000..96081d0116
--- /dev/null
+++ b/tests/auto/qml/animation/qanimationgroupjob/qanimationgroupjob.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase parallel_test
+macx:CONFIG -= app_bundle
+TARGET = tst_qanimationgroupjob
+QT = core-private qml-private testlib
+SOURCES = tst_qanimationgroupjob.cpp
diff --git a/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp b/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp
new file mode 100644
index 0000000000..f3fd3b4cfb
--- /dev/null
+++ b/tests/auto/qml/animation/qanimationgroupjob/tst_qanimationgroupjob.cpp
@@ -0,0 +1,310 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QtQml/private/qanimationgroupjob_p.h>
+#include <QtQml/private/qsequentialanimationgroupjob_p.h>
+#include <QtQml/private/qparallelanimationgroupjob_p.h>
+
+Q_DECLARE_METATYPE(QAbstractAnimationJob::State)
+
+class tst_QAnimationGroupJob : public QObject
+{
+ Q_OBJECT
+public Q_SLOTS:
+ void initTestCase();
+
+private slots:
+ void construction();
+ void emptyGroup();
+ void setCurrentTime();
+ void addChildTwice();
+};
+
+void tst_QAnimationGroupJob::initTestCase()
+{
+ qRegisterMetaType<QAbstractAnimationJob::State>("QAbstractAnimationJob::State");
+}
+
+void tst_QAnimationGroupJob::construction()
+{
+ QSequentialAnimationGroupJob animationgroup;
+}
+
+class TestableGenericAnimation : public QAbstractAnimationJob
+{
+public:
+ TestableGenericAnimation(int duration = 250) : m_duration(duration) {}
+ int duration() const { return m_duration; }
+
+private:
+ int m_duration;
+};
+
+class UncontrolledAnimation : public QObject, public QAbstractAnimationJob
+{
+ Q_OBJECT
+public:
+ UncontrolledAnimation()
+ : id(0)
+ {
+ }
+
+ int duration() const { return -1; /* not time driven */ }
+
+protected:
+ void timerEvent(QTimerEvent *event)
+ {
+ if (event->timerId() == id)
+ stop();
+ }
+
+ void updateRunning(bool running)
+ {
+ if (running) {
+ id = startTimer(500);
+ } else {
+ killTimer(id);
+ id = 0;
+ }
+ }
+
+private:
+ int id;
+};
+
+class StateChangeListener: public QAnimationJobChangeListener
+{
+public:
+ virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State)
+ {
+ states << newState;
+ }
+
+ int count()
+ {
+ return states.count();
+ }
+
+ QList<QAbstractAnimationJob::State> states;
+};
+
+void tst_QAnimationGroupJob::emptyGroup()
+{
+ QSequentialAnimationGroupJob group;
+ StateChangeListener groupStateChangedSpy;
+ group.addAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ group.start();
+
+ QCOMPARE(groupStateChangedSpy.count(), 2);
+
+ QCOMPARE(groupStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(groupStateChangedSpy.states.at(1), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+
+ QTest::ignoreMessage(QtWarningMsg, "QAbstractAnimationJob::pause: Cannot pause a stopped animation");
+ group.pause();
+
+ QCOMPARE(groupStateChangedSpy.count(), 2);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+
+ group.start();
+
+ QCOMPARE(groupStateChangedSpy.states.at(2),
+ QAnimationGroupJob::Running);
+ QCOMPARE(groupStateChangedSpy.states.at(3),
+ QAnimationGroupJob::Stopped);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+
+ group.stop();
+
+ QCOMPARE(groupStateChangedSpy.count(), 4);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+}
+
+void tst_QAnimationGroupJob::setCurrentTime()
+{
+ // was originally sequence operating on same object/property
+ QSequentialAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
+ QAbstractAnimationJob *a1_s_o1 = new TestableGenericAnimation;
+ QAbstractAnimationJob *a2_s_o1 = new TestableGenericAnimation;
+ QAbstractAnimationJob *a3_s_o1 = new TestableGenericAnimation;
+ a2_s_o1->setLoopCount(3);
+ sequence->appendAnimation(a1_s_o1);
+ sequence->appendAnimation(a2_s_o1);
+ sequence->appendAnimation(a3_s_o1);
+
+ // was originally sequence operating on different object/properties
+ QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob();
+ QAbstractAnimationJob *a1_s_o2 = new TestableGenericAnimation;
+ QAbstractAnimationJob *a1_s_o3 = new TestableGenericAnimation;
+ sequence2->appendAnimation(a1_s_o2);
+ sequence2->appendAnimation(a1_s_o3);
+
+ // was originally parallel operating on different object/properties
+ QAnimationGroupJob *parallel = new QParallelAnimationGroupJob();
+ QAbstractAnimationJob *a1_p_o1 = new TestableGenericAnimation;
+ QAbstractAnimationJob *a1_p_o2 = new TestableGenericAnimation;
+ QAbstractAnimationJob *a1_p_o3 = new TestableGenericAnimation;
+ a1_p_o2->setLoopCount(3);
+ parallel->appendAnimation(a1_p_o1);
+ parallel->appendAnimation(a1_p_o2);
+ parallel->appendAnimation(a1_p_o3);
+
+ QAbstractAnimationJob *notTimeDriven = new UncontrolledAnimation;
+ QCOMPARE(notTimeDriven->totalDuration(), -1);
+
+ QAbstractAnimationJob *loopsForever = new TestableGenericAnimation;
+ loopsForever->setLoopCount(-1);
+ QCOMPARE(loopsForever->totalDuration(), -1);
+
+ QParallelAnimationGroupJob group;
+ group.appendAnimation(sequence);
+ group.appendAnimation(sequence2);
+ group.appendAnimation(parallel);
+ group.appendAnimation(notTimeDriven);
+ group.appendAnimation(loopsForever);
+
+ // Current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(parallel->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_p_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_p_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_p_o3->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 1);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 1);
+ QCOMPARE(loopsForever->currentLoopTime(), 1);
+
+ // Current time = 250
+ group.setCurrentTime(250);
+ QCOMPARE(group.currentLoopTime(), 250);
+ QCOMPARE(sequence->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_p_o2->currentLoop(), 1);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 250);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
+ QCOMPARE(loopsForever->currentLoop(), 1);
+ QCOMPARE(sequence->currentAnimation(), a2_s_o1);
+
+ // Current time = 251
+ group.setCurrentTime(251);
+ QCOMPARE(group.currentLoopTime(), 251);
+ QCOMPARE(sequence->currentLoopTime(), 251);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a2_s_o1->currentLoop(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 251);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o2->currentLoop(), 1);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 251);
+ QCOMPARE(loopsForever->currentLoopTime(), 1);
+ QCOMPARE(sequence->currentAnimation(), a2_s_o1);
+}
+
+void tst_QAnimationGroupJob::addChildTwice()
+{
+ QAbstractAnimationJob *subGroup;
+ QAbstractAnimationJob *subGroup2;
+ QAnimationGroupJob *parent = new QSequentialAnimationGroupJob();
+
+ subGroup = new QAbstractAnimationJob;
+ parent->appendAnimation(subGroup);
+ parent->appendAnimation(subGroup);
+ QVERIFY(parent->firstChild() && !parent->firstChild()->nextSibling());
+
+ parent->clear();
+
+ QVERIFY(!parent->firstChild());
+
+ // adding the same item twice to a group will remove the item from its current position
+ // and append it to the end
+ subGroup = new QAbstractAnimationJob;
+ parent->appendAnimation(subGroup);
+ subGroup2 = new QAbstractAnimationJob;
+ parent->appendAnimation(subGroup2);
+
+ QCOMPARE(parent->firstChild(), subGroup);
+ QCOMPARE(parent->lastChild(), subGroup2);
+
+ parent->appendAnimation(subGroup);
+
+ QCOMPARE(parent->firstChild(), subGroup2);
+ QCOMPARE(parent->lastChild(), subGroup);
+
+ delete parent;
+}
+
+QTEST_MAIN(tst_QAnimationGroupJob)
+#include "tst_qanimationgroupjob.moc"
diff --git a/tests/auto/qml/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro b/tests/auto/qml/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro
new file mode 100644
index 0000000000..f76548183e
--- /dev/null
+++ b/tests/auto/qml/animation/qparallelanimationgroupjob/qparallelanimationgroupjob.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase
+macx:CONFIG -= app_bundle
+TARGET = tst_qparallelanimationgroupjob
+QT = core-private gui qml-private testlib
+SOURCES = tst_qparallelanimationgroupjob.cpp
diff --git a/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp b/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
new file mode 100644
index 0000000000..b6b3fac039
--- /dev/null
+++ b/tests/auto/qml/animation/qparallelanimationgroupjob/tst_qparallelanimationgroupjob.cpp
@@ -0,0 +1,931 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QtQml/private/qparallelanimationgroupjob_p.h>
+
+Q_DECLARE_METATYPE(QAbstractAnimationJob::State)
+
+class tst_QParallelAnimationGroupJob : public QObject
+{
+ Q_OBJECT
+public Q_SLOTS:
+ void initTestCase();
+
+private slots:
+ void construction();
+ void setCurrentTime();
+ void stateChanged();
+ void clearGroup();
+ void propagateGroupUpdateToChildren();
+ void updateChildrenWithRunningGroup();
+ void deleteChildrenWithRunningGroup();
+ void startChildrenWithStoppedGroup();
+ void stopGroupWithRunningChild();
+ void startGroupWithRunningChild();
+ void zeroDurationAnimation();
+ void stopUncontrolledAnimations();
+ void loopCount_data();
+ void loopCount();
+ void addAndRemoveDuration();
+ void pauseResume();
+
+ void crashWhenRemovingUncontrolledAnimation();
+};
+
+void tst_QParallelAnimationGroupJob::initTestCase()
+{
+ qRegisterMetaType<QAbstractAnimationJob::State>("QAbstractAnimationJob::State");
+#if defined(Q_OS_MAC) || defined(Q_OS_WINCE)
+ // give the mac/wince app start event queue time to clear
+ QTest::qWait(1000);
+#endif
+}
+
+void tst_QParallelAnimationGroupJob::construction()
+{
+ QParallelAnimationGroupJob animationgroup;
+}
+
+class TestAnimation : public QAbstractAnimationJob
+{
+public:
+ TestAnimation(int duration = 250) : m_duration(duration) {}
+ int duration() const { return m_duration; }
+
+private:
+ int m_duration;
+};
+
+class UncontrolledAnimation : public QObject, public QAbstractAnimationJob
+{
+ Q_OBJECT
+public:
+ UncontrolledAnimation()
+ : id(0)
+ {
+ }
+
+ int duration() const { return -1; /* not time driven */ }
+
+protected:
+ void timerEvent(QTimerEvent *event)
+ {
+ if (event->timerId() == id)
+ stop();
+ }
+
+ void updateRunning(bool running)
+ {
+ if (running) {
+ id = startTimer(500);
+ } else {
+ killTimer(id);
+ id = 0;
+ }
+ }
+
+private:
+ int id;
+};
+
+class StateChangeListener: public QAnimationJobChangeListener
+{
+public:
+ virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State)
+ {
+ states << newState;
+ }
+
+ void clear() { states.clear(); }
+ int count() { return states.count(); }
+
+ QList<QAbstractAnimationJob::State> states;
+};
+
+class FinishedListener: public QAnimationJobChangeListener
+{
+public:
+ FinishedListener() : m_count(0) {}
+
+ virtual void animationFinished(QAbstractAnimationJob *) { ++m_count; }
+ void clear() { m_count = 0; }
+ int count() { return m_count; }
+
+private:
+ int m_count;
+};
+
+void tst_QParallelAnimationGroupJob::setCurrentTime()
+{
+ // originally was parallel operating on different object/properties
+ QAnimationGroupJob *parallel = new QParallelAnimationGroupJob();
+ TestAnimation *a1_p_o1 = new TestAnimation;
+ TestAnimation *a1_p_o2 = new TestAnimation;
+ TestAnimation *a1_p_o3 = new TestAnimation;
+ a1_p_o2->setLoopCount(3);
+ parallel->appendAnimation(a1_p_o1);
+ parallel->appendAnimation(a1_p_o2);
+ parallel->appendAnimation(a1_p_o3);
+
+ UncontrolledAnimation *notTimeDriven = new UncontrolledAnimation;
+ QCOMPARE(notTimeDriven->totalDuration(), -1);
+
+ TestAnimation *loopsForever = new TestAnimation;
+ loopsForever->setLoopCount(-1);
+ QCOMPARE(loopsForever->totalDuration(), -1);
+
+ QParallelAnimationGroupJob group;
+ group.appendAnimation(parallel);
+ group.appendAnimation(notTimeDriven);
+ group.appendAnimation(loopsForever);
+
+ // Current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(parallel->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_p_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_p_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_p_o3->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 1);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 1);
+ QCOMPARE(loopsForever->currentLoopTime(), 1);
+
+ // Current time = 250
+ group.setCurrentTime(250);
+ QCOMPARE(group.currentLoopTime(), 250);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_p_o2->currentLoop(), 1);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 250);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
+ QCOMPARE(loopsForever->currentLoop(), 1);
+
+ // Current time = 251
+ group.setCurrentTime(251);
+ QCOMPARE(group.currentLoopTime(), 251);
+ QCOMPARE(a1_p_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_p_o2->currentLoopTime(), 1);
+ QCOMPARE(a1_p_o2->currentLoop(), 1);
+ QCOMPARE(a1_p_o3->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 251);
+ QCOMPARE(loopsForever->currentLoopTime(), 1);
+}
+
+void tst_QParallelAnimationGroupJob::stateChanged()
+{
+ //this ensures that the correct animations are started when starting the group
+ TestAnimation *anim1 = new TestAnimation(1000);
+ TestAnimation *anim2 = new TestAnimation(2000);
+ TestAnimation *anim3 = new TestAnimation(3000);
+ TestAnimation *anim4 = new TestAnimation(3000);
+
+ QParallelAnimationGroupJob group;
+ group.appendAnimation(anim1);
+ group.appendAnimation(anim2);
+ group.appendAnimation(anim3);
+ group.appendAnimation(anim4);
+
+ StateChangeListener spy1;
+ anim1->addAnimationChangeListener(&spy1, QAbstractAnimationJob::StateChange);
+ StateChangeListener spy2;
+ anim2->addAnimationChangeListener(&spy2, QAbstractAnimationJob::StateChange);
+ StateChangeListener spy3;
+ anim3->addAnimationChangeListener(&spy3, QAbstractAnimationJob::StateChange);
+ StateChangeListener spy4;
+ anim4->addAnimationChangeListener(&spy4, QAbstractAnimationJob::StateChange);
+
+ //first; let's start forward
+ group.start();
+ //all the animations should be started
+ QCOMPARE(spy1.count(), 1);
+ QCOMPARE(spy1.states.last(), TestAnimation::Running);
+ QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy2.states.last(), TestAnimation::Running);
+ QCOMPARE(spy3.count(), 1);
+ QCOMPARE(spy3.states.last(), TestAnimation::Running);
+ QCOMPARE(spy4.count(), 1);
+ QCOMPARE(spy4.states.last(), TestAnimation::Running);
+
+ group.setCurrentTime(1500); //anim1 should be finished
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(spy1.count(), 2);
+ QCOMPARE(spy1.states.last(), TestAnimation::Stopped);
+ QCOMPARE(spy2.count(), 1); //no change
+ QCOMPARE(spy3.count(), 1); //no change
+ QCOMPARE(spy4.count(), 1); //no change
+
+ group.setCurrentTime(2500); //anim2 should be finished
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(spy1.count(), 2); //no change
+ QCOMPARE(spy2.count(), 2);
+ QCOMPARE(spy2.states.last(), TestAnimation::Stopped);
+ QCOMPARE(spy3.count(), 1); //no change
+ QCOMPARE(spy4.count(), 1); //no change
+
+ group.setCurrentTime(3500); //everything should be finished
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(spy1.count(), 2); //no change
+ QCOMPARE(spy2.count(), 2); //no change
+ QCOMPARE(spy3.count(), 2);
+ QCOMPARE(spy3.states.last(), TestAnimation::Stopped);
+ QCOMPARE(spy4.count(), 2);
+ QCOMPARE(spy4.states.last(), TestAnimation::Stopped);
+
+ //cleanup
+ spy1.clear();
+ spy2.clear();
+ spy3.clear();
+ spy4.clear();
+
+ //now let's try to reverse that
+ group.setDirection(QAbstractAnimationJob::Backward);
+ group.start();
+
+ //only anim3 and anim4 should be started
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(spy1.count(), 0);
+ QCOMPARE(spy2.count(), 0);
+ QCOMPARE(spy3.count(), 1);
+ QCOMPARE(spy3.states.last(), TestAnimation::Running);
+ QCOMPARE(spy4.count(), 1);
+ QCOMPARE(spy4.states.last(), TestAnimation::Running);
+
+ group.setCurrentTime(1500); //anim2 should be started
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(spy1.count(), 0); //no change
+ QCOMPARE(spy2.count(), 1);
+ QCOMPARE(spy2.states.last(), TestAnimation::Running);
+ QCOMPARE(spy3.count(), 1); //no change
+ QCOMPARE(spy4.count(), 1); //no change
+
+ group.setCurrentTime(500); //anim1 is finally also started
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(spy1.count(), 1);
+ QCOMPARE(spy1.states.last(), TestAnimation::Running);
+ QCOMPARE(spy2.count(), 1); //no change
+ QCOMPARE(spy3.count(), 1); //no change
+ QCOMPARE(spy4.count(), 1); //no change
+
+ group.setCurrentTime(0); //everything should be stopped
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(spy1.count(), 2);
+ QCOMPARE(spy1.states.last(), TestAnimation::Stopped);
+ QCOMPARE(spy2.count(), 2);
+ QCOMPARE(spy2.states.last(), TestAnimation::Stopped);
+ QCOMPARE(spy3.count(), 2);
+ QCOMPARE(spy3.states.last(), TestAnimation::Stopped);
+ QCOMPARE(spy4.count(), 2);
+ QCOMPARE(spy4.states.last(), TestAnimation::Stopped);
+}
+
+void tst_QParallelAnimationGroupJob::clearGroup()
+{
+ QParallelAnimationGroupJob group;
+ static const int animationCount = 10;
+
+ for (int i = 0; i < animationCount; ++i) {
+ group.appendAnimation(new QParallelAnimationGroupJob);
+ }
+
+ int count = 0;
+ for (QAbstractAnimationJob *anim = group.firstChild(); anim; anim = anim->nextSibling())
+ ++count;
+ QCOMPARE(count, animationCount);
+
+ group.clear();
+
+ QVERIFY(!group.firstChild() && !group.lastChild());
+ QCOMPARE(group.currentLoopTime(), 0);
+}
+
+void tst_QParallelAnimationGroupJob::propagateGroupUpdateToChildren()
+{
+ // this test verifies if group state changes are updating its children correctly
+ QParallelAnimationGroupJob group;
+
+ TestAnimation anim1(100);
+ TestAnimation anim2(200);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+
+ group.start();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Running);
+
+ group.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+}
+
+void tst_QParallelAnimationGroupJob::updateChildrenWithRunningGroup()
+{
+ // assert that its possible to modify a child's state directly while their group is running
+ QParallelAnimationGroupJob group;
+
+ TestAnimation anim(200);
+
+ StateChangeListener groupStateChangedSpy;
+ group.addAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
+ StateChangeListener childStateChangedSpy;
+ anim.addAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange);
+
+ QCOMPARE(groupStateChangedSpy.count(), 0);
+ QCOMPARE(childStateChangedSpy.count(), 0);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim);
+
+ group.start();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Running);
+
+ QCOMPARE(groupStateChangedSpy.count(), 1);
+ QCOMPARE(childStateChangedSpy.count(), 1);
+
+ QCOMPARE(groupStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(childStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+
+ // starting directly a running child will not have any effect
+ anim.start();
+
+ QCOMPARE(groupStateChangedSpy.count(), 1);
+ QCOMPARE(childStateChangedSpy.count(), 1);
+
+ anim.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Paused);
+
+ // in the animation stops directly, the group will still be running
+ anim.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Stopped);
+
+ //cleanup
+ group.removeAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
+ anim.removeAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange);
+}
+
+void tst_QParallelAnimationGroupJob::deleteChildrenWithRunningGroup()
+{
+ // test if children can be activated when their group is stopped
+ QParallelAnimationGroupJob group;
+
+ TestAnimation *anim1 = new TestAnimation(200);
+ group.appendAnimation(anim1);
+
+ QCOMPARE(group.duration(), anim1->duration());
+
+ group.start();
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Running);
+
+ QTest::qWait(80);
+ QVERIFY(group.currentLoopTime() > 0);
+
+ delete anim1;
+ QVERIFY(!group.firstChild());
+ QCOMPARE(group.duration(), 0);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(group.currentLoopTime(), 0); //that's the invariant
+}
+
+void tst_QParallelAnimationGroupJob::startChildrenWithStoppedGroup()
+{
+ // test if children can be activated when their group is stopped
+ QParallelAnimationGroupJob group;
+
+ TestAnimation anim1(200);
+ TestAnimation anim2(200);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ anim1.start();
+ anim2.start();
+ anim2.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
+}
+
+void tst_QParallelAnimationGroupJob::stopGroupWithRunningChild()
+{
+ // children that started independently will not be affected by a group stop
+ QParallelAnimationGroupJob group;
+
+ TestAnimation anim1(200);
+ TestAnimation anim2(200);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+
+ anim1.start();
+ anim2.start();
+ anim2.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
+
+ anim1.stop();
+ anim2.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+}
+
+void tst_QParallelAnimationGroupJob::startGroupWithRunningChild()
+{
+ // as the group has precedence over its children, starting a group will restart all the children
+ QParallelAnimationGroupJob group;
+
+ TestAnimation anim1(200);
+ TestAnimation anim2(200);
+
+ StateChangeListener stateChangedSpy1;
+ anim1.addAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
+ StateChangeListener stateChangedSpy2;
+ anim2.addAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
+
+ QCOMPARE(stateChangedSpy1.count(), 0);
+ QCOMPARE(stateChangedSpy2.count(), 0);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+
+ anim1.start();
+ anim2.start();
+ anim2.pause();
+
+ QCOMPARE(stateChangedSpy1.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(stateChangedSpy2.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(stateChangedSpy2.states.at(1), QAnimationGroupJob::Paused);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
+
+ group.start();
+
+ QCOMPARE(stateChangedSpy1.count(), 3);
+ QCOMPARE(stateChangedSpy1.states.at(1), QAnimationGroupJob::Stopped);
+ QCOMPARE(stateChangedSpy1.states.at(2), QAnimationGroupJob::Running);
+
+ QCOMPARE(stateChangedSpy2.count(), 4);
+ QCOMPARE(stateChangedSpy2.states.at(2), QAnimationGroupJob::Stopped);
+ QCOMPARE(stateChangedSpy2.states.at(3), QAnimationGroupJob::Running);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Running);
+
+ //cleanup
+ anim1.removeAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
+ anim2.removeAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
+}
+
+void tst_QParallelAnimationGroupJob::zeroDurationAnimation()
+{
+ QParallelAnimationGroupJob group;
+
+ TestAnimation anim1(0);
+ TestAnimation anim2(100);
+ TestAnimation anim3(10);
+
+ StateChangeListener stateChangedSpy1;
+ anim1.addAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
+ FinishedListener finishedSpy1;
+ anim1.addAnimationChangeListener(&finishedSpy1, QAbstractAnimationJob::Completion);
+
+ StateChangeListener stateChangedSpy2;
+ anim2.addAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
+ FinishedListener finishedSpy2;
+ anim2.addAnimationChangeListener(&finishedSpy2, QAbstractAnimationJob::Completion);
+
+ StateChangeListener stateChangedSpy3;
+ anim3.addAnimationChangeListener(&stateChangedSpy3, QAbstractAnimationJob::StateChange);
+ FinishedListener finishedSpy3;
+ anim3.addAnimationChangeListener(&finishedSpy3, QAbstractAnimationJob::Completion);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+ group.appendAnimation(&anim3);
+ QCOMPARE(stateChangedSpy1.count(), 0);
+ group.start();
+ QCOMPARE(stateChangedSpy1.count(), 2);
+ QCOMPARE(finishedSpy1.count(), 1);
+ QCOMPARE(stateChangedSpy1.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(stateChangedSpy1.states.at(1), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(stateChangedSpy2.count(), 1);
+ QCOMPARE(finishedSpy2.count(), 0);
+ QCOMPARE(stateChangedSpy1.states.at(0), QAnimationGroupJob::Running);
+
+ QCOMPARE(stateChangedSpy3.count(), 1);
+ QCOMPARE(finishedSpy3.count(), 0);
+ QCOMPARE(stateChangedSpy3.states.at(0), QAnimationGroupJob::Running);
+
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim3.state(), QAnimationGroupJob::Running);
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+
+ group.stop();
+ group.setLoopCount(4);
+ stateChangedSpy1.clear();
+ stateChangedSpy2.clear();
+ stateChangedSpy3.clear();
+
+ group.start();
+ QCOMPARE(stateChangedSpy1.count(), 2);
+ QCOMPARE(stateChangedSpy2.count(), 1);
+ QCOMPARE(stateChangedSpy3.count(), 1);
+ group.setCurrentTime(50);
+ QCOMPARE(stateChangedSpy1.count(), 2);
+ QCOMPARE(stateChangedSpy2.count(), 1);
+ QCOMPARE(stateChangedSpy3.count(), 2);
+ group.setCurrentTime(150);
+ QCOMPARE(stateChangedSpy1.count(), 4);
+ QCOMPARE(stateChangedSpy2.count(), 3);
+ QCOMPARE(stateChangedSpy3.count(), 4);
+ group.setCurrentTime(50);
+ QCOMPARE(stateChangedSpy1.count(), 6);
+ QCOMPARE(stateChangedSpy2.count(), 5);
+ QCOMPARE(stateChangedSpy3.count(), 6);
+
+ //cleanup
+ anim1.removeAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
+ anim1.removeAnimationChangeListener(&finishedSpy1, QAbstractAnimationJob::Completion);
+ anim2.removeAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
+ anim2.removeAnimationChangeListener(&finishedSpy2, QAbstractAnimationJob::Completion);
+ anim3.removeAnimationChangeListener(&stateChangedSpy3, QAbstractAnimationJob::StateChange);
+ anim3.removeAnimationChangeListener(&finishedSpy3, QAbstractAnimationJob::Completion);
+}
+
+void tst_QParallelAnimationGroupJob::stopUncontrolledAnimations()
+{
+ QParallelAnimationGroupJob group;
+
+ TestAnimation anim1(0);
+
+ UncontrolledAnimation notTimeDriven;
+ QCOMPARE(notTimeDriven.totalDuration(), -1);
+
+ TestAnimation loopsForever(100);
+ loopsForever.setLoopCount(-1);
+
+ StateChangeListener stateChangedSpy;
+ anim1.addAnimationChangeListener(&stateChangedSpy, QAbstractAnimationJob::StateChange);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&notTimeDriven);
+ group.appendAnimation(&loopsForever);
+
+ group.start();
+
+ QCOMPARE(stateChangedSpy.count(), 2);
+ QCOMPARE(stateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(stateChangedSpy.states.at(1), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running);
+ QCOMPARE(loopsForever.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+
+ notTimeDriven.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever.state(), QAnimationGroupJob::Running);
+
+ loopsForever.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever.state(), QAnimationGroupJob::Stopped);
+}
+
+struct AnimState {
+ AnimState(int time = -1) : time(time), state(-1) {}
+ AnimState(int time, int state) : time(time), state(state) {}
+ int time;
+ int state;
+};
+
+#define Running QAbstractAnimationJob::Running
+#define Stopped QAbstractAnimationJob::Stopped
+
+Q_DECLARE_METATYPE(AnimState)
+void tst_QParallelAnimationGroupJob::loopCount_data()
+{
+ QTest::addColumn<bool>("directionBackward");
+ QTest::addColumn<int>("setLoopCount");
+ QTest::addColumn<int>("initialGroupTime");
+ QTest::addColumn<int>("currentGroupTime");
+ QTest::addColumn<AnimState>("expected1");
+ QTest::addColumn<AnimState>("expected2");
+ QTest::addColumn<AnimState>("expected3");
+
+ // D U R A T I O N
+ // 100 60*2 0
+ // direction = Forward
+ QTest::newRow("50") << false << 3 << 0 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("100") << false << 3 << 0 << 100 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped);
+ QTest::newRow("110") << false << 3 << 0 << 110 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("120") << false << 3 << 0 << 120 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
+
+ QTest::newRow("170") << false << 3 << 0 << 170 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("220") << false << 3 << 0 << 220 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped);
+ QTest::newRow("230") << false << 3 << 0 << 230 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("240") << false << 3 << 0 << 240 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
+
+ QTest::newRow("290") << false << 3 << 0 << 290 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("340") << false << 3 << 0 << 340 << AnimState(100 ) << AnimState( 40, Running) << AnimState( 0, Stopped);
+ QTest::newRow("350") << false << 3 << 0 << 350 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("360") << false << 3 << 0 << 360 << AnimState(100, Stopped) << AnimState( 60 ) << AnimState( 0, Stopped);
+
+ QTest::newRow("410") << false << 3 << 0 << 410 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
+ QTest::newRow("460") << false << 3 << 0 << 460 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
+ QTest::newRow("470") << false << 3 << 0 << 470 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
+ QTest::newRow("480") << false << 3 << 0 << 480 << AnimState(100, Stopped) << AnimState( 60, Stopped) << AnimState( 0, Stopped);
+
+ // direction = Forward, rewind
+ QTest::newRow("120-110") << false << 3 << 120 << 110 << AnimState( 0, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("120-50") << false << 3 << 120 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("120-0") << false << 3 << 120 << 0 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
+ QTest::newRow("300-110") << false << 3 << 300 << 110 << AnimState( 0, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("300-50") << false << 3 << 300 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("300-0") << false << 3 << 300 << 0 << AnimState( 0, Running) << AnimState( 0, Running) << AnimState( 0, Stopped);
+ QTest::newRow("115-105") << false << 3 << 115 << 105 << AnimState( 42, Stopped) << AnimState( 45, Running) << AnimState( 0, Stopped);
+
+ // direction = Backward
+ QTest::newRow("b120-120") << true << 3 << 120 << 120 << AnimState( 42, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b120-110") << true << 3 << 120 << 110 << AnimState( 42, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b120-100") << true << 3 << 120 << 100 << AnimState(100, Running) << AnimState( 40, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b120-50") << true << 3 << 120 << 50 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b120-0") << true << 3 << 120 << 0 << AnimState( 0, Stopped) << AnimState( 0, Stopped) << AnimState( 0, Stopped);
+ QTest::newRow("b360-170") << true << 3 << 360 << 170 << AnimState( 50, Running) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b360-220") << true << 3 << 360 << 220 << AnimState(100, Running) << AnimState( 40, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b360-210") << true << 3 << 360 << 210 << AnimState( 90, Running) << AnimState( 30, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b360-120") << true << 3 << 360 << 120 << AnimState( 0, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
+
+ // rewind, direction = Backward
+ QTest::newRow("b50-110") << true << 3 << 50 << 110 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b50-120") << true << 3 << 50 << 120 << AnimState(100, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b50-140") << true << 3 << 50 << 140 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b50-240") << true << 3 << 50 << 240 << AnimState(100, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b50-260") << true << 3 << 50 << 260 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b50-350") << true << 3 << 50 << 350 << AnimState(100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+
+ // infinite looping
+ QTest::newRow("inf1220") << false << -1 << 0 << 1220 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
+ QTest::newRow("inf1310") << false << -1 << 0 << 1310 << AnimState( 100, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+ // infinite looping, direction = Backward (will only loop once)
+ QTest::newRow("b.inf120-120") << true << -1 << 120 << 120 << AnimState( 42, Stopped) << AnimState( 60, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b.inf120-20") << true << -1 << 120 << 20 << AnimState( 20, Running) << AnimState( 20, Running) << AnimState( 0, Stopped);
+ QTest::newRow("b.inf120-110") << true << -1 << 120 << 110 << AnimState( 42, Stopped) << AnimState( 50, Running) << AnimState( 0, Stopped);
+
+
+}
+
+void tst_QParallelAnimationGroupJob::loopCount()
+{
+ QFETCH(bool, directionBackward);
+ QFETCH(int, setLoopCount);
+ QFETCH(int, initialGroupTime);
+ QFETCH(int, currentGroupTime);
+ QFETCH(AnimState, expected1);
+ QFETCH(AnimState, expected2);
+ QFETCH(AnimState, expected3);
+
+ QParallelAnimationGroupJob group;
+
+ TestAnimation anim1(100);
+ TestAnimation anim2(60); //total 120
+ anim2.setLoopCount(2);
+ TestAnimation anim3(0);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+ group.appendAnimation(&anim3);
+
+ group.setLoopCount(setLoopCount);
+ if (initialGroupTime >= 0)
+ group.setCurrentTime(initialGroupTime);
+ if (directionBackward)
+ group.setDirection(QAbstractAnimationJob::Backward);
+
+ group.start();
+ if (initialGroupTime >= 0)
+ group.setCurrentTime(initialGroupTime);
+
+ anim1.setCurrentTime(42); // 42 is "untouched"
+ anim2.setCurrentTime(42);
+
+ group.setCurrentTime(currentGroupTime);
+
+ QCOMPARE(anim1.currentLoopTime(), expected1.time);
+ QCOMPARE(anim2.currentLoopTime(), expected2.time);
+ QCOMPARE(anim3.currentLoopTime(), expected3.time);
+
+ if (expected1.state >=0)
+ QCOMPARE(int(anim1.state()), expected1.state);
+ if (expected2.state >=0)
+ QCOMPARE(int(anim2.state()), expected2.state);
+ if (expected3.state >=0)
+ QCOMPARE(int(anim3.state()), expected3.state);
+
+}
+
+void tst_QParallelAnimationGroupJob::addAndRemoveDuration()
+{
+ QParallelAnimationGroupJob group;
+ QCOMPARE(group.duration(), 0);
+ TestAnimation *test = new TestAnimation(250); // 0, duration = 250;
+ group.appendAnimation(test);
+ QCOMPARE(test->group(), static_cast<QAnimationGroupJob*>(&group));
+ QCOMPARE(test->duration(), 250);
+ QCOMPARE(group.duration(), 250);
+
+ TestAnimation *test2 = new TestAnimation(750); // 1
+ group.appendAnimation(test2);
+ QCOMPARE(test2->group(), static_cast<QAnimationGroupJob*>(&group));
+ QCOMPARE(group.duration(), 750);
+
+ TestAnimation *test3 = new TestAnimation(500); // 2
+ group.appendAnimation(test3);
+ QCOMPARE(test3->group(), static_cast<QAnimationGroupJob*>(&group));
+ QCOMPARE(group.duration(), 750);
+
+ group.removeAnimation(test2); // remove the one with duration = 750
+ delete test2;
+ QCOMPARE(group.duration(), 500);
+
+ group.removeAnimation(test3); // remove the one with duration = 500
+ delete test3;
+ QCOMPARE(group.duration(), 250);
+
+ group.removeAnimation(test); // remove the last one (with duration = 250)
+ QCOMPARE(test->group(), static_cast<QAnimationGroupJob*>(0));
+ QCOMPARE(group.duration(), 0);
+ delete test;
+}
+
+void tst_QParallelAnimationGroupJob::pauseResume()
+{
+ QParallelAnimationGroupJob group;
+ TestAnimation *anim = new TestAnimation(250); // 0, duration = 250;
+ group.appendAnimation(anim);
+ StateChangeListener spy;
+ anim->addAnimationChangeListener(&spy, QAbstractAnimationJob::StateChange);
+ QCOMPARE(group.duration(), 250);
+ group.start();
+ QTest::qWait(100);
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim->state(), QAnimationGroupJob::Running);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ const int currentTime = group.currentLoopTime();
+ QCOMPARE(anim->currentLoopTime(), currentTime);
+
+ group.pause();
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(group.currentLoopTime(), currentTime);
+ QCOMPARE(anim->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(anim->currentLoopTime(), currentTime);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+
+ group.resume();
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(group.currentLoopTime(), currentTime);
+ QCOMPARE(anim->state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim->currentLoopTime(), currentTime);
+ QCOMPARE(spy.count(), 1);
+
+ group.stop();
+ spy.clear();
+ group.appendAnimation(new TestAnimation(500));
+ group.start();
+ QCOMPARE(spy.count(), 1); //the animation should have been started
+ QCOMPARE(spy.states.at(0), TestAnimation::Running);
+ group.setCurrentTime(250); //end of first animation
+ QCOMPARE(spy.count(), 2); //the animation should have been stopped
+ QCOMPARE(spy.states.at(1), TestAnimation::Stopped);
+ group.pause();
+ QCOMPARE(spy.count(), 2); //this shouldn't have changed
+ group.resume();
+ QCOMPARE(spy.count(), 2); //this shouldn't have changed
+}
+
+// This is a regression test for QTBUG-8910, where a crash occurred when the
+// last animation was removed from a group.
+void tst_QParallelAnimationGroupJob::crashWhenRemovingUncontrolledAnimation()
+{
+ QParallelAnimationGroupJob group;
+ TestAnimation *anim = new TestAnimation;
+ anim->setLoopCount(-1);
+ TestAnimation *anim2 = new TestAnimation;
+ anim2->setLoopCount(-1);
+ group.appendAnimation(anim);
+ group.appendAnimation(anim2);
+ group.start();
+ delete anim;
+ // it would crash here because the internals of the group would still have a reference to anim
+ delete anim2;
+}
+
+
+QTEST_MAIN(tst_QParallelAnimationGroupJob)
+#include "tst_qparallelanimationgroupjob.moc"
diff --git a/tests/auto/qml/animation/qpauseanimationjob/qpauseanimationjob.pro b/tests/auto/qml/animation/qpauseanimationjob/qpauseanimationjob.pro
new file mode 100644
index 0000000000..b80bb0c55c
--- /dev/null
+++ b/tests/auto/qml/animation/qpauseanimationjob/qpauseanimationjob.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase
+macx:CONFIG -= app_bundle
+TARGET = tst_qpauseanimationjob
+QT = core-private gui-private qml-private testlib
+SOURCES = tst_qpauseanimationjob.cpp
diff --git a/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp
new file mode 100644
index 0000000000..247d7791bf
--- /dev/null
+++ b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp
@@ -0,0 +1,470 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <QtQml/private/qpauseanimationjob_p.h>
+#include <QtQml/private/qsequentialanimationgroupjob_p.h>
+#include <QtQml/private/qparallelanimationgroupjob_p.h>
+
+#ifdef Q_OS_WIN
+static const char winTimerError[] = "On windows, consistent timing is not working properly due to bad timer resolution";
+#endif
+
+class TestablePauseAnimation : public QPauseAnimationJob
+{
+public:
+ TestablePauseAnimation()
+ : m_updateCurrentTimeCount(0)
+ {
+ }
+
+ TestablePauseAnimation(int duration)
+ : QPauseAnimationJob(duration), m_updateCurrentTimeCount(0)
+ {
+ }
+
+ int m_updateCurrentTimeCount;
+protected:
+ void updateCurrentTime(int currentTime)
+ {
+ QPauseAnimationJob::updateCurrentTime(currentTime);
+ ++m_updateCurrentTimeCount;
+ }
+};
+
+class TestableGenericAnimation : public QAbstractAnimationJob
+{
+public:
+ TestableGenericAnimation(int duration = 250) : m_duration(duration) {}
+ int duration() const { return m_duration; }
+
+private:
+ int m_duration;
+};
+
+class EnableConsistentTiming
+{
+public:
+ EnableConsistentTiming()
+ {
+ QUnifiedTimer *timer = QUnifiedTimer::instance();
+ timer->setConsistentTiming(true);
+ }
+ ~EnableConsistentTiming()
+ {
+ QUnifiedTimer *timer = QUnifiedTimer::instance();
+ timer->setConsistentTiming(false);
+ }
+};
+
+class tst_QPauseAnimationJob : public QObject
+{
+ Q_OBJECT
+public Q_SLOTS:
+ void initTestCase();
+
+private slots:
+ void changeDirectionWhileRunning();
+ void noTimerUpdates_data();
+ void noTimerUpdates();
+ void multiplePauseAnimations();
+ void pauseAndPropertyAnimations();
+ void pauseResume();
+ void sequentialPauseGroup();
+ void sequentialGroupWithPause();
+ void multipleSequentialGroups();
+ void zeroDuration();
+};
+
+void tst_QPauseAnimationJob::initTestCase()
+{
+// qRegisterMetaType<QAbstractAnimationJob::State>("QAbstractAnimationJob::State");
+}
+
+void tst_QPauseAnimationJob::changeDirectionWhileRunning()
+{
+ EnableConsistentTiming enabled;
+
+ TestablePauseAnimation animation;
+ animation.setDuration(400);
+ animation.start();
+ QTest::qWait(100);
+ QVERIFY(animation.state() == QAbstractAnimationJob::Running);
+ animation.setDirection(QAbstractAnimationJob::Backward);
+ QTest::qWait(animation.totalDuration() + 50);
+ QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
+}
+
+void tst_QPauseAnimationJob::noTimerUpdates_data()
+{
+ QTest::addColumn<int>("duration");
+ QTest::addColumn<int>("loopCount");
+
+ QTest::newRow("0") << 200 << 1;
+ QTest::newRow("1") << 160 << 1;
+ QTest::newRow("2") << 160 << 2;
+ QTest::newRow("3") << 200 << 3;
+}
+
+void tst_QPauseAnimationJob::noTimerUpdates()
+{
+ EnableConsistentTiming enabled;
+
+ QFETCH(int, duration);
+ QFETCH(int, loopCount);
+
+ TestablePauseAnimation animation;
+ animation.setDuration(duration);
+ animation.setLoopCount(loopCount);
+ animation.start();
+ QTest::qWait(animation.totalDuration() + 100);
+
+#ifdef Q_OS_WIN
+ if (animation.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+
+ QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
+ const int expectedLoopCount = 1 + loopCount;
+
+#ifdef Q_OS_WIN
+ if (animation.m_updateCurrentTimeCount != expectedLoopCount)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QCOMPARE(animation.m_updateCurrentTimeCount, expectedLoopCount);
+}
+
+void tst_QPauseAnimationJob::multiplePauseAnimations()
+{
+ EnableConsistentTiming enabled;
+
+ TestablePauseAnimation animation;
+ animation.setDuration(200);
+
+ TestablePauseAnimation animation2;
+ animation2.setDuration(800);
+
+ animation.start();
+ animation2.start();
+ QTest::qWait(animation.totalDuration() + 100);
+
+#ifdef Q_OS_WIN
+ if (animation.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
+
+#ifdef Q_OS_WIN
+ if (animation2.state() != QAbstractAnimationJob::Running)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(animation2.state() == QAbstractAnimationJob::Running);
+
+#ifdef Q_OS_WIN
+ if (animation.m_updateCurrentTimeCount != 2)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QCOMPARE(animation.m_updateCurrentTimeCount, 2);
+
+#ifdef Q_OS_WIN
+ if (animation2.m_updateCurrentTimeCount != 2)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
+
+ QTest::qWait(550);
+
+#ifdef Q_OS_WIN
+ if (animation2.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped);
+
+#ifdef Q_OS_WIN
+ if (animation2.m_updateCurrentTimeCount != 3)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 3);
+}
+
+void tst_QPauseAnimationJob::pauseAndPropertyAnimations()
+{
+ EnableConsistentTiming enabled;
+
+ TestablePauseAnimation pause;
+ pause.setDuration(200);
+
+ TestableGenericAnimation animation;
+
+ pause.start();
+
+ QTest::qWait(100);
+ animation.start();
+
+ QVERIFY(animation.state() == QAbstractAnimationJob::Running);
+ QVERIFY(pause.state() == QAbstractAnimationJob::Running);
+ QCOMPARE(pause.m_updateCurrentTimeCount, 2);
+
+ QTest::qWait(animation.totalDuration() + 100);
+
+#ifdef Q_OS_WIN
+ if (animation.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(pause.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(pause.m_updateCurrentTimeCount > 3);
+}
+
+void tst_QPauseAnimationJob::pauseResume()
+{
+ TestablePauseAnimation animation;
+ animation.setDuration(400);
+ animation.start();
+ QVERIFY(animation.state() == QAbstractAnimationJob::Running);
+ QTest::qWait(200);
+ animation.pause();
+ QVERIFY(animation.state() == QAbstractAnimationJob::Paused);
+ animation.start();
+ QTest::qWait(300);
+ QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
+
+#ifdef Q_OS_WIN
+ if (animation.m_updateCurrentTimeCount != 3)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QCOMPARE(animation.m_updateCurrentTimeCount, 3);
+}
+
+void tst_QPauseAnimationJob::sequentialPauseGroup()
+{
+ QSequentialAnimationGroupJob group;
+
+ TestablePauseAnimation animation1(200);
+ group.appendAnimation(&animation1);
+ TestablePauseAnimation animation2(200);
+ group.appendAnimation(&animation2);
+ TestablePauseAnimation animation3(200);
+ group.appendAnimation(&animation3);
+
+ group.start();
+ QCOMPARE(animation1.m_updateCurrentTimeCount, 1);
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 0);
+ QCOMPARE(animation3.m_updateCurrentTimeCount, 0);
+
+ QVERIFY(group.state() == QAbstractAnimationJob::Running);
+ QVERIFY(animation1.state() == QAbstractAnimationJob::Running);
+ QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped);
+
+ group.setCurrentTime(250);
+ QCOMPARE(animation1.m_updateCurrentTimeCount, 2);
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 1);
+ QCOMPARE(animation3.m_updateCurrentTimeCount, 0);
+
+ QVERIFY(group.state() == QAbstractAnimationJob::Running);
+ QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped);
+ QCOMPARE((QAbstractAnimationJob*)&animation2, group.currentAnimation());
+ QVERIFY(animation2.state() == QAbstractAnimationJob::Running);
+ QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped);
+
+ group.setCurrentTime(500);
+ QCOMPARE(animation1.m_updateCurrentTimeCount, 2);
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
+ QCOMPARE(animation3.m_updateCurrentTimeCount, 1);
+
+ QVERIFY(group.state() == QAbstractAnimationJob::Running);
+ QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped);
+ QCOMPARE((QAbstractAnimationJob*)&animation3, group.currentAnimation());
+ QVERIFY(animation3.state() == QAbstractAnimationJob::Running);
+
+ group.setCurrentTime(750);
+
+ QVERIFY(group.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped);
+
+ QCOMPARE(animation1.m_updateCurrentTimeCount, 2);
+ QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
+ QCOMPARE(animation3.m_updateCurrentTimeCount, 2);
+}
+
+void tst_QPauseAnimationJob::sequentialGroupWithPause()
+{
+ QSequentialAnimationGroupJob group;
+
+ TestableGenericAnimation animation;
+ group.appendAnimation(&animation);
+
+ TestablePauseAnimation pause;
+ pause.setDuration(250);
+ group.appendAnimation(&pause);
+
+ group.start();
+
+ QVERIFY(group.state() == QAbstractAnimationJob::Running);
+ QVERIFY(animation.state() == QAbstractAnimationJob::Running);
+ QVERIFY(pause.state() == QAbstractAnimationJob::Stopped);
+
+ group.setCurrentTime(300);
+
+ QVERIFY(group.state() == QAbstractAnimationJob::Running);
+ QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
+ QCOMPARE((QAbstractAnimationJob*)&pause, group.currentAnimation());
+ QVERIFY(pause.state() == QAbstractAnimationJob::Running);
+
+ group.setCurrentTime(600);
+
+ QVERIFY(group.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
+ QVERIFY(pause.state() == QAbstractAnimationJob::Stopped);
+
+ QCOMPARE(pause.m_updateCurrentTimeCount, 2);
+}
+
+void tst_QPauseAnimationJob::multipleSequentialGroups()
+{
+ EnableConsistentTiming enabled;
+
+ QParallelAnimationGroupJob group;
+ group.setLoopCount(2);
+
+ QSequentialAnimationGroupJob subgroup1;
+ group.appendAnimation(&subgroup1);
+
+ TestableGenericAnimation animation(300);
+ subgroup1.appendAnimation(&animation);
+
+ TestablePauseAnimation pause(200);
+ subgroup1.appendAnimation(&pause);
+
+ QSequentialAnimationGroupJob subgroup2;
+ group.appendAnimation(&subgroup2);
+
+ TestableGenericAnimation animation2(200);
+ subgroup2.appendAnimation(&animation2);
+
+ TestablePauseAnimation pause2(250);
+ subgroup2.appendAnimation(&pause2);
+
+ QSequentialAnimationGroupJob subgroup3;
+ group.appendAnimation(&subgroup3);
+
+ TestablePauseAnimation pause3(400);
+ subgroup3.appendAnimation(&pause3);
+
+ TestableGenericAnimation animation3(200);
+ subgroup3.appendAnimation(&animation3);
+
+ QSequentialAnimationGroupJob subgroup4;
+ group.appendAnimation(&subgroup4);
+
+ TestablePauseAnimation pause4(310);
+ subgroup4.appendAnimation(&pause4);
+
+ TestablePauseAnimation pause5(60);
+ subgroup4.appendAnimation(&pause5);
+
+ group.start();
+
+ QVERIFY(group.state() == QAbstractAnimationJob::Running);
+ QVERIFY(subgroup1.state() == QAbstractAnimationJob::Running);
+ QVERIFY(subgroup2.state() == QAbstractAnimationJob::Running);
+ QVERIFY(subgroup3.state() == QAbstractAnimationJob::Running);
+ QVERIFY(subgroup4.state() == QAbstractAnimationJob::Running);
+
+ // This is a pretty long animation so it tends to get rather out of sync
+ // when using the consistent timer, so run for an extra half second for good
+ // measure...
+ QTest::qWait(group.totalDuration() + 500);
+
+#ifdef Q_OS_WIN
+ if (group.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(group.state() == QAbstractAnimationJob::Stopped);
+
+#ifdef Q_OS_WIN
+ if (subgroup1.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(subgroup1.state() == QAbstractAnimationJob::Stopped);
+
+#ifdef Q_OS_WIN
+ if (subgroup2.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(subgroup2.state() == QAbstractAnimationJob::Stopped);
+
+#ifdef Q_OS_WIN
+ if (subgroup3.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(subgroup3.state() == QAbstractAnimationJob::Stopped);
+
+#ifdef Q_OS_WIN
+ if (subgroup4.state() != QAbstractAnimationJob::Stopped)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QVERIFY(subgroup4.state() == QAbstractAnimationJob::Stopped);
+
+#ifdef Q_OS_WIN
+ if (pause5.m_updateCurrentTimeCount != 4)
+ QEXPECT_FAIL("", winTimerError, Abort);
+#endif
+ QCOMPARE(pause5.m_updateCurrentTimeCount, 4);
+}
+
+void tst_QPauseAnimationJob::zeroDuration()
+{
+ TestablePauseAnimation animation;
+ animation.setDuration(0);
+ animation.start();
+ QTest::qWait(animation.totalDuration() + 100);
+ QVERIFY(animation.state() == QAbstractAnimationJob::Stopped);
+ QCOMPARE(animation.m_updateCurrentTimeCount, 1);
+}
+
+QTEST_MAIN(tst_QPauseAnimationJob)
+#include "tst_qpauseanimationjob.moc"
diff --git a/tests/auto/qml/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro b/tests/auto/qml/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro
new file mode 100644
index 0000000000..fe4dc9ce82
--- /dev/null
+++ b/tests/auto/qml/animation/qsequentialanimationgroupjob/qsequentialanimationgroupjob.pro
@@ -0,0 +1,5 @@
+CONFIG += testcase parallel_test
+macx:CONFIG -= app_bundle
+TARGET = tst_qsequentialanimationgroupjob
+QT = core-private qml-private testlib
+SOURCES = tst_qsequentialanimationgroupjob.cpp
diff --git a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
new file mode 100644
index 0000000000..caa43cf9cb
--- /dev/null
+++ b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp
@@ -0,0 +1,1617 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtQml/private/qsequentialanimationgroupjob_p.h>
+#include <QtQml/private/qparallelanimationgroupjob_p.h>
+#include <QtQml/private/qpauseanimationjob_p.h>
+
+Q_DECLARE_METATYPE(QAbstractAnimationJob::State)
+Q_DECLARE_METATYPE(QAbstractAnimationJob*)
+
+class tst_QSequentialAnimationGroupJob : public QObject
+{
+ Q_OBJECT
+public Q_SLOTS:
+ void initTestCase();
+
+private slots:
+ void construction();
+ void setCurrentTime();
+ void setCurrentTimeWithUncontrolledAnimation();
+ void seekingForwards();
+ void seekingBackwards();
+ void pauseAndResume();
+ void restart();
+ void looping();
+ void startDelay();
+ void clearGroup();
+ void groupWithZeroDurationAnimations();
+ void propagateGroupUpdateToChildren();
+ void updateChildrenWithRunningGroup();
+ void deleteChildrenWithRunningGroup();
+ void startChildrenWithStoppedGroup();
+ void stopGroupWithRunningChild();
+ void startGroupWithRunningChild();
+ void zeroDurationAnimation();
+ void stopUncontrolledAnimations();
+ void finishWithUncontrolledAnimation();
+ void addRemoveAnimation();
+ void currentAnimation();
+ void currentAnimationWithZeroDuration();
+ void insertAnimation();
+ void clear();
+ void pauseResume();
+};
+
+void tst_QSequentialAnimationGroupJob::initTestCase()
+{
+ qRegisterMetaType<QAbstractAnimationJob::State>("QAbstractAnimationJob::State");
+ qRegisterMetaType<QAbstractAnimationJob*>("QAbstractAnimationJob*");
+}
+
+void tst_QSequentialAnimationGroupJob::construction()
+{
+ QSequentialAnimationGroupJob animationgroup;
+}
+
+class TestAnimation : public QAbstractAnimationJob
+{
+public:
+ TestAnimation(int duration = 250) : m_duration(duration) {}
+ int duration() const { return m_duration; }
+
+private:
+ int m_duration;
+};
+
+class TestValueAnimation : public TestAnimation
+{
+public:
+ TestValueAnimation(int duration = 250)
+ : TestAnimation(duration), start(0), end(0), value(0) {}
+
+ void updateCurrentTime(int msecs)
+ {
+ if (msecs >= duration())
+ value = end;
+ else
+ value = start + (end - start) * (qreal(msecs) / duration());
+ }
+
+ qreal start, end;
+ qreal value;
+};
+
+class UncontrolledAnimation : public QObject, public QAbstractAnimationJob
+{
+ Q_OBJECT
+public:
+ int duration() const { return -1; /* not time driven */ }
+
+protected:
+ void updateCurrentTime(int currentTime)
+ {
+ if (currentTime >= 250)
+ stop();
+ }
+};
+
+class StateChangeListener: public QAnimationJobChangeListener
+{
+public:
+ virtual void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State)
+ {
+ states << newState;
+ }
+
+ void clear() { states.clear(); }
+ int count() const { return states.count(); }
+
+ QList<QAbstractAnimationJob::State> states;
+};
+
+class FinishedListener: public QAnimationJobChangeListener
+{
+public:
+ FinishedListener() : m_count(0) {}
+
+ virtual void animationFinished(QAbstractAnimationJob *) { ++m_count; }
+ void clear() { m_count = 0; }
+ int count() { return m_count; }
+
+private:
+ int m_count;
+};
+
+void tst_QSequentialAnimationGroupJob::setCurrentTime()
+{
+ // sequence operating on same object/property
+ QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
+ TestAnimation *a1_s_o1 = new TestAnimation;
+ TestAnimation *a2_s_o1 = new TestAnimation;
+ TestAnimation *a3_s_o1 = new TestAnimation;
+ a2_s_o1->setLoopCount(3);
+ sequence->appendAnimation(a1_s_o1);
+ sequence->appendAnimation(a2_s_o1);
+ sequence->appendAnimation(a3_s_o1);
+
+ // sequence operating on different object/properties
+ QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob();
+ TestAnimation *a1_s_o2 = new TestAnimation;
+ TestAnimation *a1_s_o3 = new TestAnimation;
+ sequence2->appendAnimation(a1_s_o2);
+ sequence2->appendAnimation(a1_s_o3);
+
+ QSequentialAnimationGroupJob group;
+ group.appendAnimation(sequence);
+ group.appendAnimation(sequence2);
+
+ // Current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 250
+ group.setCurrentTime(250);
+ QCOMPARE(group.currentLoopTime(), 250);
+ QCOMPARE(sequence->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 251
+ group.setCurrentTime(251);
+ QCOMPARE(group.currentLoopTime(), 251);
+ QCOMPARE(sequence->currentLoopTime(), 251);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a2_s_o1->currentLoop(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 750
+ group.setCurrentTime(750);
+ QCOMPARE(group.currentLoopTime(), 750);
+ QCOMPARE(sequence->currentLoopTime(), 750);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 1000
+ group.setCurrentTime(1000);
+ QCOMPARE(group.currentLoopTime(), 1000);
+ QCOMPARE(sequence->currentLoopTime(), 1000);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 1010
+ group.setCurrentTime(1010);
+ QCOMPARE(group.currentLoopTime(), 1010);
+ QCOMPARE(sequence->currentLoopTime(), 1010);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 10);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 1250
+ group.setCurrentTime(1250);
+ QCOMPARE(group.currentLoopTime(), 1250);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 1500
+ group.setCurrentTime(1500);
+ QCOMPARE(group.currentLoopTime(), 1500);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 1750
+ group.setCurrentTime(1750);
+ QCOMPARE(group.currentLoopTime(), 1750);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 250);
+
+ // Current time = 2000
+ group.setCurrentTime(2000);
+ QCOMPARE(group.currentLoopTime(), 1750);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 250);
+}
+
+void tst_QSequentialAnimationGroupJob::setCurrentTimeWithUncontrolledAnimation()
+{
+ // sequence operating on different object/properties
+ QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
+ TestAnimation *a1_s_o1 = new TestAnimation;
+ TestAnimation *a1_s_o2 = new TestAnimation;
+ sequence->appendAnimation(a1_s_o1);
+ sequence->appendAnimation(a1_s_o2);
+
+ UncontrolledAnimation *notTimeDriven = new UncontrolledAnimation;
+ QCOMPARE(notTimeDriven->totalDuration(), -1);
+
+ TestAnimation *loopsForever = new TestAnimation;
+ loopsForever->setLoopCount(-1);
+ QCOMPARE(loopsForever->totalDuration(), -1);
+
+ QSequentialAnimationGroupJob group;
+ group.appendAnimation(sequence);
+ group.appendAnimation(notTimeDriven);
+ group.appendAnimation(loopsForever);
+ group.start();
+ group.pause(); // this allows the group to listen for the finish signal of its children
+
+ // Current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 0);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
+
+ // Current time = 250
+ group.setCurrentTime(250);
+ QCOMPARE(group.currentLoopTime(), 250);
+ QCOMPARE(sequence->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 0);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
+
+ // Current time = 500
+ group.setCurrentTime(500);
+ QCOMPARE(group.currentLoopTime(), 500);
+ QCOMPARE(sequence->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 0);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob *>(notTimeDriven));
+
+ // Current time = 505
+ group.setCurrentTime(505);
+ QCOMPARE(group.currentLoopTime(), 505);
+ QCOMPARE(sequence->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 5);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob *>(notTimeDriven));
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
+
+ // Current time = 750 (end of notTimeDriven animation)
+ group.setCurrentTime(750);
+ QCOMPARE(group.currentLoopTime(), 750);
+ QCOMPARE(sequence->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 250);
+ QCOMPARE(loopsForever->currentLoopTime(), 0);
+ QCOMPARE(group.currentAnimation(), loopsForever);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever->state(), QAnimationGroupJob::Paused);
+
+ // Current time = 800 (as notTimeDriven was finished at 750, loopsforever should still run)
+ group.setCurrentTime(800);
+ QCOMPARE(group.currentLoopTime(), 800);
+ QCOMPARE(group.currentAnimation(), loopsForever);
+ QCOMPARE(sequence->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(notTimeDriven->currentLoopTime(), 250);
+ QCOMPARE(loopsForever->currentLoopTime(), 50);
+
+ loopsForever->stop(); // this should stop the group
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever->state(), QAnimationGroupJob::Stopped);
+}
+
+void tst_QSequentialAnimationGroupJob::seekingForwards()
+{
+
+ // sequence operating on same object/property
+ QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob;
+ TestAnimation *a1_s_o1 = new TestAnimation;
+ TestAnimation *a2_s_o1 = new TestAnimation;
+ TestAnimation *a3_s_o1 = new TestAnimation;
+ a2_s_o1->setLoopCount(3);
+ sequence->appendAnimation(a1_s_o1);
+ sequence->appendAnimation(a2_s_o1);
+ sequence->appendAnimation(a3_s_o1);
+
+ // sequence operating on different object/properties
+ QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob;
+ TestAnimation *a1_s_o2 = new TestAnimation;
+ TestAnimation *a1_s_o3 = new TestAnimation;
+ sequence2->appendAnimation(a1_s_o2);
+ sequence2->appendAnimation(a1_s_o3);
+
+ QSequentialAnimationGroupJob group;
+ group.appendAnimation(sequence);
+ group.appendAnimation(sequence2);
+
+ // Current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // Current time = 1500
+ group.setCurrentTime(1500);
+ QCOMPARE(group.currentLoopTime(), 1500);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ // this will restart the group
+ group.start();
+ group.pause();
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped);
+
+ // Current time = 1750
+ group.setCurrentTime(1750);
+ QCOMPARE(group.currentLoopTime(), 1750);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 250);
+}
+
+void tst_QSequentialAnimationGroupJob::seekingBackwards()
+{
+ // sequence operating on same object/property
+ QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
+ TestAnimation *a1_s_o1 = new TestAnimation;
+ TestAnimation *a2_s_o1 = new TestAnimation;
+ TestAnimation *a3_s_o1 = new TestAnimation;
+ a2_s_o1->setLoopCount(3);
+ sequence->appendAnimation(a1_s_o1);
+ sequence->appendAnimation(a2_s_o1);
+ sequence->appendAnimation(a3_s_o1);
+
+ // sequence operating on different object/properties
+ QAnimationGroupJob *sequence2 = new QSequentialAnimationGroupJob();
+ TestAnimation *a1_s_o2 = new TestAnimation;
+ TestAnimation *a1_s_o3 = new TestAnimation;
+ sequence2->appendAnimation(a1_s_o2);
+ sequence2->appendAnimation(a1_s_o3);
+
+ QSequentialAnimationGroupJob group;
+ group.appendAnimation(sequence);
+ group.appendAnimation(sequence2);
+
+ group.start();
+
+ // Current time = 1600
+ group.setCurrentTime(1600);
+ QCOMPARE(group.currentLoopTime(), 1600);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 350);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 100);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence2->state(), QAnimationGroupJob::Running);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Running);
+
+ // Seeking backwards, current time = 1
+ group.setCurrentTime(1);
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+
+ QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
+ "hence they don't reset from their current animation", Continue);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 0);
+ QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
+ "hence they don't reset from their current animation", Continue);
+ QCOMPARE(a2_s_o1->currentLoop(), 0);
+ QEXPECT_FAIL("", "rewinding in nested groups is considered as a restart from the children,"
+ "hence they don't reset from their current animation", Continue);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 0);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 0);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Running);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Running);
+ QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped);
+
+ // Current time = 2000
+ group.setCurrentTime(2000);
+ QCOMPARE(group.currentLoopTime(), 1750);
+ QCOMPARE(sequence->currentLoopTime(), 1250);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 2);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+ QCOMPARE(sequence2->currentLoopTime(), 500);
+ QCOMPARE(a1_s_o2->currentLoopTime(), 250);
+ QCOMPARE(a1_s_o3->currentLoopTime(), 250);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(sequence2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1_s_o3->state(), QAnimationGroupJob::Stopped);
+}
+
+typedef QList<QAbstractAnimationJob::State> StateList;
+
+static bool compareStates(const StateChangeListener& spy, const StateList &expectedStates)
+{
+ bool equals = true;
+ for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) {
+ if (i >= spy.count() || i >= expectedStates.count()) {
+ equals = false;
+ break;
+ }
+ QAbstractAnimationJob::State st = expectedStates.at(i);
+ QAbstractAnimationJob::State actual = spy.states.at(i);
+ if (equals && actual != st) {
+ equals = false;
+ break;
+ }
+ }
+ if (!equals) {
+ const char *stateStrings[] = {"Stopped", "Paused", "Running"};
+ QString e,a;
+ for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) {
+ if (i < expectedStates.count()) {
+ int exp = int(expectedStates.at(i));
+ if (!e.isEmpty())
+ e += QLatin1String(", ");
+ e += QLatin1String(stateStrings[exp]);
+ }
+ if (i < spy.count()) {
+ QAbstractAnimationJob::State actual = spy.states.at(i);
+ if (!a.isEmpty())
+ a += QLatin1String(", ");
+ if (int(actual) >= 0 && int(actual) <= 2) {
+ a += QLatin1String(stateStrings[int(actual)]);
+ } else {
+ a += QLatin1String("NaN");
+ }
+ }
+
+ }
+ qDebug("\n"
+ "expected (count == %d): %s\n"
+ "actual (count == %d): %s\n", expectedStates.count(), qPrintable(e), spy.count(), qPrintable(a));
+ }
+ return equals;
+}
+
+void tst_QSequentialAnimationGroupJob::pauseAndResume()
+{
+ // sequence operating on same object/property
+ QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
+ TestAnimation *a1_s_o1 = new TestAnimation;
+ TestAnimation *a2_s_o1 = new TestAnimation;
+ TestAnimation *a3_s_o1 = new TestAnimation;
+ a2_s_o1->setLoopCount(2);
+ sequence->appendAnimation(a1_s_o1);
+ sequence->appendAnimation(a2_s_o1);
+ sequence->appendAnimation(a3_s_o1);
+ sequence->setLoopCount(2);
+
+ StateChangeListener a1StateChangedSpy;
+ a1_s_o1->addAnimationChangeListener(&a1StateChangedSpy, QAbstractAnimationJob::StateChange);
+ StateChangeListener seqStateChangedSpy;
+ sequence->addAnimationChangeListener(&seqStateChangedSpy, QAbstractAnimationJob::StateChange);
+
+ QSequentialAnimationGroupJob group;
+ group.appendAnimation(sequence);
+
+ group.start();
+ group.pause();
+
+ // Current time = 1751
+ group.setCurrentTime(1751);
+ QCOMPARE(group.currentLoopTime(), 1751);
+ QCOMPARE(sequence->currentLoopTime(), 751);
+ QCOMPARE(sequence->currentLoop(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 1);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Paused);
+
+ QCOMPARE(a1StateChangedSpy.count(), 5); // Running,Paused,Stopped,Running,Stopped
+ QCOMPARE(seqStateChangedSpy.count(), 2); // Running,Paused
+
+ QVERIFY(compareStates(a1StateChangedSpy, (StateList() << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Paused
+ << QAbstractAnimationJob::Stopped
+ << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Stopped)));
+
+ //### is this the same test as compareStates test above?
+ QCOMPARE(a1StateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(a1StateChangedSpy.states.at(1), QAnimationGroupJob::Paused);
+ QCOMPARE(a1StateChangedSpy.states.at(2), QAnimationGroupJob::Stopped);
+ QCOMPARE(a1StateChangedSpy.states.at(3), QAnimationGroupJob::Running);
+ QCOMPARE(a1StateChangedSpy.states.at(4), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(seqStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(seqStateChangedSpy.states.at(1), QAnimationGroupJob::Paused);
+
+ group.resume();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Running);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Running);
+
+ QVERIFY(group.currentLoopTime() >= 1751);
+ QVERIFY(sequence->currentLoopTime() >= 751);
+ QCOMPARE(sequence->currentLoop(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
+ QVERIFY(a3_s_o1->currentLoopTime() >= 1);
+
+ QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running
+ QCOMPARE(seqStateChangedSpy.states.at(2), QAnimationGroupJob::Running);
+
+ group.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Paused);
+
+ QVERIFY(group.currentLoopTime() >= 1751);
+ QVERIFY(sequence->currentLoopTime() >= 751);
+ QCOMPARE(sequence->currentLoop(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
+ QVERIFY(a3_s_o1->currentLoopTime() >= 1);
+
+ QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused
+ QCOMPARE(seqStateChangedSpy.states.at(3), QAnimationGroupJob::Paused);
+
+ group.stop();
+
+ QCOMPARE(seqStateChangedSpy.count(), 5); // Running,Paused,Running,Paused,Stopped
+ QCOMPARE(seqStateChangedSpy.states.at(4), QAnimationGroupJob::Stopped);
+}
+
+void tst_QSequentialAnimationGroupJob::restart()
+{
+ // originally was sequence operating on same object/property
+ QAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
+ //### no equivilant signal
+ //QSignalSpy seqCurrentAnimChangedSpy(sequence, SIGNAL(currentAnimationChanged(QAbstractAnimationJob*)));
+
+ StateChangeListener seqStateChangedSpy;
+ sequence->addAnimationChangeListener(&seqStateChangedSpy, QAbstractAnimationJob::StateChange);
+
+ TestAnimation *anims[3];
+ StateChangeListener *animsStateChanged[3];
+
+ for (int i = 0; i < 3; i++) {
+ anims[i] = new TestAnimation(100);
+ animsStateChanged[i] = new StateChangeListener;
+ anims[i]->addAnimationChangeListener(animsStateChanged[i], QAbstractAnimationJob::StateChange);
+ }
+
+ anims[1]->setLoopCount(2);
+ sequence->appendAnimation(anims[0]);
+ sequence->appendAnimation(anims[1]);
+ sequence->appendAnimation(anims[2]);
+ sequence->setLoopCount(2);
+
+ QSequentialAnimationGroupJob group;
+ group.appendAnimation(sequence);
+
+ group.start();
+
+ QTest::qWait(500);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+
+ QTest::qWait(300);
+ QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped);
+
+ for (int i = 0; i < 3; i++) {
+ QCOMPARE(animsStateChanged[i]->count(), 4);
+ QCOMPARE(animsStateChanged[i]->states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(animsStateChanged[i]->states.at(1), QAnimationGroupJob::Stopped);
+ QCOMPARE(animsStateChanged[i]->states.at(2), QAnimationGroupJob::Running);
+ QCOMPARE(animsStateChanged[i]->states.at(3), QAnimationGroupJob::Stopped);
+ }
+
+ QCOMPARE(seqStateChangedSpy.count(), 2);
+ QCOMPARE(seqStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(seqStateChangedSpy.states.at(1), QAnimationGroupJob::Stopped);
+
+ //QCOMPARE(seqCurrentAnimChangedSpy.count(), 6);
+ //for(int i=0; i<seqCurrentAnimChangedSpy.count(); i++)
+ // QCOMPARE(static_cast<QAbstractAnimationJob*>(anims[i%3]), qVariantValue<QAbstractAnimationJob*>(seqCurrentAnimChangedSpy.at(i).at(0)));
+
+ group.start();
+
+ QCOMPARE(animsStateChanged[0]->count(), 5);
+ QCOMPARE(animsStateChanged[1]->count(), 4);
+ QCOMPARE(animsStateChanged[2]->count(), 4);
+ QCOMPARE(seqStateChangedSpy.count(), 3);
+}
+
+void tst_QSequentialAnimationGroupJob::looping()
+{
+ // originally was sequence operating on same object/property
+ QSequentialAnimationGroupJob *sequence = new QSequentialAnimationGroupJob();
+ QAbstractAnimationJob *a1_s_o1 = new TestAnimation;
+ QAbstractAnimationJob *a2_s_o1 = new TestAnimation;
+ QAbstractAnimationJob *a3_s_o1 = new TestAnimation;
+
+ StateChangeListener a1Spy;
+ a1_s_o1->addAnimationChangeListener(&a1Spy, QAbstractAnimationJob::StateChange);
+ StateChangeListener a2Spy;
+ a2_s_o1->addAnimationChangeListener(&a2Spy, QAbstractAnimationJob::StateChange);
+ StateChangeListener a3Spy;
+ a3_s_o1->addAnimationChangeListener(&a3Spy, QAbstractAnimationJob::StateChange);
+ StateChangeListener seqSpy;
+ sequence->addAnimationChangeListener(&seqSpy, QAbstractAnimationJob::StateChange);
+
+ a2_s_o1->setLoopCount(2);
+ sequence->appendAnimation(a1_s_o1);
+ sequence->appendAnimation(a2_s_o1);
+ sequence->appendAnimation(a3_s_o1);
+ sequence->setLoopCount(2);
+
+ QSequentialAnimationGroupJob group;
+ StateChangeListener groupSpy;
+ group.addAnimationChangeListener(&groupSpy, QAbstractAnimationJob::StateChange);
+
+ group.appendAnimation(sequence);
+ group.setLoopCount(2);
+
+ group.start();
+ group.pause();
+
+ // Current time = 1750
+ group.setCurrentTime(1750);
+ QCOMPARE(group.currentLoopTime(), 1750);
+ QCOMPARE(sequence->currentLoopTime(), 750);
+ QCOMPARE(sequence->currentLoop(), 1);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
+ // this animation is at the beginning because it is the current one inside sequence
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 0);
+ QCOMPARE(sequence->currentAnimation(), a3_s_o1);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Paused);
+
+ QCOMPARE(a1Spy.count(), 5); // Running,Paused,Stopped,Running,Stopped
+ QVERIFY(compareStates(a1Spy, (StateList() << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Paused
+ << QAbstractAnimationJob::Stopped
+ << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Stopped)));
+
+ QCOMPARE(a2Spy.count(), 4); // Running,Stopped,Running,Stopped
+ QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Stopped
+ << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Paused)));
+
+ QCOMPARE(seqSpy.count(), 2); // Running,Paused
+ QCOMPARE(groupSpy.count(), 2); // Running,Paused
+
+ // Looping, current time = duration + 1
+ group.setCurrentTime(group.duration() + 1);
+ QCOMPARE(group.currentLoopTime(), 1);
+ QCOMPARE(group.currentLoop(), 1);
+ QCOMPARE(sequence->currentLoopTime(), 1);
+ QCOMPARE(sequence->currentLoop(), 0);
+ QCOMPARE(a1_s_o1->currentLoopTime(), 1);
+ QCOMPARE(a2_s_o1->currentLoopTime(), 250);
+ QCOMPARE(a2_s_o1->currentLoop(), 1);
+ // this animation is at the end because it was run on the previous loop
+ QCOMPARE(a3_s_o1->currentLoop(), 0);
+ QCOMPARE(a3_s_o1->currentLoopTime(), 250);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(sequence->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(a1_s_o1->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(a2_s_o1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a3_s_o1->state(), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(a1Spy.count(), 7); // Running,Paused,Stopped,Running,Stopped,Running,Stopped
+ QCOMPARE(a2Spy.count(), 4); // Running, Stopped, Running, Stopped
+ QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Stopped
+ << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Paused
+ << QAbstractAnimationJob::Stopped)));
+ QVERIFY(compareStates(seqSpy, (StateList() << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Paused
+ << QAbstractAnimationJob::Stopped
+ << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Paused)));
+ QCOMPARE(groupSpy.count(), 2);
+
+ //cleanup
+ a1_s_o1->removeAnimationChangeListener(&a1Spy, QAbstractAnimationJob::StateChange);
+ a2_s_o1->removeAnimationChangeListener(&a2Spy, QAbstractAnimationJob::StateChange);
+ a3_s_o1->removeAnimationChangeListener(&a3Spy, QAbstractAnimationJob::StateChange);
+ sequence->removeAnimationChangeListener(&seqSpy, QAbstractAnimationJob::StateChange);
+ group.removeAnimationChangeListener(&groupSpy, QAbstractAnimationJob::StateChange);
+}
+
+void tst_QSequentialAnimationGroupJob::startDelay()
+{
+ QSequentialAnimationGroupJob group;
+ group.appendAnimation(new QPauseAnimationJob(250));
+ group.appendAnimation(new QPauseAnimationJob(125));
+ QCOMPARE(group.totalDuration(), 375);
+
+ group.start();
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+
+ QTest::qWait(500);
+
+ QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QVERIFY(group.currentLoopTime() == 375);
+}
+
+void tst_QSequentialAnimationGroupJob::clearGroup()
+{
+ QSequentialAnimationGroupJob group;
+
+ static const int animationCount = 20;
+
+ for (int i = 0; i < animationCount/2; ++i) {
+ QSequentialAnimationGroupJob *subGroup = new QSequentialAnimationGroupJob;
+ group.appendAnimation(subGroup);
+ group.appendAnimation(new QPauseAnimationJob(100));
+ subGroup->appendAnimation(new QPauseAnimationJob(10));
+ }
+
+ int count = 0;
+ for (QAbstractAnimationJob *anim = group.firstChild(); anim; anim = anim->nextSibling())
+ ++count;
+ QCOMPARE(count, animationCount);
+
+ group.clear();
+
+ QVERIFY(!group.firstChild() && !group.lastChild());
+ QCOMPARE(group.currentLoopTime(), 0);
+}
+
+void tst_QSequentialAnimationGroupJob::groupWithZeroDurationAnimations()
+{
+ QSequentialAnimationGroupJob group;
+
+ TestValueAnimation *a1 = new TestValueAnimation(0);
+ a1->start = 42;
+ a1->end = 43;
+ group.appendAnimation(a1);
+
+ //this should just run fine and change nothing
+ group.setCurrentTime(0);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(a1));
+
+ TestValueAnimation *a2 = new TestValueAnimation(500);
+ a2->start = 13;
+ a2->end = 31;
+ group.appendAnimation(a2);
+
+ TestValueAnimation *a3 = new TestValueAnimation(0);
+ a3->start = 43;
+ a3->end = 44;
+ group.appendAnimation(a3);
+
+ TestValueAnimation *a4 = new TestValueAnimation(250);
+ a4->start = 13;
+ a4->end = 75;
+ group.appendAnimation(a4);
+
+ TestValueAnimation *a5 = new TestValueAnimation(0);
+ a5->start = 42;
+ a5->end = 12;
+ group.appendAnimation(a5);
+
+ QCOMPARE((int)a1->value, 43); //### is this actually the behavior we want?
+ QCOMPARE((int)a2->value, 0);
+ QCOMPARE((int)a3->value, 0);
+ QCOMPARE((int)a4->value, 0);
+ QCOMPARE((int)a5->value, 0);
+
+ group.start();
+
+ QCOMPARE((int)a1->value, 43); //### is this actually the behavior we want?
+ QCOMPARE((int)a2->value, 13);
+ QCOMPARE((int)a3->value, 0);
+ QCOMPARE((int)a4->value, 0);
+ QCOMPARE((int)a5->value, 0);
+
+ QTest::qWait(100);
+
+ QCOMPARE((int)a1->value, 43);
+ QVERIFY(a2->value > 13 && a2->value < 31);
+ QCOMPARE((int)a3->value, 0);
+ QCOMPARE((int)a4->value, 0);
+ QCOMPARE((int)a5->value, 0);
+
+ QTest::qWait(500);
+
+ QTRY_COMPARE((int)a3->value, 44);
+ QCOMPARE((int)a1->value, 43);
+ QCOMPARE((int)a2->value, 31);
+ //QCOMPARE((int)a4->value, 36);
+ QCOMPARE((int)a5->value, 0);
+ QCOMPARE(a1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a3->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a4->state(), QAnimationGroupJob::Running);
+ QCOMPARE(a5->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QTest::qWait(500);
+
+ QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE((int)a1->value, 43);
+ QCOMPARE((int)a2->value, 31);
+ QCOMPARE((int)a3->value, 44);
+ QCOMPARE((int)a4->value, 75);
+ QCOMPARE((int)a5->value, 12);
+ QCOMPARE(a1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a2->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a3->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a4->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(a5->state(), QAnimationGroupJob::Stopped);
+}
+
+void tst_QSequentialAnimationGroupJob::propagateGroupUpdateToChildren()
+{
+ // this test verifies if group state changes are updating its children correctly
+ QSequentialAnimationGroupJob group;
+
+ TestAnimation anim1(100);
+ TestAnimation anim2(200);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+
+ group.start();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+}
+
+void tst_QSequentialAnimationGroupJob::updateChildrenWithRunningGroup()
+{
+ // assert that its possible to modify a child's state directly while their group is running
+ QSequentialAnimationGroupJob group;
+
+ TestAnimation anim(200);
+
+ StateChangeListener groupStateChangedSpy;
+ group.addAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
+ StateChangeListener childStateChangedSpy;
+ anim.addAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange);
+
+ QCOMPARE(groupStateChangedSpy.count(), 0);
+ QCOMPARE(childStateChangedSpy.count(), 0);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim);
+
+ group.start();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Running);
+
+ QCOMPARE(groupStateChangedSpy.count(), 1);
+ QCOMPARE(childStateChangedSpy.count(), 1);
+
+ QCOMPARE(groupStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(childStateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+
+ // starting directly a running child will not have any effect
+ anim.start();
+
+ QCOMPARE(groupStateChangedSpy.count(), 1);
+ QCOMPARE(childStateChangedSpy.count(), 1);
+
+ anim.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Paused);
+
+ // in the animation stops directly, the group will still be running
+ anim.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Stopped);
+
+ //cleanup
+ group.removeAnimationChangeListener(&groupStateChangedSpy, QAbstractAnimationJob::StateChange);
+ anim.removeAnimationChangeListener(&childStateChangedSpy, QAbstractAnimationJob::StateChange);
+}
+
+void tst_QSequentialAnimationGroupJob::deleteChildrenWithRunningGroup()
+{
+ // test if children can be activated when their group is stopped
+ QSequentialAnimationGroupJob group;
+
+ TestAnimation *anim1 = new TestAnimation(200);
+ group.appendAnimation(anim1);
+
+ QCOMPARE(group.duration(), anim1->duration());
+
+ group.start();
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Running);
+
+ QTest::qWait(100);
+ QTRY_VERIFY(group.currentLoopTime() > 0);
+
+ delete anim1;
+ QVERIFY(!group.firstChild());
+ QCOMPARE(group.duration(), 0);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(group.currentLoopTime(), 0); //that's the invariant
+}
+
+void tst_QSequentialAnimationGroupJob::startChildrenWithStoppedGroup()
+{
+ // test if children can be activated when their group is stopped
+ QSequentialAnimationGroupJob group;
+
+ TestAnimation anim1(200);
+ TestAnimation anim2(200);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ anim1.start();
+ anim2.start();
+ anim2.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
+}
+
+void tst_QSequentialAnimationGroupJob::stopGroupWithRunningChild()
+{
+ // children that started independently will not be affected by a group stop
+ QSequentialAnimationGroupJob group;
+
+ TestAnimation anim1(200);
+ TestAnimation anim2(200);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(&anim1);
+ group.appendAnimation(&anim2);
+
+ anim1.start();
+ anim2.start();
+ anim2.pause();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Paused);
+
+ anim1.stop();
+ anim2.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2.state(), QAnimationGroupJob::Stopped);
+}
+
+void tst_QSequentialAnimationGroupJob::startGroupWithRunningChild()
+{
+ // as the group has precedence over its children, starting a group will restart all the children
+ QSequentialAnimationGroupJob group;
+
+ TestAnimation *anim1 = new TestAnimation(200);
+ TestAnimation *anim2 = new TestAnimation(200);
+
+ StateChangeListener stateChangedSpy1;
+ anim1->addAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
+ StateChangeListener stateChangedSpy2;
+ anim2->addAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
+
+ QCOMPARE(stateChangedSpy1.count(), 0);
+ QCOMPARE(stateChangedSpy2.count(), 0);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2->state(), QAnimationGroupJob::Stopped);
+
+ group.appendAnimation(anim1);
+ group.appendAnimation(anim2);
+
+ anim1->start();
+ anim2->start();
+ anim2->pause();
+
+ QVERIFY(compareStates(stateChangedSpy1, (StateList() << QAbstractAnimationJob::Running)));
+
+ QVERIFY(compareStates(stateChangedSpy2, (StateList() << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Paused)));
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2->state(), QAnimationGroupJob::Paused);
+
+ group.start();
+
+ QVERIFY(compareStates(stateChangedSpy1, (StateList() << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Stopped
+ << QAbstractAnimationJob::Running)));
+ QVERIFY(compareStates(stateChangedSpy2, (StateList() << QAbstractAnimationJob::Running
+ << QAbstractAnimationJob::Paused)));
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim2->state(), QAnimationGroupJob::Paused);
+
+ QTest::qWait(300);
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2->state(), QAnimationGroupJob::Running);
+
+ QCOMPARE(stateChangedSpy2.count(), 4);
+ QCOMPARE(stateChangedSpy2.states.at(2), QAnimationGroupJob::Stopped);
+ QCOMPARE(stateChangedSpy2.states.at(3), QAnimationGroupJob::Running);
+
+ group.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2->state(), QAnimationGroupJob::Stopped);
+
+ anim1->removeAnimationChangeListener(&stateChangedSpy1, QAbstractAnimationJob::StateChange);
+ anim2->removeAnimationChangeListener(&stateChangedSpy2, QAbstractAnimationJob::StateChange);
+}
+
+void tst_QSequentialAnimationGroupJob::zeroDurationAnimation()
+{
+ QSequentialAnimationGroupJob group;
+
+ TestAnimation *anim1 = new TestAnimation(0);
+ TestAnimation *anim2 = new TestAnimation(100);
+ TestValueAnimation *anim3 = new TestValueAnimation(0);
+ anim3->end = 100;
+
+ StateChangeListener stateChangedSpy;
+ anim1->addAnimationChangeListener(&stateChangedSpy, QAbstractAnimationJob::StateChange);
+
+ group.appendAnimation(anim1);
+ group.appendAnimation(anim2);
+ group.appendAnimation(anim3);
+ group.setLoopCount(2);
+ group.start();
+
+ QCOMPARE(stateChangedSpy.count(), 2);
+ QCOMPARE(stateChangedSpy.states.at(0), QAnimationGroupJob::Running);
+ QCOMPARE(stateChangedSpy.states.at(1), QAnimationGroupJob::Stopped);
+
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2->state(), QAnimationGroupJob::Running);
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+
+ //now let's try to seek to the next loop
+ group.setCurrentTime(group.duration() + 1);
+ QCOMPARE(anim1->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim2->state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim3->state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ //TODO: test that anim3 was run
+ QCOMPARE(anim3->value, qreal(100)); //anim3 should have been run
+
+ anim1->removeAnimationChangeListener(&stateChangedSpy, QAbstractAnimationJob::StateChange);
+}
+
+void tst_QSequentialAnimationGroupJob::stopUncontrolledAnimations()
+{
+ QSequentialAnimationGroupJob group;
+
+ UncontrolledAnimation notTimeDriven;
+ QCOMPARE(notTimeDriven.totalDuration(), -1);
+
+ TestAnimation loopsForever(100);
+ loopsForever.setLoopCount(-1);
+
+ group.appendAnimation(&notTimeDriven);
+ group.appendAnimation(&loopsForever);
+
+ group.start();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running);
+ QCOMPARE(loopsForever.state(), QAnimationGroupJob::Stopped);
+
+ notTimeDriven.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever.state(), QAnimationGroupJob::Running);
+
+ loopsForever.stop();
+
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(loopsForever.state(), QAnimationGroupJob::Stopped);
+}
+
+void tst_QSequentialAnimationGroupJob::finishWithUncontrolledAnimation()
+{
+ //1st case:
+ //first we test a group with one uncontrolled animation
+ QSequentialAnimationGroupJob group;
+ UncontrolledAnimation notTimeDriven;
+ group.appendAnimation(&notTimeDriven);
+ FinishedListener spy;
+ group.addAnimationChangeListener(&spy, QAbstractAnimationJob::Completion);
+
+ group.start();
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running);
+ QCOMPARE(group.currentLoopTime(), 0);
+ QCOMPARE(notTimeDriven.currentLoopTime(), 0);
+
+ QTest::qWait(300); //wait for the end of notTimeDriven
+ QTRY_COMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
+ const int actualDuration = notTimeDriven.currentLoopTime();
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(group.currentLoopTime(), actualDuration);
+ QCOMPARE(spy.count(), 1);
+
+ //2nd case:
+ // lets make sure the seeking will work again
+ spy.clear();
+ TestAnimation anim;
+ group.appendAnimation(&anim);
+ StateChangeListener animStateChangedSpy;
+ anim.addAnimationChangeListener(&animStateChangedSpy, QAbstractAnimationJob::StateChange);
+
+ group.setCurrentTime(300);
+ QCOMPARE(group.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(notTimeDriven.currentLoopTime(), actualDuration);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
+
+ //3rd case:
+ //now let's add a perfectly defined animation at the end
+ QCOMPARE(animStateChangedSpy.count(), 0);
+ group.start();
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(notTimeDriven.state(), QAnimationGroupJob::Running);
+ QCOMPARE(group.currentLoopTime(), 0);
+ QCOMPARE(notTimeDriven.currentLoopTime(), 0);
+
+ QCOMPARE(animStateChangedSpy.count(), 0);
+
+ QTest::qWait(300); //wait for the end of notTimeDriven
+ QTRY_COMPARE(notTimeDriven.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim.state(), QAnimationGroupJob::Running);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
+ QCOMPARE(animStateChangedSpy.count(), 1);
+ QTest::qWait(300); //wait for the end of anim
+
+ QTRY_COMPARE(anim.state(), QAnimationGroupJob::Stopped);
+ QCOMPARE(anim.currentLoopTime(), anim.duration());
+
+ //we should simply be at the end
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(animStateChangedSpy.count(), 2);
+ QCOMPARE(group.currentLoopTime(), notTimeDriven.currentLoopTime() + anim.currentLoopTime());
+
+ //cleanup
+ group.removeAnimationChangeListener(&spy, QAbstractAnimationJob::Completion);
+ anim.removeAnimationChangeListener(&animStateChangedSpy, QAbstractAnimationJob::StateChange);
+}
+
+void tst_QSequentialAnimationGroupJob::addRemoveAnimation()
+{
+ //this test is specific to the sequential animation group
+ QSequentialAnimationGroupJob group;
+
+ QCOMPARE(group.duration(), 0);
+ QCOMPARE(group.currentLoopTime(), 0);
+ QAbstractAnimationJob *anim1 = new TestAnimation;
+ group.appendAnimation(anim1);
+ QCOMPARE(group.duration(), 250);
+ QCOMPARE(group.currentLoopTime(), 0);
+ QCOMPARE(group.currentAnimation(), anim1);
+
+ //let's append an animation
+ QAbstractAnimationJob *anim2 = new TestAnimation;
+ group.appendAnimation(anim2);
+ QCOMPARE(group.duration(), 500);
+ QCOMPARE(group.currentLoopTime(), 0);
+ QCOMPARE(group.currentAnimation(), anim1);
+
+ //let's prepend an animation
+ QAbstractAnimationJob *anim0 = new TestAnimation;
+ group.prependAnimation(anim0);
+ QCOMPARE(group.duration(), 750);
+ QCOMPARE(group.currentLoopTime(), 0);
+ QCOMPARE(group.currentAnimation(), anim0); //anim0 has become the new currentAnimation
+
+ group.setCurrentTime(300); //anim0 | anim1 | anim2
+ QCOMPARE(group.currentLoopTime(), 300);
+ QCOMPARE(group.currentAnimation(), anim1);
+ QCOMPARE(anim1->currentLoopTime(), 50);
+
+ group.removeAnimation(anim0); //anim1 | anim2
+ QCOMPARE(group.currentLoopTime(), 50);
+ QCOMPARE(group.currentAnimation(), anim1);
+ QCOMPARE(anim1->currentLoopTime(), 50);
+
+ group.setCurrentTime(0);
+ group.prependAnimation(anim0); //anim0 | anim1 | anim2
+ group.setCurrentTime(300);
+ QCOMPARE(group.currentLoopTime(), 300);
+ QCOMPARE(group.currentAnimation(), anim1);
+ QCOMPARE(anim1->currentLoopTime(), 50);
+
+ group.removeAnimation(anim1); //anim0 | anim2
+ QCOMPARE(group.currentLoopTime(), 250);
+ QCOMPARE(group.currentAnimation(), anim2);
+ QCOMPARE(anim0->currentLoopTime(), 250);
+}
+
+void tst_QSequentialAnimationGroupJob::currentAnimation()
+{
+ QSequentialAnimationGroupJob group;
+ QVERIFY(group.currentAnimation() == 0);
+
+ TestAnimation anim(0);
+ group.appendAnimation(&anim);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
+}
+
+void tst_QSequentialAnimationGroupJob::currentAnimationWithZeroDuration()
+{
+ QSequentialAnimationGroupJob group;
+ QVERIFY(group.currentAnimation() == 0);
+
+ TestAnimation zero1(0);
+ TestAnimation zero2(0);
+
+ TestAnimation anim;
+
+ TestAnimation zero3(0);
+ TestAnimation zero4(0);
+
+ group.appendAnimation(&zero1);
+ group.appendAnimation(&zero2);
+ group.appendAnimation(&anim);
+ group.appendAnimation(&zero3);
+ group.appendAnimation(&zero4);
+
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&zero1));
+
+ group.setCurrentTime(0);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
+
+ group.setCurrentTime(group.duration());
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&zero4));
+
+ group.setDirection(QAbstractAnimationJob::Backward);
+
+ group.setCurrentTime(0);
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&zero1));
+
+ group.setCurrentTime(group.duration());
+ QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimationJob*>(&anim));
+}
+
+void tst_QSequentialAnimationGroupJob::insertAnimation()
+{
+ QSequentialAnimationGroupJob group;
+ group.setLoopCount(2);
+ TestAnimation *anim = new TestAnimation;
+ group.appendAnimation(anim);
+ QCOMPARE(group.duration(), anim->duration());
+ group.setCurrentTime(300);
+ QCOMPARE(group.currentLoop(), 1);
+
+ //this will crash if the sequential group calls duration on the created animation
+ group.appendAnimation(new TestAnimation);
+}
+
+class ClearFinishedListener: public QAnimationJobChangeListener
+{
+public:
+ ClearFinishedListener(QSequentialAnimationGroupJob *g) : group(g) {}
+
+ virtual void animationFinished(QAbstractAnimationJob *)
+ {
+ group->clear();
+ }
+
+ QSequentialAnimationGroupJob *group;
+};
+
+class RefillFinishedListener: public QAnimationJobChangeListener
+{
+public:
+ RefillFinishedListener(QSequentialAnimationGroupJob *g) : group(g) {}
+
+ virtual void animationFinished(QAbstractAnimationJob *)
+ {
+ group->stop();
+ group->clear();
+ group->appendAnimation(new TestAnimation);
+ group->start();
+ }
+
+ QSequentialAnimationGroupJob *group;
+};
+
+void tst_QSequentialAnimationGroupJob::clear()
+{
+ QSKIP("deleting an animation when finished is not currently supported");
+ QSequentialAnimationGroupJob group;
+ TestAnimation *anim1 = new TestAnimation;
+ group.appendAnimation(anim1);
+ ClearFinishedListener clearListener(&group);
+ anim1->addAnimationChangeListener(&clearListener, QAbstractAnimationJob::Completion);
+
+ TestAnimation *anim2 = new TestAnimation;
+ group.appendAnimation(anim2);
+ QCOMPARE(group.firstChild(), anim1);
+ QCOMPARE(group.lastChild(), anim2);
+
+ group.start();
+ QTest::qWait(anim1->duration() + 100);
+ QTRY_VERIFY(!group.firstChild());
+ QCOMPARE(group.state(), QAbstractAnimationJob::Stopped);
+ QCOMPARE(group.currentLoopTime(), 0);
+
+ anim1 = new TestAnimation;
+ group.appendAnimation(anim1);
+ RefillFinishedListener refillListener(&group);
+ anim1->addAnimationChangeListener(&refillListener, QAbstractAnimationJob::Completion);
+ group.start();
+ QTest::qWait(anim1->duration() + 100);
+ QTRY_COMPARE(group.state(), QAbstractAnimationJob::Running);
+}
+
+void tst_QSequentialAnimationGroupJob::pauseResume()
+{
+ QParallelAnimationGroupJob group;
+ TestAnimation *anim = new TestAnimation;
+ group.appendAnimation(anim);
+ StateChangeListener spy;
+ anim->addAnimationChangeListener(&spy, QAbstractAnimationJob::StateChange);
+ QCOMPARE(group.duration(), 250);
+ group.start();
+ QTest::qWait(100);
+ QTRY_COMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim->state(), QAnimationGroupJob::Running);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ const int currentTime = group.currentLoopTime();
+ QCOMPARE(anim->currentLoopTime(), currentTime);
+
+ group.pause();
+ QCOMPARE(group.state(), QAnimationGroupJob::Paused);
+ QCOMPARE(group.currentLoopTime(), currentTime);
+ QCOMPARE(anim->state(), QAnimationGroupJob::Paused);
+ QCOMPARE(anim->currentLoopTime(), currentTime);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+
+ group.resume();
+ QCOMPARE(group.state(), QAnimationGroupJob::Running);
+ QCOMPARE(group.currentLoopTime(), currentTime);
+ QCOMPARE(anim->state(), QAnimationGroupJob::Running);
+ QCOMPARE(anim->currentLoopTime(), currentTime);
+ QCOMPARE(spy.count(), 1);
+
+ anim->removeAnimationChangeListener(&spy, QAbstractAnimationJob::StateChange);
+}
+
+QTEST_MAIN(tst_QSequentialAnimationGroupJob)
+#include "tst_qsequentialanimationgroupjob.moc"
diff --git a/tests/auto/qml/debugger/debugger.pro b/tests/auto/qml/debugger/debugger.pro
new file mode 100644
index 0000000000..4f9ebbc350
--- /dev/null
+++ b/tests/auto/qml/debugger/debugger.pro
@@ -0,0 +1,16 @@
+TEMPLATE = subdirs
+
+PRIVATETESTS += \
+ qqmlenginedebug \
+ qqmldebugclient \
+ qqmldebugservice \
+ qqmldebugjs \
+ qqmlinspector \
+ qqmlprofilerservice \
+ qpacketprotocol \
+ qv8profilerservice \
+ qdebugmessageservice
+
+contains(QT_CONFIG, private_tests) {
+ SUBDIRS += $$PRIVATETESTS
+}
diff --git a/tests/auto/declarative/debugger/qdebugmessageservice/data/test.qml b/tests/auto/qml/debugger/qdebugmessageservice/data/test.qml
index ab86c7d468..ab86c7d468 100644
--- a/tests/auto/declarative/debugger/qdebugmessageservice/data/test.qml
+++ b/tests/auto/qml/debugger/qdebugmessageservice/data/test.qml
diff --git a/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro b/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro
new file mode 100644
index 0000000000..afda4b23bd
--- /dev/null
+++ b/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro
@@ -0,0 +1,21 @@
+CONFIG += testcase
+TARGET = tst_qdebugmessageservice
+QT += network qml-private testlib
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+
+SOURCES += tst_qdebugmessageservice.cpp \
+ ../shared/debugutil.cpp
+
+INCLUDEPATH += ../shared
+
+include(../../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+OTHER_FILES += data/test.qml
diff --git a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp
new file mode 100644
index 0000000000..a19fd4b766
--- /dev/null
+++ b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp
@@ -0,0 +1,242 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtQml/private/qqmldebugclient_p.h>
+
+//QQmlDebugTest
+#include "../shared/debugutil_p.h"
+#include "../../../shared/util.h"
+
+#include <QtCore/QString>
+#include <QtTest/QtTest>
+
+const char *NORMALMODE = "-qmljsdebugger=port:3777,block";
+const char *QMLFILE = "test.qml";
+
+class QQmlDebugMsgClient;
+class tst_QDebugMessageService : public QQmlDataTest
+{
+ Q_OBJECT
+
+public:
+ tst_QDebugMessageService();
+
+ void init();
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void cleanup();
+
+ void retrieveDebugOutput();
+
+private:
+ QQmlDebugProcess *m_process;
+ QQmlDebugMsgClient *m_client;
+ QQmlDebugConnection *m_connection;
+};
+
+struct LogEntry {
+ LogEntry(QtMsgType _type, QString _message)
+ : type(_type), message(_message) {}
+
+ QtMsgType type;
+ QString message;
+ int line;
+ QString file;
+ QString function;
+
+ QString toString() const { return QString::number(type) + ": " + message; }
+};
+
+bool operator==(const LogEntry &t1, const LogEntry &t2)
+{
+ return t1.type == t2.type && t1.message == t2.message
+ && t1.line == t2.line && t1.file == t2.file
+ && t1.function == t2.function;
+}
+
+class QQmlDebugMsgClient : public QQmlDebugClient
+{
+ Q_OBJECT
+public:
+ QQmlDebugMsgClient(QQmlDebugConnection *connection)
+ : QQmlDebugClient(QLatin1String("DebugMessages"), connection)
+ {
+ }
+
+ QList<LogEntry> logBuffer;
+
+protected:
+ //inherited from QQmlDebugClient
+ void stateChanged(State state);
+ void messageReceived(const QByteArray &data);
+
+signals:
+ void enabled();
+ void debugOutput();
+};
+
+void QQmlDebugMsgClient::stateChanged(State state)
+{
+ if (state == Enabled) {
+ emit enabled();
+ }
+}
+
+void QQmlDebugMsgClient::messageReceived(const QByteArray &data)
+{
+ QDataStream ds(data);
+ QByteArray command;
+ ds >> command;
+
+ if (command == "MESSAGE") {
+ int type;
+ QByteArray message;
+ QByteArray file;
+ QByteArray function;
+ int line;
+ ds >> type >> message >> file >> line >> function;
+ QVERIFY(ds.atEnd());
+
+ QVERIFY(type >= QtDebugMsg);
+ QVERIFY(type <= QtFatalMsg);
+
+ LogEntry entry((QtMsgType)type, QString::fromUtf8(message));
+ entry.line = line;
+ entry.file = QString::fromUtf8(file);
+ entry.function = QString::fromUtf8(function);
+ logBuffer << entry;
+ emit debugOutput();
+ } else {
+ QFAIL("Unknown message");
+ }
+}
+
+tst_QDebugMessageService::tst_QDebugMessageService()
+{
+}
+
+void tst_QDebugMessageService::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ m_process = 0;
+ m_client = 0;
+ m_connection = 0;
+}
+
+void tst_QDebugMessageService::cleanupTestCase()
+{
+ if (m_process)
+ delete m_process;
+
+ if (m_client)
+ delete m_client;
+
+ if (m_connection)
+ delete m_connection;
+}
+
+void tst_QDebugMessageService::init()
+{
+ m_connection = new QQmlDebugConnection();
+ m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene");
+ m_client = new QQmlDebugMsgClient(m_connection);
+
+ m_process->start(QStringList() << QLatin1String(NORMALMODE) << QQmlDataTest::instance()->testFile(QMLFILE));
+ if (!m_process->waitForSessionStart()) {
+ QFAIL(QString("Could not launch app. Application output: \n%1").arg(m_process->output()).toAscii());
+ }
+
+ m_connection->connectToHost("127.0.0.1", 3777);
+ QVERIFY(m_connection->waitForConnected());
+
+ QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(enabled())));
+}
+
+void tst_QDebugMessageService::cleanup()
+{
+ if (QTest::currentTestFailed())
+ qDebug() << m_process->output();
+ if (m_process)
+ delete m_process;
+
+ if (m_client)
+ delete m_client;
+
+ if (m_connection)
+ delete m_connection;
+
+ m_process = 0;
+ m_client = 0;
+ m_connection = 0;
+}
+
+void tst_QDebugMessageService::retrieveDebugOutput()
+{
+ init();
+
+ int maxTries = 2;
+ while ((m_client->logBuffer.size() < 2)
+ || (maxTries-- > 0))
+ QQmlDebugTest::waitForSignal(m_client, SIGNAL(debugOutput()), 1000);
+
+ QVERIFY(m_client->logBuffer.size() >= 2);
+
+ const QString path =
+ QUrl::fromLocalFile(QQmlDataTest::instance()->testFile(QMLFILE)).toString();
+ LogEntry entry1(QtDebugMsg, QLatin1String("console.log"));
+ entry1.line = 48;
+ entry1.file = path;
+ entry1.function = QLatin1String("onCompleted");
+ LogEntry entry2(QtDebugMsg, QLatin1String("console.count: 1"));
+ entry2.line = 49;
+ entry2.file = path;
+ entry2.function = QLatin1String("onCompleted");
+
+ QVERIFY(m_client->logBuffer.contains(entry1));
+ QVERIFY(m_client->logBuffer.contains(entry2));
+}
+
+QTEST_MAIN(tst_QDebugMessageService)
+
+#include "tst_qdebugmessageservice.moc"
diff --git a/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro b/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro
new file mode 100644
index 0000000000..88439196a7
--- /dev/null
+++ b/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro
@@ -0,0 +1,10 @@
+CONFIG += testcase
+TARGET = tst_qpacketprotocol
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qpacketprotocol.cpp \
+ ../shared/debugutil.cpp
+
+CONFIG += parallel_test
+QT += qml-private network testlib
diff --git a/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp b/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp
new file mode 100644
index 0000000000..c02dd2d8fa
--- /dev/null
+++ b/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp
@@ -0,0 +1,263 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <QTimer>
+#include <QTcpSocket>
+#include <QTcpServer>
+#include <QDebug>
+#include <QBuffer>
+
+#include <private/qpacketprotocol_p.h>
+
+#include "../shared/debugutil_p.h"
+
+class tst_QPacketProtocol : public QObject
+{
+ Q_OBJECT
+
+private:
+ QTcpServer *m_server;
+ QTcpSocket *m_client;
+ QTcpSocket *m_serverConn;
+
+private slots:
+ void init();
+ void cleanup();
+
+ void maximumPacketSize();
+ void setMaximumPacketSize();
+ void setMaximumPacketSize_data();
+ void send();
+ void send_data();
+ void packetsAvailable();
+ void packetsAvailable_data();
+ void clear();
+ void read();
+ void device();
+
+ void tst_QPacket_clear();
+};
+
+void tst_QPacketProtocol::init()
+{
+ m_server = new QTcpServer(this);
+ m_serverConn = 0;
+ QVERIFY(m_server->listen(QHostAddress("127.0.0.1")));
+
+ m_client = new QTcpSocket(this);
+ m_client->connectToHost(m_server->serverAddress(), m_server->serverPort());
+
+ QVERIFY(m_client->waitForConnected());
+ QVERIFY(m_server->waitForNewConnection(5000));
+ m_serverConn = m_server->nextPendingConnection();
+}
+
+void tst_QPacketProtocol::cleanup()
+{
+ delete m_client;
+ delete m_serverConn;
+ delete m_server;
+}
+
+void tst_QPacketProtocol::maximumPacketSize()
+{
+ QPacketProtocol p(m_client);
+ QCOMPARE(p.maximumPacketSize(), 0x7FFFFFFF);
+}
+
+void tst_QPacketProtocol::setMaximumPacketSize()
+{
+ QFETCH(qint32, size);
+ QFETCH(qint32, expected);
+
+ QPacketProtocol out(m_serverConn);
+ QCOMPARE(out.setMaximumPacketSize(size), expected);
+}
+
+void tst_QPacketProtocol::setMaximumPacketSize_data()
+{
+ QTest::addColumn<int>("size");
+ QTest::addColumn<int>("expected");
+
+ QTest::newRow("invalid") << qint32(sizeof(qint32) - 1) << qint32(0x7FFFFFFF);
+ QTest::newRow("still invalid") << qint32(sizeof(qint32)) << qint32(0x7FFFFFFF);
+ QTest::newRow("valid") << qint32(sizeof(qint32) + 1) << qint32(sizeof(qint32) + 1);
+}
+
+void tst_QPacketProtocol::send()
+{
+ QFETCH(bool, useAutoSend);
+
+ QPacketProtocol in(m_client);
+ QPacketProtocol out(m_serverConn);
+
+ QByteArray ba;
+ int num;
+
+ if (useAutoSend) {
+ out.send() << "Hello world" << 123;
+ } else {
+ QPacket packet;
+ packet << "Hello world" << 123;
+ out.send(packet);
+ }
+
+ QVERIFY(QQmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+
+ QPacket p = in.read();
+ p >> ba >> num;
+ QCOMPARE(ba, QByteArray("Hello world") + '\0');
+ QCOMPARE(num, 123);
+}
+
+void tst_QPacketProtocol::send_data()
+{
+ QTest::addColumn<bool>("useAutoSend");
+
+ QTest::newRow("auto send") << true;
+ QTest::newRow("no auto send") << false;
+}
+
+void tst_QPacketProtocol::packetsAvailable()
+{
+ QFETCH(int, packetCount);
+
+ QPacketProtocol out(m_client);
+ QPacketProtocol in(m_serverConn);
+
+ QCOMPARE(out.packetsAvailable(), qint64(0));
+ QCOMPARE(in.packetsAvailable(), qint64(0));
+
+ for (int i=0; i<packetCount; i++)
+ out.send() << "Hello";
+
+ QVERIFY(QQmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+ QCOMPARE(in.packetsAvailable(), qint64(packetCount));
+}
+
+void tst_QPacketProtocol::packetsAvailable_data()
+{
+ QTest::addColumn<int>("packetCount");
+
+ QTest::newRow("1") << 1;
+ QTest::newRow("2") << 2;
+ QTest::newRow("10") << 10;
+}
+
+void tst_QPacketProtocol::clear()
+{
+ QPacketProtocol in(m_client);
+ QPacketProtocol out(m_serverConn);
+
+ out.send() << 123;
+ out.send() << 456;
+ QVERIFY(QQmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+
+ in.clear();
+ QVERIFY(in.read().isEmpty());
+}
+
+void tst_QPacketProtocol::read()
+{
+ QPacketProtocol in(m_client);
+ QPacketProtocol out(m_serverConn);
+
+ QVERIFY(in.read().isEmpty());
+
+ out.send() << 123;
+ out.send() << 456;
+ QVERIFY(QQmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+
+ int num;
+
+ QPacket p1 = in.read();
+ QVERIFY(!p1.isEmpty());
+ p1 >> num;
+ QCOMPARE(num, 123);
+
+ QPacket p2 = in.read();
+ QVERIFY(!p2.isEmpty());
+ p2 >> num;
+ QCOMPARE(num, 456);
+
+ QVERIFY(in.read().isEmpty());
+}
+
+void tst_QPacketProtocol::device()
+{
+ QPacketProtocol p(m_client);
+ QVERIFY(p.device() == m_client);
+}
+
+void tst_QPacketProtocol::tst_QPacket_clear()
+{
+ QPacketProtocol protocol(m_client);
+
+ QPacket packet;
+
+ packet << "Hello world!" << 123;
+ protocol.send(packet);
+
+ packet.clear();
+ QVERIFY(packet.isEmpty());
+ packet << "Goodbyte world!" << 789;
+ protocol.send(packet);
+
+ QByteArray ba;
+ int num;
+ QPacketProtocol in(m_serverConn);
+ QVERIFY(QQmlDebugTest::waitForSignal(&in, SIGNAL(readyRead())));
+
+ QPacket p1 = in.read();
+ p1 >> ba >> num;
+ QCOMPARE(ba, QByteArray("Hello world!") + '\0');
+ QCOMPARE(num, 123);
+
+ QPacket p2 = in.read();
+ p2 >> ba >> num;
+ QCOMPARE(ba, QByteArray("Goodbyte world!") + '\0');
+ QCOMPARE(num, 789);
+}
+
+QTEST_MAIN(tst_QPacketProtocol)
+
+#include "tst_qpacketprotocol.moc"
diff --git a/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro b/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro
new file mode 100644
index 0000000000..d298b5c087
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmldebugclient/qqmldebugclient.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TARGET = tst_qqmldebugclient
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qqmldebugclient.cpp \
+ ../shared/debugutil.cpp
+
+CONFIG += declarative_debug
+
+QT += qml-private testlib
diff --git a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
new file mode 100644
index 0000000000..2891076af6
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <QTimer>
+#include <QHostAddress>
+#include <QDebug>
+#include <QThread>
+
+#include <QtQml/qqmlengine.h>
+
+#include "../shared/debugutil_p.h"
+
+#define PORT 13770
+#define STR_PORT "13770"
+
+class tst_QQmlDebugClient : public QObject
+{
+ Q_OBJECT
+
+private:
+ QQmlDebugConnection *m_conn;
+
+private slots:
+ void initTestCase();
+
+ void name();
+ void state();
+ void sendMessage();
+ void parallelConnect();
+ void sequentialConnect();
+};
+
+void tst_QQmlDebugClient::initTestCase()
+{
+ const QString waitingMsg = QString("QQmlDebugServer: Waiting for connection on port %1...").arg(PORT);
+ QTest::ignoreMessage(QtWarningMsg, waitingMsg.toAscii().constData());
+ new QQmlEngine(this);
+
+ m_conn = new QQmlDebugConnection(this);
+
+ QQmlDebugTestClient client("tst_QQmlDebugClient::handshake()", m_conn);
+ QQmlDebugTestService service("tst_QQmlDebugClient::handshake()");
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Connection established");
+ for (int i = 0; i < 50; ++i) {
+ // try for 5 seconds ...
+ m_conn->connectToHost("127.0.0.1", PORT);
+ if (m_conn->waitForConnected())
+ break;
+ QTest::qSleep(100);
+ }
+
+ QVERIFY(m_conn->isConnected());
+
+ QTRY_VERIFY(QQmlDebugService::hasDebuggingClient());
+ QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
+}
+
+void tst_QQmlDebugClient::name()
+{
+ QString name = "tst_QQmlDebugClient::name()";
+
+ QQmlDebugClient client(name, m_conn);
+ QCOMPARE(client.name(), name);
+}
+
+void tst_QQmlDebugClient::state()
+{
+ {
+ QQmlDebugConnection dummyConn;
+ QQmlDebugClient client("tst_QQmlDebugClient::state()", &dummyConn);
+ QCOMPARE(client.state(), QQmlDebugClient::NotConnected);
+ QCOMPARE(client.serviceVersion(), -1.0f);
+ }
+
+ QQmlDebugTestClient client("tst_QQmlDebugClient::state()", m_conn);
+ QCOMPARE(client.state(), QQmlDebugClient::Unavailable);
+
+ {
+ QQmlDebugTestService service("tst_QQmlDebugClient::state()", 2);
+ QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
+ QCOMPARE(client.serviceVersion(), 2.0f);
+ }
+
+ QTRY_COMPARE(client.state(), QQmlDebugClient::Unavailable);
+
+ // duplicate plugin name
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugClient: Conflicting plugin name \"tst_QQmlDebugClient::state()\" ");
+ QQmlDebugClient client2("tst_QQmlDebugClient::state()", m_conn);
+ QCOMPARE(client2.state(), QQmlDebugClient::NotConnected);
+
+ QQmlDebugClient client3("tst_QQmlDebugClient::state3()", 0);
+ QCOMPARE(client3.state(), QQmlDebugClient::NotConnected);
+}
+
+void tst_QQmlDebugClient::sendMessage()
+{
+ QQmlDebugTestService service("tst_QQmlDebugClient::sendMessage()");
+ QQmlDebugTestClient client("tst_QQmlDebugClient::sendMessage()", m_conn);
+
+ QByteArray msg = "hello!";
+
+ QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
+
+ client.sendMessage(msg);
+ QByteArray resp = client.waitForResponse();
+ QCOMPARE(resp, msg);
+}
+
+void tst_QQmlDebugClient::parallelConnect()
+{
+ QQmlDebugConnection connection2;
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Another client is already connected");
+ // will connect & immediately disconnect
+ connection2.connectToHost("127.0.0.1", PORT);
+ QVERIFY(connection2.waitForConnected());
+ QTRY_COMPARE(connection2.state(), QAbstractSocket::UnconnectedState);
+ QVERIFY(m_conn->isConnected());
+}
+
+void tst_QQmlDebugClient::sequentialConnect()
+{
+ QQmlDebugConnection connection2;
+ QQmlDebugTestClient client2("tst_QQmlDebugClient::handshake()", &connection2);
+ QQmlDebugTestService service("tst_QQmlDebugClient::handshake()");
+
+ m_conn->close();
+ QVERIFY(!m_conn->isConnected());
+ QCOMPARE(m_conn->state(), QAbstractSocket::UnconnectedState);
+
+ // Make sure that the disconnect is actually delivered to the server
+ QTest::qWait(100);
+
+ connection2.connectToHost("127.0.0.1", PORT);
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Connection established");
+ QVERIFY(connection2.waitForConnected());
+ QVERIFY(connection2.isConnected());
+ QTRY_VERIFY(client2.state() == QQmlDebugClient::Enabled);
+}
+
+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];
+ char arg[] = "-qmljsdebugger=port:" STR_PORT;
+ _argv[_argc - 1] = arg;
+
+ QGuiApplication app(_argc, _argv);
+ tst_QQmlDebugClient tc;
+ return QTest::qExec(&tc, _argc, _argv);
+ delete _argv;
+}
+
+#include "tst_qqmldebugclient.moc"
+
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/breakpointRelocation.qml b/tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml
index 1f0f9e22c9..1f0f9e22c9 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/breakpointRelocation.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/breakpointRelocation.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/changeBreakpoint.qml b/tests/auto/qml/debugger/qqmldebugjs/data/changeBreakpoint.qml
index fd81b3f805..fd81b3f805 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/changeBreakpoint.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/changeBreakpoint.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/condition.qml b/tests/auto/qml/debugger/qqmldebugjs/data/condition.qml
index ad4144be11..ad4144be11 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/condition.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/condition.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/createComponent.qml b/tests/auto/qml/debugger/qqmldebugjs/data/createComponent.qml
index 993f33a661..993f33a661 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/createComponent.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/createComponent.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/exception.qml b/tests/auto/qml/debugger/qqmldebugjs/data/exception.qml
index b491087a02..b491087a02 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/exception.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/exception.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/loadjsfile.qml b/tests/auto/qml/debugger/qqmldebugjs/data/loadjsfile.qml
index 4fff66a325..4fff66a325 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/loadjsfile.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/loadjsfile.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/oncompleted.qml b/tests/auto/qml/debugger/qqmldebugjs/data/oncompleted.qml
index e03ba2ca79..e03ba2ca79 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/oncompleted.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/oncompleted.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/stepAction.qml b/tests/auto/qml/debugger/qqmldebugjs/data/stepAction.qml
index 690f9fd446..690f9fd446 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/stepAction.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/stepAction.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.js b/tests/auto/qml/debugger/qqmldebugjs/data/test.js
index 7de138bdf6..7de138bdf6 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.js
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/test.js
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.qml b/tests/auto/qml/debugger/qqmldebugjs/data/test.qml
index 200f26b1c3..200f26b1c3 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/test.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/test.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/timer.qml b/tests/auto/qml/debugger/qqmldebugjs/data/timer.qml
index d9440415d2..d9440415d2 100644
--- a/tests/auto/declarative/debugger/qdeclarativedebugjs/data/timer.qml
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/timer.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro
new file mode 100644
index 0000000000..72b0e77f71
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro
@@ -0,0 +1,29 @@
+CONFIG += testcase
+TARGET = tst_qqmldebugjs
+QT += qml-private testlib
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qqmldebugjs.cpp \
+ ../shared/debugutil.cpp
+
+INCLUDEPATH += ../shared
+
+include (../../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+OTHER_FILES += data/test.qml data/test.js \
+ data/timer.qml \
+ data/exception.qml \
+ data/oncompleted.qml \
+ data/loadjsfile.qml \
+ data/condition.qml \
+ data/changeBreakpoint.qml \
+ data/stepAction.qml \
+ data/breakpointRelocation.qml \
+ data/createComponent.qml
diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
new file mode 100644
index 0000000000..9a8b00bb6c
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
@@ -0,0 +1,1790 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QtCore/QProcess>
+#include <QtCore/QTimer>
+#include <QtCore/QFileInfo>
+#include <QtCore/QDir>
+#include <QtCore/QMutex>
+#include <QtCore/QLibraryInfo>
+#include <QtQml/private/qqmldebugclient_p.h>
+#include <QtQml/QJSEngine>
+
+//QQmlDebugTest
+#include "../shared/debugutil_p.h"
+#include "../../../shared/util.h"
+
+const char *V8REQUEST = "v8request";
+const char *V8MESSAGE = "v8message";
+const char *SEQ = "seq";
+const char *TYPE = "type";
+const char *COMMAND = "command";
+const char *ARGUMENTS = "arguments";
+const char *STEPACTION = "stepaction";
+const char *STEPCOUNT = "stepcount";
+const char *EXPRESSION = "expression";
+const char *FRAME = "frame";
+const char *GLOBAL = "global";
+const char *DISABLEBREAK = "disable_break";
+const char *HANDLES = "handles";
+const char *INCLUDESOURCE = "includeSource";
+const char *FROMFRAME = "fromFrame";
+const char *TOFRAME = "toFrame";
+const char *BOTTOM = "bottom";
+const char *NUMBER = "number";
+const char *FRAMENUMBER = "frameNumber";
+const char *TYPES = "types";
+const char *IDS = "ids";
+const char *FILTER = "filter";
+const char *FROMLINE = "fromLine";
+const char *TOLINE = "toLine";
+const char *TARGET = "target";
+const char *LINE = "line";
+const char *COLUMN = "column";
+const char *ENABLED = "enabled";
+const char *CONDITION = "condition";
+const char *IGNORECOUNT = "ignoreCount";
+const char *BREAKPOINT = "breakpoint";
+const char *FLAGS = "flags";
+
+const char *CONTINEDEBUGGING = "continue";
+const char *EVALUATE = "evaluate";
+const char *LOOKUP = "lookup";
+const char *BACKTRACE = "backtrace";
+const char *SCOPE = "scope";
+const char *SCOPES = "scopes";
+const char *SCRIPTS = "scripts";
+const char *SOURCE = "source";
+const char *SETBREAKPOINT = "setbreakpoint";
+const char *CHANGEBREAKPOINT = "changebreakpoint";
+const char *CLEARBREAKPOINT = "clearbreakpoint";
+const char *SETEXCEPTIONBREAK = "setexceptionbreak";
+const char *V8FLAGS = "v8flags";
+const char *VERSION = "version";
+const char *DISCONNECT = "disconnect";
+const char *LISTBREAKPOINTS = "listbreakpoints";
+const char *GARBAGECOLLECTOR = "gc";
+//const char *PROFILE = "profile";
+
+const char *CONNECT = "connect";
+const char *INTERRUPT = "interrupt";
+const char *BREAKAFTERCOMPILE = "breakaftercompile";
+
+const char *REQUEST = "request";
+const char *IN = "in";
+const char *NEXT = "next";
+const char *OUT = "out";
+
+const char *FUNCTION = "function";
+const char *SCRIPT = "script";
+const char *SCRIPTREGEXP = "scriptRegExp";
+const char *EVENT = "event";
+
+const char *ALL = "all";
+const char *UNCAUGHT = "uncaught";
+
+//const char *PAUSE = "pause";
+//const char *RESUME = "resume";
+
+const char *BLOCKMODE = "-qmljsdebugger=port:3771,block";
+const char *NORMALMODE = "-qmljsdebugger=port:3771";
+const char *TEST_QMLFILE = "test.qml";
+const char *TEST_JSFILE = "test.js";
+const char *TIMER_QMLFILE = "timer.qml";
+const char *LOADJSFILE_QMLFILE = "loadjsfile.qml";
+const char *EXCEPTION_QMLFILE = "exception.qml";
+const char *ONCOMPLETED_QMLFILE = "oncompleted.qml";
+const char *CREATECOMPONENT_QMLFILE = "createComponent.qml";
+const char *CONDITION_QMLFILE = "condition.qml";
+const char *CHANGEBREAKPOINT_QMLFILE = "changeBreakpoint.qml";
+const char *STEPACTION_QMLFILE = "stepAction.qml";
+const char *BREAKPOINTRELOCATION_QMLFILE = "breakpointRelocation.qml";
+
+#define VARIANTMAPINIT \
+ QString obj("{}"); \
+ QJSValue jsonVal = parser.call(QJSValueList() << obj); \
+ jsonVal.setProperty(SEQ,QJSValue(seq++)); \
+ jsonVal.setProperty(TYPE,REQUEST);
+
+
+#undef QVERIFY
+#define QVERIFY(statement) \
+do {\
+ if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__)) {\
+ if (QTest::currentTestFailed()) \
+ qDebug().nospace() << "\nDEBUGGEE OUTPUT:\n" << process->output();\
+ return;\
+ }\
+} while (0)
+
+
+class QJSDebugClient;
+
+class tst_QQmlDebugJS : public QQmlDataTest
+{
+ Q_OBJECT
+
+ bool init(const QString &qmlFile = QString(TEST_QMLFILE), bool blockMode = true);
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void cleanup();
+
+ void connect();
+ void interrupt();
+ void breakAfterCompile();
+ void getVersion();
+ void getVersionWhenAttaching();
+
+ void applyV8Flags();
+
+ void disconnect();
+
+ void gc();
+
+ void listBreakpoints();
+
+ void setBreakpointInScriptOnCompleted();
+ void setBreakpointInScriptOnComponentCreated();
+ void setBreakpointInScriptOnTimerCallback();
+ void setBreakpointInScriptInDifferentFile();
+ void setBreakpointInScriptOnComment();
+ void setBreakpointInScriptOnEmptyLine();
+ void setBreakpointInScriptWithCondition();
+ //void setBreakpointInFunction(); //NOT SUPPORTED
+ void setBreakpointOnEvent();
+ void setBreakpointWhenAttaching();
+
+ void changeBreakpoint();
+ void changeBreakpointOnCondition();
+
+ void clearBreakpoint();
+
+ void setExceptionBreak();
+
+ void stepNext();
+ void stepNextWithCount();
+ void stepIn();
+ void stepOut();
+ void continueDebugging();
+
+ void backtrace();
+
+ void getFrameDetails();
+
+ void getScopeDetails();
+
+ void evaluateInGlobalScope();
+ void evaluateInLocalScope();
+
+ void getScopes();
+
+ void getScripts();
+
+ void getSource();
+
+ // void profile(); //NOT SUPPORTED
+
+ // void verifyQMLOptimizerDisabled();
+
+private:
+ QQmlDebugProcess *process;
+ QJSDebugClient *client;
+ QQmlDebugConnection *connection;
+ QTime t;
+};
+
+class QJSDebugClient : public QQmlDebugClient
+{
+ Q_OBJECT
+public:
+ enum StepAction
+ {
+ Continue,
+ In,
+ Out,
+ Next
+ };
+
+ enum Exception
+ {
+ All,
+ Uncaught
+ };
+
+// enum ProfileCommand
+// {
+// Pause,
+// Resume
+// };
+
+ QJSDebugClient(QQmlDebugConnection *connection)
+ : QQmlDebugClient(QLatin1String("V8Debugger"), connection),
+ seq(0)
+ {
+ parser = jsEngine.evaluate(QLatin1String("JSON.parse"));
+ stringify = jsEngine.evaluate(QLatin1String("JSON.stringify"));
+ }
+
+ void connect();
+ void interrupt();
+ void breakAfterCompile(bool enabled);
+
+ void continueDebugging(StepAction stepAction, int stepCount = 1);
+ void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
+ void lookup(QList<int> handles, bool includeSource = false);
+ void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false);
+ void frame(int number = -1);
+ void scope(int number = -1, int frameNumber = -1);
+ void scopes(int frameNumber = -1);
+ void scripts(int types = 4, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant());
+ void source(int frame = -1, int fromLine = -1, int toLine = -1);
+ void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = true, QString condition = QString(), int ignoreCount = -1);
+ void changeBreakpoint(int breakpoint, bool enabled = true, QString condition = QString(), int ignoreCount = -1);
+ void clearBreakpoint(int breakpoint);
+ void setExceptionBreak(Exception type, bool enabled = false);
+ void v8flags(QString flags);
+ void version();
+ //void profile(ProfileCommand command); //NOT SUPPORTED
+ void disconnect();
+ void gc();
+ void listBreakpoints();
+
+protected:
+ //inherited from QQmlDebugClient
+ void stateChanged(State state);
+ void messageReceived(const QByteArray &data);
+
+signals:
+ void enabled();
+ void connected();
+ void interruptRequested();
+ void breakAfterCompileRequested();
+ void result();
+ void stopped();
+
+private:
+ void sendMessage(const QByteArray &);
+ void flushSendBuffer();
+ QByteArray packMessage(const QByteArray &type, const QByteArray &message = QByteArray());
+
+private:
+ QJSEngine jsEngine;
+ int seq;
+
+ QList<QByteArray> sendBuffer;
+public:
+ QJSValue parser;
+ QJSValue stringify;
+ QByteArray response;
+
+};
+
+void QJSDebugClient::connect()
+{
+ sendMessage(packMessage(CONNECT));
+}
+
+void QJSDebugClient::interrupt()
+{
+ sendMessage(packMessage(INTERRUPT));
+}
+
+void QJSDebugClient::breakAfterCompile(bool enabled)
+{
+ QByteArray request;
+ QDataStream rs(&request, QIODevice::WriteOnly);
+ rs << enabled;
+ sendMessage(packMessage(BREAKAFTERCOMPILE, request));
+}
+
+void QJSDebugClient::continueDebugging(StepAction action, int count)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "continue",
+ // "arguments" : { "stepaction" : <"in", "next" or "out">,
+ // "stepcount" : <number of steps (default 1)>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CONTINEDEBUGGING)));
+
+ if (action != Continue) {
+ QJSValue args = parser.call(QJSValueList() << obj);
+ switch (action) {
+ case In: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(IN)));
+ break;
+ case Out: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(OUT)));
+ break;
+ case Next: args.setProperty(QLatin1String(STEPACTION),QJSValue(QLatin1String(NEXT)));
+ break;
+ default:break;
+ }
+ if (!args.isUndefined()) {
+ if (count != 1)
+ args.setProperty(QLatin1String(STEPCOUNT),QJSValue(count));
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+ }
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::evaluate(QString expr, bool global, bool disableBreak, int frame, const QVariantMap &/*addContext*/)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "evaluate",
+ // "arguments" : { "expression" : <expression to evaluate>,
+ // "frame" : <number>,
+ // "global" : <boolean>,
+ // "disable_break" : <boolean>,
+ // "additional_context" : [
+ // { "name" : <name1>, "handle" : <handle1> },
+ // { "name" : <name2>, "handle" : <handle2> },
+ // ...
+ // ]
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(EVALUATE)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+ args.setProperty(QLatin1String(EXPRESSION),QJSValue(expr));
+
+ if (frame != -1)
+ args.setProperty(QLatin1String(FRAME),QJSValue(frame));
+
+ if (global)
+ args.setProperty(QLatin1String(GLOBAL),QJSValue(global));
+
+ if (disableBreak)
+ args.setProperty(QLatin1String(DISABLEBREAK),QJSValue(disableBreak));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::lookup(QList<int> handles, bool includeSource)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "lookup",
+ // "arguments" : { "handles" : <array of handles>,
+ // "includeSource" : <boolean indicating whether the source will be included when script objects are returned>,
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(LOOKUP)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ QString arr("[]");
+ QJSValue array = parser.call(QJSValueList() << arr);
+ int index = 0;
+ foreach (int handle, handles) {
+ array.setProperty(index++,QJSValue(handle));
+ }
+ args.setProperty(QLatin1String(HANDLES),array);
+
+ if (includeSource)
+ args.setProperty(QLatin1String(INCLUDESOURCE),QJSValue(includeSource));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::backtrace(int fromFrame, int toFrame, bool bottom)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "backtrace",
+ // "arguments" : { "fromFrame" : <number>
+ // "toFrame" : <number>
+ // "bottom" : <boolean, set to true if the bottom of the stack is requested>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(BACKTRACE)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ if (fromFrame != -1)
+ args.setProperty(QLatin1String(FROMFRAME),QJSValue(fromFrame));
+
+ if (toFrame != -1)
+ args.setProperty(QLatin1String(TOFRAME),QJSValue(toFrame));
+
+ if (bottom)
+ args.setProperty(QLatin1String(BOTTOM),QJSValue(bottom));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::frame(int number)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "frame",
+ // "arguments" : { "number" : <frame number>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(FRAME)));
+
+ if (number != -1) {
+ QJSValue args = parser.call(QJSValueList() << obj);
+ args.setProperty(QLatin1String(NUMBER),QJSValue(number));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::scope(int number, int frameNumber)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "scope",
+ // "arguments" : { "number" : <scope number>
+ // "frameNumber" : <frame number, optional uses selected frame if missing>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCOPE)));
+
+ if (number != -1) {
+ QJSValue args = parser.call(QJSValueList() << obj);
+ args.setProperty(QLatin1String(NUMBER),QJSValue(number));
+
+ if (frameNumber != -1)
+ args.setProperty(QLatin1String(FRAMENUMBER),QJSValue(frameNumber));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::scopes(int frameNumber)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "scopes",
+ // "arguments" : { "frameNumber" : <frame number, optional uses selected frame if missing>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCOPES)));
+
+ if (frameNumber != -1) {
+ QJSValue args = parser.call(QJSValueList() << obj);
+ args.setProperty(QLatin1String(FRAMENUMBER),QJSValue(frameNumber));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::scripts(int types, QList<int> ids, bool includeSource, QVariant /*filter*/)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "scripts",
+ // "arguments" : { "types" : <types of scripts to retrieve
+ // set bit 0 for native scripts
+ // set bit 1 for extension scripts
+ // set bit 2 for normal scripts
+ // (default is 4 for normal scripts)>
+ // "ids" : <array of id's of scripts to return. If this is not specified all scripts are requrned>
+ // "includeSource" : <boolean indicating whether the source code should be included for the scripts returned>
+ // "filter" : <string or number: filter string or script id.
+ // If a number is specified, then only the script with the same number as its script id will be retrieved.
+ // If a string is specified, then only scripts whose names contain the filter string will be retrieved.>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SCRIPTS)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+ args.setProperty(QLatin1String(TYPES),QJSValue(types));
+
+ if (ids.count()) {
+ QString arr("[]");
+ QJSValue array = parser.call(QJSValueList() << arr);
+ int index = 0;
+ foreach (int id, ids) {
+ array.setProperty(index++,QJSValue(id));
+ }
+ args.setProperty(QLatin1String(IDS),array);
+ }
+
+ if (includeSource)
+ args.setProperty(QLatin1String(INCLUDESOURCE),QJSValue(includeSource));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::source(int frame, int fromLine, int toLine)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "source",
+ // "arguments" : { "frame" : <frame number (default selected frame)>
+ // "fromLine" : <from line within the source default is line 0>
+ // "toLine" : <to line within the source this line is not included in
+ // the result default is the number of lines in the script>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SOURCE)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ if (frame != -1)
+ args.setProperty(QLatin1String(FRAME),QJSValue(frame));
+
+ if (fromLine != -1)
+ args.setProperty(QLatin1String(FROMLINE),QJSValue(fromLine));
+
+ if (toLine != -1)
+ args.setProperty(QLatin1String(TOLINE),QJSValue(toLine));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::setBreakpoint(QString type, QString target, int line, int column, bool enabled, QString condition, int ignoreCount)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "setbreakpoint",
+ // "arguments" : { "type" : <"function" or "script" or "scriptId" or "scriptRegExp">
+ // "target" : <function expression or script identification>
+ // "line" : <line in script or function>
+ // "column" : <character position within the line>
+ // "enabled" : <initial enabled state. True or false, default is true>
+ // "condition" : <string with break point condition>
+ // "ignoreCount" : <number specifying the number of break point hits to ignore, default value is 0>
+ // }
+ // }
+
+ if (type == QLatin1String(EVENT)) {
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << target.toUtf8() << enabled;
+ sendMessage(packMessage(QByteArray("breakonsignal"), reply));
+
+ } else {
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SETBREAKPOINT)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ args.setProperty(QLatin1String(TYPE),QJSValue(type));
+ args.setProperty(QLatin1String(TARGET),QJSValue(target));
+
+ if (line != -1)
+ args.setProperty(QLatin1String(LINE),QJSValue(line));
+
+ if (column != -1)
+ args.setProperty(QLatin1String(COLUMN),QJSValue(column));
+
+ args.setProperty(QLatin1String(ENABLED),QJSValue(enabled));
+
+ if (!condition.isEmpty())
+ args.setProperty(QLatin1String(CONDITION),QJSValue(condition));
+
+ if (ignoreCount != -1)
+ args.setProperty(QLatin1String(IGNORECOUNT),QJSValue(ignoreCount));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+ }
+}
+
+void QJSDebugClient::changeBreakpoint(int breakpoint, bool enabled, QString condition, int ignoreCount)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "changebreakpoint",
+ // "arguments" : { "breakpoint" : <number of the break point to clear>
+ // "enabled" : <initial enabled state. True or false, default is true>
+ // "condition" : <string with break point condition>
+ // "ignoreCount" : <number specifying the number of break point hits }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CHANGEBREAKPOINT)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ args.setProperty(QLatin1String(BREAKPOINT),QJSValue(breakpoint));
+
+ args.setProperty(QLatin1String(ENABLED),QJSValue(enabled));
+
+ if (!condition.isEmpty())
+ args.setProperty(QLatin1String(CONDITION),QJSValue(condition));
+
+ if (ignoreCount != -1)
+ args.setProperty(QLatin1String(IGNORECOUNT),QJSValue(ignoreCount));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::clearBreakpoint(int breakpoint)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "clearbreakpoint",
+ // "arguments" : { "breakpoint" : <number of the break point to clear>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(CLEARBREAKPOINT)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ args.setProperty(QLatin1String(BREAKPOINT),QJSValue(breakpoint));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::setExceptionBreak(Exception type, bool enabled)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "setexceptionbreak",
+ // "arguments" : { "type" : <string: "all", or "uncaught">,
+ // "enabled" : <optional bool: enables the break type if true>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(SETEXCEPTIONBREAK)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ if (type == All)
+ args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(ALL)));
+ else if (type == Uncaught)
+ args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(UNCAUGHT)));
+
+ if (enabled)
+ args.setProperty(QLatin1String(ENABLED),QJSValue(enabled));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::v8flags(QString flags)
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "v8flags",
+ // "arguments" : { "flags" : <string: a sequence of v8 flags just like those used on the command line>
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(V8FLAGS)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ args.setProperty(QLatin1String(FLAGS),QJSValue(flags));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::version()
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "version",
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(VERSION)));
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+//void QJSDebugClient::profile(ProfileCommand command)
+//{
+//// { "seq" : <number>,
+//// "type" : "request",
+//// "command" : "profile",
+//// "arguments" : { "command" : "resume" or "pause" }
+//// }
+// VARIANTMAPINIT;
+// jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(PROFILE)));
+
+// QJSValue args = parser.call(QJSValueList() << obj);
+
+// if (command == Resume)
+// args.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(RESUME)));
+// else
+// args.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(PAUSE)));
+
+// args.setProperty(QLatin1String("modules"),QJSValue(1));
+// if (!args.isUndefined()) {
+// jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+// }
+
+// QJSValue json = stringify.call(QJSValueList() << jsonVal);
+// sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+//}
+
+void QJSDebugClient::disconnect()
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "disconnect",
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(DISCONNECT)));
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(DISCONNECT, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::gc()
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "gc",
+ // "arguments" : { "type" : <string: "all">,
+ // }
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(GARBAGECOLLECTOR)));
+
+ QJSValue args = parser.call(QJSValueList() << obj);
+
+ args.setProperty(QLatin1String(TYPE),QJSValue(QLatin1String(ALL)));
+
+ if (!args.isUndefined()) {
+ jsonVal.setProperty(QLatin1String(ARGUMENTS),args);
+ }
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::listBreakpoints()
+{
+ // { "seq" : <number>,
+ // "type" : "request",
+ // "command" : "listbreakpoints",
+ // }
+ VARIANTMAPINIT;
+ jsonVal.setProperty(QLatin1String(COMMAND),QJSValue(QLatin1String(LISTBREAKPOINTS)));
+
+ QJSValue json = stringify.call(QJSValueList() << jsonVal);
+ sendMessage(packMessage(V8REQUEST, json.toString().toUtf8()));
+}
+
+void QJSDebugClient::stateChanged(State state)
+{
+ if (state == Enabled) {
+ flushSendBuffer();
+ emit enabled();
+ }
+}
+
+void QJSDebugClient::messageReceived(const QByteArray &data)
+{
+ QDataStream ds(data);
+ QByteArray command;
+ ds >> command;
+
+ if (command == "V8DEBUG") {
+ QByteArray type;
+ ds >> type >> response;
+
+ if (type == CONNECT) {
+ emit connected();
+
+ } else if (type == INTERRUPT) {
+ emit interruptRequested();
+
+ } else if (type == V8MESSAGE) {
+ QString jsonString(response);
+ QVariantMap value = parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+ QString type = value.value("type").toString();
+
+ if (type == "response") {
+
+ if (!value.value("success").toBool()) {
+// qDebug() << "Error: The test case will fail since no signal is emitted";
+ return;
+ }
+
+ QString debugCommand(value.value("command").toString());
+ if (debugCommand == "backtrace" ||
+ debugCommand == "lookup" ||
+ debugCommand == "setbreakpoint" ||
+ debugCommand == "evaluate" ||
+ debugCommand == "listbreakpoints" ||
+ debugCommand == "version" ||
+ debugCommand == "v8flags" ||
+ debugCommand == "disconnect" ||
+ debugCommand == "gc" ||
+ debugCommand == "changebreakpoint" ||
+ debugCommand == "clearbreakpoint" ||
+ debugCommand == "frame" ||
+ debugCommand == "scope" ||
+ debugCommand == "scopes" ||
+ debugCommand == "scripts" ||
+ debugCommand == "source" ||
+ debugCommand == "setexceptionbreak" /*||
+ debugCommand == "profile"*/) {
+ emit result();
+
+ } else {
+ // DO NOTHING
+ }
+
+ } else if (type == QLatin1String(EVENT)) {
+ QString event(value.value(QLatin1String(EVENT)).toString());
+
+ if (event == "break" ||
+ event == "exception")
+ emit stopped();
+ }
+
+ } else if (type == BREAKAFTERCOMPILE) {
+ emit breakAfterCompileRequested();
+
+ }
+ }
+}
+
+void QJSDebugClient::sendMessage(const QByteArray &msg)
+{
+ if (state() == Enabled) {
+ QQmlDebugClient::sendMessage(msg);
+ } else {
+ sendBuffer.append(msg);
+ }
+}
+
+void QJSDebugClient::flushSendBuffer()
+{
+ foreach (const QByteArray &msg, sendBuffer)
+ QQmlDebugClient::sendMessage(msg);
+ sendBuffer.clear();
+}
+
+QByteArray QJSDebugClient::packMessage(const QByteArray &type, const QByteArray &message)
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ QByteArray cmd = "V8DEBUG";
+ rs << cmd << type << message;
+ return reply;
+}
+
+void tst_QQmlDebugJS::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ t.start();
+ process = 0;
+ client = 0;
+ connection = 0;
+}
+
+void tst_QQmlDebugJS::cleanupTestCase()
+{
+ if (process) {
+ process->stop();
+ delete process;
+ }
+
+ if (client)
+ delete client;
+
+ if (connection)
+ delete connection;
+
+// qDebug() << "Time Elapsed:" << t.elapsed();
+}
+
+bool tst_QQmlDebugJS::init(const QString &qmlFile, bool blockMode)
+{
+ connection = new QQmlDebugConnection();
+ process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene");
+ client = new QJSDebugClient(connection);
+
+ QStringList systemEnvironment = QProcess::systemEnvironment();
+ systemEnvironment << "QML_DISABLE_OPTIMIZER=1";
+ process->setEnvironment(systemEnvironment);
+ if (blockMode)
+ process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(qmlFile));
+ else
+ process->start(QStringList() << QLatin1String(NORMALMODE) << testFile(qmlFile));
+
+ if (!process->waitForSessionStart()) {
+ return false;
+ }
+
+ connection->connectToHost("127.0.0.1", 3771);
+ if (!connection->waitForConnected())
+ return false;
+
+ return QQmlDebugTest::waitForSignal(client, SIGNAL(enabled()));
+}
+
+void tst_QQmlDebugJS::cleanup()
+{
+ if (process) {
+ process->stop();
+ delete process;
+ }
+
+ if (client)
+ delete client;
+
+ if (connection)
+ delete connection;
+
+ process = 0;
+ client = 0;
+ connection = 0;
+}
+
+void tst_QQmlDebugJS::connect()
+{
+ //void connect()
+
+ QVERIFY(init());
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(connected())));
+}
+
+void tst_QQmlDebugJS::interrupt()
+{
+ //void connect()
+
+ QVERIFY(init());
+ client->connect();
+
+ client->interrupt();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(interruptRequested())));
+}
+
+void tst_QQmlDebugJS::breakAfterCompile()
+{
+ //void breakAfterCompile(bool enabled)
+
+ QVERIFY(init());
+ client->breakAfterCompile(true);
+ client->connect();
+
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(breakAfterCompileRequested())));
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+}
+
+void tst_QQmlDebugJS::getVersion()
+{
+ //void version()
+
+ QVERIFY(init());
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(connected())));
+
+ client->version();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::getVersionWhenAttaching()
+{
+ //void version()
+
+ QVERIFY(init(QLatin1String(TIMER_QMLFILE), false));
+ client->connect();
+
+ client->version();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::applyV8Flags()
+{
+ //void v8flags(QString flags)
+
+ QVERIFY(init());
+ client->connect();
+
+ client->v8flags(QString());
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::disconnect()
+{
+ //void disconnect()
+
+ QVERIFY(init());
+ client->connect();
+
+ client->disconnect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::gc()
+{
+ //void gc()
+
+ QVERIFY(init());
+ client->connect();
+
+ client->gc();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::listBreakpoints()
+{
+ //void listBreakpoints()
+
+ int sourceLine1 = 47;
+ int sourceLine2 = 48;
+ int sourceLine3 = 49;
+
+ QVERIFY(init());
+ client->connect();
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine1, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine2, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_QMLFILE), sourceLine3, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+ client->listBreakpoints();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QList<QVariant> breakpoints = value.value("body").toMap().value("breakpoints").toList();
+
+ QCOMPARE(breakpoints.count(), 3);
+}
+
+void tst_QQmlDebugJS::setBreakpointInScriptOnCompleted()
+{
+ //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int sourceLine = 47;
+ QVERIFY(init(ONCOMPLETED_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(ONCOMPLETED_QMLFILE));
+}
+
+void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated()
+{
+ //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int sourceLine = 47;
+ QVERIFY(init(CREATECOMPONENT_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(ONCOMPLETED_QMLFILE));
+}
+
+void tst_QQmlDebugJS::setBreakpointInScriptOnTimerCallback()
+{
+ int sourceLine = 48;
+ QVERIFY(init(TIMER_QMLFILE));
+
+ client->connect();
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TIMER_QMLFILE), sourceLine, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TIMER_QMLFILE));
+}
+
+void tst_QQmlDebugJS::setBreakpointInScriptInDifferentFile()
+{
+ //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int sourceLine = 43;
+ QVERIFY(init(LOADJSFILE_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_JSFILE), sourceLine, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TEST_JSFILE));
+}
+
+void tst_QQmlDebugJS::setBreakpointInScriptOnComment()
+{
+ //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int sourceLine = 47;
+ int actualLine = 49;
+ QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
+ QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()), 1));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), actualLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
+}
+
+void tst_QQmlDebugJS::setBreakpointInScriptOnEmptyLine()
+{
+ //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int sourceLine = 48;
+ int actualLine = 49;
+ QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true);
+ QEXPECT_FAIL("", "Relocation of breakpoints is disabled right now", Abort);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()), 1));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), actualLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(BREAKPOINTRELOCATION_QMLFILE));
+}
+
+void tst_QQmlDebugJS::setBreakpointInScriptWithCondition()
+{
+ //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int out = 10;
+ int sourceLine = 50;
+ QVERIFY(init(CONDITION_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CONDITION_QMLFILE), sourceLine, 1, true, QLatin1String("a > 10"));
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ //Get the frame index
+ QString jsonString = client->response;
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ int frameIndex = body.value("index").toInt();
+
+ //Verify the value of 'result'
+ client->evaluate(QLatin1String("a"),frameIndex);
+
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ jsonString = client->response;
+ value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ body = value.value("body").toMap();
+
+ QVERIFY(body.value("value").toInt() > out);
+}
+
+void tst_QQmlDebugJS::setBreakpointWhenAttaching()
+{
+ int sourceLine = 49;
+ QVERIFY(init(QLatin1String(TIMER_QMLFILE), false));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TIMER_QMLFILE), sourceLine);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+}
+
+//void tst_QQmlDebugJS::setBreakpointInFunction()
+//{
+// //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+// int actualLine = 31;
+
+// client->connect();
+// client->setBreakpoint(QLatin1String(FUNCTION), QLatin1String("doSomethingElse"), -1, -1, true);
+
+// QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+// QString jsonString(client->response);
+// QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+// QVariantMap body = value.value("body").toMap();
+
+// QCOMPARE(body.value("sourceLine").toInt(), actualLine);
+// QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(QMLFILE));
+//}
+
+void tst_QQmlDebugJS::setBreakpointOnEvent()
+{
+ //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ QVERIFY(init(TIMER_QMLFILE));
+
+ client->connect();
+
+ client->setBreakpoint(QLatin1String(EVENT), QLatin1String("triggered"), -1, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(TIMER_QMLFILE));
+}
+
+
+void tst_QQmlDebugJS::changeBreakpoint()
+{
+ //void changeBreakpoint(int breakpoint, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int sourceLine1 = 50;
+ int sourceLine2 = 51;
+ QVERIFY(init(CHANGEBREAKPOINT_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true);
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true);
+
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ //Will hit 1st brakpoint, change this breakpoint enable = false
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+ QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
+
+ int breakpoint = breakpointsHit.at(0).toInt();
+ client->changeBreakpoint(breakpoint,false);
+
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ //Continue with debugging
+ client->continueDebugging(QJSDebugClient::Continue);
+ //Hit 2nd breakpoint
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ //Continue with debugging
+ client->continueDebugging(QJSDebugClient::Continue);
+ //Should stop at 2nd breakpoint
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ jsonString = client->response;
+ value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
+}
+
+void tst_QQmlDebugJS::changeBreakpointOnCondition()
+{
+ //void changeBreakpoint(int breakpoint, bool enabled = false, QString condition = QString(), int ignoreCount = -1)
+
+ int sourceLine1 = 50;
+ int sourceLine2 = 51;
+
+ QVERIFY(init(CHANGEBREAKPOINT_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true);
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true);
+
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ //Will hit 1st brakpoint, change this breakpoint enable = false
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+ QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
+
+ int breakpoint = breakpointsHit.at(0).toInt();
+ client->changeBreakpoint(breakpoint, false, QLatin1String("d == 0"));
+
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ //Continue with debugging
+ client->continueDebugging(QJSDebugClient::Continue);
+ //Hit 2nd breakpoint
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ //Continue with debugging
+ client->continueDebugging(QJSDebugClient::Continue);
+ //Should stop at 2nd breakpoint
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ jsonString = client->response;
+ value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
+
+}
+
+void tst_QQmlDebugJS::clearBreakpoint()
+{
+ //void clearBreakpoint(int breakpoint);
+
+ int sourceLine1 = 50;
+ int sourceLine2 = 51;
+ QVERIFY(init(CHANGEBREAKPOINT_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine1, -1, true);
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(CHANGEBREAKPOINT_QMLFILE), sourceLine2, -1, true);
+
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ //Will hit 1st brakpoint, change this breakpoint enable = false
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+ QList<QVariant> breakpointsHit = body.value("breakpoints").toList();
+
+ int breakpoint = breakpointsHit.at(0).toInt();
+ client->clearBreakpoint(breakpoint);
+
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ //Continue with debugging
+ client->continueDebugging(QJSDebugClient::Continue);
+ //Hit 2nd breakpoint
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ //Continue with debugging
+ client->continueDebugging(QJSDebugClient::Continue);
+ //Should stop at 2nd breakpoint
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ jsonString = client->response;
+ value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
+}
+
+void tst_QQmlDebugJS::setExceptionBreak()
+{
+ //void setExceptionBreak(QString type, bool enabled = false);
+
+ QVERIFY(init(EXCEPTION_QMLFILE));
+ client->setExceptionBreak(QJSDebugClient::All,true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+}
+
+void tst_QQmlDebugJS::stepNext()
+{
+ //void continueDebugging(StepAction stepAction, int stepCount = 1);
+
+ int sourceLine = 50;
+ QVERIFY(init(STEPACTION_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->continueDebugging(QJSDebugClient::Next);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine + 1);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+}
+
+void tst_QQmlDebugJS::stepNextWithCount()
+{
+ //void continueDebugging(StepAction stepAction, int stepCount = 1);
+
+ int sourceLine = 50;
+ QVERIFY(init(STEPACTION_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->continueDebugging(QJSDebugClient::Next, 2);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine + 2);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+}
+
+void tst_QQmlDebugJS::stepIn()
+{
+ //void continueDebugging(StepAction stepAction, int stepCount = 1);
+
+ int sourceLine = 54;
+ int actualLine = 50;
+ QVERIFY(init(STEPACTION_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, 1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->continueDebugging(QJSDebugClient::In);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), actualLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+}
+
+void tst_QQmlDebugJS::stepOut()
+{
+ //void continueDebugging(StepAction stepAction, int stepCount = 1);
+
+ int sourceLine = 50;
+ int actualLine = 54;
+ QVERIFY(init(STEPACTION_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->continueDebugging(QJSDebugClient::Out);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), actualLine);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+}
+
+void tst_QQmlDebugJS::continueDebugging()
+{
+ //void continueDebugging(StepAction stepAction, int stepCount = 1);
+
+ int sourceLine1 = 54;
+ int sourceLine2 = 51;
+ QVERIFY(init(STEPACTION_QMLFILE));
+
+ client->connect();
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine1, -1, true);
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine2, -1, true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->continueDebugging(QJSDebugClient::Continue);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine2);
+ QCOMPARE(QFileInfo(body.value("script").toMap().value("name").toString()).fileName(), QLatin1String(STEPACTION_QMLFILE));
+}
+
+void tst_QQmlDebugJS::backtrace()
+{
+ //void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false);
+
+ int sourceLine = 47;
+ QVERIFY(init(ONCOMPLETED_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->backtrace();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::getFrameDetails()
+{
+ //void frame(int number = -1);
+
+ int sourceLine = 47;
+ QVERIFY(init(ONCOMPLETED_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->frame();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::getScopeDetails()
+{
+ //void scope(int number = -1, int frameNumber = -1);
+
+ int sourceLine = 47;
+ QVERIFY(init(ONCOMPLETED_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->scope();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::evaluateInGlobalScope()
+{
+ //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
+
+ QVERIFY(init());
+
+ client->connect();
+ client->evaluate(QLatin1String("print('Hello World')"), true);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ //Verify the value of 'print'
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ QCOMPARE(body.value("text").toString(),QLatin1String("undefined"));
+}
+
+void tst_QQmlDebugJS::evaluateInLocalScope()
+{
+ //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap());
+
+ int sourceLine = 47;
+ QVERIFY(init(ONCOMPLETED_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->frame();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ //Get the frame index
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ QVariantMap body = value.value("body").toMap();
+
+ int frameIndex = body.value("index").toInt();
+
+ client->evaluate(QLatin1String("root.a"), frameIndex);
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+
+ //Verify the value of 'timer.interval'
+ jsonString = client->response;
+ value = client->parser.call(QJSValueList() << QJSValue(jsonString)).toVariant().toMap();
+
+ body = value.value("body").toMap();
+
+ QCOMPARE(body.value("value").toInt(),10);
+}
+
+void tst_QQmlDebugJS::getScopes()
+{
+ //void scopes(int frameNumber = -1);
+
+ int sourceLine = 47;
+ QVERIFY(init(ONCOMPLETED_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->scopes();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+void tst_QQmlDebugJS::getScripts()
+{
+ //void scripts(int types = -1, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant());
+
+#ifdef Q_OS_MAC
+ QSKIP("QTBUG-23475 - Unreliable test on Mac OS X");
+#endif
+
+ QVERIFY(init());
+
+ client->connect();
+
+ client->scripts();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+ QString jsonString(client->response);
+ QVariantMap value = client->parser.call(QJSValueList()
+ << QJSValue(jsonString)).toVariant().toMap();
+
+ QList<QVariant> scripts = value.value("body").toList();
+
+ QCOMPARE(scripts.count(), 2);
+}
+
+void tst_QQmlDebugJS::getSource()
+{
+ //void source(int frame = -1, int fromLine = -1, int toLine = -1);
+
+ int sourceLine = 47;
+ QVERIFY(init(ONCOMPLETED_QMLFILE));
+
+ client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true);
+ client->connect();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped())));
+
+ client->source();
+ QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(result())));
+}
+
+QTEST_MAIN(tst_QQmlDebugJS)
+
+#include "tst_qqmldebugjs.moc"
+
diff --git a/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro b/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro
new file mode 100644
index 0000000000..ecb3b2ca2c
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmldebugservice/qqmldebugservice.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TARGET = tst_qqmldebugservice
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qqmldebugservice.cpp \
+ ../shared/debugutil.cpp
+
+CONFIG += parallel_test declarative_debug
+
+QT += qml-private testlib
diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
new file mode 100644
index 0000000000..5af38c2af0
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp
@@ -0,0 +1,216 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <QTimer>
+#include <QHostAddress>
+#include <QDebug>
+#include <QThread>
+
+#include <QtQml/qqmlengine.h>
+
+#include <private/qqmldebugclient_p.h>
+#include <private/qqmldebugservice_p.h>
+
+#include "../../../shared/util.h"
+#include "../shared/debugutil_p.h"
+
+#define PORT 13769
+#define STR_PORT "13769"
+
+class tst_QQmlDebugService : public QObject
+{
+ Q_OBJECT
+private:
+ QQmlDebugConnection *m_conn;
+
+private slots:
+ void initTestCase();
+
+ void name();
+ void version();
+ void state();
+ void sendMessage();
+ void idForObject();
+ void objectForId();
+ void objectToString();
+};
+
+void tst_QQmlDebugService::initTestCase()
+{
+ const QString waitingMsg = QString("QQmlDebugServer: Waiting for connection on port %1...").arg(PORT);
+ QTest::ignoreMessage(QtWarningMsg, waitingMsg.toAscii().constData());
+ new QQmlEngine(this);
+
+ m_conn = new QQmlDebugConnection(this);
+
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Connection established");
+ for (int i = 0; i < 50; ++i) {
+ // try for 5 seconds ...
+ m_conn->connectToHost("127.0.0.1", PORT);
+ if (m_conn->waitForConnected())
+ break;
+ QTest::qSleep(100);
+ }
+ QVERIFY(m_conn->isConnected());
+
+ QTRY_VERIFY(QQmlDebugService::hasDebuggingClient());
+}
+
+void tst_QQmlDebugService::name()
+{
+ QString name = "tst_QQmlDebugService::name()";
+
+ QQmlDebugService service(name, 1);
+ QCOMPARE(service.name(), name);
+}
+
+void tst_QQmlDebugService::version()
+{
+ QString name = "tst_QQmlDebugService::name()";
+
+ QQmlDebugService service(name, 2);
+ QCOMPARE(service.version(), 2.0f);
+}
+
+void tst_QQmlDebugService::state()
+{
+ QQmlDebugTestService service("tst_QQmlDebugService::state()");
+ QCOMPARE(service.state(), QQmlDebugService::Unavailable);
+
+ {
+ QQmlDebugTestClient client("tst_QQmlDebugService::state()", m_conn);
+ QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
+ QTRY_COMPARE(service.state(), QQmlDebugService::Enabled);
+ }
+
+
+ QTRY_COMPARE(service.state(), QQmlDebugService::Unavailable);
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::state()\" ");
+ QQmlDebugTestService duplicate("tst_QQmlDebugService::state()");
+ QCOMPARE(duplicate.state(), QQmlDebugService::NotConnected);
+}
+
+void tst_QQmlDebugService::sendMessage()
+{
+ QQmlDebugTestService service("tst_QQmlDebugService::sendMessage()");
+ QQmlDebugTestClient client("tst_QQmlDebugService::sendMessage()", m_conn);
+
+ QByteArray msg = "hello!";
+
+ QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled);
+ QTRY_COMPARE(service.state(), QQmlDebugService::Enabled);
+
+ client.sendMessage(msg);
+ QByteArray resp = client.waitForResponse();
+ QCOMPARE(resp, msg);
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::sendMessage()\" ");
+ QQmlDebugTestService duplicate("tst_QQmlDebugService::sendMessage()");
+ duplicate.sendMessage("msg");
+}
+
+void tst_QQmlDebugService::idForObject()
+{
+ QCOMPARE(QQmlDebugService::idForObject(0), -1);
+
+ QObject *objA = new QObject;
+
+ int idA = QQmlDebugService::idForObject(objA);
+ QVERIFY(idA >= 0);
+ QCOMPARE(QQmlDebugService::objectForId(idA), objA);
+
+ int idAA = QQmlDebugService::idForObject(objA);
+ QCOMPARE(idAA, idA);
+
+ QObject *objB = new QObject;
+ int idB = QQmlDebugService::idForObject(objB);
+ QVERIFY(idB != idA);
+ QCOMPARE(QQmlDebugService::objectForId(idB), objB);
+
+ delete objA;
+ delete objB;
+}
+
+void tst_QQmlDebugService::objectForId()
+{
+ QCOMPARE(QQmlDebugService::objectForId(-1), static_cast<QObject*>(0));
+ QCOMPARE(QQmlDebugService::objectForId(1), static_cast<QObject*>(0));
+
+ QObject *obj = new QObject;
+ int id = QQmlDebugService::idForObject(obj);
+ QCOMPARE(QQmlDebugService::objectForId(id), obj);
+
+ delete obj;
+ QCOMPARE(QQmlDebugService::objectForId(id), static_cast<QObject*>(0));
+}
+
+void tst_QQmlDebugService::objectToString()
+{
+ QCOMPARE(QQmlDebugService::objectToString(0), QString("NULL"));
+
+ QObject *obj = new QObject;
+ QCOMPARE(QQmlDebugService::objectToString(obj), QString("QObject: <unnamed>"));
+
+ obj->setObjectName("Hello");
+ QCOMPARE(QQmlDebugService::objectToString(obj), QString("QObject: Hello"));
+ delete obj;
+}
+
+
+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];
+ char arg[] = "-qmljsdebugger=port:" STR_PORT;
+ _argv[_argc - 1] = arg;
+
+ QGuiApplication app(_argc, _argv);
+ tst_QQmlDebugService tc;
+ return QTest::qExec(&tc, _argc, _argv);
+ delete _argv;
+}
+
+#include "tst_qqmldebugservice.moc"
diff --git a/tests/auto/qml/debugger/qqmlenginedebug/qqmlenginedebug.pro b/tests/auto/qml/debugger/qqmlenginedebug/qqmlenginedebug.pro
new file mode 100644
index 0000000000..529c4667cf
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlenginedebug/qqmlenginedebug.pro
@@ -0,0 +1,11 @@
+CONFIG += testcase
+TARGET = tst_qqmlenginedebug
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qqmlenginedebug.cpp \
+ ../shared/debugutil.cpp
+
+CONFIG += parallel_test declarative_debug
+
+QT += core-private qml-private quick-private v8-private testlib
diff --git a/tests/auto/qml/debugger/qqmlenginedebug/tst_qqmlenginedebug.cpp b/tests/auto/qml/debugger/qqmlenginedebug/tst_qqmlenginedebug.cpp
new file mode 100644
index 0000000000..21ed2f40ff
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlenginedebug/tst_qqmlenginedebug.cpp
@@ -0,0 +1,1235 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <QTimer>
+#include <QHostAddress>
+#include <QDebug>
+#include <QThread>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlproperty.h>
+#include <QtQuick/qquickitem.h>
+
+#include <private/qqmlbinding_p.h>
+#include <private/qqmlboundsignal_p.h>
+#include <private/qqmlenginedebug_p.h>
+#include <private/qqmldebugservice_p.h>
+#include <private/qqmlmetatype_p.h>
+#include <private/qqmlproperty_p.h>
+
+#include "../shared/debugutil_p.h"
+
+Q_DECLARE_METATYPE(QQmlDebugWatch::State)
+
+class tst_QQmlEngineDebug : public QObject
+{
+ Q_OBJECT
+
+private:
+ QQmlDebugObjectReference findRootObject(int context = 0, bool recursive = false);
+ QQmlDebugPropertyReference findProperty(const QList<QQmlDebugPropertyReference> &props, const QString &name) const;
+ void waitForQuery(QQmlDebugQuery *query);
+
+ void recursiveObjectTest(QObject *o, const QQmlDebugObjectReference &oref, bool recursive) const;
+
+ void recursiveCompareObjects(const QQmlDebugObjectReference &a, const QQmlDebugObjectReference &b) const;
+ void recursiveCompareContexts(const QQmlDebugContextReference &a, const QQmlDebugContextReference &b) const;
+ void compareProperties(const QQmlDebugPropertyReference &a, const QQmlDebugPropertyReference &b) const;
+
+ QQmlDebugConnection *m_conn;
+ QQmlEngineDebug *m_dbg;
+ QQmlEngine *m_engine;
+ QQuickItem *m_rootItem;
+
+ QObjectList m_components;
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void watch_property();
+ void watch_object();
+ void watch_expression();
+ void watch_expression_data();
+ void watch_context();
+ void watch_file();
+
+ void queryAvailableEngines();
+ void queryRootContexts();
+ void queryObject();
+ void queryObject_data();
+ void queryExpressionResult();
+ void queryExpressionResult_data();
+
+ void tst_QQmlDebugFileReference();
+ void tst_QQmlDebugEngineReference();
+ void tst_QQmlDebugObjectReference();
+ void tst_QQmlDebugContextReference();
+ void tst_QQmlDebugPropertyReference();
+
+ void setBindingForObject();
+ void setMethodBody();
+ void queryObjectTree();
+ void setBindingInStates();
+};
+
+class NonScriptProperty : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(int nonScriptProp READ nonScriptProp WRITE setNonScriptProp NOTIFY nonScriptPropChanged SCRIPTABLE false)
+public:
+ int nonScriptProp() const { return 0; }
+ void setNonScriptProp(int) {}
+signals:
+ void nonScriptPropChanged();
+};
+QML_DECLARE_TYPE(NonScriptProperty)
+
+
+QQmlDebugObjectReference tst_QQmlEngineDebug::findRootObject(int context, bool recursive)
+{
+ QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+
+ if (q_engines->engines().count() == 0)
+ return QQmlDebugObjectReference();
+ QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+
+ if (q_context->rootContext().objects().count() == 0)
+ return QQmlDebugObjectReference();
+ QQmlDebugObjectQuery *q_obj = recursive ?
+ m_dbg->queryObjectRecursive(q_context->rootContext().objects()[context], this) :
+ m_dbg->queryObject(q_context->rootContext().objects()[context], this);
+ waitForQuery(q_obj);
+
+ QQmlDebugObjectReference result = q_obj->object();
+
+ delete q_engines;
+ delete q_context;
+ delete q_obj;
+
+ return result;
+}
+
+QQmlDebugPropertyReference tst_QQmlEngineDebug::findProperty(const QList<QQmlDebugPropertyReference> &props, const QString &name) const
+{
+ foreach(const QQmlDebugPropertyReference &p, props) {
+ if (p.name() == name)
+ return p;
+ }
+ return QQmlDebugPropertyReference();
+}
+
+void tst_QQmlEngineDebug::waitForQuery(QQmlDebugQuery *query)
+{
+ QVERIFY(query);
+ QCOMPARE(query->parent(), qobject_cast<QObject*>(this));
+ QVERIFY(query->state() == QQmlDebugQuery::Waiting);
+ if (!QQmlDebugTest::waitForSignal(query, SIGNAL(stateChanged(QQmlDebugQuery::State))))
+ QFAIL("query timed out");
+}
+
+void tst_QQmlEngineDebug::recursiveObjectTest(QObject *o, const QQmlDebugObjectReference &oref, bool recursive) const
+{
+ const QMetaObject *meta = o->metaObject();
+
+ QQmlType *type = QQmlMetaType::qmlType(meta);
+ QString className = type ? QString(type->qmlTypeName()) : QString(meta->className());
+ className = className.mid(className.lastIndexOf(QLatin1Char('/'))+1);
+
+ QCOMPARE(oref.debugId(), QQmlDebugService::idForObject(o));
+ QCOMPARE(oref.name(), o->objectName());
+ QCOMPARE(oref.className(), className);
+ QCOMPARE(oref.contextDebugId(), QQmlDebugService::idForObject(qmlContext(o)));
+
+ const QObjectList &children = o->children();
+ for (int i=0; i<children.count(); i++) {
+ QObject *child = children[i];
+ if (!qmlContext(child))
+ continue;
+ int debugId = QQmlDebugService::idForObject(child);
+ QVERIFY(debugId >= 0);
+
+ QQmlDebugObjectReference cref;
+ foreach (const QQmlDebugObjectReference &ref, oref.children()) {
+ if (ref.debugId() == debugId) {
+ cref = ref;
+ break;
+ }
+ }
+ QVERIFY(cref.debugId() >= 0);
+
+ if (recursive)
+ recursiveObjectTest(child, cref, true);
+ }
+
+ foreach (const QQmlDebugPropertyReference &p, oref.properties()) {
+ QCOMPARE(p.objectDebugId(), QQmlDebugService::idForObject(o));
+
+ // signal properties are fake - they are generated from QQmlBoundSignal children
+ if (p.name().startsWith("on") && p.name().length() > 2 && p.name()[2].isUpper()) {
+ QList<QQmlBoundSignal*> signalHandlers = o->findChildren<QQmlBoundSignal*>();
+ QString signal = p.value().toString();
+ bool found = false;
+ for (int i = 0; i < signalHandlers.count(); ++i)
+ if (signalHandlers.at(i)->expression()->expression() == signal) {
+ found = true;
+ break;
+ }
+ QVERIFY(found);
+ QVERIFY(p.valueTypeName().isEmpty());
+ QVERIFY(p.binding().isEmpty());
+ QVERIFY(!p.hasNotifySignal());
+ continue;
+ }
+
+ QMetaProperty pmeta = meta->property(meta->indexOfProperty(p.name().toUtf8().constData()));
+
+ QCOMPARE(p.name(), QString::fromUtf8(pmeta.name()));
+
+ if (pmeta.type() < QVariant::UserType && pmeta.userType() != QMetaType::QVariant) // TODO test complex types
+ QCOMPARE(p.value(), pmeta.read(o));
+
+ if (p.name() == "parent")
+ QVERIFY(p.valueTypeName() == "QGraphicsObject*" || p.valueTypeName() == "QQuickItem*");
+ else
+ QCOMPARE(p.valueTypeName(), QString::fromUtf8(pmeta.typeName()));
+
+ QQmlAbstractBinding *binding =
+ QQmlPropertyPrivate::binding(QQmlProperty(o, p.name()));
+ if (binding)
+ QCOMPARE(binding->expression(), p.binding());
+
+ QCOMPARE(p.hasNotifySignal(), pmeta.hasNotifySignal());
+
+ QVERIFY(pmeta.isValid());
+ }
+}
+
+void tst_QQmlEngineDebug::recursiveCompareObjects(const QQmlDebugObjectReference &a, const QQmlDebugObjectReference &b) const
+{
+ QCOMPARE(a.debugId(), b.debugId());
+ QCOMPARE(a.className(), b.className());
+ QCOMPARE(a.name(), b.name());
+ QCOMPARE(a.contextDebugId(), b.contextDebugId());
+
+ QCOMPARE(a.source().url(), b.source().url());
+ QCOMPARE(a.source().lineNumber(), b.source().lineNumber());
+ QCOMPARE(a.source().columnNumber(), b.source().columnNumber());
+
+ QCOMPARE(a.properties().count(), b.properties().count());
+ QCOMPARE(a.children().count(), b.children().count());
+
+ QList<QQmlDebugPropertyReference> aprops = a.properties();
+ QList<QQmlDebugPropertyReference> bprops = b.properties();
+
+ for (int i=0; i<aprops.count(); i++)
+ compareProperties(aprops[i], bprops[i]);
+
+ for (int i=0; i<a.children().count(); i++)
+ recursiveCompareObjects(a.children()[i], b.children()[i]);
+}
+
+void tst_QQmlEngineDebug::recursiveCompareContexts(const QQmlDebugContextReference &a, const QQmlDebugContextReference &b) const
+{
+ QCOMPARE(a.debugId(), b.debugId());
+ QCOMPARE(a.name(), b.name());
+ QCOMPARE(a.objects().count(), b.objects().count());
+ QCOMPARE(a.contexts().count(), b.contexts().count());
+
+ for (int i=0; i<a.objects().count(); i++)
+ recursiveCompareObjects(a.objects()[i], b.objects()[i]);
+
+ for (int i=0; i<a.contexts().count(); i++)
+ recursiveCompareContexts(a.contexts()[i], b.contexts()[i]);
+}
+
+void tst_QQmlEngineDebug::compareProperties(const QQmlDebugPropertyReference &a, const QQmlDebugPropertyReference &b) const
+{
+ QCOMPARE(a.objectDebugId(), b.objectDebugId());
+ QCOMPARE(a.name(), b.name());
+ QCOMPARE(a.value(), b.value());
+ QCOMPARE(a.valueTypeName(), b.valueTypeName());
+ QCOMPARE(a.binding(), b.binding());
+ QCOMPARE(a.hasNotifySignal(), b.hasNotifySignal());
+}
+
+void tst_QQmlEngineDebug::initTestCase()
+{
+ qRegisterMetaType<QQmlDebugWatch::State>();
+ qmlRegisterType<NonScriptProperty>("Test", 1, 0, "NonScriptPropertyElement");
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Waiting for connection on port 3768...");
+ m_engine = new QQmlEngine(this);
+
+ QList<QByteArray> qml;
+ qml << "import QtQuick 2.0\n"
+ "import Test 1.0\n"
+ "Item {"
+ "id: root\n"
+ "width: 10; height: 20; scale: blueRect.scale;"
+ "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }"
+ "Text { color: blueRect.color; }"
+ "MouseArea {"
+ "onEntered: { console.log('hello') }"
+ "}"
+ "property variant varObj\n"
+ "property variant varObjList: []\n"
+ "property variant varObjMap\n"
+ "Component.onCompleted: {\n"
+ "varObj = blueRect;\n"
+ "var list = varObjList;\n"
+ "list[0] = blueRect;\n"
+ "varObjList = list;\n"
+ "var map = new Object;\n"
+ "map.rect = blueRect;\n"
+ "varObjMap = map;\n"
+ "}\n"
+ "NonScriptPropertyElement {\n"
+ "}\n"
+ "}";
+
+ // add second component to test multiple root contexts
+ qml << "import QtQuick 2.0\n"
+ "Item {}";
+
+ // and a third to test methods
+ qml << "import QtQuick 2.0\n"
+ "Item {"
+ "function myMethodNoArgs() { return 3; }\n"
+ "function myMethod(a) { return a + 9; }\n"
+ "function myMethodIndirect() { myMethod(3); }\n"
+ "}";
+
+ // and a fourth to test states
+ qml << "import QtQuick 2.0\n"
+ "Rectangle {\n"
+ "id:rootRect\n"
+ "width:100\n"
+ "states: [\n"
+ "State {\n"
+ "name:\"state1\"\n"
+ "PropertyChanges {\n"
+ "target:rootRect\n"
+ "width:200\n"
+ "}\n"
+ "}\n"
+ "]\n"
+ "transitions: [\n"
+ "Transition {\n"
+ "from:\"*\"\n"
+ "to:\"state1\"\n"
+ "PropertyAnimation {\n"
+ "target:rootRect\n"
+ "property:\"width\"\n"
+ "duration:100\n"
+ "}\n"
+ "}\n"
+ "]\n"
+ "}\n"
+ ;
+
+ for (int i=0; i<qml.count(); i++) {
+ QQmlComponent component(m_engine);
+ component.setData(qml[i], QUrl::fromLocalFile(""));
+ QVERIFY(component.isReady()); // fails if bad syntax
+ m_components << qobject_cast<QQuickItem*>(component.create());
+ }
+ m_rootItem = qobject_cast<QQuickItem*>(m_components.first());
+
+ // add an extra context to test for multiple contexts
+ QQmlContext *context = new QQmlContext(m_engine->rootContext(), this);
+ context->setObjectName("tst_QQmlDebug_childContext");
+
+ m_conn = new QQmlDebugConnection(this);
+ m_conn->connectToHost("127.0.0.1", 3768);
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlDebugServer: Connection established");
+ bool ok = m_conn->waitForConnected();
+ QVERIFY(ok);
+ QTRY_VERIFY(QQmlDebugService::hasDebuggingClient());
+ m_dbg = new QQmlEngineDebug(m_conn, this);
+ QTRY_VERIFY(m_dbg->state() == QQmlEngineDebug::Enabled);
+}
+
+void tst_QQmlEngineDebug::cleanupTestCase()
+{
+ delete m_dbg;
+ delete m_conn;
+ qDeleteAll(m_components);
+ delete m_engine;
+}
+
+void tst_QQmlEngineDebug::setMethodBody()
+{
+ QQmlDebugObjectReference obj = findRootObject(2);
+
+ QObject *root = m_components.at(2);
+ // Without args
+ {
+ QVariant rv;
+ QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, rv)));
+ QVERIFY(rv == QVariant(qreal(3)));
+
+
+ QVERIFY(m_dbg->setMethodBody(obj.debugId(), "myMethodNoArgs", "return 7"));
+ QTest::qWait(100);
+
+ QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, rv)));
+ QVERIFY(rv == QVariant(qreal(7)));
+ }
+
+ // With args
+ {
+ QVariant rv;
+ QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19))));
+ QVERIFY(rv == QVariant(qreal(28)));
+
+ QVERIFY(m_dbg->setMethodBody(obj.debugId(), "myMethod", "return a + 7"));
+ QTest::qWait(100);
+
+ QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19))));
+ QVERIFY(rv == QVariant(qreal(26)));
+ }
+}
+
+void tst_QQmlEngineDebug::watch_property()
+{
+ QQmlDebugObjectReference obj = findRootObject();
+ QQmlDebugPropertyReference prop = findProperty(obj.properties(), "width");
+
+ QQmlDebugPropertyWatch *watch;
+
+ QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
+ watch = unconnected->addWatch(prop, this);
+ QCOMPARE(watch->state(), QQmlDebugWatch::Dead);
+ delete watch;
+ delete unconnected;
+
+ watch = m_dbg->addWatch(QQmlDebugPropertyReference(), this);
+ QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
+ QCOMPARE(watch->state(), QQmlDebugWatch::Inactive);
+ delete watch;
+
+ watch = m_dbg->addWatch(prop, this);
+ QCOMPARE(watch->state(), QQmlDebugWatch::Waiting);
+ QCOMPARE(watch->objectDebugId(), obj.debugId());
+ QCOMPARE(watch->name(), prop.name());
+
+ QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
+
+ int origWidth = m_rootItem->property("width").toInt();
+ m_rootItem->setProperty("width", origWidth*2);
+
+ // stateChanged() is received before valueChanged()
+ QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
+ QCOMPARE(watch->state(), QQmlDebugWatch::Active);
+ QCOMPARE(spy.count(), 1);
+
+ m_dbg->removeWatch(watch);
+ delete watch;
+
+ // restore original value and verify spy doesn't get additional signal since watch has been removed
+ m_rootItem->setProperty("width", origWidth);
+ QTest::qWait(100);
+ QCOMPARE(spy.count(), 1);
+
+ QCOMPARE(spy.at(0).at(0).value<QByteArray>(), prop.name().toUtf8());
+ QCOMPARE(spy.at(0).at(1).value<QVariant>(), qVariantFromValue(origWidth*2));
+}
+
+void tst_QQmlEngineDebug::watch_object()
+{
+ QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+
+ QVERIFY(q_engines->engines().count() > 0);
+ QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+
+ QVERIFY(q_context->rootContext().objects().count() > 0);
+ QQmlDebugObjectQuery *q_obj = m_dbg->queryObject(q_context->rootContext().objects()[0], this);
+ waitForQuery(q_obj);
+
+ QQmlDebugObjectReference obj = q_obj->object();
+
+ delete q_engines;
+ delete q_context;
+ delete q_obj;
+
+ QQmlDebugWatch *watch;
+
+ QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
+ watch = unconnected->addWatch(obj, this);
+ QCOMPARE(watch->state(), QQmlDebugWatch::Dead);
+ delete watch;
+ delete unconnected;
+
+ watch = m_dbg->addWatch(QQmlDebugObjectReference(), this);
+ QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
+ QCOMPARE(watch->state(), QQmlDebugWatch::Inactive);
+ delete watch;
+
+ watch = m_dbg->addWatch(obj, this);
+ QCOMPARE(watch->state(), QQmlDebugWatch::Waiting);
+ QCOMPARE(watch->objectDebugId(), obj.debugId());
+
+ QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
+
+ int origWidth = m_rootItem->property("width").toInt();
+ int origHeight = m_rootItem->property("height").toInt();
+ m_rootItem->setProperty("width", origWidth*2);
+ m_rootItem->setProperty("height", origHeight*2);
+
+ // stateChanged() is received before any valueChanged() signals
+ QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
+ QCOMPARE(watch->state(), QQmlDebugWatch::Active);
+ QVERIFY(spy.count() > 0);
+
+ int newWidth = -1;
+ int newHeight = -1;
+ for (int i=0; i<spy.count(); i++) {
+ const QVariantList &values = spy[i];
+ if (values[0].value<QByteArray>() == "width")
+ newWidth = values[1].value<QVariant>().toInt();
+ else if (values[0].value<QByteArray>() == "height")
+ newHeight = values[1].value<QVariant>().toInt();
+
+ }
+
+ m_dbg->removeWatch(watch);
+ delete watch;
+
+ // since watch has been removed, restoring the original values should not trigger a valueChanged()
+ spy.clear();
+ m_rootItem->setProperty("width", origWidth);
+ m_rootItem->setProperty("height", origHeight);
+ QTest::qWait(100);
+ QCOMPARE(spy.count(), 0);
+
+ QCOMPARE(newWidth, origWidth * 2);
+ QCOMPARE(newHeight, origHeight * 2);
+}
+
+void tst_QQmlEngineDebug::watch_expression()
+{
+ QFETCH(QString, expr);
+ QFETCH(int, increment);
+ QFETCH(int, incrementCount);
+
+ int origWidth = m_rootItem->property("width").toInt();
+
+ QQmlDebugObjectReference obj = findRootObject();
+
+ QQmlDebugObjectExpressionWatch *watch;
+
+ QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
+ watch = unconnected->addWatch(obj, expr, this);
+ QCOMPARE(watch->state(), QQmlDebugWatch::Dead);
+ delete watch;
+ delete unconnected;
+
+ watch = m_dbg->addWatch(QQmlDebugObjectReference(), expr, this);
+ QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
+ QCOMPARE(watch->state(), QQmlDebugWatch::Inactive);
+ delete watch;
+
+ watch = m_dbg->addWatch(obj, expr, this);
+ QCOMPARE(watch->state(), QQmlDebugWatch::Waiting);
+ QCOMPARE(watch->objectDebugId(), obj.debugId());
+ QCOMPARE(watch->expression(), expr);
+
+ QSignalSpy spyState(watch, SIGNAL(stateChanged(QQmlDebugWatch::State)));
+
+ QSignalSpy spy(watch, SIGNAL(valueChanged(QByteArray,QVariant)));
+ int expectedSpyCount = incrementCount + 1; // should also get signal with expression's initial value
+
+ int width = origWidth;
+ for (int i=0; i<incrementCount+1; i++) {
+ if (i > 0) {
+ width += increment;
+ m_rootItem->setProperty("width", width);
+ }
+ if (!QQmlDebugTest::waitForSignal(watch, SIGNAL(valueChanged(QByteArray,QVariant))))
+ QFAIL("Did not receive valueChanged() for expression");
+ }
+
+ if (spyState.count() == 0)
+ QVERIFY(QQmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QQmlDebugWatch::State))));
+ QCOMPARE(spyState.count(), 1);
+ QCOMPARE(watch->state(), QQmlDebugWatch::Active);
+
+ m_dbg->removeWatch(watch);
+ delete watch;
+
+ // restore original value and verify spy doesn't get a signal since watch has been removed
+ m_rootItem->setProperty("width", origWidth);
+ QTest::qWait(100);
+ QCOMPARE(spy.count(), expectedSpyCount);
+
+ width = origWidth + increment;
+ for (int i=0; i<spy.count(); i++) {
+ QCOMPARE(spy.at(i).at(1).value<QVariant>().toInt(), width);
+ width += increment;
+ }
+}
+
+void tst_QQmlEngineDebug::watch_expression_data()
+{
+ QTest::addColumn<QString>("expr");
+ QTest::addColumn<int>("increment");
+ QTest::addColumn<int>("incrementCount");
+
+ QTest::newRow("width") << "width" << 0 << 0;
+ QTest::newRow("width+10") << "width + 10" << 10 << 5;
+}
+
+void tst_QQmlEngineDebug::watch_context()
+{
+ QQmlDebugContextReference c;
+ QTest::ignoreMessage(QtWarningMsg, "QQmlEngineDebug::addWatch(): Not implemented");
+ QVERIFY(!m_dbg->addWatch(c, QString(), this));
+}
+
+void tst_QQmlEngineDebug::watch_file()
+{
+ QQmlDebugFileReference f;
+ QTest::ignoreMessage(QtWarningMsg, "QQmlEngineDebug::addWatch(): Not implemented");
+ QVERIFY(!m_dbg->addWatch(f, this));
+}
+
+void tst_QQmlEngineDebug::queryAvailableEngines()
+{
+ QQmlDebugEnginesQuery *q_engines;
+
+ QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
+ q_engines = unconnected->queryAvailableEngines(0);
+ QCOMPARE(q_engines->state(), QQmlDebugQuery::Error);
+ delete q_engines;
+ delete unconnected;
+
+ q_engines = m_dbg->queryAvailableEngines(this);
+ delete q_engines;
+
+ q_engines = m_dbg->queryAvailableEngines(this);
+ QVERIFY(q_engines->engines().isEmpty());
+ waitForQuery(q_engines);
+
+ // TODO test multiple engines
+ QList<QQmlDebugEngineReference> engines = q_engines->engines();
+ QCOMPARE(engines.count(), 1);
+
+ foreach(const QQmlDebugEngineReference &e, engines) {
+ QCOMPARE(e.debugId(), QQmlDebugService::idForObject(m_engine));
+ QCOMPARE(e.name(), m_engine->objectName());
+ }
+
+ // Make query invalid by deleting client
+ q_engines = m_dbg->queryAvailableEngines(this);
+ QCOMPARE(q_engines->state(), QQmlDebugQuery::Waiting);
+ delete m_dbg;
+ QCOMPARE(q_engines->state(), QQmlDebugQuery::Error);
+ delete q_engines;
+ m_dbg = new QQmlEngineDebug(m_conn, this);
+}
+
+void tst_QQmlEngineDebug::queryRootContexts()
+{
+ QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+ int engineId = q_engines->engines()[0].debugId();
+ delete q_engines;
+
+ QQmlDebugRootContextQuery *q_context;
+
+ QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
+ q_context = unconnected->queryRootContexts(engineId, this);
+ QCOMPARE(q_context->state(), QQmlDebugQuery::Error);
+ delete q_context;
+ delete unconnected;
+
+ q_context = m_dbg->queryRootContexts(engineId, this);
+ delete q_context;
+
+ q_context = m_dbg->queryRootContexts(engineId, this);
+ waitForQuery(q_context);
+
+ QQmlContext *actualContext = m_engine->rootContext();
+ QQmlDebugContextReference context = q_context->rootContext();
+ QCOMPARE(context.debugId(), QQmlDebugService::idForObject(actualContext));
+ QCOMPARE(context.name(), actualContext->objectName());
+
+ QCOMPARE(context.objects().count(), 4); // 4 qml component objects created for context in main()
+
+ // root context query sends only root object data - it doesn't fill in
+ // the children or property info
+ QCOMPARE(context.objects()[0].properties().count(), 0);
+ QCOMPARE(context.objects()[0].children().count(), 0);
+
+ QCOMPARE(context.contexts().count(), 5);
+ QVERIFY(context.contexts()[0].debugId() >= 0);
+ QCOMPARE(context.contexts()[0].name(), QString("tst_QQmlDebug_childContext"));
+
+ // Make query invalid by deleting client
+ q_context = m_dbg->queryRootContexts(engineId, this);
+ QCOMPARE(q_context->state(), QQmlDebugQuery::Waiting);
+ delete m_dbg;
+ QCOMPARE(q_context->state(), QQmlDebugQuery::Error);
+ delete q_context;
+ m_dbg = new QQmlEngineDebug(m_conn, this);
+}
+
+void tst_QQmlEngineDebug::queryObject()
+{
+ QFETCH(bool, recursive);
+
+ QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+
+ QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+ QQmlDebugObjectReference rootObject = q_context->rootContext().objects()[0];
+
+ QQmlDebugObjectQuery *q_obj = 0;
+
+ QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
+ q_obj = recursive ? unconnected->queryObjectRecursive(rootObject, this) : unconnected->queryObject(rootObject, this);
+ QCOMPARE(q_obj->state(), QQmlDebugQuery::Error);
+ delete q_obj;
+ delete unconnected;
+
+ q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
+ delete q_obj;
+
+ q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
+ waitForQuery(q_obj);
+
+ QQmlDebugObjectReference obj = q_obj->object();
+
+ delete q_engines;
+ delete q_context;
+
+ // Make query invalid by deleting client
+ q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this);
+ QCOMPARE(q_obj->state(), QQmlDebugQuery::Waiting);
+ delete m_dbg;
+ QCOMPARE(q_obj->state(), QQmlDebugQuery::Error);
+ delete q_obj;
+ m_dbg = new QQmlEngineDebug(m_conn, this);
+
+ // check source as defined in main()
+ QQmlDebugFileReference source = obj.source();
+ QCOMPARE(source.url(), QUrl::fromLocalFile(""));
+ QCOMPARE(source.lineNumber(), 3);
+ QCOMPARE(source.columnNumber(), 1);
+
+ // generically test all properties, children and childrens' properties
+ recursiveObjectTest(m_rootItem, obj, recursive);
+
+ if (recursive) {
+ foreach(const QQmlDebugObjectReference &child, obj.children())
+ QVERIFY(child.properties().count() > 0);
+
+ QQmlDebugObjectReference rect;
+ QQmlDebugObjectReference text;
+ foreach (const QQmlDebugObjectReference &child, obj.children()) {
+ if (child.className() == "Rectangle")
+ rect = child;
+ else if (child.className() == "Text")
+ text = child;
+ }
+
+ // test specific property values
+ QCOMPARE(findProperty(rect.properties(), "width").value(), qVariantFromValue(500));
+ QCOMPARE(findProperty(rect.properties(), "height").value(), qVariantFromValue(600));
+ QCOMPARE(findProperty(rect.properties(), "color").value(), qVariantFromValue(QColor("blue")));
+
+ QCOMPARE(findProperty(text.properties(), "color").value(), qVariantFromValue(QColor("blue")));
+ } else {
+ foreach(const QQmlDebugObjectReference &child, obj.children())
+ QCOMPARE(child.properties().count(), 0);
+ }
+}
+
+void tst_QQmlEngineDebug::queryObject_data()
+{
+ QTest::addColumn<bool>("recursive");
+
+ QTest::newRow("non-recursive") << false;
+ QTest::newRow("recursive") << true;
+}
+
+void tst_QQmlEngineDebug::queryExpressionResult()
+{
+ QFETCH(QString, expr);
+ QFETCH(QVariant, result);
+
+ QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines); // check immediate deletion is ok
+
+ QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+ int objectId = q_context->rootContext().objects()[0].debugId();
+
+ QQmlDebugExpressionQuery *q_expr;
+
+ QQmlEngineDebug *unconnected = new QQmlEngineDebug(0);
+ q_expr = unconnected->queryExpressionResult(objectId, expr, this);
+ QCOMPARE(q_expr->state(), QQmlDebugQuery::Error);
+ delete q_expr;
+ delete unconnected;
+
+ q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
+ delete q_expr;
+
+ q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
+ QCOMPARE(q_expr->expression().toString(), expr);
+ waitForQuery(q_expr);
+
+ QCOMPARE(q_expr->result(), result);
+
+ delete q_engines;
+ delete q_context;
+
+ // Make query invalid by deleting client
+ q_expr = m_dbg->queryExpressionResult(objectId, expr, this);
+ QCOMPARE(q_expr->state(), QQmlDebugQuery::Waiting);
+ delete m_dbg;
+ QCOMPARE(q_expr->state(), QQmlDebugQuery::Error);
+ delete q_expr;
+ m_dbg = new QQmlEngineDebug(m_conn, this);
+}
+
+void tst_QQmlEngineDebug::queryExpressionResult_data()
+{
+ QTest::addColumn<QString>("expr");
+ QTest::addColumn<QVariant>("result");
+
+ QTest::newRow("width + 50") << "width + 50" << qVariantFromValue(60);
+ QTest::newRow("blueRect.width") << "blueRect.width" << qVariantFromValue(500);
+ QTest::newRow("bad expr") << "aeaef" << qVariantFromValue(QString("<undefined>"));
+ QTest::newRow("QObject*") << "varObj" << qVariantFromValue(QString("<unnamed object>"));
+ QTest::newRow("list of QObject*") << "varObjList" << qVariantFromValue(QString("<unknown value>"));
+ QVariantMap map;
+ map.insert(QLatin1String("rect"), QVariant(QLatin1String("<unnamed object>")));
+ QTest::newRow("varObjMap") << "varObjMap" << qVariantFromValue(map);
+}
+
+void tst_QQmlEngineDebug::tst_QQmlDebugFileReference()
+{
+ QQmlDebugFileReference ref;
+ QVERIFY(ref.url().isEmpty());
+ QCOMPARE(ref.lineNumber(), -1);
+ QCOMPARE(ref.columnNumber(), -1);
+
+ ref.setUrl(QUrl("http://test"));
+ QCOMPARE(ref.url(), QUrl("http://test"));
+ ref.setLineNumber(1);
+ QCOMPARE(ref.lineNumber(), 1);
+ ref.setColumnNumber(1);
+ QCOMPARE(ref.columnNumber(), 1);
+
+ QQmlDebugFileReference copy(ref);
+ QQmlDebugFileReference copyAssign;
+ copyAssign = ref;
+ foreach (const QQmlDebugFileReference &r, (QList<QQmlDebugFileReference>() << copy << copyAssign)) {
+ QCOMPARE(r.url(), ref.url());
+ QCOMPARE(r.lineNumber(), ref.lineNumber());
+ QCOMPARE(r.columnNumber(), ref.columnNumber());
+ }
+}
+
+void tst_QQmlEngineDebug::tst_QQmlDebugEngineReference()
+{
+ QQmlDebugEngineReference ref;
+ QCOMPARE(ref.debugId(), -1);
+ QVERIFY(ref.name().isEmpty());
+
+ ref = QQmlDebugEngineReference(1);
+ QCOMPARE(ref.debugId(), 1);
+ QVERIFY(ref.name().isEmpty());
+
+ QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+ ref = q_engines->engines()[0];
+ delete q_engines;
+
+ QQmlDebugEngineReference copy(ref);
+ QQmlDebugEngineReference copyAssign;
+ copyAssign = ref;
+ foreach (const QQmlDebugEngineReference &r, (QList<QQmlDebugEngineReference>() << copy << copyAssign)) {
+ QCOMPARE(r.debugId(), ref.debugId());
+ QCOMPARE(r.name(), ref.name());
+ }
+}
+
+void tst_QQmlEngineDebug::tst_QQmlDebugObjectReference()
+{
+ QQmlDebugObjectReference ref;
+ QCOMPARE(ref.debugId(), -1);
+ QCOMPARE(ref.className(), QString());
+ QCOMPARE(ref.name(), QString());
+ QCOMPARE(ref.contextDebugId(), -1);
+ QVERIFY(ref.properties().isEmpty());
+ QVERIFY(ref.children().isEmpty());
+
+ QQmlDebugFileReference source = ref.source();
+ QVERIFY(source.url().isEmpty());
+ QVERIFY(source.lineNumber() < 0);
+ QVERIFY(source.columnNumber() < 0);
+
+ ref = QQmlDebugObjectReference(1);
+ QCOMPARE(ref.debugId(), 1);
+
+ QQmlDebugObjectReference rootObject = findRootObject();
+ QQmlDebugObjectQuery *query = m_dbg->queryObjectRecursive(rootObject, this);
+ waitForQuery(query);
+ ref = query->object();
+ delete query;
+
+ QVERIFY(ref.debugId() >= 0);
+
+ QQmlDebugObjectReference copy(ref);
+ QQmlDebugObjectReference copyAssign;
+ copyAssign = ref;
+ foreach (const QQmlDebugObjectReference &r, (QList<QQmlDebugObjectReference>() << copy << copyAssign))
+ recursiveCompareObjects(r, ref);
+}
+
+void tst_QQmlEngineDebug::tst_QQmlDebugContextReference()
+{
+ QQmlDebugContextReference ref;
+ QCOMPARE(ref.debugId(), -1);
+ QVERIFY(ref.name().isEmpty());
+ QVERIFY(ref.objects().isEmpty());
+ QVERIFY(ref.contexts().isEmpty());
+
+ QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+ QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+
+ ref = q_context->rootContext();
+ delete q_engines;
+ delete q_context;
+ QVERIFY(ref.debugId() >= 0);
+
+ QQmlDebugContextReference copy(ref);
+ QQmlDebugContextReference copyAssign;
+ copyAssign = ref;
+ foreach (const QQmlDebugContextReference &r, (QList<QQmlDebugContextReference>() << copy << copyAssign))
+ recursiveCompareContexts(r, ref);
+}
+
+void tst_QQmlEngineDebug::tst_QQmlDebugPropertyReference()
+{
+ QQmlDebugObjectReference rootObject = findRootObject();
+ QQmlDebugObjectQuery *query = m_dbg->queryObject(rootObject, this);
+ waitForQuery(query);
+ QQmlDebugObjectReference obj = query->object();
+ delete query;
+
+ QQmlDebugPropertyReference ref = findProperty(obj.properties(), "scale");
+ QVERIFY(ref.objectDebugId() > 0);
+ QVERIFY(!ref.name().isEmpty());
+ QVERIFY(!ref.value().isNull());
+ QVERIFY(!ref.valueTypeName().isEmpty());
+ QVERIFY(!ref.binding().isEmpty());
+ QVERIFY(ref.hasNotifySignal());
+
+ QQmlDebugPropertyReference copy(ref);
+ QQmlDebugPropertyReference copyAssign;
+ copyAssign = ref;
+ foreach (const QQmlDebugPropertyReference &r, (QList<QQmlDebugPropertyReference>() << copy << copyAssign))
+ compareProperties(r, ref);
+}
+
+void tst_QQmlEngineDebug::setBindingForObject()
+{
+ QQmlDebugObjectReference rootObject = findRootObject();
+ QVERIFY(rootObject.debugId() != -1);
+ QQmlDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties(), "width");
+
+ QCOMPARE(widthPropertyRef.value(), QVariant(10));
+ QCOMPARE(widthPropertyRef.binding(), QString());
+
+ //
+ // set literal
+ //
+ m_dbg->setBindingForObject(rootObject.debugId(), "width", "15", true);
+
+ rootObject = findRootObject();
+ widthPropertyRef = findProperty(rootObject.properties(), "width");
+
+ QCOMPARE(widthPropertyRef.value(), QVariant(15));
+ QCOMPARE(widthPropertyRef.binding(), QString());
+
+ //
+ // set expression
+ //
+ m_dbg->setBindingForObject(rootObject.debugId(), "width", "height", false);
+
+ rootObject = findRootObject();
+ widthPropertyRef = findProperty(rootObject.properties(), "width");
+
+ QCOMPARE(widthPropertyRef.value(), QVariant(20));
+ QCOMPARE(widthPropertyRef.binding(), QString("height"));
+
+ //
+ // reset
+ //
+ m_dbg->resetBindingForObject(rootObject.debugId(), "width");
+
+ rootObject = findRootObject();
+ widthPropertyRef = findProperty(rootObject.properties(), "width");
+
+ // QCOMPARE(widthPropertyRef.value(), QVariant(0)); // TODO: Shouldn't this work?
+ QCOMPARE(widthPropertyRef.binding(), QString());
+
+ //
+ // set handler
+ //
+ rootObject = findRootObject();
+ QCOMPARE(rootObject.children().size(), 5); // Rectangle, Text, MouseArea, Component.onCompleted, NonScriptPropertyElement
+ QQmlDebugObjectReference mouseAreaObject = rootObject.children().at(2);
+ QQmlDebugObjectQuery *q_obj = m_dbg->queryObjectRecursive(mouseAreaObject, this);
+ waitForQuery(q_obj);
+ mouseAreaObject = q_obj->object();
+
+ QCOMPARE(mouseAreaObject.className(), QString("MouseArea"));
+
+ QQmlDebugPropertyReference onEnteredRef = findProperty(mouseAreaObject.properties(), "onEntered");
+
+ QCOMPARE(onEnteredRef.name(), QString("onEntered"));
+ QCOMPARE(onEnteredRef.value(), QVariant("(function onEntered() { { console.log('hello') } })"));
+
+ m_dbg->setBindingForObject(mouseAreaObject.debugId(), "onEntered", "{console.log('hello, world') }", false) ;
+
+ rootObject = findRootObject();
+ mouseAreaObject = rootObject.children().at(2);
+ q_obj = m_dbg->queryObjectRecursive(mouseAreaObject, this);
+ waitForQuery(q_obj);
+ mouseAreaObject = q_obj->object();
+ onEnteredRef = findProperty(mouseAreaObject.properties(), "onEntered");
+ QCOMPARE(onEnteredRef.name(), QString("onEntered"));
+ QCOMPARE(onEnteredRef.value(), QVariant("{console.log('hello, world') }"));
+}
+
+void tst_QQmlEngineDebug::setBindingInStates()
+{
+ // Check if changing bindings of propertychanges works
+
+ const int sourceIndex = 3;
+
+ QQmlDebugObjectReference obj = findRootObject(sourceIndex);
+
+ QVERIFY(obj.debugId() != -1);
+ QVERIFY(obj.children().count() >= 2);
+
+ // We are going to switch state a couple of times, we need to get rid of the transition before
+ QQmlDebugExpressionQuery *q_deleteTransition = m_dbg->queryExpressionResult(obj.debugId(),QString("transitions = []"),this);
+ waitForQuery(q_deleteTransition);
+ delete q_deleteTransition;
+
+
+ // check initial value of the property that is changing
+ QQmlDebugExpressionQuery *q_setState;
+ q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this);
+ waitForQuery(q_setState);
+ delete q_setState;
+
+ obj = findRootObject(sourceIndex);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),200);
+
+
+ q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"\""),this);
+ waitForQuery(q_setState);
+ delete q_setState;
+
+
+ obj = findRootObject(sourceIndex, true);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),100);
+
+
+ // change the binding
+ QQmlDebugObjectReference state = obj.children()[1];
+ QCOMPARE(state.className(), QString("State"));
+ QVERIFY(state.children().count() > 0);
+
+ QQmlDebugObjectReference propertyChange = state.children()[0];
+ QVERIFY(propertyChange.debugId() != -1);
+
+ QVERIFY( m_dbg->setBindingForObject(propertyChange.debugId(), "width",QVariant(300),true) );
+
+ // check properties changed in state
+ obj = findRootObject(sourceIndex);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),100);
+
+
+ q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this);
+ waitForQuery(q_setState);
+ delete q_setState;
+
+ obj = findRootObject(sourceIndex);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),300);
+
+ // check changing properties of base state from within a state
+ QVERIFY(m_dbg->setBindingForObject(obj.debugId(),"width","height*2",false));
+ QVERIFY(m_dbg->setBindingForObject(obj.debugId(),"height","200",true));
+
+ obj = findRootObject(sourceIndex);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(),300);
+
+ q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"\""),this);
+ waitForQuery(q_setState);
+ delete q_setState;
+
+ obj = findRootObject(sourceIndex);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 400);
+
+ // reset binding while in a state
+ q_setState = m_dbg->queryExpressionResult(obj.debugId(),QString("state=\"state1\""),this);
+ waitForQuery(q_setState);
+ delete q_setState;
+
+ obj = findRootObject(sourceIndex);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 300);
+
+ m_dbg->resetBindingForObject(propertyChange.debugId(), "width");
+
+ obj = findRootObject(sourceIndex);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 400);
+
+ // re-add binding
+ m_dbg->setBindingForObject(propertyChange.debugId(), "width", "300", true);
+
+ obj = findRootObject(sourceIndex);
+ QCOMPARE(findProperty(obj.properties(),"width").value().toInt(), 300);
+}
+
+void tst_QQmlEngineDebug::queryObjectTree()
+{
+ const int sourceIndex = 3;
+
+ // Check if states/transitions are initialized when fetching root item
+ QQmlDebugEnginesQuery *q_engines = m_dbg->queryAvailableEngines(this);
+ waitForQuery(q_engines);
+
+ QQmlDebugRootContextQuery *q_context = m_dbg->queryRootContexts(q_engines->engines()[0].debugId(), this);
+ waitForQuery(q_context);
+
+ QVERIFY(q_context->rootContext().objects().count() > sourceIndex);
+ QQmlDebugObjectReference rootObject = q_context->rootContext().objects()[sourceIndex];
+
+ QQmlDebugObjectQuery *q_obj = m_dbg->queryObjectRecursive(rootObject, this);
+ waitForQuery(q_obj);
+
+ QQmlDebugObjectReference obj = q_obj->object();
+
+ delete q_engines;
+ delete q_context;
+ delete q_obj;
+
+ QVERIFY(obj.debugId() != -1);
+ QVERIFY(obj.children().count() >= 2);
+
+
+
+ // check state
+ QQmlDebugObjectReference state = obj.children()[1];
+ QCOMPARE(state.className(), QString("State"));
+ QVERIFY(state.children().count() > 0);
+
+ QQmlDebugObjectReference propertyChange = state.children()[0];
+ QVERIFY(propertyChange.debugId() != -1);
+
+ QQmlDebugPropertyReference propertyChangeTarget = findProperty(propertyChange.properties(),"target");
+ QCOMPARE(propertyChangeTarget.objectDebugId(), propertyChange.debugId());
+
+ QQmlDebugObjectReference targetReference = qvariant_cast<QQmlDebugObjectReference>(propertyChangeTarget.value());
+ QVERIFY(targetReference.debugId() != -1);
+
+
+
+ // check transition
+ QQmlDebugObjectReference transition = obj.children()[0];
+ QCOMPARE(transition.className(), QString("Transition"));
+ QCOMPARE(findProperty(transition.properties(),"from").value().toString(), QString("*"));
+ QCOMPARE(findProperty(transition.properties(),"to").value(), findProperty(state.properties(),"name").value());
+ QVERIFY(transition.children().count() > 0);
+
+ QQmlDebugObjectReference animation = transition.children()[0];
+ QVERIFY(animation.debugId() != -1);
+
+ QQmlDebugPropertyReference animationTarget = findProperty(animation.properties(),"target");
+ QCOMPARE(animationTarget.objectDebugId(), animation.debugId());
+
+ targetReference = qvariant_cast<QQmlDebugObjectReference>(animationTarget.value());
+ QVERIFY(targetReference.debugId() != -1);
+
+ QCOMPARE(findProperty(animation.properties(),"property").value().toString(), QString("width"));
+ QCOMPARE(findProperty(animation.properties(),"duration").value().toInt(), 100);
+}
+
+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];
+ char arg[] = "-qmljsdebugger=port:3768";
+ _argv[_argc - 1] = arg;
+
+ QGuiApplication app(_argc, _argv);
+ tst_QQmlEngineDebug tc;
+ return QTest::qExec(&tc, _argc, _argv);
+ delete _argv;
+}
+
+#include "tst_qqmlenginedebug.moc"
diff --git a/tests/auto/qml/debugger/qqmlinspector/app/app.pro b/tests/auto/qml/debugger/qqmlinspector/app/app.pro
new file mode 100644
index 0000000000..f6ef983735
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlinspector/app/app.pro
@@ -0,0 +1,9 @@
+TARGET = app
+QT += qml quick widgets
+
+CONFIG += declarative_debug
+macx:CONFIG -= app_bundle
+
+SOURCES += main.cpp
+
+OTHER_FILES += qtquick1.qml qtquick2.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativeinspector/app/main.cpp b/tests/auto/qml/debugger/qqmlinspector/app/main.cpp
index a7ef09c283..a7ef09c283 100644
--- a/tests/auto/declarative/debugger/qdeclarativeinspector/app/main.cpp
+++ b/tests/auto/qml/debugger/qqmlinspector/app/main.cpp
diff --git a/tests/auto/declarative/debugger/qdeclarativeinspector/app/qtquick2.qml b/tests/auto/qml/debugger/qqmlinspector/app/qtquick2.qml
index 9c36e13c5b..9c36e13c5b 100644
--- a/tests/auto/declarative/debugger/qdeclarativeinspector/app/qtquick2.qml
+++ b/tests/auto/qml/debugger/qqmlinspector/app/qtquick2.qml
diff --git a/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro b/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro
new file mode 100644
index 0000000000..5544f76581
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+
+SUBDIRS += tst_qqmlinspector.pro app
diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
new file mode 100644
index 0000000000..4f74a036d6
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <QTimer>
+#include <QHostAddress>
+#include <QDebug>
+#include <QThread>
+
+#include "../../../../../src/plugins/qmltooling/shared/qqmlinspectorprotocol.h"
+#include "../shared/debugutil_p.h"
+
+using namespace QmlJSDebugger;
+
+#define PORT 13772
+#define STR_PORT "13772"
+
+class QQmlInspectorClient : public QQmlDebugClient
+{
+ Q_OBJECT
+
+public:
+ QQmlInspectorClient(QQmlDebugConnection *connection)
+ : QQmlDebugClient(QLatin1String("QQmlObserverMode"), connection)
+ , m_showAppOnTop(false)
+ {
+ }
+
+ bool showAppOnTop() const { return m_showAppOnTop; }
+ void setShowAppOnTop(bool showOnTop);
+
+signals:
+ void showAppOnTopChanged();
+
+protected:
+ void messageReceived(const QByteArray &message);
+
+private:
+ bool m_showAppOnTop;
+};
+
+class tst_QQmlInspector : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QQmlInspector()
+ : m_process(0)
+ , m_connection(0)
+ , m_client(0)
+ {
+ }
+
+
+private:
+ QQmlDebugProcess *m_process;
+ QQmlDebugConnection *m_connection;
+ QQmlInspectorClient *m_client;
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+ void connect();
+ void showAppOnTop();
+};
+
+
+void QQmlInspectorClient::setShowAppOnTop(bool showOnTop)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << InspectorProtocol::ShowAppOnTop << showOnTop;
+
+ sendMessage(message);
+}
+
+void QQmlInspectorClient::messageReceived(const QByteArray &message)
+{
+ QDataStream ds(message);
+ InspectorProtocol::Message type;
+ ds >> type;
+
+ switch (type) {
+ case InspectorProtocol::ShowAppOnTop:
+ ds >> m_showAppOnTop;
+ emit showAppOnTopChanged();
+ break;
+ default:
+ qDebug() << "Unhandled message " << (int)type;
+ }
+}
+
+void tst_QQmlInspector::initTestCase()
+{
+}
+
+void tst_QQmlInspector::cleanupTestCase()
+{
+}
+
+void tst_QQmlInspector::init()
+{
+ const QString executable = SRCDIR"/app/app";
+ const QString argument = "-qmljsdebugger=port:"STR_PORT",block";
+
+ m_process = new QQmlDebugProcess(executable);
+ m_process->start(QStringList() << argument);
+ if (!m_process->waitForSessionStart()) {
+ QFAIL(QString("Could not launch app '%1'.\nApplication output:\n%2").arg(executable, m_process->output()).toAscii());
+ }
+
+ QQmlDebugConnection *m_connection = new QQmlDebugConnection();
+ m_client = new QQmlInspectorClient(m_connection);
+
+ m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT);
+}
+
+void tst_QQmlInspector::cleanup()
+{
+ delete m_process;
+ delete m_connection;
+ delete m_client;
+}
+
+void tst_QQmlInspector::connect()
+{
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+}
+
+void tst_QQmlInspector::showAppOnTop()
+{
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->setShowAppOnTop(true);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(showAppOnTopChanged())));
+ QCOMPARE(m_client->showAppOnTop(), true);
+
+ m_client->setShowAppOnTop(false);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(showAppOnTopChanged())));
+ QCOMPARE(m_client->showAppOnTop(), false);
+}
+
+QTEST_MAIN(tst_QQmlInspector)
+
+#include "tst_qqmlinspector.moc"
diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro
new file mode 100644
index 0000000000..010e97cef7
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.pro
@@ -0,0 +1,12 @@
+CONFIG += testcase
+TARGET = tst_qqmlinspector
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+SOURCES += tst_qqmlinspector.cpp \
+ ../shared/debugutil.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+CONFIG += parallel_test declarative_debug
+
+QT += qml-private testlib
diff --git a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/exit.qml b/tests/auto/qml/debugger/qqmlprofilerservice/data/exit.qml
index b250524caa..b250524caa 100644
--- a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/exit.qml
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/exit.qml
diff --git a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/test.qml b/tests/auto/qml/debugger/qqmlprofilerservice/data/test.qml
index 9c36e13c5b..9c36e13c5b 100644
--- a/tests/auto/declarative/debugger/qdeclarativeprofilerservice/data/test.qml
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/test.qml
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
new file mode 100644
index 0000000000..0d11213cb4
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlprofilerservice
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+
+SOURCES += tst_qqmlprofilerservice.cpp \
+ ../shared/debugutil.cpp
+OTHER_FILES += data/test.qml
+
+include (../../../shared/util.pri)
+
+CONFIG += parallel_test declarative_debug
+
+QT += qml-private testlib
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
new file mode 100644
index 0000000000..edc120ba85
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
@@ -0,0 +1,310 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QLibraryInfo>
+
+#include "QtQml/private/qqmlprofilerservice_p.h"
+#include "../shared/debugutil_p.h"
+#include "../../../shared/util.h"
+
+#define PORT 13773
+#define STR_PORT "13773"
+
+class QQmlProfilerClient : public QQmlDebugClient
+{
+ Q_OBJECT
+
+public:
+ QQmlProfilerClient(QQmlDebugConnection *connection)
+ : QQmlDebugClient(QLatin1String("CanvasFrameRate"), connection)
+ {
+ }
+
+ QList<QQmlProfilerData> traceMessages;
+
+ void setTraceState(bool enabled) {
+ QByteArray message;
+ QDataStream stream(&message, QIODevice::WriteOnly);
+ stream << enabled;
+ sendMessage(message);
+ }
+
+signals:
+ void complete();
+
+protected:
+ void messageReceived(const QByteArray &message);
+};
+
+class tst_QQmlProfilerService : public QQmlDataTest
+{
+ Q_OBJECT
+
+public:
+ tst_QQmlProfilerService()
+ : m_process(0)
+ , m_connection(0)
+ , m_client(0)
+ {
+ }
+
+private:
+ QQmlDebugProcess *m_process;
+ QQmlDebugConnection *m_connection;
+ QQmlProfilerClient *m_client;
+
+ void connect(bool block, const QString &testFile);
+
+private slots:
+ void cleanup();
+
+ void blockingConnectWithTraceEnabled();
+ void blockingConnectWithTraceDisabled();
+ void nonBlockingConnect();
+ void profileOnExit();
+};
+
+void QQmlProfilerClient::messageReceived(const QByteArray &message)
+{
+ QByteArray msg = message;
+ QDataStream stream(&msg, QIODevice::ReadOnly);
+
+
+ QQmlProfilerData data;
+ data.time = -2;
+ data.messageType = -1;
+ data.detailType = -1;
+ data.line = -1;
+ data.framerate = -1;
+ data.animationcount = -1;
+
+ stream >> data.time >> data.messageType;
+
+ QVERIFY(data.time >= -1);
+
+ switch (data.messageType) {
+ case (QQmlProfilerService::Event): {
+ stream >> data.detailType;
+
+ switch (data.detailType) {
+ case QQmlProfilerService::AnimationFrame: {
+ stream >> data.framerate >> data.animationcount;
+ QVERIFY(data.framerate != -1);
+ QVERIFY(data.animationcount != -1);
+ break;
+ }
+ case QQmlProfilerService::FramePaint:
+ case QQmlProfilerService::Mouse:
+ case QQmlProfilerService::Key:
+ case QQmlProfilerService::StartTrace:
+ case QQmlProfilerService::EndTrace:
+ break;
+ default: {
+ QString failMsg = QString("Unknown event type:") + data.detailType;
+ QFAIL(qPrintable(failMsg));
+ break;
+ }
+ }
+ break;
+ }
+ case QQmlProfilerService::Complete: {
+ emit complete();
+ return;
+ }
+ case QQmlProfilerService::RangeStart: {
+ stream >> data.detailType;
+ QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerService::MaximumRangeType);
+ break;
+ }
+ case QQmlProfilerService::RangeEnd: {
+ stream >> data.detailType;
+ QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerService::MaximumRangeType);
+ break;
+ }
+ case QQmlProfilerService::RangeData: {
+ stream >> data.detailType >> data.detailData;
+ QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerService::MaximumRangeType);
+ break;
+ }
+ case QQmlProfilerService::RangeLocation: {
+ stream >> data.detailType >> data.detailData >> data.line >> data.column;
+ QVERIFY(data.detailType >= 0 && data.detailType < QQmlProfilerService::MaximumRangeType);
+ QVERIFY(data.line >= -2);
+ break;
+ }
+ default:
+ QString failMsg = QString("Unknown message type:") + data.messageType;
+ QFAIL(qPrintable(failMsg));
+ break;
+ }
+ QVERIFY(stream.atEnd());
+ traceMessages.append(data);
+}
+
+void tst_QQmlProfilerService::connect(bool block, const QString &testFile)
+{
+ const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene";
+ QStringList arguments;
+
+ if (block)
+ arguments << QString("-qmljsdebugger=port:"STR_PORT",block");
+ else
+ arguments << QString("-qmljsdebugger=port:"STR_PORT);
+
+ arguments << QQmlDataTest::instance()->testFile(testFile);
+
+ m_process = new QQmlDebugProcess(executable);
+ m_process->start(QStringList() << arguments);
+ if (!m_process->waitForSessionStart()) {
+ QString failMsg = QString("Could not launch app '%1'.\nApplication output:\n%2").arg(
+ executable, m_process->output());
+ QFAIL(qPrintable(failMsg));
+ }
+
+ QQmlDebugConnection *m_connection = new QQmlDebugConnection();
+ m_client = new QQmlProfilerClient(m_connection);
+
+ m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT);
+}
+
+void tst_QQmlProfilerService::cleanup()
+{
+ delete m_process;
+ delete m_connection;
+ delete m_client;
+}
+
+void tst_QQmlProfilerService::blockingConnectWithTraceEnabled()
+{
+ connect(true, "test.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->setTraceState(true);
+ m_client->setTraceState(false);
+ if (!QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
+ QString failMsg
+ = QString("No trace received in time. App output: \n%1\n").arg(m_process->output());
+ QFAIL(qPrintable(failMsg));
+ }
+
+ QVERIFY(m_client->traceMessages.count());
+ // must start with "StartTrace"
+ QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerService::Event);
+ QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerService::StartTrace);
+
+ // must end with "EndTrace"
+ QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerService::Event);
+ QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerService::EndTrace);
+}
+
+void tst_QQmlProfilerService::blockingConnectWithTraceDisabled()
+{
+ connect(true, "test.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->setTraceState(false);
+ m_client->setTraceState(true);
+ m_client->setTraceState(false);
+ if (!QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
+ QString failMsg
+ = QString("No trace received in time. App output: \n%1\n").arg(m_process->output());
+ QFAIL(qPrintable(failMsg));
+ }
+
+ QVERIFY(m_client->traceMessages.count());
+
+ // must start with "StartTrace"
+ QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerService::Event);
+ QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerService::StartTrace);
+
+ // must end with "EndTrace"
+ QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerService::Event);
+ QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerService::EndTrace);
+}
+
+void tst_QQmlProfilerService::nonBlockingConnect()
+{
+ connect(false, "test.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->setTraceState(true);
+ m_client->setTraceState(false);
+ if (!QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
+ QString failMsg
+ = QString("No trace received in time. App output: \n%1\n").arg(m_process->output());
+ QFAIL(qPrintable(failMsg));
+ }
+
+ // must start with "StartTrace"
+ QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerService::Event);
+ QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerService::StartTrace);
+
+ // must end with "EndTrace"
+ QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerService::Event);
+ QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerService::EndTrace);
+}
+
+void tst_QQmlProfilerService::profileOnExit()
+{
+ connect(true, "exit.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->setTraceState(true);
+
+ if (!QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete()))) {
+ QString failMsg
+ = QString("No trace received in time. App output: \n%1\n").arg(m_process->output());
+ QFAIL(qPrintable(failMsg));
+ }
+
+ // must start with "StartTrace"
+ QCOMPARE(m_client->traceMessages.first().messageType, (int)QQmlProfilerService::Event);
+ QCOMPARE(m_client->traceMessages.first().detailType, (int)QQmlProfilerService::StartTrace);
+
+ // must end with "EndTrace"
+ QCOMPARE(m_client->traceMessages.last().messageType, (int)QQmlProfilerService::Event);
+ QCOMPARE(m_client->traceMessages.last().detailType, (int)QQmlProfilerService::EndTrace);
+}
+
+QTEST_MAIN(tst_QQmlProfilerService)
+
+#include "tst_qqmlprofilerservice.moc"
diff --git a/tests/auto/declarative/debugger/qv8profilerservice/data/console.qml b/tests/auto/qml/debugger/qv8profilerservice/data/console.qml
index c23c820216..c23c820216 100644
--- a/tests/auto/declarative/debugger/qv8profilerservice/data/console.qml
+++ b/tests/auto/qml/debugger/qv8profilerservice/data/console.qml
diff --git a/tests/auto/declarative/debugger/qv8profilerservice/data/exit.qml b/tests/auto/qml/debugger/qv8profilerservice/data/exit.qml
index 604265354c..604265354c 100644
--- a/tests/auto/declarative/debugger/qv8profilerservice/data/exit.qml
+++ b/tests/auto/qml/debugger/qv8profilerservice/data/exit.qml
diff --git a/tests/auto/declarative/debugger/qv8profilerservice/data/test.qml b/tests/auto/qml/debugger/qv8profilerservice/data/test.qml
index 9c36e13c5b..9c36e13c5b 100644
--- a/tests/auto/declarative/debugger/qv8profilerservice/data/test.qml
+++ b/tests/auto/qml/debugger/qv8profilerservice/data/test.qml
diff --git a/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro b/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro
new file mode 100644
index 0000000000..e980d6594d
--- /dev/null
+++ b/tests/auto/qml/debugger/qv8profilerservice/qv8profilerservice.pro
@@ -0,0 +1,16 @@
+CONFIG += testcase
+TARGET = tst_qv8profilerservice
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+
+SOURCES += tst_qv8profilerservice.cpp \
+ ../shared/debugutil.cpp
+
+include (../../../shared/util.pri)
+
+OTHER_FILES += data/test.qml
+
+CONFIG += parallel_test declarative_debug
+
+QT += qml-private testlib
diff --git a/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp b/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
new file mode 100644
index 0000000000..a2cac08a21
--- /dev/null
+++ b/tests/auto/qml/debugger/qv8profilerservice/tst_qv8profilerservice.cpp
@@ -0,0 +1,280 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QLibraryInfo>
+
+#include "QtQml/private/qv8profilerservice_p.h"
+#include "../shared/debugutil_p.h"
+#include "../../../shared/util.h"
+
+#define PORT 13774
+#define STR_PORT "13774"
+
+class QV8ProfilerClient : public QQmlDebugClient
+{
+ Q_OBJECT
+
+public:
+ QV8ProfilerClient(QQmlDebugConnection *connection)
+ : QQmlDebugClient(QLatin1String("V8Profiler"), connection)
+ {
+ }
+
+ void startProfiling(const QString &name) {
+ QByteArray message;
+ QDataStream stream(&message, QIODevice::WriteOnly);
+ stream << QByteArray("V8PROFILER") << QByteArray("start") << name;
+ sendMessage(message);
+ }
+
+ void stopProfiling(const QString &name) {
+ QByteArray message;
+ QDataStream stream(&message, QIODevice::WriteOnly);
+ stream << QByteArray("V8PROFILER") << QByteArray("stop") << name;
+ sendMessage(message);
+ }
+
+ void takeSnapshot() {
+ QByteArray message;
+ QDataStream stream(&message, QIODevice::WriteOnly);
+ stream << QByteArray("V8SNAPSHOT") << QByteArray("full");
+ sendMessage(message);
+ }
+
+ void deleteSnapshots() {
+ QByteArray message;
+ QDataStream stream(&message, QIODevice::WriteOnly);
+ stream << QByteArray("V8SNAPSHOT") << QByteArray("delete");
+ sendMessage(message);
+ }
+
+ QList<QV8ProfilerData> traceMessages;
+ QList<QByteArray> snapshotMessages;
+
+signals:
+ void complete();
+ void snapshot();
+
+protected:
+ void messageReceived(const QByteArray &message);
+};
+
+class tst_QV8ProfilerService : public QQmlDataTest
+{
+ Q_OBJECT
+
+public:
+ tst_QV8ProfilerService()
+ : m_process(0)
+ , m_connection(0)
+ , m_client(0)
+ {
+ }
+
+private:
+ QQmlDebugProcess *m_process;
+ QQmlDebugConnection *m_connection;
+ QV8ProfilerClient *m_client;
+
+ void connect(bool block, const QString &testFile);
+
+private slots:
+ void cleanup();
+
+ void blockingConnectWithTraceEnabled();
+ void blockingConnectWithTraceDisabled();
+ void nonBlockingConnect();
+ void snapshot();
+ void profileOnExit();
+ void console();
+};
+
+void QV8ProfilerClient::messageReceived(const QByteArray &message)
+{
+ QByteArray msg = message;
+ QDataStream stream(&msg, QIODevice::ReadOnly);
+
+ int messageType;
+ stream >> messageType;
+
+ QVERIFY(messageType >= 0);
+ QVERIFY(messageType < QV8ProfilerService::V8MaximumMessage);
+
+ switch (messageType) {
+ case QV8ProfilerService::V8Entry: {
+ QV8ProfilerData entry;
+ stream >> entry.filename >> entry.functionname >> entry.lineNumber >> entry.totalTime >> entry.selfTime >> entry.treeLevel;
+ traceMessages.append(entry);
+ break;
+ }
+ case QV8ProfilerService::V8Complete:
+ emit complete();
+ break;
+ case QV8ProfilerService::V8SnapshotChunk: {
+ QByteArray json;
+ stream >> json;
+ snapshotMessages.append(json);
+ break;
+ }
+ case QV8ProfilerService::V8SnapshotComplete:
+ emit snapshot();
+ break;
+ default:
+ QString failMessage = QString("Unknown message type: %1").arg(messageType);
+ QFAIL(qPrintable(failMessage));
+ }
+
+ QVERIFY(stream.atEnd());
+}
+
+void tst_QV8ProfilerService::connect(bool block, const QString &testFile)
+{
+ const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene";
+ QStringList arguments;
+
+ if (block)
+ arguments << QString("-qmljsdebugger=port:"STR_PORT",block");
+ else
+ arguments << QString("-qmljsdebugger=port:"STR_PORT);
+
+ arguments << QQmlDataTest::instance()->testFile(testFile);
+
+ m_process = new QQmlDebugProcess(executable);
+ m_process->start(QStringList() << arguments);
+ if (!m_process->waitForSessionStart()) {
+ QString failMsg = QString("Could not launch app '%1'.\nApplication output:\n%2").arg(
+ executable, m_process->output());
+ QFAIL(qPrintable(failMsg));
+ }
+
+ QQmlDebugConnection *m_connection = new QQmlDebugConnection();
+ m_client = new QV8ProfilerClient(m_connection);
+
+ m_connection->connectToHost(QLatin1String("127.0.0.1"), PORT);
+}
+
+void tst_QV8ProfilerService::cleanup()
+{
+ if (QTest::currentTestFailed())
+ qDebug() << "Application Output:" << m_process->output();
+
+ delete m_process;
+ delete m_connection;
+ delete m_client;
+}
+
+void tst_QV8ProfilerService::blockingConnectWithTraceEnabled()
+{
+ connect(true, "test.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->startProfiling("");
+ m_client->stopProfiling("");
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())),
+ "No trace received in time.");
+}
+
+void tst_QV8ProfilerService::blockingConnectWithTraceDisabled()
+{
+ connect(true, "test.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->stopProfiling("");
+ if (QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete()), 1000)) {
+ QString failMsg
+ = QString("Unexpected trace received! App output: %1\n\n").arg(m_process->output());
+ QFAIL(qPrintable(failMsg));
+ }
+ m_client->startProfiling("");
+ m_client->stopProfiling("");
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())),
+ "No trace received in time.");
+}
+
+void tst_QV8ProfilerService::nonBlockingConnect()
+{
+ connect(false, "test.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->startProfiling("");
+ m_client->stopProfiling("");
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())),
+ "No trace received in time.");
+}
+
+void tst_QV8ProfilerService::snapshot()
+{
+ connect(false, "test.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->takeSnapshot();
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(snapshot())),
+ "No trace received in time.");
+}
+
+void tst_QV8ProfilerService::profileOnExit()
+{
+ connect(true, "exit.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->startProfiling("");
+
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())),
+ "No trace received in time.");
+ //QVERIFY(!m_client->traceMessages.isEmpty());
+}
+
+void tst_QV8ProfilerService::console()
+{
+ connect(true, "console.qml");
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ m_client->stopProfiling("");
+
+ QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())),
+ "No trace received in time.");
+ QVERIFY(!m_client->traceMessages.isEmpty());
+}
+
+QTEST_MAIN(tst_QV8ProfilerService)
+
+#include "tst_qv8profilerservice.moc"
diff --git a/tests/auto/qml/debugger/shared/debugutil.cpp b/tests/auto/qml/debugger/shared/debugutil.cpp
new file mode 100644
index 0000000000..8ed64d3a5d
--- /dev/null
+++ b/tests/auto/qml/debugger/shared/debugutil.cpp
@@ -0,0 +1,190 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "debugutil_p.h"
+
+#include <QEventLoop>
+#include <QTimer>
+
+#include <private/qqmldebugclient_p.h>
+#include <private/qqmldebugservice_p.h>
+
+bool QQmlDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) {
+ QEventLoop loop;
+ QTimer timer;
+ timer.setSingleShot(true);
+ QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ QObject::connect(receiver, member, &loop, SLOT(quit()));
+ timer.start(timeout);
+ loop.exec();
+ return timer.isActive();
+}
+
+QQmlDebugTestService::QQmlDebugTestService(const QString &s, float version, QObject *parent)
+ : QQmlDebugService(s, version, parent)
+{
+ registerService();
+}
+
+void QQmlDebugTestService::messageReceived(const QByteArray &ba)
+{
+ sendMessage(ba);
+}
+
+void QQmlDebugTestService::stateChanged(State)
+{
+ emit stateHasChanged();
+}
+
+
+QQmlDebugTestClient::QQmlDebugTestClient(const QString &s, QQmlDebugConnection *c)
+ : QQmlDebugClient(s, c)
+{
+}
+
+QByteArray QQmlDebugTestClient::waitForResponse()
+{
+ lastMsg.clear();
+ QQmlDebugTest::waitForSignal(this, SIGNAL(serverMessage(QByteArray)));
+ if (lastMsg.isEmpty()) {
+ qWarning() << "tst_QQmlDebugTestClient: no response from server!";
+ return QByteArray();
+ }
+ return lastMsg;
+}
+
+void QQmlDebugTestClient::stateChanged(State stat)
+{
+ QCOMPARE(stat, state());
+ emit stateHasChanged();
+}
+
+void QQmlDebugTestClient::messageReceived(const QByteArray &ba)
+{
+ lastMsg = ba;
+ emit serverMessage(ba);
+}
+
+QQmlDebugProcess::QQmlDebugProcess(const QString &executable)
+ : m_executable(executable)
+ , m_started(false)
+{
+ m_process.setProcessChannelMode(QProcess::MergedChannels);
+ m_timer.setSingleShot(true);
+ m_timer.setInterval(5000);
+ connect(&m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(processAppOutput()));
+ connect(&m_timer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit()));
+}
+
+QQmlDebugProcess::~QQmlDebugProcess()
+{
+ stop();
+}
+
+void QQmlDebugProcess::start(const QStringList &arguments)
+{
+ m_mutex.lock();
+ m_process.setEnvironment(m_environment);
+ m_process.start(m_executable, arguments);
+ m_process.waitForStarted();
+ m_timer.start();
+ m_mutex.unlock();
+}
+
+void QQmlDebugProcess::stop()
+{
+ if (m_process.state() != QProcess::NotRunning) {
+ m_process.kill();
+ m_process.waitForFinished(5000);
+ }
+}
+
+bool QQmlDebugProcess::waitForSessionStart()
+{
+ if (m_process.state() != QProcess::Running) {
+ qWarning() << "Could not start up " << m_executable;
+ return false;
+ }
+ m_eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
+
+ return m_started;
+}
+
+void QQmlDebugProcess::setEnvironment(const QStringList &environment)
+{
+ m_environment = environment;
+}
+
+QString QQmlDebugProcess::output() const
+{
+ return m_output;
+}
+
+void QQmlDebugProcess::processAppOutput()
+{
+ m_mutex.lock();
+
+ QString newOutput = m_process.readAll();
+ m_output.append(newOutput);
+ m_outputBuffer.append(newOutput);
+
+ while (true) {
+ const int nlIndex = m_outputBuffer.indexOf(QLatin1Char('\n'));
+ if (nlIndex < 0) // no further complete lines
+ break;
+ const QString line = m_outputBuffer.left(nlIndex);
+ m_outputBuffer = m_outputBuffer.right(m_outputBuffer.size() - nlIndex - 1);
+
+ if (line.startsWith("Qml debugging is enabled")) // ignore
+ continue;
+ if (line.startsWith("QQmlDebugServer:")) {
+ if (line.contains("Waiting for connection ")) {
+ m_started = true;
+ m_eventLoop.quit();
+ continue;
+ }
+ if (line.contains("Connection established")) {
+ continue;
+ }
+ }
+ }
+ m_mutex.unlock();
+}
diff --git a/tests/auto/qml/debugger/shared/debugutil_p.h b/tests/auto/qml/debugger/shared/debugutil_p.h
new file mode 100644
index 0000000000..194f8fa14c
--- /dev/null
+++ b/tests/auto/qml/debugger/shared/debugutil_p.h
@@ -0,0 +1,127 @@
+
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DEBUGUTIL_H
+#define DEBUGUTIL_H
+
+#include <QEventLoop>
+#include <QTimer>
+#include <QThread>
+#include <QTest>
+#include <QProcess>
+
+#include <QtQml/qqmlengine.h>
+
+#include <private/qqmldebugclient_p.h>
+#include <private/qqmldebugservice_p.h>
+
+class QQmlDebugTest
+{
+public:
+ static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000);
+};
+
+class QQmlDebugTestService : public QQmlDebugService
+{
+ Q_OBJECT
+public:
+ QQmlDebugTestService(const QString &s, float version = 1, QObject *parent = 0);
+
+signals:
+ void stateHasChanged();
+
+protected:
+ virtual void messageReceived(const QByteArray &ba);
+ virtual void stateChanged(State state);
+};
+
+class QQmlDebugTestClient : public QQmlDebugClient
+{
+ Q_OBJECT
+public:
+ QQmlDebugTestClient(const QString &s, QQmlDebugConnection *c);
+
+ QByteArray waitForResponse();
+
+signals:
+ void stateHasChanged();
+ void serverMessage(const QByteArray &);
+
+protected:
+ virtual void stateChanged(State state);
+ virtual void messageReceived(const QByteArray &ba);
+
+private:
+ QByteArray lastMsg;
+};
+
+class QQmlDebugProcess : public QObject
+{
+ Q_OBJECT
+public:
+ QQmlDebugProcess(const QString &executable);
+ ~QQmlDebugProcess();
+
+ void setEnvironment(const QStringList &environment);
+
+ void start(const QStringList &arguments);
+ bool waitForSessionStart();
+
+ QString output() const;
+ void stop();
+
+private slots:
+ void processAppOutput();
+
+private:
+ QString m_executable;
+ QProcess m_process;
+ QString m_outputBuffer;
+ QString m_output;
+ QTimer m_timer;
+ QEventLoop m_eventLoop;
+ QMutex m_mutex;
+ bool m_started;
+ QStringList m_environment;
+};
+
+#endif // DEBUGUTIL_H
diff --git a/tests/auto/qml/parserstress/parserstress.pro b/tests/auto/qml/parserstress/parserstress.pro
new file mode 100644
index 0000000000..3cf3e02e4e
--- /dev/null
+++ b/tests/auto/qml/parserstress/parserstress.pro
@@ -0,0 +1,12 @@
+CONFIG += testcase
+TARGET = tst_parserstress
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_parserstress.cpp
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+DEFINES += TESTDATADIR=\\\"$$PWD/tests\\\"
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private testlib
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4-1.js
index b73ca2df71..b73ca2df71 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4-2.js
index 7d00703d30..7d00703d30 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.1.js
index b894433d01..b894433d01 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.2.js
index 7e2e7ef436..7e2e7ef436 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.3.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.3.js
index b36f339966..b36f339966 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.js
index 414c901926..414c901926 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-1.js
index 986684e338..986684e338 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-2.js
index 9e957cbb21..9e957cbb21 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-3.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-3.js
index 4d1806d9b8..4d1806d9b8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-1.js
index 255d0b5fb4..255d0b5fb4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-2.js
index e77ba8d876..e77ba8d876 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.3.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.3.js
index 27d9bd257b..27d9bd257b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.2.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.2.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.1-2.js
index 36c1967f16..36c1967f16 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.3.2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.2.js
index dfb47ca284..dfb47ca284 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.3.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.3.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.1.js
index bd886b0cb0..bd886b0cb0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.2.js
index d0be6bd471..d0be6bd471 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.3-1.js
index ff97512a44..ff97512a44 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-1.js
index 503d7e635e..503d7e635e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.4-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-2.js
index a9b7b0ec14..a9b7b0ec14 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.4-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.4-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-1.js
index a3a521da09..a3a521da09 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-2.js
index 301c435d15..301c435d15 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-3.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-3.js
index 984d2fe80a..984d2fe80a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.5-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.5-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.js
index 2ab2072098..2ab2072098 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-1.js
index 090300d59b..090300d59b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-2.js
index 2966a00456..2966a00456 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-1.js
index ff15f9d4e8..ff15f9d4e8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-2.js
index 56a400ab49..56a400ab49 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/15.4.5.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/15.4.5.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/browser.js b/tests/auto/qml/parserstress/tests/ecma/Array/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Array/shell.js b/tests/auto/qml/parserstress/tests/ecma/Array/shell.js
index 9480d9e77d..9480d9e77d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Array/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Array/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.1.js
index b698cbe407..b698cbe407 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.2.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.2.js
index f9fccb3e57..f9fccb3e57 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-1.js
index 0be8097487..0be8097487 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-2.js
index 5d435982d4..5d435982d4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-3.js
index 0f1b125267..0f1b125267 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-4.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-4.js
index 822750308a..822750308a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1.js
index ca808c63a5..ca808c63a5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.3.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.3.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4-1.js
index 584562b2a8..584562b2a8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.1.js
index 3b75fb49ec..3b75fb49ec 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-1.js
index 54bd2e19d3..54bd2e19d3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-2.js
index 2039004472..2039004472 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-3.js
index 4dcc65f21f..4dcc65f21f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js
index 0dd3e5f349..0dd3e5f349 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.2-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-1.js
index 8b913e011e..8b913e011e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-2.js
index 5548a7874f..5548a7874f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-3.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-3.js
index f05dfc0c60..f05dfc0c60 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js
index 4ebabfa84c..4ebabfa84c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3.js
index 570652ee39..570652ee39 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.js
index 0c95d255fe..0c95d255fe 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/15.6.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/15.6.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/browser.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Boolean/shell.js b/tests/auto/qml/parserstress/tests/ecma/Boolean/shell.js
index 2ff7258ce8..2ff7258ce8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Boolean/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Boolean/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-1.js
index 8e82d205f3..8e82d205f3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-2.js
index 7b8c2644e3..7b8c2644e3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.13-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.13-1.js
index 720b39dd54..720b39dd54 100755
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.1.13-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.13-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.1.js
index 6cd76efb6b..6cd76efb6b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-1.js
index 0c643cfd3a..0c643cfd3a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-2.js
index af95bb3ae6..af95bb3ae6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-3.js
index f7de60b5b1..f7de60b5b1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-4.js
index 119b4f2559..119b4f2559 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-5.js
index d9369ca4c5..d9369ca4c5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-6.js
index 8e549936e3..8e549936e3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.2.2-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.2.2-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-1.js
index 642169a60c..642169a60c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-2.js
index fb9dff486c..fb9dff486c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-3.js
index 0d888b089c..0d888b089c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-4.js
index 5f95a5b797..5f95a5b797 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-5.js
index f37c1c8da2..f37c1c8da2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.1-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.1-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-1.js
index ae0502be64..ae0502be64 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-2.js
index acc2ac7f0b..acc2ac7f0b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-3.js
index d4b48fed35..d4b48fed35 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-4.js
index 1b2757cd9a..1b2757cd9a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-5.js
index 09d6272c6f..09d6272c6f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.2-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.2-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-1.js
index d48199ccba..d48199ccba 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-2.js
index f9d8d36d04..f9d8d36d04 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-3.js
index c3042a8216..c3042a8216 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-4.js
index c3a1eae7dc..c3a1eae7dc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-5.js
index 405842c79f..405842c79f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.3.8-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.3.8-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2-1.js
index 4b269f264f..4b269f264f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2.js
index 5a518e6442..5a518e6442 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.3.js
index b0549588aa..b0549588aa 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.4.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.4.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.1.js
index 3185a7c4e5..3185a7c4e5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-1.js
index cd73d288c9..cd73d288c9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-10.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-10.js
index 4142635486..4142635486 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-10.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-10.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-11.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-11.js
index dfadc18838..dfadc18838 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-11.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-11.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-12.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-12.js
index 2557108faf..2557108faf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-12.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-12.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-13.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-13.js
index e0e2402ebd..e0e2402ebd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-13.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-13.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-2.js
index e44cfcc5d7..e44cfcc5d7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-3.js
index 325c9bfaf2..325c9bfaf2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-4.js
index 41676c2658..41676c2658 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-5.js
index f17b0a0b29..f17b0a0b29 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-6.js
index 84f57b8805..84f57b8805 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-7.js
index 96ba89078a..96ba89078a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-8.js
index bae220a94e..bae220a94e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-9.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-9.js
index a1cee0e682..a1cee0e682 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.10-9.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.10-9.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-1.js
index 5c2439ba09..5c2439ba09 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-2.js
index d9eda4cfc1..d9eda4cfc1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-3.js
index d35f8d5967..d35f8d5967 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-4.js
index 4fc9f2ee65..4fc9f2ee65 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-5.js
index cee93a770b..cee93a770b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-6.js
index b756e43a7e..b756e43a7e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-7.js
index 65c5c1c765..65c5c1c765 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.11-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.11-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-1.js
index c173ffb193..c173ffb193 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-2.js
index 5967da6ef6..5967da6ef6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-3.js
index 9ce226665c..9ce226665c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-4.js
index 3b752a1767..3b752a1767 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-5.js
index 7fe153a5ea..7fe153a5ea 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-6.js
index 663ab81b2d..663ab81b2d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-7.js
index 23a0218058..23a0218058 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-8.js
index 4f3f66e0ce..4f3f66e0ce 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.12-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.12-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-1.js
index d82f39a7e0..d82f39a7e0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-2.js
index 13f0d080e3..13f0d080e3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-3.js
index 7c78072ee5..7c78072ee5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-4.js
index bcfcfb8c00..bcfcfb8c00 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-5.js
index 96b1acb170..96b1acb170 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-6.js
index e749ad6b7f..e749ad6b7f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-7.js
index 63607f8d2d..63607f8d2d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-8.js
index 75d42b200b..75d42b200b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.13-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.13-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.14.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.14.js
index 5a3f8216da..5a3f8216da 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.14.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.14.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.15.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.15.js
index ca2babd7ef..ca2babd7ef 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.15.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.15.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.16.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.16.js
index e791b74eae..e791b74eae 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.16.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.16.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.17.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.17.js
index e9b30c3eed..e9b30c3eed 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.17.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.17.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.18.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.18.js
index f735168efe..f735168efe 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.18.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.18.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.19.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.19.js
index 2a0d7430ef..2a0d7430ef 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.19.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.19.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-1.js
index 7ec3c691c8..7ec3c691c8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-2-n.js
index c5513b8168..c5513b8168 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2.js
index ef2df0510b..ef2df0510b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.20.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.20.js
index fb3dafde2c..fb3dafde2c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.20.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.20.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-1.js
index 4eea164305..4eea164305 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-2.js
index 37b443117a..37b443117a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-3.js
index d1d96cb7a3..d1d96cb7a3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-4.js
index b7dfa656ff..b7dfa656ff 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-5.js
index ca90b1784a..ca90b1784a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-6.js
index 9178ae76cf..9178ae76cf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-7.js
index c4d0a4b615..c4d0a4b615 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-8.js
index 624d6c6bcb..624d6c6bcb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.21-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.21-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-1.js
index 5d2a6934ab..5d2a6934ab 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-2.js
index b828b468d1..b828b468d1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-3.js
index 26c059368d..26c059368d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-4.js
index 96b9771d59..96b9771d59 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-5.js
index a943aa5699..a943aa5699 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-6.js
index 96b39d2c43..96b39d2c43 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-7.js
index 7fa0ecaf14..7fa0ecaf14 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-8.js
index 3eca9d8ec9..3eca9d8ec9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.22-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.22-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-1.js
index e4a228e2cd..e4a228e2cd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-10.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-10.js
index d4cb298d19..d4cb298d19 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-10.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-10.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-11.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-11.js
index ca28015766..ca28015766 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-11.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-11.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-12.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-12.js
index a03f599567..a03f599567 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-12.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-12.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-13.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-13.js
index a68128770c..a68128770c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-13.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-13.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-14.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-14.js
index 1923d715e3..1923d715e3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-14.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-14.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-15.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-15.js
index 31680eb386..31680eb386 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-15.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-15.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-16.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-16.js
index 3dc0726ca8..3dc0726ca8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-16.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-16.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-17.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-17.js
index 605f4cf00b..605f4cf00b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-17.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-17.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-18.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-18.js
index e30d0f05c8..e30d0f05c8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-18.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-18.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-2.js
index 8086af88d9..8086af88d9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-3-n.js
index 040604bd0e..040604bd0e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-4.js
index 39e3dec8d4..39e3dec8d4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-5.js
index b4317e6a55..b4317e6a55 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-6.js
index cc9e07b9fd..cc9e07b9fd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-7.js
index 46bb900b18..46bb900b18 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-8.js
index 8072a9cc1f..8072a9cc1f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-9.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-9.js
index b480791e3d..b480791e3d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.23-9.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.23-9.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-1.js
index e02aa6150a..e02aa6150a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-2.js
index da6261670b..da6261670b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-3.js
index 8199010953..8199010953 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-4.js
index f6b1dae966..f6b1dae966 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-5.js
index 53458028be..53458028be 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-6.js
index 188dbacff9..188dbacff9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-7.js
index b2fe8fcff9..b2fe8fcff9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-8.js
index d6ea2d8d3e..d6ea2d8d3e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.24-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.24-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.25-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.25-1.js
index 0eb7783ec8..0eb7783ec8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.25-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.25-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.26-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.26-1.js
index 509ec73d33..509ec73d33 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.26-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.26-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.27-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.27-1.js
index 1b06777332..1b06777332 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.27-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.27-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.28-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.28-1.js
index 902d70a873..902d70a873 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.28-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.28-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.29-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.29-1.js
index 42fa36e9b5..42fa36e9b5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.29-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.29-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.3-1-n.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-1-n.js
index e1f227f785..e1f227f785 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.3-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-2.js
index 9f425c3450..9f425c3450 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.30-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.30-1.js
index 7abb3927d7..7abb3927d7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.30-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.30-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.31-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.31-1.js
index 10f0f93e17..10f0f93e17 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.31-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.31-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.32-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.32-1.js
index d277fd9af1..d277fd9af1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.32-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.32-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.33-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.33-1.js
index 01e1ff2f94..01e1ff2f94 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.33-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.33-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.34-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.34-1.js
index de4d8c817b..de4d8c817b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.34-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.34-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.35-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.35-1.js
index 427657cb47..427657cb47 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.35-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.35-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-1.js
index f4cd44c2c2..f4cd44c2c2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-2.js
index a0ce018d0f..a0ce018d0f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-3.js
index f0849f28e7..f0849f28e7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-4.js
index 0ca872f8db..0ca872f8db 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-5.js
index 2496548b1d..2496548b1d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-6.js
index 9a05c3130e..9a05c3130e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-7.js
index 5bc330bbea..5bc330bbea 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.36-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.36-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-1.js
index a6acd3d10a..a6acd3d10a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-2.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-2.js
index e5ec78ea72..e5ec78ea72 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-3.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-3.js
index d256511459..d256511459 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-4.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-4.js
index 017afd6389..017afd6389 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-5.js
index 046f3095df..046f3095df 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.37-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.37-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-1.js
index 6ad06931f8..6ad06931f8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.4-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-2-n.js
index 1cd98dd801..1cd98dd801 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.4-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.4-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.5.js
index f0136b00ad..f0136b00ad 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.6.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.6.js
index 9ae804ebb9..9ae804ebb9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.7.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.7.js
index c4c83a2c38..c4c83a2c38 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.8.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.8.js
index 572e293960..572e293960 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.9.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.9.js
index 9f0fc124af..9f0fc124af 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.9.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.9.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.js
index 9e3bd94080..9e3bd94080 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/15.9.5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/browser.js b/tests/auto/qml/parserstress/tests/ecma/Date/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Date/shell.js b/tests/auto/qml/parserstress/tests/ecma/Date/shell.js
index 0beb78e064..0beb78e064 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Date/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Date/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js
index 699296d6b1..699296d6b1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js
index 3762842461..3762842461 100755
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3.js
index fd466de210..fd466de210 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js
index ec49f20596..ec49f20596 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js
index 218031c83f..218031c83f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-10.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js
index 2aee831b45..2aee831b45 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js
index a3ae0ffdec..a3ae0ffdec 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js
index 31274a0209..31274a0209 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js
index c36d2db8cc..c36d2db8cc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js
index da11110cc5..da11110cc5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js
index f1a0db4569..f1a0db4569 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js
index 1eee8da4fb..1eee8da4fb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.4-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js
index 363581eff6..363581eff6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js
index cfba3b5c73..cfba3b5c73 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js
index f5234cb13b..f5234cb13b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js
index 953e6a8feb..953e6a8feb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.5-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js
index 40e6f0ee8f..40e6f0ee8f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js
index 71aa876f02..71aa876f02 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.8-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.1.js
index 5384da4f83..5384da4f83 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js
index 787ef9e5b3..787ef9e5b3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js
index 8048c45575..8048c45575 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js
index a1977c66d6..a1977c66d6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js
index e1aa78c5da..e1aa78c5da 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.2.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/browser.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/shell.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/shell.js
index 1d353cff74..1d353cff74 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ExecutionContexts/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.1.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.1.1.js
index 18f0ec7f13..18f0ec7f13 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.1.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.1.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-1.js
index 5b70334ff5..5b70334ff5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-2.js
index 27bde196e0..27bde196e0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-3.js
index 3da6963255..3da6963255 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.10-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.10-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-1.js
index ff131b672e..ff131b672e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-2-n.js
index c2a1e894e0..c2a1e894e0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-3.js
index 11dde79fb3..11dde79fb3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-4.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-4.js
index 861692c4e8..861692c4e8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.12-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.12-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.1.js
index 5e548a3e76..5e548a3e76 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-1.js
index 41402b77ce..41402b77ce 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-2.js
index 2d3b53630b..2d3b53630b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-3.js
index c432934a30..c432934a30 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-4.js
index 8514dd8c9c..8514dd8c9c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-5.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-5.js
index 99d227b80f..99d227b80f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.2-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.2-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.js
index bf5f172d36..bf5f172d36 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.13.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.13.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.14-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.14-1.js
index c2f30afb6a..c2f30afb6a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.14-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.14-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-1.js
index 91e25b01f1..91e25b01f1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-2.js
index eda8168c0f..eda8168c0f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-3-n.js
index 0732aa0378..0732aa0378 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-4-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-4-n.js
index 110684c9c6..110684c9c6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-5.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-5.js
index 2d9f0f1632..2d9f0f1632 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.1-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.1-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-1-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1-n.js
index 3603892114..3603892114 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1.js
index 7105f17071..7105f17071 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-10-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-10-n.js
index 36781503d9..36781503d9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-10-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-10-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-11.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-11.js
index 03a0f8c436..03a0f8c436 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-11.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-11.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-2-n.js
index 7fbea97ca1..7fbea97ca1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-3-n.js
index 8b344a3dda..8b344a3dda 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-4-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-4-n.js
index c2ff538b9f..c2ff538b9f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-5-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-5-n.js
index ba8d0756fb..ba8d0756fb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-5-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-5-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-6-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-6-n.js
index f89b4009e3..f89b4009e3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-6-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-6-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-7-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-7-n.js
index 97ae43e810..97ae43e810 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-7-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-7-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-8-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-8-n.js
index 10117c726e..10117c726e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-8-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-8-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-9-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-9-n.js
index 6099754ca3..6099754ca3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.2-9-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.2-9-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-1.js
index 6e36ba8d3f..6e36ba8d3f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-2-n.js
index c3539e817a..c3539e817a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-3-n.js
index 3023fee16b..3023fee16b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-4-n.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-4-n.js
index 3c0ac1a4b3..3c0ac1a4b3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-5.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-5.js
index 92b356c1dd..92b356c1dd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.2.3-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.2.3-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.3.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.1.js
index 29235f1107..29235f1107 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.3.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.3.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.2.js
index 2d6f6c6770..2d6f6c6770 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.3.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.3.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.1.js
index 62354e17bc..62354e17bc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.2.js
index b89d9145c9..b89d9145c9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.3.js
index b746fbe8b5..b746fbe8b5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.4.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.4.js
index cbacf869e4..cbacf869e4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.5.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.5.js
index ee761c5d96..ee761c5d96 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.6.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.6.js
index 9b100d9d50..9b100d9d50 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.7-01.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-01.js
index 827b80189d..827b80189d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.7-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.7-02.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-02.js
index 43bd923e23..43bd923e23 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.7-02.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.7-02.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.8.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.8.js
index f617e10689..f617e10689 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.9.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.9.js
index 2c57e88211..2c57e88211 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.4.9.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.4.9.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.1.js
index 94edcefea5..94edcefea5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.2.js
index e459e7613f..e459e7613f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.3.js
index 9558b63a96..9558b63a96 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.5.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.5.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-1.js
index 87666161b6..87666161b6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-2.js
index 1d96d14e92..1d96d14e92 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-3.js
index 9a162787d5..9a162787d5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.2-1.js
index b3ab9b17fb..b3ab9b17fb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.3.js
index cf44738528..cf44738528 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.6.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.6.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.1.js
index 44099f6c94..44099f6c94 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.2.js
index 843388767f..843388767f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.3.js
index 27d24e121a..27d24e121a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.7.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.7.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.1.js
index 4b35c11b16..4b35c11b16 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.2.js
index c4e6f4cfbd..c4e6f4cfbd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.3.js
index 2180fc5655..2180fc5655 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.4.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.4.js
index d43aaa260d..d43aaa260d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.8.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.8.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.1.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.1.js
index 6bf3fc0517..6bf3fc0517 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.2.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.2.js
index b6983e6af1..b6983e6af1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.3.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.3.js
index cce1c63c16..cce1c63c16 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/11.9.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/11.9.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/browser.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Expressions/shell.js b/tests/auto/qml/parserstress/tests/ecma/Expressions/shell.js
index 8f5d1129d5..8f5d1129d5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Expressions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Expressions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js
index 90f080acc9..90f080acc9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js
index 57fe78c8f1..57fe78c8f1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js
index 51f7bb763b..51f7bb763b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.1.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js
index d76e57b828..d76e57b828 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js
index 7729c9587a..7729c9587a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js
index 80b1c41e00..80b1c41e00 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.2.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js
index b760afd149..b760afd149 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js
index 62e6d42342..62e6d42342 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js
index 6e1aa8426d..6e1aa8426d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.1-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js
index b1d04f3957..b1d04f3957 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.3.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js
index c90c26a9e5..c90c26a9e5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js
index a6bc775902..a6bc775902 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.js
index 59e3ff81a5..59e3ff81a5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js
index c3fbfc774e..c3fbfc774e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js
index dcb351985d..dcb351985d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js
index 406d569dba..406d569dba 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js
index 4a127fbc68..4a127fbc68 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/15.3.5.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/browser.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/shell.js b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/shell.js
index 27aa7b1318..27aa7b1318 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/FunctionObjects/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/FunctionObjects/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1-1-n.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-1-n.js
index 9946a7f2da..9946a7f2da 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1-2-n.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-2-n.js
index 545caeeae0..545caeeae0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.1.1.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.1.js
index a8d4e7fecf..a8d4e7fecf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.1.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.1.2.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.2.js
index 8671ff642a..8671ff642a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.1.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.1.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js
index 8572371f8e..8572371f8e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js
index a4bf1c7de6..a4bf1c7de6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js
index ff8806dfb2..ff8806dfb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js
index 56bf83adcc..56bf83adcc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js
index 557b93f637..557b93f637 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.4.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.4.js
index bd2114a1a9..bd2114a1a9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js
index b7b072a627..b7b072a627 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js
index 99b58752b2..99b58752b2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js
index 2615d62531..2615d62531 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.5-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.6.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.6.js
index faeeb9e0b0..faeeb9e0b0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.7.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.7.js
index e3db5e7931..e3db5e7931 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/15.1.2.7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/15.1.2.7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/browser.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/shell.js b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/shell.js
index d922707218..d922707218 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/GlobalObject/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/GlobalObject/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-1.js
index 7fa415c20d..7fa415c20d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-2.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-2.js
index aa0c3fb373..aa0c3fb373 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-3.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-3.js
index c405106ade..c405106ade 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-1.js
index dd4f2fcbed..dd4f2fcbed 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js
index d945115832..d945115832 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js
index c62410d202..c62410d202 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js
index b29f999739..b29f999739 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js
index b563d86437..b563d86437 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-5-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-6.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-6.js
index 220548e78e..220548e78e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.2-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.2-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-1.js
index 9701660576..9701660576 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-10.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-10.js
index 1cd0f18a90..1cd0f18a90 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-10.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-10.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-11.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-11.js
index f9033cd05a..f9033cd05a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-11.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-11.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-12.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-12.js
index 04ceb81409..04ceb81409 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-12.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-12.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js
index 714de99a9a..714de99a9a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-13-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-2.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-2.js
index 7aa029feda..7aa029feda 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-3.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-3.js
index 1886639e26..1886639e26 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-4.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-4.js
index 4cb53af0fb..4cb53af0fb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-5.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-5.js
index 22d9e08a60..22d9e08a60 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-6.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-6.js
index 91afd319a4..91afd319a4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-7.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-7.js
index a35cd54289..a35cd54289 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-8.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-8.js
index 2d665c4ff0..2d665c4ff0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-9.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-9.js
index caff9f7f09..caff9f7f09 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.3-9.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.3-9.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js
index 2153cc2638..2153cc2638 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js
index a50bd6020f..a50bd6020f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js
index b49fe7937b..b49fe7937b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.1-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js
index 36723173f5..36723173f5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js
index 89003d3601..89003d3601 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-10-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js
index 3aff749e51..3aff749e51 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-11-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js
index f19ed8c904..f19ed8c904 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-12-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js
index 22a5284dcc..22a5284dcc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-13-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js
index b9b05f42b7..b9b05f42b7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-14-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js
index 27e83972c3..27e83972c3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-15-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js
index 988920538c..988920538c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-16-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js
index 648610a9e6..648610a9e6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js
index d8b74d6b0e..d8b74d6b0e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js
index 2bb0aa260b..2bb0aa260b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js
index 3fdf06b2c1..3fdf06b2c1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-5-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js
index 00f3f99a4c..00f3f99a4c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-6-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js
index 6a85b261ce..6a85b261ce 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-7-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js
index 5f5122e0f2..5f5122e0f2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-8-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js
index c1c4df6d9b..c1c4df6d9b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.2-9-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js
index dee163d8e5..dee163d8e5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js
index 8d717f323d..8d717f323d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-10-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js
index 4e29e9c3af..4e29e9c3af 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-11-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js
index 913fae905b..913fae905b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-12-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js
index c196ea2418..c196ea2418 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-13-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js
index 8d5af29ede..8d5af29ede 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-14-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js
index f855132d8a..f855132d8a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-15-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js
index 6d86d357f2..6d86d357f2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-16-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js
index fe5f6ffac1..fe5f6ffac1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js
index b95c8ecbe0..b95c8ecbe0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js
index b17b06f2e9..b17b06f2e9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js
index d76025b3cc..d76025b3cc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-5-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js
index 36ffe63977..36ffe63977 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-6-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js
index 31239d561a..31239d561a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-7-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js
index 666abcc0c8..666abcc0c8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-8-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js
index 4fee9c8c4a..4fee9c8c4a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.4.3-9-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-1.js
index 57be9b63ee..57be9b63ee 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js
index 2561a3deda..2561a3deda 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-10-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js
index 3401fe4891..3401fe4891 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js
index 778c284cfb..778c284cfb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js
index 0f4b0fb2f1..0f4b0fb2f1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-4-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js
index 97a61e3449..97a61e3449 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-5-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-6.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-6.js
index a53f4413eb..a53f4413eb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-7.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-7.js
index c3446c6c0d..c3446c6c0d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js
index e363666148..e363666148 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-8-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js
index c1ac68512a..c1ac68512a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.5-9-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.6.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.6.js
index 091c74d7db..091c74d7db 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.1.js
index 83325b5f32..83325b5f32 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.2.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.2.js
index f021eb9b18..f021eb9b18 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js
index fb13b24e07..fb13b24e07 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js
index 8fbe16cb8f..8fbe16cb8f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3.js
index 9ccb912752..9ccb912752 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.4.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js
index 015a385220..015a385220 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.7.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.7.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js
index b8d844e41d..b8d844e41d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/7.8.2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/browser.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/shell.js b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/shell.js
index 4e1d61d68a..4e1d61d68a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/LexicalConventions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/LexicalConventions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8-2-n.js
index 40c2ae8d2d..40c2ae8d2d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8-3-n.js
index f6333d7ec7..f6333d7ec7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-1.js
index f90f74b9e8..f90f74b9e8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-2.js
index 9f136f2fb8..9f136f2fb8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-1.js
index 0cbc65a4fb..0cbc65a4fb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-2.js
index 6937b3520b..6937b3520b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-1.js
index 8289cc2a46..8289cc2a46 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-2.js
index 24a8b18231..24a8b18231 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-1.js
index 227dbb3e2a..227dbb3e2a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.4-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-2.js
index c9aa98e77a..c9aa98e77a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.4-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.4-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.5-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-1.js
index b753025c8a..b753025c8a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.5-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-2.js
index c134e4a577..c134e4a577 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.6-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-1.js
index f2a395618c..f2a395618c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.6-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.6-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-2.js
index ba53e78de5..ba53e78de5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.6-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.6-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.7-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-1.js
index aa60aead5b..aa60aead5b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.7-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.7-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-2.js
index 2f8c45c9f9..2f8c45c9f9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.7-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.7-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-1.js
index 3c5764d019..3c5764d019 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-2.js
index f999dac920..f999dac920 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-3.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-3.js
index 0c823aea57..0c823aea57 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.8-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.8-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.js
index 009325640b..009325640b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.1.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.1.js
index 0412742767..0412742767 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.10.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.10.js
index 05d4c187c9..05d4c187c9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.10.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.10.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.11.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.11.js
index 5a957b3de4..5a957b3de4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.11.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.11.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.12.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.12.js
index a33a5aca4a..a33a5aca4a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.12.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.12.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.13.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.13.js
index 341b3e7651..341b3e7651 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.13.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.13.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.14.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.14.js
index 1972518c81..1972518c81 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.14.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.14.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.15.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.15.js
index a5c36b4e61..a5c36b4e61 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.15.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.15.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.16.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.16.js
index deb873cdaa..deb873cdaa 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.16.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.16.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.17.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.17.js
index 2f12f1d93b..2f12f1d93b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.17.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.17.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.18.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.18.js
index be68ea191f..be68ea191f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.18.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.18.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.2.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.2.js
index 12fb00ef81..12fb00ef81 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.3.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.3.js
index 11c6d73657..11c6d73657 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.4.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.4.js
index c67ac6d4ea..c67ac6d4ea 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.5.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.5.js
index 0adc690743..0adc690743 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.6.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.6.js
index 1c20a1c93e..1c20a1c93e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.7.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.7.js
index 2b19b5986e..2b19b5986e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.8.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.8.js
index 96b6231da2..96b6231da2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.9.js b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.9.js
index b68a57d5bb..b68a57d5bb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/15.8.2.9.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/15.8.2.9.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/browser.js b/tests/auto/qml/parserstress/tests/ecma/Math/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Math/shell.js b/tests/auto/qml/parserstress/tests/ecma/Math/shell.js
index fbcc5c3f92..fbcc5c3f92 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Math/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Math/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/NativeObjects/browser.js b/tests/auto/qml/parserstress/tests/ecma/NativeObjects/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/NativeObjects/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/NativeObjects/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/NativeObjects/shell.js b/tests/auto/qml/parserstress/tests/ecma/NativeObjects/shell.js
index 4ddb940f71..4ddb940f71 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/NativeObjects/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/NativeObjects/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.1.js
index 34cec9f378..34cec9f378 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.2.js
index 4c2c8a298c..4c2c8a298c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-1.js
index d275f50a12..d275f50a12 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-2.js
index ff26a03e63..ff26a03e63 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-3.js
index 4669e969a7..4669e969a7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-1.js
index 35ff1b25c3..35ff1b25c3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-2.js
index 980b688bb6..980b688bb6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-3.js
index 2f20efe2a8..2f20efe2a8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-4.js
index 04d70ce3a9..04d70ce3a9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.2-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.2-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-1.js
index ed7f0e88a9..ed7f0e88a9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-2.js
index 2b73147c2a..2b73147c2a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-3.js
index d0c98282dd..d0c98282dd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-4.js
index e9427c62f2..e9427c62f2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.3-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.3-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-1.js
index 6a6835f04d..6a6835f04d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-2.js
index fd1e630d54..fd1e630d54 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-3.js
index 6cf1072e20..6cf1072e20 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-4.js
index 3e1db5b9d2..3e1db5b9d2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.4-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.4-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-1.js
index 8bcb3e3782..8bcb3e3782 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-2.js
index e0c2c440ac..e0c2c440ac 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-3.js
index 983cdd3147..983cdd3147 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-4.js
index acf7b0f543..acf7b0f543 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.5-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.5-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-1.js
index 466267f7d4..466267f7d4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-2.js
index c3e6dbd0fb..c3e6dbd0fb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-3.js
index 6055f49374..6055f49374 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-4.js
index 75fa6ee485..75fa6ee485 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.6-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.6-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.js
index bc5e7a3fa1..bc5e7a3fa1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4-1.js
index 175835987a..175835987a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.1.js
index 27c0a0a9e4..27c0a0a9e4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-1.js
index 531876d980..531876d980 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-2-n.js
index a99b1deb45..a99b1deb45 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-3-n.js
index f6148db1cc..f6148db1cc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-4.js
index c2fd40dd17..c2fd40dd17 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.2-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.2-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-1.js
index 755e2281b3..755e2281b3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-2.js
index 1bfed1d4af..1bfed1d4af 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-3-n.js b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-3-n.js
index 7df413ae48..7df413ae48 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/15.7.4.3-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/15.7.4.3-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/browser.js b/tests/auto/qml/parserstress/tests/ecma/Number/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Number/shell.js b/tests/auto/qml/parserstress/tests/ecma/Number/shell.js
index 03cca1d551..03cca1d551 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Number/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Number/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js
index 73ddd2894c..73ddd2894c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js
index 9e41594430..9e41594430 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.1.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js
index dfdfaeb4ab..dfdfaeb4ab 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js
index 2a5743a826..2a5743a826 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.2.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js
index 5242d7e6a5..5242d7e6a5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js
index 39510b6b22..39510b6b22 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js
index a92739f2d1..a92739f2d1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js
index 0a82c6cd02..0a82c6cd02 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js
index 86be98e1ad..86be98e1ad 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.1-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.js
index 70a9605c2e..70a9605c2e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js
index bff668f43c..bff668f43c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js
index c52a825bb8..c52a825bb8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js
index 17c4558679..17c4558679 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/15.2.4.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/browser.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/shell.js b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/shell.js
index 1a71207967..1a71207967 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/ObjectObjects/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/ObjectObjects/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/README b/tests/auto/qml/parserstress/tests/ecma/README
index 91f174ab61..91f174ab61 100755
--- a/tests/auto/declarative/parserstress/tests/ecma/README
+++ b/tests/auto/qml/parserstress/tests/ecma/README
diff --git a/tests/auto/declarative/parserstress/tests/ecma/SourceText/6-1.js b/tests/auto/qml/parserstress/tests/ecma/SourceText/6-1.js
index 487a47e3aa..487a47e3aa 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/SourceText/6-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/SourceText/6-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/SourceText/6-2.js b/tests/auto/qml/parserstress/tests/ecma/SourceText/6-2.js
index 4044308053..4044308053 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/SourceText/6-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/SourceText/6-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/SourceText/browser.js b/tests/auto/qml/parserstress/tests/ecma/SourceText/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/SourceText/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/SourceText/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/SourceText/shell.js b/tests/auto/qml/parserstress/tests/ecma/SourceText/shell.js
index c8f9f02671..c8f9f02671 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/SourceText/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/SourceText/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.10-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.10-1.js
index 7cb13789eb..7cb13789eb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.10-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.10-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.10.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.10.js
index b8d27c64e9..b8d27c64e9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.10.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.10.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.2-1.js
index d6f3b97f6d..d6f3b97f6d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.5-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.5-1.js
index 0745428c4a..0745428c4a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.5-2.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.5-2.js
index 143edb0705..143edb0705 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.1-1.js
index 97b9afaa82..97b9afaa82 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-1.js
index 2ef9378f5a..2ef9378f5a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-2.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-2.js
index cc8676cd29..cc8676cd29 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-3.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-3.js
index a16b7aa18e..a16b7aa18e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-4.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-4.js
index 6b1500d3a4..6b1500d3a4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-5.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-5.js
index a6f86ecc88..a6f86ecc88 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-6.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-6.js
index 48a4e2e607..48a4e2e607 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-7.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-7.js
index a14ced0497..a14ced0497 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-8.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-8.js
index 73d931d838..73d931d838 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-8.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-8.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-9-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-9-n.js
index 3e2f942a22..3e2f942a22 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.2-9-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.2-9-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-1.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-1.js
index 6e23b84a48..6e23b84a48 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-10.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-10.js
index 0e74f14ece..0e74f14ece 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-10.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-10.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-11.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-11.js
index efc65ee14e..efc65ee14e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-11.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-11.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-12.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-12.js
index 840ca9da65..840ca9da65 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-12.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-12.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-19.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-19.js
index 5acbee7127..5acbee7127 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-19.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-19.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-2.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-2.js
index 3ed93dc9a1..3ed93dc9a1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-3.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-3.js
index f52569bba2..f52569bba2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-4.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-4.js
index c30641f8bb..c30641f8bb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-5-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-5-n.js
index 295d059c39..295d059c39 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-5-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-5-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-6-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-6-n.js
index 8cb4c7f638..8cb4c7f638 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-6-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-6-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-7-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-7-n.js
index 871dd474cb..871dd474cb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-7-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-7-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-8-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-8-n.js
index b75a7b5f37..b75a7b5f37 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-8-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-8-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-9-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-9-n.js
index f83a8ed65a..f83a8ed65a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.6.3-9-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.6.3-9-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.7-1-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.7-1-n.js
index 7978f3be56..7978f3be56 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.7-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.7-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.8-1-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.8-1-n.js
index 29f46cf29e..29f46cf29e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.8-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.8-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.9-1-n.js b/tests/auto/qml/parserstress/tests/ecma/Statements/12.9-1-n.js
index 450cb66593..450cb66593 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/12.9-1-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/12.9-1-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/browser.js b/tests/auto/qml/parserstress/tests/ecma/Statements/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Statements/shell.js b/tests/auto/qml/parserstress/tests/ecma/Statements/shell.js
index 7346f697a5..7346f697a5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Statements/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Statements/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.1.js
index cf7ab8b420..cf7ab8b420 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.2.js
index 062d31cdc2..062d31cdc2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-1.js
index cc62c9ed51..cc62c9ed51 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-2.js
index b87137a140..b87137a140 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-3.js
index f94f83db11..f94f83db11 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-4.js
index af8c1b9560..af8c1b9560 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.1-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.1-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-1.js
index 17e715bca0..17e715bca0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-2.js
index 563623e6e3..563623e6e3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-3.js
index ae41742be2..ae41742be2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.2-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.2-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.js
index 5370484568..5370484568 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.1.js
index ae8e12463d..ae8e12463d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.10-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.10-1.js
index 2647d18cb2..2647d18cb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.10-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.10-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-1.js
index a705f3bbda..a705f3bbda 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-2.js
index 7377dc8247..7377dc8247 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-3.js
index 0a37dcd28a..0a37dcd28a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-4.js
index 1196e61c08..1196e61c08 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-5.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-5.js
index eec6410200..eec6410200 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-6.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-6.js
index e3cc6039d4..e3cc6039d4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.11-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.11-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-1.js
index ecc497db48..ecc497db48 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-2.js
index c22b87b4dc..c22b87b4dc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-3.js
index d9d8bc69ce..d9d8bc69ce 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-4.js
index caf5663f07..caf5663f07 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-5.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-5.js
index 2fbed42202..2fbed42202 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.12-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.12-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-1.js
index e607ed51e4..e607ed51e4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-2-n.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-2-n.js
index 930c1f8136..930c1f8136 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-2-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-2-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-3.js
index 1e306a06f3..1e306a06f3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2.js
index 0a1100fc63..0a1100fc63 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-1.js
index b990876fe8..b990876fe8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-2.js
index 4747e013e6..4747e013e6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-3-n.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-3-n.js
index bdfa52ece0..bdfa52ece0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.3-3-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.3-3-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-1.js
index 5dbffb1d14..5dbffb1d14 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-2.js
index c822a1d5f7..c822a1d5f7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-3.js
index 96b4759c98..96b4759c98 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-4.js
index bf9f7a6898..bf9f7a6898 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.4-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.4-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-1.js
index a1ba440a60..a1ba440a60 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-2.js
index 29cb76152e..29cb76152e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-3.js
index 46852f4022..46852f4022 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-4.js
index e1d42c820f..e1d42c820f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-5.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-5.js
index cb3ec71e25..cb3ec71e25 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.5-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.5-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.6-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-1.js
index 94e34ad5ed..94e34ad5ed 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.6-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.6-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-2.js
index acaeffb38a..acaeffb38a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.6-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.6-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.7-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-1.js
index 094be2ed62..094be2ed62 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.7-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.7-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-2.js
index 0252eae00f..0252eae00f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.7-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.7-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-1.js
index 4aa16d5ea0..4aa16d5ea0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-2.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-2.js
index ff33e62ba6..ff33e62ba6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-3.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-3.js
index fe10284a9c..fe10284a9c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.8-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.8-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.9-1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.9-1.js
index 2184c60f45..2184c60f45 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.9-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.9-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.js
index 063e4e68d1..063e4e68d1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.5.1.js b/tests/auto/qml/parserstress/tests/ecma/String/15.5.5.1.js
index 85d3d24ef2..85d3d24ef2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/15.5.5.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/15.5.5.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/browser.js b/tests/auto/qml/parserstress/tests/ecma/String/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/String/shell.js b/tests/auto/qml/parserstress/tests/ecma/String/shell.js
index 7d850446cc..7d850446cc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/String/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/String/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.2.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.2.js
index 2d428b9a9e..2d428b9a9e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3-1.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3-1.js
index 9994d6a7cd..9994d6a7cd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-1.js
index da3e8794c0..da3e8794c0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-2.js
index 911ec84b94..911ec84b94 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-3.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-3.js
index dc56427395..dc56427395 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.js
index c4b866e7f3..c4b866e7f3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.4-1.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-1.js
index e99875697a..e99875697a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.4-2.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-2.js
index 9b26a67fac..9b26a67fac 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.4-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.4-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.5-2.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.5-2.js
index 2773052340..2773052340 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.5-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.5-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.6.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.6.js
index 3d958b3f9d..3d958b3f9d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.7.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.7.js
index 34e4857fd7..34e4857fd7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.7.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.8.1.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.8.1.js
index 897dc59f6f..897dc59f6f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.8.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.8.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.9-1.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.9-1.js
index ea22980767..ea22980767 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/9.9-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/9.9-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/browser.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/shell.js b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/shell.js
index 49ce60f627..49ce60f627 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/TypeConversion/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/TypeConversion/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Types/8.1.js b/tests/auto/qml/parserstress/tests/ecma/Types/8.1.js
index 7abcb93c02..7abcb93c02 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Types/8.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Types/8.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Types/8.4.js b/tests/auto/qml/parserstress/tests/ecma/Types/8.4.js
index 7d3465f8b2..7d3465f8b2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Types/8.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Types/8.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Types/8.6.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/Types/8.6.2.1-1.js
index c06999c42c..c06999c42c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Types/8.6.2.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Types/8.6.2.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Types/browser.js b/tests/auto/qml/parserstress/tests/ecma/Types/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Types/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Types/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/Types/shell.js b/tests/auto/qml/parserstress/tests/ecma/Types/shell.js
index a16b996e00..a16b996e00 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/Types/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/Types/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/browser.js b/tests/auto/qml/parserstress/tests/ecma/browser.js
index 60e48ceed8..60e48ceed8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.4-9.js b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.4-9.js
index 91982de20c..91982de20c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.4-9.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.4-9.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.6.js b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.6.js
index 99fd4a7ff1..99fd4a7ff1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.8-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.8-1.js
index adfc8d5df5..adfc8d5df5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/10.1.8-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/10.1.8-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-1.js
index e467157441..e467157441 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-2.js
index a486885b7f..a486885b7f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-3.js
index 7d66e58530..7d66e58530 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.2-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.2-1.js
index be8a6f6c98..be8a6f6c98 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/11.6.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/11.6.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15-1.js
index fc037873a5..fc037873a5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15-2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15-2.js
index e403e46e8e..e403e46e8e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.1.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.1.2.1-1.js
index c3fe679e5e..c3fe679e5e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.1.2.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.1.2.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.1.1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.1.1.js
index f4f821877d..f4f821877d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.1.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.1.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.3-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.3-1.js
index 6d49db2481..6d49db2481 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.4.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.4.js
index df55e0894a..df55e0894a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.2.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.2.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-1.js
index 169cf50851..169cf50851 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-2.js
index 42165465bc..42165465bc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.1.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.1.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-1.js
index fab359211f..fab359211f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-2.js
index 0b37e21028..0b37e21028 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.2.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.2.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.3.1-1.js
index d4f22ff257..d4f22ff257 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.3.3.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.3.3.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.4.3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.4.3.js
index 8cbf949855..8cbf949855 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.4.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.4.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.3.js
index c25398c4f4..c25398c4f4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.2.js
index ebf4d03781..ebf4d03781 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.4-4.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.4-4.js
index c2e115e0c6..c2e115e0c6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.4-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.4-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.5-6.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.5-6.js
index 4eadc66c04..4eadc66c04 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.5-6.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.5-6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.7-3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.7-3.js
index c5832fd477..c5832fd477 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.5.4.7-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.5.4.7-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.1-5.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.1-5.js
index b9f35b8225..b9f35b8225 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.1-5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.1-5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.js
index 0ae48c59f2..0ae48c59f2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.4-2.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.4-2.js
index 7ca222235f..7ca222235f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.6.4-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.6.4-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.3.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.7.3.js
index 84e362c2db..84e362c2db 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.7.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.4.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.7.4.js
index 733b937e55..733b937e55 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.7.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.7.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.8-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.8-1.js
index 0f51cf5e61..0f51cf5e61 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.8-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.8-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.9.5.js b/tests/auto/qml/parserstress/tests/ecma/extensions/15.9.5.js
index 54e6bb6f0f..54e6bb6f0f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/15.9.5.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/15.9.5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/8.6.2.1-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/8.6.2.1-1.js
index a99bb01ee6..a99bb01ee6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/8.6.2.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/8.6.2.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/9.9-1.js b/tests/auto/qml/parserstress/tests/ecma/extensions/9.9-1.js
index 0df44013cd..0df44013cd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/9.9-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/9.9-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/browser.js b/tests/auto/qml/parserstress/tests/ecma/extensions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/extensions/shell.js b/tests/auto/qml/parserstress/tests/ecma/extensions/shell.js
index 3f52cffbc0..3f52cffbc0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/extensions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/extensions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/jsref.js b/tests/auto/qml/parserstress/tests/ecma/jsref.js
index 1416643e1e..1416643e1e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/jsref.js
+++ b/tests/auto/qml/parserstress/tests/ecma/jsref.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/shell.js b/tests/auto/qml/parserstress/tests/ecma/shell.js
index 1c012601e6..1c012601e6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma/template.js b/tests/auto/qml/parserstress/tests/ecma/template.js
index 8f11686890..8f11686890 100644
--- a/tests/auto/declarative/parserstress/tests/ecma/template.js
+++ b/tests/auto/qml/parserstress/tests/ecma/template.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-001.js
index 7462df2f98..7462df2f98 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-002.js
index 813e11cd39..813e11cd39 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/boolean-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/boolean-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-001.js
index 041bbb523c..041bbb523c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-002.js
index 4fb11b38d9..4fb11b38d9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-003.js
index 95129177c7..95129177c7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-004.js
index d77bd1c272..d77bd1c272 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/date-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/date-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-001.js
index 3762c5b3c4..3762c5b3c4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-002.js
index e5328b8b81..e5328b8b81 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-003.js
index c5956ffc95..c5956ffc95 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-004.js
index 15a07a806f..15a07a806f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-005.js
index e5532ff40c..e5532ff40c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-005.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-005.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-006.js
index b37b52becb..b37b52becb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-006.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-006.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-007.js
index a63ed0e3f8..a63ed0e3f8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-007.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-007.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-008.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-008.js
index 39326183a4..39326183a4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-008.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-008.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-009.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-009.js
index bd5cbe7f40..bd5cbe7f40 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-009.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-009.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-010-n.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-010-n.js
index cb28d635a6..cb28d635a6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-010-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-010-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-011-n.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-011-n.js
index ec5302c247..ec5302c247 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/exception-011-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/exception-011-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-001.js
index c3ae4f21e6..c3ae4f21e6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-002.js
index 2f060936ae..2f060936ae 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-003.js
index 5007b83adf..5007b83adf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-004.js
index 2befdd10f3..2befdd10f3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-005.js
index 2d76593ea2..2d76593ea2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-005.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-005.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-006.js
index eb21e0308c..eb21e0308c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-006.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-006.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-007.js
index a2305be16d..a2305be16d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-007.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-007.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-008.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-008.js
index c85310f957..c85310f957 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-008.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-008.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-009.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-009.js
index feec2cd052..feec2cd052 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-009.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-009.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-010.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-010.js
index e0b38a4838..e0b38a4838 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-010.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-010.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-011.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-011.js
index 75f872480d..75f872480d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-011.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-011.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-012.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-012.js
index 5223abd480..5223abd480 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-012.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-012.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-013.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-013.js
index 10ad726653..10ad726653 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-013.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-013.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-014.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-014.js
index fadca81c7a..fadca81c7a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-014.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-014.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-015.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-015.js
index 2bd2b8d094..2bd2b8d094 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-015.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-015.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-016.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-016.js
index 3c91495f3c..3c91495f3c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-016.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-016.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-017.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-017.js
index 4e762a54a9..4e762a54a9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-017.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-017.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-019.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-019.js
index 11ee3a0063..11ee3a0063 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/expression-019.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/expression-019.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/function-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/function-001.js
index d5f7b452e2..d5f7b452e2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/function-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/function-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-001.js
index a186a51e64..a186a51e64 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-002.js
index c4ef143529..c4ef143529 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/global-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/global-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-001.js
index cc2e3a46aa..cc2e3a46aa 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-002.js
index f7f691a049..f7f691a049 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-003.js
index 482382eeed..482382eeed 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-004.js
index ccf6124109..ccf6124109 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-005.js
index 44b2ea9c87..44b2ea9c87 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-005.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-005.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-006.js
index 6f693d8ad2..6f693d8ad2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-006.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-006.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-007.js
index b6d5152ea0..b6d5152ea0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-007.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-007.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-008.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-008.js
index eed455c243..eed455c243 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-008.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-008.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-009.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-009.js
index d796574809..d796574809 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-009.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-009.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-010.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-010.js
index 059b5a06be..059b5a06be 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-010.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-010.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-011.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-011.js
index 7f01041c41..7f01041c41 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-011.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-011.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-012.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-012.js
index e55b6eb30f..e55b6eb30f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-012.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-012.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-013.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-013.js
index fbbf20b263..fbbf20b263 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-013.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-013.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-014.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-014.js
index 880d2800e5..880d2800e5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-014.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-014.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-015.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-015.js
index a15a2be544..a15a2be544 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-015.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-015.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-016.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-016.js
index 021594d052..021594d052 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-016.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-016.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-017.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-017.js
index b89a526229..b89a526229 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-017.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-017.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-018.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-018.js
index 18773dafe6..18773dafe6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-018.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-018.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-019.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-019.js
index c1c34a93c1..c1c34a93c1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-019.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-019.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-020.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-020.js
index e82e1e50b9..e82e1e50b9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-020.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-020.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-021.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-021.js
index 47a0725a09..47a0725a09 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-021.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-021.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-022.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-022.js
index 75d72aa5b6..75d72aa5b6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-022.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-022.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-023.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-023.js
index aa89c04782..aa89c04782 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-023.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-023.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-024.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-024.js
index 7c1f22f745..7c1f22f745 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-024.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-024.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-025.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-025.js
index f1c7b93daf..f1c7b93daf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-025.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-025.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-026.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-026.js
index 31b5aaaf61..31b5aaaf61 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-026.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-026.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-027.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-027.js
index 573025b591..573025b591 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-027.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-027.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-028.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-028.js
index 1b76a22169..1b76a22169 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-028.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-028.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-029.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-029.js
index f978b8ef89..f978b8ef89 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-029.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-029.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-030.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-030.js
index 3796551698..3796551698 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-030.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-030.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-031.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-031.js
index 13379fed01..13379fed01 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-031.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-031.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-032.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-032.js
index 48e6e9aac5..48e6e9aac5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-032.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-032.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-033.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-033.js
index cc223c2282..cc223c2282 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-033.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-033.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-034.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-034.js
index 4d3c7d5fc0..4d3c7d5fc0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-034.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-034.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-035.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-035.js
index 2a61b437ba..2a61b437ba 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-035.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-035.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-036.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-036.js
index a1923b7303..a1923b7303 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-036.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-036.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-037.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-037.js
index e3cd75bd60..e3cd75bd60 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-037.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-037.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-038.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-038.js
index 1bf8c6c4e4..1bf8c6c4e4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-038.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-038.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-039.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-039.js
index 2f193af89a..2f193af89a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-039.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-039.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-040.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-040.js
index f5ba3533dd..f5ba3533dd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-040.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-040.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-041.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-041.js
index 06d63bddb3..06d63bddb3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-041.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-041.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-042.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-042.js
index c2cedb0b81..c2cedb0b81 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-042.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-042.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-047.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-047.js
index e809c24149..e809c24149 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-047.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-047.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-048.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-048.js
index 18054d4328..18054d4328 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-048.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-048.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-049.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-049.js
index e4ce840829..e4ce840829 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-049.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-049.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-050.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-050.js
index d9161c4b8f..d9161c4b8f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-050.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-050.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-051.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-051.js
index 97ccbc6b43..97ccbc6b43 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-051.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-051.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-052.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-052.js
index 20d2d3c254..20d2d3c254 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-052.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-052.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-053.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-053.js
index 4e64fa1322..4e64fa1322 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-053.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-053.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-054.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-054.js
index 3e25c36ef8..3e25c36ef8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/lexical-054.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/lexical-054.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-001.js
index eb49a5b9bd..eb49a5b9bd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-002.js
index fef61fd527..fef61fd527 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-003.js
index 46920b7072..46920b7072 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/number-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/number-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/shell.js
index 6c671f1eea..6c671f1eea 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-001.js
index 98e3d61a0c..98e3d61a0c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-002.js
index da9931e9ab..da9931e9ab 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-003.js
index d51083c4cf..d51083c4cf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-004.js
index 8b9789a929..8b9789a929 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-005.js
index 62a8c45d92..62a8c45d92 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-005.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-005.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-006.js
index ec5ba97576..ec5ba97576 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-006.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-006.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-007.js
index bb367c9924..bb367c9924 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-007.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-007.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-008.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-008.js
index 54ab39a9c9..54ab39a9c9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-008.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-008.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-009.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-009.js
index a63bd84e8e..a63bd84e8e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/statement-009.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/statement-009.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-001.js
index 551030db33..551030db33 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-002.js
index 785e339080..785e339080 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Exceptions/string-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Exceptions/string-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js
index db5c403d3d..db5c403d3d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/StrictEquality-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/shell.js
index 8f5d1129d5..8f5d1129d5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Expressions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Expressions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js
index e58d087121..e58d087121 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/apply-001-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/call-1.js b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/call-1.js
index 283e323797..283e323797 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/call-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/call-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/shell.js
index 27aa7b1318..27aa7b1318 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/FunctionObjects/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/FunctionObjects/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js
index 7362613783..7362613783 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/keywords-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js
index caa50fe363..caa50fe363 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js
index 911b5d117a..911b5d117a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/regexp-literals-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/shell.js
index 4e1d61d68a..4e1d61d68a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/LexicalConventions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/LexicalConventions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/README b/tests/auto/qml/parserstress/tests/ecma_2/README
index 6da6cdd514..6da6cdd514 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/README
+++ b/tests/auto/qml/parserstress/tests/ecma_2/README
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/constructor-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/constructor-001.js
index f1dba13b06..f1dba13b06 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/constructor-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/constructor-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-001.js
index 2d1bab472c..2d1bab472c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-002.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-002.js
index 026f27d9d4..026f27d9d4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/exec-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/exec-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/function-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/function-001.js
index 8b219b935b..8b219b935b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/function-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/function-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/hex-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js
index 3e85ac7abf..3e85ac7abf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/hex-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/hex-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/multiline-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/multiline-001.js
index 102f91fcd4..102f91fcd4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/multiline-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/multiline-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-001.js
index 1c520750ce..1c520750ce 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-002.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-002.js
index b654e5e68a..b654e5e68a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-003.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-003.js
index ee07ca602b..ee07ca602b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/octal-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/octal-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-001.js
index 7d2913cc53..7d2913cc53 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-002.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-002.js
index 1fcfd8d219..1fcfd8d219 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/properties-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/properties-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js
index c26a1216ea..c26a1216ea 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/regexp-enumerate-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regress-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/regress-001.js
index 219ce245ee..219ce245ee 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/regress-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/regress-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/shell.js
index 9b4657d963..9b4657d963 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/unicode-001.js b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/unicode-001.js
index 79a3212a2e..79a3212a2e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/RegExp/unicode-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/RegExp/unicode-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-001.js
index 8cfdc25dd6..8cfdc25dd6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-002.js
index ca53dff899..ca53dff899 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-003.js
index 598f655f8d..598f655f8d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-004.js
index eb8e0c1b72..eb8e0c1b72 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-005.js
index e4096f0d25..e4096f0d25 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-005.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-005.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-006.js
index c8ad46f629..c8ad46f629 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-006.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-006.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-007.js
index 5d148095d1..5d148095d1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/dowhile-007.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/dowhile-007.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-001.js
index 0f20f6e953..0f20f6e953 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-002.js
index 524bf38b9a..524bf38b9a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/forin-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/forin-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/if-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/if-001.js
index 439410c9a6..439410c9a6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/if-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/if-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/label-001.js
index 07bdeb6b81..07bdeb6b81 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/label-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/label-002.js
index 83b114d3f2..83b114d3f2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/label-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/label-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/shell.js
index 7346f697a5..7346f697a5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-001.js
index 22ab0a7b60..22ab0a7b60 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-002.js
index 6cb5491beb..6cb5491beb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-003.js
index 27ed593bfe..27ed593bfe 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-004.js
index e7605222d6..e7605222d6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/switch-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/switch-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-001.js
index c7b430dabe..c7b430dabe 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-003.js
index 2c39aac243..2c39aac243 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-004.js
index d41903de18..d41903de18 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-005.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-005.js
index 0b9a055325..0b9a055325 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-005.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-005.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-006.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-006.js
index 1cfbd28656..1cfbd28656 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-006.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-006.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-007.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-007.js
index 566166755c..566166755c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-007.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-007.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-008.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-008.js
index 016ab29a31..016ab29a31 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-008.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-008.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-009.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-009.js
index d6ce368638..d6ce368638 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-009.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-009.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-010.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-010.js
index 27e712c895..27e712c895 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-010.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-010.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-012.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-012.js
index 79dfca2f03..79dfca2f03 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/try-012.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/try-012.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-001.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-001.js
index 467efe7f02..467efe7f02 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-002.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-002.js
index c89e195497..c89e195497 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-003.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-003.js
index 5fb734cce6..5fb734cce6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-004.js b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-004.js
index c5e2472816..c5e2472816 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/Statements/while-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/Statements/while-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/String/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-001.js b/tests/auto/qml/parserstress/tests/ecma_2/String/match-001.js
index de2275b5d6..de2275b5d6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/match-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-002.js b/tests/auto/qml/parserstress/tests/ecma_2/String/match-002.js
index a57da2f77f..a57da2f77f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/match-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-003.js b/tests/auto/qml/parserstress/tests/ecma_2/String/match-003.js
index cd3d80c919..cd3d80c919 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/match-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-004.js b/tests/auto/qml/parserstress/tests/ecma_2/String/match-004.js
index 5c26de8b61..5c26de8b61 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/match-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/match-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/replace-001.js b/tests/auto/qml/parserstress/tests/ecma_2/String/replace-001.js
index f0ae3cdbfa..f0ae3cdbfa 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/replace-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/replace-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/String/shell.js
index 7d850446cc..7d850446cc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-001.js b/tests/auto/qml/parserstress/tests/ecma_2/String/split-001.js
index bbab3b0428..bbab3b0428 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/split-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-002.js b/tests/auto/qml/parserstress/tests/ecma_2/String/split-002.js
index 9ae000790e..9ae000790e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/split-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-003.js b/tests/auto/qml/parserstress/tests/ecma_2/String/split-003.js
index 5029fc98f9..5029fc98f9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/String/split-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/String/split-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/browser.js
index 4cde9b0629..4cde9b0629 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/constructor-001.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/constructor-001.js
index cc7907d006..cc7907d006 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/constructor-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/constructor-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/function-001.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/function-001.js
index 5153d25f9d..5153d25f9d 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/function-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/function-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-001.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-001.js
index 8ea446a248..8ea446a248 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-002.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-002.js
index 9cc837d8ef..9cc837d8ef 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-003-n.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-003-n.js
index 7a763a895c..7a763a895c 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-003-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-003-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-004-n.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-004-n.js
index 1662ae566b..1662ae566b 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-004-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-004-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-005-n.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-005-n.js
index 1a9b1b3437..1a9b1b3437 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-005-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-005-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-006.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-006.js
index 03c0f16fb9..03c0f16fb9 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/instanceof-006.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-006.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/shell.js
index 3f52cffbc0..3f52cffbc0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/extensions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/browser.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-001.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-001.js
index 39ae96fa5b..39ae96fa5b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-002.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-002.js
index c35fcb0486..c35fcb0486 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-003.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-003.js
index 6c1279f865..6c1279f865 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/instanceof-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/instanceof-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/regress-7635.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/regress-7635.js
index c643920b04..c643920b04 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/regress-7635.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/regress-7635.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/shell.js
index b390356c38..b390356c38 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/instanceof/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/instanceof/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/jsref.js b/tests/auto/qml/parserstress/tests/ecma_2/jsref.js
index e5a3ddfeed..e5a3ddfeed 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/jsref.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/jsref.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/shell.js b/tests/auto/qml/parserstress/tests/ecma_2/shell.js
index a83dd68ec2..a83dd68ec2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_2/template.js b/tests/auto/qml/parserstress/tests/ecma_2/template.js
index 83397ba7b3..83397ba7b3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_2/template.js
+++ b/tests/auto/qml/parserstress/tests/ecma_2/template.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.11-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.11-01.js
index 0436b8c1e0..0436b8c1e0 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.11-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.11-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.3-1.js
index e3de6fb116..e3de6fb116 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.4-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.4-001.js
index b87233ea97..b87233ea97 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.4.4-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.4-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.5.1-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.5.1-01.js
index b55430b44e..b55430b44e 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/15.4.5.1-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.5.1-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-101488.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-101488.js
index 15a4556298..15a4556298 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-101488.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-101488.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-130451.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-130451.js
index a738bf6356..a738bf6356 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-130451.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-130451.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-01.js
index 4e277e6da5..4e277e6da5 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-02.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-02.js
index ee426a0cec..ee426a0cec 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-02.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-02.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-03.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-03.js
index 95ee7f7a92..95ee7f7a92 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-03.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-03.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-04.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-04.js
index fe9f8fc71e..fe9f8fc71e 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-322135-04.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-04.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-387501.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-387501.js
index 36cf1478d2..36cf1478d2 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-387501.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-387501.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-421325.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-421325.js
index c869d7bff4..c869d7bff4 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-421325.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-421325.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-430717.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-430717.js
index f750ffb449..f750ffb449 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/regress-430717.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-430717.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Array/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/shell.js
index 9480d9e77d..9480d9e77d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Array/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.1.2-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.1.2-01.js
index 61b1de6ef1..61b1de6ef1 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.1.2-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.1.2-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.3.2-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.3.2-1.js
index d79b60b996..d79b60b996 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.3.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.3.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.4.3.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.4.3.js
index b197dcb9c2..b197dcb9c2 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.4.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.4.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.3.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.3.js
index 6704f1fcad..6704f1fcad 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.4.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.4.js
index a2643bfe3c..a2643bfe3c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.4.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.5-02.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5-02.js
index e3b073e7ec..e3b073e7ec 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.5-02.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5-02.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.5.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5.js
index 2b76fdcfc2..2b76fdcfc2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.5.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.6.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.6.js
index 004fbce2e0..004fbce2e0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.6.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.6.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.7.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.7.js
index 00d2541803..00d2541803 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/15.9.5.7.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.7.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/browser.js
index 4cde9b0629..4cde9b0629 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Date/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/shell.js
index 6111c3b934..6111c3b934 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Date/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js
index 6910d76f15..6910d76f15 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.1.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js
index 00f9503041..00f9503041 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.4.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js
index c6248cc7c1..c6248cc7c1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-002.js
index a9da1c4e4e..a9da1c4e4e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-003.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-003.js
index af45b2112d..af45b2112d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/15.11.7.6-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/15.11.7.6-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/binding-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/binding-001.js
index ea2dd6042f..ea2dd6042f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/binding-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/binding-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181654.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181654.js
index 3fe80f15ac..3fe80f15ac 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181654.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181654.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181914.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181914.js
index f4d1f224c8..f4d1f224c8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-181914.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-181914.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-58946.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-58946.js
index 97212c88a0..97212c88a0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-58946.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-58946.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-95101.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-95101.js
index b7ef074350..b7ef074350 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/regress-95101.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/regress-95101.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/shell.js
index 6c671f1eea..6c671f1eea 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Exceptions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Exceptions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js
index 1e7e0254bf..1e7e0254bf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-2.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-2.js
index b2e22e6c55..b2e22e6c55 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3.js
index 45a81f1f3a..45a81f1f3a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.4-1.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.4-1.js
index 896841fa29..896841fa29 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.1.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.1.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js
index 6fbe85e19f..6fbe85e19f 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/regress-23346.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-23346.js
index 6283d886f0..6283d886f0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/regress-23346.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-23346.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js
index f303199b51..f303199b51 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/shell.js
index 1d353cff74..1d353cff74 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/ExecutionContexts/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-01.js
index fd47d5d86b..fd47d5d86b 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-02.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-02.js
index 8f387c1349..8f387c1349 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-02.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-02.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-03.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-03.js
index 99af0f87c5..99af0f87c5 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.10-03.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-03.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.6.1-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.6.1-1.js
index 8854c499f2..8854c499f2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.6.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.6.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.1-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.1-01.js
index 05f9622ce2..05f9622ce2 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.1-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.1-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.2-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.2-01.js
index 64e426888a..64e426888a 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.2-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.2-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.3-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.3-01.js
index d5af3b86d4..d5af3b86d4 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.7.3-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.3-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.9.6-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.9.6-1.js
index 1e8f59e400..1e8f59e400 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/11.9.6-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.9.6-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/shell.js
index 8f5d1129d5..8f5d1129d5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Expressions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-001-n.js b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-001-n.js
index 71ed2fbb08..71ed2fbb08 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-001-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-001-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-001.js b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-001.js
index 366c5fd472..366c5fd472 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-002.js b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-002.js
index d602b01b09..d602b01b09 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/fe-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/fe-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/shell.js
index ecf5f4798f..ecf5f4798f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/FunExpr/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/FunExpr/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/15.3.4.3-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/15.3.4.3-1.js
index ef51379e4f..ef51379e4f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/15.3.4.3-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/15.3.4.3-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/15.3.4.4-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/15.3.4.4-1.js
index d27b8487b7..d27b8487b7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/15.3.4.4-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/15.3.4.4-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/arguments-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/arguments-001.js
index 2dbd603e02..2dbd603e02 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/arguments-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/arguments-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/arguments-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/arguments-002.js
index 78005560a7..78005560a7 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/arguments-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/arguments-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/call-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/call-001.js
index 61ab3b930b..61ab3b930b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/call-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/call-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-131964.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-131964.js
index f3998db91c..f3998db91c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-131964.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-131964.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-137181.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-137181.js
index 1bf7c35f93..1bf7c35f93 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-137181.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-137181.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-193555.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-193555.js
index ed37b46c90..ed37b46c90 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-193555.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-193555.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-313570.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-313570.js
index e159c4c87f..e159c4c87f 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-313570.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-313570.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-49286.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-49286.js
index 50e203bed8..50e203bed8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-49286.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-49286.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-58274.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-58274.js
index da5bde597f..da5bde597f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-58274.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-58274.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-85880.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-85880.js
index 8ea4fb6c41..8ea4fb6c41 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-85880.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-85880.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-94506.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-94506.js
index b6ab5cc24c..b6ab5cc24c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-94506.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-94506.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-97921.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-97921.js
index 855f966dc4..855f966dc4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/regress-97921.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-97921.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/scope-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/scope-001.js
index 3aa1d3bc03..3aa1d3bc03 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/scope-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/scope-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/scope-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/scope-002.js
index 7a9b6f204b..7a9b6f204b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/scope-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/scope-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Function/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/shell.js
index eebf3d51f8..eebf3d51f8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Function/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js b/tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js
index 10ee26f929..10ee26f929 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/shell.js
index 4e1d61d68a..4e1d61d68a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/LexicalConventions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.2-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.2-01.js
index 36d63ed7e4..36d63ed7e4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.2-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.2-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.3-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.3-01.js
index 7c4cba753d..7c4cba753d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.3-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.3-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.3-02.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.3-02.js
index 72e7c56141..72e7c56141 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.3-02.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.3-02.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.5-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.5-1.js
index c21efa0b66..c21efa0b66 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.5-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.5-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.6-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.6-1.js
index dec9ed6a90..dec9ed6a90 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.6-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.6-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.7-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.7-1.js
index 5aa0724a46..5aa0724a46 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.7-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.7-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.7-2.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.7-2.js
index 5c8ff396e4..5c8ff396e4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/15.7.4.7-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/15.7.4.7-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/regress-442242-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/regress-442242-01.js
index e3fa070e5a..e3fa070e5a 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/regress-442242-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/regress-442242-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Number/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/shell.js
index 03cca1d551..03cca1d551 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Number/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/shell.js
index 1847703bf3..1847703bf3 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/tostring-001.js b/tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/tostring-001.js
index 34152aa5c0..34152aa5c0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/NumberFormatting/tostring-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/NumberFormatting/tostring-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.1-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.1-01.js
index 2897ece555..2897ece555 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.1-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.1-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.2.6-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.2.6-001.js
index 8fe2b23f4a..8fe2b23f4a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/8.6.2.6-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.2.6-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/browser.js
index 0e57d1fcd0..0e57d1fcd0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-001.js
index faa2f4fceb..faa2f4fceb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-002.js
index 0b49ffd9db..0b49ffd9db 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-003.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-003.js
index 7afedb2985..7afedb2985 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-004.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-004.js
index 729b041086..729b041086 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-005.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-005.js
index f57d0681cf..f57d0681cf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/class-005.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-005.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-361274.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-361274.js
index d3962004e3..d3962004e3 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-361274.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-361274.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-385393-07.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-385393-07.js
index 0473fe4956..0473fe4956 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-385393-07.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-385393-07.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-72773.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-72773.js
index 5b0dee62bf..5b0dee62bf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-72773.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-72773.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-79129-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-79129-001.js
index efafed8047..efafed8047 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/regress-79129-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-79129-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Object/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/shell.js
index d0ee054485..d0ee054485 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Object/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.13.1-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-001.js
index 935eed2de1..935eed2de1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.13.1-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.13.1-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-002.js
index 5d3307e4a7..5d3307e4a7 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.13.1-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.4.1-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-001.js
index 7a5ed8f915..7a5ed8f915 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.4.1-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.4.1-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-002.js
index c48565ba5f..c48565ba5f 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/11.4.1-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/order-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/order-01.js
index 671faceb81..671faceb81 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/order-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/order-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/shell.js
index 910515cfe4..910515cfe4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Operators/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/README b/tests/auto/qml/parserstress/tests/ecma_3/README
index eebd421c2e..eebd421c2e 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/README
+++ b/tests/auto/qml/parserstress/tests/ecma_3/README
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2-1.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2-1.js
index 9439a2ccd6..9439a2ccd6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2.12.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2.12.js
index d68b86c2ed..d68b86c2ed 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.2.12.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2.12.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js
index 7286cea297..7286cea297 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js
index d78be13c25..d78be13c25 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.3.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js
index 47faf0051b..47faf0051b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js
index 1d67b8afe6..1d67b8afe6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js
index 12ef46bde8..12ef46bde8 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js
index 3b4245851e..3b4245851e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-4.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js
index 592fb03ac7..592fb03ac7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.4.1-5-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js
index 8203da4967..8203da4967 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js
index e6fd6c6311..e6fd6c6311 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.6.2-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-001.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-001.js
index f35724e47b..f35724e47b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-002.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-002.js
index 401ad43c11..401ad43c11 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/octal-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/octal-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-001.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-001.js
index 0b27529a32..0b27529a32 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-002.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-002.js
index a9b147b977..a9b147b977 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/perlstress-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/perlstress-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-100199.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-100199.js
index 8c88aa7f52..8c88aa7f52 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-100199.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-100199.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-105972.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-105972.js
index e691c518b4..e691c518b4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-105972.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-105972.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-119909.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-119909.js
index 97f6414bc7..97f6414bc7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-119909.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-119909.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-122076.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-122076.js
index e77f433fc4..e77f433fc4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-122076.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-122076.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-123437.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-123437.js
index 745a3a707a..745a3a707a 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-123437.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-123437.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-165353.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-165353.js
index f7c736ce4d..f7c736ce4d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-165353.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-165353.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169497.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169497.js
index 5613a93872..5613a93872 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169497.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169497.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169534.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169534.js
index c736631bd7..c736631bd7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-169534.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-169534.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-187133.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-187133.js
index 98ec4753bf..98ec4753bf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-187133.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-187133.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-188206.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-188206.js
index 308c0ff605..308c0ff605 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-188206.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-188206.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-191479.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-191479.js
index 51d5f14c42..51d5f14c42 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-191479.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-191479.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-202564.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-202564.js
index e0ae0f9948..e0ae0f9948 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-202564.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-202564.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-209067.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-209067.js
index 98b4029ce4..98b4029ce4 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-209067.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-209067.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-209919.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-209919.js
index 62c3cd86f0..62c3cd86f0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-209919.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-209919.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-216591.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-216591.js
index 455565ae36..455565ae36 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-216591.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-216591.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-220367-001.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-220367-001.js
index 59abc0c4b0..59abc0c4b0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-220367-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-220367-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-223273.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-223273.js
index 2858e85487..2858e85487 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-223273.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-223273.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-223535.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-223535.js
index 82305502fd..82305502fd 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-223535.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-223535.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-224676.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-224676.js
index 88e89ee609..88e89ee609 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-224676.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-224676.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-225289.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-225289.js
index 6e05d12ead..6e05d12ead 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-225289.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-225289.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-225343.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-225343.js
index 25e248adaa..25e248adaa 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-225343.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-225343.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-24712.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-24712.js
index c94472195f..c94472195f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-24712.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-24712.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-285219.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-285219.js
index 9d462359fa..9d462359fa 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-285219.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-285219.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-28686.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-28686.js
index b3e355fa1c..b3e355fa1c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-28686.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-28686.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-289669.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-289669.js
index 2e3d044b74..2e3d044b74 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-289669.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-289669.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-307456.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-307456.js
index dd2f540f6c..dd2f540f6c 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-307456.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-307456.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-309840.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-309840.js
index 8680b7bcfd..8680b7bcfd 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-309840.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-309840.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-311414.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-311414.js
index a24a07bb2b..a24a07bb2b 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-311414.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-311414.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-312351.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-312351.js
index a9b00d317c..a9b00d317c 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-312351.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-312351.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-31316.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-31316.js
index 594913f07c..594913f07c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-31316.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-31316.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-330684.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-330684.js
index b097fbc3d7..b097fbc3d7 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-330684.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-330684.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-334158.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-334158.js
index 41ebf0a731..41ebf0a731 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-334158.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-334158.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-346090.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-346090.js
index dfd53a9922..dfd53a9922 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-346090.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-346090.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-367888.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-367888.js
index 923c1e5ab3..923c1e5ab3 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-367888.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-367888.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375642.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375642.js
index 236eb00d28..236eb00d28 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375642.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375642.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375711.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375711.js
index 6e7339f9e9..6e7339f9e9 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375711.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375711.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js
index 437dcbd5c5..437dcbd5c5 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-02.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-02.js
index 3cd858e845..3cd858e845 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-02.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-02.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-03.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-03.js
index ffc5c5a4cc..ffc5c5a4cc 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-03.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-03.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-04.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-04.js
index 0c78a372ee..0c78a372ee 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-375715-04.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-04.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57572.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57572.js
index c7abd410bf..c7abd410bf 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57572.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57572.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57631.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57631.js
index dc222bfc0f..dc222bfc0f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-57631.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-57631.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-67773.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-67773.js
index 4ee0d52854..4ee0d52854 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-67773.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-67773.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-72964.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-72964.js
index 67a41e505c..67a41e505c 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-72964.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-72964.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-76683.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-76683.js
index 8792e379ca..8792e379ca 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-76683.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-76683.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-78156.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-78156.js
index dd42ce060b..dd42ce060b 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-78156.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-78156.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-85721.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-85721.js
index bca1a15e19..bca1a15e19 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-85721.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-85721.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-87231.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-87231.js
index b5467322eb..b5467322eb 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-87231.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-87231.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-98306.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-98306.js
index a2bfc2bf93..a2bfc2bf93 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/regress-98306.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-98306.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/shell.js
index dbc733c376..dbc733c376 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/RegExp/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-385393-04.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-385393-04.js
index 6e735fd1d2..6e735fd1d2 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-385393-04.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-385393-04.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-419152.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-419152.js
index f57f3a4f98..f57f3a4f98 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-419152.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-419152.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-420087.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420087.js
index 1f21d19739..1f21d19739 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-420087.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420087.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-420610.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420610.js
index ecd5a2dd42..ecd5a2dd42 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-420610.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420610.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-441477-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-441477-01.js
index 1be199743d..1be199743d 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/regress-441477-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-441477-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/shell.js
index 8c83369020..8c83369020 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Regress/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/12.6.3.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/12.6.3.js
index 97c3ca3136..97c3ca3136 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/12.6.3.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/12.6.3.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-121744.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-121744.js
index 828cc5d8d5..828cc5d8d5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-121744.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-121744.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-131348.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-131348.js
index 013e114178..013e114178 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-131348.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-131348.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-157509.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-157509.js
index 0b1319ebba..0b1319ebba 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-157509.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-157509.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-194364.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-194364.js
index a139f2b985..a139f2b985 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-194364.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-194364.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-226517.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-226517.js
index d99bfb503e..d99bfb503e 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-226517.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-226517.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-302439.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-302439.js
index e1ebdb6e30..e1ebdb6e30 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-302439.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-302439.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-324650.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-324650.js
index 003cd0fa42..003cd0fa42 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-324650.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-324650.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-001.js
index 93dc425f72..93dc425f72 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-002.js
index 1c54849c48..1c54849c48 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-003.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-003.js
index 0bbe062ca9..0bbe062ca9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-74474-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-74474-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-83532-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-83532-001.js
index 8e2bb6b010..8e2bb6b010 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-83532-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-83532-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-83532-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-83532-002.js
index 3bd5ce8703..3bd5ce8703 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/regress-83532-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-83532-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/shell.js
index 7346f697a5..7346f697a5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/switch-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/switch-001.js
index aae6659cc1..aae6659cc1 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Statements/switch-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/switch-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.11.js b/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.11.js
index ef518bb9e5..ef518bb9e5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.11.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.11.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.14.js b/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.14.js
index aa6c7354c2..aa6c7354c2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/15.5.4.14.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/15.5.4.14.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/String/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-104375.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-104375.js
index c5593948d7..c5593948d7 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-104375.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-104375.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-189898.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-189898.js
index c75c081513..c75c081513 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-189898.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-189898.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-304376.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-304376.js
index 733cd713d8..733cd713d8 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-304376.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-304376.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-313567.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-313567.js
index 9610238cc3..9610238cc3 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-313567.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-313567.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-392378.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js
index 368fde1278..368fde1278 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-392378.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-83293.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-83293.js
index 55e74d4dd5..55e74d4dd5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/regress-83293.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-83293.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/String/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/String/shell.js
index 7d850446cc..7d850446cc 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/String/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/String/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-01.js
index bb10ac6f7a..bb10ac6f7a 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js
index 0e3c4b0189..0e3c4b0189 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/shell.js
index 97a64fe83d..97a64fe83d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001-n.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001-n.js
index 31a13f70e2..31a13f70e2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001.js
index 3fc0c8d927..3fc0c8d927 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-001.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-001.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002-n.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002-n.js
index f1ae9a749d..f1ae9a749d 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002-n.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002-n.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002.js
index d19b2c4786..d19b2c4786 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-003.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-003.js
index 66c3f09860..66c3f09860 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-003.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-003.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-004.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-004.js
index a54923c525..a54923c525 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-004.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-004.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-005.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-005.js
index 3727042046..3727042046 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/Unicode/uc-005.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/uc-005.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/browser.js
index 2339522cb6..2339522cb6 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/10.1.3-2.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/10.1.3-2.js
index f941cb7800..f941cb7800 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/10.1.3-2.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/10.1.3-2.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/7.9.1.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/7.9.1.js
index b69e9d065a..b69e9d065a 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/7.9.1.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/7.9.1.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/browser.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/browser.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/browser.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-103087.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-103087.js
index 8cef9404e9..8cef9404e9 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-103087.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-103087.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-188206-01.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-188206-01.js
index f09963a7b5..f09963a7b5 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-188206-01.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-188206-01.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-188206-02.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-188206-02.js
index 3bd079fae6..3bd079fae6 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-188206-02.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-188206-02.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-220367-002.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-220367-002.js
index 7af2a9d63f..7af2a9d63f 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-220367-002.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-220367-002.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-228087.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-228087.js
index 6e16126cc0..6e16126cc0 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-228087.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-228087.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-274152.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-274152.js
index d7074d9128..d7074d9128 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-274152.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-274152.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-320854.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-320854.js
index 85e684882f..85e684882f 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-320854.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-320854.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-327170.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-327170.js
index 5d15ce31a9..5d15ce31a9 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-327170.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-327170.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-368516.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-368516.js
index a5f5fb769b..a5f5fb769b 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-368516.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-368516.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-385393-03.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-385393-03.js
index 40c7e8dd81..40c7e8dd81 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-385393-03.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-385393-03.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-429248.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-429248.js
index 9966269115..9966269115 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-429248.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-429248.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-430740.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-430740.js
index 446adb95a6..446adb95a6 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/regress-430740.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-430740.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/shell.js
index d83e3591af..d83e3591af 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/extensions/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/shell.js
index ea63a51957..ea63a51957 100644
--- a/tests/auto/declarative/parserstress/tests/ecma_3/shell.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/shell.js
diff --git a/tests/auto/declarative/parserstress/tests/ecma_3/template.js b/tests/auto/qml/parserstress/tests/ecma_3/template.js
index 4dedd5a0e3..4dedd5a0e3 100755
--- a/tests/auto/declarative/parserstress/tests/ecma_3/template.js
+++ b/tests/auto/qml/parserstress/tests/ecma_3/template.js
diff --git a/tests/auto/declarative/parserstress/tests/shell.js b/tests/auto/qml/parserstress/tests/shell.js
index 40af0f3799..40af0f3799 100644
--- a/tests/auto/declarative/parserstress/tests/shell.js
+++ b/tests/auto/qml/parserstress/tests/shell.js
diff --git a/tests/auto/qml/parserstress/tst_parserstress.cpp b/tests/auto/qml/parserstress/tst_parserstress.cpp
new file mode 100644
index 0000000000..c7f4840a11
--- /dev/null
+++ b/tests/auto/qml/parserstress/tst_parserstress.cpp
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QDebug>
+#include <QDir>
+#include <QFile>
+
+class tst_parserstress : public QObject
+{
+ Q_OBJECT
+public:
+ tst_parserstress() {}
+
+private slots:
+ void ecmascript_data();
+ void ecmascript();
+
+private:
+ static QStringList findJSFiles(const QDir &);
+ QQmlEngine engine;
+};
+
+QStringList tst_parserstress::findJSFiles(const QDir &d)
+{
+ QStringList rv;
+
+ QStringList files = d.entryList(QStringList() << QLatin1String("*.js"),
+ QDir::Files);
+ foreach (const QString &file, files) {
+ if (file == "browser.js")
+ continue;
+ rv << d.absoluteFilePath(file);
+ }
+
+ QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
+ QDir::NoSymLinks);
+ foreach (const QString &dir, dirs) {
+ QDir sub = d;
+ sub.cd(dir);
+ rv << findJSFiles(sub);
+ }
+
+ return rv;
+}
+
+void tst_parserstress::ecmascript_data()
+{
+#ifdef TESTDATADIR
+ QDir dir(TESTDATADIR);
+ QStringList files = findJSFiles(dir);
+
+ QTest::addColumn<QString>("file");
+ foreach (const QString &file, files) {
+ QTest::newRow(qPrintable(file)) << file;
+ }
+#endif
+}
+
+void tst_parserstress::ecmascript()
+{
+ QFETCH(QString, file);
+
+ QFile f(file);
+ QVERIFY(f.open(QIODevice::ReadOnly));
+
+ QByteArray data = f.readAll();
+
+ QVERIFY(!data.isEmpty());
+
+ QString dataStr = QString::fromUtf8(data);
+
+ QString qml = "import QtQuick 2.0\n";
+ qml+= "\n";
+ qml+= "QtObject {\n";
+ qml+= " property int test\n";
+ qml+= " test: {\n";
+ qml+= dataStr + "\n";
+ qml+= " return 1;\n";
+ qml+= " }\n";
+ qml+= " function stress() {\n";
+ qml+= dataStr;
+ qml+= " }\n";
+ qml+= "}\n";
+
+ QByteArray qmlData = qml.toUtf8();
+
+ QQmlComponent component(&engine);
+
+ component.setData(qmlData, QUrl::fromLocalFile(SRCDIR + QString("/dummy.qml")));
+
+ QFileInfo info(file);
+
+ if (info.fileName() == QLatin1String("regress-352044-02-n.js")) {
+ QVERIFY(component.isError());
+
+ QCOMPARE(component.errors().length(), 2);
+
+ QCOMPARE(component.errors().at(0).description(), QString("Expected token `;'"));
+ QCOMPARE(component.errors().at(0).line(), 66);
+
+ QCOMPARE(component.errors().at(1).description(), QString("Expected token `;'"));
+ QCOMPARE(component.errors().at(1).line(), 142);
+
+ } else {
+
+ QVERIFY(!component.isError());
+ }
+}
+
+
+QTEST_MAIN(tst_parserstress)
+
+#include "tst_parserstress.moc"
diff --git a/tests/auto/qml/qjsengine/qjsengine.pro b/tests/auto/qml/qjsengine/qjsengine.pro
new file mode 100644
index 0000000000..3451157dbb
--- /dev/null
+++ b/tests/auto/qml/qjsengine/qjsengine.pro
@@ -0,0 +1,13 @@
+CONFIG += testcase
+TARGET = tst_qjsengine
+QT += qml widgets testlib
+macx:CONFIG -= app_bundle
+SOURCES += tst_qjsengine.cpp
+wince* {
+ addFiles.files = script
+ addFiles.path = .
+ DEPLOYMENT += addFiles
+ DEFINES += SRCDIR=\\\"./\\\"
+} else {
+ DEFINES += SRCDIR=\\\"$$PWD\\\"
+}
diff --git a/tests/auto/declarative/qjsengine/script/com/__init__.js b/tests/auto/qml/qjsengine/script/com/__init__.js
index 7db3ee4cac..7db3ee4cac 100644
--- a/tests/auto/declarative/qjsengine/script/com/__init__.js
+++ b/tests/auto/qml/qjsengine/script/com/__init__.js
diff --git a/tests/auto/declarative/qjsengine/script/com/trolltech/__init__.js b/tests/auto/qml/qjsengine/script/com/trolltech/__init__.js
index a55b1328ba..a55b1328ba 100644
--- a/tests/auto/declarative/qjsengine/script/com/trolltech/__init__.js
+++ b/tests/auto/qml/qjsengine/script/com/trolltech/__init__.js
diff --git a/tests/auto/declarative/qjsengine/script/com/trolltech/recursive/__init__.js b/tests/auto/qml/qjsengine/script/com/trolltech/recursive/__init__.js
index 2f4cad48da..2f4cad48da 100644
--- a/tests/auto/declarative/qjsengine/script/com/trolltech/recursive/__init__.js
+++ b/tests/auto/qml/qjsengine/script/com/trolltech/recursive/__init__.js
diff --git a/tests/auto/declarative/qjsengine/script/com/trolltech/syntaxerror/__init__.js b/tests/auto/qml/qjsengine/script/com/trolltech/syntaxerror/__init__.js
index 55bc35b5f2..55bc35b5f2 100644
--- a/tests/auto/declarative/qjsengine/script/com/trolltech/syntaxerror/__init__.js
+++ b/tests/auto/qml/qjsengine/script/com/trolltech/syntaxerror/__init__.js
diff --git a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 66fef8e2dd..66fef8e2dd 100644
--- a/tests/auto/declarative/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
diff --git a/tests/auto/qml/qjsvalue/qjsvalue.pro b/tests/auto/qml/qjsvalue/qjsvalue.pro
new file mode 100644
index 0000000000..19b983e549
--- /dev/null
+++ b/tests/auto/qml/qjsvalue/qjsvalue.pro
@@ -0,0 +1,6 @@
+CONFIG += testcase
+TARGET = tst_qjsvalue
+macx:CONFIG -= app_bundle
+QT += qml widgets testlib
+SOURCES += tst_qjsvalue.cpp
+HEADERS += tst_qjsvalue.h
diff --git a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
index cec10ccf38..cec10ccf38 100644
--- a/tests/auto/declarative/qjsvalue/tst_qjsvalue.cpp
+++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp
diff --git a/tests/auto/declarative/qjsvalue/tst_qjsvalue.h b/tests/auto/qml/qjsvalue/tst_qjsvalue.h
index 0e7f7405a6..0e7f7405a6 100644
--- a/tests/auto/declarative/qjsvalue/tst_qjsvalue.h
+++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.h
diff --git a/tests/auto/qml/qjsvalueiterator/qjsvalueiterator.pro b/tests/auto/qml/qjsvalueiterator/qjsvalueiterator.pro
new file mode 100644
index 0000000000..4ee1693ad8
--- /dev/null
+++ b/tests/auto/qml/qjsvalueiterator/qjsvalueiterator.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase
+TARGET = tst_qjsvalueiterator
+macx:CONFIG -= app_bundle
+QT = core qml testlib
+SOURCES += tst_qjsvalueiterator.cpp
+
+
diff --git a/tests/auto/declarative/qjsvalueiterator/tst_qjsvalueiterator.cpp b/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp
index eade3de1a7..eade3de1a7 100644
--- a/tests/auto/declarative/qjsvalueiterator/tst_qjsvalueiterator.cpp
+++ b/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp
diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro
new file mode 100644
index 0000000000..7a62a71df1
--- /dev/null
+++ b/tests/auto/qml/qml.pro
@@ -0,0 +1,55 @@
+TEMPLATE = subdirs
+
+METATYPETESTS += \
+ qqmlmetatype
+
+PUBLICTESTS += \
+ parserstress \
+ qjsengine \
+ qjsvalue \
+ qjsvalueiterator \
+ qmlmin \
+ qmlplugindump \
+ qqmlcomponent \
+ qqmlconsole \
+ qqmlcontext \
+ qqmlengine \
+ qqmlerror \
+ qqmlincubator \
+ qqmlinfo \
+ qqmllistreference \
+ qqmllocale \
+ qqmlmoduleplugin \
+ qqmlqt \
+ qqmltranslation \
+ qqmlxmlhttprequest \
+ qqmlparser \
+ qquickfolderlistmodel
+
+PRIVATETESTS += \
+ animation \
+ qqmlcpputils \
+ qqmlecmascript \
+ qqmlexpression \
+ qqmlimageprovider \
+ qqmlinstruction \
+ qqmllanguage \
+ qqmlproperty \
+ qqmlpropertymap \
+ qqmlsqldatabase \
+ qqmlvaluetypes \
+ qquickbinding \
+ qquickchangeset \
+ qquickconnection \
+ qquicklistcompositor \
+ qquicklistmodel \
+ qquickworkerscript \
+ v4
+
+SUBDIRS += $$PUBLICTESTS
+SUBDIRS += $$METATYPETESTS
+SUBDIRS += debugger
+
+contains(QT_CONFIG, private_tests) {
+ SUBDIRS += $$PRIVATETESTS
+}
diff --git a/tests/auto/qml/qmlmin/qmlmin.pro b/tests/auto/qml/qmlmin/qmlmin.pro
new file mode 100644
index 0000000000..49a4e7ff58
--- /dev/null
+++ b/tests/auto/qml/qmlmin/qmlmin.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qmlmin
+QT += qml testlib
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qmlmin.cpp
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
new file mode 100644
index 0000000000..2d764317c5
--- /dev/null
+++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
@@ -0,0 +1,192 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QLibraryInfo>
+#include <QDir>
+#include <QProcess>
+#include <QDebug>
+#include <QQmlError>
+#include <cstdlib>
+
+class tst_qmlmin : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qmlmin();
+
+private slots:
+ void initTestCase();
+ void qmlMinify_data();
+ void qmlMinify();
+
+private:
+ QString qmlminPath;
+ QStringList excludedDirs;
+ QStringList invalidFiles;
+
+ QStringList findFiles(const QDir &);
+ bool isInvalidFile(const QFileInfo &fileName) const;
+};
+
+tst_qmlmin::tst_qmlmin()
+{
+}
+
+void tst_qmlmin::initTestCase()
+{
+ qmlminPath = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/qmlmin");
+#ifdef Q_OS_WIN
+ qmlminPath += QLatin1String(".exe");
+#endif
+ if (!QFileInfo(qmlminPath).exists()) {
+ QString message = QString::fromLatin1("qmlmin executable not found (looked for %0)")
+ .arg(qmlminPath);
+ QFAIL(qPrintable(message));
+ }
+
+ // Add directories you want excluded here
+
+ // These snippets are not expected to run on their own.
+ excludedDirs << "doc/src/snippets/qml/visualdatamodel_rootindex";
+ excludedDirs << "doc/src/snippets/qml/qtbinding";
+ excludedDirs << "doc/src/snippets/qml/imports";
+ excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex";
+ excludedDirs << "doc/src/snippets/qtquick1/qtbinding";
+ excludedDirs << "doc/src/snippets/qtquick1/imports";
+
+ // Add invalid files (i.e. files with syntax errors)
+ invalidFiles << "tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.3.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/property.4.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/empty.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/signal.2.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/missingObject.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/invalidRoot.1.qml";
+ invalidFiles << "tests/auto/qml/qquickfolderlistmodel/data/dummy.qml";
+ invalidFiles << "tests/auto/qml/qqmlecmascript/data/qtbug_22843.js";
+ invalidFiles << "tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.js";
+ invalidFiles << "tests/auto/qml/qquickworkerscript/data/script_error_onLoad.js";
+ invalidFiles << "tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-02-n.js";
+}
+
+QStringList tst_qmlmin::findFiles(const QDir &d)
+{
+ for (int ii = 0; ii < excludedDirs.count(); ++ii) {
+ QString s = excludedDirs.at(ii);
+ if (d.absolutePath().endsWith(s))
+ return QStringList();
+ }
+
+ QStringList rv;
+
+ QStringList files = d.entryList(QStringList() << QLatin1String("*.qml") << QLatin1String("*.js"),
+ QDir::Files);
+ foreach (const QString &file, files) {
+ rv << d.absoluteFilePath(file);
+ }
+
+ QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
+ QDir::NoSymLinks);
+ foreach (const QString &dir, dirs) {
+ QDir sub = d;
+ sub.cd(dir);
+ rv << findFiles(sub);
+ }
+
+ return rv;
+}
+
+bool tst_qmlmin::isInvalidFile(const QFileInfo &fileName) const
+{
+ foreach (const QString &invalidFile, invalidFiles) {
+ if (fileName.absoluteFilePath().endsWith(invalidFile))
+ return true;
+ }
+ return false;
+}
+
+/*
+This test runs all the examples in the QtQml UI source tree and ensures
+that they start and exit cleanly.
+
+Examples are any .qml files under the examples/ directory that start
+with a lower case letter.
+*/
+
+void tst_qmlmin::qmlMinify_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QString examples = QLatin1String(SRCDIR) + "/../../../../examples/";
+ QString tests = QLatin1String(SRCDIR) + "/../../../../tests/";
+
+ QStringList files;
+ files << findFiles(QDir(examples));
+ files << findFiles(QDir(tests));
+
+ foreach (const QString &file, files)
+ QTest::newRow(qPrintable(file)) << file;
+}
+
+void tst_qmlmin::qmlMinify()
+{
+ QFETCH(QString, file);
+
+ QProcess qmlminify;
+ qmlminify.start(qmlminPath, QStringList() << QLatin1String("--verify-only") << file);
+ qmlminify.waitForFinished();
+
+ QCOMPARE(qmlminify.error(), QProcess::UnknownError);
+ QCOMPARE(qmlminify.exitStatus(), QProcess::NormalExit);
+
+ if (isInvalidFile(file))
+ QCOMPARE(qmlminify.exitCode(), EXIT_FAILURE); // cannot minify files with syntax errors
+ else
+ QCOMPARE(qmlminify.exitCode(), 0);
+}
+
+QTEST_MAIN(tst_qmlmin)
+
+#include "tst_qmlmin.moc"
diff --git a/tests/auto/declarative/qmlplugindump/qmlplugindump.pro b/tests/auto/qml/qmlplugindump/qmlplugindump.pro
index 498a520873..498a520873 100644
--- a/tests/auto/declarative/qmlplugindump/qmlplugindump.pro
+++ b/tests/auto/qml/qmlplugindump/qmlplugindump.pro
diff --git a/tests/auto/declarative/qmlplugindump/tst_qmlplugindump.cpp b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp
index 5512cfdfe8..5512cfdfe8 100644
--- a/tests/auto/declarative/qmlplugindump/tst_qmlplugindump.cpp
+++ b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp
diff --git a/tests/auto/declarative/qdeclarativecomponent/data/createObject.qml b/tests/auto/qml/qqmlcomponent/data/createObject.qml
index da5db8e8e6..da5db8e8e6 100644
--- a/tests/auto/declarative/qdeclarativecomponent/data/createObject.qml
+++ b/tests/auto/qml/qqmlcomponent/data/createObject.qml
diff --git a/tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml b/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml
index 122c6a87c8..122c6a87c8 100644
--- a/tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml
+++ b/tests/auto/qml/qqmlcomponent/data/createObjectWithScript.qml
diff --git a/tests/auto/declarative/qdeclarativecomponent/data/incubateObject.qml b/tests/auto/qml/qqmlcomponent/data/incubateObject.qml
index c11319db30..c11319db30 100644
--- a/tests/auto/declarative/qdeclarativecomponent/data/incubateObject.qml
+++ b/tests/auto/qml/qqmlcomponent/data/incubateObject.qml
diff --git a/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro b/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro
new file mode 100644
index 0000000000..7cef181a4a
--- /dev/null
+++ b/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlcomponent
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlcomponent.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private network testlib
diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
new file mode 100644
index 0000000000..d277952f22
--- /dev/null
+++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QDebug>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlproperty.h>
+#include <QtQml/qqmlincubator.h>
+#include <qcolor.h>
+#include "../../shared/util.h"
+
+class MyIC : public QObject, public QQmlIncubationController
+{
+ Q_OBJECT
+public:
+ MyIC() { startTimer(5); }
+protected:
+ virtual void timerEvent(QTimerEvent*) {
+ incubateFor(5);
+ }
+};
+
+class tst_qqmlcomponent : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlcomponent() { engine.setIncubationController(&ic); }
+
+private slots:
+ void null();
+ void loadEmptyUrl();
+ void qmlCreateObject();
+ void qmlCreateObjectWithProperties();
+ void qmlIncubateObject();
+
+private:
+ QQmlEngine engine;
+ MyIC ic;
+};
+
+void tst_qqmlcomponent::null()
+{
+ {
+ QQmlComponent c;
+ QVERIFY(c.isNull());
+ }
+
+ {
+ QQmlComponent c(&engine);
+ QVERIFY(c.isNull());
+ }
+}
+
+
+void tst_qqmlcomponent::loadEmptyUrl()
+{
+ QQmlComponent c(&engine);
+ c.loadUrl(QUrl());
+
+ QVERIFY(c.isError());
+ QCOMPARE(c.errors().count(), 1);
+ QQmlError error = c.errors().first();
+ QCOMPARE(error.url(), QUrl());
+ QCOMPARE(error.line(), -1);
+ QCOMPARE(error.column(), -1);
+ QCOMPARE(error.description(), QLatin1String("Invalid empty URL"));
+}
+
+void tst_qqmlcomponent::qmlIncubateObject()
+{
+ QQmlComponent component(&engine, testFileUrl("incubateObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), false);
+
+ QTRY_VERIFY(object->property("test2").toBool() == true);
+
+ delete object;
+}
+
+void tst_qqmlcomponent::qmlCreateObject()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("createObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *testObject1 = object->property("qobject").value<QObject*>();
+ QVERIFY(testObject1);
+ QVERIFY(testObject1->parent() == object);
+
+ QObject *testObject2 = object->property("declarativeitem").value<QObject*>();
+ QVERIFY(testObject2);
+ QVERIFY(testObject2->parent() == object);
+ QCOMPARE(testObject2->metaObject()->className(), "QQuickItem");
+}
+
+void tst_qqmlcomponent::qmlCreateObjectWithProperties()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("createObjectWithScript.qml"));
+ QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *testObject1 = object->property("declarativerectangle").value<QObject*>();
+ QVERIFY(testObject1);
+ QVERIFY(testObject1->parent() == object);
+ QCOMPARE(testObject1->property("x").value<int>(), 17);
+ QCOMPARE(testObject1->property("y").value<int>(), 17);
+ QCOMPARE(testObject1->property("color").value<QColor>(), QColor(255,255,255));
+ QCOMPARE(QQmlProperty::read(testObject1,"border.width").toInt(), 3);
+ QCOMPARE(QQmlProperty::read(testObject1,"innerRect.border.width").toInt(), 20);
+ delete testObject1;
+
+ QObject *testObject2 = object->property("declarativeitem").value<QObject*>();
+ QVERIFY(testObject2);
+ QVERIFY(testObject2->parent() == object);
+ //QCOMPARE(testObject2->metaObject()->className(), "QDeclarativeItem_QML_2");
+ QCOMPARE(testObject2->property("x").value<int>(), 17);
+ QCOMPARE(testObject2->property("y").value<int>(), 17);
+ QCOMPARE(testObject2->property("testBool").value<bool>(), true);
+ QCOMPARE(testObject2->property("testInt").value<int>(), 17);
+ QCOMPARE(testObject2->property("testObject").value<QObject*>(), object);
+ delete testObject2;
+
+ QObject *testBindingObj = object->property("bindingTestObject").value<QObject*>();
+ QVERIFY(testBindingObj);
+ QCOMPARE(testBindingObj->parent(), object);
+ QCOMPARE(testBindingObj->property("testValue").value<int>(), 300);
+ object->setProperty("width", 150);
+ QCOMPARE(testBindingObj->property("testValue").value<int>(), 150 * 3);
+ delete testBindingObj;
+
+ QObject *testBindingThisObj = object->property("bindingThisTestObject").value<QObject*>();
+ QVERIFY(testBindingThisObj);
+ QCOMPARE(testBindingThisObj->parent(), object);
+ QCOMPARE(testBindingThisObj->property("testValue").value<int>(), 900);
+ testBindingThisObj->setProperty("width", 200);
+ QCOMPARE(testBindingThisObj->property("testValue").value<int>(), 200 * 3);
+ delete testBindingThisObj;
+}
+
+QTEST_MAIN(tst_qqmlcomponent)
+
+#include "tst_qqmlcomponent.moc"
diff --git a/tests/auto/declarative/qdeclarativeconsole/data/assert.qml b/tests/auto/qml/qqmlconsole/data/assert.qml
index 43ca893809..43ca893809 100644
--- a/tests/auto/declarative/qdeclarativeconsole/data/assert.qml
+++ b/tests/auto/qml/qqmlconsole/data/assert.qml
diff --git a/tests/auto/declarative/qdeclarativeconsole/data/exception.qml b/tests/auto/qml/qqmlconsole/data/exception.qml
index 1cda37a9f4..1cda37a9f4 100644
--- a/tests/auto/declarative/qdeclarativeconsole/data/exception.qml
+++ b/tests/auto/qml/qqmlconsole/data/exception.qml
diff --git a/tests/auto/declarative/qdeclarativeconsole/data/logging.qml b/tests/auto/qml/qqmlconsole/data/logging.qml
index 44009b5db9..44009b5db9 100644
--- a/tests/auto/declarative/qdeclarativeconsole/data/logging.qml
+++ b/tests/auto/qml/qqmlconsole/data/logging.qml
diff --git a/tests/auto/declarative/qdeclarativeconsole/data/profiling.qml b/tests/auto/qml/qqmlconsole/data/profiling.qml
index 9a0ca354a5..9a0ca354a5 100644
--- a/tests/auto/declarative/qdeclarativeconsole/data/profiling.qml
+++ b/tests/auto/qml/qqmlconsole/data/profiling.qml
diff --git a/tests/auto/qml/qqmlconsole/data/tracing.qml b/tests/auto/qml/qqmlconsole/data/tracing.qml
new file mode 100644
index 0000000000..9586829f8f
--- /dev/null
+++ b/tests/auto/qml/qqmlconsole/data/tracing.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+// moving lines in here requires fixing tst_qqmlconsole.cpp
+QtObject {
+ id: root
+
+ function tracing()
+ {
+ console.trace();
+ }
+
+ Component.onCompleted: {
+ tracing();
+ }
+}
diff --git a/tests/auto/qml/qqmlconsole/qqmlconsole.pro b/tests/auto/qml/qqmlconsole/qqmlconsole.pro
new file mode 100644
index 0000000000..9ae23316a1
--- /dev/null
+++ b/tests/auto/qml/qqmlconsole/qqmlconsole.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlconsole
+SOURCES += tst_qqmlconsole.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += qml testlib
diff --git a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp
new file mode 100644
index 0000000000..d96da678e2
--- /dev/null
+++ b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp
@@ -0,0 +1,170 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QDebug>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include "../../shared/util.h"
+
+class tst_qqmlconsole : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlconsole() {}
+
+private slots:
+ void logging();
+ void tracing();
+ void profiling();
+ void assert();
+ void exception();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_qqmlconsole::logging()
+{
+ QUrl testUrl = testFileUrl("logging.qml");
+
+ QTest::ignoreMessage(QtDebugMsg, "console.debug");
+ QTest::ignoreMessage(QtDebugMsg, "console.log");
+ QTest::ignoreMessage(QtDebugMsg, "console.info");
+ QTest::ignoreMessage(QtWarningMsg, "console.warn");
+ QTest::ignoreMessage(QtCriticalMsg, "console.error");
+
+ QTest::ignoreMessage(QtDebugMsg, "console.count: 1");
+ QTest::ignoreMessage(QtDebugMsg, ": 1");
+ QTest::ignoreMessage(QtDebugMsg, "console.count: 2");
+ QTest::ignoreMessage(QtDebugMsg, ": 2");
+
+ QTest::ignoreMessage(QtDebugMsg, "[1,2]");
+ QTest::ignoreMessage(QtDebugMsg, "Object");
+ QTest::ignoreMessage(QtDebugMsg, "undefined");
+ QTest::ignoreMessage(QtDebugMsg, "12");
+ QTest::ignoreMessage(QtDebugMsg, "function () { return 5;}");
+ QTest::ignoreMessage(QtDebugMsg, "true");
+ QTest::ignoreMessage(QtDebugMsg, "Object");
+ QTest::ignoreMessage(QtDebugMsg, "Object");
+ QTest::ignoreMessage(QtDebugMsg, "1 pong! Object");
+ QTest::ignoreMessage(QtDebugMsg, "1 [ping,pong] Object 2");
+
+ QQmlComponent component(&engine, testUrl);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlconsole::tracing()
+{
+ QUrl testUrl = testFileUrl("tracing.qml");
+
+ QString traceText =
+ QString::fromLatin1("tracing (%1:%2:%3)\n").arg(testUrl.toString()).arg(50).arg(17) +
+ QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(54).arg(9);
+
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(traceText));
+
+ QQmlComponent component(&engine, testUrl);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlconsole::profiling()
+{
+ QUrl testUrl = testFileUrl("profiling.qml");
+
+ // profiling()
+ QTest::ignoreMessage(QtDebugMsg, "Profiling started.");
+ QTest::ignoreMessage(QtDebugMsg, "Profiling ended.");
+
+ QQmlComponent component(&engine, testUrl);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlconsole::assert()
+{
+ QUrl testUrl = testFileUrl("assert.qml");
+
+ // assert()
+ QString assert1 = "This will fail\n" +
+ QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(54).arg(17);
+
+ QString assert2 = "This will fail too\n" +
+ QString::fromLatin1("assertFail (%1:%2:%3)\n").arg(testUrl.toString()).arg(47).arg(17) +
+ QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(59).arg(9);
+
+ QTest::ignoreMessage(QtCriticalMsg, qPrintable(assert1));
+ QTest::ignoreMessage(QtCriticalMsg, qPrintable(assert2));
+
+ QQmlComponent component(&engine, testUrl);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlconsole::exception()
+{
+ QUrl testUrl = testFileUrl("exception.qml");
+
+ // exception()
+ QString exception1 = "Exception 1\n" +
+ QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(51).arg(21);
+
+ QString exception2 = "Exception 2\n" +
+ QString::fromLatin1("exceptionFail (%1:%2:%3)\n").arg(testUrl.toString()).arg(46).arg(17) +
+ QString::fromLatin1("onCompleted (%1:%2:%3)").arg(testUrl.toString()).arg(56).arg(9);
+
+ QTest::ignoreMessage(QtCriticalMsg, qPrintable(exception1));
+ QTest::ignoreMessage(QtCriticalMsg, qPrintable(exception2));
+
+ QQmlComponent component(&engine, testUrl);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+QTEST_MAIN(tst_qqmlconsole)
+
+#include "tst_qqmlconsole.moc"
diff --git a/tests/auto/declarative/qdeclarativecontext/data/Object_22535.qml b/tests/auto/qml/qqmlcontext/data/Object_22535.qml
index 294c744317..294c744317 100644
--- a/tests/auto/declarative/qdeclarativecontext/data/Object_22535.qml
+++ b/tests/auto/qml/qqmlcontext/data/Object_22535.qml
diff --git a/tests/auto/declarative/qdeclarativecontext/data/RefreshExpressionsType.qml b/tests/auto/qml/qqmlcontext/data/RefreshExpressionsType.qml
index b7c3427c85..b7c3427c85 100644
--- a/tests/auto/declarative/qdeclarativecontext/data/RefreshExpressionsType.qml
+++ b/tests/auto/qml/qqmlcontext/data/RefreshExpressionsType.qml
diff --git a/tests/auto/declarative/qdeclarativecontext/data/qtbug_22535.qml b/tests/auto/qml/qqmlcontext/data/qtbug_22535.qml
index 3553f6c03b..3553f6c03b 100644
--- a/tests/auto/declarative/qdeclarativecontext/data/qtbug_22535.qml
+++ b/tests/auto/qml/qqmlcontext/data/qtbug_22535.qml
diff --git a/tests/auto/declarative/qdeclarativecontext/data/refreshExpressions.qml b/tests/auto/qml/qqmlcontext/data/refreshExpressions.qml
index 01e503f8dc..01e503f8dc 100644
--- a/tests/auto/declarative/qdeclarativecontext/data/refreshExpressions.qml
+++ b/tests/auto/qml/qqmlcontext/data/refreshExpressions.qml
diff --git a/tests/auto/declarative/qdeclarativecontext/data/refreshExpressionsRootContext.qml b/tests/auto/qml/qqmlcontext/data/refreshExpressionsRootContext.qml
index bd82cd9552..bd82cd9552 100644
--- a/tests/auto/declarative/qdeclarativecontext/data/refreshExpressionsRootContext.qml
+++ b/tests/auto/qml/qqmlcontext/data/refreshExpressionsRootContext.qml
diff --git a/tests/auto/qml/qqmlcontext/qqmlcontext.pro b/tests/auto/qml/qqmlcontext/qqmlcontext.pro
new file mode 100644
index 0000000000..9920766d61
--- /dev/null
+++ b/tests/auto/qml/qqmlcontext/qqmlcontext.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlcontext
+SOURCES += tst_qqmlcontext.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private testlib v8-private
diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
new file mode 100644
index 0000000000..6125362365
--- /dev/null
+++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
@@ -0,0 +1,652 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDebug>
+#include <QQmlEngine>
+#include <QQmlContext>
+#include <QQmlComponent>
+#include <QQmlExpression>
+#include <private/qqmlcontext_p.h>
+#include "../../shared/util.h"
+
+class tst_qqmlcontext : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlcontext() {}
+
+private slots:
+ void baseUrl();
+ void resolvedUrl();
+ void engineMethod();
+ void parentContext();
+ void setContextProperty();
+ void setContextObject();
+ void destruction();
+ void idAsContextProperty();
+ void readOnlyContexts();
+ void nameForObject();
+
+ void refreshExpressions();
+ void refreshExpressionsCrash();
+ void refreshExpressionsRootContext();
+
+ void qtbug_22535();
+private:
+ QQmlEngine engine;
+};
+
+void tst_qqmlcontext::baseUrl()
+{
+ QQmlContext ctxt(&engine);
+
+ QCOMPARE(ctxt.baseUrl(), QUrl());
+
+ ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
+
+ QCOMPARE(ctxt.baseUrl(), QUrl("http://www.nokia.com/"));
+}
+
+void tst_qqmlcontext::resolvedUrl()
+{
+ // Relative to the component
+ {
+ QQmlContext ctxt(&engine);
+ ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
+
+ QCOMPARE(ctxt.resolvedUrl(QUrl("main.qml")), QUrl("http://www.nokia.com/main.qml"));
+ }
+
+ // Relative to a parent
+ {
+ QQmlContext ctxt(&engine);
+ ctxt.setBaseUrl(QUrl("http://www.nokia.com/"));
+
+ QQmlContext ctxt2(&ctxt);
+ QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
+ }
+
+ // Relative to the engine
+ {
+ QQmlContext ctxt(&engine);
+ QCOMPARE(ctxt.resolvedUrl(QUrl("main.qml")), engine.baseUrl().resolved(QUrl("main.qml")));
+ }
+
+ // Relative to a deleted parent
+ {
+ QQmlContext *ctxt = new QQmlContext(&engine);
+ ctxt->setBaseUrl(QUrl("http://www.nokia.com/"));
+
+ QQmlContext ctxt2(ctxt);
+ QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
+
+ delete ctxt; ctxt = 0;
+
+ QCOMPARE(ctxt2.resolvedUrl(QUrl("main2.qml")), QUrl());
+ }
+
+ // Absolute
+ {
+ QQmlContext ctxt(&engine);
+
+ QCOMPARE(ctxt.resolvedUrl(QUrl("http://www.nokia.com/main2.qml")), QUrl("http://www.nokia.com/main2.qml"));
+ QCOMPARE(ctxt.resolvedUrl(QUrl("file:///main2.qml")), QUrl("file:///main2.qml"));
+ }
+}
+
+void tst_qqmlcontext::engineMethod()
+{
+ QQmlEngine *engine = new QQmlEngine;
+
+ QQmlContext ctxt(engine);
+ QQmlContext ctxt2(&ctxt);
+ QQmlContext ctxt3(&ctxt2);
+ QQmlContext ctxt4(&ctxt2);
+
+ QCOMPARE(ctxt.engine(), engine);
+ QCOMPARE(ctxt2.engine(), engine);
+ QCOMPARE(ctxt3.engine(), engine);
+ QCOMPARE(ctxt4.engine(), engine);
+
+ delete engine; engine = 0;
+
+ QCOMPARE(ctxt.engine(), engine);
+ QCOMPARE(ctxt2.engine(), engine);
+ QCOMPARE(ctxt3.engine(), engine);
+ QCOMPARE(ctxt4.engine(), engine);
+}
+
+void tst_qqmlcontext::parentContext()
+{
+ QQmlEngine *engine = new QQmlEngine;
+
+ QCOMPARE(engine->rootContext()->parentContext(), (QQmlContext *)0);
+
+ QQmlContext *ctxt = new QQmlContext(engine);
+ QQmlContext *ctxt2 = new QQmlContext(ctxt);
+ QQmlContext *ctxt3 = new QQmlContext(ctxt2);
+ QQmlContext *ctxt4 = new QQmlContext(ctxt2);
+ QQmlContext *ctxt5 = new QQmlContext(ctxt);
+ QQmlContext *ctxt6 = new QQmlContext(engine);
+ QQmlContext *ctxt7 = new QQmlContext(engine->rootContext());
+
+ QCOMPARE(ctxt->parentContext(), engine->rootContext());
+ QCOMPARE(ctxt2->parentContext(), ctxt);
+ QCOMPARE(ctxt3->parentContext(), ctxt2);
+ QCOMPARE(ctxt4->parentContext(), ctxt2);
+ QCOMPARE(ctxt5->parentContext(), ctxt);
+ QCOMPARE(ctxt6->parentContext(), engine->rootContext());
+ QCOMPARE(ctxt7->parentContext(), engine->rootContext());
+
+ delete ctxt2; ctxt2 = 0;
+
+ QCOMPARE(ctxt->parentContext(), engine->rootContext());
+ QCOMPARE(ctxt3->parentContext(), (QQmlContext *)0);
+ QCOMPARE(ctxt4->parentContext(), (QQmlContext *)0);
+ QCOMPARE(ctxt5->parentContext(), ctxt);
+ QCOMPARE(ctxt6->parentContext(), engine->rootContext());
+ QCOMPARE(ctxt7->parentContext(), engine->rootContext());
+
+ delete engine; engine = 0;
+
+ QCOMPARE(ctxt->parentContext(), (QQmlContext *)0);
+ QCOMPARE(ctxt3->parentContext(), (QQmlContext *)0);
+ QCOMPARE(ctxt4->parentContext(), (QQmlContext *)0);
+ QCOMPARE(ctxt5->parentContext(), (QQmlContext *)0);
+ QCOMPARE(ctxt6->parentContext(), (QQmlContext *)0);
+ QCOMPARE(ctxt7->parentContext(), (QQmlContext *)0);
+
+ delete ctxt7;
+ delete ctxt6;
+ delete ctxt5;
+ delete ctxt4;
+ delete ctxt3;
+ delete ctxt;
+}
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int a READ a NOTIFY aChanged)
+ Q_PROPERTY(int b READ b NOTIFY bChanged)
+ Q_PROPERTY(int c READ c NOTIFY cChanged)
+
+public:
+ TestObject() : _a(10), _b(10), _c(10) {}
+
+ int a() const { return _a; }
+ void setA(int a) { _a = a; emit aChanged(); }
+
+ int b() const { return _b; }
+ void setB(int b) { _b = b; emit bChanged(); }
+
+ int c() const { return _c; }
+ void setC(int c) { _c = c; emit cChanged(); }
+
+signals:
+ void aChanged();
+ void bChanged();
+ void cChanged();
+
+private:
+ int _a;
+ int _b;
+ int _c;
+};
+
+#define TEST_CONTEXT_PROPERTY(ctxt, name, value) \
+{ \
+ QQmlComponent component(&engine); \
+ component.setData("import QtQuick 2.0; QtObject { property variant test: " #name " }", QUrl()); \
+\
+ QObject *obj = component.create(ctxt); \
+\
+ QCOMPARE(obj->property("test"), value); \
+\
+ delete obj; \
+}
+
+void tst_qqmlcontext::setContextProperty()
+{
+ QQmlContext ctxt(&engine);
+ QQmlContext ctxt2(&ctxt);
+
+ TestObject obj1;
+ obj1.setA(3345);
+ TestObject obj2;
+ obj2.setA(-19);
+
+ // Static context properties
+ ctxt.setContextProperty("a", QVariant(10));
+ ctxt.setContextProperty("b", QVariant(9));
+ ctxt2.setContextProperty("d", &obj2);
+ ctxt2.setContextProperty("b", QVariant(19));
+ ctxt2.setContextProperty("c", QVariant(QString("Hello World!")));
+ ctxt.setContextProperty("d", &obj1);
+ ctxt.setContextProperty("e", &obj1);
+
+ TEST_CONTEXT_PROPERTY(&ctxt2, a, QVariant(10));
+ TEST_CONTEXT_PROPERTY(&ctxt2, b, QVariant(19));
+ TEST_CONTEXT_PROPERTY(&ctxt2, c, QVariant(QString("Hello World!")));
+ TEST_CONTEXT_PROPERTY(&ctxt2, d.a, QVariant(-19));
+ TEST_CONTEXT_PROPERTY(&ctxt2, e.a, QVariant(3345));
+
+ ctxt.setContextProperty("a", QVariant(13));
+ ctxt.setContextProperty("b", QVariant(4));
+ ctxt2.setContextProperty("b", QVariant(8));
+ ctxt2.setContextProperty("c", QVariant(QString("Hi World!")));
+ ctxt2.setContextProperty("d", &obj1);
+ obj1.setA(12);
+
+ TEST_CONTEXT_PROPERTY(&ctxt2, a, QVariant(13));
+ TEST_CONTEXT_PROPERTY(&ctxt2, b, QVariant(8));
+ TEST_CONTEXT_PROPERTY(&ctxt2, c, QVariant(QString("Hi World!")));
+ TEST_CONTEXT_PROPERTY(&ctxt2, d.a, QVariant(12));
+ TEST_CONTEXT_PROPERTY(&ctxt2, e.a, QVariant(12));
+
+ // Changes in context properties
+ {
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl());
+
+ QObject *obj = component.create(&ctxt2);
+
+ QCOMPARE(obj->property("test"), QVariant(13));
+ ctxt.setContextProperty("a", QVariant(19));
+ QCOMPARE(obj->property("test"), QVariant(19));
+
+ delete obj;
+ }
+ {
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property variant test: b }", QUrl());
+
+ QObject *obj = component.create(&ctxt2);
+
+ QCOMPARE(obj->property("test"), QVariant(8));
+ ctxt.setContextProperty("b", QVariant(5));
+ QCOMPARE(obj->property("test"), QVariant(8));
+ ctxt2.setContextProperty("b", QVariant(1912));
+ QCOMPARE(obj->property("test"), QVariant(1912));
+
+ delete obj;
+ }
+ {
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property variant test: e.a }", QUrl());
+
+ QObject *obj = component.create(&ctxt2);
+
+ QCOMPARE(obj->property("test"), QVariant(12));
+ obj1.setA(13);
+ QCOMPARE(obj->property("test"), QVariant(13));
+
+ delete obj;
+ }
+
+ // New context properties
+ {
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl());
+
+ QObject *obj = component.create(&ctxt2);
+
+ QCOMPARE(obj->property("test"), QVariant(19));
+ ctxt2.setContextProperty("a", QVariant(1945));
+ QCOMPARE(obj->property("test"), QVariant(1945));
+
+ delete obj;
+ }
+
+ // Setting an object-variant context property
+ {
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { id: root; property int a: 10; property int test: ctxtProp.a; property variant obj: root; }", QUrl());
+
+ QQmlContext ctxt(engine.rootContext());
+ ctxt.setContextProperty("ctxtProp", QVariant());
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>:1: TypeError: Cannot read property 'a' of undefined");
+ QObject *obj = component.create(&ctxt);
+
+ QVariant v = obj->property("obj");
+
+ ctxt.setContextProperty("ctxtProp", v);
+
+ QCOMPARE(obj->property("test"), QVariant(10));
+
+ delete obj;
+ }
+}
+
+void tst_qqmlcontext::setContextObject()
+{
+ QQmlContext ctxt(&engine);
+
+ TestObject to;
+
+ to.setA(2);
+ to.setB(192);
+ to.setC(18);
+
+ ctxt.setContextObject(&to);
+ ctxt.setContextProperty("c", QVariant(9));
+
+ // Static context properties
+ TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(2));
+ TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(192));
+ TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(9));
+
+ to.setA(12);
+ to.setB(100);
+ to.setC(7);
+ ctxt.setContextProperty("c", QVariant(3));
+
+ TEST_CONTEXT_PROPERTY(&ctxt, a, QVariant(12));
+ TEST_CONTEXT_PROPERTY(&ctxt, b, QVariant(100));
+ TEST_CONTEXT_PROPERTY(&ctxt, c, QVariant(3));
+
+ // Changes in context properties
+ {
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl());
+
+ QObject *obj = component.create(&ctxt);
+
+ QCOMPARE(obj->property("test"), QVariant(12));
+ to.setA(14);
+ QCOMPARE(obj->property("test"), QVariant(14));
+
+ delete obj;
+ }
+}
+
+void tst_qqmlcontext::destruction()
+{
+ QQmlContext *ctxt = new QQmlContext(&engine);
+
+ QObject obj;
+ QQmlEngine::setContextForObject(&obj, ctxt);
+ QQmlExpression expr(ctxt, 0, "a");
+
+ QCOMPARE(ctxt, QQmlEngine::contextForObject(&obj));
+ QCOMPARE(ctxt, expr.context());
+
+ delete ctxt; ctxt = 0;
+
+ QCOMPARE(ctxt, QQmlEngine::contextForObject(&obj));
+ QCOMPARE(ctxt, expr.context());
+}
+
+void tst_qqmlcontext::idAsContextProperty()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property variant a; a: QtObject { id: myObject } }", QUrl());
+
+ QObject *obj = component.create();
+ QVERIFY(obj);
+
+ QVariant a = obj->property("a");
+ QVERIFY(a.userType() == QMetaType::QObjectStar);
+
+ QVariant ctxt = qmlContext(obj)->contextProperty("myObject");
+ QVERIFY(ctxt.userType() == QMetaType::QObjectStar);
+
+ QVERIFY(a == ctxt);
+
+ delete obj;
+}
+
+// Internal contexts should be read-only
+void tst_qqmlcontext::readOnlyContexts()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { id: me }", QUrl());
+
+ QObject *obj = component.create();
+ QVERIFY(obj);
+
+ QQmlContext *context = qmlContext(obj);
+ QVERIFY(context);
+
+ QVERIFY(qvariant_cast<QObject*>(context->contextProperty("me")) == obj);
+ QVERIFY(context->contextObject() == obj);
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlContext: Cannot set property on internal context.");
+ context->setContextProperty("hello", 12);
+ QVERIFY(context->contextProperty("hello") == QVariant());
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlContext: Cannot set property on internal context.");
+ context->setContextProperty("hello", obj);
+ QVERIFY(context->contextProperty("hello") == QVariant());
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlContext: Cannot set context object for internal context.");
+ context->setContextObject(0);
+ QVERIFY(context->contextObject() == obj);
+
+ delete obj;
+}
+
+void tst_qqmlcontext::nameForObject()
+{
+ QObject o1;
+ QObject o2;
+ QObject o3;
+
+ QQmlEngine engine;
+
+ // As a context property
+ engine.rootContext()->setContextProperty("o1", &o1);
+ engine.rootContext()->setContextProperty("o2", &o2);
+ engine.rootContext()->setContextProperty("o1_2", &o1);
+
+ QCOMPARE(engine.rootContext()->nameForObject(&o1), QString("o1"));
+ QCOMPARE(engine.rootContext()->nameForObject(&o2), QString("o2"));
+ QCOMPARE(engine.rootContext()->nameForObject(&o3), QString());
+
+ // As an id
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { id: root; property QtObject o: QtObject { id: nested } }", QUrl());
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(qmlContext(o)->nameForObject(o), QString("root"));
+ QCOMPARE(qmlContext(o)->nameForObject(qvariant_cast<QObject*>(o->property("o"))), QString("nested"));
+ QCOMPARE(qmlContext(o)->nameForObject(&o1), QString());
+
+ delete o;
+}
+
+class DeleteCommand : public QObject
+{
+Q_OBJECT
+public:
+ DeleteCommand() : object(0) {}
+
+ QObject *object;
+
+public slots:
+ void doCommand() { if (object) delete object; object = 0; }
+};
+
+// Calling refresh expressions would crash if an expression or context was deleted during
+// the refreshing
+void tst_qqmlcontext::refreshExpressionsCrash()
+{
+ {
+ QQmlEngine engine;
+
+ DeleteCommand command;
+ engine.rootContext()->setContextProperty("deleteCommand", &command);
+ // We use a fresh context here to bypass any root-context optimizations in
+ // the engine
+ QQmlContext ctxt(engine.rootContext());
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property var binding: deleteCommand.doCommand() }", QUrl());
+ QVERIFY(component.isReady());
+
+ QObject *o1 = component.create(&ctxt);
+ QObject *o2 = component.create(&ctxt);
+
+ command.object = o2;
+
+ QQmlContextData::get(&ctxt)->refreshExpressions();
+
+ delete o1;
+ }
+ {
+ QQmlEngine engine;
+
+ DeleteCommand command;
+ engine.rootContext()->setContextProperty("deleteCommand", &command);
+ // We use a fresh context here to bypass any root-context optimizations in
+ // the engine
+ QQmlContext ctxt(engine.rootContext());
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property var binding: deleteCommand.doCommand() }", QUrl());
+ QVERIFY(component.isReady());
+
+ QObject *o1 = component.create(&ctxt);
+ QObject *o2 = component.create(&ctxt);
+
+ command.object = o1;
+
+ QQmlContextData::get(&ctxt)->refreshExpressions();
+
+ delete o2;
+ }
+}
+
+class CountCommand : public QObject
+{
+Q_OBJECT
+public:
+ CountCommand() : count(0) {}
+
+ int count;
+
+public slots:
+ void doCommand() { ++count; }
+};
+
+
+// Test that calling refresh expressions causes all the expressions to refresh
+void tst_qqmlcontext::refreshExpressions()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("refreshExpressions.qml"));
+ QQmlComponent component2(&engine, testFileUrl("RefreshExpressionsType.qml"));
+
+ CountCommand command;
+ engine.rootContext()->setContextProperty("countCommand", &command);
+
+ // We use a fresh context here to bypass any root-context optimizations in
+ // the engine
+ QQmlContext context(engine.rootContext());
+ QQmlContext context2(&context);
+
+ QObject *o1 = component.create(&context);
+ QObject *o2 = component.create(&context2);
+ QObject *o3 = component2.create(&context);
+
+ QCOMPARE(command.count, 5);
+
+ QQmlContextData::get(&context)->refreshExpressions();
+
+ QCOMPARE(command.count, 10);
+
+ delete o3;
+ delete o2;
+ delete o1;
+}
+
+// Test that updating the root context, only causes expressions in contexts with an
+// unresolved name to reevaluate
+void tst_qqmlcontext::refreshExpressionsRootContext()
+{
+ QQmlEngine engine;
+
+ CountCommand command;
+ engine.rootContext()->setContextProperty("countCommand", &command);
+
+ QQmlComponent component(&engine, testFileUrl("refreshExpressions.qml"));
+ QQmlComponent component2(&engine, testFileUrl("refreshExpressionsRootContext.qml"));
+
+ QQmlContext context(engine.rootContext());
+ QQmlContext context2(engine.rootContext());
+
+ QString warning = component2.url().toString() + QLatin1String(":4: ReferenceError: Can't find variable: unresolvedName");
+
+ QObject *o1 = component.create(&context);
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QObject *o2 = component2.create(&context2);
+
+ QCOMPARE(command.count, 3);
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QQmlContextData::get(engine.rootContext())->refreshExpressions();
+
+ QCOMPARE(command.count, 4);
+
+ delete o2;
+ delete o1;
+}
+
+void tst_qqmlcontext::qtbug_22535()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("qtbug_22535.qml"));
+ QQmlContext context(engine.rootContext());
+
+ QObject *o = component.create(&context);
+
+ // Don't crash!
+ delete o;
+}
+
+QTEST_MAIN(tst_qqmlcontext)
+
+#include "tst_qqmlcontext.moc"
diff --git a/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro b/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro
new file mode 100644
index 0000000000..1c088860e5
--- /dev/null
+++ b/tests/auto/qml/qqmlcpputils/qqmlcpputils.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qqmlcpputils
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlcpputils.cpp
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private testlib
diff --git a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp
new file mode 100644
index 0000000000..186b82a0a8
--- /dev/null
+++ b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <qsignalspy.h>
+#include <private/qqmlglobal_p.h>
+
+class tst_qqmlcpputils : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmlcpputils() {}
+
+private slots:
+ void fastConnect();
+};
+
+class MyObject : public QObject {
+ Q_OBJECT
+public:
+ MyObject() : slotCount(0) {}
+ friend class tst_qqmlcpputils;
+
+ int slotCount;
+
+signals:
+ void signal1();
+ void signal2();
+
+public slots:
+ void slot1() { slotCount++; }
+};
+
+void tst_qqmlcpputils::fastConnect()
+{
+ {
+ MyObject *obj = new MyObject;
+ FAST_CONNECT(obj, SIGNAL(signal1()), obj, SLOT(slot1()));
+
+ obj->signal1();
+ QCOMPARE(obj->slotCount, 1);
+
+ delete obj;
+ }
+
+ {
+ MyObject obj;
+ FAST_CONNECT(&obj, SIGNAL(signal1()), &obj, SLOT(slot1()))
+
+ obj.signal1();
+ QCOMPARE(obj.slotCount, 1);
+ }
+
+ {
+ MyObject *obj = new MyObject;
+ QSignalSpy spy(obj, SIGNAL(signal2()));
+ FAST_CONNECT(obj, SIGNAL(signal1()), obj, SIGNAL(signal2()));
+
+ obj->signal1();
+ QCOMPARE(spy.count(), 1);
+
+ delete obj;
+ }
+}
+
+QTEST_MAIN(tst_qqmlcpputils)
+
+#include "tst_qqmlcpputils.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsAssignCorrectlyType.qml b/tests/auto/qml/qqmlecmascript/data/AliasBindingsAssignCorrectlyType.qml
index e8e108fa44..e8e108fa44 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsAssignCorrectlyType.qml
+++ b/tests/auto/qml/qqmlecmascript/data/AliasBindingsAssignCorrectlyType.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType.qml b/tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType.qml
index 062772106b..062772106b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType.qml
+++ b/tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType3.qml b/tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType3.qml
index 823c0ef367..823c0ef367 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/AliasBindingsOverrideTargetType3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/AliasBindingsOverrideTargetType3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType1.qml b/tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType1.qml
index cef8ae09ea..cef8ae09ea 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType2.qml b/tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType2.qml
index 4a45535a50..4a45535a50 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/AliasToCompositeElementType2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ConstantsOverrideBindings.qml b/tests/auto/qml/qqmlecmascript/data/ConstantsOverrideBindings.qml
index 07bb16b0d8..07bb16b0d8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/ConstantsOverrideBindings.qml
+++ b/tests/auto/qml/qqmlecmascript/data/ConstantsOverrideBindings.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml b/tests/auto/qml/qqmlecmascript/data/CustomObject.qml
index aa1a1d6061..aa1a1d6061 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/CustomObject.qml
+++ b/tests/auto/qml/qqmlecmascript/data/CustomObject.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ElementAssignType.qml b/tests/auto/qml/qqmlecmascript/data/ElementAssignType.qml
index 4a45535a50..4a45535a50 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/ElementAssignType.qml
+++ b/tests/auto/qml/qqmlecmascript/data/ElementAssignType.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml b/tests/auto/qml/qqmlecmascript/data/MethodsObject.qml
index eaca0a7f92..eaca0a7f92 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/MethodsObject.qml
+++ b/tests/auto/qml/qqmlecmascript/data/MethodsObject.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml b/tests/auto/qml/qqmlecmascript/data/NestedTypeTransientErrors.qml
index 3b3e84a900..3b3e84a900 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/NestedTypeTransientErrors.qml
+++ b/tests/auto/qml/qqmlecmascript/data/NestedTypeTransientErrors.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarBaseItem.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarBaseItem.qml
index 5f28833fe7..5f28833fe7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarBaseItem.qml
+++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarBaseItem.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent.qml
index 36c025401f..36c025401f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent2.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent2.qml
index 6a49cb9317..6a49cb9317 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent3.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent3.qml
index a90725016e..a90725016e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent4.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent4.qml
index 9273a52f54..9273a52f54 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent5.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent5.qml
index 94ef338792..94ef338792 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarCircularComponent5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarCircularComponent5.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarInheritanceComponent.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarInheritanceComponent.qml
index b01cf6ed84..b01cf6ed84 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarInheritanceComponent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarInheritanceComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarOwnershipComponent.qml b/tests/auto/qml/qqmlecmascript/data/PropertyVarOwnershipComponent.qml
index c1f73d3bac..c1f73d3bac 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/PropertyVarOwnershipComponent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/PropertyVarOwnershipComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceSignalComponentVar.qml b/tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVar.qml
index d56bd41a99..d56bd41a99 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceSignalComponentVar.qml
+++ b/tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVar.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceSignalComponentVariant.qml b/tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVariant.qml
index e10fcfe36a..e10fcfe36a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceSignalComponentVariant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/ScarceResourceSignalComponentVariant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceVarComponent.qml b/tests/auto/qml/qqmlecmascript/data/ScarceResourceVarComponent.qml
index 2cf6b4223b..2cf6b4223b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/ScarceResourceVarComponent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/ScarceResourceVarComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/Scope6Nested.qml b/tests/auto/qml/qqmlecmascript/data/Scope6Nested.qml
index a3794df22b..a3794df22b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/Scope6Nested.qml
+++ b/tests/auto/qml/qqmlecmascript/data/Scope6Nested.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml b/tests/auto/qml/qqmlecmascript/data/ScopeObject.qml
index f341cce3c9..f341cce3c9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/ScopeObject.qml
+++ b/tests/auto/qml/qqmlecmascript/data/ScopeObject.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/SequenceConversionComponent.qml b/tests/auto/qml/qqmlecmascript/data/SequenceConversionComponent.qml
index 0c7f60b062..0c7f60b062 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/SequenceConversionComponent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/SequenceConversionComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/SpuriousWarning.qml b/tests/auto/qml/qqmlecmascript/data/SpuriousWarning.qml
index f6398d254d..f6398d254d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/SpuriousWarning.qml
+++ b/tests/auto/qml/qqmlecmascript/data/SpuriousWarning.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/TypeForDynamicCreation.qml b/tests/auto/qml/qqmlecmascript/data/TypeForDynamicCreation.qml
index 56e06252c4..56e06252c4 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/TypeForDynamicCreation.qml
+++ b/tests/auto/qml/qqmlecmascript/data/TypeForDynamicCreation.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsAssignCorrectly.qml b/tests/auto/qml/qqmlecmascript/data/aliasBindingsAssignCorrectly.qml
index ff6c553c31..ff6c553c31 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsAssignCorrectly.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasBindingsAssignCorrectly.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.2.qml b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.2.qml
index bba9033235..bba9033235 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.3.qml b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.3.qml
index 3e4cda6ba3..3e4cda6ba3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.qml b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.qml
index de5f49ffc5..de5f49ffc5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasBindingsOverrideTarget.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasBindingsOverrideTarget.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml b/tests/auto/qml/qqmlecmascript/data/aliasPropertyAndBinding.qml
index f228b2c19f..f228b2c19f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasPropertyAndBinding.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasPropertyAndBinding.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasToCompositeElement.qml b/tests/auto/qml/qqmlecmascript/data/aliasToCompositeElement.qml
index 79d6e6887c..79d6e6887c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasToCompositeElement.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasToCompositeElement.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.2.qml b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.2.qml
index b5bc280d11..b5bc280d11 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.3.qml b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.3.qml
index 6c16ff5604..6c16ff5604 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.qml b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.qml
index 441098bd39..441098bd39 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasWritesOverrideBindings.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasWritesOverrideBindings.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/AliasPropertyComponent.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/AliasPropertyComponent.qml
index 9135e79469..9135e79469 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/AliasPropertyComponent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/AliasPropertyComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.1.qml
index b855a183ee..b855a183ee 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.2.qml
index b0bb3681cf..b0bb3681cf 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.3.qml
index b318af0138..b318af0138 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.4.qml
index c5f56a8798..c5f56a8798 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.5.qml
index b07db8ba40..b07db8ba40 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.5.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.error.1.qml
index 35c9d6fd5d..35c9d6fd5d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/aliasreset/aliasPropertyReset.error.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml b/tests/auto/qml/qqmlecmascript/data/assignBasicTypes.2.qml
index 2c79729651..2c79729651 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignBasicTypes.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml b/tests/auto/qml/qqmlecmascript/data/assignBasicTypes.qml
index 86ff6b6bb3..86ff6b6bb3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignBasicTypes.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.1.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.1.qml
index be283fdda1..be283fdda1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.2.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.2.qml
index c8fb28b04e..c8fb28b04e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.3.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.3.qml
index ad8a92e317..ad8a92e317 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.4.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.4.qml
index a9f2e642d1..a9f2e642d1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.5.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.5.qml
index b8697e4290..b8697e4290 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.5.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.6.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.6.qml
index 7a794eb694..7a794eb694 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.6.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.6.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.7.qml b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.7.qml
index 96c0684939..96c0684939 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignSequenceTypes.7.qml
+++ b/tests/auto/qml/qqmlecmascript/data/assignSequenceTypes.7.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.2.qml b/tests/auto/qml/qqmlecmascript/data/attachedProperty.2.qml
index a7184c9200..a7184c9200 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/attachedProperty.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.qml b/tests/auto/qml/qqmlecmascript/data/attachedProperty.qml
index 061eda0e54..061eda0e54 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/attachedProperty.qml
+++ b/tests/auto/qml/qqmlecmascript/data/attachedProperty.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml b/tests/auto/qml/qqmlecmascript/data/attachedPropertyScope.qml
index 11fb7ccad2..11fb7ccad2 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/attachedPropertyScope.qml
+++ b/tests/auto/qml/qqmlecmascript/data/attachedPropertyScope.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/automaticSemicolon.qml b/tests/auto/qml/qqmlecmascript/data/automaticSemicolon.qml
index 6db68f2328..6db68f2328 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/automaticSemicolon.qml
+++ b/tests/auto/qml/qqmlecmascript/data/automaticSemicolon.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/bindingLoop.qml b/tests/auto/qml/qqmlecmascript/data/bindingLoop.qml
index 80545cf72b..80545cf72b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/bindingLoop.qml
+++ b/tests/auto/qml/qqmlecmascript/data/bindingLoop.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/blank.js b/tests/auto/qml/qqmlecmascript/data/blank.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/blank.js
+++ b/tests/auto/qml/qqmlecmascript/data/blank.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.1.qml b/tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.1.qml
index 3147f63989..3147f63989 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.2.qml b/tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.2.qml
index c89bb49b45..c89bb49b45 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/boolPropertiesEvaluateAsBool.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/boolPropertiesEvaluateAsBool.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/booleanConversion.qml b/tests/auto/qml/qqmlecmascript/data/booleanConversion.qml
index a363cf4dd1..a363cf4dd1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/booleanConversion.qml
+++ b/tests/auto/qml/qqmlecmascript/data/booleanConversion.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml b/tests/auto/qml/qqmlecmascript/data/bug.1.qml
index 31f7c44fcc..31f7c44fcc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/bug.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/bug.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml b/tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.1.qml
index 3fd9131b2f..3fd9131b2f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml b/tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.2.qml
index 3fbf931fca..3fbf931fca 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/canAssignNullToQObject.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/canAssignNullToQObject.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.1.qml b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.1.qml
index 1e92aca825..1e92aca825 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.2.qml b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.2.qml
index 3549d8c556..3549d8c556 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.3.qml b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.3.qml
index d611e0fe30..d611e0fe30 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.4.qml b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.4.qml
index a6862517c6..a6862517c6 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlotErrors.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlotErrors.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlots.qml b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlots.qml
index f91fb71f1f..f91fb71f1f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/changeslots/propertyChangeSlots.qml
+++ b/tests/auto/qml/qqmlecmascript/data/changeslots/propertyChangeSlots.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml b/tests/auto/qml/qqmlecmascript/data/compiled.qml
index 7c46306772..7c46306772 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/compiled.qml
+++ b/tests/auto/qml/qqmlecmascript/data/compiled.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml b/tests/auto/qml/qqmlecmascript/data/compositePropertyType.qml
index e97b75c8d0..e97b75c8d0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/compositePropertyType.qml
+++ b/tests/auto/qml/qqmlecmascript/data/compositePropertyType.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.1.qml b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.1.qml
index 13c5ae5fff..13c5ae5fff 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.2.qml b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.2.qml
index 207a06b700..207a06b700 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.3.qml b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.3.qml
index ca9d1d8ab9..ca9d1d8ab9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.4.qml b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.4.qml
index 5a2091f71c..5a2091f71c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/constantsOverrideBindings.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/constantsOverrideBindings.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deferredProperties.qml b/tests/auto/qml/qqmlecmascript/data/deferredProperties.qml
index e01f708a07..e01f708a07 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/deferredProperties.qml
+++ b/tests/auto/qml/qqmlecmascript/data/deferredProperties.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml b/tests/auto/qml/qqmlecmascript/data/deferredPropertiesErrors.qml
index 308a01ce6f..308a01ce6f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml
+++ b/tests/auto/qml/qqmlecmascript/data/deferredPropertiesErrors.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deleteLater.qml b/tests/auto/qml/qqmlecmascript/data/deleteLater.qml
index 2a9ce44b20..2a9ce44b20 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/deleteLater.qml
+++ b/tests/auto/qml/qqmlecmascript/data/deleteLater.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deleteWhileBindingRunning.qml b/tests/auto/qml/qqmlecmascript/data/deleteWhileBindingRunning.qml
index b5cc59e2c0..b5cc59e2c0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/deleteWhileBindingRunning.qml
+++ b/tests/auto/qml/qqmlecmascript/data/deleteWhileBindingRunning.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml b/tests/auto/qml/qqmlecmascript/data/deletedEngine.qml
index 97acddf5fc..97acddf5fc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml
+++ b/tests/auto/qml/qqmlecmascript/data/deletedEngine.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml b/tests/auto/qml/qqmlecmascript/data/deletedObject.qml
index 24c12bf694..24c12bf694 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/deletedObject.qml
+++ b/tests/auto/qml/qqmlecmascript/data/deletedObject.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/doubleEvaluate.qml b/tests/auto/qml/qqmlecmascript/data/doubleEvaluate.qml
index 0532715432..0532715432 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/doubleEvaluate.qml
+++ b/tests/auto/qml/qqmlecmascript/data/doubleEvaluate.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.helper.qml b/tests/auto/qml/qqmlecmascript/data/dynamicCreation.helper.qml
index d790d634e9..d790d634e9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.helper.qml
+++ b/tests/auto/qml/qqmlecmascript/data/dynamicCreation.helper.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml b/tests/auto/qml/qqmlecmascript/data/dynamicCreation.qml
index 7b132e1edf..7b132e1edf 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreation.qml
+++ b/tests/auto/qml/qqmlecmascript/data/dynamicCreation.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreationOwnership.qml b/tests/auto/qml/qqmlecmascript/data/dynamicCreationOwnership.qml
index ed396d49b0..ed396d49b0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicCreationOwnership.qml
+++ b/tests/auto/qml/qqmlecmascript/data/dynamicCreationOwnership.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.2.qml b/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.2.qml
index 9a5732c194..9a5732c194 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.qml b/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.qml
index f41e5262fd..f41e5262fd 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.qml
+++ b/tests/auto/qml/qqmlecmascript/data/dynamicDeletion.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicString.qml b/tests/auto/qml/qqmlecmascript/data/dynamicString.qml
index 5693794c71..5693794c71 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicString.qml
+++ b/tests/auto/qml/qqmlecmascript/data/dynamicString.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/elementAssign.qml b/tests/auto/qml/qqmlecmascript/data/elementAssign.qml
index 0d75cbf6fc..0d75cbf6fc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/elementAssign.qml
+++ b/tests/auto/qml/qqmlecmascript/data/elementAssign.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/enums.1.qml b/tests/auto/qml/qqmlecmascript/data/enums.1.qml
index 6351823230..6351823230 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/enums.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/enums.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/enums.2.qml b/tests/auto/qml/qqmlecmascript/data/enums.2.qml
index bdc672fadc..bdc672fadc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/enums.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/enums.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml b/tests/auto/qml/qqmlecmascript/data/eval.qml
index a752b8c0d3..a752b8c0d3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml
+++ b/tests/auto/qml/qqmlecmascript/data/eval.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/exception.js b/tests/auto/qml/qqmlecmascript/data/exception.js
index 160bbfa5b6..160bbfa5b6 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/exception.js
+++ b/tests/auto/qml/qqmlecmascript/data/exception.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/exceptionClearsOnReeval.qml b/tests/auto/qml/qqmlecmascript/data/exceptionClearsOnReeval.qml
index a2f0d1a8b7..a2f0d1a8b7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/exceptionClearsOnReeval.qml
+++ b/tests/auto/qml/qqmlecmascript/data/exceptionClearsOnReeval.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml b/tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning.qml
index b8d5e5e60f..b8d5e5e60f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning.qml
+++ b/tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml b/tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning2.qml
index a4ce55e245..a4ce55e245 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/exceptionProducesWarning2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/exceptionProducesWarning2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml b/tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup.qml
index 2c382e871a..2c382e871a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup.qml
+++ b/tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup2.qml b/tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup2.qml
index e4af3359d0..e4af3359d0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/extendedObjectPropertyLookup2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/extendedObjectPropertyLookup2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml b/tests/auto/qml/qqmlecmascript/data/extensionObjects.qml
index 7734a11dd8..7734a11dd8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjects.qml
+++ b/tests/auto/qml/qqmlecmascript/data/extensionObjects.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjectsPropertyOverride.qml b/tests/auto/qml/qqmlecmascript/data/extensionObjectsPropertyOverride.qml
index 3c443cb975..3c443cb975 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/extensionObjectsPropertyOverride.qml
+++ b/tests/auto/qml/qqmlecmascript/data/extensionObjectsPropertyOverride.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/forInLoop.qml b/tests/auto/qml/qqmlecmascript/data/forInLoop.qml
index f14367f177..f14367f177 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/forInLoop.qml
+++ b/tests/auto/qml/qqmlecmascript/data/forInLoop.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml b/tests/auto/qml/qqmlecmascript/data/function.qml
index af2da7023c..af2da7023c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml
+++ b/tests/auto/qml/qqmlecmascript/data/function.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.1.qml b/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml
index 09540f1f6e..09540f1f6e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/functionAssignment.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml b/tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml
index 0f78eaf1dc..0f78eaf1dc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/functionAssignment.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.js b/tests/auto/qml/qqmlecmascript/data/functionAssignment.js
index 14daa7629f..14daa7629f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/functionAssignment.js
+++ b/tests/auto/qml/qqmlecmascript/data/functionAssignment.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml b/tests/auto/qml/qqmlecmascript/data/functionErrors.qml
index 230a626600..230a626600 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/functionErrors.qml
+++ b/tests/auto/qml/qqmlecmascript/data/functionErrors.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.handle.1.qml b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.1.qml
index 8a06c30d8c..8a06c30d8c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.handle.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.handle.2.qml b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.2.qml
index 91edc447e2..91edc447e2 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.handle.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.handle.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.object.1.qml b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.1.qml
index 70e8390677..70e8390677 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.object.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.object.2.qml b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.2.qml
index 2ddb9253eb..2ddb9253eb 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/handleReferenceManagement.object.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/handleReferenceManagement.object.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml b/tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.1.qml
index ece23269f1..ece23269f1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml b/tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.qml
index 650ed7c73e..650ed7c73e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/idShortcutInvalidates.qml
+++ b/tests/auto/qml/qqmlecmascript/data/idShortcutInvalidates.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.1.js b/tests/auto/qml/qqmlecmascript/data/importScope.1.js
index 4c556f9e96..4c556f9e96 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.1.js
+++ b/tests/auto/qml/qqmlecmascript/data/importScope.1.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.2.js b/tests/auto/qml/qqmlecmascript/data/importScope.2.js
index 291fb9d2cc..291fb9d2cc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.2.js
+++ b/tests/auto/qml/qqmlecmascript/data/importScope.2.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml b/tests/auto/qml/qqmlecmascript/data/importScope.qml
index 9b907f11f9..9b907f11f9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml
+++ b/tests/auto/qml/qqmlecmascript/data/importScope.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/in.qml b/tests/auto/qml/qqmlecmascript/data/in.qml
index f84c9a1481..f84c9a1481 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/in.qml
+++ b/tests/auto/qml/qqmlecmascript/data/in.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include.js b/tests/auto/qml/qqmlecmascript/data/include.js
index 232fd808f8..232fd808f8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include.js
+++ b/tests/auto/qml/qqmlecmascript/data/include.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include.qml b/tests/auto/qml/qqmlecmascript/data/include.qml
index 5ce2ed78ec..5ce2ed78ec 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include.qml
+++ b/tests/auto/qml/qqmlecmascript/data/include.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js b/tests/auto/qml/qqmlecmascript/data/include_callback.js
index ea19eba300..ea19eba300 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.js
+++ b/tests/auto/qml/qqmlecmascript/data/include_callback.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml b/tests/auto/qml/qqmlecmascript/data/include_callback.qml
index fbebcdcd58..fbebcdcd58 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_callback.qml
+++ b/tests/auto/qml/qqmlecmascript/data/include_callback.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml b/tests/auto/qml/qqmlecmascript/data/include_pragma.qml
index 7b23c76baa..7b23c76baa 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml
+++ b/tests/auto/qml/qqmlecmascript/data/include_pragma.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_inner.js b/tests/auto/qml/qqmlecmascript/data/include_pragma_inner.js
index a0380a25df..a0380a25df 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_inner.js
+++ b/tests/auto/qml/qqmlecmascript/data/include_pragma_inner.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_outer.js b/tests/auto/qml/qqmlecmascript/data/include_pragma_outer.js
index d87bafc816..d87bafc816 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_outer.js
+++ b/tests/auto/qml/qqmlecmascript/data/include_pragma_outer.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js b/tests/auto/qml/qqmlecmascript/data/include_remote.js
index e6a4676819..e6a4676819 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.js
+++ b/tests/auto/qml/qqmlecmascript/data/include_remote.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml b/tests/auto/qml/qqmlecmascript/data/include_remote.qml
index fe020a55df..fe020a55df 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote.qml
+++ b/tests/auto/qml/qqmlecmascript/data/include_remote.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js b/tests/auto/qml/qqmlecmascript/data/include_remote_missing.js
index cc90860cc9..cc90860cc9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.js
+++ b/tests/auto/qml/qqmlecmascript/data/include_remote_missing.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml b/tests/auto/qml/qqmlecmascript/data/include_remote_missing.qml
index e8ef609fed..e8ef609fed 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_remote_missing.qml
+++ b/tests/auto/qml/qqmlecmascript/data/include_remote_missing.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js b/tests/auto/qml/qqmlecmascript/data/include_shared.js
index a49c07bbfc..a49c07bbfc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.js
+++ b/tests/auto/qml/qqmlecmascript/data/include_shared.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml b/tests/auto/qml/qqmlecmascript/data/include_shared.qml
index 28b1003fd4..28b1003fd4 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/include_shared.qml
+++ b/tests/auto/qml/qqmlecmascript/data/include_shared.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectArg.qml b/tests/auto/qml/qqmlecmascript/data/invokableObjectArg.qml
index 160a90b574..160a90b574 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectArg.qml
+++ b/tests/auto/qml/qqmlecmascript/data/invokableObjectArg.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectRet.qml b/tests/auto/qml/qqmlecmascript/data/invokableObjectRet.qml
index 4612273727..4612273727 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/invokableObjectRet.qml
+++ b/tests/auto/qml/qqmlecmascript/data/invokableObjectRet.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js b/tests/auto/qml/qqmlecmascript/data/js/include2.js
index 2a0c039dfa..2a0c039dfa 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/js/include2.js
+++ b/tests/auto/qml/qqmlecmascript/data/js/include2.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js b/tests/auto/qml/qqmlecmascript/data/js/include3.js
index 84b2770b6f..84b2770b6f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/js/include3.js
+++ b/tests/auto/qml/qqmlecmascript/data/js/include3.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml b/tests/auto/qml/qqmlecmascript/data/jsObject.qml
index 4223c25f31..4223c25f31 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsObject.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsObject.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleOne.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleOne.qml
index 97c72bd9a6..97c72bd9a6 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleOne.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleOne.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleTwo.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleTwo.qml
index d006343782..d006343782 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/SpecialRectangleTwo.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/SpecialRectangleTwo.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importFive.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importFive.js
index e458094552..e458094552 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importFive.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importFive.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importFour.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importFour.js
index faddc15c9d..faddc15c9d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importFour.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importFour.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importOne.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importOne.js
index 338c4e042f..338c4e042f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importOne.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importOne.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibrary.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibrary.js
index c746fef14b..c746fef14b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibrary.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibrary.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithImports.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithImports.js
index 3f2e6589dd..3f2e6589dd 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithImports.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithImports.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js
index fa6497d99b..fa6497d99b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importThree.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importThree.js
index 3917134ee2..3917134ee2 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importThree.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importThree.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importTwo.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importTwo.js
index 45b3c9a74d..45b3c9a74d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importTwo.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importTwo.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importWithNoImports.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importWithNoImports.js
index 83426c425c..83426c425c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importWithNoImports.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importWithNoImports.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImport.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImport.qml
index 456a10c7f0..456a10c7f0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImport.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImport.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibrary.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibrary.qml
index 29de15c197..29de15c197 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibrary.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibrary.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml
index 6a7459d3bb..6a7459d3bb 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml
index 01f08dbdc3..01f08dbdc3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportScoping.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportScoping.qml
index aff61cc436..aff61cc436 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportScoping.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportScoping.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testModuleImport.js b/tests/auto/qml/qqmlecmascript/data/jsimport/testModuleImport.js
index 69bc1c9887..69bc1c9887 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testModuleImport.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testModuleImport.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testScriptImport.js b/tests/auto/qml/qqmlecmascript/data/jsimport/testScriptImport.js
index 2ecccd8816..2ecccd8816 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testScriptImport.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testScriptImport.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFive.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFive.qml
index 73193a35a5..73193a35a5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFive.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFive.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFour.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFour.qml
index ef2fc591b3..ef2fc591b3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failFour.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failFour.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failOne.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failOne.qml
index d0c37ad9ba..d0c37ad9ba 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failOne.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failOne.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failThree.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failThree.qml
index edd103bd82..edd103bd82 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failThree.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failThree.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failTwo.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failTwo.qml
index 28e2026f8d..28e2026f8d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/failTwo.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/failTwo.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importOne.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importOne.js
index 45fd9c75dd..45fd9c75dd 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importOne.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importOne.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importPragmaLibrary.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importPragmaLibrary.js
index ad0e6946a2..ad0e6946a2 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importPragmaLibrary.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importPragmaLibrary.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importWithImports.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importWithImports.js
index 6d77ceccb1..6d77ceccb1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/importWithImports.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/importWithImports.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testImportPragmaLibrary.qml b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testImportPragmaLibrary.qml
index f04ce007d8..f04ce007d8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testImportPragmaLibrary.qml
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testImportPragmaLibrary.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testModuleImport.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testModuleImport.js
index 69bc1c9887..69bc1c9887 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testModuleImport.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testModuleImport.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testScriptImport.js b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testScriptImport.js
index 2ecccd8816..2ecccd8816 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/jsimportfail/testScriptImport.js
+++ b/tests/auto/qml/qqmlecmascript/data/jsimportfail/testScriptImport.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js b/tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.js
index 3ffdb339ad..3ffdb339ad 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.js
+++ b/tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.qml b/tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.qml
index 5884e2719b..5884e2719b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/libraryScriptAssert.qml
+++ b/tests/auto/qml/qqmlecmascript/data/libraryScriptAssert.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/listAssignment.qml b/tests/auto/qml/qqmlecmascript/data/listAssignment.qml
index 6e6039715b..6e6039715b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/listAssignment.qml
+++ b/tests/auto/qml/qqmlecmascript/data/listAssignment.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml b/tests/auto/qml/qqmlecmascript/data/listProperties.qml
index bdb1265a21..bdb1265a21 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/listProperties.qml
+++ b/tests/auto/qml/qqmlecmascript/data/listProperties.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml b/tests/auto/qml/qqmlecmascript/data/listToVariant.qml
index 690024b928..690024b928 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/listToVariant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/listToVariant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision.qml
index 77accd80de..77accd80de 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision.qml
+++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision2.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision2.qml
index 36057cb902..36057cb902 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision3.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision3.qml
index 81769e98f7..81769e98f7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision4.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision4.qml
index 6ebe4790bb..6ebe4790bb 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevision4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevision4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors.qml
index 8a7e24d788..8a7e24d788 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors.qml
+++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors2.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors2.qml
index 43e87948cd..43e87948cd 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors3.qml b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors3.qml
index 2f82d685fa..2f82d685fa 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/metaobjectRevisionErrors3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/metaobjectRevisionErrors3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/methods.1.qml b/tests/auto/qml/qqmlecmascript/data/methods.1.qml
index 0bbee16df8..0bbee16df8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/methods.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/methods.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/methods.2.qml b/tests/auto/qml/qqmlecmascript/data/methods.2.qml
index 9f0c6b15fe..9f0c6b15fe 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/methods.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/methods.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml b/tests/auto/qml/qqmlecmascript/data/methods.3.qml
index 365780a560..365780a560 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/methods.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/methods.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml b/tests/auto/qml/qqmlecmascript/data/methods.4.qml
index a3bd7bebf8..a3bd7bebf8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/methods.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/methods.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml b/tests/auto/qml/qqmlecmascript/data/methods.5.qml
index ede2759e2e..ede2759e2e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/methods.5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/methods.5.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/moduleApiMajorVersionFail.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMajorVersionFail.qml
index fb050f65bc..fb050f65bc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/moduleApiMajorVersionFail.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMajorVersionFail.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/moduleApiMinorVersionFail.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMinorVersionFail.qml
index e06be667f7..e06be667f7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/moduleApiMinorVersionFail.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/moduleApiMinorVersionFail.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApi.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApi.qml
index 718a64652d..718a64652d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApi.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApi.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiCaching.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiCaching.qml
index 56a55e4e9b..56a55e4e9b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiCaching.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiCaching.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiEnums.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiEnums.qml
index da5ffd5e76..da5ffd5e76 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiEnums.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiEnums.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiWriting.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml
index be647ca57f..be647ca57f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/qobjectModuleApiWriting.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/qobjectModuleApiWriting.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApi.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApi.qml
index 7c4e20489d..7c4e20489d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApi.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApi.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApiCaching.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiCaching.qml
index 90974b5969..90974b5969 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApiCaching.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiCaching.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApiWriting.qml b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiWriting.qml
index 02461d59ed..02461d59ed 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/moduleapi/scriptModuleApiWriting.qml
+++ b/tests/auto/qml/qqmlecmascript/data/moduleapi/scriptModuleApiWriting.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml b/tests/auto/qml/qqmlecmascript/data/multiEngineObject.qml
index e349ced98f..e349ced98f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/multiEngineObject.qml
+++ b/tests/auto/qml/qqmlecmascript/data/multiEngineObject.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.2.qml b/tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.2.qml
index 23276f778d..23276f778d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.qml b/tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.qml
index b4a417e04e..b4a417e04e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/noSpuriousWarningsAtShutdown.qml
+++ b/tests/auto/qml/qqmlecmascript/data/noSpuriousWarningsAtShutdown.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/nonExistentAttachedObject.qml b/tests/auto/qml/qqmlecmascript/data/nonExistentAttachedObject.qml
index f9585db009..f9585db009 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/nonExistentAttachedObject.qml
+++ b/tests/auto/qml/qqmlecmascript/data/nonExistentAttachedObject.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/nonNotifyable.qml b/tests/auto/qml/qqmlecmascript/data/nonNotifyable.qml
index 2b8b113c34..2b8b113c34 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/nonNotifyable.qml
+++ b/tests/auto/qml/qqmlecmascript/data/nonNotifyable.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/nonscriptable.qml b/tests/auto/qml/qqmlecmascript/data/nonscriptable.qml
index e96df6b40e..e96df6b40e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/nonscriptable.qml
+++ b/tests/auto/qml/qqmlecmascript/data/nonscriptable.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml b/tests/auto/qml/qqmlecmascript/data/nullObjectBinding.qml
index 1aee7a1670..1aee7a1670 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml
+++ b/tests/auto/qml/qqmlecmascript/data/nullObjectBinding.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml b/tests/auto/qml/qqmlecmascript/data/numberAssignment.qml
index 30a77e8aed..30a77e8aed 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml
+++ b/tests/auto/qml/qqmlecmascript/data/numberAssignment.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/objectConversion.qml b/tests/auto/qml/qqmlecmascript/data/objectConversion.qml
index 67fc342db3..67fc342db3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/objectConversion.qml
+++ b/tests/auto/qml/qqmlecmascript/data/objectConversion.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/objectName.qml b/tests/auto/qml/qqmlecmascript/data/objectName.qml
index 20b9ec2935..20b9ec2935 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/objectName.qml
+++ b/tests/auto/qml/qqmlecmascript/data/objectName.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml b/tests/auto/qml/qqmlecmascript/data/objectsCompareAsEqual.qml
index 845f74b1aa..845f74b1aa 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/objectsCompareAsEqual.qml
+++ b/tests/auto/qml/qqmlecmascript/data/objectsCompareAsEqual.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/objectsPassThroughSignals.qml b/tests/auto/qml/qqmlecmascript/data/objectsPassThroughSignals.qml
index 98f9e05bdf..98f9e05bdf 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/objectsPassThroughSignals.qml
+++ b/tests/auto/qml/qqmlecmascript/data/objectsPassThroughSignals.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/outerBindingOverridesInnerBinding.qml b/tests/auto/qml/qqmlecmascript/data/outerBindingOverridesInnerBinding.qml
index 090c948f26..090c948f26 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/outerBindingOverridesInnerBinding.qml
+++ b/tests/auto/qml/qqmlecmascript/data/outerBindingOverridesInnerBinding.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml b/tests/auto/qml/qqmlecmascript/data/ownership.qml
index 855a264995..855a264995 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/ownership.qml
+++ b/tests/auto/qml/qqmlecmascript/data/ownership.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml b/tests/auto/qml/qqmlecmascript/data/propertyAssignmentErrors.qml
index 34523ec1c7..34523ec1c7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyAssignmentErrors.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyAssignmentErrors.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertySplicing.qml b/tests/auto/qml/qqmlecmascript/data/propertySplicing.qml
index 53711db3f4..53711db3f4 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertySplicing.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertySplicing.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.1.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.1.qml
index 219e61bf91..219e61bf91 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.10.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.10.qml
index ac7f2bed57..ac7f2bed57 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.10.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.10.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.2.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.2.qml
index 2ac4807ec5..2ac4807ec5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.3.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.3.qml
index cf6a651639..cf6a651639 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.4.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.4.qml
index 82fc225e71..82fc225e71 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.5.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.5.qml
index a5c7812289..a5c7812289 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.5.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.6.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.6.qml
index 060d24e7bc..060d24e7bc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.6.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.6.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.7.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.7.qml
index 1d6c8c0a37..1d6c8c0a37 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.7.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.7.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.8.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.8.qml
index a9f73db402..a9f73db402 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.8.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.8.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.9.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.9.qml
index f5aca28417..f5aca28417 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.9.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.9.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.circular.2.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.2.qml
index 93c44afcc9..93c44afcc9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.circular.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.circular.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.qml
index 171d7747cd..171d7747cd 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.circular.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.circular.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.inherit.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.inherit.qml
index abd0dd7c04..abd0dd7c04 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.inherit.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.inherit.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.reparent.qml b/tests/auto/qml/qqmlecmascript/data/propertyVar.reparent.qml
index 7b3df674f1..7b3df674f1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVar.reparent.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVar.reparent.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarCpp.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarCpp.qml
index cd3147f565..cd3147f565 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarCpp.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarCpp.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarImplicitOwnership.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarImplicitOwnership.qml
index 9cebded932..9cebded932 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarImplicitOwnership.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarImplicitOwnership.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.2.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.2.qml
index 14d4f9fd27..14d4f9fd27 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.3.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.qml
index d5b449c938..d5b449c938 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.3.type.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.type.qml
index 3406553b91..3406553b91 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.3.type.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.3.type.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.qml
index 1eba36ce81..1eba36ce81 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.type1.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type1.qml
index 9a29b6e17f..9a29b6e17f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.type1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.type2.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type2.qml
index f82b8a1c1e..f82b8a1c1e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.4.type2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.4.type2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.qml b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.qml
index 7b99c4b6ad..7b99c4b6ad 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/propertyVarOwnership.qml
+++ b/tests/auto/qml/qqmlecmascript/data/propertyVarOwnership.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml b/tests/auto/qml/qqmlecmascript/data/qlistqobjectMethods.qml
index 3c1986d721..3c1986d721 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qlistqobjectMethods.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qlistqobjectMethods.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml b/tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml
index 12598b3b9f..12598b3b9f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/declarativeHasOwnProperty.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qmlHasOwnProperty.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/declarativeToString.qml b/tests/auto/qml/qqmlecmascript/data/qmlToString.qml
index ac296ce293..ac296ce293 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/declarativeToString.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qmlToString.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qobjectConnectionListExceptionHandling.qml b/tests/auto/qml/qqmlecmascript/data/qobjectConnectionListExceptionHandling.qml
index acd512a2be..acd512a2be 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qobjectConnectionListExceptionHandling.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qobjectConnectionListExceptionHandling.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qobjectDerivedArgument.qml b/tests/auto/qml/qqmlecmascript/data/qobjectDerivedArgument.qml
index bf4ab6fd7a..bf4ab6fd7a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qobjectDerivedArgument.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qobjectDerivedArgument.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_10696.qml
index 90263e5124..90263e5124 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_10696.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_10696.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.js b/tests/auto/qml/qqmlecmascript/data/qtbug_11600.js
index 092bc2b041..092bc2b041 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.js
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_11600.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_11600.qml
index 6c7e8806e6..6c7e8806e6 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_11600.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_11606.qml
index b1b062ed35..b1b062ed35 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_11606.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_20344.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_20344.qml
index f490848caf..f490848caf 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_20344.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_20344.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21580.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_21580.qml
index dc0066ba3f..dc0066ba3f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21580.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_21580.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.js b/tests/auto/qml/qqmlecmascript/data/qtbug_21864.js
index e1a688ebbe..e1a688ebbe 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.js
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_21864.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_21864.qml
index 0f972d5459..0f972d5459 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_21864.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22464.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_22464.qml
index 19f26736f1..19f26736f1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22464.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22464.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22679.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_22679.qml
index b38a84b4c0..b38a84b4c0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22679.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22679.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.js b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.js
index 6d19fe0571..6d19fe0571 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.js
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.js b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.js
index 1a7c8a2e6e..1a7c8a2e6e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.js
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.qml
index 281765bff6..281765bff6 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.library.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.library.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.qml
index 90a47c0f4b..90a47c0f4b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_22843.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_22843.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_9792.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_9792.qml
index 9ac44308c6..9ac44308c6 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_9792.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtbug_9792.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml b/tests/auto/qml/qqmlecmascript/data/qtcreatorbug_1289.qml
index 90711c8d09..90711c8d09 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/qtcreatorbug_1289.qml
+++ b/tests/auto/qml/qqmlecmascript/data/qtcreatorbug_1289.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/readonlyDeclaration.qml b/tests/auto/qml/qqmlecmascript/data/readonlyDeclaration.qml
index 5377d2dcbf..5377d2dcbf 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/readonlyDeclaration.qml
+++ b/tests/auto/qml/qqmlecmascript/data/readonlyDeclaration.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/realToInt.qml b/tests/auto/qml/qqmlecmascript/data/realToInt.qml
index a9e7dd2a95..a9e7dd2a95 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/realToInt.qml
+++ b/tests/auto/qml/qqmlecmascript/data/realToInt.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/regExp.2.qml b/tests/auto/qml/qqmlecmascript/data/regExp.2.qml
index 68cca5733b..68cca5733b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/regExp.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/regExp.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/regExp.qml b/tests/auto/qml/qqmlecmascript/data/regExp.qml
index 0dc404b5db..0dc404b5db 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/regExp.qml
+++ b/tests/auto/qml/qqmlecmascript/data/regExp.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js b/tests/auto/qml/qqmlecmascript/data/remote_file.js
index 1b123aee61..1b123aee61 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/remote_file.js
+++ b/tests/auto/qml/qqmlecmascript/data/remote_file.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings.qml b/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings.qml
index 1ae1b162b2..1ae1b162b2 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/rewriteMultiLineStrings.qml
+++ b/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopy.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.var.qml
index 805655fc17..805655fc17 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopy.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopy.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.variant.qml
index ee5b05b28a..ee5b05b28a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopy.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopy.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyFromJs.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.var.qml
index 09868e5e7c..09868e5e7c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyFromJs.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyFromJs.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.variant.qml
index a1ebeb4073..a1ebeb4073 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyFromJs.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyFromJs.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.js
index 468a6b4f2e..468a6b4f2e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.var.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.qml
index 9321481f45..9321481f45 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.variant.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.js
index 9aeb507487..9aeb507487 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.variant.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.qml
index e8b53979dd..e8b53979dd 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImport.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImport.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportDifferent.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.js
index 000eeddb34..000eeddb34 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportDifferent.var.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportDifferent.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.qml
index 082d132c24..082d132c24 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportDifferent.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportDifferent.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.js
index ba52b323f0..ba52b323f0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.var.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.qml
index a1a3c1d66f..a1a3c1d66f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.variant.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.js
index b59b5b1fa9..b59b5b1fa9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.variant.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.qml
index 8f6dcd6603..8f6dcd6603 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportFail.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportFail.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.js
index 130199f78a..130199f78a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.var.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.qml
index 5284b40cc8..5284b40cc8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.variant.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.js
index 14a36a19ea..14a36a19ea 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.variant.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.qml
index 826cbe49fc..826cbe49fc 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyImportNoBinding.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyImportNoBinding.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyNoBinding.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.var.qml
index 4adef39980..4adef39980 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyNoBinding.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyNoBinding.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.variant.qml
index 4adef39980..4adef39980 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceCopyNoBinding.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceCopyNoBinding.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceDestroyedCopy.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.var.qml
index 500f5d5bd7..500f5d5bd7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceDestroyedCopy.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceDestroyedCopy.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.variant.qml
index 7a3b845247..7a3b845247 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceDestroyedCopy.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceDestroyedCopy.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunction.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.var.qml
index 23e4c8d15e..23e4c8d15e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunction.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunction.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.variant.qml
index fe3707b5d3..fe3707b5d3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceFunction.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunction.variant.qml
diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.var.qml
new file mode 100644
index 0000000000..9b4b1e6fd9
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.var.qml
@@ -0,0 +1,23 @@
+import QtQuick 2.0
+import Qt.test 1.0
+
+// In this example, a common syntax error will only be "caught"
+// when the function is called via:
+// QQmlVMEMetaObject::metaCall->invokeMetaMethod()
+// We would like to ensure that a useful error message is printed.
+
+QtObject {
+ id: root
+ property MyScarceResourceObject a: MyScarceResourceObject { id: scarceResourceProvider }
+ property var scarceResourceCopy;
+ property string srp_name: a.toString();
+
+ function retrieveScarceResource() {
+ root.scarceResourceCopy = scarceResourceProvider.scarceResource(); // common syntax error, should throw exception
+ }
+
+ function releaseScarceResource() {
+ root.scarceResourceCopy = null;
+ }
+}
+
diff --git a/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.variant.qml
new file mode 100644
index 0000000000..57673de3f3
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceFunctionFail.variant.qml
@@ -0,0 +1,23 @@
+import QtQuick 2.0
+import Qt.test 1.0
+
+// In this example, a common syntax error will only be "caught"
+// when the function is called via:
+// QQmlVMEMetaObject::metaCall->invokeMetaMethod()
+// We would like to ensure that a useful error message is printed.
+
+QtObject {
+ id: root
+ property MyScarceResourceObject a: MyScarceResourceObject { id: scarceResourceProvider }
+ property variant scarceResourceCopy;
+ property string srp_name: a.toString();
+
+ function retrieveScarceResource() {
+ root.scarceResourceCopy = scarceResourceProvider.scarceResource(); // common syntax error, should throw exception
+ }
+
+ function releaseScarceResource() {
+ root.scarceResourceCopy = null;
+ }
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js
index 217f693456..217f693456 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml
index 205131661f..205131661f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleDifferentNoBinding.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameNoBinding.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.js
index 5b2494c8e6..5b2494c8e6 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameNoBinding.var.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameNoBinding.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.qml
index e7f6d7868f..e7f6d7868f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameNoBinding.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameNoBinding.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameWithBinding.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameWithBinding.var.qml
index 34cb97f39c..34cb97f39c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceMultipleSameWithBinding.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceMultipleSameWithBinding.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceObjectGc.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceObjectGc.var.qml
index 7ec98e6619..7ec98e6619 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceObjectGc.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceObjectGc.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceSignal.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.var.qml
index 0b30e88fa8..0b30e88fa8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceSignal.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceSignal.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.variant.qml
index 1011c7e240..1011c7e240 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceSignal.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceSignal.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.var.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.js
index c904eb3564..c904eb3564 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.var.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.qml
index 1d4e67055e..1d4e67055e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.variant.js b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.js
index c904eb3564..c904eb3564 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.variant.js
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.qml
index 1d4e67055e..1d4e67055e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTest.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTest.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestMultiple.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.var.qml
index 5e6c2d97f9..5e6c2d97f9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestMultiple.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestMultiple.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.variant.qml
index 2970bcb26c..2970bcb26c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestMultiple.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestMultiple.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestPreserve.var.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.var.qml
index 9e9495c0fa..9e9495c0fa 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestPreserve.var.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.var.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestPreserve.variant.qml b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.variant.qml
index 022067beca..022067beca 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scarceResourceTestPreserve.variant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scarceResourceTestPreserve.variant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml b/tests/auto/qml/qqmlecmascript/data/scope.2.qml
index fe1c4c7931..fe1c4c7931 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scope.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml b/tests/auto/qml/qqmlecmascript/data/scope.3.qml
index 9add81809c..9add81809c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scope.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml b/tests/auto/qml/qqmlecmascript/data/scope.4.qml
index d65b6e7c7c..d65b6e7c7c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scope.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.5.qml b/tests/auto/qml/qqmlecmascript/data/scope.5.qml
index 6dbcbe2a40..6dbcbe2a40 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scope.5.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.6.qml b/tests/auto/qml/qqmlecmascript/data/scope.6.qml
index 5897b533d7..5897b533d7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.6.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scope.6.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.qml b/tests/auto/qml/qqmlecmascript/data/scope.qml
index a00352b684..a00352b684 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scope.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.js b/tests/auto/qml/qqmlecmascript/data/scriptConnect.1.js
index 54284fea47..54284fea47 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.js
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.1.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.1.qml
index ace473756e..ace473756e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.js b/tests/auto/qml/qqmlecmascript/data/scriptConnect.2.js
index 595c778aa7..595c778aa7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.js
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.2.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.2.qml
index cdf2d6ad98..cdf2d6ad98 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.3.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.3.qml
index b0e40565c0..b0e40565c0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.4.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.4.qml
index ef5331c94a..ef5331c94a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.5.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.5.qml
index 8dcacbcbb7..8dcacbcbb7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.5.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.js b/tests/auto/qml/qqmlecmascript/data/scriptConnect.6.js
index 71bdd088a2..71bdd088a2 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.js
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.6.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.qml b/tests/auto/qml/qqmlecmascript/data/scriptConnect.6.qml
index 06b6f0fa62..06b6f0fa62 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptConnect.6.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptConnect.6.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.js b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.js
index 407426fcd1..407426fcd1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.js
+++ b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.qml b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.qml
index e546ee44d8..e546ee44d8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.2.qml b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.2.qml
index e70cd8b900..e70cd8b900 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.3.qml b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.3.qml
index 6f47776ea5..6f47776ea5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.4.qml b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.4.qml
index b3887545fb..b3887545fb 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptDisconnect.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptDisconnect.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.js b/tests/auto/qml/qqmlecmascript/data/scriptErrors.js
index d22f623edb..d22f623edb 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.js
+++ b/tests/auto/qml/qqmlecmascript/data/scriptErrors.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml b/tests/auto/qml/qqmlecmascript/data/scriptErrors.qml
index 4998f63929..4998f63929 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml
+++ b/tests/auto/qml/qqmlecmascript/data/scriptErrors.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.2.qml b/tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.2.qml
index 58cf8051f0..58cf8051f0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.qml b/tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.qml
index 074851a67b..074851a67b 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/selfDeletingBinding.qml
+++ b/tests/auto/qml/qqmlecmascript/data/selfDeletingBinding.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.array.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml
index 52abda1e55..52abda1e55 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.array.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.bindings.error.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.error.qml
index 9c87dd293e..9c87dd293e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.bindings.error.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.error.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.bindings.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.qml
index 8d83e9f9f5..8d83e9f9f5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.bindings.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.bindings.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.copy.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.copy.qml
index f6614dad0c..f6614dad0c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.copy.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.copy.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.indexes.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml
index 23f1e90417..23f1e90417 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.indexes.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.indexes.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.read.error.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.error.qml
index 12a76d7e7d..12a76d7e7d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.read.error.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.error.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.read.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.qml
index 4a8a4a17b2..4a8a4a17b2 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.read.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.read.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.threads.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.threads.qml
index aefad89ca4..aefad89ca4 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.threads.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.threads.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.write.error.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.error.qml
index 75beafd1ee..75beafd1ee 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.write.error.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.error.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.write.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.qml
index 812de043b7..812de043b7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sequenceConversion.write.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.write.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/sharedAttachedObject.qml b/tests/auto/qml/qqmlecmascript/data/sharedAttachedObject.qml
index b967f0984c..b967f0984c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/sharedAttachedObject.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sharedAttachedObject.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml b/tests/auto/qml/qqmlecmascript/data/shutdownErrors.qml
index b30aa8b4cd..b30aa8b4cd 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/shutdownErrors.qml
+++ b/tests/auto/qml/qqmlecmascript/data/shutdownErrors.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.1.qml b/tests/auto/qml/qqmlecmascript/data/signalAssignment.1.qml
index fbd09142f7..fbd09142f7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalAssignment.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml b/tests/auto/qml/qqmlecmascript/data/signalAssignment.2.qml
index 6467c42bb9..6467c42bb9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalAssignment.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalAssignment.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalHandlers.qml b/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml
index 975be1b2ad..975be1b2ad 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalHandlers.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalHandlers.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml
index 4fc2dab943..4fc2dab943 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalParameterTypes.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml b/tests/auto/qml/qqmlecmascript/data/signalTriggeredBindings.qml
index d98d7e9c81..d98d7e9c81 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalTriggeredBindings.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalTriggeredBindings.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalWithJSValueInVariant.qml b/tests/auto/qml/qqmlecmascript/data/signalWithJSValueInVariant.qml
index a6f1aa381a..a6f1aa381a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalWithJSValueInVariant.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalWithJSValueInVariant.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalWithQJSValue.qml b/tests/auto/qml/qqmlecmascript/data/signalWithQJSValue.qml
index 36f481d533..36f481d533 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalWithQJSValue.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalWithQJSValue.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/signalWithUnknownTypes.qml b/tests/auto/qml/qqmlecmascript/data/signalWithUnknownTypes.qml
index 49293edfb3..49293edfb3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/signalWithUnknownTypes.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalWithUnknownTypes.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/strictlyEquals.qml b/tests/auto/qml/qqmlecmascript/data/strictlyEquals.qml
index e709e3a8bd..e709e3a8bd 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/strictlyEquals.qml
+++ b/tests/auto/qml/qqmlecmascript/data/strictlyEquals.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/stringArg.qml b/tests/auto/qml/qqmlecmascript/data/stringArg.qml
index 7019af9da5..7019af9da5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/stringArg.qml
+++ b/tests/auto/qml/qqmlecmascript/data/stringArg.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.1.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.1.qml
index 3c7870839d..3c7870839d 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.2.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.2.qml
index 928d36be1f..928d36be1f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.3.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.3.qml
index 5b05d88767..5b05d88767 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.4.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.4.qml
index 43ba199a04..43ba199a04 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.5.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.5.qml
index e0fc62e392..e0fc62e392 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.5.qml
+++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.5.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.6.qml b/tests/auto/qml/qqmlecmascript/data/switchStatement.6.qml
index 6fb71eb345..6fb71eb345 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/switchStatement.6.qml
+++ b/tests/auto/qml/qqmlecmascript/data/switchStatement.6.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/threadScript.js b/tests/auto/qml/qqmlecmascript/data/threadScript.js
index 9f94de1bc1..9f94de1bc1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/threadScript.js
+++ b/tests/auto/qml/qqmlecmascript/data/threadScript.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml b/tests/auto/qml/qqmlecmascript/data/transientErrors.2.qml
index c44acf4fd1..c44acf4fd1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/transientErrors.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml b/tests/auto/qml/qqmlecmascript/data/transientErrors.qml
index 451bb51996..451bb51996 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/transientErrors.qml
+++ b/tests/auto/qml/qqmlecmascript/data/transientErrors.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.1.qml b/tests/auto/qml/qqmlecmascript/data/tryStatement.1.qml
index 71cc67a941..71cc67a941 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/tryStatement.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.2.qml b/tests/auto/qml/qqmlecmascript/data/tryStatement.2.qml
index e7fca0bff7..e7fca0bff7 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/tryStatement.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.3.qml b/tests/auto/qml/qqmlecmascript/data/tryStatement.3.qml
index 04b39f73d5..04b39f73d5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.3.qml
+++ b/tests/auto/qml/qqmlecmascript/data/tryStatement.3.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.4.qml b/tests/auto/qml/qqmlecmascript/data/tryStatement.4.qml
index 231aaf0683..231aaf0683 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/tryStatement.4.qml
+++ b/tests/auto/qml/qqmlecmascript/data/tryStatement.4.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/typeOf.js b/tests/auto/qml/qqmlecmascript/data/typeOf.js
index 16a34234c0..16a34234c0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/typeOf.js
+++ b/tests/auto/qml/qqmlecmascript/data/typeOf.js
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/typeOf.qml b/tests/auto/qml/qqmlecmascript/data/typeOf.qml
index 28f7debed5..28f7debed5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/typeOf.qml
+++ b/tests/auto/qml/qqmlecmascript/data/typeOf.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/unaryExpression.qml b/tests/auto/qml/qqmlecmascript/data/unaryExpression.qml
index 0d40bec710..0d40bec710 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/unaryExpression.qml
+++ b/tests/auto/qml/qqmlecmascript/data/unaryExpression.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.2.qml b/tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.2.qml
index e73d38e2ce..e73d38e2ce 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.qml b/tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.qml
index eceff60aa1..eceff60aa1 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/undefinedResetsProperty.qml
+++ b/tests/auto/qml/qqmlecmascript/data/undefinedResetsProperty.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/urlListProperty.qml b/tests/auto/qml/qqmlecmascript/data/urlListProperty.qml
index eeb0815f09..eeb0815f09 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/urlListProperty.qml
+++ b/tests/auto/qml/qqmlecmascript/data/urlListProperty.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.1.qml b/tests/auto/qml/qqmlecmascript/data/urlProperty.1.qml
index 451cb03206..451cb03206 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/urlProperty.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.2.qml b/tests/auto/qml/qqmlecmascript/data/urlProperty.2.qml
index 0e8bdaec96..0e8bdaec96 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/urlProperty.2.qml
+++ b/tests/auto/qml/qqmlecmascript/data/urlProperty.2.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/v8bindingException.qml b/tests/auto/qml/qqmlecmascript/data/v8bindingException.qml
index ff203e23e3..ff203e23e3 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/v8bindingException.qml
+++ b/tests/auto/qml/qqmlecmascript/data/v8bindingException.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/v8functionException.qml b/tests/auto/qml/qqmlecmascript/data/v8functionException.qml
index 51df1c65d8..51df1c65d8 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/v8functionException.qml
+++ b/tests/auto/qml/qqmlecmascript/data/v8functionException.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/valueTypeFunctions.qml b/tests/auto/qml/qqmlecmascript/data/valueTypeFunctions.qml
index 33b4a68c40..33b4a68c40 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/valueTypeFunctions.qml
+++ b/tests/auto/qml/qqmlecmascript/data/valueTypeFunctions.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/variantsAssignedUndefined.qml b/tests/auto/qml/qqmlecmascript/data/variantsAssignedUndefined.qml
index 6aa8480365..6aa8480365 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/variantsAssignedUndefined.qml
+++ b/tests/auto/qml/qqmlecmascript/data/variantsAssignedUndefined.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/withStatement.1.qml b/tests/auto/qml/qqmlecmascript/data/withStatement.1.qml
index 28f0c08451..28f0c08451 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/withStatement.1.qml
+++ b/tests/auto/qml/qqmlecmascript/data/withStatement.1.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/writeAttachedProperty.qml b/tests/auto/qml/qqmlecmascript/data/writeAttachedProperty.qml
index 3854b069a0..3854b069a0 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/writeAttachedProperty.qml
+++ b/tests/auto/qml/qqmlecmascript/data/writeAttachedProperty.qml
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/writeRemovesBinding.qml b/tests/auto/qml/qqmlecmascript/data/writeRemovesBinding.qml
index a1ba5df071..a1ba5df071 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/writeRemovesBinding.qml
+++ b/tests/auto/qml/qqmlecmascript/data/writeRemovesBinding.qml
diff --git a/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro b/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro
new file mode 100644
index 0000000000..b07e4393a9
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/qqmlecmascript.pro
@@ -0,0 +1,22 @@
+CONFIG += testcase
+TARGET = tst_qqmlecmascript
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlecmascript.cpp \
+ testtypes.cpp \
+ ../../shared/testhttpserver.cpp
+HEADERS += testtypes.h \
+ ../../shared/testhttpserver.h
+INCLUDEPATH += ../../shared
+
+include (../../shared/util.pri)
+
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# LIBS += -lgcov
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private network widgets testlib
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp
new file mode 100644
index 0000000000..78119cb776
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp
@@ -0,0 +1,210 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "testtypes.h"
+#include <QWidget>
+#include <QPlainTextEdit>
+#include <QQmlEngine>
+#include <QJSEngine>
+
+class BaseExtensionObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int baseExtendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged)
+public:
+ BaseExtensionObject(QObject *parent) : QObject(parent), m_value(0) {}
+
+ int extendedProperty() const { return m_value; }
+ void setExtendedProperty(int v) { m_value = v; emit extendedPropertyChanged(); }
+
+signals:
+ void extendedPropertyChanged();
+private:
+ int m_value;
+};
+
+class ExtensionObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int extendedProperty READ extendedProperty WRITE setExtendedProperty NOTIFY extendedPropertyChanged)
+public:
+ ExtensionObject(QObject *parent) : QObject(parent), m_value(0) {}
+
+ int extendedProperty() const { return m_value; }
+ void setExtendedProperty(int v) { m_value = v; emit extendedPropertyChanged(); }
+
+signals:
+ void extendedPropertyChanged();
+private:
+ int m_value;
+};
+
+class DefaultPropertyExtensionObject : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("DefaultProperty", "firstProperty")
+public:
+ DefaultPropertyExtensionObject(QObject *parent) : QObject(parent) {}
+};
+
+class QWidgetDeclarativeUI : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
+
+signals:
+ void widthChanged();
+
+public:
+ QWidgetDeclarativeUI(QObject *other) : QObject(other) { }
+
+public:
+ int width() const { return 0; }
+ void setWidth(int) { }
+};
+
+void MyQmlObject::v8function(QQmlV8Function *args)
+{
+ const char *error = "Exception thrown from within QObject slot";
+ v8::ThrowException(v8::Exception::Error(v8::String::New(error)));
+}
+
+static QJSValue script_api(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(engine)
+
+ static int testProperty = 13;
+ QJSValue v = scriptEngine->newObject();
+ v.setProperty("scriptTestProperty", testProperty++);
+ return v;
+}
+
+static QJSValue readonly_script_api(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(engine)
+
+ static int testProperty = 42;
+ QJSValue v = scriptEngine->newObject();
+ v.setProperty("scriptTestProperty", testProperty++);
+
+ // now freeze it so that it's read-only
+ QJSValue freezeFunction = scriptEngine->evaluate("(function(obj) { return Object.freeze(obj); })");
+ v = freezeFunction.call(QJSValueList() << v);
+
+ return v;
+}
+
+static QObject *qobject_api(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(engine)
+ Q_UNUSED(scriptEngine)
+
+ testQObjectApi *o = new testQObjectApi();
+ o->setQObjectTestProperty(20);
+ o->setQObjectTestWritableProperty(50);
+ return o;
+}
+
+static QObject *qobject_api_engine_parent(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(scriptEngine)
+
+ static int testProperty = 26;
+ testQObjectApi *o = new testQObjectApi(engine);
+ o->setQObjectTestProperty(testProperty++);
+ return o;
+}
+
+void registerTypes()
+{
+ qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObjectAlias");
+ qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject");
+ qmlRegisterType<MyDeferredObject>("Qt.test", 1,0, "MyDeferredObject");
+ qmlRegisterType<MyQmlContainer>("Qt.test", 1,0, "MyQmlContainer");
+ qmlRegisterExtendedType<MyBaseExtendedObject, BaseExtensionObject>("Qt.test", 1,0, "MyBaseExtendedObject");
+ qmlRegisterExtendedType<MyExtendedObject, ExtensionObject>("Qt.test", 1,0, "MyExtendedObject");
+ qmlRegisterType<MyTypeObject>("Qt.test", 1,0, "MyTypeObject");
+ qmlRegisterType<MyDerivedObject>("Qt.test", 1,0, "MyDerivedObject");
+ qmlRegisterType<NumberAssignment>("Qt.test", 1,0, "NumberAssignment");
+ qmlRegisterExtendedType<DefaultPropertyExtendedObject, DefaultPropertyExtensionObject>("Qt.test", 1,0, "DefaultPropertyExtendedObject");
+ qmlRegisterType<OverrideDefaultPropertyObject>("Qt.test", 1,0, "OverrideDefaultPropertyObject");
+ qmlRegisterType<MyRevisionedClass>("Qt.test",1,0,"MyRevisionedClass");
+ qmlRegisterType<MyDeleteObject>("Qt.test", 1,0, "MyDeleteObject");
+ qmlRegisterType<MyRevisionedClass,1>("Qt.test",1,1,"MyRevisionedClass");
+
+ // test scarce resource property binding post-evaluation optimisation
+ // and for testing memory usage in property var circular reference test
+ qmlRegisterType<ScarceResourceObject>("Qt.test", 1,0, "MyScarceResourceObject");
+
+ // Register the uncreatable base class
+ qmlRegisterRevision<MyRevisionedBaseClassRegistered,1>("Qt.test",1,1);
+ // MyRevisionedSubclass 1.0 uses MyRevisionedClass revision 0
+ qmlRegisterType<MyRevisionedSubclass>("Qt.test",1,0,"MyRevisionedSubclass");
+ // MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1
+ qmlRegisterType<MyRevisionedSubclass,1>("Qt.test",1,1,"MyRevisionedSubclass");
+
+ qmlRegisterExtendedType<QWidget,QWidgetDeclarativeUI>("Qt.test",1,0,"QWidget");
+ qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit");
+
+ qRegisterMetaType<MyQmlObject::MyType>("MyQmlObject::MyType");
+
+ qmlRegisterModuleApi("Qt.test",1,0,script_api); // register (script) module API for an existing uri which contains elements
+ qmlRegisterModuleApi("Qt.test",1,0,qobject_api); // register (qobject) for an existing uri for which another module API was previously regd. Should replace!
+ qmlRegisterModuleApi("Qt.test.scriptApi",1,0,script_api); // register (script) module API for a uri which doesn't contain elements
+ qmlRegisterModuleApi("Qt.test.scriptApi",2,0,readonly_script_api); // register (script) module API for a uri which doesn't contain elements - will be made read-only
+ qmlRegisterModuleApi("Qt.test.qobjectApi",1,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements
+ qmlRegisterModuleApi("Qt.test.qobjectApi",1,3,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, minor version set
+ qmlRegisterModuleApi("Qt.test.qobjectApi",2,0,qobject_api); // register (qobject) module API for a uri which doesn't contain elements, major version set
+ qmlRegisterModuleApi("Qt.test.qobjectApiParented",1,0,qobject_api_engine_parent); // register (parented qobject) module API for a uri which doesn't contain elements
+
+ qRegisterMetaType<MyQmlObject::MyType>("MyEnum2");
+ qRegisterMetaType<Qt::MouseButtons>("Qt::MouseButtons");
+
+ qmlRegisterType<CircularReferenceObject>("Qt.test", 1, 0, "CircularReferenceObject");
+ qmlRegisterType<CircularReferenceHandle>("Qt.test", 1, 0, "CircularReferenceHandle");
+
+ qmlRegisterType<MyDynamicCreationDestructionObject>("Qt.test", 1, 0, "MyDynamicCreationDestructionObject");
+ qmlRegisterType<WriteCounter>("Qt.test", 1, 0, "WriteCounter");
+
+ qmlRegisterType<MySequenceConversionObject>("Qt.test", 1, 0, "MySequenceConversionObject");
+}
+
+#include "testtypes.moc"
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h
new file mode 100644
index 0000000000..154e6f019c
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/testtypes.h
@@ -0,0 +1,1311 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qsize.h>
+#include <QtQml/qqmllist.h>
+#include <QtCore/qrect.h>
+#include <QtGui/qmatrix.h>
+#include <QtGui/qcolor.h>
+#include <QtGui/qvector3d.h>
+#include <QtGui/QPixmap>
+#include <QtCore/qdatetime.h>
+#include <QtQml/qjsvalue.h>
+#include <QtQml/qqmlscriptstring.h>
+#include <QtQml/qqmlcomponent.h>
+
+#include <private/qqmlengine_p.h>
+#include <private/qv8engine_p.h>
+
+class MyQmlAttachedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value CONSTANT)
+ Q_PROPERTY(int value2 READ value2 WRITE setValue2 NOTIFY value2Changed)
+public:
+ MyQmlAttachedObject(QObject *parent) : QObject(parent), m_value2(0) {}
+
+ int value() const { return 19; }
+ int value2() const { return m_value2; }
+ void setValue2(int v) { if (m_value2 == v) return; m_value2 = v; emit value2Changed(); }
+
+ void emitMySignal() { emit mySignal(); }
+
+signals:
+ void value2Changed();
+ void mySignal();
+
+private:
+ int m_value2;
+};
+
+class MyQmlObject : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(MyEnum)
+ Q_ENUMS(MyEnum2)
+ Q_PROPERTY(int deleteOnSet READ deleteOnSet WRITE setDeleteOnSet)
+ Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT)
+ Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT)
+ Q_PROPERTY(int value READ value WRITE setValue)
+ Q_PROPERTY(int console READ console CONSTANT)
+ Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
+ Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty NOTIFY urlChanged)
+ Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged)
+ Q_PROPERTY(QQmlListProperty<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)
+ Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty NOTIFY intChanged)
+
+public:
+ MyQmlObject(): myinvokableObject(0), m_methodCalled(false), m_methodIntCalled(false), m_object(0), m_value(0), m_resetProperty(13), m_intProperty(0) {}
+
+ enum MyEnum { EnumValue1 = 0, EnumValue2 = 1 };
+ enum MyEnum2 { EnumValue3 = 2, EnumValue4 = 3 };
+
+ bool trueProperty() const { return true; }
+ bool falseProperty() const { return false; }
+
+ QString stringProperty() const { return m_string; }
+ void setStringProperty(const QString &s)
+ {
+ if (s == m_string)
+ return;
+ m_string = s;
+ emit stringChanged();
+ }
+
+ QUrl urlProperty() const { return m_url; }
+ void setUrlProperty(const QUrl &url)
+ {
+ if (url == m_url)
+ return;
+ m_url = url;
+ emit urlChanged();
+ }
+
+ QObject *objectProperty() const { return m_object; }
+ void setObjectProperty(QObject *obj) {
+ if (obj == m_object)
+ return;
+ m_object = obj;
+ emit objectChanged();
+ }
+
+ QQmlListProperty<QObject> objectListProperty() { return QQmlListProperty<QObject>(this, m_objectQList); }
+
+ bool methodCalled() const { return m_methodCalled; }
+ bool methodIntCalled() const { return m_methodIntCalled; }
+
+ QString string() const { return m_string; }
+
+ static MyQmlAttachedObject *qmlAttachedProperties(QObject *o) {
+ return new MyQmlAttachedObject(o);
+ }
+
+ int deleteOnSet() const { return 1; }
+ void setDeleteOnSet(int v) { if(v) delete this; }
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; }
+
+ int resettableProperty() const { return m_resetProperty; }
+ void setResettableProperty(int v) { m_resetProperty = v; }
+ void resetProperty() { m_resetProperty = 13; }
+
+ QRegExp regExp() { return m_regExp; }
+ 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; }
+
+ struct MyType {
+ int value;
+ };
+ QVariant variant() const { return m_variant; }
+ QJSValue qjsvalue() const { return m_qjsvalue; }
+
+ int intProperty() const { return m_intProperty; }
+ void setIntProperty(int i) { m_intProperty = i; emit intChanged(); }
+
+signals:
+ void basicSignal();
+ void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e);
+ void stringChanged();
+ void urlChanged();
+ void objectChanged();
+ void anotherBasicSignal();
+ void thirdBasicSignal();
+ void signalWithUnknownType(const MyQmlObject::MyType &arg);
+ void signalWithVariant(const QVariant &arg);
+ void signalWithQJSValue(const QJSValue &arg);
+ void intChanged();
+
+public slots:
+ void deleteMe() { delete this; }
+ 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; }
+ void variantMethod(const QVariant &v) { m_variant = v; }
+ void qjsvalueMethod(const QJSValue &v) { m_qjsvalue = v; }
+ void v8function(QQmlV8Function*);
+
+private:
+ friend class tst_qqmlecmascript;
+ bool m_methodCalled;
+ bool m_methodIntCalled;
+
+ QObject *m_object;
+ QString m_string;
+ QUrl m_url;
+ QList<QObject *> m_objectQList;
+ int m_value;
+ int m_resetProperty;
+ QRegExp m_regExp;
+ QVariant m_variant;
+ QJSValue m_qjsvalue;
+ int m_intProperty;
+};
+
+QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
+
+class MyQmlContainer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<MyQmlObject> children READ children CONSTANT)
+public:
+ MyQmlContainer() {}
+
+ QQmlListProperty<MyQmlObject> children() { return QQmlListProperty<MyQmlObject>(this, m_children); }
+
+private:
+ QList<MyQmlObject*> m_children;
+};
+
+
+class MyExpression : public QQmlExpression
+{
+ Q_OBJECT
+public:
+ MyExpression(QQmlContext *ctxt, const QString &expr)
+ : QQmlExpression(ctxt, 0, expr), changed(false)
+ {
+ QObject::connect(this, SIGNAL(valueChanged()), this, SLOT(expressionValueChanged()));
+ setNotifyOnValueChanged(true);
+ }
+
+ bool changed;
+
+public slots:
+ void expressionValueChanged() {
+ changed = true;
+ }
+};
+
+
+class MyDefaultObject1 : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int horseLegs READ horseLegs CONSTANT)
+ Q_PROPERTY(int antLegs READ antLegs CONSTANT)
+ Q_PROPERTY(int emuLegs READ emuLegs CONSTANT)
+public:
+ int horseLegs() const { return 4; }
+ int antLegs() const { return 6; }
+ int emuLegs() const { return 2; }
+};
+
+class MyDefaultObject3 : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int antLegs READ antLegs CONSTANT)
+ Q_PROPERTY(int humanLegs READ humanLegs CONSTANT)
+public:
+ int antLegs() const { return 7; } // Mutant
+ int humanLegs() const { return 2; }
+ int millipedeLegs() const { return 1000; }
+};
+
+class MyDeferredObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
+ Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
+ Q_PROPERTY(QObject *objectProperty2 READ objectProperty2 WRITE setObjectProperty2)
+ Q_CLASSINFO("DeferredPropertyNames", "value,objectProperty,objectProperty2")
+
+public:
+ MyDeferredObject() : m_value(0), m_object(0), m_object2(0) {}
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; emit valueChanged(); }
+
+ QObject *objectProperty() const { return m_object; }
+ void setObjectProperty(QObject *obj) { m_object = obj; }
+
+ QObject *objectProperty2() const { return m_object2; }
+ void setObjectProperty2(QObject *obj) { m_object2 = obj; }
+
+signals:
+ void valueChanged();
+
+private:
+ int m_value;
+ QObject *m_object;
+ QObject *m_object2;
+};
+
+class MyBaseExtendedObject : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(int baseProperty READ baseProperty WRITE setBaseProperty)
+public:
+ MyBaseExtendedObject() : m_value(0) {}
+
+ int baseProperty() const { return m_value; }
+ void setBaseProperty(int v) { m_value = v; }
+
+private:
+ int m_value;
+};
+
+class MyExtendedObject : public MyBaseExtendedObject
+{
+Q_OBJECT
+Q_PROPERTY(int coreProperty READ coreProperty WRITE setCoreProperty)
+public:
+ MyExtendedObject() : m_value(0) {}
+
+ int coreProperty() const { return m_value; }
+ void setCoreProperty(int v) { m_value = v; }
+
+private:
+ int m_value;
+};
+
+class MyTypeObject : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(MyEnum)
+ Q_FLAGS(MyFlags)
+
+ Q_PROPERTY(QString id READ id WRITE setId)
+ Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
+ Q_PROPERTY(QQmlComponent *componentProperty READ componentProperty WRITE setComponentProperty)
+ Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty)
+ Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty)
+ Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
+ Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty)
+ Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty)
+ Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty)
+ Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty)
+ Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty)
+ Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty)
+ Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty)
+ Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty)
+ Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty)
+ Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty)
+ Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty)
+ Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty)
+ Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty)
+ Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged)
+ Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2)
+ Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty)
+ Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty)
+ Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty)
+ Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty)
+ Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty)
+
+ Q_PROPERTY(QQmlScriptString scriptProperty READ scriptProperty WRITE setScriptProperty)
+
+public:
+ MyTypeObject()
+ : objectPropertyValue(0), componentPropertyValue(0) {}
+
+ QString idValue;
+ QString id() const {
+ return idValue;
+ }
+ void setId(const QString &v) {
+ idValue = v;
+ }
+
+ QObject *objectPropertyValue;
+ QObject *objectProperty() const {
+ return objectPropertyValue;
+ }
+ void setObjectProperty(QObject *v) {
+ objectPropertyValue = v;
+ }
+
+ QQmlComponent *componentPropertyValue;
+ QQmlComponent *componentProperty() const {
+ return componentPropertyValue;
+ }
+ void setComponentProperty(QQmlComponent *v) {
+ componentPropertyValue = v;
+ }
+
+ enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
+ Q_DECLARE_FLAGS(MyFlags, MyFlag)
+ MyFlags flagPropertyValue;
+ MyFlags flagProperty() const {
+ return flagPropertyValue;
+ }
+ void setFlagProperty(MyFlags v) {
+ flagPropertyValue = v;
+ }
+
+ enum MyEnum { EnumVal1, EnumVal2 };
+ MyEnum enumPropertyValue;
+ MyEnum enumProperty() const {
+ return enumPropertyValue;
+ }
+ void setEnumProperty(MyEnum v) {
+ enumPropertyValue = v;
+ }
+
+ QString stringPropertyValue;
+ QString stringProperty() const {
+ return stringPropertyValue;
+ }
+ void setStringProperty(const QString &v) {
+ stringPropertyValue = v;
+ }
+
+ uint uintPropertyValue;
+ uint uintProperty() const {
+ return uintPropertyValue;
+ }
+ void setUintProperty(const uint &v) {
+ uintPropertyValue = v;
+ }
+
+ int intPropertyValue;
+ int intProperty() const {
+ return intPropertyValue;
+ }
+ void setIntProperty(const int &v) {
+ intPropertyValue = v;
+ }
+
+ qreal realPropertyValue;
+ qreal realProperty() const {
+ return realPropertyValue;
+ }
+ void setRealProperty(const qreal &v) {
+ realPropertyValue = v;
+ }
+
+ double doublePropertyValue;
+ double doubleProperty() const {
+ return doublePropertyValue;
+ }
+ void setDoubleProperty(const double &v) {
+ doublePropertyValue = v;
+ }
+
+ float floatPropertyValue;
+ float floatProperty() const {
+ return floatPropertyValue;
+ }
+ void setFloatProperty(const float &v) {
+ floatPropertyValue = v;
+ }
+
+ QColor colorPropertyValue;
+ QColor colorProperty() const {
+ return colorPropertyValue;
+ }
+ void setColorProperty(const QColor &v) {
+ colorPropertyValue = v;
+ }
+
+ QDate datePropertyValue;
+ QDate dateProperty() const {
+ return datePropertyValue;
+ }
+ void setDateProperty(const QDate &v) {
+ datePropertyValue = v;
+ }
+
+ QTime timePropertyValue;
+ QTime timeProperty() const {
+ return timePropertyValue;
+ }
+ void setTimeProperty(const QTime &v) {
+ timePropertyValue = v;
+ }
+
+ QDateTime dateTimePropertyValue;
+ QDateTime dateTimeProperty() const {
+ return dateTimePropertyValue;
+ }
+ void setDateTimeProperty(const QDateTime &v) {
+ dateTimePropertyValue = v;
+ }
+
+ QPoint pointPropertyValue;
+ QPoint pointProperty() const {
+ return pointPropertyValue;
+ }
+ void setPointProperty(const QPoint &v) {
+ pointPropertyValue = v;
+ }
+
+ QPointF pointFPropertyValue;
+ QPointF pointFProperty() const {
+ return pointFPropertyValue;
+ }
+ void setPointFProperty(const QPointF &v) {
+ pointFPropertyValue = v;
+ }
+
+ QSize sizePropertyValue;
+ QSize sizeProperty() const {
+ return sizePropertyValue;
+ }
+ void setSizeProperty(const QSize &v) {
+ sizePropertyValue = v;
+ }
+
+ QSizeF sizeFPropertyValue;
+ QSizeF sizeFProperty() const {
+ return sizeFPropertyValue;
+ }
+ void setSizeFProperty(const QSizeF &v) {
+ sizeFPropertyValue = v;
+ }
+
+ QRect rectPropertyValue;
+ QRect rectProperty() const {
+ return rectPropertyValue;
+ }
+ void setRectProperty(const QRect &v) {
+ rectPropertyValue = v;
+ emit rectPropertyChanged();
+ }
+
+ QRect rectPropertyValue2;
+ QRect rectProperty2() const {
+ return rectPropertyValue2;
+ }
+ void setRectProperty2(const QRect &v) {
+ rectPropertyValue2 = v;
+ }
+
+ QRectF rectFPropertyValue;
+ QRectF rectFProperty() const {
+ return rectFPropertyValue;
+ }
+ void setRectFProperty(const QRectF &v) {
+ rectFPropertyValue = v;
+ }
+
+ bool boolPropertyValue;
+ bool boolProperty() const {
+ return boolPropertyValue;
+ }
+ void setBoolProperty(const bool &v) {
+ boolPropertyValue = v;
+ }
+
+ QVariant variantPropertyValue;
+ QVariant variantProperty() const {
+ return variantPropertyValue;
+ }
+ void setVariantProperty(const QVariant &v) {
+ variantPropertyValue = v;
+ }
+
+ QVector3D vectorPropertyValue;
+ QVector3D vectorProperty() const {
+ return vectorPropertyValue;
+ }
+ void setVectorProperty(const QVector3D &v) {
+ vectorPropertyValue = v;
+ }
+
+ QUrl urlPropertyValue;
+ QUrl urlProperty() const {
+ return urlPropertyValue;
+ }
+ void setUrlProperty(const QUrl &v) {
+ urlPropertyValue = v;
+ }
+
+ QQmlScriptString scriptPropertyValue;
+ QQmlScriptString scriptProperty() const {
+ return scriptPropertyValue;
+ }
+ void setScriptProperty(const QQmlScriptString &v) {
+ scriptPropertyValue = v;
+ }
+
+ void doAction() { emit action(); }
+signals:
+ void action();
+ void rectPropertyChanged();
+};
+Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
+
+class MyDerivedObject : public MyTypeObject
+{
+ Q_OBJECT
+public:
+ Q_INVOKABLE bool intProperty() const {
+ return true;
+ }
+};
+
+Q_DECLARE_METATYPE(QJSValue);
+class MyInvokableBaseObject : public QObject
+{
+ Q_OBJECT
+public:
+ inline ~MyInvokableBaseObject() = 0;
+
+ Q_INVOKABLE inline void method_inherited(int a);
+ Q_INVOKABLE inline void method_overload();
+};
+
+class MyInvokableObject : public MyInvokableBaseObject
+{
+ Q_OBJECT
+ Q_ENUMS(TestEnum)
+public:
+ enum TestEnum { EnumValue1, EnumValue2 };
+ MyInvokableObject() { reset(); }
+
+ int invoked() const { return m_invoked; }
+ bool error() const { return m_invokedError; }
+ const QVariantList &actuals() const { return m_actuals; }
+ void reset() { m_invoked = -1; m_invokedError = false; m_actuals.clear(); }
+
+ Q_INVOKABLE QPointF method_get_QPointF() { return QPointF(99.3, -10.2); }
+ Q_INVOKABLE QPoint method_get_QPoint() { return QPoint(9, 12); }
+
+ Q_INVOKABLE void method_NoArgs() { invoke(0); }
+ Q_INVOKABLE int method_NoArgs_int() { invoke(1); return 6; }
+ Q_INVOKABLE qreal method_NoArgs_real() { invoke(2); return 19.75; }
+ Q_INVOKABLE QPointF method_NoArgs_QPointF() { invoke(3); return QPointF(123, 4.5); }
+ Q_INVOKABLE QObject *method_NoArgs_QObject() { invoke(4); return this; }
+ Q_INVOKABLE MyInvokableObject *method_NoArgs_unknown() { invoke(5); return this; }
+ Q_INVOKABLE QJSValue method_NoArgs_QScriptValue() { invoke(6); return QJSValue("Hello world"); }
+ Q_INVOKABLE QVariant method_NoArgs_QVariant() { invoke(7); return QVariant("QML rocks"); }
+
+ Q_INVOKABLE void method_int(int a) { invoke(8); m_actuals << a; }
+ Q_INVOKABLE void method_intint(int a, int b) { invoke(9); m_actuals << a << b; }
+ Q_INVOKABLE void method_real(qreal a) { invoke(10); m_actuals << a; }
+ Q_INVOKABLE void method_QString(QString a) { invoke(11); m_actuals << a; }
+ Q_INVOKABLE void method_QPointF(QPointF a) { invoke(12); m_actuals << a; }
+ Q_INVOKABLE void method_QObject(QObject *a) { invoke(13); m_actuals << qVariantFromValue(a); }
+ Q_INVOKABLE void method_QScriptValue(QJSValue a) { invoke(14); m_actuals << qVariantFromValue(a); }
+ Q_INVOKABLE void method_intQScriptValue(int a, QJSValue b) { invoke(15); m_actuals << a << qVariantFromValue(b); }
+
+ Q_INVOKABLE void method_overload(int a) { invoke(16); m_actuals << a; }
+ Q_INVOKABLE void method_overload(int a, int b) { invoke(17); m_actuals << a << b; }
+ Q_INVOKABLE void method_overload(QString a) { invoke(18); m_actuals << a; }
+
+ Q_INVOKABLE void method_with_enum(TestEnum e) { invoke(19); m_actuals << (int)e; }
+
+ Q_INVOKABLE int method_default(int a, int b = 19) { invoke(20); m_actuals << a << b; return b; }
+
+ Q_INVOKABLE void method_QVariant(QVariant a, QVariant b = QVariant()) { invoke(21); m_actuals << a << b; }
+
+private:
+ friend class MyInvokableBaseObject;
+ void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;}
+ int m_invoked;
+ bool m_invokedError;
+ QVariantList m_actuals;
+};
+
+MyInvokableBaseObject::~MyInvokableBaseObject() {}
+
+void MyInvokableBaseObject::method_inherited(int a)
+{
+ static_cast<MyInvokableObject *>(this)->invoke(-3);
+ static_cast<MyInvokableObject *>(this)->m_actuals << a;
+}
+
+// This is a hidden overload of the MyInvokableObject::method_overload() method
+void MyInvokableBaseObject::method_overload()
+{
+ static_cast<MyInvokableObject *>(this)->invoke(-2);
+}
+
+class NumberAssignment : public QObject
+{
+ Q_OBJECT
+public:
+ 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)
+ qreal _test2;
+ qreal test2() const { return _test2; }
+ void setTest2(qreal v) { _test2 = v; }
+
+ 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)
+ qreal _test4;
+ qreal test4() const { return _test4; }
+ void setTest4(qreal v) { _test4 = v; }
+
+ 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)
+ int _test6;
+ int test6() const { return _test6; }
+ void setTest6(int v) { _test6 = v; }
+
+ 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)
+ int _test8;
+ int test8() const { return _test8; }
+ void setTest8(int v) { _test8 = v; }
+
+ 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)
+ 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)
+ 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)
+ unsigned int _test12;
+ unsigned int test12() const { return _test12; }
+ void setTest12(unsigned int v) { _test12 = v; }
+};
+
+class DefaultPropertyExtendedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QObject *firstProperty READ firstProperty WRITE setFirstProperty)
+ Q_PROPERTY(QObject *secondProperty READ secondProperty WRITE setSecondProperty)
+public:
+ DefaultPropertyExtendedObject(QObject *parent = 0) : QObject(parent), m_firstProperty(0), m_secondProperty(0) {}
+
+ QObject *firstProperty() const { return m_firstProperty; }
+ QObject *secondProperty() const { return m_secondProperty; }
+ void setFirstProperty(QObject *property) { m_firstProperty = property; }
+ void setSecondProperty(QObject *property) { m_secondProperty = property; }
+private:
+ QObject* m_firstProperty;
+ QObject* m_secondProperty;
+};
+
+class OverrideDefaultPropertyObject : public DefaultPropertyExtendedObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("DefaultProperty", "secondProperty")
+public:
+ OverrideDefaultPropertyObject() {}
+};
+
+class MyRevisionedBaseClassRegistered : public QObject
+{
+Q_OBJECT
+ Q_PROPERTY(qreal propA READ propA WRITE setPropA NOTIFY propAChanged)
+ Q_PROPERTY(qreal propB READ propB WRITE setPropB NOTIFY propBChanged REVISION 1)
+
+public:
+ MyRevisionedBaseClassRegistered() : m_pa(1), m_pb(2) {}
+
+ qreal propA() const { return m_pa; }
+ void setPropA(qreal p) {
+ if (p != m_pa) {
+ m_pa = p;
+ emit propAChanged();
+ }
+ }
+ qreal propB() const { return m_pb; }
+ void setPropB(qreal p) {
+ if (p != m_pb) {
+ m_pb = p;
+ emit propBChanged();
+ }
+ }
+
+ Q_INVOKABLE void methodA() { }
+ Q_INVOKABLE Q_REVISION(1) void methodB() { }
+
+signals:
+ void propAChanged();
+ void propBChanged();
+
+ void signalA();
+ Q_REVISION(1) void signalB();
+
+protected:
+ qreal m_pa;
+ qreal m_pb;
+};
+
+class MyRevisionedBaseClassUnregistered : public MyRevisionedBaseClassRegistered
+{
+Q_OBJECT
+ Q_PROPERTY(qreal propC READ propC WRITE setPropC NOTIFY propCChanged)
+ Q_PROPERTY(qreal propD READ propD WRITE setPropD NOTIFY propDChanged REVISION 1)
+
+public:
+ MyRevisionedBaseClassUnregistered() : m_pc(1), m_pd(2) {}
+
+ qreal propC() const { return m_pc; }
+ void setPropC(qreal p) {
+ if (p != m_pc) {
+ m_pc = p;
+ emit propCChanged();
+ }
+ }
+ qreal propD() const { return m_pd; }
+ void setPropD(qreal p) {
+ if (p != m_pd) {
+ m_pd = p;
+ emit propDChanged();
+ }
+ }
+
+ Q_INVOKABLE void methodC() { }
+ Q_INVOKABLE Q_REVISION(1) void methodD() { }
+
+signals:
+ void propCChanged();
+ void propDChanged();
+
+ void signalC();
+ Q_REVISION(1) void signalD();
+
+protected:
+ qreal m_pc;
+ qreal m_pd;
+};
+
+class MyRevisionedClass : public MyRevisionedBaseClassUnregistered
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal prop1 READ prop1 WRITE setProp1 NOTIFY prop1Changed)
+ Q_PROPERTY(qreal prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed REVISION 1)
+
+public:
+ MyRevisionedClass() {}
+
+ qreal prop1() const { return m_p1; }
+ void setProp1(qreal p) {
+ if (p != m_p1) {
+ m_p1 = p;
+ emit prop1Changed();
+ }
+ }
+ qreal prop2() const { return m_p2; }
+ void setProp2(qreal p) {
+ if (p != m_p2) {
+ m_p2 = p;
+ emit prop2Changed();
+ }
+ }
+
+ Q_INVOKABLE void method1() { }
+ Q_INVOKABLE Q_REVISION(1) void method2() { }
+
+signals:
+ void prop1Changed();
+ void prop2Changed();
+
+ void signal1();
+ Q_REVISION(1) void signal2();
+
+protected:
+ qreal m_p1;
+ qreal m_p2;
+};
+
+class MyRevisionedSubclass : public MyRevisionedClass
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal prop3 READ prop3 WRITE setProp3 NOTIFY prop3Changed)
+ Q_PROPERTY(qreal prop4 READ prop4 WRITE setProp4 NOTIFY prop4Changed REVISION 1)
+
+public:
+ MyRevisionedSubclass() : m_p3(3), m_p4(4) {}
+
+ qreal prop3() const { return m_p3; }
+ void setProp3(qreal p) {
+ if (p != m_p3) {
+ m_p3 = p;
+ emit prop3Changed();
+ }
+ }
+ qreal prop4() const { return m_p4; }
+ void setProp4(qreal p) {
+ if (p != m_p4) {
+ m_p4 = p;
+ emit prop4Changed();
+ }
+ }
+
+ Q_INVOKABLE void method3() { }
+ Q_INVOKABLE Q_REVISION(1) void method4() { }
+
+signals:
+ void prop3Changed();
+ void prop4Changed();
+
+ void signal3();
+ Q_REVISION(1) void signal4();
+
+protected:
+ qreal m_p3;
+ qreal m_p4;
+};
+
+QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered)
+QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered)
+QML_DECLARE_TYPE(MyRevisionedClass)
+QML_DECLARE_TYPE(MyRevisionedSubclass)
+Q_DECLARE_METATYPE(MyQmlObject::MyType)
+
+
+class ScarceResourceObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QPixmap scarceResource READ scarceResource WRITE setScarceResource NOTIFY scarceResourceChanged)
+public:
+ ScarceResourceObject(QObject *parent = 0) : QObject(parent), m_value(100, 100) { m_value.fill(Qt::blue); }
+ ~ScarceResourceObject() {}
+
+ QPixmap scarceResource() const { return m_value; }
+ void setScarceResource(QPixmap v) { m_value = v; emit scarceResourceChanged(); }
+
+ bool scarceResourceIsDetached() const { return m_value.isDetached(); }
+
+ // this particular one returns a new one each time
+ // this means that every Scarce Resource Copy will
+ // consume resources (so that we can track disposal
+ // of v8 handles with circular references).
+ Q_INVOKABLE QPixmap newScarceResource() const
+ {
+ QPixmap retn(800, 600);
+ retn.fill(QColor(100, 110, 120, 45));
+ return retn;
+ }
+
+signals:
+ void scarceResourceChanged();
+
+private:
+ QPixmap m_value;
+};
+QML_DECLARE_TYPE(ScarceResourceObject)
+
+class testQObjectApi : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(MyEnum)
+ Q_PROPERTY (int qobjectTestProperty READ qobjectTestProperty NOTIFY qobjectTestPropertyChanged)
+ Q_PROPERTY (int qobjectTestWritableProperty READ qobjectTestWritableProperty WRITE setQObjectTestWritableProperty NOTIFY qobjectTestWritablePropertyChanged)
+
+public:
+ testQObjectApi(QObject* parent = 0)
+ : QObject(parent), m_testProperty(0), m_testWritableProperty(0), m_methodCallCount(0)
+ {
+ }
+
+ ~testQObjectApi() {}
+
+ enum MyEnum { EnumValue1 = 25, EnumValue2 = 42 };
+ Q_INVOKABLE int qobjectEnumTestMethod(MyEnum val) { return (static_cast<int>(val) + 5); }
+ Q_INVOKABLE int qobjectTestMethod(int increment = 1) { m_methodCallCount += increment; return m_methodCallCount; }
+
+ int qobjectTestProperty() const { return m_testProperty; }
+ void setQObjectTestProperty(int tp) { m_testProperty = tp; emit qobjectTestPropertyChanged(tp); }
+
+ int qobjectTestWritableProperty() const { return m_testWritableProperty; }
+ void setQObjectTestWritableProperty(int tp) { m_testWritableProperty = tp; emit qobjectTestWritablePropertyChanged(tp); }
+
+signals:
+ void qobjectTestPropertyChanged(int testProperty);
+ void qobjectTestWritablePropertyChanged(int testWritableProperty);
+
+private:
+ int m_testProperty;
+ int m_testWritableProperty;
+ int m_methodCallCount;
+};
+
+class CircularReferenceObject : public QObject,
+ public QV8GCCallback::Node
+{
+ Q_OBJECT
+
+public:
+ CircularReferenceObject(QObject *parent = 0)
+ : QObject(parent), QV8GCCallback::Node(callback), m_referenced(0), m_dtorCount(0)
+ {
+ QV8GCCallback::addGcCallbackNode(this);
+ }
+
+ ~CircularReferenceObject()
+ {
+ if (m_dtorCount) *m_dtorCount = *m_dtorCount + 1;
+ }
+
+ Q_INVOKABLE void setDtorCount(int *dtorCount)
+ {
+ m_dtorCount = dtorCount;
+ }
+
+ Q_INVOKABLE CircularReferenceObject *generate(QObject *parent = 0)
+ {
+ CircularReferenceObject *retn = new CircularReferenceObject(parent);
+ retn->m_dtorCount = m_dtorCount;
+ retn->m_engine = m_engine;
+ return retn;
+ }
+
+ Q_INVOKABLE void addReference(QObject *other)
+ {
+ m_referenced = other;
+ }
+
+ static void callback(QV8GCCallback::Node *n)
+ {
+ CircularReferenceObject *cro = static_cast<CircularReferenceObject*>(n);
+ if (cro->m_referenced) {
+ cro->m_engine->addRelationshipForGC(cro, cro->m_referenced);
+ }
+ }
+
+ void setEngine(QQmlEngine* declarativeEngine)
+ {
+ m_engine = QQmlEnginePrivate::get(declarativeEngine)->v8engine();
+ }
+
+private:
+ QObject *m_referenced;
+ int *m_dtorCount;
+ QV8Engine* m_engine;
+};
+Q_DECLARE_METATYPE(CircularReferenceObject*)
+
+class CircularReferenceHandle : public QObject,
+ public QV8GCCallback::Node
+{
+ Q_OBJECT
+
+public:
+ CircularReferenceHandle(QObject *parent = 0)
+ : QObject(parent), QV8GCCallback::Node(gccallback), m_dtorCount(0), m_engine(0)
+ {
+ QV8GCCallback::addGcCallbackNode(this);
+ }
+
+ ~CircularReferenceHandle()
+ {
+ if (m_dtorCount) *m_dtorCount = *m_dtorCount + 1;
+ }
+
+ Q_INVOKABLE void setDtorCount(int *dtorCount)
+ {
+ m_dtorCount = dtorCount;
+ }
+
+ Q_INVOKABLE CircularReferenceHandle *generate(QObject *parent = 0)
+ {
+ CircularReferenceHandle *retn = new CircularReferenceHandle(parent);
+ retn->m_dtorCount = m_dtorCount;
+ retn->m_engine = m_engine;
+ return retn;
+ }
+
+ Q_INVOKABLE void addReference(v8::Persistent<v8::Value> handle)
+ {
+ m_referenced = qPersistentNew(handle);
+ m_referenced.MakeWeak(static_cast<void*>(this), wrcallback);
+ }
+
+ static void wrcallback(v8::Persistent<v8::Value> handle, void *params)
+ {
+ CircularReferenceHandle *crh = static_cast<CircularReferenceHandle*>(params);
+ qPersistentDispose(handle);
+ crh->m_referenced.Clear();
+ }
+
+ static void gccallback(QV8GCCallback::Node *n)
+ {
+ CircularReferenceHandle *crh = static_cast<CircularReferenceHandle*>(n);
+ crh->m_engine->addRelationshipForGC(crh, crh->m_referenced);
+ }
+
+ void setEngine(QQmlEngine* declarativeEngine)
+ {
+ m_engine = QQmlEnginePrivate::get(declarativeEngine)->v8engine();
+ }
+
+private:
+ v8::Persistent<v8::Value> m_referenced;
+ int *m_dtorCount;
+ QV8Engine* m_engine;
+};
+Q_DECLARE_METATYPE(CircularReferenceHandle*)
+
+class MyDynamicCreationDestructionObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY (int intProperty READ intProperty WRITE setIntProperty NOTIFY intPropertyChanged)
+
+public:
+ MyDynamicCreationDestructionObject(QObject *parent = 0) : QObject(parent), m_intProperty(0), m_dtorCount(0)
+ {
+ }
+
+ ~MyDynamicCreationDestructionObject()
+ {
+ if (m_dtorCount) {
+ (*m_dtorCount)++;
+ }
+ }
+
+ int intProperty() const { return m_intProperty; }
+ void setIntProperty(int val) { m_intProperty = val; emit intPropertyChanged(); }
+
+ Q_INVOKABLE MyDynamicCreationDestructionObject *createNew()
+ {
+ // no parent == ownership transfers to JS; same dtor counter.
+ MyDynamicCreationDestructionObject *retn = new MyDynamicCreationDestructionObject;
+ retn->setDtorCount(m_dtorCount);
+ return retn;
+ }
+
+ void setDtorCount(int *dtorCount)
+ {
+ m_dtorCount = dtorCount;
+ }
+
+signals:
+ void intPropertyChanged();
+
+private:
+ int m_intProperty;
+ int *m_dtorCount;
+};
+
+class WriteCounter : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue);
+public:
+ WriteCounter() : m_value(0), m_count(0) {}
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; ++m_count; }
+
+ int count() const { return m_count; }
+
+private:
+ int m_value;
+ int m_count;
+};
+
+class MySequenceConversionObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY (QList<int> intListProperty READ intListProperty WRITE setIntListProperty NOTIFY intListPropertyChanged)
+ Q_PROPERTY (QList<int> intListProperty2 READ intListProperty2 WRITE setIntListProperty2 NOTIFY intListProperty2Changed)
+ Q_PROPERTY (QList<qreal> qrealListProperty READ qrealListProperty WRITE setQrealListProperty NOTIFY qrealListPropertyChanged)
+ Q_PROPERTY (QList<bool> boolListProperty READ boolListProperty WRITE setBoolListProperty NOTIFY boolListPropertyChanged)
+ Q_PROPERTY (QList<QString> stringListProperty READ stringListProperty WRITE setStringListProperty NOTIFY stringListPropertyChanged)
+ Q_PROPERTY (QList<QUrl> urlListProperty READ urlListProperty WRITE setUrlListProperty NOTIFY urlListPropertyChanged)
+ Q_PROPERTY (QStringList qstringListProperty READ qstringListProperty WRITE setQStringListProperty NOTIFY qstringListPropertyChanged)
+
+ Q_PROPERTY (QList<QPoint> pointListProperty READ pointListProperty WRITE setPointListProperty NOTIFY pointListPropertyChanged)
+ Q_PROPERTY (QList<QVariant> variantListProperty READ variantListProperty WRITE setVariantListProperty NOTIFY variantListPropertyChanged)
+
+ Q_PROPERTY (qint32 maxIndex READ maxIndex CONSTANT)
+ Q_PROPERTY (quint32 tooBigIndex READ tooBigIndex CONSTANT)
+ Q_PROPERTY (qint32 negativeIndex READ negativeIndex CONSTANT)
+
+public:
+ MySequenceConversionObject()
+ {
+ m_intList << 1 << 2 << 3 << 4;
+ m_intList2 << 1 << 2 << 3 << 4;
+ m_qrealList << 1.1 << 2.2 << 3.3 << 4.4;
+ m_boolList << true << false << true << false;
+ m_stringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
+ m_urlList << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com");
+ m_qstringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
+
+ m_pointList << QPoint(1, 2) << QPoint(3, 4) << QPoint(5, 6);
+ m_variantList << QVariant(QLatin1String("one")) << QVariant(true) << QVariant(3);
+ }
+
+ ~MySequenceConversionObject() {}
+
+ qint32 maxIndex() const
+ {
+ return INT_MAX;
+ }
+ quint32 tooBigIndex() const
+ {
+ quint32 retn = 7;
+ retn += INT_MAX;
+ return retn;
+ }
+ qint32 negativeIndex() const
+ {
+ return -5;
+ }
+
+ QList<int> intListProperty() const { return m_intList; }
+ void setIntListProperty(const QList<int> &list) { m_intList = list; emit intListPropertyChanged(); }
+ QList<int> intListProperty2() const { return m_intList2; }
+ void setIntListProperty2(const QList<int> &list) { m_intList2 = list; emit intListProperty2Changed(); }
+ QList<qreal> qrealListProperty() const { return m_qrealList; }
+ void setQrealListProperty(const QList<qreal> &list) { m_qrealList = list; emit qrealListPropertyChanged(); }
+ QList<bool> boolListProperty() const { return m_boolList; }
+ void setBoolListProperty(const QList<bool> &list) { m_boolList = list; emit boolListPropertyChanged(); }
+ QList<QString> stringListProperty() const { return m_stringList; }
+ void setStringListProperty(const QList<QString> &list) { m_stringList = list; emit stringListPropertyChanged(); }
+ QList<QUrl> urlListProperty() const { return m_urlList; }
+ void setUrlListProperty(const QList<QUrl> &list) { m_urlList = list; emit urlListPropertyChanged(); }
+ QStringList qstringListProperty() const { return m_qstringList; }
+ void setQStringListProperty(const QStringList &list) { m_qstringList = list; emit qstringListPropertyChanged(); }
+ QList<QPoint> pointListProperty() const { return m_pointList; }
+ void setPointListProperty(const QList<QPoint> &list) { m_pointList = list; emit pointListPropertyChanged(); }
+ QList<QVariant> variantListProperty() const { return m_variantList; }
+ void setVariantListProperty(const QList<QVariant> &list) { m_variantList = list; emit variantListPropertyChanged(); }
+
+ // now for "copy resource" sequences:
+ Q_INVOKABLE QList<int> generateIntSequence() const { QList<int> retn; retn << 1 << 2 << 3; return retn; }
+ Q_INVOKABLE QList<qreal> generateQrealSequence() const { QList<qreal> retn; retn << 1.1 << 2.2 << 3.3; return retn; }
+ Q_INVOKABLE QList<bool> generateBoolSequence() const { QList<bool> retn; retn << true << false << true; return retn; }
+ Q_INVOKABLE QList<QString> generateStringSequence() const { QList<QString> retn; retn << "one" << "two" << "three"; return retn; }
+ Q_INVOKABLE QList<QUrl> generateUrlSequence() const { QList<QUrl> retn; retn << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com"); return retn; }
+ Q_INVOKABLE QStringList generateQStringSequence() const { QStringList retn; retn << "one" << "two" << "three"; return retn; }
+
+ // "reference resource" underlying qobject deletion test:
+ Q_INVOKABLE MySequenceConversionObject *generateTestObject() const { return new MySequenceConversionObject; }
+ Q_INVOKABLE void deleteTestObject(QObject *object) const { delete object; }
+
+signals:
+ void intListPropertyChanged();
+ void intListProperty2Changed();
+ void qrealListPropertyChanged();
+ void boolListPropertyChanged();
+ void stringListPropertyChanged();
+ void urlListPropertyChanged();
+ void qstringListPropertyChanged();
+ void pointListPropertyChanged();
+ void variantListPropertyChanged();
+
+private:
+ QList<int> m_intList;
+ QList<int> m_intList2;
+ QList<qreal> m_qrealList;
+ QList<bool> m_boolList;
+ QList<QString> m_stringList;
+ QList<QUrl> m_urlList;
+ QStringList m_qstringList;
+
+ QList<QPoint> m_pointList; // not a supported sequence type
+ QList<QVariant> m_variantList; // not a supported sequence type, but QVariantList support is hardcoded.
+};
+
+class MyDeleteObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QObject *nestedObject READ nestedObject NOTIFY nestedObjectChanged);
+ Q_PROPERTY(int deleteNestedObject READ deleteNestedObject NOTIFY deleteNestedObjectChanged);
+
+public:
+ MyDeleteObject() : m_nestedObject(new MyQmlObject) {}
+
+ QObject *nestedObject() const { return m_nestedObject; }
+ int deleteNestedObject() { delete m_nestedObject; m_nestedObject = 0; return 1; }
+
+signals:
+ void nestedObjectChanged();
+ void deleteNestedObjectChanged();
+
+private:
+ MyQmlObject *m_nestedObject;
+};
+
+void registerTypes();
+
+#endif // TESTTYPES_H
+
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
new file mode 100644
index 0000000000..af219c8826
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -0,0 +1,6062 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qdebug.h>
+#include <QtQml/private/qqmlguard_p.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qnumeric.h>
+#include <private/qqmlengine_p.h>
+#include <private/qqmlvmemetaobject_p.h>
+#include <private/qv4compiler_p.h>
+#include "testtypes.h"
+#include "testhttpserver.h"
+#include "../../shared/util.h"
+
+/*
+This test covers evaluation of ECMAScript expressions and bindings from within
+QML. This does not include static QML language issues.
+
+Static QML language issues are covered in qmllanguage
+*/
+
+class tst_qqmlecmascript : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlecmascript() {}
+
+private slots:
+ void initTestCase();
+ void assignBasicTypes();
+ void idShortcutInvalidates();
+ void boolPropertiesEvaluateAsBool();
+ void methods();
+ void signalAssignment();
+ void bindingLoop();
+ void basicExpressions();
+ void basicExpressions_data();
+ void arrayExpressions();
+ void contextPropertiesTriggerReeval();
+ void objectPropertiesTriggerReeval();
+ void deferredProperties();
+ void deferredPropertiesErrors();
+ void extensionObjects();
+ void overrideExtensionProperties();
+ void attachedProperties();
+ void enums();
+ void valueTypeFunctions();
+ void constantsOverrideBindings();
+ void outerBindingOverridesInnerBinding();
+ void aliasPropertyAndBinding();
+ void aliasPropertyReset();
+ void nonExistentAttachedObject();
+ void scope();
+ void importScope();
+ void signalParameterTypes();
+ void objectsCompareAsEqual();
+ void dynamicCreation_data();
+ void dynamicCreation();
+ void dynamicDestruction();
+ void objectToString();
+ void objectHasOwnProperty();
+ void selfDeletingBinding();
+ void extendedObjectPropertyLookup();
+ void extendedObjectPropertyLookup2();
+ void scriptErrors();
+ void functionErrors();
+ void propertyAssignmentErrors();
+ void signalTriggeredBindings();
+ void listProperties();
+ void exceptionClearsOnReeval();
+ void exceptionSlotProducesWarning();
+ void exceptionBindingProducesWarning();
+ void compileInvalidBinding();
+ void transientErrors();
+ void shutdownErrors();
+ void compositePropertyType();
+ void jsObject();
+ void undefinedResetsProperty();
+ void listToVariant();
+ void listAssignment();
+ void multiEngineObject();
+ void deletedObject();
+ void attachedPropertyScope();
+ void scriptConnect();
+ void scriptDisconnect();
+ void ownership();
+ void cppOwnershipReturnValue();
+ void ownershipCustomReturnValue();
+ void qlistqobjectMethods();
+ void strictlyEquals();
+ void compiled();
+ void numberAssignment();
+ void propertySplicing();
+ void signalWithUnknownTypes();
+ void signalWithJSValueInVariant_data();
+ void signalWithJSValueInVariant();
+ void signalWithJSValueInVariant_twoEngines_data();
+ void signalWithJSValueInVariant_twoEngines();
+ void signalWithQJSValue_data();
+ void signalWithQJSValue();
+ void moduleApi_data();
+ void moduleApi();
+ void importScripts_data();
+ void importScripts();
+ void scarceResources();
+ void scarceResources_data();
+ void scarceResources_other();
+ void propertyChangeSlots();
+ void propertyVar_data();
+ void propertyVar();
+ void propertyVarCpp();
+ void propertyVarOwnership();
+ void propertyVarImplicitOwnership();
+ void propertyVarReparent();
+ void propertyVarReparentNullContext();
+ void propertyVarCircular();
+ void propertyVarCircular2();
+ void propertyVarInheritance();
+ void propertyVarInheritance2();
+ void elementAssign();
+ void objectPassThroughSignals();
+ void objectConversion();
+ void booleanConversion();
+ void handleReferenceManagement();
+ void stringArg();
+ void readonlyDeclaration();
+ void sequenceConversionRead();
+ void sequenceConversionWrite();
+ void sequenceConversionArray();
+ void sequenceConversionIndexes();
+ void sequenceConversionThreads();
+ void sequenceConversionBindings();
+ void sequenceConversionCopy();
+ void assignSequenceTypes();
+ void qtbug_22464();
+ void qtbug_21580();
+
+ void bug1();
+ void bug2();
+ void dynamicCreationCrash();
+ void dynamicCreationOwnership();
+ void regExpBug();
+ void nullObjectBinding();
+ void deletedEngine();
+ void libraryScriptAssert();
+ void variantsAssignedUndefined();
+ void qtbug_9792();
+ void qtcreatorbug_1289();
+ void noSpuriousWarningsAtShutdown();
+ void canAssignNullToQObject();
+ void functionAssignment_fromBinding();
+ void functionAssignment_fromJS();
+ void functionAssignment_fromJS_data();
+ void functionAssignmentfromJS_invalid();
+ void eval();
+ void function();
+ void functionException();
+ void qtbug_10696();
+ void qtbug_11606();
+ void qtbug_11600();
+ void qtbug_21864();
+ void qobjectConnectionListExceptionHandling();
+ void nonscriptable();
+ void deleteLater();
+ void in();
+ void typeOf();
+ void sharedAttachedObject();
+ void objectName();
+ void writeRemovesBinding();
+ void aliasBindingsAssignCorrectly();
+ void aliasBindingsOverrideTarget();
+ void aliasWritesOverrideBindings();
+ void aliasToCompositeElement();
+ void realToInt();
+ void urlProperty();
+ void urlPropertyWithEncoding();
+ void urlListPropertyWithEncoding();
+ void dynamicString();
+ void include();
+ void signalHandlers();
+ void doubleEvaluate();
+ void forInLoop();
+ void nonNotifyable();
+ void deleteWhileBindingRunning();
+ void callQtInvokables();
+ void invokableObjectArg();
+ void invokableObjectRet();
+ void qtbug_20344();
+ void qtbug_22679();
+ void qtbug_22843_data();
+ void qtbug_22843();
+ void rewriteMultiLineStrings();
+ void revisionErrors();
+ void revision();
+ void invokableWithQObjectDerived();
+
+ void automaticSemicolon();
+ void unaryExpression();
+ void switchStatement();
+ void withStatement();
+ void tryStatement();
+
+private:
+ static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
+ QQmlEngine engine;
+};
+
+void tst_qqmlecmascript::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ registerTypes();
+}
+
+void tst_qqmlecmascript::assignBasicTypes()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("assignBasicTypes.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
+ QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
+ QCOMPARE(object->stringProperty(), QString("Hello World!"));
+ QCOMPARE(object->uintProperty(), uint(10));
+ QCOMPARE(object->intProperty(), -19);
+ QCOMPARE((float)object->realProperty(), float(23.2));
+ QCOMPARE((float)object->doubleProperty(), float(-19.75));
+ QCOMPARE((float)object->floatProperty(), float(8.5));
+ QCOMPARE(object->colorProperty(), QColor("red"));
+ QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
+ QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
+ QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
+ QCOMPARE(object->pointProperty(), QPoint(99,13));
+ QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
+ QCOMPARE(object->sizeProperty(), QSize(99, 13));
+ QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
+ QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
+ QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
+ QCOMPARE(object->boolProperty(), true);
+ QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
+ QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
+ QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml")));
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("assignBasicTypes.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
+ QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
+ QCOMPARE(object->stringProperty(), QString("Hello World!"));
+ QCOMPARE(object->uintProperty(), uint(10));
+ QCOMPARE(object->intProperty(), -19);
+ QCOMPARE((float)object->realProperty(), float(23.2));
+ QCOMPARE((float)object->doubleProperty(), float(-19.75));
+ QCOMPARE((float)object->floatProperty(), float(8.5));
+ QCOMPARE(object->colorProperty(), QColor("red"));
+ QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
+ QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
+ QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
+ QCOMPARE(object->pointProperty(), QPoint(99,13));
+ QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
+ QCOMPARE(object->sizeProperty(), QSize(99, 13));
+ QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
+ QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
+ QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
+ QCOMPARE(object->boolProperty(), true);
+ QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
+ QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
+ QCOMPARE(object->urlProperty(), component.url().resolved(QUrl("main.qml")));
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::idShortcutInvalidates()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("idShortcutInvalidates.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->objectProperty() != 0);
+ delete object->objectProperty();
+ QVERIFY(object->objectProperty() == 0);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("idShortcutInvalidates.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->objectProperty() != 0);
+ delete object->objectProperty();
+ QVERIFY(object->objectProperty() == 0);
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::boolPropertiesEvaluateAsBool()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("boolPropertiesEvaluateAsBool.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->stringProperty(), QLatin1String("pass"));
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("boolPropertiesEvaluateAsBool.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->stringProperty(), QLatin1String("pass"));
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::signalAssignment()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("signalAssignment.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->string(), QString());
+ emit object->basicSignal();
+ QCOMPARE(object->string(), QString("pass"));
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("signalAssignment.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->string(), QString());
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25 3 2"));
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::methods()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("methods.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->methodCalled(), false);
+ QCOMPARE(object->methodIntCalled(), false);
+ emit object->basicSignal();
+ QCOMPARE(object->methodCalled(), true);
+ QCOMPARE(object->methodIntCalled(), false);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("methods.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->methodCalled(), false);
+ QCOMPARE(object->methodIntCalled(), false);
+ emit object->basicSignal();
+ QCOMPARE(object->methodCalled(), false);
+ QCOMPARE(object->methodIntCalled(), true);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("methods.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toInt(), 19);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("methods.4.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toInt(), 19);
+ QCOMPARE(object->property("test2").toInt(), 17);
+ QCOMPARE(object->property("test3").toInt(), 16);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("methods.5.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toInt(), 9);
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::bindingLoop()
+{
+ QQmlComponent component(&engine, testFileUrl("bindingLoop.qml"));
+ QString warning = component.url().toString() + ":5:9: QML MyQmlObject: Binding loop detected for property \"stringProperty\"";
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlecmascript::basicExpressions_data()
+{
+ QTest::addColumn<QString>("expression");
+ QTest::addColumn<QVariant>("result");
+ QTest::addColumn<bool>("nest");
+
+ QTest::newRow("Syntax error (self test)") << "{console.log({'a':1'}.a)}" << QVariant() << false;
+ QTest::newRow("Context property") << "a" << QVariant(1944) << false;
+ QTest::newRow("Context property") << "a" << QVariant(1944) << true;
+ QTest::newRow("Context property expression") << "a * 2" << QVariant(3888) << false;
+ QTest::newRow("Context property expression") << "a * 2" << QVariant(3888) << true;
+ QTest::newRow("Overridden context property") << "b" << QVariant("Milk") << false;
+ QTest::newRow("Overridden context property") << "b" << QVariant("Cow") << true;
+ QTest::newRow("Object property") << "object.stringProperty" << QVariant("Object1") << false;
+ QTest::newRow("Object property") << "object.stringProperty" << QVariant("Object1") << true;
+ QTest::newRow("Overridden object property") << "objectOverride.stringProperty" << QVariant("Object2") << false;
+ QTest::newRow("Overridden object property") << "objectOverride.stringProperty" << QVariant("Object3") << true;
+ QTest::newRow("Default object property") << "horseLegs" << QVariant(4) << false;
+ QTest::newRow("Default object property") << "antLegs" << QVariant(6) << false;
+ QTest::newRow("Default object property") << "emuLegs" << QVariant(2) << false;
+ QTest::newRow("Nested default object property") << "horseLegs" << QVariant(4) << true;
+ QTest::newRow("Nested default object property") << "antLegs" << QVariant(7) << true;
+ QTest::newRow("Nested default object property") << "emuLegs" << QVariant(2) << true;
+ QTest::newRow("Nested default object property") << "humanLegs" << QVariant(2) << true;
+ QTest::newRow("Context property override default object property") << "millipedeLegs" << QVariant(100) << true;
+}
+
+void tst_qqmlecmascript::basicExpressions()
+{
+ QFETCH(QString, expression);
+ QFETCH(QVariant, result);
+ QFETCH(bool, nest);
+
+ MyQmlObject object1;
+ MyQmlObject object2;
+ MyQmlObject object3;
+ MyDefaultObject1 default1;
+ MyDefaultObject3 default3;
+ object1.setStringProperty("Object1");
+ object2.setStringProperty("Object2");
+ object3.setStringProperty("Object3");
+
+ QQmlContext context(engine.rootContext());
+ QQmlContext nestedContext(&context);
+
+ context.setContextObject(&default1);
+ context.setContextProperty("a", QVariant(1944));
+ context.setContextProperty("b", QVariant("Milk"));
+ context.setContextProperty("object", &object1);
+ context.setContextProperty("objectOverride", &object2);
+ nestedContext.setContextObject(&default3);
+ nestedContext.setContextProperty("b", QVariant("Cow"));
+ nestedContext.setContextProperty("objectOverride", &object3);
+ nestedContext.setContextProperty("millipedeLegs", QVariant(100));
+
+ MyExpression expr(nest?&nestedContext:&context, expression);
+ QCOMPARE(expr.evaluate(), result);
+}
+
+void tst_qqmlecmascript::arrayExpressions()
+{
+ QObject obj1;
+ QObject obj2;
+ QObject obj3;
+
+ QQmlContext context(engine.rootContext());
+ context.setContextProperty("a", &obj1);
+ context.setContextProperty("b", &obj2);
+ context.setContextProperty("c", &obj3);
+
+ MyExpression expr(&context, "[a, b, c, 10]");
+ QVariant result = expr.evaluate();
+ QCOMPARE(result.userType(), qMetaTypeId<QList<QObject *> >());
+ QList<QObject *> list = qvariant_cast<QList<QObject *> >(result);
+ QCOMPARE(list.count(), 4);
+ QCOMPARE(list.at(0), &obj1);
+ QCOMPARE(list.at(1), &obj2);
+ QCOMPARE(list.at(2), &obj3);
+ QCOMPARE(list.at(3), (QObject *)0);
+}
+
+// Tests that modifying a context property will reevaluate expressions
+void tst_qqmlecmascript::contextPropertiesTriggerReeval()
+{
+ QQmlContext context(engine.rootContext());
+ MyQmlObject object1;
+ MyQmlObject object2;
+ MyQmlObject *object3 = new MyQmlObject;
+
+ object1.setStringProperty("Hello");
+ object2.setStringProperty("World");
+
+ context.setContextProperty("testProp", QVariant(1));
+ context.setContextProperty("testObj", &object1);
+ context.setContextProperty("testObj2", object3);
+
+ {
+ MyExpression expr(&context, "testProp + 1");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.evaluate(), QVariant(2));
+
+ context.setContextProperty("testProp", QVariant(2));
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.evaluate(), QVariant(3));
+ }
+
+ {
+ MyExpression expr(&context, "testProp + testProp + testProp");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.evaluate(), QVariant(6));
+
+ context.setContextProperty("testProp", QVariant(4));
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.evaluate(), QVariant(12));
+ }
+
+ {
+ MyExpression expr(&context, "testObj.stringProperty");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.evaluate(), QVariant("Hello"));
+
+ context.setContextProperty("testObj", &object2);
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.evaluate(), QVariant("World"));
+ }
+
+ {
+ MyExpression expr(&context, "testObj.stringProperty /**/");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.evaluate(), QVariant("World"));
+
+ context.setContextProperty("testObj", &object1);
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.evaluate(), QVariant("Hello"));
+ }
+
+ {
+ MyExpression expr(&context, "testObj2");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.evaluate(), QVariant::fromValue((QObject *)object3));
+ }
+
+ delete object3;
+}
+
+void tst_qqmlecmascript::objectPropertiesTriggerReeval()
+{
+ QQmlContext context(engine.rootContext());
+ MyQmlObject object1;
+ MyQmlObject object2;
+ MyQmlObject object3;
+ context.setContextProperty("testObj", &object1);
+
+ object1.setStringProperty(QLatin1String("Hello"));
+ object2.setStringProperty(QLatin1String("Dog"));
+ object3.setStringProperty(QLatin1String("Cat"));
+
+ {
+ MyExpression expr(&context, "testObj.stringProperty");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.evaluate(), QVariant("Hello"));
+
+ object1.setStringProperty(QLatin1String("World"));
+ QCOMPARE(expr.changed, true);
+ QCOMPARE(expr.evaluate(), QVariant("World"));
+ }
+
+ {
+ MyExpression expr(&context, "testObj.objectProperty.stringProperty");
+ QCOMPARE(expr.changed, false);
+ QCOMPARE(expr.evaluate(), QVariant());
+
+ object1.setObjectProperty(&object2);
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.evaluate(), QVariant("Dog"));
+
+ object1.setObjectProperty(&object3);
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.evaluate(), QVariant("Cat"));
+
+ object1.setObjectProperty(0);
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.evaluate(), QVariant());
+
+ object1.setObjectProperty(&object3);
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.evaluate(), QVariant("Cat"));
+
+ object3.setStringProperty("Donkey");
+ QCOMPARE(expr.changed, true);
+ expr.changed = false;
+ QCOMPARE(expr.evaluate(), QVariant("Donkey"));
+ }
+}
+
+void tst_qqmlecmascript::deferredProperties()
+{
+ QQmlComponent component(&engine, testFileUrl("deferredProperties.qml"));
+ MyDeferredObject *object =
+ qobject_cast<MyDeferredObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->value(), 0);
+ QVERIFY(object->objectProperty() == 0);
+ QVERIFY(object->objectProperty2() != 0);
+ qmlExecuteDeferred(object);
+ QCOMPARE(object->value(), 10);
+ QVERIFY(object->objectProperty() != 0);
+ MyQmlObject *qmlObject =
+ qobject_cast<MyQmlObject *>(object->objectProperty());
+ QVERIFY(qmlObject != 0);
+ QCOMPARE(qmlObject->value(), 10);
+ object->setValue(19);
+ QCOMPARE(qmlObject->value(), 19);
+
+ delete object;
+}
+
+// Check errors on deferred properties are correctly emitted
+void tst_qqmlecmascript::deferredPropertiesErrors()
+{
+ QQmlComponent component(&engine, testFileUrl("deferredPropertiesErrors.qml"));
+ MyDeferredObject *object =
+ qobject_cast<MyDeferredObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->value(), 0);
+ QVERIFY(object->objectProperty() == 0);
+ QVERIFY(object->objectProperty2() == 0);
+
+ QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject*";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ qmlExecuteDeferred(object);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::extensionObjects()
+{
+ QQmlComponent component(&engine, testFileUrl("extensionObjects.qml"));
+ MyExtendedObject *object =
+ qobject_cast<MyExtendedObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->baseProperty(), 13);
+ QCOMPARE(object->coreProperty(), 9);
+ object->setProperty("extendedProperty", QVariant(11));
+ object->setProperty("baseExtendedProperty", QVariant(92));
+ QCOMPARE(object->coreProperty(), 11);
+ QCOMPARE(object->baseProperty(), 92);
+
+ MyExtendedObject *nested = qobject_cast<MyExtendedObject*>(qvariant_cast<QObject *>(object->property("nested")));
+ QVERIFY(nested);
+ QCOMPARE(nested->baseProperty(), 13);
+ QCOMPARE(nested->coreProperty(), 9);
+ nested->setProperty("extendedProperty", QVariant(11));
+ nested->setProperty("baseExtendedProperty", QVariant(92));
+ QCOMPARE(nested->coreProperty(), 11);
+ QCOMPARE(nested->baseProperty(), 92);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::overrideExtensionProperties()
+{
+ QQmlComponent component(&engine, testFileUrl("extensionObjectsPropertyOverride.qml"));
+ OverrideDefaultPropertyObject *object =
+ qobject_cast<OverrideDefaultPropertyObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->secondProperty() != 0);
+ QVERIFY(object->firstProperty() == 0);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::attachedProperties()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("attachedProperty.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("a").toInt(), 19);
+ QCOMPARE(object->property("b").toInt(), 19);
+ QCOMPARE(object->property("c").toInt(), 19);
+ QCOMPARE(object->property("d").toInt(), 19);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("attachedProperty.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("a").toInt(), 26);
+ QCOMPARE(object->property("b").toInt(), 26);
+ QCOMPARE(object->property("c").toInt(), 26);
+ QCOMPARE(object->property("d").toInt(), 26);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("writeAttachedProperty.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QMetaObject::invokeMethod(object, "writeValue2");
+
+ MyQmlAttachedObject *attached =
+ qobject_cast<MyQmlAttachedObject *>(qmlAttachedPropertiesObject<MyQmlObject>(object));
+ QVERIFY(attached != 0);
+
+ QCOMPARE(attached->value2(), 9);
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::enums()
+{
+ // Existent enums
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("a").toInt(), 0);
+ QCOMPARE(object->property("b").toInt(), 1);
+ QCOMPARE(object->property("c").toInt(), 2);
+ QCOMPARE(object->property("d").toInt(), 3);
+ QCOMPARE(object->property("e").toInt(), 0);
+ QCOMPARE(object->property("f").toInt(), 1);
+ QCOMPARE(object->property("g").toInt(), 2);
+ QCOMPARE(object->property("h").toInt(), 3);
+ QCOMPARE(object->property("i").toInt(), 19);
+ QCOMPARE(object->property("j").toInt(), 19);
+
+ delete object;
+ }
+ // Non-existent enums
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.2.qml"));
+
+ QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int";
+ QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("a").toInt(), 0);
+ QCOMPARE(object->property("b").toInt(), 0);
+
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::valueTypeFunctions()
+{
+ QQmlComponent component(&engine, testFileUrl("valueTypeFunctions.qml"));
+ MyTypeObject *obj = qobject_cast<MyTypeObject*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->rectProperty(), QRect(0,0,100,100));
+ QCOMPARE(obj->rectFProperty(), QRectF(0,0.5,100,99.5));
+
+ delete obj;
+}
+
+/*
+Tests that writing a constant to a property with a binding on it disables the
+binding.
+*/
+void tst_qqmlecmascript::constantsOverrideBindings()
+{
+ // From ECMAScript
+ {
+ QQmlComponent component(&engine, testFileUrl("constantsOverrideBindings.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c2").toInt(), 0);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c2").toInt(), 9);
+
+ emit object->basicSignal();
+
+ QCOMPARE(object->property("c2").toInt(), 13);
+ object->setProperty("c1", QVariant(8));
+ QCOMPARE(object->property("c2").toInt(), 13);
+
+ delete object;
+ }
+
+ // During construction
+ {
+ QQmlComponent component(&engine, testFileUrl("constantsOverrideBindings.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c1").toInt(), 0);
+ QCOMPARE(object->property("c2").toInt(), 10);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c2").toInt(), 10);
+
+ delete object;
+ }
+
+#if 0
+ // From C++
+ {
+ QQmlComponent component(&engine, testFileUrl("constantsOverrideBindings.3.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c2").toInt(), 0);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c2").toInt(), 9);
+
+ object->setProperty("c2", QVariant(13));
+ QCOMPARE(object->property("c2").toInt(), 13);
+ object->setProperty("c1", QVariant(7));
+ QCOMPARE(object->property("c1").toInt(), 7);
+ QCOMPARE(object->property("c2").toInt(), 13);
+
+ delete object;
+ }
+#endif
+
+ // Using an alias
+ {
+ QQmlComponent component(&engine, testFileUrl("constantsOverrideBindings.4.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c1").toInt(), 0);
+ QCOMPARE(object->property("c3").toInt(), 10);
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c3").toInt(), 10);
+
+ delete object;
+ }
+}
+
+/*
+Tests that assigning a binding to a property that already has a binding causes
+the original binding to be disabled.
+*/
+void tst_qqmlecmascript::outerBindingOverridesInnerBinding()
+{
+ QQmlComponent component(&engine,
+ testFileUrl("outerBindingOverridesInnerBinding.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c1").toInt(), 0);
+ QCOMPARE(object->property("c2").toInt(), 0);
+ QCOMPARE(object->property("c3").toInt(), 0);
+
+ object->setProperty("c1", QVariant(9));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c2").toInt(), 0);
+ QCOMPARE(object->property("c3").toInt(), 0);
+
+ object->setProperty("c3", QVariant(8));
+ QCOMPARE(object->property("c1").toInt(), 9);
+ QCOMPARE(object->property("c2").toInt(), 8);
+ QCOMPARE(object->property("c3").toInt(), 8);
+
+ delete object;
+}
+
+/*
+Access a non-existent attached object.
+
+Tests for a regression where this used to crash.
+*/
+void tst_qqmlecmascript::nonExistentAttachedObject()
+{
+ QQmlComponent component(&engine, testFileUrl("nonExistentAttachedObject.qml"));
+
+ QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::scope()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("scope.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toInt(), 1);
+ QCOMPARE(object->property("test2").toInt(), 2);
+ QCOMPARE(object->property("test3").toString(), QString("1Test"));
+ QCOMPARE(object->property("test4").toString(), QString("2Test"));
+ QCOMPARE(object->property("test5").toInt(), 1);
+ QCOMPARE(object->property("test6").toInt(), 1);
+ QCOMPARE(object->property("test7").toInt(), 2);
+ QCOMPARE(object->property("test8").toInt(), 2);
+ QCOMPARE(object->property("test9").toInt(), 1);
+ QCOMPARE(object->property("test10").toInt(), 3);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scope.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toInt(), 19);
+ QCOMPARE(object->property("test2").toInt(), 19);
+ QCOMPARE(object->property("test3").toInt(), 14);
+ QCOMPARE(object->property("test4").toInt(), 14);
+ QCOMPARE(object->property("test5").toInt(), 24);
+ QCOMPARE(object->property("test6").toInt(), 24);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scope.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("test3").toBool(), true);
+
+ delete object;
+ }
+
+ // Signal argument scope
+ {
+ QQmlComponent component(&engine, testFileUrl("scope.4.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 0);
+ QCOMPARE(object->property("test2").toString(), QString());
+
+ emit object->argumentSignal(13, "Argument Scope", 9, MyQmlObject::EnumValue4, Qt::RightButton);
+
+ QCOMPARE(object->property("test").toInt(), 13);
+ QCOMPARE(object->property("test2").toString(), QString("Argument Scope"));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scope.5.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scope.6.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+}
+
+// In 4.7, non-library javascript files that had no imports shared the imports of their
+// importing context
+void tst_qqmlecmascript::importScope()
+{
+ QQmlComponent component(&engine, testFileUrl("importScope.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toInt(), 240);
+
+ delete o;
+}
+
+/*
+Tests that "any" type passes through a synthesized signal parameter. This
+is essentially a test of QQmlMetaType::copy()
+*/
+void tst_qqmlecmascript::signalParameterTypes()
+{
+ QQmlComponent component(&engine, testFileUrl("signalParameterTypes.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ emit object->basicSignal();
+
+ QCOMPARE(object->property("intProperty").toInt(), 10);
+ QCOMPARE(object->property("realProperty").toReal(), 19.2);
+ QVERIFY(object->property("colorProperty").value<QColor>() == QColor(255, 255, 0, 255));
+ QVERIFY(object->property("variantProperty") == QVariant::fromValue(QColor(255, 0, 255, 255)));
+ QVERIFY(object->property("enumProperty") == MyQmlObject::EnumValue3);
+ QVERIFY(object->property("qtEnumProperty") == Qt::LeftButton);
+
+ delete object;
+}
+
+/*
+Test that two JS objects for the same QObject compare as equal.
+*/
+void tst_qqmlecmascript::objectsCompareAsEqual()
+{
+ QQmlComponent component(&engine, testFileUrl("objectsCompareAsEqual.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), true);
+ QCOMPARE(object->property("test5").toBool(), true);
+
+ delete object;
+}
+
+/*
+Confirm bindings and alias properties can coexist.
+
+Tests for a regression where the binding would not reevaluate.
+*/
+void tst_qqmlecmascript::aliasPropertyAndBinding()
+{
+ QQmlComponent component(&engine, testFileUrl("aliasPropertyAndBinding.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("c2").toInt(), 3);
+ QCOMPARE(object->property("c3").toInt(), 3);
+
+ object->setProperty("c2", QVariant(19));
+
+ QCOMPARE(object->property("c2").toInt(), 19);
+ QCOMPARE(object->property("c3").toInt(), 19);
+
+ delete object;
+}
+
+/*
+Ensure that we can write undefined value to an alias property,
+and that the aliased property is reset correctly if possible.
+*/
+void tst_qqmlecmascript::aliasPropertyReset()
+{
+ QObject *object = 0;
+
+ // test that a manual write (of undefined) to a resettable aliased property succeeds
+ QQmlComponent c1(&engine, testFileUrl("aliasreset/aliasPropertyReset.1.qml"));
+ object = c1.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() != 0);
+ QCOMPARE(object->property("aliasIsUndefined"), QVariant(false));
+ QMetaObject::invokeMethod(object, "resetAliased");
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0);
+ QCOMPARE(object->property("aliasIsUndefined"), QVariant(true));
+ delete object;
+
+ // test that a manual write (of undefined) to a resettable alias property succeeds
+ QQmlComponent c2(&engine, testFileUrl("aliasreset/aliasPropertyReset.2.qml"));
+ object = c2.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() != 0);
+ QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(false));
+ QMetaObject::invokeMethod(object, "resetAlias");
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0);
+ QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(true));
+ delete object;
+
+ // test that an alias to a bound property works correctly
+ QQmlComponent c3(&engine, testFileUrl("aliasreset/aliasPropertyReset.3.qml"));
+ object = c3.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() != 0);
+ QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(false));
+ QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false));
+ QMetaObject::invokeMethod(object, "resetAlias");
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0);
+ QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(true));
+ QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false));
+ delete object;
+
+ // test that a manual write (of undefined) to a resettable alias property
+ // whose aliased property's object has been deleted, does not crash.
+ QQmlComponent c4(&engine, testFileUrl("aliasreset/aliasPropertyReset.4.qml"));
+ object = c4.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() != 0);
+ QObject *loader = object->findChild<QObject*>("loader");
+ QVERIFY(loader != 0);
+ delete loader;
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0); // deletion should have caused value unset.
+ QMetaObject::invokeMethod(object, "resetAlias"); // shouldn't crash.
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0);
+ QMetaObject::invokeMethod(object, "setAlias"); // shouldn't crash, and shouldn't change value (since it's no longer referencing anything).
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0);
+ delete object;
+
+ // test that binding an alias property to an undefined value works correctly
+ QQmlComponent c5(&engine, testFileUrl("aliasreset/aliasPropertyReset.5.qml"));
+ object = c5.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0); // bound to undefined value.
+ delete object;
+
+ // test that a manual write (of undefined) to a non-resettable property fails properly
+ QUrl url = testFileUrl("aliasreset/aliasPropertyReset.error.1.qml");
+ QString warning1 = url.toString() + QLatin1String(":15: Error: Cannot assign [undefined] to int");
+ QQmlComponent e1(&engine, url);
+ object = e1.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("intAlias").value<int>(), 12);
+ QCOMPARE(object->property("aliasedIntIsUndefined"), QVariant(false));
+ QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
+ QMetaObject::invokeMethod(object, "resetAlias");
+ QCOMPARE(object->property("intAlias").value<int>(), 12);
+ QCOMPARE(object->property("aliasedIntIsUndefined"), QVariant(false));
+ delete object;
+}
+
+void tst_qqmlecmascript::dynamicCreation_data()
+{
+ QTest::addColumn<QString>("method");
+ QTest::addColumn<QString>("createdName");
+
+ QTest::newRow("One") << "createOne" << "objectOne";
+ QTest::newRow("Two") << "createTwo" << "objectTwo";
+ QTest::newRow("Three") << "createThree" << "objectThree";
+}
+
+/*
+Test using createQmlObject to dynamically generate an item
+Also using createComponent is tested.
+*/
+void tst_qqmlecmascript::dynamicCreation()
+{
+ QFETCH(QString, method);
+ QFETCH(QString, createdName);
+
+ QQmlComponent component(&engine, testFileUrl("dynamicCreation.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QMetaObject::invokeMethod(object, method.toUtf8());
+ QObject *created = object->objectProperty();
+ QVERIFY(created);
+ QCOMPARE(created->objectName(), createdName);
+
+ delete object;
+}
+
+/*
+ Tests the destroy function
+*/
+void tst_qqmlecmascript::dynamicDestruction()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("dynamicDeletion.qml"));
+ QQmlGuard<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ QQmlGuard<QObject> createdQmlObject = 0;
+
+ QMetaObject::invokeMethod(object, "create");
+ createdQmlObject = object->objectProperty();
+ QVERIFY(createdQmlObject);
+ QCOMPARE(createdQmlObject->objectName(), QString("emptyObject"));
+
+ QMetaObject::invokeMethod(object, "killOther");
+ QVERIFY(createdQmlObject);
+
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QVERIFY(createdQmlObject);
+ for (int ii = 0; createdQmlObject && ii < 50; ++ii) { // After 5 seconds we should give up
+ if (createdQmlObject) {
+ QTest::qWait(100);
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ }
+ }
+ QVERIFY(!createdQmlObject);
+
+ QQmlEngine::setObjectOwnership(object, QQmlEngine::JavaScriptOwnership);
+ QMetaObject::invokeMethod(object, "killMe");
+ QVERIFY(object);
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QVERIFY(!object);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("dynamicDeletion.2.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0);
+
+ QMetaObject::invokeMethod(o, "create");
+
+ QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) != 0);
+
+ QMetaObject::invokeMethod(o, "destroy");
+
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+
+ QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0);
+
+ delete o;
+ }
+}
+
+/*
+ tests that id.toString() works
+*/
+void tst_qqmlecmascript::objectToString()
+{
+ QQmlComponent component(&engine, testFileUrl("qmlToString.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "testToString");
+ QVERIFY(object->stringProperty().startsWith("MyQmlObject_QML_"));
+ QVERIFY(object->stringProperty().endsWith(", \"objName\")"));
+
+ delete object;
+}
+
+/*
+ tests that id.hasOwnProperty() works
+*/
+void tst_qqmlecmascript::objectHasOwnProperty()
+{
+ QUrl url = testFileUrl("qmlHasOwnProperty.qml");
+ QString warning1 = url.toString() + ":59: TypeError: Cannot call method 'hasOwnProperty' of undefined";
+ QString warning2 = url.toString() + ":64: TypeError: Cannot call method 'hasOwnProperty' of undefined";
+ QString warning3 = url.toString() + ":69: TypeError: Cannot call method 'hasOwnProperty' of undefined";
+
+ QQmlComponent component(&engine, url);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // test QObjects in QML
+ QMetaObject::invokeMethod(object, "testHasOwnPropertySuccess");
+ QVERIFY(object->property("result").value<bool>() == true);
+ QMetaObject::invokeMethod(object, "testHasOwnPropertyFailure");
+ QVERIFY(object->property("result").value<bool>() == false);
+
+ // now test other types in QML
+ QObject *child = object->findChild<QObject*>("typeObj");
+ QVERIFY(child != 0);
+ QMetaObject::invokeMethod(child, "testHasOwnPropertySuccess");
+ QCOMPARE(child->property("valueTypeHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("valueTypeHasOwnProperty2").toBool(), true);
+ QCOMPARE(child->property("variantTypeHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("stringTypeHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("listTypeHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("emptyListTypeHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("enumTypeHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("typenameHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("typenameHasOwnProperty2").toBool(), true);
+ QCOMPARE(child->property("moduleApiTypeHasOwnProperty").toBool(), true);
+ QCOMPARE(child->property("moduleApiPropertyTypeHasOwnProperty").toBool(), true);
+
+ QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
+ QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureOne");
+ QCOMPARE(child->property("enumNonValueHasOwnProperty").toBool(), false);
+ QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
+ QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureTwo");
+ QCOMPARE(child->property("moduleApiNonPropertyHasOwnProperty").toBool(), false);
+ QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
+ QMetaObject::invokeMethod(child, "testHasOwnPropertyFailureThree");
+ QCOMPARE(child->property("listAtInvalidHasOwnProperty").toBool(), false);
+
+ delete object;
+}
+
+/*
+Tests bindings that indirectly cause their own deletion work.
+
+This test is best run under valgrind to ensure no invalid memory access occur.
+*/
+void tst_qqmlecmascript::selfDeletingBinding()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("selfDeletingBinding.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ object->setProperty("triggerDelete", true);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("selfDeletingBinding.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ object->setProperty("triggerDelete", true);
+ delete object;
+ }
+}
+
+/*
+Test that extended object properties can be accessed.
+
+This test a regression where this used to crash. The issue was specificially
+for extended objects that did not include a synthesized meta object (so non-root
+and no synthesiszed properties).
+*/
+void tst_qqmlecmascript::extendedObjectPropertyLookup()
+{
+ QQmlComponent component(&engine, testFileUrl("extendedObjectPropertyLookup.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+/*
+Test that extended object properties can be accessed correctly.
+*/
+void tst_qqmlecmascript::extendedObjectPropertyLookup2()
+{
+ QQmlComponent component(&engine, testFileUrl("extendedObjectPropertyLookup2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVariant returnValue;
+ QVERIFY(QMetaObject::invokeMethod(object, "getValue", Q_RETURN_ARG(QVariant, returnValue)));
+ QCOMPARE(returnValue.toInt(), 42);
+
+ delete object;
+}
+/*
+Test file/lineNumbers for binding/Script errors.
+*/
+void tst_qqmlecmascript::scriptErrors()
+{
+ QQmlComponent component(&engine, testFileUrl("scriptErrors.qml"));
+ QString url = component.url().toString();
+
+ QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\"";
+ QString warning2 = url + ":5: ReferenceError: Can't find variable: a";
+ QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\"";
+ QString warning4 = url + ":13: ReferenceError: Can't find variable: a";
+ QString warning5 = url + ":11: ReferenceError: Can't find variable: a";
+ QString warning6 = url + ":10: Unable to assign [undefined] to int";
+ QString warning7 = url + ":15: Error: Cannot assign to read-only property \"trueProperty\"";
+ QString warning8 = url + ":16: Error: Cannot assign to non-existent property \"fakeProperty\"";
+
+ QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning5.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning6.toLatin1().constData());
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, warning4.toLatin1().constData());
+ emit object->basicSignal();
+
+ QTest::ignoreMessage(QtWarningMsg, warning7.toLatin1().constData());
+ emit object->anotherBasicSignal();
+
+ QTest::ignoreMessage(QtWarningMsg, warning8.toLatin1().constData());
+ emit object->thirdBasicSignal();
+
+ delete object;
+}
+
+/*
+Test file/lineNumbers for inline functions.
+*/
+void tst_qqmlecmascript::functionErrors()
+{
+ QQmlComponent component(&engine, testFileUrl("functionErrors.qml"));
+ QString url = component.url().toString();
+
+ QString warning = url + ":5: Error: Invalid write to global property \"a\"";
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+
+ // test that if an exception occurs while invoking js function from cpp, it is reported as expected.
+ QQmlComponent componentTwo(&engine, testFileUrl("scarceResourceFunctionFail.var.qml"));
+ url = componentTwo.url().toString();
+ object = componentTwo.create();
+ QVERIFY(object != 0);
+
+ QString srpname = object->property("srp_name").toString();
+
+ warning = url + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srpname
+ + QLatin1String(" is not a function");
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); // we expect a meaningful warning to be printed.
+ QMetaObject::invokeMethod(object, "retrieveScarceResource");
+ delete object;
+}
+
+/*
+Test various errors that can occur when assigning a property from script
+*/
+void tst_qqmlecmascript::propertyAssignmentErrors()
+{
+ QQmlComponent component(&engine, testFileUrl("propertyAssignmentErrors.qml"));
+
+ QString url = component.url().toString();
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+
+ delete object;
+}
+
+/*
+Test bindings still work when the reeval is triggered from within
+a signal script.
+*/
+void tst_qqmlecmascript::signalTriggeredBindings()
+{
+ QQmlComponent component(&engine, testFileUrl("signalTriggeredBindings.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("base").toReal(), 50.);
+ QCOMPARE(object->property("test1").toReal(), 50.);
+ QCOMPARE(object->property("test2").toReal(), 50.);
+
+ object->basicSignal();
+
+ QCOMPARE(object->property("base").toReal(), 200.);
+ QCOMPARE(object->property("test1").toReal(), 200.);
+ QCOMPARE(object->property("test2").toReal(), 200.);
+
+ object->argumentSignal(10, QString(), 10, MyQmlObject::EnumValue4, Qt::RightButton);
+
+ QCOMPARE(object->property("base").toReal(), 400.);
+ QCOMPARE(object->property("test1").toReal(), 400.);
+ QCOMPARE(object->property("test2").toReal(), 400.);
+
+ delete object;
+}
+
+/*
+Test that list properties can be iterated from ECMAScript
+*/
+void tst_qqmlecmascript::listProperties()
+{
+ QQmlComponent component(&engine, testFileUrl("listProperties.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toInt(), 21);
+ QCOMPARE(object->property("test2").toInt(), 2);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::exceptionClearsOnReeval()
+{
+ QQmlComponent component(&engine, testFileUrl("exceptionClearsOnReeval.qml"));
+ QString url = component.url().toString();
+
+ QString warning = url + ":4: TypeError: Cannot read property 'objectProperty' of null";
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), false);
+
+ MyQmlObject object2;
+ MyQmlObject object3;
+ object2.setObjectProperty(&object3);
+ object->setObjectProperty(&object2);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::exceptionSlotProducesWarning()
+{
+ QQmlComponent component(&engine, testFileUrl("exceptionProducesWarning.qml"));
+ QString url = component.url().toString();
+
+ QString warning = component.url().toString() + ":6: Error: JS exception";
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlecmascript::exceptionBindingProducesWarning()
+{
+ QQmlComponent component(&engine, testFileUrl("exceptionProducesWarning2.qml"));
+ QString url = component.url().toString();
+
+ QString warning = component.url().toString() + ":5: Error: JS exception";
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlecmascript::compileInvalidBinding()
+{
+ // QTBUG-23387: ensure that invalid bindings don't cause a crash.
+ QQmlComponent component(&engine, testFileUrl("v8bindingException.qml"));
+ QString warning = component.url().toString() + ":16: SyntaxError: Unexpected token ILLEGAL";
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+static int transientErrorsMsgCount = 0;
+static void transientErrorsMsgHandler(QtMsgType, const char *)
+{
+ ++transientErrorsMsgCount;
+}
+
+// Check that transient binding errors are not displayed
+void tst_qqmlecmascript::transientErrors()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("transientErrors.qml"));
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ qInstallMsgHandler(old);
+
+ QCOMPARE(transientErrorsMsgCount, 0);
+
+ delete object;
+ }
+
+ // One binding erroring multiple times, but then resolving
+ {
+ QQmlComponent component(&engine, testFileUrl("transientErrors.2.qml"));
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ qInstallMsgHandler(old);
+
+ QCOMPARE(transientErrorsMsgCount, 0);
+
+ delete object;
+ }
+}
+
+// Check that errors during shutdown are minimized
+void tst_qqmlecmascript::shutdownErrors()
+{
+ QQmlComponent component(&engine, testFileUrl("shutdownErrors.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ delete object;
+
+ qInstallMsgHandler(old);
+ QCOMPARE(transientErrorsMsgCount, 0);
+}
+
+void tst_qqmlecmascript::compositePropertyType()
+{
+ QQmlComponent component(&engine, testFileUrl("compositePropertyType.qml"));
+
+ QTest::ignoreMessage(QtDebugMsg, "hello world");
+ QObject *object = qobject_cast<QObject *>(component.create());
+ delete object;
+}
+
+// QTBUG-5759
+void tst_qqmlecmascript::jsObject()
+{
+ QQmlComponent component(&engine, testFileUrl("jsObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 92);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::undefinedResetsProperty()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("undefinedResetsProperty.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("resettableProperty").toInt(), 92);
+
+ object->setProperty("setUndefined", true);
+
+ QCOMPARE(object->property("resettableProperty").toInt(), 13);
+
+ object->setProperty("setUndefined", false);
+
+ QCOMPARE(object->property("resettableProperty").toInt(), 92);
+
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("undefinedResetsProperty.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("resettableProperty").toInt(), 19);
+
+ QMetaObject::invokeMethod(object, "doReset");
+
+ QCOMPARE(object->property("resettableProperty").toInt(), 13);
+
+ delete object;
+ }
+}
+
+// Aliases to variant properties should work
+void tst_qqmlecmascript::qtbug_22464()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_22464.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::qtbug_21580()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_21580.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// QTBUG-6781
+void tst_qqmlecmascript::bug1()
+{
+ QQmlComponent component(&engine, testFileUrl("bug.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 14);
+
+ object->setProperty("a", 11);
+
+ QCOMPARE(object->property("test").toInt(), 3);
+
+ object->setProperty("b", true);
+
+ QCOMPARE(object->property("test").toInt(), 9);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::bug2()
+{
+ QQmlComponent component(&engine);
+ component.setData("import Qt.test 1.0;\nQPlainTextEdit { width: 100 }", QUrl());
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ delete object;
+}
+
+// Don't crash in createObject when the component has errors.
+void tst_qqmlecmascript::dynamicCreationCrash()
+{
+ QQmlComponent component(&engine, testFileUrl("dynamicCreation.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ QMetaObject::invokeMethod(object, "dontCrash");
+ QObject *created = object->objectProperty();
+ QVERIFY(created == 0);
+
+ delete object;
+}
+
+// ownership transferred to JS, ensure that GC runs the dtor
+void tst_qqmlecmascript::dynamicCreationOwnership()
+{
+ int dtorCount = 0;
+ int expectedDtorCount = 1; // start at 1 since we expect mdcdo to dtor too.
+
+ // allow the engine to go out of scope too.
+ {
+ QQmlEngine dcoEngine;
+ QQmlComponent component(&dcoEngine, testFileUrl("dynamicCreationOwnership.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ MyDynamicCreationDestructionObject *mdcdo = object->findChild<MyDynamicCreationDestructionObject*>("mdcdo");
+ QVERIFY(mdcdo != 0);
+ mdcdo->setDtorCount(&dtorCount);
+
+ for (int i = 1; i < 105; ++i, ++expectedDtorCount) {
+ QMetaObject::invokeMethod(object, "dynamicallyCreateJsOwnedObject");
+ if (i % 90 == 0) {
+ // we do this once manually, but it should be done automatically
+ // when the engine goes out of scope (since it should gc in dtor)
+ QMetaObject::invokeMethod(object, "performGc");
+ }
+ if (i % 10 == 0) {
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ }
+ }
+
+ delete object;
+ }
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, expectedDtorCount);
+}
+
+void tst_qqmlecmascript::regExpBug()
+{
+ //QTBUG-9367
+ {
+ QQmlComponent component(&engine, testFileUrl("regExp.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->regExp().pattern(), QLatin1String("[a-zA-z]"));
+ delete object;
+ }
+
+ //QTBUG-23068
+ {
+ QString err = QString(QLatin1String("%1:6 Invalid property assignment: regular expression expected; use /pattern/ syntax\n")).arg(testFileUrl("regExp.2.qml").toString());
+ QQmlComponent component(&engine, testFileUrl("regExp.2.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(!object);
+ QCOMPARE(component.errorString(), err);
+ }
+}
+
+static inline bool evaluate_error(QV8Engine *engine, v8::Handle<v8::Object> o, const char *source)
+{
+ QString functionSource = QLatin1String("(function(object) { return ") +
+ QLatin1String(source) + QLatin1String(" })");
+ v8::TryCatch tc;
+ v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource));
+ if (tc.HasCaught())
+ return false;
+ v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run());
+ if (function.IsEmpty())
+ return false;
+ v8::Handle<v8::Value> args[] = { o };
+ function->Call(engine->global(), 1, args);
+ return tc.HasCaught();
+}
+
+static inline bool evaluate_value(QV8Engine *engine, v8::Handle<v8::Object> o,
+ const char *source, v8::Handle<v8::Value> result)
+{
+ QString functionSource = QLatin1String("(function(object) { return ") +
+ QLatin1String(source) + QLatin1String(" })");
+ v8::TryCatch tc;
+ v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource));
+ if (tc.HasCaught())
+ return false;
+ v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run());
+ if (function.IsEmpty())
+ return false;
+ v8::Handle<v8::Value> args[] = { o };
+
+ v8::Handle<v8::Value> value = function->Call(engine->global(), 1, args);
+
+ if (tc.HasCaught())
+ return false;
+
+ return value->StrictEquals(result);
+}
+
+static inline v8::Handle<v8::Value> evaluate(QV8Engine *engine, v8::Handle<v8::Object> o,
+ const char *source)
+{
+ QString functionSource = QLatin1String("(function(object) { return ") +
+ QLatin1String(source) + QLatin1String(" })");
+ v8::TryCatch tc;
+ v8::Local<v8::Script> program = v8::Script::Compile(engine->toString(functionSource));
+ if (tc.HasCaught())
+ return v8::Handle<v8::Value>();
+ v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(program->Run());
+ if (function.IsEmpty())
+ return v8::Handle<v8::Value>();
+ v8::Handle<v8::Value> args[] = { o };
+
+ v8::Handle<v8::Value> value = function->Call(engine->global(), 1, args);
+
+ if (tc.HasCaught())
+ return v8::Handle<v8::Value>();
+ return value;
+}
+
+#define EVALUATE_ERROR(source) evaluate_error(engine, object, source)
+#define EVALUATE_VALUE(source, result) evaluate_value(engine, object, source, result)
+#define EVALUATE(source) evaluate(engine, object, source)
+
+void tst_qqmlecmascript::callQtInvokables()
+{
+ MyInvokableObject o;
+
+ QQmlEngine qmlengine;
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(&qmlengine);
+
+ QV8Engine *engine = ep->v8engine();
+
+ v8::HandleScope handle_scope;
+ v8::Context::Scope scope(engine->context());
+
+ v8::Local<v8::Object> object = engine->newQObject(&o)->ToObject();
+
+ // Non-existent methods
+ o.reset();
+ QVERIFY(EVALUATE_ERROR("object.method_nonexistent()"));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QVERIFY(EVALUATE_ERROR("object.method_nonexistent(10, 11)"));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ // Insufficient arguments
+ o.reset();
+ QVERIFY(EVALUATE_ERROR("object.method_int()"));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QVERIFY(EVALUATE_ERROR("object.method_intint(10)"));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ // Excessive arguments
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_int(10, 11)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(10));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_intint(10, 11, 12)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 9);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(10));
+ QCOMPARE(o.actuals().at(1), QVariant(11));
+
+ // Test return types
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_NoArgs()", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 0);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_NoArgs_int()", v8::Integer::New(6)));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_NoArgs_real()", v8::Number::New(19.75)));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 2);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ {
+ v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QPointF()");
+ QVERIFY(!ret.IsEmpty());
+ QCOMPARE(engine->toVariant(ret, -1), QVariant(QPointF(123, 4.5)));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 3);
+ QCOMPARE(o.actuals().count(), 0);
+ }
+
+ o.reset();
+ {
+ v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QObject()");
+ QCOMPARE(engine->toQObject(ret), (QObject *)&o);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 4);
+ QCOMPARE(o.actuals().count(), 0);
+ }
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_NoArgs_unknown()", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 5);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ {
+ v8::Handle<v8::Value> ret = EVALUATE("object.method_NoArgs_QScriptValue()");
+ QVERIFY(ret->IsString());
+ QCOMPARE(engine->toString(ret), QString("Hello world"));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 6);
+ QCOMPARE(o.actuals().count(), 0);
+ }
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_NoArgs_QVariant()", engine->toString("QML rocks")));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 7);
+ QCOMPARE(o.actuals().count(), 0);
+
+ // Test arg types
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_int(94)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(94));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_int(\"94\")", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(94));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_int(\"not a number\")", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_int(null)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_int(undefined)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_int(object)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 8);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_intint(122, 9)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 9);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(122));
+ QCOMPARE(o.actuals().at(1), QVariant(9));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_real(94.3)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(94.3));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_real(\"94.3\")", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(94.3));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_real(\"not a number\")", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_real(null)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_real(undefined)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_real(object)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 10);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qIsNaN(o.actuals().at(0).toDouble()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QString(\"Hello world\")", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant("Hello world"));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QString(19)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant("19"));
+
+ o.reset();
+ {
+ QString expected = "MyInvokableObject(0x" + QString::number((quintptr)&o, 16) + ")";
+ QVERIFY(EVALUATE_VALUE("object.method_QString(object)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(expected));
+ }
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QString(null)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QString()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QString(undefined)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 11);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QString()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QPointF(0)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QPointF(null)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QPointF(undefined)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QPointF(object)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF()));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QPointF(object.method_get_QPointF())", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF(99.3, -10.2)));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QPointF(object.method_get_QPoint())", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 12);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QPointF(9, 12)));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QObject(0)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QObject(\"Hello world\")", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QObject(null)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QObject(undefined)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)0));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QObject(object)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 13);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), qVariantFromValue((QObject *)&o));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(null)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 14);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(0)).isNull());
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(undefined)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 14);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(0)).isUndefined());
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QScriptValue(19)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 14);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(0)).strictlyEquals(QJSValue(19)));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QScriptValue([19, 20])", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 14);
+ QCOMPARE(o.actuals().count(), 1);
+ QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(0)).isArray());
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(4, null)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 15);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(4));
+ QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(1)).isNull());
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(8, undefined)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 15);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(8));
+ QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(1)).isUndefined());
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(3, 19)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 15);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(3));
+ QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(1)).strictlyEquals(QJSValue(19)));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_intQScriptValue(44, [19, 20])", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 15);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(44));
+ QVERIFY(qvariant_cast<QJSValue>(o.actuals().at(1)).isArray());
+
+ o.reset();
+ QVERIFY(EVALUATE_ERROR("object.method_overload()"));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -1);
+ QCOMPARE(o.actuals().count(), 0);
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_overload(10)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 16);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(10));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_overload(10, 11)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 17);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(10));
+ QCOMPARE(o.actuals().at(1), QVariant(11));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_overload(\"Hello\")", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 18);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(QString("Hello")));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_with_enum(9)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 19);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(9));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_default(10)", v8::Integer::New(19)));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 20);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(10));
+ QCOMPARE(o.actuals().at(1), QVariant(19));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_default(10, 13)", v8::Integer::New(13)));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 20);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(10));
+ QCOMPARE(o.actuals().at(1), QVariant(13));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_inherited(9)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), -3);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(9));
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QVariant(9)", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 21);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(9));
+ QCOMPARE(o.actuals().at(1), QVariant());
+
+ o.reset();
+ QVERIFY(EVALUATE_VALUE("object.method_QVariant(\"Hello\", \"World\")", v8::Undefined()));
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 21);
+ QCOMPARE(o.actuals().count(), 2);
+ QCOMPARE(o.actuals().at(0), QVariant(QString("Hello")));
+ QCOMPARE(o.actuals().at(1), QVariant(QString("World")));
+}
+
+// QTBUG-13047 (check that you can pass registered object types as args)
+void tst_qqmlecmascript::invokableObjectArg()
+{
+ QQmlComponent component(&engine, testFileUrl("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_qqmlecmascript::invokableObjectRet()
+{
+ QQmlComponent component(&engine, testFileUrl("invokableObjectRet.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+// QTBUG-5675
+void tst_qqmlecmascript::listToVariant()
+{
+ QQmlComponent component(&engine, testFileUrl("listToVariant.qml"));
+
+ MyQmlContainer container;
+
+ QQmlContext context(engine.rootContext());
+ context.setContextObject(&container);
+
+ QObject *object = component.create(&context);
+ QVERIFY(object != 0);
+
+ QVariant v = object->property("test");
+ QCOMPARE(v.userType(), qMetaTypeId<QQmlListReference>());
+ QVERIFY(qvariant_cast<QQmlListReference>(v).object() == &container);
+
+ delete object;
+}
+
+// QTBUG-16316
+Q_DECLARE_METATYPE(QQmlListProperty<MyQmlObject>)
+void tst_qqmlecmascript::listAssignment()
+{
+ QQmlComponent component(&engine, testFileUrl("listAssignment.qml"));
+ QObject *obj = component.create();
+ QCOMPARE(obj->property("list1length").toInt(), 2);
+ QQmlListProperty<MyQmlObject> list1 = obj->property("list1").value<QQmlListProperty<MyQmlObject> >();
+ QQmlListProperty<MyQmlObject> list2 = obj->property("list2").value<QQmlListProperty<MyQmlObject> >();
+ QCOMPARE(list1.count(&list1), list2.count(&list2));
+ QCOMPARE(list1.at(&list1, 0), list2.at(&list2, 0));
+ QCOMPARE(list1.at(&list1, 1), list2.at(&list2, 1));
+ delete obj;
+}
+
+// QTBUG-7957
+void tst_qqmlecmascript::multiEngineObject()
+{
+ MyQmlObject obj;
+ obj.setStringProperty("Howdy planet");
+
+ QQmlEngine e1;
+ e1.rootContext()->setContextProperty("thing", &obj);
+ QQmlComponent c1(&e1, testFileUrl("multiEngineObject.qml"));
+
+ QQmlEngine e2;
+ e2.rootContext()->setContextProperty("thing", &obj);
+ QQmlComponent c2(&e2, testFileUrl("multiEngineObject.qml"));
+
+ QObject *o1 = c1.create();
+ QObject *o2 = c2.create();
+
+ QCOMPARE(o1->property("test").toString(), QString("Howdy planet"));
+ QCOMPARE(o2->property("test").toString(), QString("Howdy planet"));
+
+ delete o2;
+ delete o1;
+}
+
+// Test that references to QObjects are cleanup when the object is destroyed
+void tst_qqmlecmascript::deletedObject()
+{
+ QQmlComponent component(&engine, testFileUrl("deletedObject.qml"));
+
+ QObject *object = component.create();
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::attachedPropertyScope()
+{
+ QQmlComponent component(&engine, testFileUrl("attachedPropertyScope.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ MyQmlAttachedObject *attached =
+ qobject_cast<MyQmlAttachedObject *>(qmlAttachedPropertiesObject<MyQmlObject>(object));
+ QVERIFY(attached != 0);
+
+ QCOMPARE(object->property("value2").toInt(), 0);
+
+ attached->emitMySignal();
+
+ QCOMPARE(object->property("value2").toInt(), 9);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::scriptConnect()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptConnect.1.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), false);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptConnect.2.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), false);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptConnect.3.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), false);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptConnect.4.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->methodCalled(), false);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->methodCalled(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptConnect.5.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->methodCalled(), false);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->methodCalled(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptConnect.6.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 0);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 2);
+
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::scriptDisconnect()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptDisconnect.1.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 0);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 1);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 2);
+ emit object->basicSignal();
+ QCOMPARE(object->property("test").toInt(), 2);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 2);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptDisconnect.2.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 0);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 1);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 2);
+ emit object->basicSignal();
+ QCOMPARE(object->property("test").toInt(), 2);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 2);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptDisconnect.3.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 0);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 1);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 2);
+ emit object->basicSignal();
+ QCOMPARE(object->property("test").toInt(), 2);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 3);
+
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("scriptDisconnect.4.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 0);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 1);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 2);
+ emit object->basicSignal();
+ QCOMPARE(object->property("test").toInt(), 2);
+ emit object->argumentSignal(19, "Hello world!", 10.25, MyQmlObject::EnumValue4, Qt::RightButton);
+ QCOMPARE(object->property("test").toInt(), 3);
+
+ delete object;
+ }
+}
+
+class OwnershipObject : public QObject
+{
+ Q_OBJECT
+public:
+ OwnershipObject() { object = new QObject; }
+
+ QPointer<QObject> object;
+
+public slots:
+ QObject *getObject() { return object; }
+};
+
+void tst_qqmlecmascript::ownership()
+{
+ OwnershipObject own;
+ QQmlContext *context = new QQmlContext(engine.rootContext());
+ context->setContextObject(&own);
+
+ {
+ QQmlComponent component(&engine, testFileUrl("ownership.qml"));
+
+ QVERIFY(own.object != 0);
+
+ QObject *object = component.create(context);
+
+ engine.collectGarbage();
+
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+
+ QVERIFY(own.object == 0);
+
+ delete object;
+ }
+
+ own.object = new QObject(&own);
+
+ {
+ QQmlComponent component(&engine, testFileUrl("ownership.qml"));
+
+ QVERIFY(own.object != 0);
+
+ QObject *object = component.create(context);
+
+ engine.collectGarbage();
+
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+
+ QVERIFY(own.object != 0);
+
+ delete object;
+ }
+
+ delete context;
+}
+
+class CppOwnershipReturnValue : public QObject
+{
+ Q_OBJECT
+public:
+ CppOwnershipReturnValue() : value(0) {}
+ ~CppOwnershipReturnValue() { delete value; }
+
+ Q_INVOKABLE QObject *create() {
+ value = new QObject;
+ QQmlEngine::setObjectOwnership(value, QQmlEngine::CppOwnership);
+ return value;
+ }
+
+ Q_INVOKABLE MyQmlObject *createQmlObject() {
+ MyQmlObject *rv = new MyQmlObject;
+ value = rv;
+ return rv;
+ }
+
+ QPointer<QObject> value;
+};
+
+// QTBUG-15695.
+// Test setObjectOwnership(CppOwnership) works even when there is no QQmlData
+void tst_qqmlecmascript::cppOwnershipReturnValue()
+{
+ CppOwnershipReturnValue source;
+
+ {
+ QQmlEngine engine;
+ engine.rootContext()->setContextProperty("source", &source);
+
+ QVERIFY(source.value == 0);
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nQtObject {\nComponent.onCompleted: { var a = source.create(); }\n}\n", QUrl());
+
+ QObject *object = component.create();
+
+ QVERIFY(object != 0);
+ QVERIFY(source.value != 0);
+
+ delete object;
+ }
+
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+
+ QVERIFY(source.value != 0);
+}
+
+// QTBUG-15697
+void tst_qqmlecmascript::ownershipCustomReturnValue()
+{
+ CppOwnershipReturnValue source;
+
+ {
+ QQmlEngine engine;
+ engine.rootContext()->setContextProperty("source", &source);
+
+ QVERIFY(source.value == 0);
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nQtObject {\nComponent.onCompleted: { var a = source.createQmlObject(); }\n}\n", QUrl());
+
+ QObject *object = component.create();
+
+ QVERIFY(object != 0);
+ QVERIFY(source.value != 0);
+
+ delete object;
+ }
+
+ engine.collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+
+ QVERIFY(source.value == 0);
+}
+
+class QListQObjectMethodsObject : public QObject
+{
+ Q_OBJECT
+public:
+ QListQObjectMethodsObject() {
+ m_objects.append(new MyQmlObject());
+ m_objects.append(new MyQmlObject());
+ }
+
+ ~QListQObjectMethodsObject() {
+ qDeleteAll(m_objects);
+ }
+
+public slots:
+ QList<QObject *> getObjects() { return m_objects; }
+
+private:
+ QList<QObject *> m_objects;
+};
+
+// Tests that returning a QList<QObject*> from a method works
+void tst_qqmlecmascript::qlistqobjectMethods()
+{
+ QListQObjectMethodsObject obj;
+ QQmlContext *context = new QQmlContext(engine.rootContext());
+ context->setContextObject(&obj);
+
+ QQmlComponent component(&engine, testFileUrl("qlistqobjectMethods.qml"));
+
+ QObject *object = component.create(context);
+
+ QCOMPARE(object->property("test").toInt(), 2);
+ QCOMPARE(object->property("test2").toBool(), true);
+
+ delete object;
+ delete context;
+}
+
+// QTBUG-9205
+void tst_qqmlecmascript::strictlyEquals()
+{
+ QQmlComponent component(&engine, testFileUrl("strictlyEquals.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), true);
+ QCOMPARE(object->property("test5").toBool(), true);
+ QCOMPARE(object->property("test6").toBool(), true);
+ QCOMPARE(object->property("test7").toBool(), true);
+ QCOMPARE(object->property("test8").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::compiled()
+{
+ QQmlComponent component(&engine, testFileUrl("compiled.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toReal(), qreal(15.7));
+ QCOMPARE(object->property("test2").toReal(), qreal(-6.7));
+ QCOMPARE(object->property("test3").toBool(), true);
+ QCOMPARE(object->property("test4").toBool(), false);
+ QCOMPARE(object->property("test5").toBool(), false);
+ QCOMPARE(object->property("test6").toBool(), true);
+
+ QCOMPARE(object->property("test7").toInt(), 185);
+ QCOMPARE(object->property("test8").toInt(), 167);
+ QCOMPARE(object->property("test9").toBool(), true);
+ QCOMPARE(object->property("test10").toBool(), false);
+ QCOMPARE(object->property("test11").toBool(), false);
+ QCOMPARE(object->property("test12").toBool(), true);
+
+ QCOMPARE(object->property("test13").toString(), QLatin1String("HelloWorld"));
+ QCOMPARE(object->property("test14").toString(), QLatin1String("Hello World"));
+ QCOMPARE(object->property("test15").toBool(), false);
+ QCOMPARE(object->property("test16").toBool(), true);
+
+ QCOMPARE(object->property("test17").toInt(), 5);
+ QCOMPARE(object->property("test18").toReal(), qreal(176));
+ QCOMPARE(object->property("test19").toInt(), 7);
+ QCOMPARE(object->property("test20").toReal(), qreal(6.7));
+ QCOMPARE(object->property("test21").toString(), QLatin1String("6.7"));
+ QCOMPARE(object->property("test22").toString(), QLatin1String("!"));
+ QCOMPARE(object->property("test23").toBool(), true);
+ QCOMPARE(qvariant_cast<QColor>(object->property("test24")), QColor(0x11,0x22,0x33));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test25")), QColor(0x11,0x22,0x33,0xAA));
+
+ delete object;
+}
+
+// Test that numbers assigned in bindings as strings work consistently
+void tst_qqmlecmascript::numberAssignment()
+{
+ QQmlComponent component(&engine, testFileUrl("numberAssignment.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1"), QVariant((qreal)6.7));
+ QCOMPARE(object->property("test2"), QVariant((qreal)6.7));
+ QCOMPARE(object->property("test2"), QVariant((qreal)6.7));
+ QCOMPARE(object->property("test3"), QVariant((qreal)6));
+ QCOMPARE(object->property("test4"), QVariant((qreal)6));
+
+ QCOMPARE(object->property("test5"), QVariant((int)7));
+ QCOMPARE(object->property("test6"), QVariant((int)7));
+ QCOMPARE(object->property("test7"), QVariant((int)6));
+ QCOMPARE(object->property("test8"), QVariant((int)6));
+
+ QCOMPARE(object->property("test9"), QVariant((unsigned int)7));
+ QCOMPARE(object->property("test10"), QVariant((unsigned int)7));
+ QCOMPARE(object->property("test11"), QVariant((unsigned int)6));
+ QCOMPARE(object->property("test12"), QVariant((unsigned int)6));
+
+ delete object;
+}
+
+void tst_qqmlecmascript::propertySplicing()
+{
+ QQmlComponent component(&engine, testFileUrl("propertySplicing.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// QTBUG-16683
+void tst_qqmlecmascript::signalWithUnknownTypes()
+{
+ QQmlComponent component(&engine, testFileUrl("signalWithUnknownTypes.qml"));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ MyQmlObject::MyType type;
+ type.value = 0x8971123;
+ emit object->signalWithUnknownType(type);
+
+ MyQmlObject::MyType result = qvariant_cast<MyQmlObject::MyType>(object->variant());
+
+ QCOMPARE(result.value, type.value);
+
+
+ delete object;
+}
+
+void tst_qqmlecmascript::signalWithJSValueInVariant_data()
+{
+ QTest::addColumn<QString>("expression");
+ QTest::addColumn<QString>("compare");
+
+ QString compareStrict("(function(a, b) { return a === b; })");
+ QTest::newRow("true") << "true" << compareStrict;
+ QTest::newRow("undefined") << "undefined" << compareStrict;
+ QTest::newRow("null") << "null" << compareStrict;
+ QTest::newRow("123") << "123" << compareStrict;
+ QTest::newRow("'ciao'") << "'ciao'" << compareStrict;
+
+ QString comparePropertiesStrict(
+ "(function(a, b) {"
+ " if (typeof b != 'object')"
+ " return a === b;"
+ " var props = Object.getOwnPropertyNames(b);"
+ " for (var i = 0; i < props.length; ++i) {"
+ " var p = props[i];"
+ " return arguments.callee(a[p], b[p]);"
+ " }"
+ "})");
+ QTest::newRow("{ foo: 'bar' }") << "({ foo: 'bar' })" << comparePropertiesStrict;
+ QTest::newRow("[10,20,30]") << "[10,20,30]" << comparePropertiesStrict;
+}
+
+void tst_qqmlecmascript::signalWithJSValueInVariant()
+{
+ QFETCH(QString, expression);
+ QFETCH(QString, compare);
+
+ QQmlComponent component(&engine, testFileUrl("signalWithJSValueInVariant.qml"));
+ QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
+ QVERIFY(object != 0);
+
+ QJSValue value = engine.evaluate(expression);
+ QVERIFY(!engine.hasUncaughtException());
+ object->setProperty("expression", expression);
+ object->setProperty("compare", compare);
+ object->setProperty("pass", false);
+
+ emit object->signalWithVariant(QVariant::fromValue(value));
+ QVERIFY(object->property("pass").toBool());
+}
+
+void tst_qqmlecmascript::signalWithJSValueInVariant_twoEngines_data()
+{
+ signalWithJSValueInVariant_data();
+}
+
+void tst_qqmlecmascript::signalWithJSValueInVariant_twoEngines()
+{
+ QFETCH(QString, expression);
+ QFETCH(QString, compare);
+
+ QQmlComponent component(&engine, testFileUrl("signalWithJSValueInVariant.qml"));
+ QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
+ QVERIFY(object != 0);
+
+ QJSEngine engine2;
+ QJSValue value = engine2.evaluate(expression);
+ QVERIFY(!engine2.hasUncaughtException());
+ object->setProperty("expression", expression);
+ object->setProperty("compare", compare);
+ object->setProperty("pass", false);
+
+ QTest::ignoreMessage(QtWarningMsg, "JSValue can't be rassigned to an another engine.");
+ emit object->signalWithVariant(QVariant::fromValue(value));
+ QVERIFY(!object->property("pass").toBool());
+}
+
+void tst_qqmlecmascript::signalWithQJSValue_data()
+{
+ signalWithJSValueInVariant_data();
+}
+
+void tst_qqmlecmascript::signalWithQJSValue()
+{
+ QFETCH(QString, expression);
+ QFETCH(QString, compare);
+
+ QQmlComponent component(&engine, testFileUrl("signalWithQJSValue.qml"));
+ QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
+ QVERIFY(object != 0);
+
+ QJSValue value = engine.evaluate(expression);
+ QVERIFY(!engine.hasUncaughtException());
+ object->setProperty("expression", expression);
+ object->setProperty("compare", compare);
+ object->setProperty("pass", false);
+
+ emit object->signalWithQJSValue(value);
+
+ QVERIFY(object->property("pass").toBool());
+ QVERIFY(object->qjsvalue().strictlyEquals(value));
+}
+
+void tst_qqmlecmascript::moduleApi_data()
+{
+ QTest::addColumn<QUrl>("testfile");
+ QTest::addColumn<QString>("errorMessage");
+ QTest::addColumn<QStringList>("warningMessages");
+ QTest::addColumn<QStringList>("readProperties");
+ QTest::addColumn<QVariantList>("readExpectedValues");
+ QTest::addColumn<QStringList>("writeProperties");
+ QTest::addColumn<QVariantList>("writeValues");
+ QTest::addColumn<QStringList>("readBackProperties");
+ QTest::addColumn<QVariantList>("readBackExpectedValues");
+
+ QTest::newRow("qobject, register + read + method")
+ << testFileUrl("moduleapi/qobjectModuleApi.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << "existingUriTest" << "qobjectTest" << "qobjectMethodTest"
+ << "qobjectMinorVersionTest" << "qobjectMajorVersionTest" << "qobjectParentedTest")
+ << (QVariantList() << 20 << 20 << 1 << 20 << 20 << 26)
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList();
+
+ QTest::newRow("script, register + read")
+ << testFileUrl("moduleapi/scriptModuleApi.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << "scriptTest")
+ << (QVariantList() << 13)
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList();
+
+ QTest::newRow("qobject, caching + read")
+ << testFileUrl("moduleapi/qobjectModuleApiCaching.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << "existingUriTest" << "qobjectParentedTest")
+ << (QVariantList() << 20 << 26) // 26, shouldn't have incremented to 27.
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList();
+
+ QTest::newRow("script, caching + read")
+ << testFileUrl("moduleapi/scriptModuleApiCaching.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << "scriptTest")
+ << (QVariantList() << 13) // 13, shouldn't have incremented to 14.
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList();
+
+ QTest::newRow("qobject, writing + readonly constraints")
+ << testFileUrl("moduleapi/qobjectModuleApiWriting.qml")
+ << QString()
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/qobjectModuleApiWriting.qml").toLocalFile() + QLatin1String(":14: Error: Cannot assign to read-only property \"qobjectTestProperty\"")))
+ << (QStringList() << "readOnlyProperty" << "writableProperty")
+ << (QVariantList() << 20 << 50)
+ << (QStringList() << "firstProperty" << "writableProperty")
+ << (QVariantList() << 30 << 30)
+ << (QStringList() << "readOnlyProperty" << "writableProperty")
+ << (QVariantList() << 20 << 30);
+
+ QTest::newRow("script, writing + readonly constraints")
+ << testFileUrl("moduleapi/scriptModuleApiWriting.qml")
+ << QString()
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/scriptModuleApiWriting.qml").toLocalFile() + QLatin1String(":21: Error: Cannot assign to read-only property \"scriptTestProperty\"")))
+ << (QStringList() << "readBack" << "unchanged")
+ << (QVariantList() << 13 << 42)
+ << (QStringList() << "firstProperty" << "secondProperty")
+ << (QVariantList() << 30 << 30)
+ << (QStringList() << "readBack" << "unchanged")
+ << (QVariantList() << 30 << 42);
+
+ QTest::newRow("qobject module API enum values in JS")
+ << testFileUrl("moduleapi/qobjectModuleApiEnums.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << "enumValue" << "enumMethod")
+ << (QVariantList() << 42 << 30)
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList();
+
+ QTest::newRow("qobject, invalid major version fail")
+ << testFileUrl("moduleapi/moduleApiMajorVersionFail.qml")
+ << QString("QQmlComponent: Component is not ready")
+ << QStringList()
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList();
+
+ QTest::newRow("qobject, invalid minor version fail")
+ << testFileUrl("moduleapi/moduleApiMinorVersionFail.qml")
+ << QString("QQmlComponent: Component is not ready")
+ << QStringList()
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList()
+ << QStringList()
+ << QVariantList();
+}
+
+void tst_qqmlecmascript::moduleApi()
+{
+ QFETCH(QUrl, testfile);
+ QFETCH(QString, errorMessage);
+ QFETCH(QStringList, warningMessages);
+ QFETCH(QStringList, readProperties);
+ QFETCH(QVariantList, readExpectedValues);
+ QFETCH(QStringList, writeProperties);
+ QFETCH(QVariantList, writeValues);
+ QFETCH(QStringList, readBackProperties);
+ QFETCH(QVariantList, readBackExpectedValues);
+
+ QQmlComponent component(&engine, testfile);
+
+ if (!errorMessage.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, errorMessage.toAscii().constData());
+
+ if (warningMessages.size())
+ foreach (const QString &warning, warningMessages)
+ QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
+
+ QObject *object = component.create();
+ if (!errorMessage.isEmpty()) {
+ QVERIFY(object == 0);
+ } else {
+ QVERIFY(object != 0);
+ for (int i = 0; i < readProperties.size(); ++i)
+ QCOMPARE(object->property(readProperties.at(i).toAscii().constData()), readExpectedValues.at(i));
+ for (int i = 0; i < writeProperties.size(); ++i)
+ QVERIFY(object->setProperty(writeProperties.at(i).toAscii().constData(), writeValues.at(i)));
+ for (int i = 0; i < readBackProperties.size(); ++i)
+ QCOMPARE(object->property(readBackProperties.at(i).toAscii().constData()), readBackExpectedValues.at(i));
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::importScripts_data()
+{
+ QTest::addColumn<QUrl>("testfile");
+ QTest::addColumn<QString>("errorMessage");
+ QTest::addColumn<QStringList>("warningMessages");
+ QTest::addColumn<QStringList>("propertyNames");
+ QTest::addColumn<QVariantList>("propertyValues");
+
+ QTest::newRow("basic functionality")
+ << testFileUrl("jsimport/testImport.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << QLatin1String("importedScriptStringValue")
+ << QLatin1String("importedScriptFunctionValue")
+ << QLatin1String("importedModuleAttachedPropertyValue")
+ << QLatin1String("importedModuleEnumValue"))
+ << (QVariantList() << QVariant(QLatin1String("Hello, World!"))
+ << QVariant(20)
+ << QVariant(19)
+ << QVariant(2));
+
+ QTest::newRow("import scoping")
+ << testFileUrl("jsimport/testImportScoping.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << QLatin1String("componentError"))
+ << (QVariantList() << QVariant(5));
+
+ QTest::newRow("parent scope shouldn't be inherited by import with imports")
+ << testFileUrl("jsimportfail/failOne.qml")
+ << QString()
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failOne.qml").toLocalFile() + QLatin1String(":6: TypeError: Cannot call method 'greetingString' of undefined")))
+ << (QStringList() << QLatin1String("importScriptFunctionValue"))
+ << (QVariantList() << QVariant(QString()));
+
+ QTest::newRow("javascript imports in an import should be private to the import scope")
+ << testFileUrl("jsimportfail/failTwo.qml")
+ << QString()
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failTwo.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: ImportOneJs")))
+ << (QStringList() << QLatin1String("importScriptFunctionValue"))
+ << (QVariantList() << QVariant(QString()));
+
+ QTest::newRow("module imports in an import should be private to the import scope")
+ << testFileUrl("jsimportfail/failThree.qml")
+ << QString()
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failThree.qml").toLocalFile() + QLatin1String(":7: TypeError: Cannot read property 'JsQtTest' of undefined")))
+ << (QStringList() << QLatin1String("importedModuleAttachedPropertyValue"))
+ << (QVariantList() << QVariant(false));
+
+ QTest::newRow("typenames in an import should be private to the import scope")
+ << testFileUrl("jsimportfail/failFour.qml")
+ << QString()
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failFour.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: JsQtTest")))
+ << (QStringList() << QLatin1String("importedModuleEnumValue"))
+ << (QVariantList() << QVariant(0));
+
+ QTest::newRow("import with imports has it's own activation scope")
+ << testFileUrl("jsimportfail/failFive.qml")
+ << QString()
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importWithImports.js").toLocalFile() + QLatin1String(":8: ReferenceError: Can't find variable: Component")))
+ << (QStringList() << QLatin1String("componentError"))
+ << (QVariantList() << QVariant(0));
+
+ QTest::newRow("import pragma library script")
+ << testFileUrl("jsimport/testImportPragmaLibrary.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << QLatin1String("testValue"))
+ << (QVariantList() << QVariant(31));
+
+ QTest::newRow("pragma library imports shouldn't inherit parent imports or scope")
+ << testFileUrl("jsimportfail/testImportPragmaLibrary.qml")
+ << QString()
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importPragmaLibrary.js").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: Component")))
+ << (QStringList() << QLatin1String("testValue"))
+ << (QVariantList() << QVariant(0));
+
+ QTest::newRow("import pragma library script which has an import")
+ << testFileUrl("jsimport/testImportPragmaLibraryWithImports.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << QLatin1String("testValue"))
+ << (QVariantList() << QVariant(55));
+
+ QTest::newRow("import pragma library script which has a pragma library import")
+ << testFileUrl("jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << QLatin1String("testValue"))
+ << (QVariantList() << QVariant(18));
+}
+
+void tst_qqmlecmascript::importScripts()
+{
+ QFETCH(QUrl, testfile);
+ QFETCH(QString, errorMessage);
+ QFETCH(QStringList, warningMessages);
+ QFETCH(QStringList, propertyNames);
+ QFETCH(QVariantList, propertyValues);
+
+ QQmlComponent component(&engine, testfile);
+
+ if (!errorMessage.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, errorMessage.toAscii().constData());
+
+ if (warningMessages.size())
+ foreach (const QString &warning, warningMessages)
+ QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
+
+ QObject *object = component.create();
+ if (!errorMessage.isEmpty()) {
+ QVERIFY(object == 0);
+ } else {
+ QVERIFY(object != 0);
+ for (int i = 0; i < propertyNames.size(); ++i)
+ QCOMPARE(object->property(propertyNames.at(i).toAscii().constData()), propertyValues.at(i));
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::scarceResources_other()
+{
+ /* These tests require knowledge of state, since we test values after
+ performing signal or function invocation. */
+
+ QPixmap origPixmap(100, 100);
+ origPixmap.fill(Qt::blue);
+ QString srp_name, expectedWarning;
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(&engine);
+ ScarceResourceObject *eo = 0;
+ QObject *srsc = 0;
+ QObject *object = 0;
+
+ /* property var semantics */
+
+ // test that scarce resources are handled properly in signal invocation
+ QQmlComponent varComponentTen(&engine, testFileUrl("scarceResourceSignal.var.qml"));
+ object = varComponentTen.create();
+ srsc = object->findChild<QObject*>("srsc");
+ QVERIFY(srsc);
+ QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // hasn't been instantiated yet.
+ QCOMPARE(srsc->property("width"), QVariant(5)); // default value is 5.
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ QMetaObject::invokeMethod(srsc, "testSignal");
+ QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // still hasn't been instantiated
+ QCOMPARE(srsc->property("width"), QVariant(10)); // but width was assigned to 10.
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should still be no other copies of it at this stage.
+ QMetaObject::invokeMethod(srsc, "testSignal2"); // assigns scarceResourceCopy to the scarce pixmap.
+ QVERIFY(srsc->property("scarceResourceCopy").isValid());
+ QCOMPARE(srsc->property("scarceResourceCopy").value<QPixmap>(), origPixmap);
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(!(eo->scarceResourceIsDetached())); // should be another copy of the resource now.
+ QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
+ delete object;
+
+ // test that scarce resources are handled properly from js functions in qml files
+ QQmlComponent varComponentEleven(&engine, testFileUrl("scarceResourceFunction.var.qml"));
+ object = varComponentEleven.create();
+ QVERIFY(object != 0);
+ QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ QMetaObject::invokeMethod(object, "retrieveScarceResource");
+ QVERIFY(object->property("scarceResourceCopy").isValid()); // assigned, so should be valid.
+ QCOMPARE(object->property("scarceResourceCopy").value<QPixmap>(), origPixmap);
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(!eo->scarceResourceIsDetached()); // should be a copy of the resource at this stage.
+ QMetaObject::invokeMethod(object, "releaseScarceResource");
+ QVERIFY(!object->property("scarceResourceCopy").isValid()); // just released, so should not be valid
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
+ delete object;
+
+ // test that if an exception occurs while invoking js function from cpp, that the resources are released.
+ QQmlComponent varComponentTwelve(&engine, testFileUrl("scarceResourceFunctionFail.var.qml"));
+ object = varComponentTwelve.create();
+ QVERIFY(object != 0);
+ QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ srp_name = object->property("srp_name").toString();
+ expectedWarning = varComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srp_name + QLatin1String(" is not a function");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed.
+ QMetaObject::invokeMethod(object, "retrieveScarceResource");
+ QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred.
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
+ delete object;
+
+ // test that if an Item which has JS ownership but has a scarce resource property is garbage collected,
+ // that the scarce resource is removed from the engine's list of scarce resources to clean up.
+ QQmlComponent varComponentThirteen(&engine, testFileUrl("scarceResourceObjectGc.var.qml"));
+ object = varComponentThirteen.create();
+ QVERIFY(object != 0);
+ QVERIFY(!object->property("varProperty").isValid()); // not assigned yet
+ QMetaObject::invokeMethod(object, "assignVarProperty");
+ QVERIFY(ep->scarceResources.isEmpty()); // the scarce resource is a VME property.
+ QMetaObject::invokeMethod(object, "deassignVarProperty");
+ QVERIFY(ep->scarceResources.isEmpty()); // should still be empty; the resource should have been released on gc.
+ delete object;
+
+ /* property variant semantics */
+
+ // test that scarce resources are handled properly in signal invocation
+ QQmlComponent variantComponentTen(&engine, testFileUrl("scarceResourceSignal.variant.qml"));
+ object = variantComponentTen.create();
+ QVERIFY(object != 0);
+ srsc = object->findChild<QObject*>("srsc");
+ QVERIFY(srsc);
+ QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // hasn't been instantiated yet.
+ QCOMPARE(srsc->property("width"), QVariant(5)); // default value is 5.
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ QMetaObject::invokeMethod(srsc, "testSignal");
+ QVERIFY(!srsc->property("scarceResourceCopy").isValid()); // still hasn't been instantiated
+ QCOMPARE(srsc->property("width"), QVariant(10)); // but width was assigned to 10.
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should still be no other copies of it at this stage.
+ QMetaObject::invokeMethod(srsc, "testSignal2"); // assigns scarceResourceCopy to the scarce pixmap.
+ QVERIFY(srsc->property("scarceResourceCopy").isValid());
+ QCOMPARE(srsc->property("scarceResourceCopy").value<QPixmap>(), origPixmap);
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(!(eo->scarceResourceIsDetached())); // should be another copy of the resource now.
+ QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
+ delete object;
+
+ // test that scarce resources are handled properly from js functions in qml files
+ QQmlComponent variantComponentEleven(&engine, testFileUrl("scarceResourceFunction.variant.qml"));
+ object = variantComponentEleven.create();
+ QVERIFY(object != 0);
+ QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ QMetaObject::invokeMethod(object, "retrieveScarceResource");
+ QVERIFY(object->property("scarceResourceCopy").isValid()); // assigned, so should be valid.
+ QCOMPARE(object->property("scarceResourceCopy").value<QPixmap>(), origPixmap);
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(!eo->scarceResourceIsDetached()); // should be a copy of the resource at this stage.
+ QMetaObject::invokeMethod(object, "releaseScarceResource");
+ QVERIFY(!object->property("scarceResourceCopy").isValid()); // just released, so should not be valid
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
+ delete object;
+
+ // test that if an exception occurs while invoking js function from cpp, that the resources are released.
+ QQmlComponent variantComponentTwelve(&engine, testFileUrl("scarceResourceFunctionFail.variant.qml"));
+ object = variantComponentTwelve.create();
+ QVERIFY(object != 0);
+ QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ srp_name = object->property("srp_name").toString();
+ expectedWarning = variantComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ") + srp_name + QLatin1String(" is not a function");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed.
+ QMetaObject::invokeMethod(object, "retrieveScarceResource");
+ QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred.
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage.
+ QVERIFY(ep->scarceResources.isEmpty()); // should have been released by this point.
+ delete object;
+}
+
+void tst_qqmlecmascript::scarceResources_data()
+{
+ QTest::addColumn<QUrl>("qmlFile");
+ QTest::addColumn<bool>("readDetachStatus");
+ QTest::addColumn<bool>("expectedDetachStatus");
+ QTest::addColumn<QStringList>("propertyNames");
+ QTest::addColumn<QVariantList>("expectedValidity");
+ QTest::addColumn<QVariantList>("expectedValues");
+ QTest::addColumn<QStringList>("expectedErrors");
+
+ QPixmap origPixmap(100, 100);
+ origPixmap.fill(Qt::blue);
+
+ /* property var semantics */
+
+ // in the following three cases, the instance created from the component
+ // has a property which is a copy of the scarce resource; hence, the
+ // resource should NOT be detached prior to deletion of the object instance,
+ // unless the resource is destroyed explicitly.
+ QTest::newRow("var: import scarce resource copy directly")
+ << testFileUrl("scarceResourceCopy.var.qml")
+ << true
+ << false // won't be detached, because assigned to property and not explicitly released
+ << (QStringList() << QLatin1String("scarceResourceCopy"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << origPixmap)
+ << QStringList();
+
+ QTest::newRow("var: import scarce resource copy from JS")
+ << testFileUrl("scarceResourceCopyFromJs.var.qml")
+ << true
+ << false // won't be detached, because assigned to property and not explicitly released
+ << (QStringList() << QLatin1String("scarceResourceCopy"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << origPixmap)
+ << QStringList();
+
+ QTest::newRow("var: import released scarce resource copy from JS")
+ << testFileUrl("scarceResourceDestroyedCopy.var.qml")
+ << true
+ << true // explicitly released, so it will be detached
+ << (QStringList() << QLatin1String("scarceResourceCopy"))
+ << (QList<QVariant>() << false)
+ << (QList<QVariant>() << QVariant())
+ << QStringList();
+
+ // in the following three cases, no other copy should exist in memory,
+ // and so it should be detached (unless explicitly preserved).
+ QTest::newRow("var: import auto-release SR from JS in binding side-effect")
+ << testFileUrl("scarceResourceTest.var.qml")
+ << true
+ << true // auto released, so it will be detached
+ << (QStringList() << QLatin1String("scarceResourceTest"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << QVariant(100))
+ << QStringList();
+ QTest::newRow("var: import explicit-preserve SR from JS in binding side-effect")
+ << testFileUrl("scarceResourceTestPreserve.var.qml")
+ << true
+ << false // won't be detached because we explicitly preserve it
+ << (QStringList() << QLatin1String("scarceResourceTest"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << QVariant(100))
+ << QStringList();
+ QTest::newRow("var: import explicit-preserve SR from JS in binding side-effect")
+ << testFileUrl("scarceResourceTestMultiple.var.qml")
+ << true
+ << true // will be detached because all resources were released manually or automatically.
+ << (QStringList() << QLatin1String("scarceResourceTest"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << QVariant(100))
+ << QStringList();
+
+ // In the following three cases, test that scarce resources are handled
+ // correctly for imports.
+ QTest::newRow("var: import with no binding")
+ << testFileUrl("scarceResourceCopyImportNoBinding.var.qml")
+ << false // cannot check detach status.
+ << false
+ << QStringList()
+ << QList<QVariant>()
+ << QList<QVariant>()
+ << QStringList();
+ QTest::newRow("var: import with binding without explicit preserve")
+ << testFileUrl("scarceResourceCopyImportNoBinding.var.qml")
+ << false
+ << false
+ << (QStringList() << QLatin1String("scarceResourceCopy"))
+ << (QList<QVariant>() << false) // will have been released prior to evaluation of binding.
+ << (QList<QVariant>() << QVariant())
+ << QStringList();
+ QTest::newRow("var: import with explicit release after binding evaluation")
+ << testFileUrl("scarceResourceCopyImport.var.qml")
+ << false
+ << false
+ << (QStringList() << QLatin1String("scarceResourceImportedCopy") << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo") << QLatin1String("arePropertiesEqual"))
+ << (QList<QVariant>() << false << false << false << true) // since property var = JS object reference, by releasing the provider's resource, all handles are invalidated.
+ << (QList<QVariant>() << QVariant() << QVariant() << QVariant() << QVariant(true))
+ << QStringList();
+ QTest::newRow("var: import with different js objects")
+ << testFileUrl("scarceResourceCopyImportDifferent.var.qml")
+ << false
+ << false
+ << (QStringList() << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo") << QLatin1String("arePropertiesEqual"))
+ << (QList<QVariant>() << false << true << true) // invalidating one shouldn't invalidate the other, because they're not references to the same JS object.
+ << (QList<QVariant>() << QVariant() << QVariant(origPixmap) << QVariant(false))
+ << QStringList();
+ QTest::newRow("var: import with different js objects and explicit release")
+ << testFileUrl("scarceResourceMultipleDifferentNoBinding.var.qml")
+ << false
+ << false
+ << (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo"))
+ << (QList<QVariant>() << true << false) // invalidating one shouldn't invalidate the other, because they're not references to the same JS object.
+ << (QList<QVariant>() << QVariant(origPixmap) << QVariant())
+ << QStringList();
+ QTest::newRow("var: import with same js objects and explicit release")
+ << testFileUrl("scarceResourceMultipleSameNoBinding.var.qml")
+ << false
+ << false
+ << (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo"))
+ << (QList<QVariant>() << false << false) // invalidating one should invalidate the other, because they're references to the same JS object.
+ << (QList<QVariant>() << QVariant() << QVariant())
+ << QStringList();
+ QTest::newRow("var: binding with same js objects and explicit release")
+ << testFileUrl("scarceResourceMultipleSameWithBinding.var.qml")
+ << false
+ << false
+ << (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo"))
+ << (QList<QVariant>() << false << false) // invalidating one should invalidate the other, because they're references to the same JS object.
+ << (QList<QVariant>() << QVariant() << QVariant())
+ << QStringList();
+
+
+ /* property variant semantics */
+
+ // in the following three cases, the instance created from the component
+ // has a property which is a copy of the scarce resource; hence, the
+ // resource should NOT be detached prior to deletion of the object instance,
+ // unless the resource is destroyed explicitly.
+ QTest::newRow("variant: import scarce resource copy directly")
+ << testFileUrl("scarceResourceCopy.variant.qml")
+ << true
+ << false // won't be detached, because assigned to property and not explicitly released
+ << (QStringList() << QLatin1String("scarceResourceCopy"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << origPixmap)
+ << QStringList();
+
+ QTest::newRow("variant: import scarce resource copy from JS")
+ << testFileUrl("scarceResourceCopyFromJs.variant.qml")
+ << true
+ << false // won't be detached, because assigned to property and not explicitly released
+ << (QStringList() << QLatin1String("scarceResourceCopy"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << origPixmap)
+ << QStringList();
+
+ QTest::newRow("variant: import released scarce resource copy from JS")
+ << testFileUrl("scarceResourceDestroyedCopy.variant.qml")
+ << true
+ << true // explicitly released, so it will be detached
+ << (QStringList() << QLatin1String("scarceResourceCopy"))
+ << (QList<QVariant>() << false)
+ << (QList<QVariant>() << QVariant())
+ << QStringList();
+
+ // in the following three cases, no other copy should exist in memory,
+ // and so it should be detached (unless explicitly preserved).
+ QTest::newRow("variant: import auto-release SR from JS in binding side-effect")
+ << testFileUrl("scarceResourceTest.variant.qml")
+ << true
+ << true // auto released, so it will be detached
+ << (QStringList() << QLatin1String("scarceResourceTest"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << QVariant(100))
+ << QStringList();
+ QTest::newRow("variant: import explicit-preserve SR from JS in binding side-effect")
+ << testFileUrl("scarceResourceTestPreserve.variant.qml")
+ << true
+ << false // won't be detached because we explicitly preserve it
+ << (QStringList() << QLatin1String("scarceResourceTest"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << QVariant(100))
+ << QStringList();
+ QTest::newRow("variant: import multiple scarce resources")
+ << testFileUrl("scarceResourceTestMultiple.variant.qml")
+ << true
+ << true // will be detached because all resources were released manually or automatically.
+ << (QStringList() << QLatin1String("scarceResourceTest"))
+ << (QList<QVariant>() << true)
+ << (QList<QVariant>() << QVariant(100))
+ << QStringList();
+
+ // In the following three cases, test that scarce resources are handled
+ // correctly for imports.
+ QTest::newRow("variant: import with no binding")
+ << testFileUrl("scarceResourceCopyImportNoBinding.variant.qml")
+ << false // cannot check detach status.
+ << false
+ << QStringList()
+ << QList<QVariant>()
+ << QList<QVariant>()
+ << QStringList();
+ QTest::newRow("variant: import with binding without explicit preserve")
+ << testFileUrl("scarceResourceCopyImportNoBinding.variant.qml")
+ << false
+ << false
+ << (QStringList() << QLatin1String("scarceResourceCopy"))
+ << (QList<QVariant>() << false) // will have been released prior to evaluation of binding.
+ << (QList<QVariant>() << QVariant())
+ << QStringList();
+ QTest::newRow("variant: import with explicit release after binding evaluation")
+ << testFileUrl("scarceResourceCopyImport.variant.qml")
+ << false
+ << false
+ << (QStringList() << QLatin1String("scarceResourceImportedCopy") << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo"))
+ << (QList<QVariant>() << true << true << false) // since property variant = variant copy, releasing the provider's resource does not invalidate previously assigned copies.
+ << (QList<QVariant>() << origPixmap << origPixmap << QVariant())
+ << QStringList();
+}
+
+void tst_qqmlecmascript::scarceResources()
+{
+ QFETCH(QUrl, qmlFile);
+ QFETCH(bool, readDetachStatus);
+ QFETCH(bool, expectedDetachStatus);
+ QFETCH(QStringList, propertyNames);
+ QFETCH(QVariantList, expectedValidity);
+ QFETCH(QVariantList, expectedValues);
+ QFETCH(QStringList, expectedErrors);
+
+ QQmlEnginePrivate *ep = QQmlEnginePrivate::get(&engine);
+ ScarceResourceObject *eo = 0;
+ QObject *object = 0;
+
+ QQmlComponent c(&engine, qmlFile);
+ object = c.create();
+ QVERIFY(object != 0);
+ for (int i = 0; i < propertyNames.size(); ++i) {
+ QString prop = propertyNames.at(i);
+ bool validity = expectedValidity.at(i).toBool();
+ QVariant value = expectedValues.at(i);
+
+ QCOMPARE(object->property(prop.toLatin1().constData()).isValid(), validity);
+ if (value.type() == QVariant::Int) {
+ QCOMPARE(object->property(prop.toLatin1().constData()).toInt(), value.toInt());
+ } else if (value.type() == QVariant::Pixmap) {
+ QCOMPARE(object->property(prop.toLatin1().constData()).value<QPixmap>(), value.value<QPixmap>());
+ }
+ }
+
+ if (readDetachStatus) {
+ eo = qobject_cast<ScarceResourceObject*>(QQmlProperty::read(object, "a").value<QObject*>());
+ QCOMPARE(eo->scarceResourceIsDetached(), expectedDetachStatus);
+ }
+
+ QVERIFY(ep->scarceResources.isEmpty());
+ delete object;
+}
+
+void tst_qqmlecmascript::propertyChangeSlots()
+{
+ // ensure that allowable property names are allowed and onPropertyNameChanged slots are generated correctly.
+ QQmlComponent component(&engine, testFileUrl("changeslots/propertyChangeSlots.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+
+ // ensure that invalid property names fail properly.
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ QQmlComponent e1(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.1.qml"));
+ QString expectedErrorString = e1.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on_nameWithUnderscoreChanged\"");
+ QCOMPARE(e1.errors().at(0).toString(), expectedErrorString);
+ object = e1.create();
+ QVERIFY(object == 0);
+ delete object;
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ QQmlComponent e2(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.2.qml"));
+ expectedErrorString = e2.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on____nameWithUnderscoresChanged\"");
+ QCOMPARE(e2.errors().at(0).toString(), expectedErrorString);
+ object = e2.create();
+ QVERIFY(object == 0);
+ delete object;
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ QQmlComponent e3(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.3.qml"));
+ expectedErrorString = e3.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on$NameWithDollarsignChanged\"");
+ QCOMPARE(e3.errors().at(0).toString(), expectedErrorString);
+ object = e3.create();
+ QVERIFY(object == 0);
+ delete object;
+
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ QQmlComponent e4(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.4.qml"));
+ expectedErrorString = e4.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on_6NameWithUnderscoreNumberChanged\"");
+ QCOMPARE(e4.errors().at(0).toString(), expectedErrorString);
+ object = e4.create();
+ QVERIFY(object == 0);
+ delete object;
+}
+
+void tst_qqmlecmascript::propertyVar_data()
+{
+ QTest::addColumn<QUrl>("qmlFile");
+
+ // valid
+ QTest::newRow("non-bindable object subproperty changed") << testFileUrl("propertyVar.1.qml");
+ QTest::newRow("non-bindable object changed") << testFileUrl("propertyVar.2.qml");
+ QTest::newRow("primitive changed") << testFileUrl("propertyVar.3.qml");
+ QTest::newRow("javascript array modification") << testFileUrl("propertyVar.4.qml");
+ QTest::newRow("javascript map modification") << testFileUrl("propertyVar.5.qml");
+ QTest::newRow("javascript array assignment") << testFileUrl("propertyVar.6.qml");
+ QTest::newRow("javascript map assignment") << testFileUrl("propertyVar.7.qml");
+ QTest::newRow("literal property assignment") << testFileUrl("propertyVar.8.qml");
+ QTest::newRow("qobject property assignment") << testFileUrl("propertyVar.9.qml");
+ QTest::newRow("base class var property assignment") << testFileUrl("propertyVar.10.qml");
+}
+
+void tst_qqmlecmascript::propertyVar()
+{
+ QFETCH(QUrl, qmlFile);
+
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Tests that we can write QVariant values to var properties from C++
+void tst_qqmlecmascript::propertyVarCpp()
+{
+ QObject *object = 0;
+
+ // ensure that writing to and reading from a var property from cpp works as required.
+ // Literal values stored in var properties can be read and written as QVariants
+ // of a specific type, whereas object values are read as QVariantMaps.
+ QQmlComponent component(&engine, testFileUrl("propertyVarCpp.qml"));
+ object = component.create();
+ QVERIFY(object != 0);
+ // assign int to property var that currently has int assigned
+ QVERIFY(object->setProperty("varProperty", QVariant::fromValue(10)));
+ QCOMPARE(object->property("varBound"), QVariant(15));
+ QCOMPARE(object->property("intBound"), QVariant(15));
+ QCOMPARE(object->property("varProperty").userType(), (int)QVariant::Int);
+ QCOMPARE(object->property("varBound").userType(), (int)QVariant::Int);
+ // assign string to property var that current has bool assigned
+ QCOMPARE(object->property("varProperty2").userType(), (int)QVariant::Bool);
+ QVERIFY(object->setProperty("varProperty2", QVariant(QLatin1String("randomString"))));
+ QCOMPARE(object->property("varProperty2"), QVariant(QLatin1String("randomString")));
+ QCOMPARE(object->property("varProperty2").userType(), (int)QVariant::String);
+ // now enforce behaviour when accessing JavaScript objects from cpp.
+ QCOMPARE(object->property("jsobject").userType(), (int)QVariant::Map);
+ delete object;
+}
+
+static void gc(QQmlEngine &engine)
+{
+ engine.collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+}
+
+void tst_qqmlecmascript::propertyVarOwnership()
+{
+ // Referenced JS objects are not collected
+ {
+ QQmlComponent component(&engine, testFileUrl("propertyVarOwnership.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toBool(), false);
+ QMetaObject::invokeMethod(object, "runTest");
+ QCOMPARE(object->property("test").toBool(), true);
+ delete object;
+ }
+ // Referenced JS objects are not collected
+ {
+ QQmlComponent component(&engine, testFileUrl("propertyVarOwnership.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toBool(), false);
+ QMetaObject::invokeMethod(object, "runTest");
+ QCOMPARE(object->property("test").toBool(), true);
+ delete object;
+ }
+ // Qt objects are not collected until they've been dereferenced
+ {
+ QQmlComponent component(&engine, testFileUrl("propertyVarOwnership.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test2").toBool(), false);
+ QCOMPARE(object->property("test2").toBool(), false);
+
+ QMetaObject::invokeMethod(object, "runTest");
+ QCOMPARE(object->property("test1").toBool(), true);
+
+ QPointer<QObject> referencedObject = object->property("object").value<QObject*>();
+ QVERIFY(!referencedObject.isNull());
+ gc(engine);
+ QVERIFY(!referencedObject.isNull());
+
+ QMetaObject::invokeMethod(object, "runTest2");
+ QCOMPARE(object->property("test2").toBool(), true);
+ gc(engine);
+ QVERIFY(referencedObject.isNull());
+
+ delete object;
+ }
+ // Self reference does not prevent Qt object collection
+ {
+ QQmlComponent component(&engine, testFileUrl("propertyVarOwnership.4.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ QPointer<QObject> referencedObject = object->property("object").value<QObject*>();
+ QVERIFY(!referencedObject.isNull());
+ gc(engine);
+ QVERIFY(!referencedObject.isNull());
+
+ QMetaObject::invokeMethod(object, "runTest");
+ gc(engine);
+ QVERIFY(referencedObject.isNull());
+
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::propertyVarImplicitOwnership()
+{
+ // The childObject has a reference to a different QObject. We want to ensure
+ // that the different item will not be cleaned up until required. IE, the childObject
+ // has implicit ownership of the constructed QObject.
+ QQmlComponent component(&engine, testFileUrl("propertyVarImplicitOwnership.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "assignCircular");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QObject *rootObject = object->property("vp").value<QObject*>();
+ QVERIFY(rootObject != 0);
+ QObject *childObject = rootObject->findChild<QObject*>("text");
+ QVERIFY(childObject != 0);
+ QCOMPARE(rootObject->property("rectCanary").toInt(), 5);
+ QCOMPARE(childObject->property("textCanary").toInt(), 10);
+ QMetaObject::invokeMethod(childObject, "constructQObject"); // creates a reference to a constructed QObject.
+ QWeakPointer<QObject> qobjectGuard(childObject->property("vp").value<QObject*>()); // get the pointer prior to processing deleteLater events.
+ QVERIFY(!qobjectGuard.isNull());
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QVERIFY(!qobjectGuard.isNull());
+ QMetaObject::invokeMethod(object, "deassignCircular");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QVERIFY(qobjectGuard.isNull()); // should have been collected now.
+ delete object;
+}
+
+void tst_qqmlecmascript::propertyVarReparent()
+{
+ // ensure that nothing breaks if we re-parent objects
+ QQmlComponent component(&engine, testFileUrl("propertyVar.reparent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "assignVarProp");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QObject *rect = object->property("vp").value<QObject*>();
+ QObject *text = rect->findChild<QObject*>("textOne");
+ QObject *text2 = rect->findChild<QObject*>("textTwo");
+ QWeakPointer<QObject> rectGuard(rect);
+ QWeakPointer<QObject> textGuard(text);
+ QWeakPointer<QObject> text2Guard(text2);
+ QVERIFY(!rectGuard.isNull());
+ QVERIFY(!textGuard.isNull());
+ QVERIFY(!text2Guard.isNull());
+ QCOMPARE(text->property("textCanary").toInt(), 11);
+ QCOMPARE(text2->property("textCanary").toInt(), 12);
+ // now construct an image which we will reparent.
+ QMetaObject::invokeMethod(text2, "constructQObject");
+ QObject *image = text2->property("vp").value<QObject*>();
+ QWeakPointer<QObject> imageGuard(image);
+ QVERIFY(!imageGuard.isNull());
+ QCOMPARE(image->property("imageCanary").toInt(), 13);
+ // now reparent the "Image" object (currently, it has JS ownership)
+ image->setParent(text); // shouldn't be collected after deassignVp now, since has a parent.
+ QMetaObject::invokeMethod(text2, "deassignVp");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QCOMPARE(text->property("textCanary").toInt(), 11);
+ QCOMPARE(text2->property("textCanary").toInt(), 22);
+ QVERIFY(!imageGuard.isNull()); // should still be alive.
+ QCOMPARE(image->property("imageCanary").toInt(), 13); // still able to access var properties
+ QMetaObject::invokeMethod(object, "deassignVarProp"); // now deassign the root-object's vp, causing gc of rect+text+text2
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QVERIFY(imageGuard.isNull()); // should now have been deleted, due to parent being deleted.
+ delete object;
+}
+
+void tst_qqmlecmascript::propertyVarReparentNullContext()
+{
+ // sometimes reparenting can cause problems
+ // (eg, if the ctxt is collected, varproperties are no longer available)
+ // this test ensures that no crash occurs in that situation.
+ QQmlComponent component(&engine, testFileUrl("propertyVar.reparent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "assignVarProp");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QObject *rect = object->property("vp").value<QObject*>();
+ QObject *text = rect->findChild<QObject*>("textOne");
+ QObject *text2 = rect->findChild<QObject*>("textTwo");
+ QWeakPointer<QObject> rectGuard(rect);
+ QWeakPointer<QObject> textGuard(text);
+ QWeakPointer<QObject> text2Guard(text2);
+ QVERIFY(!rectGuard.isNull());
+ QVERIFY(!textGuard.isNull());
+ QVERIFY(!text2Guard.isNull());
+ QCOMPARE(text->property("textCanary").toInt(), 11);
+ QCOMPARE(text2->property("textCanary").toInt(), 12);
+ // now construct an image which we will reparent.
+ QMetaObject::invokeMethod(text2, "constructQObject");
+ QObject *image = text2->property("vp").value<QObject*>();
+ QWeakPointer<QObject> imageGuard(image);
+ QVERIFY(!imageGuard.isNull());
+ QCOMPARE(image->property("imageCanary").toInt(), 13);
+ // now reparent the "Image" object (currently, it has JS ownership)
+ image->setParent(object); // reparented to base object. after deassignVarProp, the ctxt will be invalid.
+ QMetaObject::invokeMethod(object, "deassignVarProp"); // now deassign the root-object's vp, causing gc of rect+text+text2
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QVERIFY(!imageGuard.isNull()); // should still be alive.
+ QVERIFY(!image->property("imageCanary").isValid()); // but varProperties won't be available (null context).
+ delete object;
+ QVERIFY(imageGuard.isNull()); // should now be dead.
+}
+
+void tst_qqmlecmascript::propertyVarCircular()
+{
+ // enforce behaviour regarding circular references - ensure qdvmemo deletion.
+ QQmlComponent component(&engine, testFileUrl("propertyVar.circular.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "assignCircular"); // cause assignment and gc
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QCOMPARE(object->property("canaryInt"), QVariant(5));
+ QVariant canaryResourceVariant = object->property("canaryResource");
+ QVERIFY(canaryResourceVariant.isValid());
+ QPixmap canaryResourcePixmap = canaryResourceVariant.value<QPixmap>();
+ canaryResourceVariant = QVariant(); // invalidate it to remove one copy of the pixmap from memory.
+ QMetaObject::invokeMethod(object, "deassignCanaryResource"); // remove one copy of the pixmap from memory
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QVERIFY(!canaryResourcePixmap.isDetached()); // two copies extant - this and the propertyVar.vp.vp.vp.vp.memoryHog.
+ QMetaObject::invokeMethod(object, "deassignCircular"); // cause deassignment and gc
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QCOMPARE(object->property("canaryInt"), QVariant(2));
+ QCOMPARE(object->property("canaryResource"), QVariant(1));
+ QVERIFY(canaryResourcePixmap.isDetached()); // now detached, since orig copy was member of qdvmemo which was deleted.
+ delete object;
+}
+
+void tst_qqmlecmascript::propertyVarCircular2()
+{
+ // track deletion of JS-owned parent item with Cpp-owned child
+ // where the child has a var property referencing its parent.
+ QQmlComponent component(&engine, testFileUrl("propertyVar.circular.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "assignCircular");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QObject *rootObject = object->property("vp").value<QObject*>();
+ QVERIFY(rootObject != 0);
+ QObject *childObject = rootObject->findChild<QObject*>("text");
+ QVERIFY(childObject != 0);
+ QWeakPointer<QObject> rootObjectTracker(rootObject);
+ QVERIFY(!rootObjectTracker.isNull());
+ QWeakPointer<QObject> childObjectTracker(childObject);
+ QVERIFY(!childObjectTracker.isNull());
+ gc(engine);
+ QCOMPARE(rootObject->property("rectCanary").toInt(), 5);
+ QCOMPARE(childObject->property("textCanary").toInt(), 10);
+ QMetaObject::invokeMethod(object, "deassignCircular");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QVERIFY(rootObjectTracker.isNull()); // should have been collected
+ QVERIFY(childObjectTracker.isNull()); // should have been collected
+ delete object;
+}
+
+void tst_qqmlecmascript::propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter)
+{
+ *(int*)(parameter) += 1;
+ qPersistentDispose(object);
+}
+
+void tst_qqmlecmascript::propertyVarInheritance()
+{
+ int propertyVarWeakRefCallbackCount = 0;
+
+ // enforce behaviour regarding element inheritance - ensure handle disposal.
+ // The particular component under test here has a chain of references.
+ QQmlComponent component(&engine, testFileUrl("propertyVar.inherit.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "assignCircular"); // cause assignment and gc
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ // we want to be able to track when the varProperties array of the last metaobject is disposed
+ QObject *cco5 = object->property("varProperty").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>();
+ QObject *ico5 = object->property("varProperty").value<QObject*>()->property("inheritanceVarProperty").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>();
+ QQmlVMEMetaObject *icovmemo = ((QQmlVMEMetaObject *)(ico5->metaObject()));
+ QQmlVMEMetaObject *ccovmemo = ((QQmlVMEMetaObject *)(cco5->metaObject()));
+ v8::Persistent<v8::Value> icoCanaryHandle;
+ v8::Persistent<v8::Value> ccoCanaryHandle;
+ {
+ v8::HandleScope hs;
+ // XXX NOTE: this is very implementation dependent. QDVMEMO->vmeProperty() is the only
+ // public function which can return us a handle to something in the varProperties array.
+ icoCanaryHandle = qPersistentNew(icovmemo->vmeProperty(ico5->metaObject()->indexOfProperty("circ")));
+ ccoCanaryHandle = qPersistentNew(ccovmemo->vmeProperty(cco5->metaObject()->indexOfProperty("circ")));
+ // we make them weak and invoke the gc, but we should not hit the weak-callback yet
+ // as the varproperties array of each vmemo still references the resource.
+ icoCanaryHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback);
+ ccoCanaryHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback);
+ gc(engine);
+ QVERIFY(propertyVarWeakRefCallbackCount == 0);
+ }
+ // now we deassign the var prop, which should trigger collection of item subtrees.
+ QMetaObject::invokeMethod(object, "deassignCircular"); // cause deassignment and gc
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ // ensure that there are only weak handles to the underlying varProperties array remaining.
+ gc(engine);
+ QCOMPARE(propertyVarWeakRefCallbackCount, 2); // should have been called for both, since all refs should be weak.
+ delete object;
+ // since there are no parent vmemo's to keep implicit references alive, and the only handles
+ // to what remains are weak, all varProperties arrays must have been collected.
+}
+
+void tst_qqmlecmascript::propertyVarInheritance2()
+{
+ int propertyVarWeakRefCallbackCount = 0;
+
+ // The particular component under test here does NOT have a chain of references; the
+ // only link between rootObject and childObject is that rootObject is the parent of childObject.
+ QQmlComponent component(&engine, testFileUrl("propertyVar.circular.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "assignCircular");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QObject *rootObject = object->property("vp").value<QObject*>();
+ QVERIFY(rootObject != 0);
+ QObject *childObject = rootObject->findChild<QObject*>("text");
+ QVERIFY(childObject != 0);
+ QCOMPARE(rootObject->property("rectCanary").toInt(), 5);
+ QCOMPARE(childObject->property("textCanary").toInt(), 10);
+ v8::Persistent<v8::Value> childObjectVarArrayValueHandle;
+ {
+ v8::HandleScope hs;
+ propertyVarWeakRefCallbackCount = 0; // reset callback count.
+ childObjectVarArrayValueHandle = qPersistentNew(((QQmlVMEMetaObject *)(childObject->metaObject()))->vmeProperty(childObject->metaObject()->indexOfProperty("vp")));
+ childObjectVarArrayValueHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback);
+ gc(engine);
+ QVERIFY(propertyVarWeakRefCallbackCount == 0); // should not have been collected yet.
+ QCOMPARE(childObject->property("vp").value<QObject*>(), rootObject);
+ QCOMPARE(childObject->property("textCanary").toInt(), 10);
+ }
+ QMetaObject::invokeMethod(object, "deassignCircular");
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper.
+ QCoreApplication::processEvents();
+ QVERIFY(propertyVarWeakRefCallbackCount == 1); // should have been collected now.
+ delete object;
+}
+
+// Ensure that QObject type conversion works on binding assignment
+void tst_qqmlecmascript::elementAssign()
+{
+ QQmlComponent component(&engine, testFileUrl("elementAssign.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// QTBUG-12457
+void tst_qqmlecmascript::objectPassThroughSignals()
+{
+ QQmlComponent component(&engine, testFileUrl("objectsPassThroughSignals.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// QTBUG-21626
+void tst_qqmlecmascript::objectConversion()
+{
+ QQmlComponent component(&engine, testFileUrl("objectConversion.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QVariant retn;
+ QMetaObject::invokeMethod(object, "circularObject", Q_RETURN_ARG(QVariant, retn));
+ QCOMPARE(retn.value<QVariantMap>().value("test"), QVariant(100));
+
+ delete object;
+}
+
+
+// QTBUG-20242
+void tst_qqmlecmascript::booleanConversion()
+{
+ QQmlComponent component(&engine, testFileUrl("booleanConversion.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test_true1").toBool(), true);
+ QCOMPARE(object->property("test_true2").toBool(), true);
+ QCOMPARE(object->property("test_true3").toBool(), true);
+ QCOMPARE(object->property("test_true4").toBool(), true);
+ QCOMPARE(object->property("test_true5").toBool(), true);
+
+ QCOMPARE(object->property("test_false1").toBool(), false);
+ QCOMPARE(object->property("test_false2").toBool(), false);
+ QCOMPARE(object->property("test_false3").toBool(), false);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::handleReferenceManagement()
+{
+
+ int dtorCount = 0;
+ {
+ // Linear QObject reference
+ QQmlEngine hrmEngine;
+ QQmlComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.object.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ CircularReferenceObject *cro = object->findChild<CircularReferenceObject*>("cro");
+ cro->setEngine(&hrmEngine);
+ cro->setDtorCount(&dtorCount);
+ QMetaObject::invokeMethod(object, "createReference");
+ gc(engine);
+ QCOMPARE(dtorCount, 0); // second has JS ownership, kept alive by first's reference
+ delete object;
+ hrmEngine.collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 3);
+ }
+
+ dtorCount = 0;
+ {
+ // Circular QObject reference
+ QQmlEngine hrmEngine;
+ QQmlComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.object.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ CircularReferenceObject *cro = object->findChild<CircularReferenceObject*>("cro");
+ cro->setEngine(&hrmEngine);
+ cro->setDtorCount(&dtorCount);
+ QMetaObject::invokeMethod(object, "circularReference");
+ gc(engine);
+ QCOMPARE(dtorCount, 2); // both should be cleaned up, since circular references shouldn't keep alive.
+ delete object;
+ hrmEngine.collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 3);
+ }
+
+ dtorCount = 0;
+ {
+ // Linear handle reference
+ QQmlEngine hrmEngine;
+ QQmlComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ CircularReferenceHandle *crh = object->findChild<CircularReferenceHandle*>("crh");
+ QVERIFY(crh != 0);
+ crh->setEngine(&hrmEngine);
+ crh->setDtorCount(&dtorCount);
+ QMetaObject::invokeMethod(object, "createReference");
+ CircularReferenceHandle *first = object->property("first").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *second = object->property("second").value<CircularReferenceHandle*>();
+ QVERIFY(first != 0);
+ QVERIFY(second != 0);
+ first->addReference(QQmlData::get(second)->v8object); // create reference
+ // now we have to reparent second and make second owned by JS.
+ second->setParent(0);
+ QQmlEngine::setObjectOwnership(second, QQmlEngine::JavaScriptOwnership);
+ gc(engine);
+ QCOMPARE(dtorCount, 0); // due to reference from first to second, second shouldn't be collected.
+ delete object;
+ hrmEngine.collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 3);
+ }
+
+ dtorCount = 0;
+ {
+ // Circular handle reference
+ QQmlEngine hrmEngine;
+ QQmlComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.handle.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ CircularReferenceHandle *crh = object->findChild<CircularReferenceHandle*>("crh");
+ QVERIFY(crh != 0);
+ crh->setEngine(&hrmEngine);
+ crh->setDtorCount(&dtorCount);
+ QMetaObject::invokeMethod(object, "circularReference");
+ CircularReferenceHandle *first = object->property("first").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *second = object->property("second").value<CircularReferenceHandle*>();
+ QVERIFY(first != 0);
+ QVERIFY(second != 0);
+ first->addReference(QQmlData::get(second)->v8object); // create circular reference
+ second->addReference(QQmlData::get(first)->v8object); // note: must be weak.
+ // now we have to reparent and change ownership.
+ first->setParent(0);
+ second->setParent(0);
+ QQmlEngine::setObjectOwnership(first, QQmlEngine::JavaScriptOwnership);
+ QQmlEngine::setObjectOwnership(second, QQmlEngine::JavaScriptOwnership);
+ gc(engine);
+ QCOMPARE(dtorCount, 2); // despite circular references, both will be collected.
+ delete object;
+ hrmEngine.collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 3);
+ }
+
+ dtorCount = 0;
+ {
+ // multiple engine interaction - linear reference
+ QQmlEngine hrmEngine1;
+ QQmlEngine hrmEngine2;
+ QQmlComponent component1(&hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QQmlComponent component2(&hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QObject *object1 = component1.create();
+ QObject *object2 = component2.create();
+ QVERIFY(object1 != 0);
+ QVERIFY(object2 != 0);
+ CircularReferenceHandle *crh1 = object1->findChild<CircularReferenceHandle*>("crh");
+ CircularReferenceHandle *crh2 = object2->findChild<CircularReferenceHandle*>("crh");
+ QVERIFY(crh1 != 0);
+ QVERIFY(crh2 != 0);
+ crh1->setEngine(&hrmEngine1);
+ crh2->setEngine(&hrmEngine2);
+ crh1->setDtorCount(&dtorCount);
+ crh2->setDtorCount(&dtorCount);
+ QMetaObject::invokeMethod(object1, "createReference");
+ QMetaObject::invokeMethod(object2, "createReference");
+ CircularReferenceHandle *first1 = object1->property("first").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *second1 = object1->property("second").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *first2 = object2->property("first").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *second2 = object2->property("second").value<CircularReferenceHandle*>();
+ QVERIFY(first1 != 0);
+ QVERIFY(second1 != 0);
+ QVERIFY(first2 != 0);
+ QVERIFY(second2 != 0);
+ first1->addReference(QQmlData::get(second2)->v8object); // create reference across engines
+ // now we have to reparent second2 and make second2 owned by JS.
+ second2->setParent(0);
+ QQmlEngine::setObjectOwnership(second2, QQmlEngine::JavaScriptOwnership);
+ gc(engine);
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 0); // due to reference from first1 to second2, second2 shouldn't be collected.
+ delete object1;
+ delete object2;
+ hrmEngine1.collectGarbage();
+ hrmEngine2.collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 6);
+ }
+
+ dtorCount = 0;
+ {
+ // multiple engine interaction - circular reference
+ QQmlEngine hrmEngine1;
+ QQmlEngine hrmEngine2;
+ QQmlComponent component1(&hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QQmlComponent component2(&hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QObject *object1 = component1.create();
+ QObject *object2 = component2.create();
+ QVERIFY(object1 != 0);
+ QVERIFY(object2 != 0);
+ CircularReferenceHandle *crh1 = object1->findChild<CircularReferenceHandle*>("crh");
+ CircularReferenceHandle *crh2 = object2->findChild<CircularReferenceHandle*>("crh");
+ QVERIFY(crh1 != 0);
+ QVERIFY(crh2 != 0);
+ crh1->setEngine(&hrmEngine1);
+ crh2->setEngine(&hrmEngine2);
+ crh1->setDtorCount(&dtorCount);
+ crh2->setDtorCount(&dtorCount);
+ QMetaObject::invokeMethod(object1, "createReference");
+ QMetaObject::invokeMethod(object2, "createReference");
+ CircularReferenceHandle *first1 = object1->property("first").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *second1 = object1->property("second").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *first2 = object2->property("first").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *second2 = object2->property("second").value<CircularReferenceHandle*>();
+ QVERIFY(first1 != 0);
+ QVERIFY(second1 != 0);
+ QVERIFY(first2 != 0);
+ QVERIFY(second2 != 0);
+ first1->addReference(QQmlData::get(second1)->v8object); // create linear reference within engine1
+ second1->addReference(QQmlData::get(second2)->v8object); // create linear reference across engines
+ second2->addReference(QQmlData::get(first2)->v8object); // create linear reference within engine2
+ first2->addReference(QQmlData::get(first1)->v8object); // close the loop - circular ref across engines
+ // now we have to reparent and change ownership to JS.
+ first1->setParent(0);
+ second1->setParent(0);
+ first2->setParent(0);
+ second2->setParent(0);
+ QQmlEngine::setObjectOwnership(first1, QQmlEngine::JavaScriptOwnership);
+ QQmlEngine::setObjectOwnership(second1, QQmlEngine::JavaScriptOwnership);
+ QQmlEngine::setObjectOwnership(first2, QQmlEngine::JavaScriptOwnership);
+ QQmlEngine::setObjectOwnership(second2, QQmlEngine::JavaScriptOwnership);
+ gc(engine);
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 4); // circular references shouldn't keep them alive.
+ delete object1;
+ delete object2;
+ hrmEngine1.collectGarbage();
+ hrmEngine2.collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 6);
+ }
+
+ dtorCount = 0;
+ {
+ // multiple engine interaction - linear reference with engine deletion
+ QQmlEngine *hrmEngine1 = new QQmlEngine;
+ QQmlEngine *hrmEngine2 = new QQmlEngine;
+ QQmlComponent component1(hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QQmlComponent component2(hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QObject *object1 = component1.create();
+ QObject *object2 = component2.create();
+ QVERIFY(object1 != 0);
+ QVERIFY(object2 != 0);
+ CircularReferenceHandle *crh1 = object1->findChild<CircularReferenceHandle*>("crh");
+ CircularReferenceHandle *crh2 = object2->findChild<CircularReferenceHandle*>("crh");
+ QVERIFY(crh1 != 0);
+ QVERIFY(crh2 != 0);
+ crh1->setEngine(hrmEngine1);
+ crh2->setEngine(hrmEngine2);
+ crh1->setDtorCount(&dtorCount);
+ crh2->setDtorCount(&dtorCount);
+ QMetaObject::invokeMethod(object1, "createReference");
+ QMetaObject::invokeMethod(object2, "createReference");
+ CircularReferenceHandle *first1 = object1->property("first").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *second1 = object1->property("second").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *first2 = object2->property("first").value<CircularReferenceHandle*>();
+ CircularReferenceHandle *second2 = object2->property("second").value<CircularReferenceHandle*>();
+ QVERIFY(first1 != 0);
+ QVERIFY(second1 != 0);
+ QVERIFY(first2 != 0);
+ QVERIFY(second2 != 0);
+ first1->addReference(QQmlData::get(second1)->v8object); // create linear reference within engine1
+ second1->addReference(QQmlData::get(second2)->v8object); // create linear reference across engines
+ second2->addReference(QQmlData::get(first2)->v8object); // create linear reference within engine2
+ // now we have to reparent and change ownership to JS.
+ first1->setParent(crh1);
+ second1->setParent(0);
+ first2->setParent(0);
+ second2->setParent(0);
+ QQmlEngine::setObjectOwnership(second1, QQmlEngine::JavaScriptOwnership);
+ QQmlEngine::setObjectOwnership(first2, QQmlEngine::JavaScriptOwnership);
+ QQmlEngine::setObjectOwnership(second2, QQmlEngine::JavaScriptOwnership);
+ gc(engine);
+ QCOMPARE(dtorCount, 0);
+ delete hrmEngine2;
+ gc(engine);
+ QCOMPARE(dtorCount, 0);
+ delete object1;
+ delete object2;
+ hrmEngine1->collectGarbage();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QCOMPARE(dtorCount, 6);
+ delete hrmEngine1;
+ }
+}
+
+void tst_qqmlecmascript::stringArg()
+{
+ QQmlComponent component(&engine, testFileUrl("stringArg.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "success");
+ QVERIFY(object->property("returnValue").toBool());
+
+ QString w1 = testFileUrl("stringArg.qml").toString() + QLatin1String(":45: Error: String.arg(): Invalid arguments");
+ QTest::ignoreMessage(QtWarningMsg, w1.toAscii().constData());
+ QMetaObject::invokeMethod(object, "failure");
+ QVERIFY(object->property("returnValue").toBool());
+
+ delete object;
+}
+
+void tst_qqmlecmascript::readonlyDeclaration()
+{
+ QQmlComponent component(&engine, testFileUrl("readonlyDeclaration.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+Q_DECLARE_METATYPE(QList<int>)
+Q_DECLARE_METATYPE(QList<qreal>)
+Q_DECLARE_METATYPE(QList<bool>)
+Q_DECLARE_METATYPE(QList<QString>)
+Q_DECLARE_METATYPE(QList<QUrl>)
+void tst_qqmlecmascript::sequenceConversionRead()
+{
+ {
+ QUrl qmlFile = testFileUrl("sequenceConversion.read.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco");
+ QVERIFY(seq != 0);
+
+ QMetaObject::invokeMethod(object, "readSequences");
+ QList<int> intList; intList << 1 << 2 << 3 << 4;
+ QCOMPARE(object->property("intListLength").toInt(), intList.length());
+ QCOMPARE(object->property("intList").value<QList<int> >(), intList);
+ QList<qreal> qrealList; qrealList << 1.1 << 2.2 << 3.3 << 4.4;
+ QCOMPARE(object->property("qrealListLength").toInt(), qrealList.length());
+ QCOMPARE(object->property("qrealList").value<QList<qreal> >(), qrealList);
+ QList<bool> boolList; boolList << true << false << true << false;
+ QCOMPARE(object->property("boolListLength").toInt(), boolList.length());
+ QCOMPARE(object->property("boolList").value<QList<bool> >(), boolList);
+ QList<QString> stringList; stringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
+ QCOMPARE(object->property("stringListLength").toInt(), stringList.length());
+ QCOMPARE(object->property("stringList").value<QList<QString> >(), stringList);
+ QList<QUrl> urlList; urlList << QUrl("http://www.example1.com") << QUrl("http://www.example2.com") << QUrl("http://www.example3.com");
+ QCOMPARE(object->property("urlListLength").toInt(), urlList.length());
+ QCOMPARE(object->property("urlList").value<QList<QUrl> >(), urlList);
+ QStringList qstringList; qstringList << QLatin1String("first") << QLatin1String("second") << QLatin1String("third") << QLatin1String("fourth");
+ QCOMPARE(object->property("qstringListLength").toInt(), qstringList.length());
+ QCOMPARE(object->property("qstringList").value<QStringList>(), qstringList);
+
+ QMetaObject::invokeMethod(object, "readSequenceElements");
+ QCOMPARE(object->property("intVal").toInt(), 2);
+ QCOMPARE(object->property("qrealVal").toReal(), 2.2);
+ QCOMPARE(object->property("boolVal").toBool(), false);
+ QCOMPARE(object->property("stringVal").toString(), QString(QLatin1String("second")));
+ QCOMPARE(object->property("urlVal").toUrl(), QUrl("http://www.example2.com"));
+ QCOMPARE(object->property("qstringVal").toString(), QString(QLatin1String("second")));
+
+ QMetaObject::invokeMethod(object, "enumerateSequenceElements");
+ QCOMPARE(object->property("enumerationMatches").toBool(), true);
+
+ intList.clear(); intList << 1 << 2 << 3 << 4 << 5; // set by the enumerateSequenceElements test.
+ QQmlProperty seqProp(seq, "intListProperty");
+ QCOMPARE(seqProp.read().value<QList<int> >(), intList);
+ QQmlProperty seqProp2(seq, "intListProperty", &engine);
+ QCOMPARE(seqProp2.read().value<QList<int> >(), intList);
+
+ QMetaObject::invokeMethod(object, "testReferenceDeletion");
+ QCOMPARE(object->property("referenceDeletion").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QUrl qmlFile = testFileUrl("sequenceConversion.read.error.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco");
+ QVERIFY(seq != 0);
+
+ // we haven't registered QList<QPoint> as a sequence type.
+ QString warningOne = QLatin1String("QMetaProperty::read: Unable to handle unregistered datatype 'QList<QPoint>' for property 'MySequenceConversionObject::pointListProperty'");
+ QString warningTwo = qmlFile.toString() + QLatin1String(":18: TypeError: Cannot read property 'length' of undefined");
+ QTest::ignoreMessage(QtWarningMsg, warningOne.toAscii().constData());
+ QTest::ignoreMessage(QtWarningMsg, warningTwo.toAscii().constData());
+
+ QMetaObject::invokeMethod(object, "performTest");
+
+ // QList<QPoint> has not been registered as a sequence type.
+ QCOMPARE(object->property("pointListLength").toInt(), 0);
+ QVERIFY(!object->property("pointList").isValid());
+ QTest::ignoreMessage(QtWarningMsg, "QMetaProperty::read: Unable to handle unregistered datatype 'QList<QPoint>' for property 'MySequenceConversionObject::pointListProperty'");
+ QQmlProperty seqProp(seq, "pointListProperty", &engine);
+ QVERIFY(!seqProp.read().isValid()); // not a valid/known sequence type
+
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::sequenceConversionWrite()
+{
+ {
+ QUrl qmlFile = testFileUrl("sequenceConversion.write.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco");
+ QVERIFY(seq != 0);
+
+ QMetaObject::invokeMethod(object, "writeSequences");
+ QCOMPARE(object->property("success").toBool(), true);
+
+ QMetaObject::invokeMethod(object, "writeSequenceElements");
+ QCOMPARE(object->property("success").toBool(), true);
+
+ QMetaObject::invokeMethod(object, "writeOtherElements");
+ QCOMPARE(object->property("success").toBool(), true);
+
+ QMetaObject::invokeMethod(object, "testReferenceDeletion");
+ QCOMPARE(object->property("referenceDeletion").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QUrl qmlFile = testFileUrl("sequenceConversion.write.error.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ MySequenceConversionObject *seq = object->findChild<MySequenceConversionObject*>("msco");
+ QVERIFY(seq != 0);
+
+ // we haven't registered QList<QPoint> as a sequence type, so writing shouldn't work.
+ QString warningOne = qmlFile.toString() + QLatin1String(":16: Error: Cannot assign QVariantList to void");
+ QTest::ignoreMessage(QtWarningMsg, warningOne.toAscii().constData());
+
+ QMetaObject::invokeMethod(object, "performTest");
+
+ QList<QPoint> pointList; pointList << QPoint(1, 2) << QPoint(3, 4) << QPoint(5, 6); // original values, shouldn't have changed
+ QCOMPARE(seq->pointListProperty(), pointList);
+
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::sequenceConversionArray()
+{
+ // ensure that in JS the returned sequences act just like normal JS Arrays.
+ QUrl qmlFile = testFileUrl("sequenceConversion.array.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "indexedAccess");
+ QVERIFY(object->property("success").toBool());
+ QMetaObject::invokeMethod(object, "arrayOperations");
+ QVERIFY(object->property("success").toBool());
+ QMetaObject::invokeMethod(object, "testEqualitySemantics");
+ QVERIFY(object->property("success").toBool());
+ QMetaObject::invokeMethod(object, "testReferenceDeletion");
+ QCOMPARE(object->property("referenceDeletion").toBool(), true);
+ delete object;
+}
+
+
+void tst_qqmlecmascript::sequenceConversionIndexes()
+{
+ // ensure that we gracefully fail if unsupported index values are specified.
+ // Qt container classes only support non-negative, signed integer index values.
+ QUrl qmlFile = testFileUrl("sequenceConversion.indexes.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QString w1 = qmlFile.toString() + QLatin1String(":34: Index out of range during length set");
+ QString w2 = qmlFile.toString() + QLatin1String(":41: Index out of range during indexed set");
+ QString w3 = qmlFile.toString() + QLatin1String(":48: Index out of range during indexed get");
+ QString w4 = qmlFile.toString() + QLatin1String(":78: std::bad_alloc during length set");
+ QString w5 = qmlFile.toString() + QLatin1String(":83: std::bad_alloc during indexed set");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(w1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(w2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(w3));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(w4));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(w5));
+ QMetaObject::invokeMethod(object, "indexedAccess");
+ QVERIFY(object->property("success").toBool());
+ delete object;
+}
+
+void tst_qqmlecmascript::sequenceConversionThreads()
+{
+ // ensure that sequence conversion operations work correctly in a worker thread
+ // and that serialisation between the main and worker thread succeeds.
+ QUrl qmlFile = testFileUrl("sequenceConversion.threads.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QMetaObject::invokeMethod(object, "testIntSequence");
+ QTRY_VERIFY(object->property("finished").toBool());
+ QVERIFY(object->property("success").toBool());
+
+ QMetaObject::invokeMethod(object, "testQrealSequence");
+ QTRY_VERIFY(object->property("finished").toBool());
+ QVERIFY(object->property("success").toBool());
+
+ QMetaObject::invokeMethod(object, "testBoolSequence");
+ QTRY_VERIFY(object->property("finished").toBool());
+ QVERIFY(object->property("success").toBool());
+
+ QMetaObject::invokeMethod(object, "testStringSequence");
+ QTRY_VERIFY(object->property("finished").toBool());
+ QVERIFY(object->property("success").toBool());
+
+ QMetaObject::invokeMethod(object, "testQStringSequence");
+ QTRY_VERIFY(object->property("finished").toBool());
+ QVERIFY(object->property("success").toBool());
+
+ QMetaObject::invokeMethod(object, "testUrlSequence");
+ QTRY_VERIFY(object->property("finished").toBool());
+ QVERIFY(object->property("success").toBool());
+
+ QMetaObject::invokeMethod(object, "testVariantSequence");
+ QTRY_VERIFY(object->property("finished").toBool());
+ QVERIFY(object->property("success").toBool());
+
+ delete object;
+}
+
+void tst_qqmlecmascript::sequenceConversionBindings()
+{
+ {
+ QUrl qmlFile = testFileUrl("sequenceConversion.bindings.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QList<int> intList; intList << 1 << 2 << 3 << 12 << 7;
+ QCOMPARE(object->property("boundSequence").value<QList<int> >(), intList);
+ QCOMPARE(object->property("boundElement").toInt(), intList.at(3));
+ QList<int> intListTwo; intListTwo << 1 << 2 << 3 << 12 << 14;
+ QCOMPARE(object->property("boundSequenceTwo").value<QList<int> >(), intListTwo);
+ delete object;
+ }
+
+ {
+ QUrl qmlFile = testFileUrl("sequenceConversion.bindings.error.qml");
+ QString warning = QString(QLatin1String("%1:17: Unable to assign QList<int> to QList<bool>")).arg(qmlFile.toString());
+ QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::sequenceConversionCopy()
+{
+ QUrl qmlFile = testFileUrl("sequenceConversion.copy.qml");
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QMetaObject::invokeMethod(object, "testCopySequences");
+ QCOMPARE(object->property("success").toBool(), true);
+ QMetaObject::invokeMethod(object, "readSequenceCopyElements");
+ QCOMPARE(object->property("success").toBool(), true);
+ QMetaObject::invokeMethod(object, "testEqualitySemantics");
+ QCOMPARE(object->property("success").toBool(), true);
+ delete object;
+}
+
+void tst_qqmlecmascript::assignSequenceTypes()
+{
+ // test binding array to sequence type property
+ {
+ QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.1.qml"));
+ MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->intListProperty(), (QList<int>() << 1 << 2));
+ QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1 << 2.2));
+ QCOMPARE(object->boolListProperty(), (QList<bool>() << false << true));
+ QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl("http://www.example1.com") << QUrl("http://www.example2.com")));
+ QCOMPARE(object->stringListProperty(), (QList<QString>() << QLatin1String("one") << QLatin1String("two")));
+ QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("one") << QLatin1String("two")));
+ delete object;
+ }
+
+ // test binding literal to sequence type property
+ {
+ QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.2.qml"));
+ MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->intListProperty(), (QList<int>() << 1));
+ QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
+ QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
+ QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl("http://www.example1.com")));
+ QCOMPARE(object->stringListProperty(), (QList<QString>() << QLatin1String("one")));
+ QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("two")));
+ delete object;
+ }
+
+ // test binding single value to sequence type property
+ {
+ QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.3.qml"));
+ MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->intListProperty(), (QList<int>() << 1));
+ QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
+ QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
+ QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
+ delete object;
+ }
+
+ // test assigning array to sequence type property in js function
+ {
+ QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.4.qml"));
+ MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->intListProperty(), (QList<int>() << 1 << 2));
+ QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1 << 2.2));
+ QCOMPARE(object->boolListProperty(), (QList<bool>() << false << true));
+ QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl("http://www.example1.com") << QUrl("http://www.example2.com")));
+ QCOMPARE(object->stringListProperty(), (QList<QString>() << QLatin1String("one") << QLatin1String("two")));
+ QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("one") << QLatin1String("two")));
+ delete object;
+ }
+
+ // test assigning literal to sequence type property in js function
+ {
+ QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.5.qml"));
+ MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->intListProperty(), (QList<int>() << 1));
+ QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
+ QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
+ QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl("http://www.example1.com")));
+ QCOMPARE(object->stringListProperty(), (QList<QString>() << QLatin1String("one")));
+ QCOMPARE(object->qstringListProperty(), (QStringList() << QLatin1String("two")));
+ delete object;
+ }
+
+ // test assigning single value to sequence type property in js function
+ {
+ QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.6.qml"));
+ MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->intListProperty(), (QList<int>() << 1));
+ QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
+ QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
+ QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
+ delete object;
+ }
+
+ // test QList<QUrl> literal assignment and binding assignment causes url resolution when required
+ {
+ QQmlComponent component(&engine, testFileUrl("assignSequenceTypes.7.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ MySequenceConversionObject *msco1 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco1"));
+ MySequenceConversionObject *msco2 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco2"));
+ MySequenceConversionObject *msco3 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco3"));
+ MySequenceConversionObject *msco4 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco4"));
+ MySequenceConversionObject *msco5 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco5"));
+ QVERIFY(msco1 != 0 && msco2 != 0 && msco3 != 0 && msco4 != 0 && msco5 != 0);
+ QCOMPARE(msco1->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
+ QCOMPARE(msco2->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
+ QCOMPARE(msco3->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
+ QCOMPARE(msco4->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
+ QCOMPARE(msco5->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
+ delete object;
+ }
+}
+
+// Test that assigning a null object works
+// Regressed with: df1788b4dbbb2826ae63f26bdf166342595343f4
+void tst_qqmlecmascript::nullObjectBinding()
+{
+ QQmlComponent component(&engine, testFileUrl("nullObjectBinding.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(object->property("test") == QVariant::fromValue((QObject *)0));
+
+ delete object;
+}
+
+// Test that bindings don't evaluate once the engine has been destroyed
+void tst_qqmlecmascript::deletedEngine()
+{
+ QQmlEngine *engine = new QQmlEngine;
+ QQmlComponent component(engine, testFileUrl("deletedEngine.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("a").toInt(), 39);
+ object->setProperty("b", QVariant(9));
+ QCOMPARE(object->property("a").toInt(), 117);
+
+ delete engine;
+
+ QCOMPARE(object->property("a").toInt(), 117);
+ object->setProperty("b", QVariant(10));
+ QCOMPARE(object->property("a").toInt(), 117);
+
+ delete object;
+}
+
+// Test the crashing part of QTBUG-9705
+void tst_qqmlecmascript::libraryScriptAssert()
+{
+ QQmlComponent component(&engine, testFileUrl("libraryScriptAssert.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::variantsAssignedUndefined()
+{
+ QQmlComponent component(&engine, testFileUrl("variantsAssignedUndefined.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toInt(), 10);
+ QCOMPARE(object->property("test2").toInt(), 11);
+
+ object->setProperty("runTest", true);
+
+ QCOMPARE(object->property("test1"), QVariant());
+ QCOMPARE(object->property("test2"), QVariant());
+
+
+ delete object;
+}
+
+void tst_qqmlecmascript::qtbug_9792()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_9792.qml"));
+
+ QQmlContext *context = new QQmlContext(engine.rootContext());
+
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create(context));
+ QVERIFY(object != 0);
+
+ QTest::ignoreMessage(QtDebugMsg, "Hello world!");
+ object->basicSignal();
+
+ delete context;
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ object->basicSignal();
+
+ qInstallMsgHandler(old);
+
+ QCOMPARE(transientErrorsMsgCount, 0);
+
+ delete object;
+}
+
+// Verifies that QQmlGuard<>s used in the vmemetaobject are cleaned correctly
+void tst_qqmlecmascript::qtcreatorbug_1289()
+{
+ QQmlComponent component(&engine, testFileUrl("qtcreatorbug_1289.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QObject *nested = qvariant_cast<QObject *>(o->property("object"));
+ QVERIFY(nested != 0);
+
+ QVERIFY(qvariant_cast<QObject *>(nested->property("nestedObject")) == o);
+
+ delete nested;
+ nested = qvariant_cast<QObject *>(o->property("object"));
+ QVERIFY(nested == 0);
+
+ // If the bug is present, the next line will crash
+ delete o;
+}
+
+// Test that we shut down without stupid warnings
+void tst_qqmlecmascript::noSpuriousWarningsAtShutdown()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("noSpuriousWarningsAtShutdown.qml"));
+
+ QObject *o = component.create();
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ delete o;
+
+ qInstallMsgHandler(old);
+
+ QCOMPARE(transientErrorsMsgCount, 0);
+ }
+
+
+ {
+ QQmlComponent component(&engine, testFileUrl("noSpuriousWarningsAtShutdown.2.qml"));
+
+ QObject *o = component.create();
+
+ transientErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
+
+ delete o;
+
+ qInstallMsgHandler(old);
+
+ QCOMPARE(transientErrorsMsgCount, 0);
+ }
+}
+
+void tst_qqmlecmascript::canAssignNullToQObject()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("canAssignNullToQObject.1.qml"));
+
+ MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(o != 0);
+
+ QVERIFY(o->objectProperty() != 0);
+
+ o->setProperty("runTest", true);
+
+ QVERIFY(o->objectProperty() == 0);
+
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("canAssignNullToQObject.2.qml"));
+
+ MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(o != 0);
+
+ QVERIFY(o->objectProperty() == 0);
+
+ delete o;
+ }
+}
+
+void tst_qqmlecmascript::functionAssignment_fromBinding()
+{
+ QQmlComponent component(&engine, testFileUrl("functionAssignment.1.qml"));
+
+ QString url = component.url().toString();
+ QString warning = url + ":4: Unable to assign a function to a property.";
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+
+ MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(o != 0);
+
+ QVERIFY(!o->property("a").isValid());
+
+ delete o;
+}
+
+void tst_qqmlecmascript::functionAssignment_fromJS()
+{
+ QFETCH(QString, triggerProperty);
+
+ QQmlComponent component(&engine, testFileUrl("functionAssignment.2.qml"));
+ QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
+
+ MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(o != 0);
+ QVERIFY(!o->property("a").isValid());
+
+ o->setProperty("aNumber", QVariant(5));
+ o->setProperty(triggerProperty.toUtf8().constData(), true);
+ QCOMPARE(o->property("a"), QVariant(50));
+
+ o->setProperty("aNumber", QVariant(10));
+ QCOMPARE(o->property("a"), QVariant(100));
+
+ delete o;
+}
+
+void tst_qqmlecmascript::functionAssignment_fromJS_data()
+{
+ QTest::addColumn<QString>("triggerProperty");
+
+ QTest::newRow("assign to property") << "assignToProperty";
+ QTest::newRow("assign to property, from JS file") << "assignToPropertyFromJsFile";
+
+ QTest::newRow("assign to value type") << "assignToValueType";
+
+ QTest::newRow("use 'this'") << "assignWithThis";
+ QTest::newRow("use 'this' from JS file") << "assignWithThisFromJsFile";
+}
+
+void tst_qqmlecmascript::functionAssignmentfromJS_invalid()
+{
+ QQmlComponent component(&engine, testFileUrl("functionAssignment.2.qml"));
+ QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
+
+ MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(o != 0);
+ QVERIFY(!o->property("a").isValid());
+
+ o->setProperty("assignFuncWithoutReturn", true);
+ QVERIFY(!o->property("a").isValid());
+
+ QString url = component.url().toString();
+ QString warning = url + ":67: Unable to assign QString to int";
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ o->setProperty("assignWrongType", true);
+
+ warning = url + ":71: Unable to assign QString to int";
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+ o->setProperty("assignWrongTypeToValueType", true);
+
+ delete o;
+}
+
+void tst_qqmlecmascript::eval()
+{
+ QQmlComponent component(&engine, testFileUrl("eval.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+
+ delete o;
+}
+
+void tst_qqmlecmascript::function()
+{
+ QQmlComponent component(&engine, testFileUrl("function.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+
+ delete o;
+}
+
+void tst_qqmlecmascript::functionException()
+{
+ // QTBUG-24037 - shouldn't crash.
+ QString errstr = testFileUrl("v8functionException.qml").toString() + QLatin1String(":13: SyntaxError: Unexpected token ILLEGAL");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(errstr));
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Exception occurred during compilation of function: dynamicSlot()");
+ QQmlComponent component(&engine, testFileUrl("v8functionException.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QMetaObject::invokeMethod(o, "dynamicSlot");
+ delete o;
+}
+
+// Test the "Qt.include" method
+void tst_qqmlecmascript::include()
+{
+ // Non-library relative include
+ {
+ QQmlComponent component(&engine, testFileUrl("include.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test0").toInt(), 99);
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test2_1").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test3_1").toBool(), true);
+
+ delete o;
+ }
+
+ // Library relative include
+ {
+ QQmlComponent component(&engine, testFileUrl("include_shared.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test0").toInt(), 99);
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test2_1").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test3_1").toBool(), true);
+
+ delete o;
+ }
+
+ // Callback
+ {
+ QQmlComponent component(&engine, testFileUrl("include_callback.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+ QCOMPARE(o->property("test6").toBool(), true);
+
+ delete o;
+ }
+
+ // Including file with ".pragma library"
+ {
+ QQmlComponent component(&engine, testFileUrl("include_pragma.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test1").toInt(), 100);
+
+ delete o;
+ }
+
+ // Remote - success
+ {
+ TestHTTPServer server(8111);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+
+ QQmlComponent component(&engine, testFileUrl("include_remote.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ 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);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+
+ QCOMPARE(o->property("test6").toBool(), true);
+ QCOMPARE(o->property("test7").toBool(), true);
+ QCOMPARE(o->property("test8").toBool(), true);
+ QCOMPARE(o->property("test9").toBool(), true);
+ QCOMPARE(o->property("test10").toBool(), true);
+
+ delete o;
+ }
+
+ // Remote - error
+ {
+ TestHTTPServer server(8111);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+
+ QQmlComponent component(&engine, testFileUrl("include_remote_missing.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QTRY_VERIFY(o->property("done").toBool() == true);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+
+ delete o;
+ }
+}
+
+void tst_qqmlecmascript::signalHandlers()
+{
+ QQmlComponent component(&engine, testFileUrl("signalHandlers.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QVERIFY(o->property("count").toInt() == 0);
+ QMetaObject::invokeMethod(o, "testSignalCall");
+ QCOMPARE(o->property("count").toInt(), 1);
+
+ QMetaObject::invokeMethod(o, "testSignalHandlerCall");
+ QCOMPARE(o->property("count").toInt(), 1);
+ QCOMPARE(o->property("errorString").toString(), QLatin1String("TypeError: Property 'onTestSignal' of object [object Object] is not a function"));
+
+ QVERIFY(o->property("funcCount").toInt() == 0);
+ QMetaObject::invokeMethod(o, "testSignalConnection");
+ QCOMPARE(o->property("funcCount").toInt(), 1);
+
+ QMetaObject::invokeMethod(o, "testSignalHandlerConnection");
+ QCOMPARE(o->property("funcCount").toInt(), 2);
+
+ QMetaObject::invokeMethod(o, "testSignalDefined");
+ QCOMPARE(o->property("definedResult").toBool(), true);
+
+ QMetaObject::invokeMethod(o, "testSignalHandlerDefined");
+ QCOMPARE(o->property("definedHandlerResult").toBool(), true);
+
+ delete o;
+}
+
+void tst_qqmlecmascript::qtbug_10696()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_10696.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ delete o;
+}
+
+void tst_qqmlecmascript::qtbug_11606()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_11606.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+void tst_qqmlecmascript::qtbug_11600()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_11600.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+void tst_qqmlecmascript::qtbug_21864()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_21864.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+void tst_qqmlecmascript::rewriteMultiLineStrings()
+{
+ // QTBUG-23387
+ QQmlComponent component(&engine, testFileUrl("rewriteMultiLineStrings.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QTRY_COMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+void tst_qqmlecmascript::qobjectConnectionListExceptionHandling()
+{
+ // QTBUG-23375
+ QQmlComponent component(&engine, testFileUrl("qobjectConnectionListExceptionHandling.qml"));
+ QString warning = component.url().toString() + QLatin1String(":13: TypeError: Cannot read property 'undefined' of undefined");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+// Reading and writing non-scriptable properties should fail
+void tst_qqmlecmascript::nonscriptable()
+{
+ QQmlComponent component(&engine, testFileUrl("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_qqmlecmascript::deleteLater()
+{
+ QQmlComponent component(&engine, testFileUrl("deleteLater.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+void tst_qqmlecmascript::in()
+{
+ QQmlComponent component(&engine, testFileUrl("in.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ delete o;
+}
+
+void tst_qqmlecmascript::typeOf()
+{
+ QQmlComponent component(&engine, testFileUrl("typeOf.qml"));
+
+ // These warnings should not happen once QTBUG-21864 is fixed
+ QString warning1 = component.url().toString() + QLatin1String(":16: Error: Cannot assign [undefined] to QString");
+ QString warning2 = component.url().resolved(QUrl("typeOf.js")).toString() + QLatin1String(":1: ReferenceError: Can't find variable: a");
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QEXPECT_FAIL("", "QTBUG-21864", Abort);
+ QCOMPARE(o->property("test1").toString(), QLatin1String("undefined"));
+ QCOMPARE(o->property("test2").toString(), QLatin1String("object"));
+ QCOMPARE(o->property("test3").toString(), QLatin1String("number"));
+ QCOMPARE(o->property("test4").toString(), QLatin1String("string"));
+ QCOMPARE(o->property("test5").toString(), QLatin1String("function"));
+ QCOMPARE(o->property("test6").toString(), QLatin1String("object"));
+ QCOMPARE(o->property("test7").toString(), QLatin1String("undefined"));
+ QCOMPARE(o->property("test8").toString(), QLatin1String("boolean"));
+ QCOMPARE(o->property("test9").toString(), QLatin1String("object"));
+
+ delete o;
+}
+
+void tst_qqmlecmascript::sharedAttachedObject()
+{
+ QQmlComponent component(&engine, testFileUrl("sharedAttachedObject.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ delete o;
+}
+
+// QTBUG-13999
+void tst_qqmlecmascript::objectName()
+{
+ QQmlComponent component(&engine, testFileUrl("objectName.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toString(), QString("hello"));
+ QCOMPARE(o->property("test2").toString(), QString("ell"));
+
+ o->setObjectName("world");
+
+ QCOMPARE(o->property("test1").toString(), QString("world"));
+ QCOMPARE(o->property("test2").toString(), QString("orl"));
+
+ delete o;
+}
+
+void tst_qqmlecmascript::writeRemovesBinding()
+{
+ QQmlComponent component(&engine, testFileUrl("writeRemovesBinding.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+}
+
+// Test bindings assigned to alias properties actually assign to the alias' target
+void tst_qqmlecmascript::aliasBindingsAssignCorrectly()
+{
+ QQmlComponent component(&engine, testFileUrl("aliasBindingsAssignCorrectly.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+}
+
+// Test bindings assigned to alias properties override a binding on the target (QTBUG-13719)
+void tst_qqmlecmascript::aliasBindingsOverrideTarget()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.2.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.3.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+}
+
+// Test that writes to alias properties override bindings on the alias target (QTBUG-13719)
+void tst_qqmlecmascript::aliasWritesOverrideBindings()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.2.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.3.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+}
+
+// Allow an alais to a composite element
+// QTBUG-20200
+void tst_qqmlecmascript::aliasToCompositeElement()
+{
+ QQmlComponent component(&engine, testFileUrl("aliasToCompositeElement.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::qtbug_20344()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_20344.qml"));
+
+ QString warning = component.url().toString() + ":5: Error: Exception thrown from within QObject slot";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::revisionErrors()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("metaobjectRevisionErrors.qml"));
+ QString url = component.url().toString();
+
+ QString warning1 = url + ":8: ReferenceError: Can't find variable: prop2";
+ QString warning2 = url + ":11: ReferenceError: Can't find variable: prop2";
+ QString warning3 = url + ":13: ReferenceError: Can't find variable: method2";
+
+ QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
+ MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
+ QVERIFY(object != 0);
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("metaobjectRevisionErrors2.qml"));
+ QString url = component.url().toString();
+
+ // MyRevisionedSubclass 1.0 uses MyRevisionedClass revision 0
+ // method2, prop2 from MyRevisionedClass not available
+ // method4, prop4 from MyRevisionedSubclass not available
+ QString warning1 = url + ":8: ReferenceError: Can't find variable: prop2";
+ QString warning2 = url + ":14: ReferenceError: Can't find variable: prop2";
+ QString warning3 = url + ":10: ReferenceError: Can't find variable: prop4";
+ QString warning4 = url + ":16: ReferenceError: Can't find variable: prop4";
+ QString warning5 = url + ":20: ReferenceError: Can't find variable: method2";
+
+ QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning4.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning5.toLatin1().constData());
+ MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
+ QVERIFY(object != 0);
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("metaobjectRevisionErrors3.qml"));
+ QString url = component.url().toString();
+
+ // MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1
+ // All properties/methods available, except MyRevisionedBaseClassUnregistered rev 1
+ QString warning1 = url + ":30: ReferenceError: Can't find variable: methodD";
+ QString warning2 = url + ":10: ReferenceError: Can't find variable: propD";
+ QString warning3 = url + ":20: ReferenceError: Can't find variable: propD";
+ QTest::ignoreMessage(QtWarningMsg, warning1.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning2.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, warning3.toLatin1().constData());
+ MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
+ QVERIFY(object != 0);
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::revision()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("metaobjectRevision.qml"));
+ QString url = component.url().toString();
+
+ MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
+ QVERIFY(object != 0);
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("metaobjectRevision2.qml"));
+ QString url = component.url().toString();
+
+ MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
+ QVERIFY(object != 0);
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("metaobjectRevision3.qml"));
+ QString url = component.url().toString();
+
+ MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
+ QVERIFY(object != 0);
+ delete object;
+ }
+ // Test that non-root classes can resolve revisioned methods
+ {
+ QQmlComponent component(&engine, testFileUrl("metaobjectRevision4.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toReal(), 11.);
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::realToInt()
+{
+ QQmlComponent component(&engine, testFileUrl("realToInt.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+
+ QMetaObject::invokeMethod(object, "test1");
+ QCOMPARE(object->value(), int(4));
+ QMetaObject::invokeMethod(object, "test2");
+ QCOMPARE(object->value(), int(8));
+}
+
+void tst_qqmlecmascript::urlProperty()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("urlProperty.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ object->setStringProperty("http://qt-project.org");
+ QCOMPARE(object->urlProperty(), QUrl("http://qt-project.org/index.html"));
+ QCOMPARE(object->intProperty(), 123);
+ QCOMPARE(object->value(), 1);
+ QCOMPARE(object->property("result").toBool(), true);
+ }
+}
+
+void tst_qqmlecmascript::urlPropertyWithEncoding()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("urlProperty.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ object->setStringProperty("http://qt-project.org");
+ QUrl encoded;
+ encoded.setEncodedUrl("http://qt-project.org/?get%3cDATA%3e", QUrl::TolerantMode);
+ QCOMPARE(object->urlProperty(), encoded);
+ QCOMPARE(object->value(), 0); // Interpreting URL as string yields canonicalised version
+ QCOMPARE(object->property("result").toBool(), true);
+ }
+}
+
+void tst_qqmlecmascript::urlListPropertyWithEncoding()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("urlListProperty.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ MySequenceConversionObject *msco1 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco1"));
+ MySequenceConversionObject *msco2 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco2"));
+ MySequenceConversionObject *msco3 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco3"));
+ MySequenceConversionObject *msco4 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco4"));
+ QVERIFY(msco1 != 0 && msco2 != 0 && msco3 != 0 && msco4 != 0);
+ QUrl encoded;
+ encoded.setEncodedUrl("http://qt-project.org/?get%3cDATA%3e", QUrl::TolerantMode);
+ QCOMPARE(msco1->urlListProperty(), (QList<QUrl>() << encoded));
+ QCOMPARE(msco2->urlListProperty(), (QList<QUrl>() << encoded));
+ QCOMPARE(msco3->urlListProperty(), (QList<QUrl>() << encoded << encoded));
+ QCOMPARE(msco4->urlListProperty(), (QList<QUrl>() << encoded << encoded));
+ delete object;
+ }
+}
+
+void tst_qqmlecmascript::dynamicString()
+{
+ QQmlComponent component(&engine, testFileUrl("dynamicString.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("stringProperty").toString(),
+ QString::fromLatin1("string:Hello World false:0 true:1 uint32:100 int32:-100 double:3.14159 date:2011-02-11 05::30:50!"));
+}
+
+void tst_qqmlecmascript::automaticSemicolon()
+{
+ QQmlComponent component(&engine, testFileUrl("automaticSemicolon.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+void tst_qqmlecmascript::unaryExpression()
+{
+ QQmlComponent component(&engine, testFileUrl("unaryExpression.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+// Makes sure that a binding isn't double re-evaluated when it depends on the same variable twice
+void tst_qqmlecmascript::doubleEvaluate()
+{
+ QQmlComponent component(&engine, testFileUrl("doubleEvaluate.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ WriteCounter *wc = qobject_cast<WriteCounter *>(object);
+ QVERIFY(wc != 0);
+ QCOMPARE(wc->count(), 1);
+
+ wc->setProperty("x", 9);
+
+ QCOMPARE(wc->count(), 2);
+
+ delete object;
+}
+
+static QStringList messages;
+static void captureMsgHandler(QtMsgType, const char *msg)
+{
+ messages.append(QLatin1String(msg));
+}
+
+void tst_qqmlecmascript::nonNotifyable()
+{
+ QV4Compiler::enableV4(false);
+ QQmlComponent component(&engine, testFileUrl("nonNotifyable.qml"));
+ QV4Compiler::enableV4(true);
+
+ QtMsgHandler old = qInstallMsgHandler(captureMsgHandler);
+ messages.clear();
+ QObject *object = component.create();
+ qInstallMsgHandler(old);
+
+ QVERIFY(object != 0);
+
+ QString expected1 = QLatin1String("QQmlExpression: Expression ") +
+ component.url().toString() +
+ QLatin1String(":5 depends on non-NOTIFYable properties:");
+ QString expected2 = QLatin1String(" ") +
+ QLatin1String(object->metaObject()->className()) +
+ QLatin1String("::value");
+
+ QCOMPARE(messages.length(), 2);
+ QCOMPARE(messages.at(0), expected1);
+ QCOMPARE(messages.at(1), expected2);
+
+ delete object;
+}
+
+void tst_qqmlecmascript::forInLoop()
+{
+ QQmlComponent component(&engine, testFileUrl("forInLoop.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QMetaObject::invokeMethod(object, "listProperty");
+
+ QStringList r = object->property("listResult").toString().split("|", QString::SkipEmptyParts);
+ QCOMPARE(r.size(), 3);
+ QCOMPARE(r[0],QLatin1String("0=obj1"));
+ QCOMPARE(r[1],QLatin1String("1=obj2"));
+ QCOMPARE(r[2],QLatin1String("2=obj3"));
+
+ //TODO: should test for in loop for other objects (such as QObjects) as well.
+
+ delete object;
+}
+
+// An object the binding depends on is deleted while the binding is still running
+void tst_qqmlecmascript::deleteWhileBindingRunning()
+{
+ QQmlComponent component(&engine, testFileUrl("deleteWhileBindingRunning.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlecmascript::qtbug_22679()
+{
+ MyQmlObject object;
+ object.setStringProperty(QLatin1String("Please work correctly"));
+ engine.rootContext()->setContextProperty("contextProp", &object);
+
+ QQmlComponent component(&engine, testFileUrl("qtbug_22679.qml"));
+ qRegisterMetaType<QList<QQmlError> >("QList<QQmlError>");
+ QSignalSpy warningsSpy(&engine, SIGNAL(warnings(QList<QQmlError>)));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(warningsSpy.count(), 0);
+ delete o;
+}
+
+void tst_qqmlecmascript::qtbug_22843_data()
+{
+ QTest::addColumn<bool>("library");
+
+ QTest::newRow("without .pragma library") << false;
+ QTest::newRow("with .pragma library") << true;
+}
+
+void tst_qqmlecmascript::qtbug_22843()
+{
+ QFETCH(bool, library);
+
+ QString fileName("qtbug_22843");
+ if (library)
+ fileName += QLatin1String(".library");
+ fileName += QLatin1String(".qml");
+
+ QQmlComponent component(&engine, testFileUrl(fileName));
+ QString url = component.url().toString();
+ QString warning1 = url.left(url.length()-3) + QLatin1String("js:4: SyntaxError: Unexpected token )");
+ QString warning2 = url + QLatin1String(":5: TypeError: Object [object Object] has no method 'func'");
+
+ qRegisterMetaType<QList<QQmlError> >("QList<QQmlError>");
+ QSignalSpy warningsSpy(&engine, SIGNAL(warnings(QList<QQmlError>)));
+ for (int x = 0; x < 3; ++x) {
+ warningsSpy.clear();
+ // For libraries, only the first import attempt should produce a
+ // SyntaxError warning; subsequent component creation should not
+ // attempt to reload the script.
+ bool expectSyntaxError = !library || (x == 0);
+ if (expectSyntaxError)
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(warningsSpy.count(), 1 + (expectSyntaxError?1:0));
+ delete object;
+ }
+}
+
+
+void tst_qqmlecmascript::switchStatement()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("switchStatement.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ // `object->value()' is the number of executed statements
+
+ object->setStringProperty("A");
+ QCOMPARE(object->value(), 5);
+
+ object->setStringProperty("S");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("D");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("F");
+ QCOMPARE(object->value(), 4);
+
+ object->setStringProperty("something else");
+ QCOMPARE(object->value(), 1);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("switchStatement.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ // `object->value()' is the number of executed statements
+
+ object->setStringProperty("A");
+ QCOMPARE(object->value(), 5);
+
+ object->setStringProperty("S");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("D");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("F");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("something else");
+ QCOMPARE(object->value(), 4);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("switchStatement.3.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ // `object->value()' is the number of executed statements
+
+ object->setStringProperty("A");
+ QCOMPARE(object->value(), 5);
+
+ object->setStringProperty("S");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("D");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("F");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("something else");
+ QCOMPARE(object->value(), 6);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("switchStatement.4.qml"));
+
+ QString warning = component.url().toString() + ":4: Unable to assign [undefined] to int";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ // `object->value()' is the number of executed statements
+
+ object->setStringProperty("A");
+ QCOMPARE(object->value(), 5);
+
+ object->setStringProperty("S");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("D");
+ QCOMPARE(object->value(), 3);
+
+ object->setStringProperty("F");
+ QCOMPARE(object->value(), 3);
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ object->setStringProperty("something else");
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("switchStatement.5.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ // `object->value()' is the number of executed statements
+
+ object->setStringProperty("A");
+ QCOMPARE(object->value(), 1);
+
+ object->setStringProperty("S");
+ QCOMPARE(object->value(), 1);
+
+ object->setStringProperty("D");
+ QCOMPARE(object->value(), 1);
+
+ object->setStringProperty("F");
+ QCOMPARE(object->value(), 1);
+
+ object->setStringProperty("something else");
+ QCOMPARE(object->value(), 1);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("switchStatement.6.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ // `object->value()' is the number of executed statements
+
+ object->setStringProperty("A");
+ QCOMPARE(object->value(), 123);
+
+ object->setStringProperty("S");
+ QCOMPARE(object->value(), 123);
+
+ object->setStringProperty("D");
+ QCOMPARE(object->value(), 321);
+
+ object->setStringProperty("F");
+ QCOMPARE(object->value(), 321);
+
+ object->setStringProperty("something else");
+ QCOMPARE(object->value(), 0);
+ }
+}
+
+void tst_qqmlecmascript::withStatement()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("withStatement.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->value(), 123);
+ }
+}
+
+void tst_qqmlecmascript::tryStatement()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("tryStatement.1.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->value(), 123);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("tryStatement.2.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->value(), 321);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("tryStatement.3.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->value(), 1);
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("tryStatement.4.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->value(), 1);
+ }
+}
+
+class CppInvokableWithQObjectDerived : public QObject
+{
+ Q_OBJECT
+public:
+ CppInvokableWithQObjectDerived() {}
+ ~CppInvokableWithQObjectDerived() {}
+
+ Q_INVOKABLE MyQmlObject *createMyQmlObject(QString data)
+ {
+ MyQmlObject *obj = new MyQmlObject();
+ obj->setStringProperty(data);
+ return obj;
+ }
+
+ Q_INVOKABLE QString getStringProperty(MyQmlObject *obj)
+ {
+ return obj->stringProperty();
+ }
+};
+
+void tst_qqmlecmascript::invokableWithQObjectDerived()
+{
+ CppInvokableWithQObjectDerived invokable;
+
+ {
+ QQmlEngine engine;
+ engine.rootContext()->setContextProperty("invokable", &invokable);
+
+ QQmlComponent component(&engine, testFileUrl("qobjectDerivedArgument.qml"));
+
+ QObject *object = component.create();
+
+ QVERIFY(object != 0);
+ QVERIFY(object->property("result").value<bool>() == true);
+
+ delete object;
+ }
+}
+
+QTEST_MAIN(tst_qqmlecmascript)
+
+#include "tst_qqmlecmascript.moc"
diff --git a/tests/auto/qml/qqmlengine/qqmlengine.pro b/tests/auto/qml/qqmlengine/qqmlengine.pro
new file mode 100644
index 0000000000..e87b4e30aa
--- /dev/null
+++ b/tests/auto/qml/qqmlengine/qqmlengine.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qqmlengine
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlengine.cpp
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private network testlib
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
new file mode 100644
index 0000000000..af2c897d7a
--- /dev/null
+++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
@@ -0,0 +1,365 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlContext>
+#include <QNetworkAccessManager>
+#include <QPointer>
+#include <QDir>
+#include <QStandardPaths>
+#include <QDebug>
+#include <QQmlComponent>
+#include <QQmlNetworkAccessManagerFactory>
+#include <QQmlExpression>
+
+class tst_qqmlengine : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmlengine() {}
+
+private slots:
+ void rootContext();
+ void networkAccessManager();
+ void baseUrl();
+ void contextForObject();
+ void offlineStoragePath();
+ void clearComponentCache();
+ void outputWarningsToStandardError();
+ void objectOwnership();
+ void multipleEngines();
+};
+
+void tst_qqmlengine::rootContext()
+{
+ QQmlEngine engine;
+
+ QVERIFY(engine.rootContext());
+
+ QCOMPARE(engine.rootContext()->engine(), &engine);
+ QVERIFY(engine.rootContext()->parentContext() == 0);
+}
+
+class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory
+{
+public:
+ NetworkAccessManagerFactory() : manager(0) {}
+
+ QNetworkAccessManager *create(QObject *parent) {
+ manager = new QNetworkAccessManager(parent);
+ return manager;
+ }
+
+ QNetworkAccessManager *manager;
+};
+
+void tst_qqmlengine::networkAccessManager()
+{
+ QQmlEngine *engine = new QQmlEngine;
+
+ // Test QQmlEngine created manager
+ QPointer<QNetworkAccessManager> manager = engine->networkAccessManager();
+ QVERIFY(manager != 0);
+ delete engine;
+
+ // Test factory created manager
+ engine = new QQmlEngine;
+ NetworkAccessManagerFactory factory;
+ engine->setNetworkAccessManagerFactory(&factory);
+ QVERIFY(engine->networkAccessManagerFactory() == &factory);
+ QVERIFY(engine->networkAccessManager() == factory.manager);
+ delete engine;
+}
+
+void tst_qqmlengine::baseUrl()
+{
+ QQmlEngine engine;
+
+ QUrl cwd = QUrl::fromLocalFile(QDir::currentPath() + QDir::separator());
+
+ QCOMPARE(engine.baseUrl(), cwd);
+ QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd.resolved(QUrl("main.qml")));
+
+ QDir dir = QDir::current();
+ dir.cdUp();
+ QVERIFY(dir != QDir::current());
+ QDir::setCurrent(dir.path());
+ QVERIFY(QDir::current() == dir);
+
+ QUrl cwd2 = QUrl::fromLocalFile(QDir::currentPath() + QDir::separator());
+ QCOMPARE(engine.baseUrl(), cwd2);
+ QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd2.resolved(QUrl("main.qml")));
+
+ engine.setBaseUrl(cwd);
+ QCOMPARE(engine.baseUrl(), cwd);
+ QCOMPARE(engine.rootContext()->resolvedUrl(QUrl("main.qml")), cwd.resolved(QUrl("main.qml")));
+}
+
+void tst_qqmlengine::contextForObject()
+{
+ QQmlEngine *engine = new QQmlEngine;
+
+ // Test null-object
+ QVERIFY(QQmlEngine::contextForObject(0) == 0);
+
+ // Test an object with no context
+ QObject object;
+ QVERIFY(QQmlEngine::contextForObject(&object) == 0);
+
+ // Test setting null-object
+ QQmlEngine::setContextForObject(0, engine->rootContext());
+
+ // Test setting null-context
+ QQmlEngine::setContextForObject(&object, 0);
+
+ // Test setting context
+ QQmlEngine::setContextForObject(&object, engine->rootContext());
+ QVERIFY(QQmlEngine::contextForObject(&object) == engine->rootContext());
+
+ QQmlContext context(engine->rootContext());
+
+ // Try changing context
+ QTest::ignoreMessage(QtWarningMsg, "QQmlEngine::setContextForObject(): Object already has a QQmlContext");
+ QQmlEngine::setContextForObject(&object, &context);
+ QVERIFY(QQmlEngine::contextForObject(&object) == engine->rootContext());
+
+ // Delete context
+ delete engine; engine = 0;
+ QVERIFY(QQmlEngine::contextForObject(&object) == 0);
+}
+
+void tst_qqmlengine::offlineStoragePath()
+{
+ // Without these set, QDesktopServices::storageLocation returns
+ // strings with extra "//" at the end. We set them to ignore this problem.
+ qApp->setApplicationName("tst_qqmlengine");
+ qApp->setOrganizationName("Nokia");
+ qApp->setOrganizationDomain("nokia.com");
+
+ QQmlEngine engine;
+
+ QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
+ dir.mkpath("QML");
+ dir.cd("QML");
+ dir.mkpath("OfflineStorage");
+ dir.cd("OfflineStorage");
+
+ QCOMPARE(QDir::fromNativeSeparators(engine.offlineStoragePath()), dir.path());
+
+ engine.setOfflineStoragePath(QDir::homePath());
+ QCOMPARE(engine.offlineStoragePath(), QDir::homePath());
+}
+
+void tst_qqmlengine::clearComponentCache()
+{
+ QQmlEngine engine;
+
+ // Create original qml file
+ {
+ QFile file("temp.qml");
+ QVERIFY(file.open(QIODevice::WriteOnly));
+ file.write("import QtQuick 2.0\nQtObject {\nproperty int test: 10\n}\n");
+ file.close();
+ }
+
+ // Test "test" property
+ {
+ QQmlComponent component(&engine, "temp.qml");
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->property("test").toInt(), 10);
+ delete obj;
+ }
+
+ // Modify qml file
+ {
+ QFile file("temp.qml");
+ QVERIFY(file.open(QIODevice::WriteOnly));
+ file.write("import QtQuick 2.0\nQtObject {\nproperty int test: 11\n}\n");
+ file.close();
+ }
+
+ // Test cache hit
+ {
+ QQmlComponent component(&engine, "temp.qml");
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->property("test").toInt(), 10);
+ delete obj;
+ }
+
+ // Clear cache
+ engine.clearComponentCache();
+
+ // Test cache refresh
+ {
+ QQmlComponent component(&engine, "temp.qml");
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->property("test").toInt(), 11);
+ delete obj;
+ }
+}
+
+static QStringList warnings;
+static void msgHandler(QtMsgType, const char *warning)
+{
+ warnings << QString::fromUtf8(warning);
+}
+
+void tst_qqmlengine::outputWarningsToStandardError()
+{
+ QQmlEngine engine;
+
+ QCOMPARE(engine.outputWarningsToStandardError(), true);
+
+ QQmlComponent c(&engine);
+ c.setData("import QtQuick 2.0; QtObject { property int a: undefined }", QUrl());
+
+ QVERIFY(c.isReady() == true);
+
+ warnings.clear();
+ QtMsgHandler old = qInstallMsgHandler(msgHandler);
+
+ QObject *o = c.create();
+
+ qInstallMsgHandler(old);
+
+ QVERIFY(o != 0);
+ delete o;
+
+ QCOMPARE(warnings.count(), 1);
+ QCOMPARE(warnings.at(0), QLatin1String("<Unknown File>:1: Unable to assign [undefined] to int"));
+ warnings.clear();
+
+
+ engine.setOutputWarningsToStandardError(false);
+ QCOMPARE(engine.outputWarningsToStandardError(), false);
+
+
+ old = qInstallMsgHandler(msgHandler);
+
+ o = c.create();
+
+ qInstallMsgHandler(old);
+
+ QVERIFY(o != 0);
+ delete o;
+
+ QCOMPARE(warnings.count(), 0);
+}
+
+void tst_qqmlengine::objectOwnership()
+{
+ {
+ QCOMPARE(QQmlEngine::objectOwnership(0), QQmlEngine::CppOwnership);
+ QQmlEngine::setObjectOwnership(0, QQmlEngine::JavaScriptOwnership);
+ QCOMPARE(QQmlEngine::objectOwnership(0), QQmlEngine::CppOwnership);
+ }
+
+ {
+ QObject o;
+ QCOMPARE(QQmlEngine::objectOwnership(&o), QQmlEngine::CppOwnership);
+ QQmlEngine::setObjectOwnership(&o, QQmlEngine::CppOwnership);
+ QCOMPARE(QQmlEngine::objectOwnership(&o), QQmlEngine::CppOwnership);
+ QQmlEngine::setObjectOwnership(&o, QQmlEngine::JavaScriptOwnership);
+ QCOMPARE(QQmlEngine::objectOwnership(&o), QQmlEngine::JavaScriptOwnership);
+ QQmlEngine::setObjectOwnership(&o, QQmlEngine::CppOwnership);
+ QCOMPARE(QQmlEngine::objectOwnership(&o), QQmlEngine::CppOwnership);
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine);
+ c.setData("import QtQuick 2.0; QtObject { property QtObject object: QtObject {} }", QUrl());
+
+ QObject *o = c.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(QQmlEngine::objectOwnership(o), QQmlEngine::CppOwnership);
+
+ QObject *o2 = qvariant_cast<QObject *>(o->property("object"));
+ QCOMPARE(QQmlEngine::objectOwnership(o2), QQmlEngine::JavaScriptOwnership);
+
+ delete o;
+ }
+
+}
+
+// Test an object can be accessed by multiple engines
+void tst_qqmlengine::multipleEngines()
+{
+ QObject o;
+ o.setObjectName("TestName");
+
+ // Simultaneous engines
+ {
+ QQmlEngine engine1;
+ QQmlEngine engine2;
+ engine1.rootContext()->setContextProperty("object", &o);
+ engine2.rootContext()->setContextProperty("object", &o);
+
+ QQmlExpression expr1(engine1.rootContext(), 0, QString("object.objectName"));
+ QQmlExpression expr2(engine2.rootContext(), 0, QString("object.objectName"));
+
+ QCOMPARE(expr1.evaluate().toString(), QString("TestName"));
+ QCOMPARE(expr2.evaluate().toString(), QString("TestName"));
+ }
+
+ // Serial engines
+ {
+ QQmlEngine engine1;
+ engine1.rootContext()->setContextProperty("object", &o);
+ QQmlExpression expr1(engine1.rootContext(), 0, QString("object.objectName"));
+ QCOMPARE(expr1.evaluate().toString(), QString("TestName"));
+ }
+ {
+ QQmlEngine engine1;
+ engine1.rootContext()->setContextProperty("object", &o);
+ QQmlExpression expr1(engine1.rootContext(), 0, QString("object.objectName"));
+ QCOMPARE(expr1.evaluate().toString(), QString("TestName"));
+ }
+}
+
+QTEST_MAIN(tst_qqmlengine)
+
+#include "tst_qqmlengine.moc"
diff --git a/tests/auto/declarative/qdeclarativeerror/data/test.txt b/tests/auto/qml/qqmlerror/data/test.txt
index cdafd9ed82..cdafd9ed82 100644
--- a/tests/auto/declarative/qdeclarativeerror/data/test.txt
+++ b/tests/auto/qml/qqmlerror/data/test.txt
diff --git a/tests/auto/qml/qqmlerror/qqmlerror.pro b/tests/auto/qml/qqmlerror/qqmlerror.pro
new file mode 100644
index 0000000000..be2b9ab24f
--- /dev/null
+++ b/tests/auto/qml/qqmlerror/qqmlerror.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlerror
+SOURCES += tst_qqmlerror.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+CONFIG += parallel_test
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+QT += core-private gui-private qml-private testlib
diff --git a/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp b/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp
new file mode 100644
index 0000000000..b0e9f50a17
--- /dev/null
+++ b/tests/auto/qml/qqmlerror/tst_qqmlerror.cpp
@@ -0,0 +1,243 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlError>
+#include <QDebug>
+#include "../../shared/util.h"
+
+class tst_qqmlerror : public QQmlDataTest
+{
+ Q_OBJECT
+private slots:
+ void url();
+ void description();
+ void line();
+ void column();
+ void toString();
+
+ void copy();
+ void debug();
+};
+
+void tst_qqmlerror::url()
+{
+ QQmlError error;
+
+ QCOMPARE(error.url(), QUrl());
+
+ error.setUrl(QUrl("http://www.nokia.com/main.qml"));
+
+ QCOMPARE(error.url(), QUrl("http://www.nokia.com/main.qml"));
+
+ QQmlError error2 = error;
+
+ QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
+
+ error.setUrl(QUrl("http://qt.nokia.com/main.qml"));
+
+ QCOMPARE(error.url(), QUrl("http://qt.nokia.com/main.qml"));
+ QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
+}
+
+void tst_qqmlerror::description()
+{
+ QQmlError error;
+
+ QCOMPARE(error.description(), QString());
+
+ error.setDescription("An Error");
+
+ QCOMPARE(error.description(), QString("An Error"));
+
+ QQmlError error2 = error;
+
+ QCOMPARE(error2.description(), QString("An Error"));
+
+ error.setDescription("Another Error");
+
+ QCOMPARE(error.description(), QString("Another Error"));
+ QCOMPARE(error2.description(), QString("An Error"));
+}
+
+void tst_qqmlerror::line()
+{
+ QQmlError error;
+
+ QCOMPARE(error.line(), -1);
+
+ error.setLine(102);
+
+ QCOMPARE(error.line(), 102);
+
+ QQmlError error2 = error;
+
+ QCOMPARE(error2.line(), 102);
+
+ error.setLine(4);
+
+ QCOMPARE(error.line(), 4);
+ QCOMPARE(error2.line(), 102);
+}
+
+void tst_qqmlerror::column()
+{
+ QQmlError error;
+
+ QCOMPARE(error.column(), -1);
+
+ error.setColumn(16);
+
+ QCOMPARE(error.column(), 16);
+
+ QQmlError error2 = error;
+
+ QCOMPARE(error2.column(), 16);
+
+ error.setColumn(3);
+
+ QCOMPARE(error.column(), 3);
+ QCOMPARE(error2.column(), 16);
+}
+
+void tst_qqmlerror::toString()
+{
+ {
+ QQmlError error;
+ error.setUrl(QUrl("http://www.nokia.com/main.qml"));
+ error.setDescription("An Error");
+ error.setLine(92);
+ error.setColumn(13);
+
+ QCOMPARE(error.toString(), QString("http://www.nokia.com/main.qml:92:13: An Error"));
+ }
+
+ {
+ QQmlError error;
+ error.setUrl(QUrl("http://www.nokia.com/main.qml"));
+ error.setDescription("An Error");
+ error.setLine(92);
+
+ QCOMPARE(error.toString(), QString("http://www.nokia.com/main.qml:92: An Error"));
+ }
+}
+
+void tst_qqmlerror::copy()
+{
+ QQmlError error;
+ error.setUrl(QUrl("http://www.nokia.com/main.qml"));
+ error.setDescription("An Error");
+ error.setLine(92);
+ error.setColumn(13);
+
+ QQmlError error2(error);
+ QQmlError error3;
+ error3 = error;
+
+ error.setUrl(QUrl("http://qt.nokia.com/main.qml"));
+ error.setDescription("Another Error");
+ error.setLine(2);
+ error.setColumn(33);
+
+ QCOMPARE(error.url(), QUrl("http://qt.nokia.com/main.qml"));
+ QCOMPARE(error.description(), QString("Another Error"));
+ QCOMPARE(error.line(), 2);
+ QCOMPARE(error.column(), 33);
+
+ QCOMPARE(error2.url(), QUrl("http://www.nokia.com/main.qml"));
+ QCOMPARE(error2.description(), QString("An Error"));
+ QCOMPARE(error2.line(), 92);
+ QCOMPARE(error2.column(), 13);
+
+ QCOMPARE(error3.url(), QUrl("http://www.nokia.com/main.qml"));
+ QCOMPARE(error3.description(), QString("An Error"));
+ QCOMPARE(error3.line(), 92);
+ QCOMPARE(error3.column(), 13);
+
+}
+
+void tst_qqmlerror::debug()
+{
+ {
+ QQmlError error;
+ error.setUrl(QUrl("http://www.nokia.com/main.qml"));
+ error.setDescription("An Error");
+ error.setLine(92);
+ error.setColumn(13);
+
+ QTest::ignoreMessage(QtWarningMsg, "http://www.nokia.com/main.qml:92:13: An Error ");
+ qWarning() << error;
+ }
+
+ {
+ QUrl url(dataDirectoryUrl().resolved(QUrl("test.txt")));
+ QQmlError error;
+ error.setUrl(url);
+ error.setDescription("An Error");
+ error.setLine(2);
+ error.setColumn(5);
+
+ QString out = url.toString() + ":2:5: An Error \n Line2 Content \n ^ ";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(out));
+
+ qWarning() << error;
+ }
+
+ {
+ QUrl url(dataDirectoryUrl().resolved(QUrl("foo.txt")));
+ QQmlError error;
+ error.setUrl(url);
+ error.setDescription("An Error");
+ error.setLine(2);
+ error.setColumn(5);
+
+ QString out = url.toString() + ":2:5: An Error ";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(out));
+
+ qWarning() << error;
+ }
+}
+
+
+
+QTEST_MAIN(tst_qqmlerror)
+
+#include "tst_qqmlerror.moc"
diff --git a/tests/auto/declarative/qdeclarativeexpression/data/scriptString.qml b/tests/auto/qml/qqmlexpression/data/scriptString.qml
index 38c3d1b456..38c3d1b456 100644
--- a/tests/auto/declarative/qdeclarativeexpression/data/scriptString.qml
+++ b/tests/auto/qml/qqmlexpression/data/scriptString.qml
diff --git a/tests/auto/qml/qqmlexpression/qqmlexpression.pro b/tests/auto/qml/qqmlexpression/qqmlexpression.pro
new file mode 100644
index 0000000000..c2c1aa86e3
--- /dev/null
+++ b/tests/auto/qml/qqmlexpression/qqmlexpression.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlexpression
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlexpression.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private testlib
diff --git a/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp
new file mode 100644
index 0000000000..5cc6289212
--- /dev/null
+++ b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlscriptstring.h>
+#include "../../shared/util.h"
+
+class tst_qqmlexpression : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlexpression() {}
+
+private slots:
+ void scriptString();
+ void syntaxError();
+};
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlScriptString scriptString READ scriptString WRITE setScriptString)
+ Q_PROPERTY(QQmlScriptString scriptStringError READ scriptStringError WRITE setScriptStringError)
+public:
+ TestObject(QObject *parent = 0) : QObject(parent) {}
+
+ QQmlScriptString scriptString() const { return m_scriptString; }
+ void setScriptString(QQmlScriptString scriptString) { m_scriptString = scriptString; }
+
+ QQmlScriptString scriptStringError() const { return m_scriptStringError; }
+ void setScriptStringError(QQmlScriptString scriptString) { m_scriptStringError = scriptString; }
+
+private:
+ QQmlScriptString m_scriptString;
+ QQmlScriptString m_scriptStringError;
+};
+
+QML_DECLARE_TYPE(TestObject)
+
+void tst_qqmlexpression::scriptString()
+{
+ qmlRegisterType<TestObject>("Test", 1, 0, "TestObject");
+
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("scriptString.qml"));
+ TestObject *testObj = qobject_cast<TestObject*>(c.create());
+ QVERIFY(testObj != 0);
+
+ QQmlScriptString script = testObj->scriptString();
+ QCOMPARE(script.script(), QLatin1String("value1 + value2"));
+
+ QQmlExpression expression(script);
+ QVariant value = expression.evaluate();
+ QCOMPARE(value.toInt(), 15);
+
+ QQmlScriptString scriptError = testObj->scriptStringError();
+ QCOMPARE(scriptError.script(), QLatin1String("value3 * 5"));
+
+ //verify that the expression has the correct error location information
+ QQmlExpression expressionError(scriptError);
+ QVariant valueError = expressionError.evaluate();
+ QVERIFY(!valueError.isValid());
+ QVERIFY(expressionError.hasError());
+ QQmlError error = expressionError.error();
+ QCOMPARE(error.url(), c.url());
+ QCOMPARE(error.line(), 8);
+}
+
+// QTBUG-21310 - crash test
+void tst_qqmlexpression::syntaxError()
+{
+ QQmlEngine engine;
+ QQmlExpression expression(engine.rootContext(), 0, "asd asd");
+ QVariant v = expression.evaluate();
+ QCOMPARE(v, QVariant());
+}
+
+QTEST_MAIN(tst_qqmlexpression)
+
+#include "tst_qqmlexpression.moc"
diff --git a/tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro b/tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro
new file mode 100644
index 0000000000..9feeee15fd
--- /dev/null
+++ b/tests/auto/qml/qqmlimageprovider/qqmlimageprovider.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qqmlimageprovider
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlimageprovider.cpp
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp b/tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp
new file mode 100644
index 0000000000..bc53544566
--- /dev/null
+++ b/tests/auto/qml/qqmlimageprovider/tst_qqmlimageprovider.cpp
@@ -0,0 +1,424 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QtTest>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlimageprovider.h>
+#include <private/qquickimage_p.h>
+#include <QImageReader>
+#include <QWaitCondition>
+
+Q_DECLARE_METATYPE(QQmlImageProvider*);
+
+class tst_qqmlimageprovider : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmlimageprovider()
+ {
+ }
+
+private slots:
+ void requestImage_sync_data();
+ void requestImage_sync();
+ void requestImage_async_data();
+ void requestImage_async();
+
+ void requestPixmap_sync_data();
+ void requestPixmap_sync();
+ void requestPixmap_async();
+
+ void removeProvider_data();
+ void removeProvider();
+
+ void threadTest();
+
+private:
+ QString newImageFileName() const;
+ void fillRequestTestsData(const QString &id);
+ void runTest(bool async, QQmlImageProvider *provider);
+};
+
+
+class TestQImageProvider : public QQmlImageProvider
+{
+public:
+ TestQImageProvider(bool *deleteWatch = 0)
+ : QQmlImageProvider(Image), deleteWatch(deleteWatch)
+ {
+ }
+
+ ~TestQImageProvider()
+ {
+ if (deleteWatch)
+ *deleteWatch = true;
+ }
+
+ QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize)
+ {
+ lastImageId = id;
+
+ if (id == QLatin1String("no-such-file.png"))
+ return QImage();
+
+ int width = 100;
+ int height = 100;
+ QImage image(width, height, QImage::Format_RGB32);
+ if (size)
+ *size = QSize(width, height);
+ if (requestedSize.isValid())
+ image = image.scaled(requestedSize);
+ return image;
+ }
+
+ bool *deleteWatch;
+ QString lastImageId;
+};
+Q_DECLARE_METATYPE(TestQImageProvider*);
+
+
+class TestQPixmapProvider : public QQmlImageProvider
+{
+public:
+ TestQPixmapProvider(bool *deleteWatch = 0)
+ : QQmlImageProvider(Pixmap), deleteWatch(deleteWatch)
+ {
+ }
+
+ ~TestQPixmapProvider()
+ {
+ if (deleteWatch)
+ *deleteWatch = true;
+ }
+
+ QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize)
+ {
+ lastImageId = id;
+
+ if (id == QLatin1String("no-such-file.png"))
+ return QPixmap();
+
+ int width = 100;
+ int height = 100;
+ QPixmap image(width, height);
+ if (size)
+ *size = QSize(width, height);
+ if (requestedSize.isValid())
+ image = image.scaled(requestedSize);
+ return image;
+ }
+
+ bool *deleteWatch;
+ QString lastImageId;
+};
+Q_DECLARE_METATYPE(TestQPixmapProvider*);
+
+
+QString tst_qqmlimageprovider::newImageFileName() const
+{
+ // need to generate new filenames each time or else images are loaded
+ // from cache and we won't get loading status changes when testing
+ // async loading
+ static int count = 0;
+ return QString("image://test/image-%1.png").arg(count++);
+}
+
+void tst_qqmlimageprovider::fillRequestTestsData(const QString &id)
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<QString>("imageId");
+ QTest::addColumn<QString>("properties");
+ QTest::addColumn<QSize>("size");
+ QTest::addColumn<QString>("error");
+
+ QString fileName = newImageFileName();
+ QTest::newRow(QTest::toString(id + " simple test"))
+ << "image://test/" + fileName << fileName << "" << QSize(100,100) << "";
+
+ fileName = newImageFileName();
+ QTest::newRow(QTest::toString(id + " simple test with capitalization"))//As it's a URL, should make no difference
+ << "image://Test/" + fileName << fileName << "" << QSize(100,100) << "";
+
+ fileName = newImageFileName();
+ QTest::newRow(QTest::toString(id + " url with no id"))
+ << "image://test/" + fileName << "" + fileName << "" << QSize(100,100) << "";
+
+ fileName = newImageFileName();
+ QTest::newRow(QTest::toString(id + " url with path"))
+ << "image://test/test/path" + fileName << "test/path" + fileName << "" << QSize(100,100) << "";
+
+ fileName = newImageFileName();
+ QTest::newRow(QTest::toString(id + " url with fragment"))
+ << "image://test/faq.html?#question13" + fileName << "faq.html?#question13" + fileName << "" << QSize(100,100) << "";
+
+ fileName = newImageFileName();
+ QTest::newRow(QTest::toString(id + " url with query"))
+ << "image://test/cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName << "cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName
+ << "" << QSize(100,100) << "";
+
+ fileName = newImageFileName();
+ QTest::newRow(QTest::toString(id + " scaled image"))
+ << "image://test/" + fileName << fileName << "sourceSize: \"80x30\"" << QSize(80,30) << "";
+
+ QTest::newRow(QTest::toString(id + " missing"))
+ << "image://test/no-such-file.png" << "no-such-file.png" << "" << QSize(100,100)
+ << "file::2:1: QML Image: Failed to get image from provider: image://test/no-such-file.png";
+
+ QTest::newRow(QTest::toString(id + " unknown provider"))
+ << "image://bogus/exists.png" << "" << "" << QSize()
+ << "file::2:1: QML Image: Invalid image provider: image://bogus/exists.png";
+}
+
+void tst_qqmlimageprovider::runTest(bool async, QQmlImageProvider *provider)
+{
+ QFETCH(QString, source);
+ QFETCH(QString, imageId);
+ QFETCH(QString, properties);
+ QFETCH(QSize, size);
+ QFETCH(QString, error);
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ QQmlEngine engine;
+
+ engine.addImageProvider("test", provider);
+ QVERIFY(engine.imageProvider("test") != 0);
+
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + source + "\"; "
+ + (async ? "asynchronous: true; " : "")
+ + properties + " }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ if (async)
+ QTRY_VERIFY(obj->status() == QQuickImage::Loading);
+
+ QCOMPARE(obj->source(), QUrl(source));
+
+ if (error.isEmpty()) {
+ if (async)
+ QTRY_VERIFY(obj->status() == QQuickImage::Ready);
+ else
+ QVERIFY(obj->status() == QQuickImage::Ready);
+ if (QByteArray(QTest::currentDataTag()).startsWith("qimage"))
+ QCOMPARE(static_cast<TestQImageProvider*>(provider)->lastImageId, imageId);
+ else
+ QCOMPARE(static_cast<TestQPixmapProvider*>(provider)->lastImageId, imageId);
+
+ QCOMPARE(obj->width(), qreal(size.width()));
+ QCOMPARE(obj->height(), qreal(size.height()));
+ QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
+ QCOMPARE(obj->progress(), 1.0);
+ } else {
+ if (async)
+ QTRY_VERIFY(obj->status() == QQuickImage::Error);
+ else
+ QVERIFY(obj->status() == QQuickImage::Error);
+ }
+
+ delete obj;
+}
+
+void tst_qqmlimageprovider::requestImage_sync_data()
+{
+ fillRequestTestsData("qimage|sync");
+}
+
+void tst_qqmlimageprovider::requestImage_sync()
+{
+ bool deleteWatch = false;
+ runTest(false, new TestQImageProvider(&deleteWatch));
+ QVERIFY(deleteWatch);
+}
+
+void tst_qqmlimageprovider::requestImage_async_data()
+{
+ fillRequestTestsData("qimage|async");
+}
+
+void tst_qqmlimageprovider::requestImage_async()
+{
+ bool deleteWatch = false;
+ runTest(true, new TestQImageProvider(&deleteWatch));
+ QVERIFY(deleteWatch);
+}
+
+void tst_qqmlimageprovider::requestPixmap_sync_data()
+{
+ fillRequestTestsData("qpixmap");
+}
+
+void tst_qqmlimageprovider::requestPixmap_sync()
+{
+ bool deleteWatch = false;
+ runTest(false, new TestQPixmapProvider(&deleteWatch));
+ QVERIFY(deleteWatch);
+}
+
+void tst_qqmlimageprovider::requestPixmap_async()
+{
+ QQmlEngine engine;
+ QQmlImageProvider *provider = new TestQPixmapProvider();
+
+ engine.addImageProvider("test", provider);
+ QVERIFY(engine.imageProvider("test") != 0);
+
+ // pixmaps are loaded synchronously regardless of 'asynchronous' value
+ QString componentStr = "import QtQuick 2.0\nImage { asynchronous: true; source: \"image://test/pixmap-async-test.png\" }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ delete obj;
+}
+
+void tst_qqmlimageprovider::removeProvider_data()
+{
+ QTest::addColumn<QQmlImageProvider*>("provider");
+
+ QTest::newRow("qimage") << static_cast<QQmlImageProvider*>(new TestQImageProvider);
+ QTest::newRow("qpixmap") << static_cast<QQmlImageProvider*>(new TestQPixmapProvider);
+}
+
+void tst_qqmlimageprovider::removeProvider()
+{
+ QFETCH(QQmlImageProvider*, provider);
+
+ QQmlEngine engine;
+
+ engine.addImageProvider("test", provider);
+ QVERIFY(engine.imageProvider("test") != 0);
+
+ // add provider, confirm it works
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + newImageFileName() + "\" }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->status(), QQuickImage::Ready);
+
+ // remove the provider and confirm
+ QString fileName = newImageFileName();
+ QString error("file::2:1: QML Image: Invalid image provider: " + fileName);
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ engine.removeImageProvider("test");
+
+ obj->setSource(QUrl(fileName));
+ QCOMPARE(obj->status(), QQuickImage::Error);
+
+ delete obj;
+}
+
+class TestThreadProvider : public QQmlImageProvider
+{
+ public:
+ TestThreadProvider() : QQmlImageProvider(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_qqmlimageprovider::threadTest()
+{
+ QQmlEngine engine;
+
+ TestThreadProvider *provider = new TestThreadProvider;
+
+ engine.addImageProvider("test_thread", provider);
+ QVERIFY(engine.imageProvider("test_thread") != 0);
+
+ QString componentStr = "import QtQuick 2.0\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"
+ " }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QObject *obj = component.create();
+ //MUST not deadlock
+ QVERIFY(obj != 0);
+ QList<QQuickImage *> images = obj->findChildren<QQuickImage *>();
+ QCOMPARE(images.count(), 4);
+ QTest::qWait(100);
+ foreach (QQuickImage *img, images) {
+ QCOMPARE(img->status(), QQuickImage::Loading);
+ }
+ provider->ok = true;
+ provider->cond.wakeAll();
+ QTest::qWait(250);
+ foreach (QQuickImage *img, images) {
+ QTRY_VERIFY(img->status() == QQuickImage::Ready);
+ }
+}
+
+
+QTEST_MAIN(tst_qqmlimageprovider)
+
+#include "tst_qqmlimageprovider.moc"
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/AsynchronousIfNestedType.qml b/tests/auto/qml/qqmlincubator/data/AsynchronousIfNestedType.qml
index 8a3f46ee72..8a3f46ee72 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/AsynchronousIfNestedType.qml
+++ b/tests/auto/qml/qqmlincubator/data/AsynchronousIfNestedType.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.1.qml b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.1.qml
index 18ff4aabb7..18ff4aabb7 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.1.qml
+++ b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.1.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.2.qml b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.2.qml
index 3f6cd932de..3f6cd932de 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.2.qml
+++ b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.2.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.3.qml b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.3.qml
index 7e5ee7cf5c..7e5ee7cf5c 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/asynchronousIfNested.3.qml
+++ b/tests/auto/qml/qqmlincubator/data/asynchronousIfNested.3.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/chainInCompletion.qml b/tests/auto/qml/qqmlincubator/data/chainInCompletion.qml
index e79fed356a..e79fed356a 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/chainInCompletion.qml
+++ b/tests/auto/qml/qqmlincubator/data/chainInCompletion.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/chainedAsynchronousIfNested.qml b/tests/auto/qml/qqmlincubator/data/chainedAsynchronousIfNested.qml
index 1300426cfa..1300426cfa 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/chainedAsynchronousIfNested.qml
+++ b/tests/auto/qml/qqmlincubator/data/chainedAsynchronousIfNested.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/clear.qml b/tests/auto/qml/qqmlincubator/data/clear.qml
index f00f975923..f00f975923 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/clear.qml
+++ b/tests/auto/qml/qqmlincubator/data/clear.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/clearDuringCompletion.qml b/tests/auto/qml/qqmlincubator/data/clearDuringCompletion.qml
index 556f460d58..556f460d58 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/clearDuringCompletion.qml
+++ b/tests/auto/qml/qqmlincubator/data/clearDuringCompletion.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/contextDelete.qml b/tests/auto/qml/qqmlincubator/data/contextDelete.qml
index c3952074f1..c3952074f1 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/contextDelete.qml
+++ b/tests/auto/qml/qqmlincubator/data/contextDelete.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/forceCompletion.qml b/tests/auto/qml/qqmlincubator/data/forceCompletion.qml
index 9b76701c1b..9b76701c1b 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/forceCompletion.qml
+++ b/tests/auto/qml/qqmlincubator/data/forceCompletion.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/nestedComponent.js b/tests/auto/qml/qqmlincubator/data/nestedComponent.js
index 4b6b0bde43..4b6b0bde43 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/nestedComponent.js
+++ b/tests/auto/qml/qqmlincubator/data/nestedComponent.js
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/nestedComponent.qml b/tests/auto/qml/qqmlincubator/data/nestedComponent.qml
index dd20707456..dd20707456 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/nestedComponent.qml
+++ b/tests/auto/qml/qqmlincubator/data/nestedComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/noIncubationController.qml b/tests/auto/qml/qqmlincubator/data/noIncubationController.qml
index 7d93e856f0..7d93e856f0 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/noIncubationController.qml
+++ b/tests/auto/qml/qqmlincubator/data/noIncubationController.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/objectDeleted.errors.txt b/tests/auto/qml/qqmlincubator/data/objectDeleted.errors.txt
index eeda289d35..eeda289d35 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/objectDeleted.errors.txt
+++ b/tests/auto/qml/qqmlincubator/data/objectDeleted.errors.txt
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/objectDeleted.qml b/tests/auto/qml/qqmlincubator/data/objectDeleted.qml
index f00f975923..f00f975923 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/objectDeleted.qml
+++ b/tests/auto/qml/qqmlincubator/data/objectDeleted.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/recursiveClear.1.qml b/tests/auto/qml/qqmlincubator/data/recursiveClear.1.qml
index 748a3f0cbf..748a3f0cbf 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/recursiveClear.1.qml
+++ b/tests/auto/qml/qqmlincubator/data/recursiveClear.1.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/recursiveClear.2.qml b/tests/auto/qml/qqmlincubator/data/recursiveClear.2.qml
index e96ac00f21..e96ac00f21 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/recursiveClear.2.qml
+++ b/tests/auto/qml/qqmlincubator/data/recursiveClear.2.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/selfDelete.qml b/tests/auto/qml/qqmlincubator/data/selfDelete.qml
index c3952074f1..c3952074f1 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/selfDelete.qml
+++ b/tests/auto/qml/qqmlincubator/data/selfDelete.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/setInitialState.qml b/tests/auto/qml/qqmlincubator/data/setInitialState.qml
index 0fd61abfd2..0fd61abfd2 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/setInitialState.qml
+++ b/tests/auto/qml/qqmlincubator/data/setInitialState.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/statusChanged.nested.qml b/tests/auto/qml/qqmlincubator/data/statusChanged.nested.qml
index 3a496ea6fe..3a496ea6fe 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/statusChanged.nested.qml
+++ b/tests/auto/qml/qqmlincubator/data/statusChanged.nested.qml
diff --git a/tests/auto/declarative/qdeclarativeincubator/data/statusChanged.qml b/tests/auto/qml/qqmlincubator/data/statusChanged.qml
index 18ff4aabb7..18ff4aabb7 100644
--- a/tests/auto/declarative/qdeclarativeincubator/data/statusChanged.qml
+++ b/tests/auto/qml/qqmlincubator/data/statusChanged.qml
diff --git a/tests/auto/qml/qqmlincubator/qqmlincubator.pro b/tests/auto/qml/qqmlincubator/qqmlincubator.pro
new file mode 100644
index 0000000000..956d72402c
--- /dev/null
+++ b/tests/auto/qml/qqmlincubator/qqmlincubator.pro
@@ -0,0 +1,18 @@
+CONFIG += testcase
+TARGET = tst_qqmlincubator
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlincubator.cpp \
+ testtypes.cpp
+
+HEADERS += testtypes.h
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private network widgets testlib
diff --git a/tests/auto/qml/qqmlincubator/testtypes.cpp b/tests/auto/qml/qqmlincubator/testtypes.cpp
new file mode 100644
index 0000000000..7936fc146c
--- /dev/null
+++ b/tests/auto/qml/qqmlincubator/testtypes.cpp
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "testtypes.h"
+#include <QtQml/qqml.h>
+
+SelfRegisteringType *SelfRegisteringType::m_me = 0;
+SelfRegisteringType::SelfRegisteringType()
+: m_v(0)
+{
+ m_me = this;
+}
+
+SelfRegisteringType *SelfRegisteringType::me()
+{
+ return m_me;
+}
+
+void SelfRegisteringType::clearMe()
+{
+ m_me = 0;
+}
+
+CompletionRegisteringType *CompletionRegisteringType::m_me = 0;
+CompletionRegisteringType::CompletionRegisteringType()
+{
+}
+
+void CompletionRegisteringType::classBegin()
+{
+}
+
+void CompletionRegisteringType::componentComplete()
+{
+ m_me = this;
+}
+
+CompletionRegisteringType *CompletionRegisteringType::me()
+{
+ return m_me;
+}
+
+void CompletionRegisteringType::clearMe()
+{
+ m_me = 0;
+}
+
+CallbackRegisteringType::callback CallbackRegisteringType::m_callback = 0;
+void *CallbackRegisteringType::m_data = 0;
+CallbackRegisteringType::CallbackRegisteringType()
+: m_v(0)
+{
+}
+
+void CallbackRegisteringType::clearCallback()
+{
+ m_callback = 0;
+ m_data = 0;
+}
+
+void CallbackRegisteringType::registerCallback(callback c, void *d)
+{
+ m_callback = c;
+ m_data = d;
+}
+
+CompletionCallbackType::callback CompletionCallbackType::m_callback = 0;
+void *CompletionCallbackType::m_data = 0;
+CompletionCallbackType::CompletionCallbackType()
+{
+}
+
+void CompletionCallbackType::classBegin()
+{
+}
+
+void CompletionCallbackType::componentComplete()
+{
+ if (m_callback) m_callback(this, m_data);
+}
+
+void CompletionCallbackType::clearCallback()
+{
+ m_callback = 0;
+ m_data = 0;
+}
+
+void CompletionCallbackType::registerCallback(callback c, void *d)
+{
+ m_callback = c;
+ m_data = d;
+}
+
+void registerTypes()
+{
+ qmlRegisterType<SelfRegisteringType>("Qt.test", 1,0, "SelfRegistering");
+ qmlRegisterType<CompletionRegisteringType>("Qt.test", 1,0, "CompletionRegistering");
+ qmlRegisterType<CallbackRegisteringType>("Qt.test", 1,0, "CallbackRegistering");
+ qmlRegisterType<CompletionCallbackType>("Qt.test", 1,0, "CompletionCallback");
+}
diff --git a/tests/auto/qml/qqmlincubator/testtypes.h b/tests/auto/qml/qqmlincubator/testtypes.h
new file mode 100644
index 0000000000..8ca7ee34ee
--- /dev/null
+++ b/tests/auto/qml/qqmlincubator/testtypes.h
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QtCore/qobject.h>
+#include <QQmlParserStatus>
+
+class SelfRegisteringType : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(int value READ value WRITE setValue);
+public:
+ SelfRegisteringType();
+
+ int value() const { return m_v; }
+ void setValue(int v) { m_v = v; }
+
+ static SelfRegisteringType *me();
+ static void clearMe();
+
+private:
+ static SelfRegisteringType *m_me;
+
+ int m_v;
+};
+
+class CallbackRegisteringType : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(int value READ value WRITE setValue)
+public:
+ CallbackRegisteringType();
+
+ int value() const { return m_v; }
+ void setValue(int v) { if (m_callback) m_callback(this, m_data); m_v = v; }
+
+ typedef void (*callback)(CallbackRegisteringType *, void *);
+ static void clearCallback();
+ static void registerCallback(callback, void *);
+
+private:
+ static callback m_callback;
+ static void *m_data;
+
+ int m_v;
+};
+
+class CompletionRegisteringType : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+public:
+ CompletionRegisteringType();
+
+ virtual void classBegin();
+ virtual void componentComplete();
+
+ static CompletionRegisteringType *me();
+ static void clearMe();
+
+private:
+ static CompletionRegisteringType *m_me;
+};
+
+class CompletionCallbackType : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
+public:
+ CompletionCallbackType();
+
+ virtual void classBegin();
+ virtual void componentComplete();
+
+ typedef void (*callback)(CompletionCallbackType *, void *);
+ static void clearCallback();
+ static void registerCallback(callback, void *);
+
+private:
+ static callback m_callback;
+ static void *m_data;
+};
+
+void registerTypes();
+
+#endif // TESTTYPES_H
diff --git a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
new file mode 100644
index 0000000000..fc54f715c9
--- /dev/null
+++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
@@ -0,0 +1,1030 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "testtypes.h"
+
+#include <QUrl>
+#include <QDir>
+#include <QDebug>
+#include <qtest.h>
+#include <QPointer>
+#include <QFileInfo>
+#include <QQmlEngine>
+#include <QQmlContext>
+#include <QQmlProperty>
+#include <QQmlComponent>
+#include <QQmlIncubator>
+#include "../../shared/util.h"
+
+class tst_qqmlincubator : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlincubator() {}
+
+private slots:
+ void initTestCase();
+
+ void incubationMode();
+ void objectDeleted();
+ void clear();
+ void noIncubationController();
+ void forceCompletion();
+ void setInitialState();
+ void clearDuringCompletion();
+ void objectDeletionAfterInit();
+ void recursiveClear();
+ void statusChanged();
+ void asynchronousIfNested();
+ void nestedComponent();
+ void chainedAsynchronousIfNested();
+ void chainedAsynchronousIfNestedOnCompleted();
+ void selfDelete();
+ void contextDelete();
+
+private:
+ QQmlIncubationController controller;
+ QQmlEngine engine;
+};
+
+#define VERIFY_ERRORS(component, errorfile) \
+ if (!errorfile) { \
+ if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
+ qWarning() << "Unexpected Errors:" << component.errors(); \
+ QVERIFY(!component.isError()); \
+ QVERIFY(component.errors().isEmpty()); \
+ } else { \
+ QFile file(QQmlDataTest::instance()->testFile(errorfile)); \
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \
+ QByteArray data = file.readAll(); \
+ file.close(); \
+ QList<QByteArray> expected = data.split('\n'); \
+ expected.removeAll(QByteArray("")); \
+ QList<QQmlError> errors = component.errors(); \
+ QList<QByteArray> actual; \
+ for (int ii = 0; ii < errors.count(); ++ii) { \
+ const QQmlError &error = errors.at(ii); \
+ QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
+ QByteArray::number(error.column()) + ":" + \
+ error.description().toUtf8(); \
+ actual << errorStr; \
+ } \
+ if (qgetenv("DEBUG") != "" && expected != actual) \
+ qWarning() << "Expected:" << expected << "Actual:" << actual; \
+ QCOMPARE(expected, actual); \
+ }
+
+void tst_qqmlincubator::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ registerTypes();
+ engine.setIncubationController(&controller);
+}
+
+void tst_qqmlincubator::incubationMode()
+{
+ {
+ QQmlIncubator incubator;
+ QCOMPARE(incubator.incubationMode(), QQmlIncubator::Asynchronous);
+ }
+ {
+ QQmlIncubator incubator(QQmlIncubator::Asynchronous);
+ QCOMPARE(incubator.incubationMode(), QQmlIncubator::Asynchronous);
+ }
+ {
+ QQmlIncubator incubator(QQmlIncubator::Synchronous);
+ QCOMPARE(incubator.incubationMode(), QQmlIncubator::Synchronous);
+ }
+ {
+ QQmlIncubator incubator(QQmlIncubator::AsynchronousIfNested);
+ QCOMPARE(incubator.incubationMode(), QQmlIncubator::AsynchronousIfNested);
+ }
+}
+
+void tst_qqmlincubator::objectDeleted()
+{
+ SelfRegisteringType::clearMe();
+
+ QQmlComponent component(&engine, testFileUrl("objectDeleted.qml"));
+ QVERIFY(component.isReady());
+
+ QQmlIncubator incubator;
+ component.create(incubator);
+
+ QCOMPARE(incubator.status(), QQmlIncubator::Loading);
+ QVERIFY(SelfRegisteringType::me() == 0);
+
+ while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QVERIFY(incubator.isLoading());
+
+ delete SelfRegisteringType::me();
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isError());
+ VERIFY_ERRORS(incubator, "objectDeleted.errors.txt");
+ QVERIFY(incubator.object() == 0);
+}
+
+void tst_qqmlincubator::clear()
+{
+ SelfRegisteringType::clearMe();
+
+ QQmlComponent component(&engine, testFileUrl("clear.qml"));
+ QVERIFY(component.isReady());
+
+ // Clear in null state
+ {
+ QQmlIncubator incubator;
+ QVERIFY(incubator.isNull());
+ incubator.clear(); // no effect
+ QVERIFY(incubator.isNull());
+ }
+
+ // Clear in loading state
+ {
+ QQmlIncubator incubator;
+ component.create(incubator);
+ QVERIFY(incubator.isLoading());
+ incubator.clear();
+ QVERIFY(incubator.isNull());
+ }
+
+ // Clear mid load
+ {
+ QQmlIncubator incubator;
+ component.create(incubator);
+
+ while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QPointer<SelfRegisteringType> srt = SelfRegisteringType::me();
+
+ incubator.clear();
+ QVERIFY(incubator.isNull());
+ QVERIFY(srt.isNull());
+ }
+
+ // Clear in ready state
+ {
+ QQmlIncubator incubator;
+ component.create(incubator);
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object() != 0);
+ QPointer<QObject> obj = incubator.object();
+
+ incubator.clear();
+ QVERIFY(incubator.isNull());
+ QVERIFY(incubator.object() == 0);
+ QVERIFY(!obj.isNull());
+
+ delete obj;
+ QVERIFY(obj.isNull());
+ }
+}
+
+void tst_qqmlincubator::noIncubationController()
+{
+ // All incubators should behave synchronously when there is no controller
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("noIncubationController.qml"));
+
+ QVERIFY(component.isReady());
+
+ {
+ QQmlIncubator incubator(QQmlIncubator::Asynchronous);
+ component.create(incubator);
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object());
+ QCOMPARE(incubator.object()->property("testValue").toInt(), 1913);
+ delete incubator.object();
+ }
+
+ {
+ QQmlIncubator incubator(QQmlIncubator::AsynchronousIfNested);
+ component.create(incubator);
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object());
+ QCOMPARE(incubator.object()->property("testValue").toInt(), 1913);
+ delete incubator.object();
+ }
+
+ {
+ QQmlIncubator incubator(QQmlIncubator::Synchronous);
+ component.create(incubator);
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object());
+ QCOMPARE(incubator.object()->property("testValue").toInt(), 1913);
+ delete incubator.object();
+ }
+}
+
+void tst_qqmlincubator::forceCompletion()
+{
+ QQmlComponent component(&engine, testFileUrl("forceCompletion.qml"));
+ QVERIFY(component.isReady());
+
+ {
+ // forceCompletion on a null incubator does nothing
+ QQmlIncubator incubator;
+ QVERIFY(incubator.isNull());
+ incubator.forceCompletion();
+ QVERIFY(incubator.isNull());
+ }
+
+ {
+ // forceCompletion immediately after creating an asynchronous object completes it
+ QQmlIncubator incubator;
+ QVERIFY(incubator.isNull());
+ component.create(incubator);
+ QVERIFY(incubator.isLoading());
+
+ incubator.forceCompletion();
+
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object() != 0);
+ QCOMPARE(incubator.object()->property("testValue").toInt(), 3499);
+
+ delete incubator.object();
+ }
+
+ {
+ // forceCompletion during creation completes it
+ SelfRegisteringType::clearMe();
+
+ QQmlIncubator incubator;
+ QVERIFY(incubator.isNull());
+ component.create(incubator);
+ QVERIFY(incubator.isLoading());
+
+ while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QVERIFY(incubator.isLoading());
+
+ incubator.forceCompletion();
+
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object() != 0);
+ QCOMPARE(incubator.object()->property("testValue").toInt(), 3499);
+
+ delete incubator.object();
+ }
+
+ {
+ // forceCompletion on a ready incubator has no effect
+ QQmlIncubator incubator;
+ QVERIFY(incubator.isNull());
+ component.create(incubator);
+ QVERIFY(incubator.isLoading());
+
+ incubator.forceCompletion();
+
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object() != 0);
+ QCOMPARE(incubator.object()->property("testValue").toInt(), 3499);
+
+ incubator.forceCompletion();
+
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object() != 0);
+ QCOMPARE(incubator.object()->property("testValue").toInt(), 3499);
+
+ delete incubator.object();
+ }
+}
+
+void tst_qqmlincubator::setInitialState()
+{
+ QQmlComponent component(&engine, testFileUrl("setInitialState.qml"));
+ QVERIFY(component.isReady());
+
+ struct MyIncubator : public QQmlIncubator
+ {
+ MyIncubator(QQmlIncubator::IncubationMode mode)
+ : QQmlIncubator(mode) {}
+
+ virtual void setInitialState(QObject *o) {
+ QQmlProperty::write(o, "test2", 19);
+ QQmlProperty::write(o, "testData1", 201);
+ }
+ };
+
+ {
+ MyIncubator incubator(QQmlIncubator::Asynchronous);
+ component.create(incubator);
+ QVERIFY(incubator.isLoading());
+ bool b = true;
+ controller.incubateWhile(&b);
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object());
+ QCOMPARE(incubator.object()->property("myValueFunctionCalled").toBool(), false);
+ QCOMPARE(incubator.object()->property("test1").toInt(), 502);
+ QCOMPARE(incubator.object()->property("test2").toInt(), 19);
+ delete incubator.object();
+ }
+
+ {
+ MyIncubator incubator(QQmlIncubator::Synchronous);
+ component.create(incubator);
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object());
+ QCOMPARE(incubator.object()->property("myValueFunctionCalled").toBool(), false);
+ QCOMPARE(incubator.object()->property("test1").toInt(), 502);
+ QCOMPARE(incubator.object()->property("test2").toInt(), 19);
+ delete incubator.object();
+ }
+}
+
+void tst_qqmlincubator::clearDuringCompletion()
+{
+ CompletionRegisteringType::clearMe();
+ SelfRegisteringType::clearMe();
+
+ QQmlComponent component(&engine, testFileUrl("clearDuringCompletion.qml"));
+ QVERIFY(component.isReady());
+
+ QQmlIncubator incubator;
+ component.create(incubator);
+
+ QCOMPARE(incubator.status(), QQmlIncubator::Loading);
+ QVERIFY(CompletionRegisteringType::me() == 0);
+
+ while (CompletionRegisteringType::me() == 0 && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(CompletionRegisteringType::me() != 0);
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QVERIFY(incubator.isLoading());
+
+ QPointer<QObject> srt = SelfRegisteringType::me();
+
+ incubator.clear();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QVERIFY(incubator.isNull());
+ QVERIFY(srt.isNull());
+}
+
+void tst_qqmlincubator::objectDeletionAfterInit()
+{
+ QQmlComponent component(&engine, testFileUrl("clear.qml"));
+ QVERIFY(component.isReady());
+
+ struct MyIncubator : public QQmlIncubator
+ {
+ MyIncubator(QQmlIncubator::IncubationMode mode)
+ : QQmlIncubator(mode), obj(0) {}
+
+ virtual void setInitialState(QObject *o) {
+ obj = o;
+ }
+
+ QObject *obj;
+ };
+
+ SelfRegisteringType::clearMe();
+ MyIncubator incubator(QQmlIncubator::Asynchronous);
+ component.create(incubator);
+
+ while (!incubator.obj && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(SelfRegisteringType::me() != 0);
+
+ delete incubator.obj;
+
+ incubator.clear();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QVERIFY(incubator.isNull());
+}
+
+class Switcher : public QObject
+{
+ Q_OBJECT
+public:
+ Switcher(QQmlEngine *e) : QObject(), engine(e) { }
+
+ struct MyIncubator : public QQmlIncubator
+ {
+ MyIncubator(QQmlIncubator::IncubationMode mode, QObject *s)
+ : QQmlIncubator(mode), switcher(s) {}
+
+ virtual void setInitialState(QObject *o) {
+ if (o->objectName() == "switchMe")
+ connect(o, SIGNAL(switchMe()), switcher, SLOT(switchIt()));
+ }
+
+ QObject *switcher;
+ };
+
+ void start()
+ {
+ incubator = new MyIncubator(QQmlIncubator::Synchronous, this);
+ component = new QQmlComponent(engine, QQmlDataTest::instance()->testFileUrl("recursiveClear.1.qml"));
+ component->create(*incubator);
+ }
+
+ QQmlEngine *engine;
+ MyIncubator *incubator;
+ QQmlComponent *component;
+
+public slots:
+ void switchIt() {
+ component->deleteLater();
+ incubator->clear();
+ component = new QQmlComponent(engine, QQmlDataTest::instance()->testFileUrl("recursiveClear.2.qml"));
+ component->create(*incubator);
+ }
+};
+
+void tst_qqmlincubator::recursiveClear()
+{
+ Switcher switcher(&engine);
+ switcher.start();
+}
+
+void tst_qqmlincubator::statusChanged()
+{
+ class MyIncubator : public QQmlIncubator
+ {
+ public:
+ MyIncubator(QQmlIncubator::IncubationMode mode = QQmlIncubator::Asynchronous)
+ : QQmlIncubator(mode) {}
+
+ QList<int> statuses;
+ protected:
+ virtual void statusChanged(Status s) { statuses << s; }
+ virtual void setInitialState(QObject *) { statuses << -1; }
+ };
+
+ {
+ QQmlComponent component(&engine, testFileUrl("statusChanged.qml"));
+ QVERIFY(component.isReady());
+
+ MyIncubator incubator(QQmlIncubator::Synchronous);
+ component.create(incubator);
+ QVERIFY(incubator.isReady());
+ QCOMPARE(incubator.statuses.count(), 3);
+ QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
+ QCOMPARE(incubator.statuses.at(1), -1);
+ QCOMPARE(incubator.statuses.at(2), int(QQmlIncubator::Ready));
+ delete incubator.object();
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("statusChanged.qml"));
+ QVERIFY(component.isReady());
+
+ MyIncubator incubator(QQmlIncubator::Asynchronous);
+ component.create(incubator);
+ QVERIFY(incubator.isLoading());
+ QCOMPARE(incubator.statuses.count(), 1);
+ QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ QCOMPARE(incubator.statuses.count(), 3);
+ QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
+ QCOMPARE(incubator.statuses.at(1), -1);
+ QCOMPARE(incubator.statuses.at(2), int(QQmlIncubator::Ready));
+ delete incubator.object();
+ }
+
+ {
+ QQmlComponent component2(&engine, testFileUrl("statusChanged.nested.qml"));
+ QVERIFY(component2.isReady());
+
+ MyIncubator incubator(QQmlIncubator::Asynchronous);
+ component2.create(incubator);
+ QVERIFY(incubator.isLoading());
+ QCOMPARE(incubator.statuses.count(), 1);
+ QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isReady());
+ QCOMPARE(incubator.statuses.count(), 3);
+ QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
+ QCOMPARE(incubator.statuses.at(1), -1);
+ QCOMPARE(incubator.statuses.at(2), int(QQmlIncubator::Ready));
+ delete incubator.object();
+ }
+}
+
+void tst_qqmlincubator::asynchronousIfNested()
+{
+ // Asynchronous if nested within a finalized context behaves synchronously
+ {
+ QQmlComponent component(&engine, testFileUrl("asynchronousIfNested.1.qml"));
+ QVERIFY(component.isReady());
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("a").toInt(), 10);
+
+ QQmlIncubator incubator(QQmlIncubator::AsynchronousIfNested);
+ component.create(incubator, 0, qmlContext(object));
+
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object());
+ QCOMPARE(incubator.object()->property("a").toInt(), 10);
+ delete incubator.object();
+ delete object;
+ }
+
+ // Asynchronous if nested within an executing context behaves asynchronously, but prevents
+ // the parent from finishing
+ {
+ SelfRegisteringType::clearMe();
+
+ QQmlComponent component(&engine, testFileUrl("asynchronousIfNested.2.qml"));
+ QVERIFY(component.isReady());
+
+ QQmlIncubator incubator;
+ component.create(incubator);
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(SelfRegisteringType::me() == 0);
+ while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QVERIFY(incubator.isLoading());
+
+ QQmlIncubator nested(QQmlIncubator::AsynchronousIfNested);
+ component.create(nested, 0, qmlContext(SelfRegisteringType::me()));
+ QVERIFY(nested.isLoading());
+
+ while (nested.isLoading()) {
+ QVERIFY(incubator.isLoading());
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(nested.isReady());
+ QVERIFY(incubator.isLoading());
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(nested.isReady());
+ QVERIFY(incubator.isReady());
+
+ delete nested.object();
+ delete incubator.object();
+ }
+
+ // AsynchronousIfNested within a synchronous AsynchronousIfNested behaves synchronously
+ {
+ SelfRegisteringType::clearMe();
+
+ QQmlComponent component(&engine, testFileUrl("asynchronousIfNested.3.qml"));
+ QVERIFY(component.isReady());
+
+ struct CallbackData {
+ CallbackData(QQmlEngine *e) : engine(e), pass(false) {}
+ QQmlEngine *engine;
+ bool pass;
+ static void callback(CallbackRegisteringType *o, void *data) {
+ CallbackData *d = (CallbackData *)data;
+
+ QQmlComponent c(d->engine, QQmlDataTest::instance()->testFileUrl("asynchronousIfNested.1.qml"));
+ if (!c.isReady()) return;
+
+ QQmlIncubator incubator(QQmlIncubator::AsynchronousIfNested);
+ c.create(incubator, 0, qmlContext(o));
+
+ if (!incubator.isReady()) return;
+
+ if (incubator.object()->property("a").toInt() != 10) return;
+
+ d->pass = true;
+ }
+ };
+
+ CallbackData cd(&engine);
+ CallbackRegisteringType::registerCallback(&CallbackData::callback, &cd);
+
+ QQmlIncubator incubator(QQmlIncubator::AsynchronousIfNested);
+ component.create(incubator);
+
+ QVERIFY(incubator.isReady());
+ QCOMPARE(cd.pass, true);
+
+ delete incubator.object();
+ }
+}
+
+void tst_qqmlincubator::nestedComponent()
+{
+ QQmlComponent component(&engine, testFileUrl("nestedComponent.qml"));
+ QVERIFY(component.isReady());
+
+ QObject *object = component.create();
+
+ QQmlComponent *nested = object->property("c").value<QQmlComponent*>();
+ QVERIFY(nested);
+ QVERIFY(nested->isReady());
+
+ // Test without incubator
+ {
+ QObject *nestedObject = nested->create();
+ QCOMPARE(nestedObject->property("value").toInt(), 19988);
+ delete nestedObject;
+ }
+
+ // Test with incubator
+ {
+ QQmlIncubator incubator(QQmlIncubator::Synchronous);
+ nested->create(incubator);
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator.object());
+ QCOMPARE(incubator.object()->property("value").toInt(), 19988);
+ delete incubator.object();
+ }
+
+ delete object;
+}
+
+// Checks that a new AsynchronousIfNested incubator can be correctly started in the
+// statusChanged() callback of another.
+void tst_qqmlincubator::chainedAsynchronousIfNested()
+{
+ SelfRegisteringType::clearMe();
+
+ QQmlComponent component(&engine, testFileUrl("chainedAsynchronousIfNested.qml"));
+ QVERIFY(component.isReady());
+
+ QQmlIncubator incubator(QQmlIncubator::Asynchronous);
+ component.create(incubator);
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(SelfRegisteringType::me() == 0);
+
+ while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QVERIFY(incubator.isLoading());
+
+ struct MyIncubator : public QQmlIncubator {
+ MyIncubator(MyIncubator *next, QQmlComponent *component, QQmlContext *ctxt)
+ : QQmlIncubator(AsynchronousIfNested), next(next), component(component), ctxt(ctxt) {}
+
+ protected:
+ virtual void statusChanged(Status s) {
+ if (s == Ready && next)
+ component->create(*next, 0, ctxt);
+ }
+
+ private:
+ MyIncubator *next;
+ QQmlComponent *component;
+ QQmlContext *ctxt;
+ };
+
+ MyIncubator incubator2(0, &component, 0);
+ MyIncubator incubator1(&incubator2, &component, qmlContext(SelfRegisteringType::me()));
+
+ component.create(incubator1, 0, qmlContext(SelfRegisteringType::me()));
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isLoading());
+ QVERIFY(incubator2.isNull());
+
+ while (incubator1.isLoading()) {
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isLoading());
+ QVERIFY(incubator2.isNull());
+
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isLoading());
+
+ while (incubator2.isLoading()) {
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isLoading());
+
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isReady());
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isReady());
+}
+
+// Checks that new AsynchronousIfNested incubators can be correctly chained if started in
+// componentCompleted().
+void tst_qqmlincubator::chainedAsynchronousIfNestedOnCompleted()
+{
+ SelfRegisteringType::clearMe();
+
+ QQmlComponent component(&engine, testFileUrl("chainInCompletion.qml"));
+ QVERIFY(component.isReady());
+
+ QQmlComponent c1(&engine, testFileUrl("chainedAsynchronousIfNested.qml"));
+ QVERIFY(c1.isReady());
+
+ struct MyIncubator : public QQmlIncubator {
+ MyIncubator(MyIncubator *next, QQmlComponent *component, QQmlContext *ctxt)
+ : QQmlIncubator(AsynchronousIfNested), next(next), component(component), ctxt(ctxt) {}
+
+ protected:
+ virtual void statusChanged(Status s) {
+ if (s == Ready && next) {
+ component->create(*next, 0, ctxt);
+ }
+ }
+
+ private:
+ MyIncubator *next;
+ QQmlComponent *component;
+ QQmlContext *ctxt;
+ };
+
+ struct CallbackData {
+ CallbackData(QQmlComponent *c, MyIncubator *i, QQmlContext *ct)
+ : component(c), incubator(i), ctxt(ct) {}
+ QQmlComponent *component;
+ MyIncubator *incubator;
+ QQmlContext *ctxt;
+ static void callback(CompletionCallbackType *, void *data) {
+ CallbackData *d = (CallbackData *)data;
+ d->component->create(*d->incubator, 0, d->ctxt);
+ }
+ };
+
+ QQmlIncubator incubator(QQmlIncubator::Asynchronous);
+ component.create(incubator);
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(SelfRegisteringType::me() == 0);
+
+ while (SelfRegisteringType::me() == 0 && incubator.isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QVERIFY(incubator.isLoading());
+
+ MyIncubator incubator3(0, &c1, qmlContext(SelfRegisteringType::me()));
+ MyIncubator incubator2(&incubator3, &c1, qmlContext(SelfRegisteringType::me()));
+ MyIncubator incubator1(&incubator2, &c1, qmlContext(SelfRegisteringType::me()));
+
+ // start incubator1 in componentComplete
+ CallbackData cd(&c1, &incubator1, qmlContext(SelfRegisteringType::me()));
+ CompletionCallbackType::registerCallback(&CallbackData::callback, &cd);
+
+ while (!incubator1.isLoading()) {
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator2.isNull());
+ QVERIFY(incubator3.isNull());
+
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isLoading());
+ QVERIFY(incubator2.isNull());
+ QVERIFY(incubator3.isNull());
+
+ while (incubator1.isLoading()) {
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isLoading());
+ QVERIFY(incubator2.isNull());
+ QVERIFY(incubator3.isNull());
+
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isLoading());
+ QVERIFY(incubator3.isNull());
+
+ while (incubator2.isLoading()) {
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isLoading());
+ QVERIFY(incubator3.isNull());
+
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isReady());
+ QVERIFY(incubator3.isLoading());
+
+ while (incubator3.isLoading()) {
+ QVERIFY(incubator.isLoading());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isReady());
+ QVERIFY(incubator3.isLoading());
+
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(incubator.isReady());
+ QVERIFY(incubator1.isReady());
+ QVERIFY(incubator2.isReady());
+ QVERIFY(incubator3.isReady());
+}
+
+void tst_qqmlincubator::selfDelete()
+{
+ struct MyIncubator : public QQmlIncubator {
+ MyIncubator(bool *done, Status status, IncubationMode mode)
+ : QQmlIncubator(mode), done(done), status(status) {}
+
+ protected:
+ virtual void statusChanged(Status s) {
+ if (s == status) {
+ *done = true;
+ if (s == Ready) delete object();
+ delete this;
+ }
+ }
+
+ private:
+ bool *done;
+ Status status;
+ };
+
+ {
+ QQmlComponent component(&engine, testFileUrl("selfDelete.qml"));
+
+#define DELETE_TEST(status, mode) { \
+ bool done = false; \
+ component.create(*(new MyIncubator(&done, status, mode))); \
+ bool True = true; \
+ controller.incubateWhile(&True); \
+ QVERIFY(done == true); \
+ }
+
+ DELETE_TEST(QQmlIncubator::Loading, QQmlIncubator::Synchronous);
+ DELETE_TEST(QQmlIncubator::Ready, QQmlIncubator::Synchronous);
+ DELETE_TEST(QQmlIncubator::Loading, QQmlIncubator::Asynchronous);
+ DELETE_TEST(QQmlIncubator::Ready, QQmlIncubator::Asynchronous);
+
+#undef DELETE_TEST
+ }
+
+ // Delete within error status
+ {
+ SelfRegisteringType::clearMe();
+
+ QQmlComponent component(&engine, testFileUrl("objectDeleted.qml"));
+ QVERIFY(component.isReady());
+
+ bool done = false;
+ MyIncubator *incubator = new MyIncubator(&done, QQmlIncubator::Error,
+ QQmlIncubator::Asynchronous);
+ component.create(*incubator);
+
+ QCOMPARE(incubator->QQmlIncubator::status(), QQmlIncubator::Loading);
+ QVERIFY(SelfRegisteringType::me() == 0);
+
+ while (SelfRegisteringType::me() == 0 && incubator->isLoading()) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(SelfRegisteringType::me() != 0);
+ QVERIFY(incubator->isLoading());
+
+ delete SelfRegisteringType::me();
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ QVERIFY(done);
+ }
+}
+
+// Test that QML doesn't crash if the context is deleted prior to the incubator
+// first executing.
+void tst_qqmlincubator::contextDelete()
+{
+ QQmlContext *context = new QQmlContext(engine.rootContext());
+ QQmlComponent component(&engine, testFileUrl("contextDelete.qml"));
+
+ QQmlIncubator incubator;
+ component.create(incubator, context);
+
+ delete context;
+
+ {
+ bool b = false;
+ controller.incubateWhile(&b);
+ }
+}
+
+QTEST_MAIN(tst_qqmlincubator)
+
+#include "tst_qqmlincubator.moc"
diff --git a/tests/auto/declarative/qdeclarativeinfo/data/NestedComponent.qml b/tests/auto/qml/qqmlinfo/data/NestedComponent.qml
index cfe47589df..cfe47589df 100644
--- a/tests/auto/declarative/qdeclarativeinfo/data/NestedComponent.qml
+++ b/tests/auto/qml/qqmlinfo/data/NestedComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml b/tests/auto/qml/qqmlinfo/data/NestedObject.qml
index 4b19b11699..4b19b11699 100644
--- a/tests/auto/declarative/qdeclarativeinfo/data/NestedObject.qml
+++ b/tests/auto/qml/qqmlinfo/data/NestedObject.qml
diff --git a/tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml b/tests/auto/qml/qqmlinfo/data/nestedQmlObject.qml
index d199a612c4..d199a612c4 100644
--- a/tests/auto/declarative/qdeclarativeinfo/data/nestedQmlObject.qml
+++ b/tests/auto/qml/qqmlinfo/data/nestedQmlObject.qml
diff --git a/tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml b/tests/auto/qml/qqmlinfo/data/qmlObject.qml
index 6a8e2fbc90..6a8e2fbc90 100644
--- a/tests/auto/declarative/qdeclarativeinfo/data/qmlObject.qml
+++ b/tests/auto/qml/qqmlinfo/data/qmlObject.qml
diff --git a/tests/auto/qml/qqmlinfo/qqmlinfo.pro b/tests/auto/qml/qqmlinfo/qqmlinfo.pro
new file mode 100644
index 0000000000..21dc2c76a6
--- /dev/null
+++ b/tests/auto/qml/qqmlinfo/qqmlinfo.pro
@@ -0,0 +1,14 @@
+CONFIG += testcase
+TARGET = tst_qqmlinfo
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlinfo.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private widgets testlib
diff --git a/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp
new file mode 100644
index 0000000000..ed53cbd1aa
--- /dev/null
+++ b/tests/auto/qml/qqmlinfo/tst_qqmlinfo.cpp
@@ -0,0 +1,221 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QTimer>
+#include <QQmlContext>
+#include <qqmlinfo.h>
+#include "../../shared/util.h"
+
+class tst_qqmlinfo : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlinfo() {}
+
+private slots:
+ void qmlObject();
+ void nestedQmlObject();
+ void nestedComponent();
+ void nonQmlObject();
+ void nullObject();
+ void nonQmlContextedObject();
+ void types();
+ void chaining();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_qqmlinfo::qmlObject()
+{
+ QQmlComponent component(&engine, testFileUrl("qmlObject.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QString message = component.url().toString() + ":3:1: QML QtObject: Test Message";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(object) << "Test Message";
+
+ QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
+ QVERIFY(nested != 0);
+
+ message = component.url().toString() + ":6:13: QML QtObject: Second Test Message";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(nested) << "Second Test Message";
+}
+
+void tst_qqmlinfo::nestedQmlObject()
+{
+ QQmlComponent component(&engine, testFileUrl("nestedQmlObject.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
+ QVERIFY(nested != 0);
+ QObject *nested2 = qvariant_cast<QObject *>(object->property("nested2"));
+ QVERIFY(nested2 != 0);
+
+ QString message = component.url().toString() + ":5:13: QML NestedObject: Outer Object";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(nested) << "Outer Object";
+
+ message = testFileUrl("NestedObject.qml").toString() + ":6:14: QML QtObject: Inner Object";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(nested2) << "Inner Object";
+}
+
+void tst_qqmlinfo::nestedComponent()
+{
+ QQmlComponent component(&engine, testFileUrl("NestedComponent.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *nested = qvariant_cast<QObject *>(object->property("nested"));
+ QVERIFY(nested != 0);
+ QObject *nested2 = qvariant_cast<QObject *>(object->property("nested2"));
+ QVERIFY(nested2 != 0);
+
+ QString message = component.url().toString() + ":10:9: QML NestedObject: Complex Object";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(nested) << "Complex Object";
+
+ message = component.url().toString() + ":16:9: QML Image: Simple Object";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ qmlInfo(nested2) << "Simple Object";
+}
+
+void tst_qqmlinfo::nonQmlObject()
+{
+ QObject object;
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML QtObject: Test Message");
+ qmlInfo(&object) << "Test Message";
+
+ QTimer nonQmlObject;
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML QTimer: Test Message");
+ qmlInfo(&nonQmlObject) << "Test Message";
+}
+
+void tst_qqmlinfo::nullObject()
+{
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Null Object Test Message");
+ qmlInfo(0) << "Null Object Test Message";
+}
+
+void tst_qqmlinfo::nonQmlContextedObject()
+{
+ QObject object;
+ QQmlContext context(&engine);
+ QQmlEngine::setContextForObject(&object, &context);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML QtObject: Test Message");
+ qmlInfo(&object) << "Test Message";
+}
+
+void tst_qqmlinfo::types()
+{
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: false");
+ qmlInfo(0) << false;
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 1.1");
+ qmlInfo(0) << 1.1;
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 1.2");
+ qmlInfo(0) << 1.2f;
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 15");
+ qmlInfo(0) << 15;
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 'b'");
+ qmlInfo(0) << QChar('b');
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: \"Qt\"");
+ qmlInfo(0) << QByteArray("Qt");
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: true");
+ qmlInfo(0) << bool(true);
+
+ //### do we actually want QUrl to show up in the output?
+ //### why the extra space at the end?
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QUrl(\"http://qt.nokia.com\") ");
+ qmlInfo(0) << QUrl("http://qt.nokia.com");
+
+ //### should this be quoted?
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: hello");
+ qmlInfo(0) << QLatin1String("hello");
+
+ //### should this be quoted?
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: World");
+ QString str("Hello World");
+ QStringRef ref(&str, 6, 5);
+ qmlInfo(0) << ref;
+
+ //### should this be quoted?
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Quick");
+ qmlInfo(0) << QString ("Quick");
+}
+
+void tst_qqmlinfo::chaining()
+{
+ //### should more of these be automatically inserting spaces?
+ QString str("Hello World");
+ QStringRef ref(&str, 6, 5);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: false 1.1 1.2 15 hello 'b' QUrl(\"http://qt.nokia.com\") World \"Qt\" true Quick ");
+ qmlInfo(0) << false << ' '
+ << 1.1 << ' '
+ << 1.2f << ' '
+ << 15 << ' '
+ << QLatin1String("hello") << ' '
+ << QChar('b') << ' '
+ << QUrl("http://qt.nokia.com")
+ << ref
+ << QByteArray("Qt")
+ << bool(true)
+ << QString ("Quick");
+}
+
+QTEST_MAIN(tst_qqmlinfo)
+
+#include "tst_qqmlinfo.moc"
diff --git a/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro b/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro
new file mode 100644
index 0000000000..093b190bbf
--- /dev/null
+++ b/tests/auto/qml/qqmlinstruction/qqmlinstruction.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+TARGET = tst_qqmlinstruction
+SOURCES += tst_qqmlinstruction.cpp
+macx:CONFIG -= app_bundle
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private testlib
diff --git a/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp
new file mode 100644
index 0000000000..07b89af0a3
--- /dev/null
+++ b/tests/auto/qml/qqmlinstruction/tst_qqmlinstruction.cpp
@@ -0,0 +1,678 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <private/qqmlcompiler_p.h>
+
+class tst_qqmlinstruction : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmlinstruction() {}
+
+private slots:
+ void dump();
+
+ void point();
+ void pointf();
+ void size();
+ void sizef();
+ void rect();
+ void rectf();
+ void vector3d();
+ void vector4d();
+ void time();
+};
+
+static QStringList messages;
+static void msgHandler(QtMsgType, const char *msg)
+{
+ messages << QLatin1String(msg);
+}
+
+void tst_qqmlinstruction::dump()
+{
+ QQmlEngine engine;
+ QQmlCompiledData *data = new QQmlCompiledData(&engine);
+
+ {
+ QQmlCompiledData::Instruction::Init i;
+ i.bindingsSize = 0;
+ i.parserStatusSize = 3;
+ i.contextCache = -1;
+ i.compiledBinding = -1;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::TypeReference ref;
+ ref.className = "Test";
+ data->types << ref;
+
+ QQmlCompiledData::Instruction::CreateCppObject i;
+ i.type = 0;
+ i.data = -1;
+ i.column = 10;
+ data->addInstruction(i);
+ }
+
+ {
+ data->primitives << "testId";
+
+ QQmlCompiledData::Instruction::SetId i;
+ i.value = data->primitives.count() - 1;
+ i.index = 0;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::SetDefault i;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::CreateComponent i;
+ i.count = 3;
+ i.column = 4;
+ i.endLine = 14;
+ i.metaObject = 0;
+
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreMetaObject i;
+ i.data = 3;
+ i.aliasData = 6;
+ i.propertyCache = 7;
+
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreFloat i;
+ i.propertyIndex = 3;
+ i.value = 11.3;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreDouble i;
+ i.propertyIndex = 4;
+ i.value = 14.8;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreInteger i;
+ i.propertyIndex = 5;
+ i.value = 9;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreBool i;
+ i.propertyIndex = 6;
+ i.value = true;
+
+ data->addInstruction(i);
+ }
+
+ {
+ data->primitives << "Test String";
+ QQmlCompiledData::Instruction::StoreString i;
+ i.propertyIndex = 7;
+ i.value = data->primitives.count() - 1;
+ data->addInstruction(i);
+ }
+
+ {
+ data->urls << QUrl("http://www.nokia.com");
+ QQmlCompiledData::Instruction::StoreUrl i;
+ i.propertyIndex = 8;
+ i.value = data->urls.count() - 1;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreColor i;
+ i.propertyIndex = 9;
+ i.value = 0xFF00FF00;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreDate i;
+ i.propertyIndex = 10;
+ i.value = 9;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreTime i;
+ i.propertyIndex = 11;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreDateTime i;
+ i.propertyIndex = 12;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StorePoint i;
+ i.propertyIndex = 13;
+ i.point.xp = 3;
+ i.point.yp = 7;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StorePointF i;
+ i.propertyIndex = 13;
+ i.point.xp = 3;
+ i.point.yp = 7;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreSize i;
+ i.propertyIndex = 15;
+ i.size.wd = 8;
+ i.size.ht = 11;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreSizeF i;
+ i.propertyIndex = 15;
+ i.size.wd = 8;
+ i.size.ht = 11;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreRect i;
+ i.propertyIndex = 17;
+ i.rect.x1 = 7;
+ i.rect.y1 = 9;
+ i.rect.x2 = 11;
+ i.rect.y2 = 13;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreRectF i;
+ i.propertyIndex = 18;
+ i.rect.xp = 11.3;
+ i.rect.yp = 9.8;
+ i.rect.w = 3;
+ i.rect.h = 2.1;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreVector3D i;
+ i.propertyIndex = 19;
+ i.vector.xp = 9;
+ i.vector.yp = 3;
+ i.vector.zp = 92;
+ data->addInstruction(i);
+ }
+
+ {
+ data->primitives << "color(1, 1, 1, 1)";
+ QQmlCompiledData::Instruction::StoreVariant i;
+ i.propertyIndex = 20;
+ i.value = data->primitives.count() - 1;
+
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreObject i;
+ i.propertyIndex = 21;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreVariantObject i;
+ i.propertyIndex = 22;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreInterface i;
+ i.propertyIndex = 23;
+ data->addInstruction(i);
+ }
+
+ {
+ data->primitives << "console.log(1921)";
+
+ QQmlCompiledData::Instruction::StoreSignal i;
+ i.signalIndex = 2;
+ i.value = data->primitives.count() - 1;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreScriptString i;
+ i.propertyIndex = 24;
+ i.value = 3;
+ i.scope = 1;
+ i.bindingId = 4;
+ data->addInstruction(i);
+ }
+
+ {
+ data->primitives << "mySignal";
+
+ QQmlCompiledData::Instruction::AssignSignalObject i;
+ i.signal = data->primitives.count() - 1;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::AssignCustomType i;
+ i.propertyIndex = 25;
+ i.primitive = 6;
+ i.type = 9;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreBinding i;
+ i.property.coreIndex = 26;
+ i.value = 3;
+ i.context = 2;
+ i.owner = 0;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreV4Binding i;
+ i.property = 27;
+ i.value = 2;
+ i.context = 4;
+ i.owner = 0;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreValueSource i;
+ i.property.coreIndex = 29;
+ i.owner = 1;
+ i.castValue = 4;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreValueInterceptor i;
+ i.property.coreIndex = 30;
+ i.owner = 2;
+ i.castValue = -4;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::BeginObject i;
+ i.castValue = 4;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreObjectQList i;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::AssignObjectList i;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::FetchAttached i;
+ i.id = 23;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::FetchQList i;
+ i.property = 32;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::FetchObject i;
+ i.property = 33;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::FetchValueType i;
+ i.property = 34;
+ i.type = 6;
+ i.bindingSkipList = 7;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::PopFetchedObject i;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::PopQList i;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::PopValueType i;
+ i.property = 35;
+ i.type = 8;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::Defer i;
+ i.deferCount = 7;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::Defer i;
+ i.deferCount = 7;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreImportedScript i;
+ i.value = 2;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreVariantInteger i;
+ i.value = 11;
+ i.propertyIndex = 32;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreVariantDouble i;
+ i.value = 33.7;
+ i.propertyIndex = 19;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::Done i;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreTrString i;
+ i.propertyIndex = 99;
+ i.context = 3;
+ i.text = 14;
+ i.comment = 14;
+ i.n = 2;
+ data->addInstruction(i);
+ }
+
+ {
+ QQmlCompiledData::Instruction::StoreTrIdString i;
+ i.propertyIndex = 78;
+ i.text = 7;
+ i.n = -1;
+ data->addInstruction(i);
+ }
+
+ QStringList expect;
+ expect
+ << "Index\tOperation\t\tData1\tData2\tData3\tComments"
+ << "-------------------------------------------------------------------------------"
+ << "0\t\tINIT\t\t\t0\t3\t-1\t-1"
+ << "1\t\tCREATECPP\t\t\t0\t\t\t\"Test\""
+ << "2\t\tSETID\t\t\t0\t\t\t\"testId\""
+ << "3\t\tSET_DEFAULT"
+ << "4\t\tCREATE_COMPONENT\t3"
+ << "5\t\tSTORE_META\t\t3"
+ << "6\t\tSTORE_FLOAT\t\t3\t11.3"
+ << "7\t\tSTORE_DOUBLE\t\t4\t14.8"
+ << "8\t\tSTORE_INTEGER\t\t5\t9"
+ << "9\t\tSTORE_BOOL\t\t6\ttrue"
+ << "10\t\tSTORE_STRING\t\t7\t1\t\t\"Test String\""
+ << "11\t\tSTORE_URL\t\t8\t0\t\tQUrl(\"http://www.nokia.com\") "
+ << "12\t\tSTORE_COLOR\t\t9\t\t\t\"ff00ff00\""
+ << "13\t\tSTORE_DATE\t\t10\t9"
+ << "14\t\tSTORE_TIME\t\t11"
+ << "15\t\tSTORE_DATETIME\t\t12"
+ << "16\t\tSTORE_POINT\t\t13\t3\t7"
+ << "17\t\tSTORE_POINTF\t\t13\t3\t7"
+ << "18\t\tSTORE_SIZE\t\t15\t8\t11"
+ << "19\t\tSTORE_SIZEF\t\t15\t8\t11"
+ << "20\t\tSTORE_RECT\t\t17\t7\t9\t11\t13"
+ << "21\t\tSTORE_RECTF\t\t18\t11.3\t9.8\t3\t2.1"
+ << "22\t\tSTORE_VECTOR3D\t\t19\t9\t3\t92"
+ << "23\t\tSTORE_VARIANT\t\t20\t2\t\t\"color(1, 1, 1, 1)\""
+ << "24\t\tSTORE_OBJECT\t\t21"
+ << "25\t\tSTORE_VARIANT_OBJECT\t22"
+ << "26\t\tSTORE_INTERFACE\t\t23"
+ << "27\t\tSTORE_SIGNAL\t\t2\t3\t\t\"console.log(1921)\""
+ << "28\t\tSTORE_SCRIPT_STRING\t24\t3\t1\t4"
+ << "29\t\tASSIGN_SIGNAL_OBJECT\t4\t\t\t\"mySignal\""
+ << "30\t\tASSIGN_CUSTOMTYPE\t25\t6\t9"
+ << "31\t\tSTORE_BINDING\t26\t3\t2"
+ << "32\t\tSTORE_COMPILED_BINDING\t27\t2\t4"
+ << "33\t\tSTORE_VALUE_SOURCE\t29\t4"
+ << "34\t\tSTORE_VALUE_INTERCEPTOR\t30\t-4"
+ << "35\t\tBEGIN\t\t\t4"
+ << "36\t\tSTORE_OBJECT_QLIST"
+ << "37\t\tASSIGN_OBJECT_LIST"
+ << "38\t\tFETCH_ATTACHED\t\t23"
+ << "39\t\tFETCH_QLIST\t\t32"
+ << "40\t\tFETCH\t\t\t33"
+ << "41\t\tFETCH_VALUE\t\t34\t6\t7"
+ << "42\t\tPOP"
+ << "43\t\tPOP_QLIST"
+ << "44\t\tPOP_VALUE\t\t35\t8"
+ << "45\t\tDEFER\t\t\t7"
+ << "46\t\tDEFER\t\t\t7"
+ << "47\t\tSTORE_IMPORTED_SCRIPT\t2"
+ << "48\t\tSTORE_VARIANT_INTEGER\t\t32\t11"
+ << "49\t\tSTORE_VARIANT_DOUBLE\t\t19\t33.7"
+ << "50\t\tDONE"
+ << "51\t\tSTORE_TR_STRING\t99\t3\t14\t14\t2"
+ << "52\t\tSTORE_TRID_STRING\t78\t7\t-1"
+ << "-------------------------------------------------------------------------------";
+
+ messages = QStringList();
+ QtMsgHandler old = qInstallMsgHandler(msgHandler);
+
+ data->dumpInstructions();
+ qInstallMsgHandler(old);
+
+ QCOMPARE(messages.count(), expect.count());
+ for (int ii = 0; ii < messages.count(); ++ii) {
+ QCOMPARE(messages.at(ii), expect.at(ii));
+ }
+
+ data->release();
+}
+
+void tst_qqmlinstruction::point()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storePoint::QPoint), sizeof(QPoint));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storePoint::QPoint), Q_ALIGNOF(QPoint));
+
+ QQmlInstruction i;
+ i.storePoint.point.xp = 8;
+ i.storePoint.point.yp = 11;
+
+ const QPoint &point = (const QPoint &)(i.storePoint.point);
+ QCOMPARE(point.x(), 8);
+ QCOMPARE(point.y(), 11);
+}
+
+void tst_qqmlinstruction::pointf()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storePointF::QPointF), sizeof(QPointF));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storePointF::QPointF), Q_ALIGNOF(QPointF));
+
+ QQmlInstruction i;
+ i.storePointF.point.xp = 8.7;
+ i.storePointF.point.yp = 11.3;
+
+ const QPointF &point = (const QPointF &)(i.storePointF.point);
+ QCOMPARE(point.x(), 8.7);
+ QCOMPARE(point.y(), 11.3);
+}
+
+void tst_qqmlinstruction::size()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storeSize::QSize), sizeof(QSize));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeSize::QSize), Q_ALIGNOF(QSize));
+
+ QQmlInstruction i;
+ i.storeSize.size.wd = 8;
+ i.storeSize.size.ht = 11;
+
+ const QSize &size = (const QSize &)(i.storeSize.size);
+ QCOMPARE(size.width(), 8);
+ QCOMPARE(size.height(), 11);
+}
+
+void tst_qqmlinstruction::sizef()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storeSizeF::QSizeF), sizeof(QSizeF));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeSizeF::QSizeF), Q_ALIGNOF(QSizeF));
+
+ QQmlInstruction i;
+ i.storeSizeF.size.wd = 8;
+ i.storeSizeF.size.ht = 11;
+
+ const QSizeF &size = (const QSizeF &)(i.storeSizeF.size);
+ QCOMPARE(size.width(), (qreal)8);
+ QCOMPARE(size.height(), (qreal)11);
+}
+
+void tst_qqmlinstruction::rect()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storeRect::QRect), sizeof(QRect));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeRect::QRect), Q_ALIGNOF(QRect));
+
+ QQmlInstruction i;
+ i.storeRect.rect.x1 = 8;
+ i.storeRect.rect.y1 = 11;
+ i.storeRect.rect.x2 = 13;
+ i.storeRect.rect.y2 = 19;
+
+ const QRect &rect = (const QRect &)(i.storeRect.rect);
+ QCOMPARE(rect.left(), 8);
+ QCOMPARE(rect.top(), 11);
+ QCOMPARE(rect.right(), 13);
+ QCOMPARE(rect.bottom(), 19);
+}
+
+void tst_qqmlinstruction::rectf()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storeRectF::QRectF), sizeof(QRectF));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeRectF::QRectF), Q_ALIGNOF(QRectF));
+
+ QQmlInstruction i;
+ i.storeRectF.rect.xp = 8;
+ i.storeRectF.rect.yp = 11;
+ i.storeRectF.rect.w = 13;
+ i.storeRectF.rect.h = 19;
+
+ const QRectF &rect = (const QRectF &)(i.storeRectF.rect);
+ QCOMPARE(rect.left(), (qreal)8);
+ QCOMPARE(rect.top(), (qreal)11);
+ QCOMPARE(rect.width(), (qreal)13);
+ QCOMPARE(rect.height(), (qreal)19);
+}
+
+void tst_qqmlinstruction::vector3d()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storeVector3D::QVector3D), sizeof(QVector3D));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeVector3D::QVector3D), Q_ALIGNOF(QVector3D));
+
+ QQmlInstruction i;
+ i.storeVector3D.vector.xp = 8.2;
+ i.storeVector3D.vector.yp = 99.3;
+ i.storeVector3D.vector.zp = 12.0;
+
+ const QVector3D &vector = (const QVector3D &)(i.storeVector3D.vector);
+ QCOMPARE(vector.x(), (qreal)(float)8.2);
+ QCOMPARE(vector.y(), (qreal)(float)99.3);
+ QCOMPARE(vector.z(), (qreal)(float)12.0);
+}
+
+void tst_qqmlinstruction::vector4d()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storeVector4D::QVector4D), sizeof(QVector4D));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeVector4D::QVector4D), Q_ALIGNOF(QVector4D));
+
+ QQmlInstruction i;
+ i.storeVector4D.vector.xp = 8.2;
+ i.storeVector4D.vector.yp = 99.3;
+ i.storeVector4D.vector.zp = 12.0;
+ i.storeVector4D.vector.wp = 121.1;
+
+ const QVector4D &vector = (const QVector4D &)(i.storeVector4D.vector);
+ QCOMPARE(vector.x(), (qreal)(float)8.2);
+ QCOMPARE(vector.y(), (qreal)(float)99.3);
+ QCOMPARE(vector.z(), (qreal)(float)12.0);
+ QCOMPARE(vector.w(), (qreal)(float)121.1);
+}
+
+void tst_qqmlinstruction::time()
+{
+ QCOMPARE(sizeof(QQmlInstruction::instr_storeTime::QTime), sizeof(QTime));
+ QCOMPARE(Q_ALIGNOF(QQmlInstruction::instr_storeTime::QTime), Q_ALIGNOF(QTime));
+}
+
+QTEST_MAIN(tst_qqmlinstruction)
+
+#include "tst_qqmlinstruction.moc"
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/Alias.qml b/tests/auto/qml/qqmllanguage/data/Alias.qml
index 2cb7cbe2e0..2cb7cbe2e0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/Alias.qml
+++ b/tests/auto/qml/qqmllanguage/data/Alias.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml b/tests/auto/qml/qqmllanguage/data/Alias2.qml
index 134e1440b5..134e1440b5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/Alias2.qml
+++ b/tests/auto/qml/qqmllanguage/data/Alias2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml b/tests/auto/qml/qqmllanguage/data/Alias3.qml
index 54b548e049..54b548e049 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/Alias3.qml
+++ b/tests/auto/qml/qqmllanguage/data/Alias3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml b/tests/auto/qml/qqmllanguage/data/Alias4.qml
index e09eca2ff3..e09eca2ff3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/Alias4.qml
+++ b/tests/auto/qml/qqmllanguage/data/Alias4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/AliasPropertyChangeSignalsType.qml b/tests/auto/qml/qqmllanguage/data/AliasPropertyChangeSignalsType.qml
index 9265ffb1df..9265ffb1df 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/AliasPropertyChangeSignalsType.qml
+++ b/tests/auto/qml/qqmllanguage/data/AliasPropertyChangeSignalsType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml b/tests/auto/qml/qqmllanguage/data/ComponentComposite.qml
index 889450b565..889450b565 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/ComponentComposite.qml
+++ b/tests/auto/qml/qqmllanguage/data/ComponentComposite.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml b/tests/auto/qml/qqmllanguage/data/CompositeType.qml
index addc4265a9..addc4265a9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType.qml
+++ b/tests/auto/qml/qqmllanguage/data/CompositeType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType2.qml b/tests/auto/qml/qqmllanguage/data/CompositeType2.qml
index 86210e9072..86210e9072 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType2.qml
+++ b/tests/auto/qml/qqmllanguage/data/CompositeType2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml b/tests/auto/qml/qqmllanguage/data/CompositeType3.qml
index f48a77598c..f48a77598c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType3.qml
+++ b/tests/auto/qml/qqmllanguage/data/CompositeType3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType4.qml b/tests/auto/qml/qqmllanguage/data/CompositeType4.qml
index a6a8168d8f..a6a8168d8f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/CompositeType4.qml
+++ b/tests/auto/qml/qqmllanguage/data/CompositeType4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/DontDoubleCallClassBeginItem.qml b/tests/auto/qml/qqmllanguage/data/DontDoubleCallClassBeginItem.qml
index 1f8eac8a3b..1f8eac8a3b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/DontDoubleCallClassBeginItem.qml
+++ b/tests/auto/qml/qqmllanguage/data/DontDoubleCallClassBeginItem.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml b/tests/auto/qml/qqmllanguage/data/DynamicPropertiesNestedType.qml
index 4667adda14..4667adda14 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/DynamicPropertiesNestedType.qml
+++ b/tests/auto/qml/qqmllanguage/data/DynamicPropertiesNestedType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml b/tests/auto/qml/qqmllanguage/data/HelperAlias.qml
index c2ab70ffd6..c2ab70ffd6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/HelperAlias.qml
+++ b/tests/auto/qml/qqmllanguage/data/HelperAlias.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/I18n.qml b/tests/auto/qml/qqmllanguage/data/I18n.qml
index 558c836e52..558c836e52 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/I18n.qml
+++ b/tests/auto/qml/qqmllanguage/data/I18n.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/I18nType30.qml b/tests/auto/qml/qqmllanguage/data/I18nType30.qml
index 42dbc69044..42dbc69044 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/I18nType30.qml
+++ b/tests/auto/qml/qqmllanguage/data/I18nType30.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml b/tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType.qml
index 42513e463f..42513e463f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType.qml
+++ b/tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml b/tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType2.qml
index 4a45535a50..4a45535a50 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/InlineAssignmentsOverrideBindingsType2.qml
+++ b/tests/auto/qml/qqmllanguage/data/InlineAssignmentsOverrideBindingsType2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/LocalLast.qml b/tests/auto/qml/qqmllanguage/data/LocalLast.qml
index 59df88216e..59df88216e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/LocalLast.qml
+++ b/tests/auto/qml/qqmllanguage/data/LocalLast.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/MyComponent.qml b/tests/auto/qml/qqmllanguage/data/MyComponent.qml
index 1a23277ff8..1a23277ff8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/MyComponent.qml
+++ b/tests/auto/qml/qqmllanguage/data/MyComponent.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/MyCompositeValueSource.qml b/tests/auto/qml/qqmllanguage/data/MyCompositeValueSource.qml
index e620e26490..e620e26490 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/MyCompositeValueSource.qml
+++ b/tests/auto/qml/qqmllanguage/data/MyCompositeValueSource.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/MyContainerComponent.qml b/tests/auto/qml/qqmllanguage/data/MyContainerComponent.qml
index 61f54c5eb8..61f54c5eb8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/MyContainerComponent.qml
+++ b/tests/auto/qml/qqmllanguage/data/MyContainerComponent.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml b/tests/auto/qml/qqmllanguage/data/NestedAlias.qml
index 7d49b0ac98..7d49b0ac98 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/NestedAlias.qml
+++ b/tests/auto/qml/qqmllanguage/data/NestedAlias.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/NestedComponentRoot.qml b/tests/auto/qml/qqmllanguage/data/NestedComponentRoot.qml
index 887d7fae50..887d7fae50 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/NestedComponentRoot.qml
+++ b/tests/auto/qml/qqmllanguage/data/NestedComponentRoot.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml b/tests/auto/qml/qqmllanguage/data/NestedErrorsType.qml
index 06a3212916..06a3212916 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/NestedErrorsType.qml
+++ b/tests/auto/qml/qqmllanguage/data/NestedErrorsType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml b/tests/auto/qml/qqmllanguage/data/OnCompletedType.qml
index 947f14811f..947f14811f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/OnCompletedType.qml
+++ b/tests/auto/qml/qqmllanguage/data/OnCompletedType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml b/tests/auto/qml/qqmllanguage/data/OnDestructionType.qml
index 11fb9d9578..11fb9d9578 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml
+++ b/tests/auto/qml/qqmllanguage/data/OnDestructionType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/ReadOnlyType.qml b/tests/auto/qml/qqmllanguage/data/ReadOnlyType.qml
index 456ac762fc..456ac762fc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/ReadOnlyType.qml
+++ b/tests/auto/qml/qqmllanguage/data/ReadOnlyType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml b/tests/auto/qml/qqmllanguage/data/alias.1.qml
index dbb3f06d32..dbb3f06d32 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.10.qml b/tests/auto/qml/qqmllanguage/data/alias.10.qml
index bf6352e82b..bf6352e82b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.10.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.10.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.11.qml b/tests/auto/qml/qqmllanguage/data/alias.11.qml
index fbd50d9dc9..fbd50d9dc9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.11.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.11.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.2.qml b/tests/auto/qml/qqmllanguage/data/alias.2.qml
index 5c922709fe..5c922709fe 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml b/tests/auto/qml/qqmllanguage/data/alias.3.qml
index 16a6d9d903..16a6d9d903 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.4.qml b/tests/auto/qml/qqmllanguage/data/alias.4.qml
index bd6a769367..bd6a769367 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml b/tests/auto/qml/qqmllanguage/data/alias.5.qml
index cee2a88cf7..cee2a88cf7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml b/tests/auto/qml/qqmllanguage/data/alias.6.qml
index 54d3c320e0..54d3c320e0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml b/tests/auto/qml/qqmllanguage/data/alias.7.qml
index 0dc54d6787..0dc54d6787 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml b/tests/auto/qml/qqmllanguage/data/alias.8.qml
index 3cb280ef47..3cb280ef47 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml b/tests/auto/qml/qqmllanguage/data/alias.9.qml
index 01cf9142b2..01cf9142b2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/alias.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/alias.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertiesAndSignals.qml b/tests/auto/qml/qqmllanguage/data/aliasPropertiesAndSignals.qml
index 60e66921d2..60e66921d2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertiesAndSignals.qml
+++ b/tests/auto/qml/qqmllanguage/data/aliasPropertiesAndSignals.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.2.qml b/tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.2.qml
index 089130d14c..089130d14c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.qml b/tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.qml
index 4e11b9174a..4e11b9174a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/aliasPropertyChangeSignals.qml
+++ b/tests/auto/qml/qqmllanguage/data/aliasPropertyChangeSignals.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/allowedRevisionOverloads.qml b/tests/auto/qml/qqmllanguage/data/allowedRevisionOverloads.qml
index 64acbd1576..64acbd1576 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/allowedRevisionOverloads.qml
+++ b/tests/auto/qml/qqmllanguage/data/allowedRevisionOverloads.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml b/tests/auto/qml/qqmllanguage/data/assignBasicTypes.qml
index 28a340128d..28a340128d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignBasicTypes.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignBasicTypes.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml b/tests/auto/qml/qqmllanguage/data/assignCompositeToType.qml
index 717cd84536..717cd84536 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignCompositeToType.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignCompositeToType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralSignalProperty.qml b/tests/auto/qml/qqmllanguage/data/assignLiteralSignalProperty.qml
index 399fcea04d..399fcea04d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralSignalProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignLiteralSignalProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVar.qml b/tests/auto/qml/qqmllanguage/data/assignLiteralToVar.qml
index 89e66c6172..89e66c6172 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVar.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignLiteralToVar.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml b/tests/auto/qml/qqmllanguage/data/assignLiteralToVariant.qml
index f6f9a139dc..f6f9a139dc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignLiteralToVariant.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToSignal.qml b/tests/auto/qml/qqmllanguage/data/assignObjectToSignal.qml
index 789cc66215..789cc66215 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToSignal.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignObjectToSignal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml b/tests/auto/qml/qqmllanguage/data/assignObjectToVariant.qml
index 1f731c539c..1f731c539c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignObjectToVariant.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignObjectToVariant.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignQmlComponent.qml b/tests/auto/qml/qqmllanguage/data/assignQmlComponent.qml
index 20bdc559c1..20bdc559c1 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignQmlComponent.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignQmlComponent.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignSignal.qml b/tests/auto/qml/qqmllanguage/data/assignSignal.qml
index 2a48df8fcf..2a48df8fcf 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignSignal.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignSignal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.errors.txt b/tests/auto/qml/qqmllanguage/data/assignToNamespace.errors.txt
index 78aa4713fb..78aa4713fb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/assignToNamespace.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml b/tests/auto/qml/qqmllanguage/data/assignToNamespace.qml
index 54fef61ef0..54fef61ef0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignToNamespace.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignTypeExtremes.qml b/tests/auto/qml/qqmllanguage/data/assignTypeExtremes.qml
index 60ede525e4..60ede525e4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignTypeExtremes.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignTypeExtremes.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt b/tests/auto/qml/qqmllanguage/data/assignValueToSignal.errors.txt
index eb1430a715..eb1430a715 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/assignValueToSignal.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.qml b/tests/auto/qml/qqmllanguage/data/assignValueToSignal.qml
index 6fa1259f39..6fa1259f39 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.qml
+++ b/tests/auto/qml/qqmllanguage/data/assignValueToSignal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml b/tests/auto/qml/qqmllanguage/data/attachedProperties.qml
index 3637ded26f..3637ded26f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/attachedProperties.qml
+++ b/tests/auto/qml/qqmllanguage/data/attachedProperties.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/autoComponentCreation.qml b/tests/auto/qml/qqmllanguage/data/autoComponentCreation.qml
index 5d00144eaf..5d00144eaf 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/autoComponentCreation.qml
+++ b/tests/auto/qml/qqmllanguage/data/autoComponentCreation.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml b/tests/auto/qml/qqmllanguage/data/autoNotifyConnection.qml
index 640fb54f99..640fb54f99 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/autoNotifyConnection.qml
+++ b/tests/auto/qml/qqmllanguage/data/autoNotifyConnection.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.1.errors.txt b/tests/auto/qml/qqmllanguage/data/component.1.errors.txt
index 091aad61fa..091aad61fa 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.1.qml b/tests/auto/qml/qqmllanguage/data/component.1.qml
index a22772bd89..a22772bd89 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.2.errors.txt b/tests/auto/qml/qqmllanguage/data/component.2.errors.txt
index 76e7656a62..76e7656a62 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.2.qml b/tests/auto/qml/qqmllanguage/data/component.2.qml
index fbe315f771..fbe315f771 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt b/tests/auto/qml/qqmllanguage/data/component.3.errors.txt
index 450fc163bd..450fc163bd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.3.qml b/tests/auto/qml/qqmllanguage/data/component.3.qml
index bac23ef903..bac23ef903 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.4.errors.txt b/tests/auto/qml/qqmllanguage/data/component.4.errors.txt
index 2ab18685c8..2ab18685c8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.4.qml b/tests/auto/qml/qqmllanguage/data/component.4.qml
index d07695477d..d07695477d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.5.errors.txt b/tests/auto/qml/qqmllanguage/data/component.5.errors.txt
index e3c2df755f..e3c2df755f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.5.qml b/tests/auto/qml/qqmllanguage/data/component.5.qml
index 9867377bb9..9867377bb9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.6.errors.txt b/tests/auto/qml/qqmllanguage/data/component.6.errors.txt
index 2b1c6ca606..2b1c6ca606 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.6.qml b/tests/auto/qml/qqmllanguage/data/component.6.qml
index 010949a35f..010949a35f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.7.errors.txt b/tests/auto/qml/qqmllanguage/data/component.7.errors.txt
index b144814a70..b144814a70 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.7.qml b/tests/auto/qml/qqmllanguage/data/component.7.qml
index b1a31195eb..b1a31195eb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.8.errors.txt b/tests/auto/qml/qqmllanguage/data/component.8.errors.txt
index 6f2d0d201d..6f2d0d201d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.8.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.8.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.8.qml b/tests/auto/qml/qqmllanguage/data/component.8.qml
index fb7a079d39..fb7a079d39 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.9.errors.txt b/tests/auto/qml/qqmllanguage/data/component.9.errors.txt
index 92f1456895..92f1456895 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.9.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/component.9.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/component.9.qml b/tests/auto/qml/qqmllanguage/data/component.9.qml
index 17824b4ede..17824b4ede 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/component.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/component.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml b/tests/auto/qml/qqmllanguage/data/componentCompositeType.qml
index 232b320fb0..232b320fb0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/componentCompositeType.qml
+++ b/tests/auto/qml/qqmllanguage/data/componentCompositeType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.2.qml b/tests/auto/qml/qqmllanguage/data/cppnamespace.2.qml
index e3b32ca5d8..e3b32ca5d8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/cppnamespace.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.qml b/tests/auto/qml/qqmllanguage/data/cppnamespace.qml
index e1daf3b78f..e1daf3b78f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/cppnamespace.qml
+++ b/tests/auto/qml/qqmllanguage/data/cppnamespace.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/crash2.qml b/tests/auto/qml/qqmllanguage/data/crash2.qml
index 2b8d285348..2b8d285348 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/crash2.qml
+++ b/tests/auto/qml/qqmllanguage/data/crash2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml b/tests/auto/qml/qqmllanguage/data/customOnProperty.qml
index 57241ffc28..57241ffc28 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/customOnProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/customOnProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.errors.txt b/tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.errors.txt
index 43a8bb28b3..43a8bb28b3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml b/tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.qml
index c42173ddfb..c42173ddfb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/customParserIdNotAllowed.qml
+++ b/tests/auto/qml/qqmllanguage/data/customParserIdNotAllowed.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml b/tests/auto/qml/qqmllanguage/data/customParserTypes.qml
index 76a8a4773f..76a8a4773f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/customParserTypes.qml
+++ b/tests/auto/qml/qqmllanguage/data/customParserTypes.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/customVariantTypes.qml b/tests/auto/qml/qqmllanguage/data/customVariantTypes.qml
index 0263ed20f2..0263ed20f2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/customVariantTypes.qml
+++ b/tests/auto/qml/qqmllanguage/data/customVariantTypes.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml b/tests/auto/qml/qqmllanguage/data/declaredPropertyValues.qml
index 03f5c1ff7e..03f5c1ff7e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/declaredPropertyValues.qml
+++ b/tests/auto/qml/qqmllanguage/data/declaredPropertyValues.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt b/tests/auto/qml/qqmllanguage/data/defaultGrouped.errors.txt
index 32055f6608..32055f6608 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/defaultGrouped.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml b/tests/auto/qml/qqmllanguage/data/defaultGrouped.qml
index 66a78eb67f..66a78eb67f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/defaultGrouped.qml
+++ b/tests/auto/qml/qqmllanguage/data/defaultGrouped.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml b/tests/auto/qml/qqmllanguage/data/defaultPropertyListOrder.qml
index 31d17fd55f..31d17fd55f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/defaultPropertyListOrder.qml
+++ b/tests/auto/qml/qqmllanguage/data/defaultPropertyListOrder.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt b/tests/auto/qml/qqmllanguage/data/destroyedSignal.errors.txt
index 3348494a8f..3348494a8f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/destroyedSignal.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml b/tests/auto/qml/qqmllanguage/data/destroyedSignal.qml
index b5b29148a2..b5b29148a2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml
+++ b/tests/auto/qml/qqmllanguage/data/destroyedSignal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.errors.txt b/tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.errors.txt
index e9b449d8d9..e9b449d8d9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.qml b/tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.qml
index 612bcfe0ea..612bcfe0ea 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/disallowedRevisionOverloads.qml
+++ b/tests/auto/qml/qqmllanguage/data/disallowedRevisionOverloads.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml b/tests/auto/qml/qqmllanguage/data/dontDoubleCallClassBegin.qml
index 905ee48e0b..905ee48e0b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dontDoubleCallClassBegin.qml
+++ b/tests/auto/qml/qqmllanguage/data/dontDoubleCallClassBegin.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt b/tests/auto/qml/qqmllanguage/data/doubleSignal.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/doubleSignal.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.qml b/tests/auto/qml/qqmllanguage/data/doubleSignal.qml
index fb07b9f659..fb07b9f659 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/doubleSignal.qml
+++ b/tests/auto/qml/qqmllanguage/data/doubleSignal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.errors.txt b/tests/auto/qml/qqmllanguage/data/duplicateIDs.errors.txt
index 66241cf1f2..66241cf1f2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/duplicateIDs.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.qml b/tests/auto/qml/qqmllanguage/data/duplicateIDs.qml
index a993abdd37..a993abdd37 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/duplicateIDs.qml
+++ b/tests/auto/qml/qqmllanguage/data/duplicateIDs.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.errors.txt b/tests/auto/qml/qqmllanguage/data/dynamicMeta.1.errors.txt
index 1f9f9169e9..1f9f9169e9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.qml b/tests/auto/qml/qqmllanguage/data/dynamicMeta.1.qml
index 3dbd5b0b2e..3dbd5b0b2e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.errors.txt b/tests/auto/qml/qqmllanguage/data/dynamicMeta.2.errors.txt
index 713d5f6272..713d5f6272 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.qml b/tests/auto/qml/qqmllanguage/data/dynamicMeta.2.qml
index 5d4efeebb2..5d4efeebb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.errors.txt b/tests/auto/qml/qqmllanguage/data/dynamicMeta.3.errors.txt
index 8226c16a1e..8226c16a1e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.qml b/tests/auto/qml/qqmllanguage/data/dynamicMeta.3.qml
index f084947eaf..f084947eaf 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.errors.txt b/tests/auto/qml/qqmllanguage/data/dynamicMeta.4.errors.txt
index 028e25c37f..028e25c37f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.qml b/tests/auto/qml/qqmllanguage/data/dynamicMeta.4.qml
index 3691529aa9..3691529aa9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.errors.txt b/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.errors.txt
index 015d55b03b..015d55b03b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.qml b/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.qml
index 64ba907415..64ba907415 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicMeta.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicMeta.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml b/tests/auto/qml/qqmllanguage/data/dynamicObject.1.qml
index 2214bacda0..2214bacda0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObject.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicObject.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml
index 6f822ba157..6f822ba157 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.qml
index 5d072b160a..5d072b160a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicObjectProperties.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml b/tests/auto/qml/qqmllanguage/data/dynamicProperties.qml
index cd403b3d46..cd403b3d46 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicProperties.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicProperties.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml b/tests/auto/qml/qqmllanguage/data/dynamicPropertiesNested.qml
index b86e89b5e7..b86e89b5e7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicPropertiesNested.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicPropertiesNested.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml b/tests/auto/qml/qqmllanguage/data/dynamicSignalsAndSlots.qml
index d80d94be09..d80d94be09 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicSignalsAndSlots.qml
+++ b/tests/auto/qml/qqmllanguage/data/dynamicSignalsAndSlots.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/empty.errors.txt b/tests/auto/qml/qqmllanguage/data/empty.errors.txt
index 620db2bbba..620db2bbba 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/empty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/empty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/empty.qml b/tests/auto/qml/qqmllanguage/data/empty.qml
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/empty.qml
+++ b/tests/auto/qml/qqmllanguage/data/empty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt b/tests/auto/qml/qqmllanguage/data/emptySignal.errors.txt
index 8b20434973..8b20434973 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/emptySignal.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml b/tests/auto/qml/qqmllanguage/data/emptySignal.qml
index c84fea3fe6..c84fea3fe6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml
+++ b/tests/auto/qml/qqmllanguage/data/emptySignal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt b/tests/auto/qml/qqmllanguage/data/enumTypes.errors.txt
index d4e0cc0bc4..d4e0cc0bc4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/enumTypes.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml b/tests/auto/qml/qqmllanguage/data/enumTypes.qml
index ff083250f0..ff083250f0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/enumTypes.qml
+++ b/tests/auto/qml/qqmllanguage/data/enumTypes.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/failingComponent.errors.txt b/tests/auto/qml/qqmllanguage/data/failingComponent.errors.txt
index 364ca6747f..364ca6747f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/failingComponent.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/failingComponent.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/failingComponentTest.qml b/tests/auto/qml/qqmllanguage/data/failingComponentTest.qml
index 74a6acfc49..74a6acfc49 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/failingComponentTest.qml
+++ b/tests/auto/qml/qqmllanguage/data/failingComponentTest.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/fakeDotProperty.errors.txt
index 30748234bc..30748234bc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/fakeDotProperty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.qml b/tests/auto/qml/qqmllanguage/data/fakeDotProperty.qml
index d971eee4d0..d971eee4d0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/fakeDotProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/fakeDotProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/finalOverride.errors.txt b/tests/auto/qml/qqmllanguage/data/finalOverride.errors.txt
index 49e06cbdf5..49e06cbdf5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/finalOverride.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/finalOverride.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/finalOverride.qml b/tests/auto/qml/qqmllanguage/data/finalOverride.qml
index a84393af94..a84393af94 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/finalOverride.qml
+++ b/tests/auto/qml/qqmllanguage/data/finalOverride.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyNames.qml b/tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyNames.qml
index 558c836e52..558c836e52 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyNames.qml
+++ b/tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyNames.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyUse.qml b/tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyUse.qml
index 74918e2764..74918e2764 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/i18nDeclaredPropertyUse.qml
+++ b/tests/auto/qml/qqmllanguage/data/i18nDeclaredPropertyUse.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/i18nNameSpace.qml b/tests/auto/qml/qqmllanguage/data/i18nNameSpace.qml
index c0b2f94857..c0b2f94857 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/i18nNameSpace.qml
+++ b/tests/auto/qml/qqmllanguage/data/i18nNameSpace.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml b/tests/auto/qml/qqmllanguage/data/i18nScript.qml
index e77cb52074..e77cb52074 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/i18nScript.qml
+++ b/tests/auto/qml/qqmllanguage/data/i18nScript.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/i18nStrings.qml b/tests/auto/qml/qqmllanguage/data/i18nStrings.qml
index 764c92639a..764c92639a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/i18nStrings.qml
+++ b/tests/auto/qml/qqmllanguage/data/i18nStrings.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/i18nType.qml b/tests/auto/qml/qqmllanguage/data/i18nType.qml
index d7954ef718..d7954ef718 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/i18nType.qml
+++ b/tests/auto/qml/qqmllanguage/data/i18nType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml b/tests/auto/qml/qqmllanguage/data/idProperty.qml
index bf048ea60a..bf048ea60a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/idProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/idProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importFile.errors.txt b/tests/auto/qml/qqmllanguage/data/importFile.errors.txt
index 3fdac0921e..3fdac0921e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importFile.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importFile.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importFile.qml b/tests/auto/qml/qqmllanguage/data/importFile.qml
index a0d8410ca3..a0d8410ca3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importFile.qml
+++ b/tests/auto/qml/qqmllanguage/data/importFile.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml b/tests/auto/qml/qqmllanguage/data/importIncorrectCase.qml
index 804e76b932..804e76b932 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml
+++ b/tests/auto/qml/qqmllanguage/data/importIncorrectCase.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.1.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.1.errors.txt
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.1.qml b/tests/auto/qml/qqmllanguage/data/importJs.1.qml
index eaba98ecd2..eaba98ecd2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.10.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.10.errors.txt
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.10.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.10.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.10.qml b/tests/auto/qml/qqmllanguage/data/importJs.10.qml
index 578ca47ea5..578ca47ea5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.10.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.10.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.2.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.2.errors.txt
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.2.qml b/tests/auto/qml/qqmllanguage/data/importJs.2.qml
index dd3d65c5dd..dd3d65c5dd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.3.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.3.errors.txt
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.3.qml b/tests/auto/qml/qqmllanguage/data/importJs.3.qml
index f59d445a56..f59d445a56 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.4.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.4.errors.txt
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.4.qml b/tests/auto/qml/qqmllanguage/data/importJs.4.qml
index e7b74bac0a..e7b74bac0a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.5.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.5.errors.txt
index 10dbc80297..10dbc80297 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.5.qml b/tests/auto/qml/qqmllanguage/data/importJs.5.qml
index a9ec20c72b..a9ec20c72b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.6.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.6.errors.txt
index 41c99702a2..41c99702a2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.6.qml b/tests/auto/qml/qqmllanguage/data/importJs.6.qml
index 6c4eb89551..6c4eb89551 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.7.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.7.errors.txt
index 56bc4c548f..56bc4c548f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.7.qml b/tests/auto/qml/qqmllanguage/data/importJs.7.qml
index 5523a158bd..5523a158bd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.8.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.8.errors.txt
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.8.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.8.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.8.qml b/tests/auto/qml/qqmllanguage/data/importJs.8.qml
index 4ddedc31a8..4ddedc31a8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.9.errors.txt b/tests/auto/qml/qqmllanguage/data/importJs.9.errors.txt
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.9.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importJs.9.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importJs.9.qml b/tests/auto/qml/qqmllanguage/data/importJs.9.qml
index 351164ba41..351164ba41 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importJs.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/importJs.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.errors.txt b/tests/auto/qml/qqmllanguage/data/importNamespaceConflict.errors.txt
index 231998daf7..231998daf7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importNamespaceConflict.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml b/tests/auto/qml/qqmllanguage/data/importNamespaceConflict.qml
index 45ad40501b..45ad40501b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importNamespaceConflict.qml
+++ b/tests/auto/qml/qqmllanguage/data/importNamespaceConflict.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNewerVersion.errors.txt b/tests/auto/qml/qqmllanguage/data/importNewerVersion.errors.txt
index 413f096384..413f096384 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importNewerVersion.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importNewerVersion.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNewerVersion.qml b/tests/auto/qml/qqmllanguage/data/importNewerVersion.qml
index c4a0d386a4..c4a0d386a4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importNewerVersion.qml
+++ b/tests/auto/qml/qqmllanguage/data/importNewerVersion.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNonExist.errors.txt b/tests/auto/qml/qqmllanguage/data/importNonExist.errors.txt
index 1baf05cee0..1baf05cee0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importNonExist.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importNonExist.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNonExist.qml b/tests/auto/qml/qqmllanguage/data/importNonExist.qml
index 5cbee0264b..5cbee0264b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importNonExist.qml
+++ b/tests/auto/qml/qqmllanguage/data/importNonExist.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.errors.txt b/tests/auto/qml/qqmllanguage/data/importNonExistOlder.errors.txt
index dfa7a369ff..dfa7a369ff 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importNonExistOlder.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.qml b/tests/auto/qml/qqmllanguage/data/importNonExistOlder.qml
index 18514b1efa..18514b1efa 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importNonExistOlder.qml
+++ b/tests/auto/qml/qqmllanguage/data/importNonExistOlder.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.errors.txt b/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.errors.txt
index c7d880e79e..c7d880e79e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.qml b/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.qml
index 23ed566e15..23ed566e15 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingBuiltIn.qml
+++ b/tests/auto/qml/qqmllanguage/data/importVersionMissingBuiltIn.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt b/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.errors.txt
index 89e58ee764..89e58ee764 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml b/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.qml
index 97ec22280f..97ec22280f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importVersionMissingInstalled.qml
+++ b/tests/auto/qml/qqmllanguage/data/importVersionMissingInstalled.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.errors.txt b/tests/auto/qml/qqmllanguage/data/importscript.1.errors.txt
index ebc936d153..ebc936d153 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/importscript.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.qml b/tests/auto/qml/qqmllanguage/data/importscript.1.qml
index 2b2ab6ba0d..2b2ab6ba0d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/importscript.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/importscript.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.insensitive.txt b/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.insensitive.txt
index 3813680562..3813680562 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.insensitive.txt
+++ b/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.insensitive.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.txt b/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.sensitive.txt
index abed1a73f5..abed1a73f5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.txt
+++ b/tests/auto/qml/qqmllanguage/data/incorrectCase.errors.sensitive.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml b/tests/auto/qml/qqmllanguage/data/incorrectCase.qml
index 15b6dc3a6e..15b6dc3a6e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml
+++ b/tests/auto/qml/qqmllanguage/data/incorrectCase.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml b/tests/auto/qml/qqmllanguage/data/incorrectCaseType.qml
index addc4265a9..addc4265a9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml
+++ b/tests/auto/qml/qqmllanguage/data/incorrectCaseType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml b/tests/auto/qml/qqmllanguage/data/inlineAssignmentsOverrideBindings.qml
index 4390d22d45..4390d22d45 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/inlineAssignmentsOverrideBindings.qml
+++ b/tests/auto/qml/qqmllanguage/data/inlineAssignmentsOverrideBindings.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml b/tests/auto/qml/qqmllanguage/data/inlineQmlComponents.qml
index a6f277adb2..a6f277adb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/inlineQmlComponents.qml
+++ b/tests/auto/qml/qqmllanguage/data/inlineQmlComponents.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.errors.txt b/tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.errors.txt
index 651009cf05..651009cf05 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.qml b/tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml
index 4e561b48b2..4e561b48b2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/insertedSemicolon.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/insertedSemicolon.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml b/tests/auto/qml/qqmllanguage/data/interfaceProperty.qml
index f85e3e4e5b..f85e3e4e5b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/interfaceProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/interfaceProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/interfaceQList.qml b/tests/auto/qml/qqmllanguage/data/interfaceQList.qml
index c87dfae785..c87dfae785 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/interfaceQList.qml
+++ b/tests/auto/qml/qqmllanguage/data/interfaceQList.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.1.errors.txt
index 9848e48579..9848e48579 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.1.qml
index 8aab61e49e..8aab61e49e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.10.errors.txt
index 93652a7042..93652a7042 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.10.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.10.qml
index 3ff7b16fd8..3ff7b16fd8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.10.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.2.errors.txt
index 3e15628a13..3e15628a13 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.2.qml
index b85b2584eb..b85b2584eb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.3.errors.txt
index fbf1b580e2..fbf1b580e2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.3.qml
index a363373734..a363373734 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.4.errors.txt
index fbf1b580e2..fbf1b580e2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.4.qml
index cfdfca0590..cfdfca0590 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.5.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.5.errors.txt
index 6f78e599d4..6f78e599d4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.5.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.5.qml
index 0c1d5d7ef1..0c1d5d7ef1 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.6.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.6.errors.txt
index 93652a7042..93652a7042 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.6.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.6.qml
index edfdb24bcc..edfdb24bcc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.7.errors.txt
index 93652a7042..93652a7042 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.7.qml
index 2a09648d57..2a09648d57 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.8.errors.txt
index 93652a7042..93652a7042 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.8.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.8.qml
index 4faa52d250..4faa52d250 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.9.errors.txt
index 93652a7042..93652a7042 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.9.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.9.qml
index f1839127b0..f1839127b0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.errors.txt
index 492bbb48fa..492bbb48fa 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.qml
index 20864b9a41..20864b9a41 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.errors.txt
index ff2409bd2d..ff2409bd2d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.qml
index 20906de606..20906de606 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.10.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.10.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.errors.txt
index fee5050743..fee5050743 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.qml
index 95add15147..95add15147 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.11.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.11.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.12.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.errors.txt
index 189a795837..189a795837 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.12.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.12.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.qml
index 7de503e766..7de503e766 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.12.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.12.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.13.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.errors.txt
index 46d7be2ac3..46d7be2ac3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.13.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.13.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.qml
index 986ab855c5..986ab855c5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.13.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.13.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.errors.txt
index 34de769e13..34de769e13 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.qml
index 050e619ff2..050e619ff2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.errors.txt
index 05161c4d10..05161c4d10 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.qml
index 24b09a53d5..24b09a53d5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.errors.txt
index a208bcfaa7..a208bcfaa7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.qml
index fb38ee9536..fb38ee9536 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.errors.txt
index 05161c4d10..05161c4d10 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.qml
index 789e42f7ef..789e42f7ef 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.errors.txt
index 6770e1f30b..6770e1f30b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.qml
index 9060a55d00..9060a55d00 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.errors.txt
index 6770e1f30b..6770e1f30b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.qml
index 47b6cc37d8..47b6cc37d8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.errors.txt
index ff2409bd2d..ff2409bd2d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.qml
index 146934f7ac..146934f7ac 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.errors.txt
index 6770e1f30b..6770e1f30b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.qml
index 73724aa6e7..73724aa6e7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAttachedProperty.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidAttachedProperty.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.errors.txt
index 810fd31b41..810fd31b41 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.qml
index fa46b8242a..fa46b8242a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.errors.txt
index 1fcb1b65f5..1fcb1b65f5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.qml
index 41aa3e2923..41aa3e2923 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.10.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.10.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.errors.txt
index 810fd31b41..810fd31b41 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.qml
index 3e516738d6..3e516738d6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.errors.txt
index f6d6f29fbf..f6d6f29fbf 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.qml
index 0bbfc4f529..0bbfc4f529 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.errors.txt
index 69c68716d9..69c68716d9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.qml
index 134fef9b0a..134fef9b0a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.errors.txt
index 2c8a970da7..2c8a970da7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.qml
index 55cefe66b9..55cefe66b9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.qml
index 9ec33abe7b..9ec33abe7b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.errors.txt
index 4a7e3830a8..4a7e3830a8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.qml
index 977539a357..977539a357 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.errors.txt
index fa0da21c55..fa0da21c55 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.qml
index 56fca9b990..56fca9b990 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.errors.txt
index 6d837a7222..6d837a7222 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.qml b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.qml
index 982ab26051..982ab26051 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidGroupedProperty.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.2.errors.txt
index 2c6b8bf0f3..2c6b8bf0f3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.qml b/tests/auto/qml/qqmllanguage/data/invalidID.2.qml
index 4fb3b298dd..4fb3b298dd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.3.errors.txt
index bb811cfe9d..bb811cfe9d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.qml b/tests/auto/qml/qqmllanguage/data/invalidID.3.qml
index 668417286b..668417286b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.4.errors.txt
index c721fe91bf..c721fe91bf 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.qml b/tests/auto/qml/qqmllanguage/data/invalidID.4.qml
index 86010bf792..86010bf792 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.5.errors.txt
index c167de382e..c167de382e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.qml b/tests/auto/qml/qqmllanguage/data/invalidID.5.qml
index 5b92a1a0eb..5b92a1a0eb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.6.errors.txt
index 7251de118f..7251de118f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.qml b/tests/auto/qml/qqmllanguage/data/invalidID.6.qml
index 62187d9473..62187d9473 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.7.errors.txt
index e4fd1db3f0..e4fd1db3f0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.qml b/tests/auto/qml/qqmllanguage/data/invalidID.7.qml
index d4bc539650..d4bc539650 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.8.errors.txt
index b03ec6ccea..b03ec6ccea 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.8.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.qml b/tests/auto/qml/qqmllanguage/data/invalidID.8.qml
index 1ea615c32e..1ea615c32e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.9.errors.txt
index c010e79492..c010e79492 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.9.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.qml b/tests/auto/qml/qqmllanguage/data/invalidID.9.qml
index 57474b7212..57474b7212 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidID.errors.txt
index c010e79492..c010e79492 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.qml b/tests/auto/qml/qqmllanguage/data/invalidID.qml
index 04db3eb67c..04db3eb67c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidID.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidID.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidImportID.errors.txt
index 034e937366..034e937366 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidImportID.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml b/tests/auto/qml/qqmllanguage/data/invalidImportID.qml
index 37e7c5d4d0..37e7c5d4d0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidImportID.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidImportID.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidOn.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidOn.errors.txt
index b4210a11fc..b4210a11fc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidOn.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidOn.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidOn.qml b/tests/auto/qml/qqmllanguage/data/invalidOn.qml
index d748bf4755..d748bf4755 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidOn.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidOn.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidProperty.errors.txt
index e9e27c479b..e9e27c479b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidProperty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml b/tests/auto/qml/qqmllanguage/data/invalidProperty.qml
index f9b322e35c..f9b322e35c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidRoot.1.errors.txt
index eff7c0e6c4..eff7c0e6c4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.qml b/tests/auto/qml/qqmllanguage/data/invalidRoot.1.qml
index 2c63c08510..2c63c08510 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidRoot.2.errors.txt
index 4bcc948e92..4bcc948e92 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.2.qml b/tests/auto/qml/qqmllanguage/data/invalidRoot.2.qml
index 427827ca89..427827ca89 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidRoot.3.errors.txt
index fdce1abf06..fdce1abf06 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.3.qml b/tests/auto/qml/qqmllanguage/data/invalidRoot.3.qml
index 65e93ed55d..65e93ed55d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidRoot.4.errors.txt
index 3b90f573a2..3b90f573a2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.4.qml b/tests/auto/qml/qqmllanguage/data/invalidRoot.4.qml
index ba4c8ae1f7..ba4c8ae1f7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidRoot.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidRoot.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.1.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidTypeName.1.errors.txt
index 4bcc948e92..4bcc948e92 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.1.qml b/tests/auto/qml/qqmllanguage/data/invalidTypeName.1.qml
index 658b72d9f2..658b72d9f2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.2.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidTypeName.2.errors.txt
index fdce1abf06..fdce1abf06 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.2.qml b/tests/auto/qml/qqmllanguage/data/invalidTypeName.2.qml
index 9c83238282..9c83238282 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.3.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidTypeName.3.errors.txt
index 208df2b84a..208df2b84a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.3.qml b/tests/auto/qml/qqmllanguage/data/invalidTypeName.3.qml
index 2f7027081e..2f7027081e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.4.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.errors.txt
index 3b90f573a2..3b90f573a2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.4.qml b/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.qml
index ba4c8ae1f7..ba4c8ae1f7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/invalidTypeName.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/invalidTypeName.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js
index c7b3c8b6ca..c7b3c8b6ca 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.1.6.js
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js
index b90033eeb4..b90033eeb4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/FirstAPI.js
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js
index b802477cb6..b802477cb6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/SecondAPI.js
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir
index 083afb051c..083afb051c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule.1.6/qmldir
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js
index b90033eeb4..b90033eeb4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/FirstAPI.js
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js
index b802477cb6..b802477cb6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/SecondAPI.js
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/qmldir b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/qmldir
index 5c3acebd39..5c3acebd39 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/PureJsModule/qmldir
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/PureJsModule/qmldir
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js
index efac613fc2..efac613fc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/SomeAPI.js
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir
index 5c1b182028..5c1b182028 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/VersionedOnlyJsModule.9.0/qmldir
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
index 56daa9c09a..56daa9c09a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml
index 59df88216e..59df88216e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/InstalledTest2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/LocalLast.qml
index 26a5d6bba9..26a5d6bba9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/LocalLast.qml
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/LocalLast.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/PrivateType.qml
index ed1b09e419..ed1b09e419 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/PrivateType.qml
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/PrivateType.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/qmldir
index d15720a154..d15720a154 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/qmldir
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest/qmldir
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml
index 56daa9c09a..56daa9c09a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml
index 59df88216e..59df88216e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/InstalledTest2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/qmldir b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/qmldir
index b301226099..b301226099 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest0/qmldir
+++ b/tests/auto/qml/qqmllanguage/data/lib/com/nokia/installedtest0/qmldir
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.errors.txt b/tests/auto/qml/qqmllanguage/data/listAssignment.1.errors.txt
index 35d2d3510e..35d2d3510e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/listAssignment.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.qml b/tests/auto/qml/qqmllanguage/data/listAssignment.1.qml
index 1af190633d..1af190633d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/listAssignment.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.errors.txt b/tests/auto/qml/qqmllanguage/data/listAssignment.2.errors.txt
index 8b40aa3ebb..8b40aa3ebb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/listAssignment.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.qml b/tests/auto/qml/qqmllanguage/data/listAssignment.2.qml
index e3baadb46c..e3baadb46c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/listAssignment.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt b/tests/auto/qml/qqmllanguage/data/listAssignment.3.errors.txt
index c721fe91bf..c721fe91bf 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/listAssignment.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.qml b/tests/auto/qml/qqmllanguage/data/listAssignment.3.qml
index 00c4c6b543..00c4c6b543 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/listAssignment.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/listAssignment.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml b/tests/auto/qml/qqmllanguage/data/listItemDeleteSelf.qml
index 74439c66d4..74439c66d4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/listItemDeleteSelf.qml
+++ b/tests/auto/qml/qqmllanguage/data/listItemDeleteSelf.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml b/tests/auto/qml/qqmllanguage/data/listProperties.qml
index dcfe37d6fc..dcfe37d6fc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/listProperties.qml
+++ b/tests/auto/qml/qqmllanguage/data/listProperties.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/majorVersionIsolation.errors.txt b/tests/auto/qml/qqmllanguage/data/majorVersionIsolation.errors.txt
index 07d05d3d21..07d05d3d21 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/majorVersionIsolation.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/majorVersionIsolation.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/majorVersionIsolation.qml b/tests/auto/qml/qqmllanguage/data/majorVersionIsolation.qml
index 717ca76f05..717ca76f05 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/majorVersionIsolation.qml
+++ b/tests/auto/qml/qqmllanguage/data/majorVersionIsolation.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.errors.txt b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.errors.txt
index 29342dc46e..29342dc46e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.qml b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.qml
index fbb37705a1..fbb37705a1 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.errors.txt b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.errors.txt
index 57b5764b08..57b5764b08 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.qml b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.qml
index 8da7a2558f..8da7a2558f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.errors.txt b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.errors.txt
index 45364a044f..45364a044f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.qml b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.qml
index 195be2116a..195be2116a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/metaobjectRevision.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/metaobjectRevision.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/method.1.errors.txt b/tests/auto/qml/qqmllanguage/data/method.1.errors.txt
index 98d0b9cefb..98d0b9cefb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/method.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/method.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/method.1.qml b/tests/auto/qml/qqmllanguage/data/method.1.qml
index a888b1aaf4..a888b1aaf4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/method.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/method.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/missingObject.errors.txt b/tests/auto/qml/qqmllanguage/data/missingObject.errors.txt
index b31b562de1..b31b562de1 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/missingObject.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/missingObject.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml b/tests/auto/qml/qqmllanguage/data/missingObject.qml
index 2f17045869..2f17045869 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/missingObject.qml
+++ b/tests/auto/qml/qqmllanguage/data/missingObject.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.errors.txt b/tests/auto/qml/qqmllanguage/data/missingSignal.errors.txt
index f562246288..f562246288 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/missingSignal.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml b/tests/auto/qml/qqmllanguage/data/missingSignal.qml
index 92aefef8c4..92aefef8c4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/missingSignal.qml
+++ b/tests/auto/qml/qqmllanguage/data/missingSignal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.errors.txt
index caf7e55ba2..caf7e55ba2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.qml b/tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.qml
index 9a0fa6a26b..9a0fa6a26b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/missingValueTypeProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/missingValueTypeProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.1.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.qml b/tests/auto/qml/qqmllanguage/data/multiSet.1.qml
index 649c49ee3a..649c49ee3a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.10.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.10.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.qml b/tests/auto/qml/qqmllanguage/data/multiSet.10.qml
index bc21db98f8..bc21db98f8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.10.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.10.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.11.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.11.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.11.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.11.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.11.qml b/tests/auto/qml/qqmllanguage/data/multiSet.11.qml
index 7d03139056..7d03139056 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.11.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.11.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.2.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.qml b/tests/auto/qml/qqmllanguage/data/multiSet.2.qml
index abcd216744..abcd216744 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.3.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.qml b/tests/auto/qml/qqmllanguage/data/multiSet.3.qml
index 77eaba0b32..77eaba0b32 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.4.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.qml b/tests/auto/qml/qqmllanguage/data/multiSet.4.qml
index c16d04fea6..c16d04fea6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.5.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.qml b/tests/auto/qml/qqmllanguage/data/multiSet.5.qml
index 2980c5b28c..2980c5b28c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.6.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.qml b/tests/auto/qml/qqmllanguage/data/multiSet.6.qml
index 492c720edc..492c720edc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.7.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.qml b/tests/auto/qml/qqmllanguage/data/multiSet.7.qml
index 2a9c1d0de8..2a9c1d0de8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.8.errors.txt
index 450fc163bd..450fc163bd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.8.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.qml b/tests/auto/qml/qqmllanguage/data/multiSet.8.qml
index 052437ea18..052437ea18 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.errors.txt b/tests/auto/qml/qqmllanguage/data/multiSet.9.errors.txt
index e1f7ec5bc2..e1f7ec5bc2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.9.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.qml b/tests/auto/qml/qqmllanguage/data/multiSet.9.qml
index e2e954f778..e2e954f778 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/multiSet.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/multiSet.9.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nestedComponentRoots.qml b/tests/auto/qml/qqmllanguage/data/nestedComponentRoots.qml
index 5e6c2a91c9..5e6c2a91c9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nestedComponentRoots.qml
+++ b/tests/auto/qml/qqmllanguage/data/nestedComponentRoots.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt b/tests/auto/qml/qqmllanguage/data/nestedErrors.errors.txt
index 53e752b641..53e752b641 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nestedErrors.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml b/tests/auto/qml/qqmllanguage/data/nestedErrors.qml
index cc1df4d181..cc1df4d181 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.qml
+++ b/tests/auto/qml/qqmllanguage/data/nestedErrors.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/noCreation.errors.txt b/tests/auto/qml/qqmllanguage/data/noCreation.errors.txt
index 23cd3f3504..23cd3f3504 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/noCreation.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/noCreation.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/noCreation.qml b/tests/auto/qml/qqmllanguage/data/noCreation.qml
index 28852f1a0c..28852f1a0c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/noCreation.qml
+++ b/tests/auto/qml/qqmllanguage/data/noCreation.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/nonScriptableProperty.errors.txt
index cdfa4b2ef2..cdfa4b2ef2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nonScriptableProperty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.qml b/tests/auto/qml/qqmllanguage/data/nonScriptableProperty.qml
index bd59bc80f9..bd59bc80f9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonScriptableProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/nonScriptableProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.errors.txt
index 6bfce9a2c9..6bfce9a2c9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.qml
index df7406ce98..df7406ce98 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.errors.txt
index 4b30056d59..4b30056d59 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.qml
index 06ccd37905..06ccd37905 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.errors.txt
index 4b30056d59..4b30056d59 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.qml
index 5b08608862..5b08608862 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.errors.txt
index 4b30056d59..4b30056d59 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.qml
index 65791919ba..65791919ba 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.errors.txt
index c07f2b99a2..c07f2b99a2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml
index 37af05731e..37af05731e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.errors.txt b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.errors.txt
index 89925b74c2..89925b74c2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.qml b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.qml
index 5cd55d0856..5cd55d0856 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nonexistantProperty.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/nonexistantProperty.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt b/tests/auto/qml/qqmllanguage/data/notAvailable.errors.txt
index af95a53cc7..af95a53cc7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/notAvailable.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml b/tests/auto/qml/qqmllanguage/data/notAvailable.qml
index 7c3c7ee08d..7c3c7ee08d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml
+++ b/tests/auto/qml/qqmllanguage/data/notAvailable.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/nullDotProperty.errors.txt
index 07a40949cd..07a40949cd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nullDotProperty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.qml b/tests/auto/qml/qqmllanguage/data/nullDotProperty.qml
index 4e36779b5c..4e36779b5c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nullDotProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/nullDotProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt
index db7d9c0f60..db7d9c0f60 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.qml b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.qml
index 99247735dd..99247735dd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/objectValueTypeProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml b/tests/auto/qml/qqmllanguage/data/onCompleted.qml
index 89e6777f8a..89e6777f8a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/onCompleted.qml
+++ b/tests/auto/qml/qqmllanguage/data/onCompleted.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml b/tests/auto/qml/qqmllanguage/data/onDestruction.qml
index 7d6da260b4..7d6da260b4 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml
+++ b/tests/auto/qml/qqmllanguage/data/onDestruction.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.1.errors.txt b/tests/auto/qml/qqmllanguage/data/property.1.errors.txt
index 3ae6c4601b..3ae6c4601b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/property.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.1.qml b/tests/auto/qml/qqmllanguage/data/property.1.qml
index 6b43e6cc89..6b43e6cc89 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/property.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.2.errors.txt b/tests/auto/qml/qqmllanguage/data/property.2.errors.txt
index a18e21a01c..a18e21a01c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/property.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.2.qml b/tests/auto/qml/qqmllanguage/data/property.2.qml
index e6aa00e730..e6aa00e730 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/property.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.3.errors.txt b/tests/auto/qml/qqmllanguage/data/property.3.errors.txt
index 5e09a25b57..5e09a25b57 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/property.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.3.qml b/tests/auto/qml/qqmllanguage/data/property.3.qml
index 978c1aa80b..978c1aa80b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/property.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.4.errors.txt b/tests/auto/qml/qqmllanguage/data/property.4.errors.txt
index b447186849..b447186849 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/property.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.4.qml b/tests/auto/qml/qqmllanguage/data/property.4.qml
index bb94e84244..bb94e84244 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/property.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.6.errors.txt b/tests/auto/qml/qqmllanguage/data/property.6.errors.txt
index 985c083cc3..985c083cc3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/property.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.6.qml b/tests/auto/qml/qqmllanguage/data/property.6.qml
index 88f493f9a9..88f493f9a9 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/property.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.7.errors.txt b/tests/auto/qml/qqmllanguage/data/property.7.errors.txt
index 985c083cc3..985c083cc3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/property.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/property.7.qml b/tests/auto/qml/qqmllanguage/data/property.7.qml
index 05eb319947..05eb319947 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/property.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/property.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/propertyInit.1.qml b/tests/auto/qml/qqmllanguage/data/propertyInit.1.qml
index 7d6fea24db..7d6fea24db 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/propertyInit.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/propertyInit.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/propertyInit.2.qml b/tests/auto/qml/qqmllanguage/data/propertyInit.2.qml
index fa690ba6bc..fa690ba6bc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/propertyInit.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/propertyInit.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml b/tests/auto/qml/qqmllanguage/data/propertyValueSource.2.qml
index e48526abec..e48526abec 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/propertyValueSource.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml b/tests/auto/qml/qqmllanguage/data/propertyValueSource.qml
index 22aa68250e..22aa68250e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/propertyValueSource.qml
+++ b/tests/auto/qml/qqmllanguage/data/propertyValueSource.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.1.qml b/tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml
index 55c507f67e..55c507f67e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.2.qml b/tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml
index db8a3da2b2..db8a3da2b2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qmlAttachedPropertiesObjectMethod.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/qmlAttachedPropertiesObjectMethod.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/LocalInternal.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/LocalInternal.qml
index 4ce04c46d2..4ce04c46d2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/LocalInternal.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/LocalInternal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/Test.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/Test.qml
index f789a905f2..f789a905f2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/Test.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/Test.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestLocal.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestLocal.qml
index 11443ca6d5..11443ca6d5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestLocal.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestLocal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestNamed.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestNamed.qml
index 672cb8f201..672cb8f201 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestNamed.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestNamed.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestSubDir.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestSubDir.qml
index 0dfede4093..0dfede4093 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/TestSubDir.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/TestSubDir.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/UndeclaredLocal.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/UndeclaredLocal.qml
index 4ce04c46d2..4ce04c46d2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/UndeclaredLocal.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/UndeclaredLocal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/WrongTestLocal.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/WrongTestLocal.qml
index 8dcb7be231..8dcb7be231 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/WrongTestLocal.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/WrongTestLocal.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/noqmldir/Test.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/noqmldir/Test.qml
index f789a905f2..f789a905f2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/noqmldir/Test.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/noqmldir/Test.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/pics/blue.png b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/pics/blue.png
index 46f815f1ed..46f815f1ed 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/pics/blue.png
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/pics/blue.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/qmldir b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/qmldir
index 60150f837c..60150f837c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/qmldir
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/qmldir
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/subdir/SubTest.qml b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/SubTest.qml
index 1480ae8683..1480ae8683 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/subdir/SubTest.qml
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/SubTest.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/subdir/qmldir b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/qmldir
index a54f7dfa61..a54f7dfa61 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/qtest/declarative/qmllanguage/subdir/qmldir
+++ b/tests/auto/qml/qqmllanguage/data/qtest/qml/qqmllanguage/subdir/qmldir
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.errors.txt b/tests/auto/qml/qqmllanguage/data/readOnly.1.errors.txt
index b8c34042be..b8c34042be 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.qml b/tests/auto/qml/qqmllanguage/data/readOnly.1.qml
index 60757bd005..60757bd005 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.errors.txt b/tests/auto/qml/qqmllanguage/data/readOnly.2.errors.txt
index d857a0440e..d857a0440e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.qml b/tests/auto/qml/qqmllanguage/data/readOnly.2.qml
index 8f1633cc11..8f1633cc11 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.errors.txt b/tests/auto/qml/qqmllanguage/data/readOnly.3.errors.txt
index c7e9e1bb2f..c7e9e1bb2f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml b/tests/auto/qml/qqmllanguage/data/readOnly.3.qml
index e3c56b701a..e3c56b701a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.4.errors.txt b/tests/auto/qml/qqmllanguage/data/readOnly.4.errors.txt
index d857a0440e..d857a0440e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.4.qml b/tests/auto/qml/qqmllanguage/data/readOnly.4.qml
index 5338ac77bc..5338ac77bc 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.errors.txt b/tests/auto/qml/qqmllanguage/data/readOnly.5.errors.txt
index e71ae4447c..e71ae4447c 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.qml b/tests/auto/qml/qqmllanguage/data/readOnly.5.qml
index d80b27a1e3..d80b27a1e3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readOnly.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/readOnly.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/readonly.qml b/tests/auto/qml/qqmllanguage/data/readonly.qml
index 493a9ad502..493a9ad502 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/readonly.qml
+++ b/tests/auto/qml/qqmllanguage/data/readonly.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/registrationOrder.qml b/tests/auto/qml/qqmllanguage/data/registrationOrder.qml
index 14217ad521..14217ad521 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/registrationOrder.qml
+++ b/tests/auto/qml/qqmllanguage/data/registrationOrder.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/remoteLoadCrash.qml b/tests/auto/qml/qqmllanguage/data/remoteLoadCrash.qml
index 5f237d39a2..5f237d39a2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/remoteLoadCrash.qml
+++ b/tests/auto/qml/qqmllanguage/data/remoteLoadCrash.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/revisions11.qml b/tests/auto/qml/qqmllanguage/data/revisions11.qml
index 823439acdd..823439acdd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/revisions11.qml
+++ b/tests/auto/qml/qqmllanguage/data/revisions11.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/revisionsbasesub11.qml b/tests/auto/qml/qqmllanguage/data/revisionsbasesub11.qml
index 78ab51a4b7..78ab51a4b7 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/revisionsbasesub11.qml
+++ b/tests/auto/qml/qqmllanguage/data/revisionsbasesub11.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/revisionssub11.qml b/tests/auto/qml/qqmllanguage/data/revisionssub11.qml
index d00758387e..d00758387e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/revisionssub11.qml
+++ b/tests/auto/qml/qqmllanguage/data/revisionssub11.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/rootAsQmlComponent.qml b/tests/auto/qml/qqmllanguage/data/rootAsQmlComponent.qml
index 8d72cd3844..8d72cd3844 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/rootAsQmlComponent.qml
+++ b/tests/auto/qml/qqmllanguage/data/rootAsQmlComponent.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.1.errors.txt b/tests/auto/qml/qqmllanguage/data/scriptString.1.errors.txt
index 14463e0941..14463e0941 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/scriptString.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.1.qml b/tests/auto/qml/qqmllanguage/data/scriptString.1.qml
index f07d2231fe..f07d2231fe 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/scriptString.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.2.errors.txt b/tests/auto/qml/qqmllanguage/data/scriptString.2.errors.txt
index f8a776f9a0..f8a776f9a0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/scriptString.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.2.qml b/tests/auto/qml/qqmllanguage/data/scriptString.2.qml
index dc825c7511..dc825c7511 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/scriptString.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.qml b/tests/auto/qml/qqmllanguage/data/scriptString.qml
index 40a3bbeede..40a3bbeede 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/scriptString.qml
+++ b/tests/auto/qml/qqmllanguage/data/scriptString.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString2.qml b/tests/auto/qml/qqmllanguage/data/scriptString2.qml
index c42da2b9e1..c42da2b9e1 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/scriptString2.qml
+++ b/tests/auto/qml/qqmllanguage/data/scriptString2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString3.qml b/tests/auto/qml/qqmllanguage/data/scriptString3.qml
index 0cd82ff58f..0cd82ff58f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/scriptString3.qml
+++ b/tests/auto/qml/qqmllanguage/data/scriptString3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString4.qml b/tests/auto/qml/qqmllanguage/data/scriptString4.qml
index 3e2f9a49f1..3e2f9a49f1 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/scriptString4.qml
+++ b/tests/auto/qml/qqmllanguage/data/scriptString4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.1.errors.txt b/tests/auto/qml/qqmllanguage/data/signal.1.errors.txt
index 78d996016a..78d996016a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/signal.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml b/tests/auto/qml/qqmllanguage/data/signal.1.qml
index 1c27baa4e8..1c27baa4e8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/signal.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.2.errors.txt b/tests/auto/qml/qqmllanguage/data/signal.2.errors.txt
index 0d4c33d750..0d4c33d750 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/signal.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml b/tests/auto/qml/qqmllanguage/data/signal.2.qml
index 2b00ab80bb..2b00ab80bb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/signal.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.3.errors.txt b/tests/auto/qml/qqmllanguage/data/signal.3.errors.txt
index bf043ac85a..bf043ac85a 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/signal.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml b/tests/auto/qml/qqmllanguage/data/signal.3.qml
index 1bfcfff7b5..1bfcfff7b5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/signal.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.4.errors.txt b/tests/auto/qml/qqmllanguage/data/signal.4.errors.txt
index 513ff60ae6..513ff60ae6 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/signal.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/signal.4.qml b/tests/auto/qml/qqmllanguage/data/signal.4.qml
index 653c14e6aa..653c14e6aa 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/signal.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/signal.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/simpleBindings.qml b/tests/auto/qml/qqmllanguage/data/simpleBindings.qml
index 2fcd1a5a4f..2fcd1a5a4f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/simpleBindings.qml
+++ b/tests/auto/qml/qqmllanguage/data/simpleBindings.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/simpleContainer.qml b/tests/auto/qml/qqmllanguage/data/simpleContainer.qml
index c3a795f536..c3a795f536 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/simpleContainer.qml
+++ b/tests/auto/qml/qqmllanguage/data/simpleContainer.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/simpleObject.qml b/tests/auto/qml/qqmllanguage/data/simpleObject.qml
index 30c78237de..30c78237de 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/simpleObject.qml
+++ b/tests/auto/qml/qqmllanguage/data/simpleObject.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.errors.txt b/tests/auto/qml/qqmllanguage/data/singularProperty.2.errors.txt
index beae562ff0..beae562ff0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/singularProperty.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml b/tests/auto/qml/qqmllanguage/data/singularProperty.2.qml
index e2760cb418..e2760cb418 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/singularProperty.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/singularProperty.errors.txt
index beae562ff0..beae562ff0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/singularProperty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml b/tests/auto/qml/qqmllanguage/data/singularProperty.qml
index ccbc6f0849..ccbc6f0849 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/singularProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml b/tests/auto/qml/qqmllanguage/data/subdir/Test.qml
index f789a905f2..f789a905f2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/subdir/Test.qml
+++ b/tests/auto/qml/qqmllanguage/data/subdir/Test.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml b/tests/auto/qml/qqmllanguage/data/subdir/subsubdir/SubTest.qml
index f789a905f2..f789a905f2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/subdir/subsubdir/SubTest.qml
+++ b/tests/auto/qml/qqmllanguage/data/subdir/subsubdir/SubTest.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/test.js b/tests/auto/qml/qqmllanguage/data/test.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/test.js
+++ b/tests/auto/qml/qqmllanguage/data/test.js
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/test2.js b/tests/auto/qml/qqmllanguage/data/test2.js
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/test2.js
+++ b/tests/auto/qml/qqmllanguage/data/test2.js
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.errors.txt b/tests/auto/qml/qqmllanguage/data/unregisteredObject.errors.txt
index 10e5fb2d96..10e5fb2d96 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/unregisteredObject.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.qml b/tests/auto/qml/qqmllanguage/data/unregisteredObject.qml
index 4969f62ad5..4969f62ad5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/unregisteredObject.qml
+++ b/tests/auto/qml/qqmllanguage/data/unregisteredObject.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/unsupportedProperty.errors.txt
index 3cd626de86..3cd626de86 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/unsupportedProperty.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.qml b/tests/auto/qml/qqmllanguage/data/unsupportedProperty.qml
index 9f19680368..9f19680368 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/unsupportedProperty.qml
+++ b/tests/auto/qml/qqmllanguage/data/unsupportedProperty.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/valueTypes.qml b/tests/auto/qml/qqmllanguage/data/valueTypes.qml
index bf325a74ee..bf325a74ee 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/valueTypes.qml
+++ b/tests/auto/qml/qqmllanguage/data/valueTypes.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/variantNotify.qml b/tests/auto/qml/qqmllanguage/data/variantNotify.qml
index 169b245450..169b245450 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/variantNotify.qml
+++ b/tests/auto/qml/qqmllanguage/data/variantNotify.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/versionedbase.qml b/tests/auto/qml/qqmllanguage/data/versionedbase.qml
index 3e8bca0368..3e8bca0368 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/versionedbase.qml
+++ b/tests/auto/qml/qqmllanguage/data/versionedbase.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.1.errors.txt
index ba7a0766b2..ba7a0766b2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.1.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.qml b/tests/auto/qml/qqmllanguage/data/wrongType.1.qml
index 289d37f050..289d37f050 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.1.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.1.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.10.errors.txt
index ae75b5289d..ae75b5289d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.10.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.qml b/tests/auto/qml/qqmllanguage/data/wrongType.10.qml
index 2cf0e50277..2cf0e50277 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.10.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.10.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.11.errors.txt
index 23a4cda4c2..23a4cda4c2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.11.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.qml b/tests/auto/qml/qqmllanguage/data/wrongType.11.qml
index ae77ba1fe8..ae77ba1fe8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.11.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.11.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.12.errors.txt
index 3092100280..3092100280 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.12.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.qml b/tests/auto/qml/qqmllanguage/data/wrongType.12.qml
index b7a366f567..b7a366f567 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.12.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.12.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.13.errors.txt
index ba7a0766b2..ba7a0766b2 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.13.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.qml b/tests/auto/qml/qqmllanguage/data/wrongType.13.qml
index 477aff1dbe..477aff1dbe 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.13.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.13.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.14.errors.txt
index d621fdd6cd..d621fdd6cd 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.14.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.qml b/tests/auto/qml/qqmllanguage/data/wrongType.14.qml
index 672d693c72..672d693c72 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.14.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.14.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.15.errors.txt
index 44768e30cb..44768e30cb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.15.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.qml b/tests/auto/qml/qqmllanguage/data/wrongType.15.qml
index 633a5ba2ba..633a5ba2ba 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.15.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.15.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.16.errors.txt
index 77cf210918..77cf210918 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.16.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.qml b/tests/auto/qml/qqmllanguage/data/wrongType.16.qml
index 973fdada24..973fdada24 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.16.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.16.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.17.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.17.errors.txt
index ef34d0ea95..ef34d0ea95 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.17.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.17.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.17.qml b/tests/auto/qml/qqmllanguage/data/wrongType.17.qml
index f678fb3136..f678fb3136 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.17.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.17.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.2.errors.txt
index 9ff9f250c0..9ff9f250c0 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.qml b/tests/auto/qml/qqmllanguage/data/wrongType.2.qml
index 34b74f7e01..34b74f7e01 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.2.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.3.errors.txt
index 6d971c6499..6d971c6499 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.3.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.qml b/tests/auto/qml/qqmllanguage/data/wrongType.3.qml
index 384181a17f..384181a17f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.3.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.3.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.4.errors.txt
index ef34d0ea95..ef34d0ea95 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.4.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.qml b/tests/auto/qml/qqmllanguage/data/wrongType.4.qml
index 0787bf5fda..0787bf5fda 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.4.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.4.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.5.errors.txt
index cab10bddb8..cab10bddb8 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.5.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.qml b/tests/auto/qml/qqmllanguage/data/wrongType.5.qml
index c50ae9a26d..c50ae9a26d 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.5.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.5.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.6.errors.txt
index d2b8c54c5b..d2b8c54c5b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.6.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.qml b/tests/auto/qml/qqmllanguage/data/wrongType.6.qml
index da10b7895f..da10b7895f 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.6.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.7.errors.txt
index 614346bd2b..614346bd2b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.7.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.qml b/tests/auto/qml/qqmllanguage/data/wrongType.7.qml
index ddc3835199..ddc3835199 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.7.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.7.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.8.errors.txt
index 1773c00825..1773c00825 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.8.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.qml b/tests/auto/qml/qqmllanguage/data/wrongType.8.qml
index a5f6756399..a5f6756399 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.8.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.8.qml
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.errors.txt b/tests/auto/qml/qqmllanguage/data/wrongType.9.errors.txt
index 8630975c57..8630975c57 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.9.errors.txt
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.qml b/tests/auto/qml/qqmllanguage/data/wrongType.9.qml
index a3db732692..a3db732692 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.9.qml
+++ b/tests/auto/qml/qqmllanguage/data/wrongType.9.qml
diff --git a/tests/auto/qml/qqmllanguage/qqmllanguage.pro b/tests/auto/qml/qqmllanguage/qqmllanguage.pro
new file mode 100644
index 0000000000..41b1d11764
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/qqmllanguage.pro
@@ -0,0 +1,18 @@
+CONFIG += testcase
+TARGET = tst_qqmllanguage
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmllanguage.cpp \
+ testtypes.cpp
+HEADERS += testtypes.h
+
+INCLUDEPATH += ../../shared/
+HEADERS += ../../shared/testhttpserver.h
+SOURCES += ../../shared/testhttpserver.cpp
+
+importFiles.files = data
+importFiles.path = .
+DEPLOYMENT += importFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private network testlib
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp
index 3c7a7c2058..3c7a7c2058 100644
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
+++ b/tests/auto/qml/qqmllanguage/testtypes.cpp
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h
new file mode 100644
index 0000000000..e9898bd039
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/testtypes.h
@@ -0,0 +1,823 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qdatetime.h>
+#include <QtGui/qmatrix.h>
+#include <QtGui/qcolor.h>
+#include <QtGui/qvector3d.h>
+#include <QtGui/qvector4d.h>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlparserstatus.h>
+#include <QtQml/qqmlpropertyvaluesource.h>
+#include <QtQml/qqmlscriptstring.h>
+#include <QtQml/qqmlproperty.h>
+
+#include <private/qqmlcustomparser_p.h>
+
+QVariant myCustomVariantTypeConverter(const QString &data);
+
+class MyInterface
+{
+public:
+ MyInterface() : id(913) {}
+ int id;
+};
+
+QT_BEGIN_NAMESPACE
+Q_DECLARE_INTERFACE(MyInterface, "com.trolltech.Qt.Test.MyInterface");
+QT_END_NAMESPACE
+QML_DECLARE_INTERFACE(MyInterface);
+
+struct MyCustomVariantType
+{
+ MyCustomVariantType() : a(0) {}
+ int a;
+};
+Q_DECLARE_METATYPE(MyCustomVariantType);
+
+class MyAttachedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
+ Q_PROPERTY(int value2 READ value2 WRITE setValue2)
+public:
+ MyAttachedObject(QObject *parent) : QObject(parent), m_value(0), m_value2(0) {}
+
+ int value() const { return m_value; }
+ void setValue(int v) { if (m_value != v) { m_value = v; emit valueChanged(); } }
+
+ int value2() const { return m_value2; }
+ void setValue2(int v) { m_value2 = v; }
+
+signals:
+ void valueChanged();
+
+private:
+ int m_value;
+ int m_value2;
+};
+
+class MyQmlObject : public QObject, public MyInterface
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue FINAL)
+ Q_PROPERTY(QString readOnlyString READ readOnlyString)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
+ Q_PROPERTY(QRect rect READ rect WRITE setRect)
+ Q_PROPERTY(QMatrix matrix READ matrix WRITE setMatrix) //assumed to be unsupported by QML
+ Q_PROPERTY(MyInterface *interfaceProperty READ interface WRITE setInterface)
+ Q_PROPERTY(int onLiteralSignal READ onLiteralSignal WRITE setOnLiteralSignal)
+ 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:
+ MyQmlObject() : m_value(-1), m_interface(0), m_qmlobject(0) { qRegisterMetaType<MyCustomVariantType>("MyCustomVariantType"); }
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; }
+
+ QString readOnlyString() const { return QLatin1String(""); }
+
+ bool enabled() const { return false; }
+ void setEnabled(bool) {}
+
+ QRect rect() const { return QRect(); }
+ void setRect(const QRect&) {}
+
+ QMatrix matrix() const { return QMatrix(); }
+ void setMatrix(const QMatrix&) {}
+
+ MyInterface *interface() const { return m_interface; }
+ void setInterface(MyInterface *iface) { m_interface = iface; }
+
+ static MyAttachedObject *qmlAttachedProperties(QObject *other) {
+ return new MyAttachedObject(other);
+ }
+ Q_CLASSINFO("DefaultMethod", "basicSlot()")
+
+ int onLiteralSignal() const { return m_value; }
+ void setOnLiteralSignal(int v) { m_value = v; }
+
+ MyQmlObject *qmlobject() const { return m_qmlobject; }
+ void setQmlobject(MyQmlObject *o) { m_qmlobject = o; }
+
+ MyCustomVariantType customType() const { return m_custom; }
+ void setCustomType(const MyCustomVariantType &v) { m_custom = v; }
+
+ 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); }
+
+signals:
+ void basicSignal();
+ void basicParameterizedSignal(int parameter);
+ void oddlyNamedNotifySignal();
+
+private:
+ friend class tst_qqmllanguage;
+ int m_value;
+ MyInterface *m_interface;
+ MyQmlObject *m_qmlobject;
+ MyCustomVariantType m_custom;
+ int m_propertyWithNotify;
+};
+QML_DECLARE_TYPE(MyQmlObject)
+QML_DECLARE_TYPEINFO(MyQmlObject, QML_HAS_ATTACHED_PROPERTIES)
+
+class MyGroupedObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlScriptString script READ script WRITE setScript)
+ Q_PROPERTY(int value READ value WRITE setValue)
+public:
+ QQmlScriptString script() const { return m_script; }
+ void setScript(const QQmlScriptString &s) { m_script = s; }
+
+ int value() const { return m_value; }
+ void setValue(int v) { m_value = v; }
+
+private:
+ int m_value;
+ QQmlScriptString m_script;
+};
+
+
+class MyTypeObject : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(MyEnum)
+ Q_FLAGS(MyFlags)
+
+ Q_PROPERTY(QString id READ id WRITE setId)
+ Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty)
+ Q_PROPERTY(QQmlComponent *componentProperty READ componentProperty WRITE setComponentProperty)
+ Q_PROPERTY(MyFlags flagProperty READ flagProperty WRITE setFlagProperty)
+ Q_PROPERTY(MyEnum enumProperty READ enumProperty WRITE setEnumProperty)
+ Q_PROPERTY(MyEnum readOnlyEnumProperty READ readOnlyEnumProperty)
+ Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
+ Q_PROPERTY(uint uintProperty READ uintProperty WRITE setUintProperty)
+ Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty)
+ Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty)
+ Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty)
+ Q_PROPERTY(float floatProperty READ floatProperty WRITE setFloatProperty)
+ Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty)
+ Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty)
+ Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty)
+ Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty)
+ Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty)
+ Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty)
+ Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty)
+ Q_PROPERTY(QSizeF sizeFProperty READ sizeFProperty WRITE setSizeFProperty)
+ Q_PROPERTY(QRect rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged)
+ Q_PROPERTY(QRect rectProperty2 READ rectProperty2 WRITE setRectProperty2)
+ Q_PROPERTY(QRectF rectFProperty READ rectFProperty WRITE setRectFProperty)
+ Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty)
+ Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty)
+ Q_PROPERTY(QVector3D vectorProperty READ vectorProperty WRITE setVectorProperty)
+ Q_PROPERTY(QVector4D vector4Property READ vector4Property WRITE setVector4Property)
+ Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty)
+
+ Q_PROPERTY(QQmlScriptString scriptProperty READ scriptProperty WRITE setScriptProperty)
+ Q_PROPERTY(MyGroupedObject *grouped READ grouped CONSTANT)
+ Q_PROPERTY(MyGroupedObject *nullGrouped READ nullGrouped CONSTANT)
+
+public:
+ MyTypeObject()
+ : objectPropertyValue(0), componentPropertyValue(0) {}
+
+ QString idValue;
+ QString id() const {
+ return idValue;
+ }
+ void setId(const QString &v) {
+ idValue = v;
+ }
+
+ QObject *objectPropertyValue;
+ QObject *objectProperty() const {
+ return objectPropertyValue;
+ }
+ void setObjectProperty(QObject *v) {
+ objectPropertyValue = v;
+ }
+
+ QQmlComponent *componentPropertyValue;
+ QQmlComponent *componentProperty() const {
+ return componentPropertyValue;
+ }
+ void setComponentProperty(QQmlComponent *v) {
+ componentPropertyValue = v;
+ }
+
+ enum MyFlag { FlagVal1 = 0x01, FlagVal2 = 0x02, FlagVal3 = 0x04 };
+ Q_DECLARE_FLAGS(MyFlags, MyFlag)
+ MyFlags flagPropertyValue;
+ MyFlags flagProperty() const {
+ return flagPropertyValue;
+ }
+ void setFlagProperty(MyFlags v) {
+ flagPropertyValue = v;
+ }
+
+ enum MyEnum { EnumVal1, EnumVal2 };
+ MyEnum enumPropertyValue;
+ MyEnum enumProperty() const {
+ return enumPropertyValue;
+ }
+ void setEnumProperty(MyEnum v) {
+ enumPropertyValue = v;
+ }
+
+ MyEnum readOnlyEnumProperty() const {
+ return EnumVal1;
+ }
+
+ QString stringPropertyValue;
+ QString stringProperty() const {
+ return stringPropertyValue;
+ }
+ void setStringProperty(const QString &v) {
+ stringPropertyValue = v;
+ }
+
+ uint uintPropertyValue;
+ uint uintProperty() const {
+ return uintPropertyValue;
+ }
+ void setUintProperty(const uint &v) {
+ uintPropertyValue = v;
+ }
+
+ int intPropertyValue;
+ int intProperty() const {
+ return intPropertyValue;
+ }
+ void setIntProperty(const int &v) {
+ intPropertyValue = v;
+ }
+
+ qreal realPropertyValue;
+ qreal realProperty() const {
+ return realPropertyValue;
+ }
+ void setRealProperty(const qreal &v) {
+ realPropertyValue = v;
+ }
+
+ double doublePropertyValue;
+ double doubleProperty() const {
+ return doublePropertyValue;
+ }
+ void setDoubleProperty(const double &v) {
+ doublePropertyValue = v;
+ }
+
+ float floatPropertyValue;
+ float floatProperty() const {
+ return floatPropertyValue;
+ }
+ void setFloatProperty(const float &v) {
+ floatPropertyValue = v;
+ }
+
+ QColor colorPropertyValue;
+ QColor colorProperty() const {
+ return colorPropertyValue;
+ }
+ void setColorProperty(const QColor &v) {
+ colorPropertyValue = v;
+ }
+
+ QDate datePropertyValue;
+ QDate dateProperty() const {
+ return datePropertyValue;
+ }
+ void setDateProperty(const QDate &v) {
+ datePropertyValue = v;
+ }
+
+ QTime timePropertyValue;
+ QTime timeProperty() const {
+ return timePropertyValue;
+ }
+ void setTimeProperty(const QTime &v) {
+ timePropertyValue = v;
+ }
+
+ QDateTime dateTimePropertyValue;
+ QDateTime dateTimeProperty() const {
+ return dateTimePropertyValue;
+ }
+ void setDateTimeProperty(const QDateTime &v) {
+ dateTimePropertyValue = v;
+ }
+
+ QPoint pointPropertyValue;
+ QPoint pointProperty() const {
+ return pointPropertyValue;
+ }
+ void setPointProperty(const QPoint &v) {
+ pointPropertyValue = v;
+ }
+
+ QPointF pointFPropertyValue;
+ QPointF pointFProperty() const {
+ return pointFPropertyValue;
+ }
+ void setPointFProperty(const QPointF &v) {
+ pointFPropertyValue = v;
+ }
+
+ QSize sizePropertyValue;
+ QSize sizeProperty() const {
+ return sizePropertyValue;
+ }
+ void setSizeProperty(const QSize &v) {
+ sizePropertyValue = v;
+ }
+
+ QSizeF sizeFPropertyValue;
+ QSizeF sizeFProperty() const {
+ return sizeFPropertyValue;
+ }
+ void setSizeFProperty(const QSizeF &v) {
+ sizeFPropertyValue = v;
+ }
+
+ QRect rectPropertyValue;
+ QRect rectProperty() const {
+ return rectPropertyValue;
+ }
+ void setRectProperty(const QRect &v) {
+ rectPropertyValue = v;
+ emit rectPropertyChanged();
+ }
+
+ QRect rectPropertyValue2;
+ QRect rectProperty2() const {
+ return rectPropertyValue2;
+ }
+ void setRectProperty2(const QRect &v) {
+ rectPropertyValue2 = v;
+ }
+
+ QRectF rectFPropertyValue;
+ QRectF rectFProperty() const {
+ return rectFPropertyValue;
+ }
+ void setRectFProperty(const QRectF &v) {
+ rectFPropertyValue = v;
+ }
+
+ bool boolPropertyValue;
+ bool boolProperty() const {
+ return boolPropertyValue;
+ }
+ void setBoolProperty(const bool &v) {
+ boolPropertyValue = v;
+ }
+
+ QVariant variantPropertyValue;
+ QVariant variantProperty() const {
+ return variantPropertyValue;
+ }
+ void setVariantProperty(const QVariant &v) {
+ variantPropertyValue = v;
+ }
+
+ QVector3D vectorPropertyValue;
+ QVector3D vectorProperty() const {
+ return vectorPropertyValue;
+ }
+ void setVectorProperty(const QVector3D &v) {
+ vectorPropertyValue = v;
+ }
+
+ QVector4D vector4PropertyValue;
+ QVector4D vector4Property() const {
+ return vector4PropertyValue;
+ }
+ void setVector4Property(const QVector4D &v) {
+ vector4PropertyValue = v;
+ }
+
+ QUrl urlPropertyValue;
+ QUrl urlProperty() const {
+ return urlPropertyValue;
+ }
+ void setUrlProperty(const QUrl &v) {
+ urlPropertyValue = v;
+ }
+
+ QQmlScriptString scriptPropertyValue;
+ QQmlScriptString scriptProperty() const {
+ return scriptPropertyValue;
+ }
+ void setScriptProperty(const QQmlScriptString &v) {
+ scriptPropertyValue = v;
+ }
+
+ MyGroupedObject groupedValue;
+ MyGroupedObject *grouped() { return &groupedValue; }
+
+ MyGroupedObject *nullGrouped() { return 0; }
+
+ void doAction() { emit action(); }
+signals:
+ void action();
+ void rectPropertyChanged();
+};
+Q_DECLARE_OPERATORS_FOR_FLAGS(MyTypeObject::MyFlags)
+
+
+class MyContainer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<QObject> children READ children)
+ Q_PROPERTY(QQmlListProperty<MyContainer> containerChildren READ containerChildren)
+ Q_PROPERTY(QQmlListProperty<MyInterface> qlistInterfaces READ qlistInterfaces)
+ Q_CLASSINFO("DefaultProperty", "children")
+public:
+ MyContainer() {}
+
+ QQmlListProperty<QObject> children() { return QQmlListProperty<QObject>(this, m_children); }
+ QQmlListProperty<MyContainer> containerChildren() { return QQmlListProperty<MyContainer>(this, m_containerChildren); }
+ QList<QObject *> *getChildren() { return &m_children; }
+ QQmlListProperty<MyInterface> qlistInterfaces() { return QQmlListProperty<MyInterface>(this, m_interfaces); }
+ QList<MyInterface *> *getQListInterfaces() { return &m_interfaces; }
+
+ QList<MyContainer*> m_containerChildren;
+ QList<QObject*> m_children;
+ QList<MyInterface *> m_interfaces;
+};
+
+
+class MyPropertyValueSource : public QObject, public QQmlPropertyValueSource
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlPropertyValueSource)
+public:
+ MyPropertyValueSource()
+ : QQmlPropertyValueSource() {}
+
+ QQmlProperty prop;
+ virtual void setTarget(const QQmlProperty &p)
+ {
+ prop = p;
+ }
+};
+
+class UnavailableType : public QObject
+{
+ Q_OBJECT
+public:
+ UnavailableType() {}
+};
+
+class MyDotPropertyObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(MyQmlObject *obj READ obj)
+ Q_PROPERTY(MyQmlObject *readWriteObj READ readWriteObj WRITE setReadWriteObj)
+public:
+ MyDotPropertyObject() : m_rwobj(0), m_ownRWObj(false) {}
+ ~MyDotPropertyObject()
+ {
+ if (m_ownRWObj)
+ delete m_rwobj;
+ }
+
+ MyQmlObject *obj() { return 0; }
+
+ MyQmlObject *readWriteObj()
+ {
+ if (!m_rwobj) {
+ m_rwobj = new MyQmlObject;
+ m_ownRWObj = true;
+ }
+ return m_rwobj;
+ }
+
+ void setReadWriteObj(MyQmlObject *obj)
+ {
+ if (m_ownRWObj) {
+ delete m_rwobj;
+ m_ownRWObj = false;
+ }
+
+ m_rwobj = obj;
+ }
+
+private:
+ MyQmlObject *m_rwobj;
+ bool m_ownRWObj;
+};
+
+
+namespace MyNamespace {
+ class MyNamespacedType : public QObject
+ {
+ Q_OBJECT
+ };
+
+ class MySecondNamespacedType : public QObject
+ {
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<MyNamespace::MyNamespacedType> list READ list)
+ public:
+ QQmlListProperty<MyNamespacedType> list() { return QQmlListProperty<MyNamespacedType>(this, m_list); }
+
+ private:
+ QList<MyNamespacedType *> m_list;
+ };
+}
+
+class MyCustomParserType : public QObject
+{
+ Q_OBJECT
+};
+
+class MyCustomParserTypeParser : public QQmlCustomParser
+{
+public:
+ QByteArray compile(const QList<QQmlCustomParserProperty> &) { return QByteArray(); }
+ void setCustomData(QObject *, const QByteArray &) {}
+};
+
+class MyParserStatus : public QObject, public QQmlParserStatus
+{
+ Q_INTERFACES(QQmlParserStatus)
+ 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;
+};
+
+class MyRevisionedBaseClassRegistered : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal propA READ propA WRITE setPropA NOTIFY propAChanged)
+ Q_PROPERTY(qreal propB READ propB WRITE setPropB NOTIFY propBChanged REVISION 1)
+
+public:
+ MyRevisionedBaseClassRegistered() : m_pa(1), m_pb(2) {}
+
+ qreal propA() const { return m_pa; }
+ void setPropA(qreal p) {
+ if (p != m_pa) {
+ m_pa = p;
+ emit propAChanged();
+ }
+ }
+ qreal propB() const { return m_pb; }
+ void setPropB(qreal p) {
+ if (p != m_pb) {
+ m_pb = p;
+ emit propBChanged();
+ }
+ }
+
+ Q_INVOKABLE void methodA() { }
+ Q_INVOKABLE Q_REVISION(1) void methodB() { }
+
+signals:
+ void propAChanged();
+ void propBChanged();
+
+ void signalA();
+ Q_REVISION(1) void signalB();
+
+protected:
+ qreal m_pa;
+ qreal m_pb;
+};
+
+class MyRevisionedIllegalOverload : public MyRevisionedBaseClassRegistered
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal propA READ propA WRITE setPropA REVISION 1);
+};
+
+class MyRevisionedLegalOverload : public MyRevisionedBaseClassRegistered
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal propB READ propB WRITE setPropB REVISION 1);
+};
+
+class MyRevisionedBaseClassUnregistered : public MyRevisionedBaseClassRegistered
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal propC READ propC WRITE setPropC NOTIFY propCChanged)
+ Q_PROPERTY(qreal propD READ propD WRITE setPropD NOTIFY propDChanged REVISION 1)
+
+public:
+ MyRevisionedBaseClassUnregistered() : m_pc(1), m_pd(2) {}
+
+ qreal propC() const { return m_pc; }
+ void setPropC(qreal p) {
+ if (p != m_pc) {
+ m_pc = p;
+ emit propCChanged();
+ }
+ }
+ qreal propD() const { return m_pd; }
+ void setPropD(qreal p) {
+ if (p != m_pd) {
+ m_pd = p;
+ emit propDChanged();
+ }
+ }
+
+ Q_INVOKABLE void methodC() { }
+ Q_INVOKABLE Q_REVISION(1) void methodD() { }
+
+signals:
+ void propCChanged();
+ void propDChanged();
+
+ void signalC();
+ Q_REVISION(1) void signalD();
+
+protected:
+ qreal m_pc;
+ qreal m_pd;
+};
+
+class MyRevisionedClass : public MyRevisionedBaseClassUnregistered
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal prop1 READ prop1 WRITE setProp1 NOTIFY prop1Changed)
+ Q_PROPERTY(qreal prop2 READ prop2 WRITE setProp2 NOTIFY prop2Changed REVISION 1)
+
+public:
+ MyRevisionedClass() : m_p1(1), m_p2(2) {}
+
+ qreal prop1() const { return m_p1; }
+ void setProp1(qreal p) {
+ if (p != m_p1) {
+ m_p1 = p;
+ emit prop1Changed();
+ }
+ }
+ qreal prop2() const { return m_p2; }
+ void setProp2(qreal p) {
+ if (p != m_p2) {
+ m_p2 = p;
+ emit prop2Changed();
+ }
+ }
+
+ Q_INVOKABLE void method1() { }
+ Q_INVOKABLE Q_REVISION(1) void method2() { }
+
+signals:
+ void prop1Changed();
+ void prop2Changed();
+
+ void signal1();
+ Q_REVISION(1) void signal2();
+
+protected:
+ qreal m_p1;
+ qreal m_p2;
+};
+
+class MyRevisionedSubclass : public MyRevisionedClass
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal prop3 READ prop3 WRITE setProp3 NOTIFY prop3Changed)
+ Q_PROPERTY(qreal prop4 READ prop4 WRITE setProp4 NOTIFY prop4Changed REVISION 1)
+
+public:
+ MyRevisionedSubclass() : m_p3(3), m_p4(4) {}
+
+ qreal prop3() const { return m_p3; }
+ void setProp3(qreal p) {
+ if (p != m_p3) {
+ m_p3 = p;
+ emit prop3Changed();
+ }
+ }
+ qreal prop4() const { return m_p4; }
+ void setProp4(qreal p) {
+ if (p != m_p4) {
+ m_p4 = p;
+ emit prop4Changed();
+ }
+ }
+
+ Q_INVOKABLE void method3() { }
+ Q_INVOKABLE Q_REVISION(1) void method4() { }
+
+signals:
+ void prop3Changed();
+ void prop4Changed();
+
+ void signal3();
+ Q_REVISION(1) void signal4();
+
+protected:
+ qreal m_p3;
+ qreal m_p4;
+};
+
+class MySubclass : public MyRevisionedClass
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal prop5 READ prop5 WRITE setProp5 NOTIFY prop5Changed)
+
+public:
+ MySubclass() : m_p5(5) {}
+
+ qreal prop5() const { return m_p5; }
+ void setProp5(qreal p) {
+ if (p != m_p5) {
+ m_p5 = p;
+ emit prop5Changed();
+ }
+ }
+
+ Q_INVOKABLE void method5() { }
+
+signals:
+ void prop5Changed();
+
+protected:
+ qreal m_p5;
+};
+
+class MyVersion2Class : public QObject
+{
+ Q_OBJECT
+};
+
+QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered)
+QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered)
+QML_DECLARE_TYPE(MyRevisionedClass)
+QML_DECLARE_TYPE(MyRevisionedSubclass)
+QML_DECLARE_TYPE(MySubclass)
+
+
+
+void registerTypes();
+
+#endif // TESTTYPES_H
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
new file mode 100644
index 0000000000..379c32d4b8
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -0,0 +1,2289 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qdir.h>
+
+#include <private/qqmlproperty_p.h>
+#include <private/qqmlmetatype_p.h>
+#include <private/qqmlglobal_p.h>
+
+#include "testtypes.h"
+#include "testhttpserver.h"
+
+DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES)
+
+/*
+ Returns the path to some testdata file or directory.
+*/
+QString testdata(QString const& name = QString())
+{
+ static const QString dataDirectory = QDir::currentPath() + QLatin1String("/data");
+ QString result = dataDirectory;
+ if (!name.isEmpty()) {
+ result += QLatin1Char('/');
+ result += name;
+ }
+ return result;
+}
+
+/*
+This test case covers QML language issues. This covers everything that does not
+involve evaluating ECMAScript expressions and bindings.
+
+Evaluation of expressions and bindings is covered in qmlecmascript
+*/
+class tst_qqmllanguage : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmllanguage() {
+ QQmlMetaType::registerCustomStringConverter(qMetaTypeId<MyCustomVariantType>(), myCustomVariantTypeConverter);
+ engine.addImportPath(testdata("lib"));
+ }
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void errors_data();
+ void errors();
+
+ void insertedSemicolon_data();
+ void insertedSemicolon();
+
+ void simpleObject();
+ void simpleContainer();
+ void interfaceProperty();
+ void interfaceQList();
+ void assignObjectToSignal();
+ void assignObjectToVariant();
+ void assignLiteralSignalProperty();
+ void assignQmlComponent();
+ void assignBasicTypes();
+ void assignTypeExtremes();
+ void assignCompositeToType();
+ void assignLiteralToVariant();
+ void assignLiteralToVar();
+ void customParserTypes();
+ void rootAsQmlComponent();
+ void inlineQmlComponents();
+ void idProperty();
+ void autoNotifyConnection();
+ void assignSignal();
+ void dynamicProperties();
+ void dynamicPropertiesNested();
+ void listProperties();
+ void dynamicObjectProperties();
+ void dynamicSignalsAndSlots();
+ void simpleBindings();
+ void autoComponentCreation();
+ void propertyValueSource();
+ void attachedProperties();
+ void dynamicObjects();
+ void customVariantTypes();
+ void valueTypes();
+ void cppnamespace();
+ void aliasProperties();
+ void aliasPropertiesAndSignals();
+ void aliasPropertyChangeSignals();
+ void componentCompositeType();
+ void i18n();
+ void i18n_data();
+ void onCompleted();
+ void onDestruction();
+ void scriptString();
+ void defaultPropertyListOrder();
+ void declaredPropertyValues();
+ void dontDoubleCallClassBegin();
+ void reservedWords_data();
+ void reservedWords();
+ void inlineAssignmentsOverrideBindings();
+ void nestedComponentRoots();
+ void registrationOrder();
+ void readonly();
+
+ void basicRemote_data();
+ void basicRemote();
+ void importsBuiltin_data();
+ void importsBuiltin();
+ void importsLocal_data();
+ void importsLocal();
+ void importsRemote_data();
+ void importsRemote();
+ void importsInstalled_data();
+ void importsInstalled();
+ void importsOrder_data();
+ void importsOrder();
+ void importIncorrectCase();
+ void importJs_data();
+ void importJs();
+
+ void qmlAttachedPropertiesObjectMethod();
+ void customOnProperty();
+ void variantNotify();
+
+ void revisions();
+ void revisionOverloads();
+
+ void propertyInit();
+ void remoteLoadCrash();
+
+ // regression tests for crashes
+ void crash1();
+ void crash2();
+
+private:
+ QQmlEngine engine;
+ void testType(const QString& qml, const QString& type, const QString& error);
+};
+
+#define DETERMINE_ERRORS(errorfile,expected,actual)\
+ QList<QByteArray> expected; \
+ QList<QByteArray> actual; \
+ do { \
+ QFile file(testdata(QLatin1String(errorfile))); \
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \
+ QByteArray data = file.readAll(); \
+ file.close(); \
+ expected = data.split('\n'); \
+ expected.removeAll(QByteArray("")); \
+ QList<QQmlError> errors = component.errors(); \
+ for (int ii = 0; ii < errors.count(); ++ii) { \
+ const QQmlError &error = errors.at(ii); \
+ QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
+ QByteArray::number(error.column()) + ":" + \
+ error.description().toUtf8(); \
+ actual << errorStr; \
+ } \
+ } while (false);
+
+#define VERIFY_ERRORS(errorfile) \
+ if (!errorfile) { \
+ if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
+ qWarning() << "Unexpected Errors:" << component.errors(); \
+ QVERIFY(!component.isError()); \
+ QVERIFY(component.errors().isEmpty()); \
+ } else { \
+ DETERMINE_ERRORS(errorfile,actual,expected);\
+ if (qgetenv("DEBUG") != "" && expected != actual) \
+ qWarning() << "Expected:" << expected << "Actual:" << actual; \
+ if (qgetenv("QDECLARATIVELANGUAGE_UPDATEERRORS") != "" && expected != actual) {\
+ QFile file(QLatin1String("data/") + QLatin1String(errorfile)); \
+ QVERIFY(file.open(QIODevice::WriteOnly)); \
+ for (int ii = 0; ii < actual.count(); ++ii) { \
+ file.write(actual.at(ii)); file.write("\n"); \
+ } \
+ file.close(); \
+ } else { \
+ QCOMPARE(expected, actual); \
+ } \
+ }
+
+inline QUrl TEST_FILE(const QString &filename)
+{
+ return QUrl::fromLocalFile(testdata(filename));
+}
+
+inline QUrl TEST_FILE(const char *filename)
+{
+ return TEST_FILE(QLatin1String(filename));
+}
+
+void tst_qqmllanguage::cleanupTestCase()
+{
+ QVERIFY(QFile::remove(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile()));
+}
+
+void tst_qqmllanguage::insertedSemicolon_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("errorFile");
+ QTest::addColumn<bool>("create");
+
+ QTest::newRow("insertedSemicolon.1") << "insertedSemicolon.1.qml" << "insertedSemicolon.1.errors.txt" << false;
+}
+
+void tst_qqmllanguage::insertedSemicolon()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, errorFile);
+ QFETCH(bool, create);
+
+ QQmlComponent component(&engine, TEST_FILE(file));
+
+ if(create) {
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+ }
+
+ VERIFY_ERRORS(errorFile.toLatin1().constData());
+}
+
+void tst_qqmllanguage::errors_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("errorFile");
+ QTest::addColumn<bool>("create");
+
+ QTest::newRow("nonexistantProperty.1") << "nonexistantProperty.1.qml" << "nonexistantProperty.1.errors.txt" << false;
+ QTest::newRow("nonexistantProperty.2") << "nonexistantProperty.2.qml" << "nonexistantProperty.2.errors.txt" << false;
+ QTest::newRow("nonexistantProperty.3") << "nonexistantProperty.3.qml" << "nonexistantProperty.3.errors.txt" << false;
+ QTest::newRow("nonexistantProperty.4") << "nonexistantProperty.4.qml" << "nonexistantProperty.4.errors.txt" << false;
+ QTest::newRow("nonexistantProperty.5") << "nonexistantProperty.5.qml" << "nonexistantProperty.5.errors.txt" << false;
+ QTest::newRow("nonexistantProperty.6") << "nonexistantProperty.6.qml" << "nonexistantProperty.6.errors.txt" << false;
+
+ QTest::newRow("wrongType (string for int)") << "wrongType.1.qml" << "wrongType.1.errors.txt" << false;
+ QTest::newRow("wrongType (int for bool)") << "wrongType.2.qml" << "wrongType.2.errors.txt" << false;
+ QTest::newRow("wrongType (bad rect)") << "wrongType.3.qml" << "wrongType.3.errors.txt" << false;
+
+ QTest::newRow("wrongType (invalid enum)") << "wrongType.4.qml" << "wrongType.4.errors.txt" << false;
+ QTest::newRow("wrongType (int for uint)") << "wrongType.5.qml" << "wrongType.5.errors.txt" << false;
+ QTest::newRow("wrongType (string for real)") << "wrongType.6.qml" << "wrongType.6.errors.txt" << false;
+ QTest::newRow("wrongType (int for color)") << "wrongType.7.qml" << "wrongType.7.errors.txt" << false;
+ QTest::newRow("wrongType (int for date)") << "wrongType.8.qml" << "wrongType.8.errors.txt" << false;
+ QTest::newRow("wrongType (int for time)") << "wrongType.9.qml" << "wrongType.9.errors.txt" << false;
+ QTest::newRow("wrongType (int for datetime)") << "wrongType.10.qml" << "wrongType.10.errors.txt" << false;
+ QTest::newRow("wrongType (string for point)") << "wrongType.11.qml" << "wrongType.11.errors.txt" << false;
+ QTest::newRow("wrongType (color for size)") << "wrongType.12.qml" << "wrongType.12.errors.txt" << false;
+ QTest::newRow("wrongType (number string for int)") << "wrongType.13.qml" << "wrongType.13.errors.txt" << false;
+ QTest::newRow("wrongType (int for string)") << "wrongType.14.qml" << "wrongType.14.errors.txt" << false;
+ QTest::newRow("wrongType (int for url)") << "wrongType.15.qml" << "wrongType.15.errors.txt" << false;
+ QTest::newRow("wrongType (invalid object)") << "wrongType.16.qml" << "wrongType.16.errors.txt" << false;
+ QTest::newRow("wrongType (int for enum)") << "wrongType.17.qml" << "wrongType.17.errors.txt" << false;
+
+ QTest::newRow("readOnly.1") << "readOnly.1.qml" << "readOnly.1.errors.txt" << false;
+ QTest::newRow("readOnly.2") << "readOnly.2.qml" << "readOnly.2.errors.txt" << false;
+ QTest::newRow("readOnly.3") << "readOnly.3.qml" << "readOnly.3.errors.txt" << false;
+ QTest::newRow("readOnly.4") << "readOnly.4.qml" << "readOnly.4.errors.txt" << false;
+ QTest::newRow("readOnly.5") << "readOnly.5.qml" << "readOnly.5.errors.txt" << false;
+
+ QTest::newRow("listAssignment.1") << "listAssignment.1.qml" << "listAssignment.1.errors.txt" << false;
+ QTest::newRow("listAssignment.2") << "listAssignment.2.qml" << "listAssignment.2.errors.txt" << false;
+ QTest::newRow("listAssignment.3") << "listAssignment.3.qml" << "listAssignment.3.errors.txt" << false;
+
+ QTest::newRow("invalidID.1") << "invalidID.qml" << "invalidID.errors.txt" << false;
+ QTest::newRow("invalidID.2") << "invalidID.2.qml" << "invalidID.2.errors.txt" << false;
+ QTest::newRow("invalidID.3") << "invalidID.3.qml" << "invalidID.3.errors.txt" << false;
+ QTest::newRow("invalidID.4") << "invalidID.4.qml" << "invalidID.4.errors.txt" << false;
+ QTest::newRow("invalidID.5") << "invalidID.5.qml" << "invalidID.5.errors.txt" << false;
+ QTest::newRow("invalidID.6") << "invalidID.6.qml" << "invalidID.6.errors.txt" << false;
+ QTest::newRow("invalidID.7") << "invalidID.7.qml" << "invalidID.7.errors.txt" << false;
+ QTest::newRow("invalidID.8") << "invalidID.8.qml" << "invalidID.8.errors.txt" << false;
+ QTest::newRow("invalidID.9") << "invalidID.9.qml" << "invalidID.9.errors.txt" << false;
+
+ QTest::newRow("scriptString.1") << "scriptString.1.qml" << "scriptString.1.errors.txt" << false;
+ QTest::newRow("scriptString.2") << "scriptString.2.qml" << "scriptString.2.errors.txt" << false;
+
+ QTest::newRow("unsupportedProperty") << "unsupportedProperty.qml" << "unsupportedProperty.errors.txt" << false;
+ QTest::newRow("nullDotProperty") << "nullDotProperty.qml" << "nullDotProperty.errors.txt" << true;
+ QTest::newRow("fakeDotProperty") << "fakeDotProperty.qml" << "fakeDotProperty.errors.txt" << false;
+ QTest::newRow("duplicateIDs") << "duplicateIDs.qml" << "duplicateIDs.errors.txt" << false;
+ QTest::newRow("unregisteredObject") << "unregisteredObject.qml" << "unregisteredObject.errors.txt" << false;
+ QTest::newRow("empty") << "empty.qml" << "empty.errors.txt" << false;
+ QTest::newRow("missingObject") << "missingObject.qml" << "missingObject.errors.txt" << false;
+ QTest::newRow("failingComponent") << "failingComponentTest.qml" << "failingComponent.errors.txt" << false;
+ QTest::newRow("missingSignal") << "missingSignal.qml" << "missingSignal.errors.txt" << false;
+ QTest::newRow("finalOverride") << "finalOverride.qml" << "finalOverride.errors.txt" << false;
+ QTest::newRow("customParserIdNotAllowed") << "customParserIdNotAllowed.qml" << "customParserIdNotAllowed.errors.txt" << false;
+
+ QTest::newRow("invalidGroupedProperty.1") << "invalidGroupedProperty.1.qml" << "invalidGroupedProperty.1.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.2") << "invalidGroupedProperty.2.qml" << "invalidGroupedProperty.2.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.3") << "invalidGroupedProperty.3.qml" << "invalidGroupedProperty.3.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.4") << "invalidGroupedProperty.4.qml" << "invalidGroupedProperty.4.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.5") << "invalidGroupedProperty.5.qml" << "invalidGroupedProperty.5.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.6") << "invalidGroupedProperty.6.qml" << "invalidGroupedProperty.6.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.7") << "invalidGroupedProperty.7.qml" << "invalidGroupedProperty.7.errors.txt" << true;
+ QTest::newRow("invalidGroupedProperty.8") << "invalidGroupedProperty.8.qml" << "invalidGroupedProperty.8.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.9") << "invalidGroupedProperty.9.qml" << "invalidGroupedProperty.9.errors.txt" << false;
+ QTest::newRow("invalidGroupedProperty.10") << "invalidGroupedProperty.10.qml" << "invalidGroupedProperty.10.errors.txt" << false;
+
+ QTest::newRow("importNamespaceConflict") << "importNamespaceConflict.qml" << "importNamespaceConflict.errors.txt" << false;
+ QTest::newRow("importVersionMissing (builtin)") << "importVersionMissingBuiltIn.qml" << "importVersionMissingBuiltIn.errors.txt" << false;
+ QTest::newRow("importVersionMissing (installed)") << "importVersionMissingInstalled.qml" << "importVersionMissingInstalled.errors.txt" << false;
+ QTest::newRow("importNonExist (installed)") << "importNonExist.qml" << "importNonExist.errors.txt" << false;
+ QTest::newRow("importNonExistOlder (installed)") << "importNonExistOlder.qml" << "importNonExistOlder.errors.txt" << false;
+ QTest::newRow("importNewerVersion (installed)") << "importNewerVersion.qml" << "importNewerVersion.errors.txt" << false;
+ QTest::newRow("invalidImportID") << "invalidImportID.qml" << "invalidImportID.errors.txt" << false;
+ QTest::newRow("importFile") << "importFile.qml" << "importFile.errors.txt" << false;
+
+ QTest::newRow("signal.1") << "signal.1.qml" << "signal.1.errors.txt" << false;
+ QTest::newRow("signal.2") << "signal.2.qml" << "signal.2.errors.txt" << false;
+ QTest::newRow("signal.3") << "signal.3.qml" << "signal.3.errors.txt" << false;
+ QTest::newRow("signal.4") << "signal.4.qml" << "signal.4.errors.txt" << false;
+
+ QTest::newRow("method.1") << "method.1.qml" << "method.1.errors.txt" << false;
+
+ QTest::newRow("property.1") << "property.1.qml" << "property.1.errors.txt" << false;
+ QTest::newRow("property.2") << "property.2.qml" << "property.2.errors.txt" << false;
+ QTest::newRow("property.3") << "property.3.qml" << "property.3.errors.txt" << false;
+ QTest::newRow("property.4") << "property.4.qml" << "property.4.errors.txt" << false;
+ QTest::newRow("property.6") << "property.6.qml" << "property.6.errors.txt" << false;
+ QTest::newRow("property.7") << "property.7.qml" << "property.7.errors.txt" << false;
+
+ QTest::newRow("importScript.1") << "importscript.1.qml" << "importscript.1.errors.txt" << false;
+
+ QTest::newRow("Component.1") << "component.1.qml" << "component.1.errors.txt" << false;
+ QTest::newRow("Component.2") << "component.2.qml" << "component.2.errors.txt" << false;
+ QTest::newRow("Component.3") << "component.3.qml" << "component.3.errors.txt" << false;
+ QTest::newRow("Component.4") << "component.4.qml" << "component.4.errors.txt" << false;
+ QTest::newRow("Component.5") << "component.5.qml" << "component.5.errors.txt" << false;
+ QTest::newRow("Component.6") << "component.6.qml" << "component.6.errors.txt" << false;
+ QTest::newRow("Component.7") << "component.7.qml" << "component.7.errors.txt" << false;
+ QTest::newRow("Component.8") << "component.8.qml" << "component.8.errors.txt" << false;
+ QTest::newRow("Component.9") << "component.9.qml" << "component.9.errors.txt" << false;
+
+ QTest::newRow("MultiSet.1") << "multiSet.1.qml" << "multiSet.1.errors.txt" << false;
+ QTest::newRow("MultiSet.2") << "multiSet.2.qml" << "multiSet.2.errors.txt" << false;
+ QTest::newRow("MultiSet.3") << "multiSet.3.qml" << "multiSet.3.errors.txt" << false;
+ QTest::newRow("MultiSet.4") << "multiSet.4.qml" << "multiSet.4.errors.txt" << false;
+ QTest::newRow("MultiSet.5") << "multiSet.5.qml" << "multiSet.5.errors.txt" << false;
+ QTest::newRow("MultiSet.6") << "multiSet.6.qml" << "multiSet.6.errors.txt" << false;
+ QTest::newRow("MultiSet.7") << "multiSet.7.qml" << "multiSet.7.errors.txt" << false;
+ QTest::newRow("MultiSet.8") << "multiSet.8.qml" << "multiSet.8.errors.txt" << false;
+ QTest::newRow("MultiSet.9") << "multiSet.9.qml" << "multiSet.9.errors.txt" << false;
+ QTest::newRow("MultiSet.10") << "multiSet.10.qml" << "multiSet.10.errors.txt" << false;
+ QTest::newRow("MultiSet.11") << "multiSet.11.qml" << "multiSet.11.errors.txt" << false;
+
+ QTest::newRow("dynamicMeta.1") << "dynamicMeta.1.qml" << "dynamicMeta.1.errors.txt" << false;
+ QTest::newRow("dynamicMeta.2") << "dynamicMeta.2.qml" << "dynamicMeta.2.errors.txt" << false;
+ QTest::newRow("dynamicMeta.3") << "dynamicMeta.3.qml" << "dynamicMeta.3.errors.txt" << false;
+ QTest::newRow("dynamicMeta.4") << "dynamicMeta.4.qml" << "dynamicMeta.4.errors.txt" << false;
+ QTest::newRow("dynamicMeta.5") << "dynamicMeta.5.qml" << "dynamicMeta.5.errors.txt" << false;
+
+ QTest::newRow("invalidAlias.1") << "invalidAlias.1.qml" << "invalidAlias.1.errors.txt" << false;
+ QTest::newRow("invalidAlias.2") << "invalidAlias.2.qml" << "invalidAlias.2.errors.txt" << false;
+ QTest::newRow("invalidAlias.3") << "invalidAlias.3.qml" << "invalidAlias.3.errors.txt" << false;
+ 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("invalidAlias.8") << "invalidAlias.8.qml" << "invalidAlias.8.errors.txt" << false;
+ QTest::newRow("invalidAlias.9") << "invalidAlias.9.qml" << "invalidAlias.9.errors.txt" << false;
+ QTest::newRow("invalidAlias.10") << "invalidAlias.10.qml" << "invalidAlias.10.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;
+ QTest::newRow("invalidAttachedProperty.3") << "invalidAttachedProperty.3.qml" << "invalidAttachedProperty.3.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.4") << "invalidAttachedProperty.4.qml" << "invalidAttachedProperty.4.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.5") << "invalidAttachedProperty.5.qml" << "invalidAttachedProperty.5.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.6") << "invalidAttachedProperty.6.qml" << "invalidAttachedProperty.6.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.7") << "invalidAttachedProperty.7.qml" << "invalidAttachedProperty.7.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.8") << "invalidAttachedProperty.8.qml" << "invalidAttachedProperty.8.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.9") << "invalidAttachedProperty.9.qml" << "invalidAttachedProperty.9.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.10") << "invalidAttachedProperty.10.qml" << "invalidAttachedProperty.10.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.11") << "invalidAttachedProperty.11.qml" << "invalidAttachedProperty.11.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.12") << "invalidAttachedProperty.12.qml" << "invalidAttachedProperty.12.errors.txt" << false;
+ QTest::newRow("invalidAttachedProperty.13") << "invalidAttachedProperty.13.qml" << "invalidAttachedProperty.13.errors.txt" << false;
+
+ QTest::newRow("assignValueToSignal") << "assignValueToSignal.qml" << "assignValueToSignal.errors.txt" << false;
+ QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false;
+
+ QTest::newRow("nestedErrors") << "nestedErrors.qml" << "nestedErrors.errors.txt" << false;
+ QTest::newRow("defaultGrouped") << "defaultGrouped.qml" << "defaultGrouped.errors.txt" << false;
+ QTest::newRow("doubleSignal") << "doubleSignal.qml" << "doubleSignal.errors.txt" << false;
+ QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false;
+ QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false;
+ QTest::newRow("enumTypes") << "enumTypes.qml" << "enumTypes.errors.txt" << false;
+ QTest::newRow("noCreation") << "noCreation.qml" << "noCreation.errors.txt" << false;
+ QTest::newRow("destroyedSignal") << "destroyedSignal.qml" << "destroyedSignal.errors.txt" << false;
+ 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;
+ QTest::newRow("notAvailable") << "notAvailable.qml" << "notAvailable.errors.txt" << false;
+ QTest::newRow("singularProperty") << "singularProperty.qml" << "singularProperty.errors.txt" << false;
+ QTest::newRow("singularProperty.2") << "singularProperty.2.qml" << "singularProperty.2.errors.txt" << false;
+ QTest::newRow("incorrectCase") << "incorrectCase.qml"
+#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
+ << "incorrectCase.errors.insensitive.txt"
+#else
+ << "incorrectCase.errors.sensitive.txt"
+#endif
+ << false;
+
+ QTest::newRow("metaobjectRevision.1") << "metaobjectRevision.1.qml" << "metaobjectRevision.1.errors.txt" << false;
+ QTest::newRow("metaobjectRevision.2") << "metaobjectRevision.2.qml" << "metaobjectRevision.2.errors.txt" << false;
+ QTest::newRow("metaobjectRevision.3") << "metaobjectRevision.3.qml" << "metaobjectRevision.3.errors.txt" << false;
+
+ QTest::newRow("invalidRoot.1") << "invalidRoot.1.qml" << "invalidRoot.1.errors.txt" << false;
+ QTest::newRow("invalidRoot.2") << "invalidRoot.2.qml" << "invalidRoot.2.errors.txt" << false;
+ QTest::newRow("invalidRoot.3") << "invalidRoot.3.qml" << "invalidRoot.3.errors.txt" << false;
+ QTest::newRow("invalidRoot.4") << "invalidRoot.4.qml" << "invalidRoot.4.errors.txt" << false;
+
+ QTest::newRow("invalidTypeName.1") << "invalidTypeName.1.qml" << "invalidTypeName.1.errors.txt" << false;
+ QTest::newRow("invalidTypeName.2") << "invalidTypeName.2.qml" << "invalidTypeName.2.errors.txt" << false;
+ QTest::newRow("invalidTypeName.3") << "invalidTypeName.3.qml" << "invalidTypeName.3.errors.txt" << false;
+ QTest::newRow("invalidTypeName.4") << "invalidTypeName.4.qml" << "invalidTypeName.4.errors.txt" << false;
+
+ QTest::newRow("Major version isolation") << "majorVersionIsolation.qml" << "majorVersionIsolation.errors.txt" << false;
+}
+
+
+void tst_qqmllanguage::errors()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, errorFile);
+ QFETCH(bool, create);
+
+ QQmlComponent component(&engine, TEST_FILE(file));
+
+ if(create) {
+ QObject *object = component.create();
+ QVERIFY(object == 0);
+ }
+
+ VERIFY_ERRORS(errorFile.toLatin1().constData());
+}
+
+void tst_qqmllanguage::simpleObject()
+{
+ QQmlComponent component(&engine, TEST_FILE("simpleObject.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+void tst_qqmllanguage::simpleContainer()
+{
+ QQmlComponent component(&engine, TEST_FILE("simpleContainer.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *container= qobject_cast<MyContainer*>(component.create());
+ QVERIFY(container != 0);
+ QCOMPARE(container->getChildren()->count(),2);
+}
+
+void tst_qqmllanguage::interfaceProperty()
+{
+ QQmlComponent component(&engine, TEST_FILE("interfaceProperty.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->interface());
+ QVERIFY(object->interface()->id == 913);
+}
+
+void tst_qqmllanguage::interfaceQList()
+{
+ QQmlComponent component(&engine, TEST_FILE("interfaceQList.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *container= qobject_cast<MyContainer*>(component.create());
+ QVERIFY(container != 0);
+ QVERIFY(container->getQListInterfaces()->count() == 2);
+ for(int ii = 0; ii < 2; ++ii)
+ QVERIFY(container->getQListInterfaces()->at(ii)->id == 913);
+}
+
+void tst_qqmllanguage::assignObjectToSignal()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignObjectToSignal.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
+ emit object->basicSignal();
+}
+
+void tst_qqmllanguage::assignObjectToVariant()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignObjectToVariant.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QVariant v = object->property("a");
+ QVERIFY(v.userType() == qMetaTypeId<QObject *>());
+}
+
+void tst_qqmllanguage::assignLiteralSignalProperty()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignLiteralSignalProperty.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->onLiteralSignal(), 10);
+}
+
+// Test is an external component can be loaded and assigned (to a qlist)
+void tst_qqmllanguage::assignQmlComponent()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignQmlComponent.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *object = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->getChildren()->count() == 1);
+ QObject *child = object->getChildren()->at(0);
+ QCOMPARE(child->property("x"), QVariant(10));
+ QCOMPARE(child->property("y"), QVariant(11));
+}
+
+// Test literal assignment to all the basic types
+void tst_qqmllanguage::assignBasicTypes()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignBasicTypes.qml"));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
+ QCOMPARE(object->enumProperty(), MyTypeObject::EnumVal2);
+ QCOMPARE(object->stringProperty(), QString("Hello World!"));
+ QCOMPARE(object->uintProperty(), uint(10));
+ QCOMPARE(object->intProperty(), -19);
+ QCOMPARE((float)object->realProperty(), float(23.2));
+ QCOMPARE((float)object->doubleProperty(), float(-19.7));
+ QCOMPARE((float)object->floatProperty(), float(8.5));
+ QCOMPARE(object->colorProperty(), QColor("red"));
+ QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
+ QCOMPARE(object->timeProperty(), QTime(11, 11, 32));
+ QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1)));
+ QCOMPARE(object->pointProperty(), QPoint(99,13));
+ QCOMPARE(object->pointFProperty(), QPointF(-10.1, 12.3));
+ QCOMPARE(object->sizeProperty(), QSize(99, 13));
+ QCOMPARE(object->sizeFProperty(), QSizeF(0.1, 0.2));
+ QCOMPARE(object->rectProperty(), QRect(9, 7, 100, 200));
+ QCOMPARE(object->rectFProperty(), QRectF(1000.1, -10.9, 400, 90.99));
+ QCOMPARE(object->boolProperty(), true);
+ QCOMPARE(object->variantProperty(), QVariant("Hello World!"));
+ QCOMPARE(object->vectorProperty(), QVector3D(10, 1, 2.2));
+ QCOMPARE(object->vector4Property(), QVector4D(10, 1, 2.2, 2.3));
+ QUrl encoded;
+ encoded.setEncodedUrl("main.qml?with%3cencoded%3edata", QUrl::TolerantMode);
+ QCOMPARE(object->urlProperty(), component.url().resolved(encoded));
+ QVERIFY(object->objectProperty() != 0);
+ MyTypeObject *child = qobject_cast<MyTypeObject *>(object->objectProperty());
+ QVERIFY(child != 0);
+ QCOMPARE(child->intProperty(), 8);
+}
+
+// Test edge case type assignments
+void tst_qqmllanguage::assignTypeExtremes()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignTypeExtremes.qml"));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->uintProperty(), 0xEE6B2800);
+ QCOMPARE(object->intProperty(), -0x77359400);
+}
+
+// Test that a composite type can assign to a property of its base type
+void tst_qqmllanguage::assignCompositeToType()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignCompositeToType.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+// Test that literals are stored correctly in variant properties
+void tst_qqmllanguage::assignLiteralToVariant()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignLiteralToVariant.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").userType(), (int)QVariant::Int);
+ QCOMPARE(object->property("test2").userType(), (int)QMetaType::Double);
+ QCOMPARE(object->property("test3").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test4").userType(), (int)QVariant::Color);
+ QCOMPARE(object->property("test5").userType(), (int)QVariant::RectF);
+ QCOMPARE(object->property("test6").userType(), (int)QVariant::PointF);
+ QCOMPARE(object->property("test7").userType(), (int)QVariant::SizeF);
+ QCOMPARE(object->property("test8").userType(), (int)QVariant::Vector3D);
+ QCOMPARE(object->property("test9").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test10").userType(), (int)QVariant::Bool);
+ QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool);
+ QCOMPARE(object->property("test12").userType(), (int)QVariant::Vector4D);
+
+ QVERIFY(object->property("test1") == QVariant(1));
+ QVERIFY(object->property("test2") == QVariant((double)1.7));
+ QVERIFY(object->property("test3") == QVariant(QString(QLatin1String("Hello world!"))));
+ QVERIFY(object->property("test4") == QVariant(QColor::fromRgb(0xFF008800)));
+ QVERIFY(object->property("test5") == QVariant(QRectF(10, 10, 10, 10)));
+ QVERIFY(object->property("test6") == QVariant(QPointF(10, 10)));
+ QVERIFY(object->property("test7") == QVariant(QSizeF(10, 10)));
+ QVERIFY(object->property("test8") == QVariant(QVector3D(100, 100, 100)));
+ QVERIFY(object->property("test9") == QVariant(QString(QLatin1String("#FF008800"))));
+ QVERIFY(object->property("test10") == QVariant(bool(true)));
+ QVERIFY(object->property("test11") == QVariant(bool(false)));
+ QVERIFY(object->property("test12") == QVariant(QVector4D(100, 100, 100, 100)));
+
+ delete object;
+}
+
+// Test that literals are stored correctly in "var" properties
+// Note that behaviour differs from "variant" properties in that
+// no conversion from "special strings" to QVariants is performed.
+void tst_qqmllanguage::assignLiteralToVar()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignLiteralToVar.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").userType(), (int)QMetaType::Int);
+ QCOMPARE(object->property("test2").userType(), (int)QMetaType::Double);
+ QCOMPARE(object->property("test3").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test4").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test5").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test6").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test7").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test8").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test9").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test10").userType(), (int)QVariant::Bool);
+ QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool);
+ QCOMPARE(object->property("test12").userType(), (int)QVariant::Color);
+ QCOMPARE(object->property("test13").userType(), (int)QVariant::RectF);
+ QCOMPARE(object->property("test14").userType(), (int)QVariant::PointF);
+ QCOMPARE(object->property("test15").userType(), (int)QVariant::SizeF);
+ QCOMPARE(object->property("test16").userType(), (int)QVariant::Vector3D);
+ QCOMPARE(object->property("variantTest1Bound").userType(), (int)QMetaType::Int);
+ QCOMPARE(object->property("test1Bound").userType(), (int)QMetaType::Int);
+
+ QCOMPARE(object->property("test1"), QVariant(5));
+ QCOMPARE(object->property("test2"), QVariant((double)1.7));
+ QCOMPARE(object->property("test3"), QVariant(QString(QLatin1String("Hello world!"))));
+ QCOMPARE(object->property("test4"), QVariant(QString(QLatin1String("#FF008800"))));
+ QCOMPARE(object->property("test5"), QVariant(QString(QLatin1String("10,10,10x10"))));
+ QCOMPARE(object->property("test6"), QVariant(QString(QLatin1String("10,10"))));
+ QCOMPARE(object->property("test7"), QVariant(QString(QLatin1String("10x10"))));
+ QCOMPARE(object->property("test8"), QVariant(QString(QLatin1String("100,100,100"))));
+ QCOMPARE(object->property("test9"), QVariant(QString(QLatin1String("#FF008800"))));
+ QCOMPARE(object->property("test10"), QVariant(bool(true)));
+ QCOMPARE(object->property("test11"), QVariant(bool(false)));
+ QCOMPARE(object->property("test12"), QVariant(QColor::fromRgbF(0.2, 0.3, 0.4, 0.5)));
+ QCOMPARE(object->property("test13"), QVariant(QRectF(10, 10, 10, 10)));
+ QCOMPARE(object->property("test14"), QVariant(QPointF(10, 10)));
+ QCOMPARE(object->property("test15"), QVariant(QSizeF(10, 10)));
+ QCOMPARE(object->property("test16"), QVariant(QVector3D(100, 100, 100)));
+ QCOMPARE(object->property("variantTest1Bound"), QVariant(9));
+ QCOMPARE(object->property("test1Bound"), QVariant(11));
+
+ delete object;
+}
+
+// Tests that custom parser types can be instantiated
+void tst_qqmllanguage::customParserTypes()
+{
+ QQmlComponent component(&engine, TEST_FILE("customParserTypes.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->property("count") == QVariant(2));
+}
+
+// Tests that the root item can be a custom component
+void tst_qqmllanguage::rootAsQmlComponent()
+{
+ QQmlComponent component(&engine, TEST_FILE("rootAsQmlComponent.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *object = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("x"), QVariant(11));
+ QCOMPARE(object->getChildren()->count(), 2);
+}
+
+// Tests that components can be specified inline
+void tst_qqmllanguage::inlineQmlComponents()
+{
+ QQmlComponent component(&engine, TEST_FILE("inlineQmlComponents.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *object = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->getChildren()->count(), 1);
+ QQmlComponent *comp = qobject_cast<QQmlComponent *>(object->getChildren()->at(0));
+ QVERIFY(comp != 0);
+ MyQmlObject *compObject = qobject_cast<MyQmlObject *>(comp->create());
+ QVERIFY(compObject != 0);
+ QCOMPARE(compObject->value(), 11);
+}
+
+// Tests that types that have an id property have it set
+void tst_qqmllanguage::idProperty()
+{
+ QQmlComponent component(&engine, TEST_FILE("idProperty.qml"));
+ VERIFY_ERRORS(0);
+ MyContainer *object = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->getChildren()->count(), 1);
+ MyTypeObject *child =
+ qobject_cast<MyTypeObject *>(object->getChildren()->at(0));
+ QVERIFY(child != 0);
+ QCOMPARE(child->id(), QString("myObjectId"));
+ QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child));
+}
+
+// Tests automatic connection to notify signals if "onBlahChanged" syntax is used
+// even if the notify signal for "blah" is not called "blahChanged"
+void tst_qqmllanguage::autoNotifyConnection()
+{
+ QQmlComponent component(&engine, TEST_FILE("autoNotifyConnection.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QMetaProperty prop = object->metaObject()->property(object->metaObject()->indexOfProperty("receivedNotify"));
+ QVERIFY(prop.isValid());
+
+ QCOMPARE(prop.read(object), QVariant::fromValue(false));
+ object->setPropertyWithNotify(1);
+ QCOMPARE(prop.read(object), QVariant::fromValue(true));
+}
+
+// Tests that signals can be assigned to
+void tst_qqmllanguage::assignSignal()
+{
+ QQmlComponent component(&engine, TEST_FILE("assignSignal.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
+ emit object->basicSignal();
+ QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlotWithArgs(9)");
+ emit object->basicParameterizedSignal(9);
+}
+
+// Tests the creation and assignment of dynamic properties
+void tst_qqmllanguage::dynamicProperties()
+{
+ QQmlComponent component(&engine, TEST_FILE("dynamicProperties.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("intProperty"), QVariant(10));
+ QCOMPARE(object->property("boolProperty"), QVariant(false));
+ QCOMPARE(object->property("doubleProperty"), QVariant(-10.1));
+ QCOMPARE(object->property("realProperty"), QVariant((qreal)-19.9));
+ QCOMPARE(object->property("stringProperty"), QVariant("Hello World!"));
+ QCOMPARE(object->property("urlProperty"), QVariant(TEST_FILE("main.qml")));
+ QCOMPARE(object->property("colorProperty"), QVariant(QColor("red")));
+ QCOMPARE(object->property("dateProperty"), QVariant(QDate(1945, 9, 2)));
+ QCOMPARE(object->property("varProperty"), QVariant("Hello World!"));
+}
+
+// Test that nested types can use dynamic properties
+void tst_qqmllanguage::dynamicPropertiesNested()
+{
+ QQmlComponent component(&engine, TEST_FILE("dynamicPropertiesNested.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("super_a").toInt(), 11); // Overridden
+ QCOMPARE(object->property("super_c").toInt(), 14); // Inherited
+ QCOMPARE(object->property("a").toInt(), 13); // New
+ QCOMPARE(object->property("b").toInt(), 12); // New
+
+ delete object;
+}
+
+// Tests the creation and assignment to dynamic list properties
+void tst_qqmllanguage::listProperties()
+{
+ QQmlComponent component(&engine, TEST_FILE("listProperties.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toInt(), 2);
+}
+
+// Tests the creation and assignment of dynamic object properties
+// ### Not complete
+void tst_qqmllanguage::dynamicObjectProperties()
+{
+ {
+ QQmlComponent component(&engine, TEST_FILE("dynamicObjectProperties.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(object->property("objectProperty") == qVariantFromValue((QObject*)0));
+ QVERIFY(object->property("objectProperty2") != qVariantFromValue((QObject*)0));
+ }
+ {
+ QQmlComponent component(&engine, TEST_FILE("dynamicObjectProperties.2.qml"));
+ QEXPECT_FAIL("", "QTBUG-10822", Abort);
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(object->property("objectProperty") != qVariantFromValue((QObject*)0));
+ }
+}
+
+// Tests the declaration of dynamic signals and slots
+void tst_qqmllanguage::dynamicSignalsAndSlots()
+{
+ QTest::ignoreMessage(QtDebugMsg, "1921");
+
+ QQmlComponent component(&engine, TEST_FILE("dynamicSignalsAndSlots.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QVERIFY(object->metaObject()->indexOfMethod("signal1()") != -1);
+ QVERIFY(object->metaObject()->indexOfMethod("signal2()") != -1);
+ QVERIFY(object->metaObject()->indexOfMethod("slot1()") != -1);
+ QVERIFY(object->metaObject()->indexOfMethod("slot2()") != -1);
+
+ QCOMPARE(object->property("test").toInt(), 0);
+ QMetaObject::invokeMethod(object, "slot3", Qt::DirectConnection, Q_ARG(QVariant, QVariant(10)));
+ QCOMPARE(object->property("test").toInt(), 10);
+}
+
+void tst_qqmllanguage::simpleBindings()
+{
+ QQmlComponent component(&engine, TEST_FILE("simpleBindings.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("value1"), QVariant(10));
+ QCOMPARE(object->property("value2"), QVariant(10));
+ QCOMPARE(object->property("value3"), QVariant(21));
+ QCOMPARE(object->property("value4"), QVariant(10));
+ QCOMPARE(object->property("objectProperty"), QVariant::fromValue(object));
+}
+
+void tst_qqmllanguage::autoComponentCreation()
+{
+ QQmlComponent component(&engine, TEST_FILE("autoComponentCreation.qml"));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->componentProperty() != 0);
+ MyTypeObject *child = qobject_cast<MyTypeObject *>(object->componentProperty()->create());
+ QVERIFY(child != 0);
+ QCOMPARE(child->realProperty(), qreal(9));
+}
+
+void tst_qqmllanguage::propertyValueSource()
+{
+ {
+ QQmlComponent component(&engine, TEST_FILE("propertyValueSource.qml"));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QList<QObject *> valueSources;
+ QObjectList allChildren = object->findChildren<QObject*>();
+ foreach (QObject *child, allChildren) {
+ if (qobject_cast<QQmlPropertyValueSource *>(child))
+ valueSources.append(child);
+ }
+
+ QCOMPARE(valueSources.count(), 1);
+ MyPropertyValueSource *valueSource =
+ qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
+ QVERIFY(valueSource != 0);
+ QCOMPARE(valueSource->prop.object(), qobject_cast<QObject*>(object));
+ QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty")));
+ }
+
+ {
+ QQmlComponent component(&engine, TEST_FILE("propertyValueSource.2.qml"));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QList<QObject *> valueSources;
+ QObjectList allChildren = object->findChildren<QObject*>();
+ foreach (QObject *child, allChildren) {
+ if (qobject_cast<QQmlPropertyValueSource *>(child))
+ valueSources.append(child);
+ }
+
+ QCOMPARE(valueSources.count(), 1);
+ MyPropertyValueSource *valueSource =
+ qobject_cast<MyPropertyValueSource *>(valueSources.at(0));
+ QVERIFY(valueSource != 0);
+ QCOMPARE(valueSource->prop.object(), qobject_cast<QObject*>(object));
+ QCOMPARE(valueSource->prop.name(), QString(QLatin1String("intProperty")));
+ }
+}
+
+void tst_qqmllanguage::attachedProperties()
+{
+ QQmlComponent component(&engine, TEST_FILE("attachedProperties.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QObject *attached = qmlAttachedPropertiesObject<MyQmlObject>(object);
+ QVERIFY(attached != 0);
+ QCOMPARE(attached->property("value"), QVariant(10));
+ QCOMPARE(attached->property("value2"), QVariant(13));
+}
+
+// Tests non-static object properties
+void tst_qqmllanguage::dynamicObjects()
+{
+ QQmlComponent component(&engine, TEST_FILE("dynamicObject.1.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+// Tests the registration of custom variant string converters
+void tst_qqmllanguage::customVariantTypes()
+{
+ QQmlComponent component(&engine, TEST_FILE("customVariantTypes.qml"));
+ VERIFY_ERRORS(0);
+ MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->customType().a, 10);
+}
+
+void tst_qqmllanguage::valueTypes()
+{
+ QQmlComponent component(&engine, TEST_FILE("valueTypes.qml"));
+ VERIFY_ERRORS(0);
+
+ QString message = component.url().toString() + ":2:1: QML MyTypeObject: Binding loop detected for property \"rectProperty.width\"";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+
+ MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
+ QVERIFY(object != 0);
+
+
+ QCOMPARE(object->rectProperty(), QRect(10, 11, 12, 13));
+ QCOMPARE(object->rectProperty2(), QRect(10, 11, 12, 13));
+ QCOMPARE(object->intProperty(), 10);
+ object->doAction();
+ QCOMPARE(object->rectProperty(), QRect(12, 11, 14, 13));
+ QCOMPARE(object->rectProperty2(), QRect(12, 11, 14, 13));
+ QCOMPARE(object->intProperty(), 12);
+
+ // ###
+#if 0
+ QQmlProperty p(object, "rectProperty.x");
+ QCOMPARE(p.read(), QVariant(12));
+ p.write(13);
+ QCOMPARE(p.read(), QVariant(13));
+
+ quint32 r = QQmlPropertyPrivate::saveValueType(p.coreIndex(), p.valueTypeCoreIndex());
+ QQmlProperty p2;
+ QQmlPropertyPrivate::restore(p2, r, object);
+ QCOMPARE(p2.read(), QVariant(13));
+#endif
+}
+
+void tst_qqmllanguage::cppnamespace()
+{
+ {
+ QQmlComponent component(&engine, TEST_FILE("cppnamespace.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, TEST_FILE("cppnamespace.2.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+ }
+}
+
+void tst_qqmllanguage::aliasProperties()
+{
+ // Simple "int" alias
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.1.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // Read through alias
+ QCOMPARE(object->property("valueAlias").toInt(), 10);
+ object->setProperty("value", QVariant(13));
+ QCOMPARE(object->property("valueAlias").toInt(), 13);
+
+ // Write through alias
+ object->setProperty("valueAlias", QVariant(19));
+ QCOMPARE(object->property("valueAlias").toInt(), 19);
+ QCOMPARE(object->property("value").toInt(), 19);
+
+ delete object;
+ }
+
+ // Complex object alias
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.2.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // Read through alias
+ MyQmlObject *v =
+ qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
+ QVERIFY(v != 0);
+ QCOMPARE(v->value(), 10);
+
+ // Write through alias
+ MyQmlObject *v2 = new MyQmlObject();
+ v2->setParent(object);
+ object->setProperty("aliasObject", qVariantFromValue(v2));
+ MyQmlObject *v3 =
+ qvariant_cast<MyQmlObject *>(object->property("aliasObject"));
+ QVERIFY(v3 != 0);
+ QCOMPARE(v3, v2);
+
+ delete object;
+ }
+
+ // Nested aliases
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.3.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("value").toInt(), 1892);
+ QCOMPARE(object->property("value2").toInt(), 1892);
+
+ object->setProperty("value", QVariant(1313));
+ QCOMPARE(object->property("value").toInt(), 1313);
+ QCOMPARE(object->property("value2").toInt(), 1313);
+
+ object->setProperty("value2", QVariant(8080));
+ QCOMPARE(object->property("value").toInt(), 8080);
+ QCOMPARE(object->property("value2").toInt(), 8080);
+
+ delete object;
+ }
+
+ // Enum aliases
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.4.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("enumAlias").toInt(), 1);
+
+ delete object;
+ }
+
+ // Id aliases
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.5.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVariant v = object->property("otherAlias");
+ QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>());
+ MyQmlObject *o = qvariant_cast<MyQmlObject*>(v);
+ QCOMPARE(o->value(), 10);
+
+ delete o;
+
+ v = object->property("otherAlias");
+ QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>());
+ o = qvariant_cast<MyQmlObject*>(v);
+ QVERIFY(o == 0);
+
+ delete object;
+ }
+
+ // Nested aliases - this used to cause a crash
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.6.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("a").toInt(), 1923);
+ }
+
+ // Ptr Alias Cleanup - check that aliases to ptr types return 0
+ // if the object aliased to is removed
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.7.qml"));
+ VERIFY_ERRORS(0);
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *object1 = qvariant_cast<QObject *>(object->property("object"));
+ QVERIFY(object1 != 0);
+ QObject *object2 = qvariant_cast<QObject *>(object1->property("object"));
+ QVERIFY(object2 != 0);
+
+ QObject *alias = qvariant_cast<QObject *>(object->property("aliasedObject"));
+ QVERIFY(alias == object2);
+
+ delete object1;
+
+ QObject *alias2 = object; // "Random" start value
+ int status = -1;
+ void *a[] = { &alias2, 0, &status };
+ QMetaObject::metacall(object, QMetaObject::ReadProperty,
+ object->metaObject()->indexOfProperty("aliasedObject"), a);
+ QVERIFY(alias2 == 0);
+ }
+
+ // Simple composite type
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.8.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("value").toInt(), 10);
+
+ delete object;
+ }
+
+ // Complex composite type
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.9.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("value").toInt(), 10);
+
+ delete object;
+ }
+
+ // Valuetype alias
+ // Simple "int" alias
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.10.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // Read through alias
+ QCOMPARE(object->property("valueAlias").toRect(), QRect(10, 11, 9, 8));
+ object->setProperty("rectProperty", QVariant(QRect(33, 12, 99, 100)));
+ QCOMPARE(object->property("valueAlias").toRect(), QRect(33, 12, 99, 100));
+
+ // Write through alias
+ object->setProperty("valueAlias", QVariant(QRect(3, 3, 4, 9)));
+ QCOMPARE(object->property("valueAlias").toRect(), QRect(3, 3, 4, 9));
+ QCOMPARE(object->property("rectProperty").toRect(), QRect(3, 3, 4, 9));
+
+ delete object;
+ }
+
+ // Valuetype sub-alias
+ {
+ QQmlComponent component(&engine, TEST_FILE("alias.11.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ // Read through alias
+ QCOMPARE(object->property("aliasProperty").toInt(), 19);
+ object->setProperty("rectProperty", QVariant(QRect(33, 8, 102, 111)));
+ QCOMPARE(object->property("aliasProperty").toInt(), 33);
+
+ // Write through alias
+ object->setProperty("aliasProperty", QVariant(4));
+ QCOMPARE(object->property("aliasProperty").toInt(), 4);
+ QCOMPARE(object->property("rectProperty").toRect(), QRect(4, 8, 102, 111));
+
+ delete object;
+ }
+}
+
+// QTBUG-13374 Test that alias properties and signals can coexist
+void tst_qqmllanguage::aliasPropertiesAndSignals()
+{
+ QQmlComponent 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_qqmllanguage::componentCompositeType()
+{
+ QQmlComponent component(&engine, TEST_FILE("componentCompositeType.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+class TestType : public QObject {
+ Q_OBJECT
+public:
+ TestType(QObject *p=0) : QObject(p) {}
+};
+
+class TestType2 : public QObject {
+ Q_OBJECT
+public:
+ TestType2(QObject *p=0) : QObject(p) {}
+};
+
+void tst_qqmllanguage::i18n_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("stringProperty");
+ QTest::newRow("i18nStrings") << "i18nStrings.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245 (5 accented 'a' letters)");
+ QTest::newRow("i18nDeclaredPropertyNames") << "i18nDeclaredPropertyNames.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 10");
+ QTest::newRow("i18nDeclaredPropertyUse") << "i18nDeclaredPropertyUse.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 15");
+ QTest::newRow("i18nScript") << "i18nScript.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 20");
+ QTest::newRow("i18nType") << "i18nType.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 30");
+ QTest::newRow("i18nNameSpace") << "i18nNameSpace.qml" << QString::fromUtf8("Test \303\241\303\242\303\243\303\244\303\245: 40");
+}
+
+void tst_qqmllanguage::i18n()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, stringProperty);
+ QQmlComponent component(&engine, TEST_FILE(file));
+ VERIFY_ERRORS(0);
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->stringProperty(), stringProperty);
+
+ delete object;
+}
+
+// Check that the Component::onCompleted attached property works
+void tst_qqmllanguage::onCompleted()
+{
+ QQmlComponent component(&engine, TEST_FILE("onCompleted.qml"));
+ VERIFY_ERRORS(0);
+ QTest::ignoreMessage(QtDebugMsg, "Completed 6 10");
+ QTest::ignoreMessage(QtDebugMsg, "Completed 6 10");
+ QTest::ignoreMessage(QtDebugMsg, "Completed 10 11");
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+// Check that the Component::onDestruction attached property works
+void tst_qqmllanguage::onDestruction()
+{
+ QQmlComponent component(&engine, TEST_FILE("onDestruction.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QTest::ignoreMessage(QtDebugMsg, "Destruction 6 10");
+ QTest::ignoreMessage(QtDebugMsg, "Destruction 6 10");
+ QTest::ignoreMessage(QtDebugMsg, "Destruction 10 11");
+ delete object;
+}
+
+// Check that assignments to QQmlScriptString properties work
+void tst_qqmllanguage::scriptString()
+{
+ {
+ QQmlComponent component(&engine, TEST_FILE("scriptString.qml"));
+ VERIFY_ERRORS(0);
+
+ MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->scriptProperty().script(), QString("foo + bar"));
+ QCOMPARE(object->scriptProperty().scopeObject(), qobject_cast<QObject*>(object));
+ QCOMPARE(object->scriptProperty().context(), qmlContext(object));
+
+ QVERIFY(object->grouped() != 0);
+ QCOMPARE(object->grouped()->script().script(), QString("console.log(1921)"));
+ QCOMPARE(object->grouped()->script().scopeObject(), qobject_cast<QObject*>(object));
+ QCOMPARE(object->grouped()->script().context(), qmlContext(object));
+ }
+
+ {
+ QQmlComponent component(&engine, TEST_FILE("scriptString2.qml"));
+ VERIFY_ERRORS(0);
+
+ MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->scriptProperty().script(), QString("\"hello\\n\\\"world\\\"\""));
+ }
+
+ {
+ QQmlComponent component(&engine, TEST_FILE("scriptString3.qml"));
+ VERIFY_ERRORS(0);
+
+ MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->scriptProperty().script(), QString("12.345"));
+ }
+
+ {
+ QQmlComponent component(&engine, TEST_FILE("scriptString4.qml"));
+ VERIFY_ERRORS(0);
+
+ MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->scriptProperty().script(), QString("true"));
+ }
+}
+
+// Check that default property assignments are correctly spliced into explicit
+// property assignments
+void tst_qqmllanguage::defaultPropertyListOrder()
+{
+ QQmlComponent component(&engine, TEST_FILE("defaultPropertyListOrder.qml"));
+ VERIFY_ERRORS(0);
+
+ MyContainer *container = qobject_cast<MyContainer *>(component.create());
+ QVERIFY(container != 0);
+
+ QCOMPARE(container->getChildren()->count(), 6);
+ QCOMPARE(container->getChildren()->at(0)->property("index"), QVariant(0));
+ QCOMPARE(container->getChildren()->at(1)->property("index"), QVariant(1));
+ QCOMPARE(container->getChildren()->at(2)->property("index"), QVariant(2));
+ QCOMPARE(container->getChildren()->at(3)->property("index"), QVariant(3));
+ QCOMPARE(container->getChildren()->at(4)->property("index"), QVariant(4));
+ QCOMPARE(container->getChildren()->at(5)->property("index"), QVariant(5));
+}
+
+void tst_qqmllanguage::declaredPropertyValues()
+{
+ QQmlComponent component(&engine, TEST_FILE("declaredPropertyValues.qml"));
+ VERIFY_ERRORS(0);
+}
+
+void tst_qqmllanguage::dontDoubleCallClassBegin()
+{
+ QQmlComponent 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;
+}
+
+void tst_qqmllanguage::reservedWords_data()
+{
+ QTest::addColumn<QByteArray>("word");
+
+ QTest::newRow("abstract") << QByteArray("abstract");
+ QTest::newRow("as") << QByteArray("as");
+ QTest::newRow("boolean") << QByteArray("boolean");
+ QTest::newRow("break") << QByteArray("break");
+ QTest::newRow("byte") << QByteArray("byte");
+ QTest::newRow("case") << QByteArray("case");
+ QTest::newRow("catch") << QByteArray("catch");
+ QTest::newRow("char") << QByteArray("char");
+ QTest::newRow("class") << QByteArray("class");
+ QTest::newRow("continue") << QByteArray("continue");
+ QTest::newRow("const") << QByteArray("const");
+ QTest::newRow("debugger") << QByteArray("debugger");
+ QTest::newRow("default") << QByteArray("default");
+ QTest::newRow("delete") << QByteArray("delete");
+ QTest::newRow("do") << QByteArray("do");
+ QTest::newRow("double") << QByteArray("double");
+ QTest::newRow("else") << QByteArray("else");
+ QTest::newRow("enum") << QByteArray("enum");
+ QTest::newRow("export") << QByteArray("export");
+ QTest::newRow("extends") << QByteArray("extends");
+ QTest::newRow("false") << QByteArray("false");
+ QTest::newRow("final") << QByteArray("final");
+ QTest::newRow("finally") << QByteArray("finally");
+ QTest::newRow("float") << QByteArray("float");
+ QTest::newRow("for") << QByteArray("for");
+ QTest::newRow("function") << QByteArray("function");
+ QTest::newRow("goto") << QByteArray("goto");
+ QTest::newRow("if") << QByteArray("if");
+ QTest::newRow("implements") << QByteArray("implements");
+ QTest::newRow("import") << QByteArray("import");
+ QTest::newRow("in") << QByteArray("in");
+ QTest::newRow("instanceof") << QByteArray("instanceof");
+ QTest::newRow("int") << QByteArray("int");
+ QTest::newRow("interface") << QByteArray("interface");
+ QTest::newRow("long") << QByteArray("long");
+ QTest::newRow("native") << QByteArray("native");
+ QTest::newRow("new") << QByteArray("new");
+ QTest::newRow("null") << QByteArray("null");
+ QTest::newRow("package") << QByteArray("package");
+ QTest::newRow("private") << QByteArray("private");
+ QTest::newRow("protected") << QByteArray("protected");
+ QTest::newRow("public") << QByteArray("public");
+ QTest::newRow("return") << QByteArray("return");
+ QTest::newRow("short") << QByteArray("short");
+ QTest::newRow("static") << QByteArray("static");
+ QTest::newRow("super") << QByteArray("super");
+ QTest::newRow("switch") << QByteArray("switch");
+ QTest::newRow("synchronized") << QByteArray("synchronized");
+ QTest::newRow("this") << QByteArray("this");
+ QTest::newRow("throw") << QByteArray("throw");
+ QTest::newRow("throws") << QByteArray("throws");
+ QTest::newRow("transient") << QByteArray("transient");
+ QTest::newRow("true") << QByteArray("true");
+ QTest::newRow("try") << QByteArray("try");
+ QTest::newRow("typeof") << QByteArray("typeof");
+ QTest::newRow("var") << QByteArray("var");
+ QTest::newRow("void") << QByteArray("void");
+ QTest::newRow("volatile") << QByteArray("volatile");
+ QTest::newRow("while") << QByteArray("while");
+ QTest::newRow("with") << QByteArray("with");
+}
+
+void tst_qqmllanguage::reservedWords()
+{
+ QFETCH(QByteArray, word);
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nQtObject { property string " + word + " }", QUrl());
+ QCOMPARE(component.errorString(), QLatin1String(":2 Expected token `identifier'\n"));
+}
+
+// Check that first child of qml is of given type. Empty type insists on error.
+void tst_qqmllanguage::testType(const QString& qml, const QString& type, const QString& expectederror)
+{
+ QQmlComponent component(&engine);
+ component.setData(qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports
+
+ QTRY_VERIFY(!component.isLoading());
+
+ if (type.isEmpty()) {
+ QVERIFY(component.isError());
+ QString actualerror;
+ foreach (const QQmlError e, component.errors()) {
+ if (!actualerror.isEmpty())
+ actualerror.append("; ");
+ actualerror.append(e.description());
+ }
+ QCOMPARE(actualerror,expectederror);
+ } else {
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(QString(object->metaObject()->className()), type);
+ delete object;
+ }
+}
+
+// QTBUG-17276
+void tst_qqmllanguage::inlineAssignmentsOverrideBindings()
+{
+ QQmlComponent component(&engine, TEST_FILE("inlineAssignmentsOverrideBindings.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toInt(), 11);
+ delete o;
+}
+
+// QTBUG-19354
+void tst_qqmllanguage::nestedComponentRoots()
+{
+ QQmlComponent component(&engine, TEST_FILE("nestedComponentRoots.qml"));
+}
+
+// Import tests (QT-558)
+void tst_qqmllanguage::importsBuiltin_data()
+{
+ // QT-610
+
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+ QTest::addColumn<QString>("error");
+
+ // import built-ins
+ QTest::newRow("missing import")
+ << "Test {}"
+ << ""
+ << "Test is not a type";
+ QTest::newRow("not in version 0.0")
+ << "import com.nokia.Test 0.0\n"
+ "Test {}"
+ << ""
+ << "Test is not a type";
+ QTest::newRow("version not installed")
+ << "import com.nokia.Test 99.0\n"
+ "Test {}"
+ << ""
+ << "module \"com.nokia.Test\" version 99.0 is not installed";
+ QTest::newRow("in version 0.0")
+ << "import com.nokia.Test 0.0\n"
+ "TestTP {}"
+ << "TestType"
+ << "";
+ QTest::newRow("qualified in version 0.0")
+ << "import com.nokia.Test 0.0 as T\n"
+ "T.TestTP {}"
+ << "TestType"
+ << "";
+ QTest::newRow("in version 1.0")
+ << "import com.nokia.Test 1.0\n"
+ "Test {}"
+ << "TestType"
+ << "";
+ QTest::newRow("qualified wrong")
+ << "import com.nokia.Test 1.0 as T\n" // QT-610
+ "Test {}"
+ << ""
+ << "Test is not a type";
+ QTest::newRow("qualified right")
+ << "import com.nokia.Test 1.0 as T\n"
+ "T.Test {}"
+ << "TestType"
+ << "";
+ QTest::newRow("qualified right but not in version 0.0")
+ << "import com.nokia.Test 0.0 as T\n"
+ "T.Test {}"
+ << ""
+ << "T.Test is not a type";
+ QTest::newRow("in version 1.1")
+ << "import com.nokia.Test 1.1\n"
+ "Test {}"
+ << "TestType"
+ << "";
+ QTest::newRow("in version 1.3")
+ << "import com.nokia.Test 1.3\n"
+ "Test {}"
+ << "TestType"
+ << "";
+ QTest::newRow("in version 1.5")
+ << "import com.nokia.Test 1.5\n"
+ "Test {}"
+ << "TestType"
+ << "";
+ QTest::newRow("changed in version 1.8")
+ << "import com.nokia.Test 1.8\n"
+ "Test {}"
+ << "TestType2"
+ << "";
+ QTest::newRow("in version 1.12")
+ << "import com.nokia.Test 1.12\n"
+ "Test {}"
+ << "TestType2"
+ << "";
+ QTest::newRow("old in version 1.9")
+ << "import com.nokia.Test 1.9\n"
+ "OldTest {}"
+ << "TestType"
+ << "";
+ QTest::newRow("old in version 1.11")
+ << "import com.nokia.Test 1.11\n"
+ "OldTest {}"
+ << "TestType"
+ << "";
+ QTest::newRow("multiversion 1")
+ << "import com.nokia.Test 1.11\n"
+ "import com.nokia.Test 1.12\n"
+ "Test {}"
+ << (!qmlCheckTypes()?"TestType2":"")
+ << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11");
+ QTest::newRow("multiversion 2")
+ << "import com.nokia.Test 1.11\n"
+ "import com.nokia.Test 1.12\n"
+ "OldTest {}"
+ << (!qmlCheckTypes()?"TestType":"")
+ << (!qmlCheckTypes()?"":"OldTest is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11");
+ QTest::newRow("qualified multiversion 3")
+ << "import com.nokia.Test 1.0 as T0\n"
+ "import com.nokia.Test 1.8 as T8\n"
+ "T0.Test {}"
+ << "TestType"
+ << "";
+ QTest::newRow("qualified multiversion 4")
+ << "import com.nokia.Test 1.0 as T0\n"
+ "import com.nokia.Test 1.8 as T8\n"
+ "T8.Test {}"
+ << "TestType2"
+ << "";
+}
+
+void tst_qqmllanguage::importsBuiltin()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ QFETCH(QString, error);
+ testType(qml,type,error);
+}
+
+void tst_qqmllanguage::importsLocal_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+ QTest::addColumn<QString>("error");
+
+ // import locals
+ QTest::newRow("local import")
+ << "import \"subdir\"\n" // QT-613
+ "Test {}"
+ << "QQuickRectangle"
+ << "";
+ QTest::newRow("local import second")
+ << "import QtQuick 2.0\nimport \"subdir\"\n"
+ "Test {}"
+ << "QQuickRectangle"
+ << "";
+ QTest::newRow("local import subsubdir")
+ << "import QtQuick 2.0\nimport \"subdir/subsubdir\"\n"
+ "SubTest {}"
+ << "QQuickRectangle"
+ << "";
+ QTest::newRow("local import QTBUG-7721 A")
+ << "subdir.Test {}" // no longer allowed (QTBUG-7721)
+ << ""
+ << "subdir.Test - subdir is not a namespace";
+ QTest::newRow("local import QTBUG-7721 B")
+ << "import \"subdir\" as X\n"
+ "X.subsubdir.SubTest {}" // no longer allowed (QTBUG-7721)
+ << ""
+ << "X.subsubdir.SubTest - nested namespaces not allowed";
+ QTest::newRow("local import as")
+ << "import \"subdir\" as T\n"
+ "T.Test {}"
+ << "QQuickRectangle"
+ << "";
+ QTest::newRow("wrong local import as")
+ << "import \"subdir\" as T\n"
+ "Test {}"
+ << ""
+ << "Test is not a type";
+ QTest::newRow("library precedence over local import")
+ << "import \"subdir\"\n"
+ "import com.nokia.Test 1.0\n"
+ "Test {}"
+ << (!qmlCheckTypes()?"TestType":"")
+ << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test and in subdir");
+}
+
+void tst_qqmllanguage::importsLocal()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ QFETCH(QString, error);
+ testType(qml,type,error);
+}
+
+void tst_qqmllanguage::basicRemote_data()
+{
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<QString>("type");
+ QTest::addColumn<QString>("error");
+
+ QString serverdir = "http://127.0.0.1:14447/qtest/qml/qqmllanguage/";
+
+ QTest::newRow("no need for qmldir") << QUrl(serverdir+"Test.qml") << "" << "";
+ QTest::newRow("absent qmldir") << QUrl(serverdir+"/noqmldir/Test.qml") << "" << "";
+ QTest::newRow("need qmldir") << QUrl(serverdir+"TestLocal.qml") << "" << "";
+}
+
+void tst_qqmllanguage::basicRemote()
+{
+ QFETCH(QUrl, url);
+ QFETCH(QString, type);
+ QFETCH(QString, error);
+
+ TestHTTPServer server(14447);
+ server.serveDirectory(testdata());
+
+ QQmlComponent component(&engine, url);
+
+ QTRY_VERIFY(!component.isLoading());
+
+ if (error.isEmpty()) {
+ if (component.isError())
+ qDebug() << component.errors();
+ QVERIFY(!component.isError());
+ } else {
+ QVERIFY(component.isError());
+ }
+}
+
+void tst_qqmllanguage::importsRemote_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+ QTest::addColumn<QString>("error");
+
+ QString serverdir = "http://127.0.0.1:14447/qtest/qml/qqmllanguage";
+
+ QTest::newRow("remote import") << "import \""+serverdir+"\"\nTest {}" << "QQuickRectangle"
+ << "";
+ QTest::newRow("remote import with subdir") << "import \""+serverdir+"\"\nTestSubDir {}" << "QQuickText"
+ << "";
+ QTest::newRow("remote import with local") << "import \""+serverdir+"\"\nTestLocal {}" << "QQuickImage"
+ << "";
+ QTest::newRow("wrong remote import with undeclared local") << "import \""+serverdir+"\"\nWrongTestLocal {}" << ""
+ << "WrongTestLocal is not a type";
+ QTest::newRow("wrong remote import of internal local") << "import \""+serverdir+"\"\nLocalInternal {}" << ""
+ << "LocalInternal is not a type";
+ QTest::newRow("wrong remote import of undeclared local") << "import \""+serverdir+"\"\nUndeclaredLocal {}" << ""
+ << "UndeclaredLocal is not a type";
+}
+
+void tst_qqmllanguage::importsRemote()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ QFETCH(QString, error);
+
+ TestHTTPServer server(14447);
+ server.serveDirectory(testdata());
+
+ testType(qml,type,error);
+}
+
+void tst_qqmllanguage::importsInstalled_data()
+{
+ // QT-610
+
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+ QTest::addColumn<QString>("error");
+
+ // import installed
+ QTest::newRow("installed import 0")
+ << "import com.nokia.installedtest0 0.0\n"
+ "InstalledTestTP {}"
+ << "QQuickRectangle"
+ << "";
+ QTest::newRow("installed import 0 as TP")
+ << "import com.nokia.installedtest0 0.0 as TP\n"
+ "TP.InstalledTestTP {}"
+ << "QQuickRectangle"
+ << "";
+ QTest::newRow("installed import 1")
+ << "import com.nokia.installedtest 1.0\n"
+ "InstalledTest {}"
+ << "QQuickRectangle"
+ << "";
+ QTest::newRow("installed import 2")
+ << "import com.nokia.installedtest 1.3\n"
+ "InstalledTest {}"
+ << "QQuickRectangle"
+ << "";
+ QTest::newRow("installed import 3")
+ << "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << "QQuickText"
+ << "";
+ QTest::newRow("installed import minor version not available") // QTBUG-11936
+ << "import com.nokia.installedtest 0.1\n"
+ "InstalledTest {}"
+ << ""
+ << "module \"com.nokia.installedtest\" version 0.1 is not installed";
+ QTest::newRow("installed import minor version not available") // QTBUG-9627
+ << "import com.nokia.installedtest 1.10\n"
+ "InstalledTest {}"
+ << ""
+ << "module \"com.nokia.installedtest\" version 1.10 is not installed";
+ QTest::newRow("installed import major version not available") // QTBUG-9627
+ << "import com.nokia.installedtest 9.0\n"
+ "InstalledTest {}"
+ << ""
+ << "module \"com.nokia.installedtest\" version 9.0 is not installed";
+ QTest::newRow("installed import visibility") // QT-614
+ << "import com.nokia.installedtest 1.4\n"
+ "PrivateType {}"
+ << ""
+ << "PrivateType is not a type";
+}
+
+void tst_qqmllanguage::importsInstalled()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ QFETCH(QString, error);
+ testType(qml,type,error);
+}
+
+
+void tst_qqmllanguage::importsOrder_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("type");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("double import") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << (!qmlCheckTypes()?"QQuickText":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.4");
+ QTest::newRow("installed import overrides 1") <<
+ "import com.nokia.installedtest 1.0\n"
+ "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << (!qmlCheckTypes()?"QQuickText":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0");
+ QTest::newRow("installed import overrides 2") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "InstalledTest {}"
+ << (!qmlCheckTypes()?"QQuickRectangle":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4");
+ QTest::newRow("installed import re-overrides 1") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << (!qmlCheckTypes()?"QQuickText":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0");
+ QTest::newRow("installed import re-overrides 2") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.0\n"
+ "InstalledTest {}"
+ << (!qmlCheckTypes()?"QQuickRectangle":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4");
+
+ QTest::newRow("installed import versus builtin 1") <<
+ "import com.nokia.installedtest 1.5\n"
+ "import QtQuick 2.0\n"
+ "Rectangle {}"
+ << (!qmlCheckTypes()?"QQuickRectangle":"")
+ << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in Qt and in lib/com/nokia/installedtest");
+ QTest::newRow("installed import versus builtin 2") <<
+ "import QtQuick 2.0\n"
+ "import com.nokia.installedtest 1.5\n"
+ "Rectangle {}"
+ << (!qmlCheckTypes()?"QQuickText":"")
+ << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in lib/com/nokia/installedtest and in Qt");
+ QTest::newRow("namespaces cannot be overridden by types 1") <<
+ "import QtQuick 2.0 as Rectangle\n"
+ "import com.nokia.installedtest 1.5\n"
+ "Rectangle {}"
+ << ""
+ << "Namespace Rectangle cannot be used as a type";
+ QTest::newRow("namespaces cannot be overridden by types 2") <<
+ "import QtQuick 2.0 as Rectangle\n"
+ "import com.nokia.installedtest 1.5\n"
+ "Rectangle.Image {}"
+ << "QQuickImage"
+ << "";
+ QTest::newRow("local last 1") <<
+ "LocalLast {}"
+ << "QQuickText"
+ << "";
+ QTest::newRow("local last 2") <<
+ "import com.nokia.installedtest 1.0\n"
+ "LocalLast {}"
+ << (!qmlCheckTypes()?"QQuickRectangle":"")// i.e. from com.nokia.installedtest, not data/LocalLast.qml
+ << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/com/nokia/installedtest and in local directory");
+}
+
+void tst_qqmllanguage::importsOrder()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, type);
+ QFETCH(QString, error);
+ testType(qml,type,error);
+}
+
+void tst_qqmllanguage::importIncorrectCase()
+{
+ QQmlComponent component(&engine, TEST_FILE("importIncorrectCase.qml"));
+
+ QList<QQmlError> errors = component.errors();
+ QCOMPARE(errors.count(), 1);
+
+#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
+ QString expectedError = QLatin1String("cannot load module \"com.Nokia.installedtest\": File name case mismatch for \"") + testdata("lib/com/Nokia/installedtest/qmldir") + QLatin1String("\"");
+#else
+ QString expectedError = QLatin1String("module \"com.Nokia.installedtest\" is not installed");
+#endif
+
+ QCOMPARE(errors.at(0).description(), expectedError);
+}
+
+void tst_qqmllanguage::importJs_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("errorFile");
+ QTest::addColumn<bool>("performTest");
+
+ QTest::newRow("defaultVersion")
+ << "importJs.1.qml"
+ << "importJs.1.errors.txt"
+ << true;
+
+ QTest::newRow("specifiedVersion")
+ << "importJs.2.qml"
+ << "importJs.2.errors.txt"
+ << true;
+
+ QTest::newRow("excludeExcessiveVersion")
+ << "importJs.3.qml"
+ << "importJs.3.errors.txt"
+ << false;
+
+ QTest::newRow("includeAppropriateVersion")
+ << "importJs.4.qml"
+ << "importJs.4.errors.txt"
+ << true;
+
+ QTest::newRow("noDefaultVersion")
+ << "importJs.5.qml"
+ << "importJs.5.errors.txt"
+ << false;
+
+ QTest::newRow("repeatImportFails")
+ << "importJs.6.qml"
+ << "importJs.6.errors.txt"
+ << false;
+
+ QTest::newRow("multipleVersionImportFails")
+ << "importJs.7.qml"
+ << "importJs.7.errors.txt"
+ << false;
+
+ QTest::newRow("namespacedImport")
+ << "importJs.8.qml"
+ << "importJs.8.errors.txt"
+ << true;
+
+ QTest::newRow("namespacedVersionedImport")
+ << "importJs.9.qml"
+ << "importJs.9.errors.txt"
+ << true;
+
+ QTest::newRow("namespacedRepeatImport")
+ << "importJs.10.qml"
+ << "importJs.10.errors.txt"
+ << true;
+}
+
+void tst_qqmllanguage::importJs()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, errorFile);
+ QFETCH(bool, performTest);
+
+ QQmlComponent component(&engine, TEST_FILE(file));
+
+ {
+ DETERMINE_ERRORS(errorFile.toLatin1().constData(),expected,actual);
+ QCOMPARE(expected.size(), actual.size());
+ for (int i = 0; i < expected.size(); ++i)
+ {
+ size_t compareLen = std::min(expected.at(i).length(), actual.at(i).length());
+ QCOMPARE(expected.at(i).left(compareLen), actual.at(i).left(compareLen));
+ }
+ }
+
+ if (performTest) {
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("test").toBool(),true);
+ delete object;
+ }
+}
+
+void tst_qqmllanguage::qmlAttachedPropertiesObjectMethod()
+{
+ QObject object;
+
+ QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, false), (QObject *)0);
+ QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(&object, true), (QObject *)0);
+
+ {
+ QQmlComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.1.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qmlAttachedPropertiesObject<MyQmlObject>(object, false), (QObject *)0);
+ QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, true) != 0);
+ }
+
+ {
+ QQmlComponent component(&engine, TEST_FILE("qmlAttachedPropertiesObjectMethod.2.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, false) != 0);
+ QVERIFY(qmlAttachedPropertiesObject<MyQmlObject>(object, true) != 0);
+ }
+}
+
+void tst_qqmllanguage::crash1()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nComponent {}", QUrl());
+}
+
+void tst_qqmllanguage::crash2()
+{
+ QQmlComponent component(&engine, TEST_FILE("crash2.qml"));
+}
+
+// QTBUG-8676
+void tst_qqmllanguage::customOnProperty()
+{
+ QQmlComponent component(&engine, TEST_FILE("customOnProperty.qml"));
+
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("on").toInt(), 10);
+
+ delete object;
+}
+
+// QTBUG-12601
+void tst_qqmllanguage::variantNotify()
+{
+ QQmlComponent 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_qqmllanguage::revisions()
+{
+ {
+ QQmlComponent component(&engine, TEST_FILE("revisions11.qml"));
+
+ VERIFY_ERRORS(0);
+ MyRevisionedClass *object = qobject_cast<MyRevisionedClass*>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->prop2(), 10.0);
+
+ delete object;
+ }
+ {
+ QQmlEngine myEngine;
+ QQmlComponent component(&myEngine, TEST_FILE("revisionssub11.qml"));
+
+ VERIFY_ERRORS(0);
+ MyRevisionedSubclass *object = qobject_cast<MyRevisionedSubclass*>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->prop1(), 10.0);
+ QCOMPARE(object->prop2(), 10.0);
+ QCOMPARE(object->prop3(), 10.0);
+ QCOMPARE(object->prop4(), 10.0);
+
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, TEST_FILE("versionedbase.qml"));
+ VERIFY_ERRORS(0);
+ MySubclass *object = qobject_cast<MySubclass*>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->prop1(), 10.0);
+ QCOMPARE(object->prop2(), 10.0);
+
+ delete object;
+ }
+}
+
+void tst_qqmllanguage::revisionOverloads()
+{
+ {
+ QQmlComponent component(&engine, TEST_FILE("allowedRevisionOverloads.qml"));
+ VERIFY_ERRORS(0);
+ }
+ {
+ QQmlComponent component(&engine, TEST_FILE("disallowedRevisionOverloads.qml"));
+ QEXPECT_FAIL("", "QTBUG-13849", Abort);
+ QVERIFY(0);
+ VERIFY_ERRORS("disallowedRevisionOverloads.errors.txt");
+ }
+}
+
+void tst_qqmllanguage::initTestCase()
+{
+ QString testdataDir = QFileInfo(QFINDTESTDATA("data")).absolutePath();
+ QVERIFY2(QDir::setCurrent(testdataDir), qPrintable("Could not chdir to " + testdataDir));
+
+ registerTypes();
+
+ // Registering the TestType class in other modules should have no adverse effects
+ qmlRegisterType<TestType>("com.nokia.TestPre", 1, 0, "Test");
+
+ qmlRegisterType<TestType>("com.nokia.Test", 0, 0, "TestTP");
+ qmlRegisterType<TestType>("com.nokia.Test", 1, 0, "Test");
+ qmlRegisterType<TestType>("com.nokia.Test", 1, 5, "Test");
+ qmlRegisterType<TestType2>("com.nokia.Test", 1, 8, "Test");
+ qmlRegisterType<TestType>("com.nokia.Test", 1, 9, "OldTest");
+ qmlRegisterType<TestType2>("com.nokia.Test", 1, 12, "Test");
+
+ // Registering the TestType class in other modules should have no adverse effects
+ qmlRegisterType<TestType>("com.nokia.TestPost", 1, 0, "Test");
+
+ // Create locale-specific file
+ // For POSIX, this will just be data/I18nType.qml, since POSIX is 7-bit
+ // For iso8859-1 locale, this will just be data/I18nType?????.qml where ????? is 5 8-bit characters
+ // For utf-8 locale, this will be data/I18nType??????????.qml where ?????????? is 5 8-bit characters, UTF-8 encoded
+ QFile in(TEST_FILE(QLatin1String("I18nType30.qml")).toLocalFile());
+ QVERIFY2(in.open(QIODevice::ReadOnly), qPrintable(QString::fromLatin1("Cannot open '%1': %2").arg(in.fileName(), in.errorString())));
+ QFile out(TEST_FILE(QString::fromUtf8("I18nType\303\201\303\242\303\243\303\244\303\245.qml")).toLocalFile());
+ QVERIFY2(out.open(QIODevice::WriteOnly), qPrintable(QString::fromLatin1("Cannot open '%1': %2").arg(out.fileName(), out.errorString())));
+ out.write(in.readAll());
+}
+
+void tst_qqmllanguage::aliasPropertyChangeSignals()
+{
+ {
+ QQmlComponent component(&engine, TEST_FILE("aliasPropertyChangeSignals.qml"));
+
+ VERIFY_ERRORS(0);
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+
+ // QTCREATORBUG-2769
+ {
+ QQmlComponent component(&engine, TEST_FILE("aliasPropertyChangeSignals.2.qml"));
+
+ VERIFY_ERRORS(0);
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+ }
+}
+
+// Tests property initializers
+void tst_qqmllanguage::propertyInit()
+{
+ {
+ QQmlComponent component(&engine, TEST_FILE("propertyInit.1.qml"));
+
+ VERIFY_ERRORS(0);
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toInt(), 1);
+
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, TEST_FILE("propertyInit.2.qml"));
+
+ VERIFY_ERRORS(0);
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toInt(), 123);
+
+ delete o;
+ }
+}
+
+// Test that registration order doesn't break type availability
+// QTBUG-16878
+void tst_qqmllanguage::registrationOrder()
+{
+ QQmlComponent component(&engine, TEST_FILE("registrationOrder.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QVERIFY(o->metaObject() == &MyVersion2Class::staticMetaObject);
+ delete o;
+}
+
+void tst_qqmllanguage::readonly()
+{
+ QQmlComponent component(&engine, TEST_FILE("readonly.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toInt(), 10);
+ QCOMPARE(o->property("test2").toInt(), 18);
+ QCOMPARE(o->property("test3").toInt(), 13);
+
+ o->setProperty("testData", 13);
+
+ QCOMPARE(o->property("test1").toInt(), 10);
+ QCOMPARE(o->property("test2").toInt(), 22);
+ QCOMPARE(o->property("test3").toInt(), 13);
+
+ o->setProperty("testData2", 2);
+
+ QCOMPARE(o->property("test1").toInt(), 10);
+ QCOMPARE(o->property("test2").toInt(), 22);
+ QCOMPARE(o->property("test3").toInt(), 2);
+
+ o->setProperty("test1", 11);
+ o->setProperty("test2", 11);
+ o->setProperty("test3", 11);
+
+ QCOMPARE(o->property("test1").toInt(), 10);
+ QCOMPARE(o->property("test2").toInt(), 22);
+ QCOMPARE(o->property("test3").toInt(), 2);
+
+ delete o;
+}
+
+// QTBUG-18268
+void tst_qqmllanguage::remoteLoadCrash()
+{
+ TestHTTPServer server(14448);
+ server.serveDirectory(testdata());
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Text {}", QUrl("http://127.0.0.1:14448/remoteLoadCrash.qml"));
+ while (component.isLoading())
+ QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents, 50);
+
+ QObject *o = component.create();
+ delete o;
+}
+
+QTEST_MAIN(tst_qqmllanguage)
+
+#include "tst_qqmllanguage.moc"
diff --git a/tests/auto/declarative/qdeclarativelistreference/data/MyType.qml b/tests/auto/qml/qqmllistreference/data/MyType.qml
index f48a77598c..f48a77598c 100644
--- a/tests/auto/declarative/qdeclarativelistreference/data/MyType.qml
+++ b/tests/auto/qml/qqmllistreference/data/MyType.qml
diff --git a/tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml b/tests/auto/qml/qqmllistreference/data/engineTypes.qml
index 99a61a7680..99a61a7680 100644
--- a/tests/auto/declarative/qdeclarativelistreference/data/engineTypes.qml
+++ b/tests/auto/qml/qqmllistreference/data/engineTypes.qml
diff --git a/tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml b/tests/auto/qml/qqmllistreference/data/variantToList.qml
index 3728cd0311..3728cd0311 100644
--- a/tests/auto/declarative/qdeclarativelistreference/data/variantToList.qml
+++ b/tests/auto/qml/qqmllistreference/data/variantToList.qml
diff --git a/tests/auto/qml/qqmllistreference/qqmllistreference.pro b/tests/auto/qml/qqmllistreference/qqmllistreference.pro
new file mode 100644
index 0000000000..baca1e7c71
--- /dev/null
+++ b/tests/auto/qml/qqmllistreference/qqmllistreference.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmllistreference
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmllistreference.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private testlib
diff --git a/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp
new file mode 100644
index 0000000000..bcb8ee8963
--- /dev/null
+++ b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp
@@ -0,0 +1,570 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QUrl>
+#include <QFileInfo>
+#include <QDir>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QtQml/qqml.h>
+#include <QtQml/qqmlprivate.h>
+#include <QtQml/qqmlproperty.h>
+#include <QDebug>
+#include "../../shared/util.h"
+
+class tst_qqmllistreference : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmllistreference() {}
+
+private slots:
+ void initTestCase();
+ void qmllistreference();
+ void qmllistreference_invalid();
+ void isValid();
+ void object();
+ void listElementType();
+ void canAppend();
+ void canAt();
+ void canClear();
+ void canCount();
+ void append();
+ void at();
+ void clear();
+ void count();
+ void copy();
+ void qmlmetaproperty();
+ void engineTypes();
+ void variantToList();
+};
+
+class TestType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<TestType> data READ dataProperty)
+ Q_PROPERTY(int intProperty READ intProperty)
+
+public:
+ TestType() : property(this, data) {}
+ QQmlListProperty<TestType> dataProperty() { return property; }
+ int intProperty() const { return 10; }
+
+ QList<TestType *> data;
+ QQmlListProperty<TestType> property;
+};
+
+void tst_qqmllistreference::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ qmlRegisterType<TestType>();
+}
+
+void tst_qqmllistreference::qmllistreference()
+{
+ TestType tt;
+
+ QQmlListReference r(&tt, "data");
+ QVERIFY(r.isValid() == true);
+ QCOMPARE(r.count(), 0);
+
+ tt.data.append(&tt);
+ QCOMPARE(r.count(), 1);
+}
+
+void tst_qqmllistreference::qmllistreference_invalid()
+{
+ TestType tt;
+
+ // Invalid
+ {
+ QQmlListReference r;
+ QVERIFY(r.isValid() == false);
+ QVERIFY(r.object() == 0);
+ QVERIFY(r.listElementType() == 0);
+ QVERIFY(r.canAt() == false);
+ QVERIFY(r.canClear() == false);
+ QVERIFY(r.canCount() == false);
+ QVERIFY(r.append(0) == false);
+ QVERIFY(r.at(10) == 0);
+ QVERIFY(r.clear() == false);
+ QVERIFY(r.count() == 0);
+ }
+
+ // Non-property
+ {
+ QQmlListReference r(&tt, "blah");
+ QVERIFY(r.isValid() == false);
+ QVERIFY(r.object() == 0);
+ QVERIFY(r.listElementType() == 0);
+ QVERIFY(r.canAt() == false);
+ QVERIFY(r.canClear() == false);
+ QVERIFY(r.canCount() == false);
+ QVERIFY(r.append(0) == false);
+ QVERIFY(r.at(10) == 0);
+ QVERIFY(r.clear() == false);
+ QVERIFY(r.count() == 0);
+ }
+
+ // Non-list property
+ {
+ QQmlListReference r(&tt, "intProperty");
+ QVERIFY(r.isValid() == false);
+ QVERIFY(r.object() == 0);
+ QVERIFY(r.listElementType() == 0);
+ QVERIFY(r.canAt() == false);
+ QVERIFY(r.canClear() == false);
+ QVERIFY(r.canCount() == false);
+ QVERIFY(r.append(0) == false);
+ QVERIFY(r.at(10) == 0);
+ QVERIFY(r.clear() == false);
+ QVERIFY(r.count() == 0);
+ }
+}
+
+void tst_qqmllistreference::isValid()
+{
+ TestType *tt = new TestType;
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.isValid() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.isValid() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.isValid() == true);
+ delete tt;
+ QVERIFY(ref.isValid() == false);
+ }
+}
+
+void tst_qqmllistreference::object()
+{
+ TestType *tt = new TestType;
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.object() == 0);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.object() == 0);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.object() == tt);
+ delete tt;
+ QVERIFY(ref.object() == 0);
+ }
+}
+
+void tst_qqmllistreference::listElementType()
+{
+ TestType *tt = new TestType;
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.listElementType() == 0);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.listElementType() == 0);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
+ delete tt;
+ QVERIFY(ref.listElementType() == 0);
+ }
+}
+
+void tst_qqmllistreference::canAppend()
+{
+ TestType *tt = new TestType;
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.canAppend() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.canAppend() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.canAppend() == true);
+ delete tt;
+ QVERIFY(ref.canAppend() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.append = 0;
+ QQmlListReference ref(&tt, "data");
+ QVERIFY(ref.canAppend() == false);
+ }
+}
+
+void tst_qqmllistreference::canAt()
+{
+ TestType *tt = new TestType;
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.canAt() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.canAt() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.canAt() == true);
+ delete tt;
+ QVERIFY(ref.canAt() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.at = 0;
+ QQmlListReference ref(&tt, "data");
+ QVERIFY(ref.canAt() == false);
+ }
+}
+
+void tst_qqmllistreference::canClear()
+{
+ TestType *tt = new TestType;
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.canClear() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.canClear() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.canClear() == true);
+ delete tt;
+ QVERIFY(ref.canClear() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.clear = 0;
+ QQmlListReference ref(&tt, "data");
+ QVERIFY(ref.canClear() == false);
+ }
+}
+
+void tst_qqmllistreference::canCount()
+{
+ TestType *tt = new TestType;
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.canCount() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.canCount() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.canCount() == true);
+ delete tt;
+ QVERIFY(ref.canCount() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.count = 0;
+ QQmlListReference ref(&tt, "data");
+ QVERIFY(ref.canCount() == false);
+ }
+}
+
+void tst_qqmllistreference::append()
+{
+ TestType *tt = new TestType;
+ QObject object;
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.append(tt) == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.append(tt) == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.append(tt) == true);
+ QVERIFY(tt->data.count() == 1);
+ QVERIFY(tt->data.at(0) == tt);
+ QVERIFY(ref.append(&object) == false);
+ QVERIFY(tt->data.count() == 1);
+ QVERIFY(tt->data.at(0) == tt);
+ QVERIFY(ref.append(0) == true);
+ QVERIFY(tt->data.count() == 2);
+ QVERIFY(tt->data.at(0) == tt);
+ QVERIFY(tt->data.at(1) == 0);
+ delete tt;
+ QVERIFY(ref.append(0) == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.append = 0;
+ QQmlListReference ref(&tt, "data");
+ QVERIFY(ref.append(&tt) == false);
+ }
+}
+
+void tst_qqmllistreference::at()
+{
+ TestType *tt = new TestType;
+ tt->data.append(tt);
+ tt->data.append(0);
+ tt->data.append(tt);
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.at(0) == 0);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.at(0) == 0);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.at(0) == tt);
+ QVERIFY(ref.at(1) == 0);
+ QVERIFY(ref.at(2) == tt);
+ delete tt;
+ QVERIFY(ref.at(0) == 0);
+ }
+
+ {
+ TestType tt;
+ tt.data.append(&tt);
+ tt.property.at = 0;
+ QQmlListReference ref(&tt, "data");
+ QVERIFY(ref.at(0) == 0);
+ }
+}
+
+void tst_qqmllistreference::clear()
+{
+ TestType *tt = new TestType;
+ tt->data.append(tt);
+ tt->data.append(0);
+ tt->data.append(tt);
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.clear() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.clear() == false);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.clear() == true);
+ QVERIFY(tt->data.count() == 0);
+ delete tt;
+ QVERIFY(ref.clear() == false);
+ }
+
+ {
+ TestType tt;
+ tt.property.clear = 0;
+ QQmlListReference ref(&tt, "data");
+ QVERIFY(ref.clear() == false);
+ }
+}
+
+void tst_qqmllistreference::count()
+{
+ TestType *tt = new TestType;
+ tt->data.append(tt);
+ tt->data.append(0);
+ tt->data.append(tt);
+
+ {
+ QQmlListReference ref;
+ QVERIFY(ref.count() == 0);
+ }
+
+ {
+ QQmlListReference ref(tt, "blah");
+ QVERIFY(ref.count() == 0);
+ }
+
+ {
+ QQmlListReference ref(tt, "data");
+ QVERIFY(ref.count() == 3);
+ tt->data.removeAt(1);
+ QVERIFY(ref.count() == 2);
+ delete tt;
+ QVERIFY(ref.count() == 0);
+ }
+
+ {
+ TestType tt;
+ tt.data.append(&tt);
+ tt.property.count = 0;
+ QQmlListReference ref(&tt, "data");
+ QVERIFY(ref.count() == 0);
+ }
+}
+
+void tst_qqmllistreference::copy()
+{
+ TestType tt;
+ tt.data.append(&tt);
+ tt.data.append(0);
+ tt.data.append(&tt);
+
+ QQmlListReference *r1 = new QQmlListReference(&tt, "data");
+ QVERIFY(r1->count() == 3);
+
+ QQmlListReference r2(*r1);
+ QQmlListReference r3;
+ r3 = *r1;
+
+ QVERIFY(r2.count() == 3);
+ QVERIFY(r3.count() == 3);
+
+ delete r1;
+
+ QVERIFY(r2.count() == 3);
+ QVERIFY(r3.count() == 3);
+
+ tt.data.removeAt(2);
+
+ QVERIFY(r2.count() == 2);
+ QVERIFY(r3.count() == 2);
+}
+
+void tst_qqmllistreference::qmlmetaproperty()
+{
+ TestType tt;
+ tt.data.append(&tt);
+ tt.data.append(0);
+ tt.data.append(&tt);
+
+ QQmlProperty prop(&tt, QLatin1String("data"));
+ QVariant v = prop.read();
+ QVERIFY(v.userType() == qMetaTypeId<QQmlListReference>());
+ QQmlListReference ref = qvariant_cast<QQmlListReference>(v);
+ QVERIFY(ref.count() == 3);
+ QVERIFY(ref.listElementType() == &TestType::staticMetaObject);
+}
+
+void tst_qqmllistreference::engineTypes()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("engineTypes.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o);
+
+ QQmlProperty p1(o, QLatin1String("myList"));
+ QVERIFY(p1.propertyTypeCategory() == QQmlProperty::Normal);
+
+ QQmlProperty p2(o, QLatin1String("myList"), engine.rootContext());
+ QVERIFY(p2.propertyTypeCategory() == QQmlProperty::List);
+ QVariant v = p2.read();
+ QVERIFY(v.userType() == qMetaTypeId<QQmlListReference>());
+ QQmlListReference ref = qvariant_cast<QQmlListReference>(v);
+ QVERIFY(ref.count() == 2);
+ QVERIFY(ref.listElementType());
+ QVERIFY(ref.listElementType() != &QObject::staticMetaObject);
+
+ delete o;
+}
+
+void tst_qqmllistreference::variantToList()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("variantToList.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o);
+
+ QVERIFY(o->property("value").userType() == qMetaTypeId<QQmlListReference>());
+ QCOMPARE(o->property("test").toInt(), 1);
+
+ delete o;
+}
+
+QTEST_MAIN(tst_qqmllistreference)
+
+#include "tst_qqmllistreference.moc"
diff --git a/tests/auto/declarative/qdeclarativelocale/data/date.qml b/tests/auto/qml/qqmllocale/data/date.qml
index 3f58497d22..3f58497d22 100644
--- a/tests/auto/declarative/qdeclarativelocale/data/date.qml
+++ b/tests/auto/qml/qqmllocale/data/date.qml
diff --git a/tests/auto/declarative/qdeclarativelocale/data/functions.qml b/tests/auto/qml/qqmllocale/data/functions.qml
index 5fef6a26fb..5fef6a26fb 100644
--- a/tests/auto/declarative/qdeclarativelocale/data/functions.qml
+++ b/tests/auto/qml/qqmllocale/data/functions.qml
diff --git a/tests/auto/declarative/qdeclarativelocale/data/localeCompare.qml b/tests/auto/qml/qqmllocale/data/localeCompare.qml
index 6851af6ef9..6851af6ef9 100644
--- a/tests/auto/declarative/qdeclarativelocale/data/localeCompare.qml
+++ b/tests/auto/qml/qqmllocale/data/localeCompare.qml
diff --git a/tests/auto/declarative/qdeclarativelocale/data/number.qml b/tests/auto/qml/qqmllocale/data/number.qml
index 51a6c15dce..51a6c15dce 100644
--- a/tests/auto/declarative/qdeclarativelocale/data/number.qml
+++ b/tests/auto/qml/qqmllocale/data/number.qml
diff --git a/tests/auto/declarative/qdeclarativelocale/data/properties.qml b/tests/auto/qml/qqmllocale/data/properties.qml
index 16d1f4092a..16d1f4092a 100644
--- a/tests/auto/declarative/qdeclarativelocale/data/properties.qml
+++ b/tests/auto/qml/qqmllocale/data/properties.qml
diff --git a/tests/auto/qml/qqmllocale/qqmllocale.pro b/tests/auto/qml/qqmllocale/qqmllocale.pro
new file mode 100644
index 0000000000..1773f83f91
--- /dev/null
+++ b/tests/auto/qml/qqmllocale/qqmllocale.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmllocale
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmllocale.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += qml testlib
diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
new file mode 100644
index 0000000000..af1a81847b
--- /dev/null
+++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp
@@ -0,0 +1,1183 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QDebug>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtCore/QDateTime>
+#include <qcolor.h>
+#include "../../shared/util.h"
+
+class tst_qqmllocale : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmllocale() { }
+
+private slots:
+ void defaultLocale();
+
+ void properties_data();
+ void properties();
+ void currencySymbol_data();
+ void currencySymbol();
+ void monthName_data();
+ void monthName();
+ void standaloneMonthName_data();
+ void standaloneMonthName();
+ void dayName_data();
+ void dayName();
+ void standaloneDayName_data();
+ void standaloneDayName();
+ void weekDays_data();
+ void weekDays();
+ void uiLanguages_data();
+ void uiLanguages();
+ void dateFormat_data();
+ void dateFormat();
+ void dateTimeFormat_data();
+ void dateTimeFormat();
+ void timeFormat_data();
+ void timeFormat();
+
+ void dateToLocaleString_data();
+ void dateToLocaleString();
+ void dateToLocaleStringFormatted_data();
+ void dateToLocaleStringFormatted();
+ void dateToLocaleDateString_data();
+ void dateToLocaleDateString();
+ void dateToLocaleDateStringFormatted_data();
+ void dateToLocaleDateStringFormatted();
+ void dateToLocaleTimeString_data();
+ void dateToLocaleTimeString();
+ void dateToLocaleTimeStringFormatted_data();
+ void dateToLocaleTimeStringFormatted();
+ void dateFromLocaleString_data();
+ void dateFromLocaleString();
+ void dateFromLocaleDateString_data();
+ void dateFromLocaleDateString();
+ void dateFromLocaleTimeString_data();
+ void dateFromLocaleTimeString();
+
+ void numberToLocaleString_data();
+ void numberToLocaleString();
+ void numberToLocaleCurrencyString_data();
+ void numberToLocaleCurrencyString();
+ void numberFromLocaleString_data();
+ void numberFromLocaleString();
+ void numberConstToLocaleString();
+
+ void stringLocaleCompare_data();
+ void stringLocaleCompare();
+
+private:
+ void addPropertyData(const QString &l);
+ QVariant getProperty(QObject *obj, const QString &locale, const QString &property);
+ void addCurrencySymbolData(const QString &locale);
+ void addStandardFormatData();
+ void addFormatNameData(const QString &locale);
+ void addDateTimeFormatData(const QString &l);
+ void addDateFormatData(const QString &l);
+ void addTimeFormatData(const QString &l);
+ QQmlEngine engine;
+};
+
+void tst_qqmllocale::defaultLocale()
+{
+ QQmlComponent c(&engine, testFileUrl("properties.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QCOMPARE(obj->property("name").toString(), QLocale().name());
+}
+
+#define LOCALE_PROP(type,prop) { #prop, QVariant(type(qlocale.prop())) }
+
+void tst_qqmllocale::addPropertyData(const QString &l)
+{
+ QLocale qlocale(l);
+
+ struct {
+ const char *name;
+ QVariant value;
+ }
+ values[] = {
+ LOCALE_PROP(QString,name),
+ LOCALE_PROP(QString,amText),
+ LOCALE_PROP(QString,pmText),
+ LOCALE_PROP(QString,nativeLanguageName),
+ LOCALE_PROP(QString,nativeCountryName),
+ LOCALE_PROP(QString,decimalPoint),
+ LOCALE_PROP(QString,groupSeparator),
+ LOCALE_PROP(QString,percent),
+ LOCALE_PROP(QString,zeroDigit),
+ LOCALE_PROP(QString,negativeSign),
+ LOCALE_PROP(QString,positiveSign),
+ LOCALE_PROP(QString,exponential),
+ LOCALE_PROP(int,firstDayOfWeek),
+ LOCALE_PROP(int,measurementSystem),
+ LOCALE_PROP(int,textDirection),
+ { 0, QVariant() }
+ };
+
+ int i = 0;
+ while (values[i].name) {
+ QByteArray n = l.toLatin1() + ':' + values[i].name;
+ QTest::newRow(n.constData()) << l << QByteArray(values[i].name) << values[i].value;
+ ++i;
+ }
+}
+
+void tst_qqmllocale::properties_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<QByteArray>("property");
+ QTest::addColumn<QVariant>("value");
+
+ addPropertyData("en_US");
+ addPropertyData("de_DE");
+ addPropertyData("ar_SA");
+ addPropertyData("hi_IN");
+ addPropertyData("zh_CN");
+ addPropertyData("th_TH");
+}
+
+void tst_qqmllocale::properties()
+{
+ QFETCH(QString, locale);
+ QFETCH(QByteArray, property);
+ QFETCH(QVariant, value);
+
+ QQmlComponent c(&engine, testFileUrl("properties.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QCOMPARE(obj->property(property), value);
+
+ delete obj;
+}
+
+void tst_qqmllocale::addCurrencySymbolData(const QString &l)
+{
+ QByteArray locale = l.toLatin1();
+ QTest::newRow(locale.constData()) << l << -1;
+ QByteArray t(locale);
+ t += " CurrencyIsoCode";
+ QTest::newRow(t.constData()) << l << (int)QLocale::CurrencyIsoCode;
+ t = locale + " CurrencySymbol";
+ QTest::newRow(t.constData()) << l << (int)QLocale::CurrencySymbol;
+ t = locale + " CurrencyDisplayName";
+ QTest::newRow(t.constData()) << l << (int)QLocale::CurrencyDisplayName;
+}
+
+void tst_qqmllocale::currencySymbol_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<int>("param");
+
+ addCurrencySymbolData("en_US");
+ addCurrencySymbolData("de_DE");
+ addCurrencySymbolData("ar_SA");
+ addCurrencySymbolData("hi_IN");
+ addCurrencySymbolData("zh_CN");
+ addCurrencySymbolData("th_TH");
+}
+
+void tst_qqmllocale::currencySymbol()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("functions.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QVariant val;
+ QLocale::CurrencySymbolFormat format = QLocale::CurrencySymbol;
+
+ if (param >= 0)
+ format = QLocale::CurrencySymbolFormat(param);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QMetaObject::invokeMethod(obj, "currencySymbol", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(int(format))));
+
+ QCOMPARE(val.toString(), l.currencySymbol(format));
+
+ delete obj;
+}
+
+void tst_qqmllocale::addFormatNameData(const QString &l)
+{
+ QByteArray locale = l.toLatin1();
+ QTest::newRow(locale.constData()) << l << -1;
+ QByteArray t(locale);
+ t += " LongFormat";
+ QTest::newRow(t.constData()) << l << (int)QLocale::LongFormat;
+ t = locale + " ShortFormat";
+ QTest::newRow(t.constData()) << l << (int)QLocale::ShortFormat;
+ t = locale + " NarrowFormat";
+ QTest::newRow(t.constData()) << l << (int)QLocale::NarrowFormat;
+}
+
+void tst_qqmllocale::addStandardFormatData()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<int>("param");
+
+ addFormatNameData("en_US");
+ addFormatNameData("de_DE");
+ addFormatNameData("ar_SA");
+ addFormatNameData("hi_IN");
+ addFormatNameData("zh_CN");
+ addFormatNameData("th_TH");
+}
+
+void tst_qqmllocale::monthName_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::monthName()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("functions.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QVariant val;
+ QLocale::FormatType format = QLocale::LongFormat;
+ if (param >= 0)
+ format = QLocale::FormatType(param);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ for (int i = 0; i <= 11; ++i) {
+ QMetaObject::invokeMethod(obj, "monthName", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(i)),
+ Q_ARG(QVariant, QVariant(int(format))));
+
+ // QLocale January == 1, JS Date January == 0
+ QCOMPARE(val.toString(), l.monthName(i+1, format));
+ }
+
+ delete obj;
+}
+
+void tst_qqmllocale::standaloneMonthName_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::standaloneMonthName()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("functions.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QVariant val;
+ QLocale::FormatType format = QLocale::LongFormat;
+ if (param >= 0)
+ format = QLocale::FormatType(param);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ for (int i = 0; i <= 11; ++i) {
+ QMetaObject::invokeMethod(obj, "standaloneMonthName", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(i)),
+ Q_ARG(QVariant, QVariant(int(format))));
+
+ // QLocale January == 1, JS Date January == 0
+ QCOMPARE(val.toString(), l.standaloneMonthName(i+1, format));
+ }
+
+ delete obj;
+}
+
+void tst_qqmllocale::dayName_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::dayName()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("functions.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QVariant val;
+ QLocale::FormatType format = QLocale::LongFormat;
+ if (param >= 0)
+ format = QLocale::FormatType(param);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ for (int i = 1; i <= 7; ++i) {
+ QMetaObject::invokeMethod(obj, "dayName", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(i)),
+ Q_ARG(QVariant, QVariant(int(format))));
+
+ QCOMPARE(val.toString(), l.dayName(i, format));
+ }
+
+ delete obj;
+}
+
+void tst_qqmllocale::standaloneDayName_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::standaloneDayName()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("functions.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QVariant val;
+ QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ for (int i = 1; i <= 7; ++i) {
+ QMetaObject::invokeMethod(obj, "standaloneDayName", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(i)),
+ Q_ARG(QVariant, QVariant(int(format))));
+
+ QCOMPARE(val.toString(), l.standaloneDayName(i, format));
+ }
+
+ delete obj;
+}
+
+void tst_qqmllocale::weekDays_data()
+{
+ QTest::addColumn<QString>("locale");
+
+ QTest::newRow("en_US") << "en_US";
+ QTest::newRow("de_DE") << "de_DE";
+ QTest::newRow("ar_SA") << "ar_SA";
+ QTest::newRow("hi_IN") << "hi_IN";
+ QTest::newRow("zh_CN") << "zh_CN";
+ QTest::newRow("th_TH") << "th_TH";
+}
+
+void tst_qqmllocale::weekDays()
+{
+ QFETCH(QString, locale);
+
+ QQmlComponent c(&engine, testFileUrl("properties.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QVariant val = obj->property("weekDays");
+ QVERIFY(val.type() == QVariant::List);
+
+ QList<QVariant> qmlDays = val.toList();
+ QList<Qt::DayOfWeek> days = QLocale(locale).weekdays();
+
+ QVERIFY(days.count() == qmlDays.count());
+
+ for (int i = 0; i < days.count(); ++i) {
+ int day = int(days.at(i));
+ if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday)
+ day = 0;
+ QCOMPARE(day, qmlDays.at(i).toInt());
+ }
+
+ delete obj;
+}
+
+void tst_qqmllocale::uiLanguages_data()
+{
+ QTest::addColumn<QString>("locale");
+
+ QTest::newRow("en_US") << "en_US";
+ QTest::newRow("de_DE") << "de_DE";
+ QTest::newRow("ar_SA") << "ar_SA";
+ QTest::newRow("hi_IN") << "hi_IN";
+ QTest::newRow("zh_CN") << "zh_CN";
+ QTest::newRow("th_TH") << "th_TH";
+}
+
+void tst_qqmllocale::uiLanguages()
+{
+ QFETCH(QString, locale);
+
+ QQmlComponent c(&engine, testFileUrl("properties.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QVariant val = obj->property("uiLanguages");
+ QVERIFY(val.type() == QVariant::List);
+
+ QList<QVariant> qmlLangs = val.toList();
+ QStringList langs = QLocale(locale).uiLanguages();
+
+ QVERIFY(langs.count() == qmlLangs.count());
+
+ for (int i = 0; i < langs.count(); ++i) {
+ QCOMPARE(langs.at(i), qmlLangs.at(i).toString());
+ }
+
+ delete obj;
+}
+
+
+void tst_qqmllocale::dateTimeFormat_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::dateTimeFormat()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("functions.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QVariant val;
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
+ QMetaObject::invokeMethod(obj, "dateTimeFormat", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(param)));
+
+ QCOMPARE(val.toString(), l.dateTimeFormat(format));
+}
+
+void tst_qqmllocale::dateFormat_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::dateFormat()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("functions.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QVariant val;
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
+ QMetaObject::invokeMethod(obj, "dateFormat", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(param)));
+
+ QCOMPARE(val.toString(), l.dateFormat(format));
+}
+
+void tst_qqmllocale::timeFormat_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::timeFormat()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("functions.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QVariant val;
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
+ QMetaObject::invokeMethod(obj, "timeFormat", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(param)));
+
+ QCOMPARE(val.toString(), l.timeFormat(format));
+}
+
+void tst_qqmllocale::dateToLocaleString_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::dateToLocaleString()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
+
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(param)));
+
+ QLocale l(locale);
+ QCOMPARE(val.toString(), l.toString(dt, format));
+}
+
+void tst_qqmllocale::addDateTimeFormatData(const QString &l)
+{
+ const char *formats[] = {
+ "hh:mm dd.MM.yyyy",
+ "h:m:sap ddd MMMM d yy",
+ "'The date and time is: 'H:mm:ss:zzz dd/MM/yy",
+ "MMM d yyyy HH:mm t",
+ 0
+ };
+ QByteArray locale = l.toLatin1();
+ int i = 0;
+ while (formats[i]) {
+ QByteArray t(locale);
+ t += " ";
+ t += formats[i];
+ QTest::newRow(t.constData()) << l << QString(formats[i]);
+ ++i;
+ }
+}
+
+void tst_qqmllocale::dateToLocaleStringFormatted_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<QString>("format");
+
+ addDateTimeFormatData("en_US");
+ addDateTimeFormatData("de_DE");
+ addDateTimeFormatData("ar_SA");
+ addDateTimeFormatData("hi_IN");
+ addDateTimeFormatData("zh_CN");
+ addDateTimeFormatData("th_TH");
+}
+
+void tst_qqmllocale::dateToLocaleStringFormatted()
+{
+ QFETCH(QString, locale);
+ QFETCH(QString, format);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(format)));
+
+ QLocale l(locale);
+ QCOMPARE(val.toString(), l.toString(dt, format));
+}
+
+void tst_qqmllocale::dateToLocaleDateString_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::dateToLocaleDateString()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
+
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "toLocaleDateString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(param)));
+
+ QLocale l(locale);
+ QCOMPARE(val.toString(), l.toString(dt.date(), format));
+}
+
+void tst_qqmllocale::addDateFormatData(const QString &l)
+{
+ const char *formats[] = {
+ "dd.MM.yyyy",
+ "ddd MMMM d yy",
+ "'The date is: 'dd/MM/yy",
+ "MMM d yyyy",
+ 0
+ };
+ QByteArray locale = l.toLatin1();
+ int i = 0;
+ while (formats[i]) {
+ QByteArray t(locale);
+ t += " ";
+ t += formats[i];
+ QTest::newRow(t.constData()) << l << QString(formats[i]);
+ ++i;
+ }
+}
+
+void tst_qqmllocale::dateToLocaleDateStringFormatted_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<QString>("format");
+
+ addDateFormatData("en_US");
+ addDateFormatData("de_DE");
+ addDateFormatData("ar_SA");
+ addDateFormatData("hi_IN");
+ addDateFormatData("zh_CN");
+ addDateFormatData("th_TH");
+}
+
+void tst_qqmllocale::dateToLocaleDateStringFormatted()
+{
+ QFETCH(QString, locale);
+ QFETCH(QString, format);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(format)));
+
+ QLocale l(locale);
+ QCOMPARE(val.toString(), l.toString(dt.date(), format));
+}
+
+void tst_qqmllocale::dateToLocaleTimeString_data()
+{
+ addStandardFormatData();
+}
+
+void tst_qqmllocale::dateToLocaleTimeString()
+{
+ QFETCH(QString, locale);
+ QFETCH(int, param);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale::FormatType format = param < 0 ? QLocale::LongFormat : QLocale::FormatType(param);
+
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "toLocaleTimeString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(param)));
+
+ QLocale l(locale);
+ QCOMPARE(val.toString(), l.toString(dt.time(), format));
+}
+
+void tst_qqmllocale::addTimeFormatData(const QString &l)
+{
+ const char *formats[] = {
+ "hh:mm",
+ "h:m:sap",
+ "'The time is: 'H:mm:ss:zzz",
+ "HH:mm t",
+ 0
+ };
+ QByteArray locale = l.toLatin1();
+ int i = 0;
+ while (formats[i]) {
+ QByteArray t(locale);
+ t += " ";
+ t += formats[i];
+ QTest::newRow(t.constData()) << l << QString(formats[i]);
+ ++i;
+ }
+}
+
+void tst_qqmllocale::dateToLocaleTimeStringFormatted_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<QString>("format");
+
+ addTimeFormatData("en_US");
+ addTimeFormatData("de_DE");
+ addTimeFormatData("ar_SA");
+ addTimeFormatData("hi_IN");
+ addTimeFormatData("zh_CN");
+ addTimeFormatData("th_TH");
+}
+
+void tst_qqmllocale::dateToLocaleTimeStringFormatted()
+{
+ QFETCH(QString, locale);
+ QFETCH(QString, format);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7)); // weirdly, JS Date month range is 0-11
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(format)));
+
+ QLocale l(locale);
+ QCOMPARE(val.toString(), l.toString(dt.time(), format));
+}
+
+void tst_qqmllocale::dateFromLocaleString_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<QString>("format");
+
+ QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP";
+ QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat();
+ QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat();
+ QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat();
+ QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat();
+ QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat);
+}
+
+void tst_qqmllocale::dateFromLocaleString()
+{
+ QFETCH(QString, locale);
+ QFETCH(QString, format);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7));
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale l(locale);
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "fromLocaleString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(l.toString(dt, format))),
+ Q_ARG(QVariant, QVariant(format)));
+
+ QDateTime pd = l.toDateTime(l.toString(dt, format), format);
+ QCOMPARE(val.toDateTime(), pd);
+}
+
+void tst_qqmllocale::dateFromLocaleDateString_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<QString>("format");
+
+ QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP";
+ QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat();
+ QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat();
+ QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat();
+ QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat();
+ QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat);
+}
+
+void tst_qqmllocale::dateFromLocaleDateString()
+{
+ QFETCH(QString, locale);
+ QFETCH(QString, format);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7));
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale l(locale);
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "fromLocaleDateString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(l.toString(dt, format))),
+ Q_ARG(QVariant, QVariant(format)));
+
+ QDate pd = l.toDate(l.toString(dt, format), format);
+ QCOMPARE(val.toDate(), pd);
+}
+
+void tst_qqmllocale::dateFromLocaleTimeString_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<QString>("format");
+
+ QTest::newRow("en_US 1") << "en_US" << "dddd, MMMM d, yyyy h:mm:ss AP";
+ QTest::newRow("en_US long") << "en_US" << QLocale("en_US").dateTimeFormat();
+ QTest::newRow("en_US short") << "en_US" << QLocale("en_US").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("de_DE long") << "de_DE" << QLocale("de_DE").dateTimeFormat();
+ QTest::newRow("de_DE short") << "de_DE" << QLocale("de_DE").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("ar_SA long") << "ar_SA" << QLocale("ar_SA").dateTimeFormat();
+ QTest::newRow("ar_SA short") << "ar_SA" << QLocale("ar_SA").dateTimeFormat(QLocale::ShortFormat);
+ QTest::newRow("zh_CN long") << "zh_CN" << QLocale("zh_CN").dateTimeFormat();
+ QTest::newRow("zh_CN short") << "zh_CN" << QLocale("zh_CN").dateTimeFormat(QLocale::ShortFormat);
+}
+
+void tst_qqmllocale::dateFromLocaleTimeString()
+{
+ QFETCH(QString, locale);
+ QFETCH(QString, format);
+
+ QQmlComponent c(&engine, testFileUrl("date.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QDateTime dt;
+ dt.setDate(QDate(2011, 10, 7));
+ dt.setTime(QTime(18, 53, 48, 345));
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale l(locale);
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "fromLocaleTimeString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(l.toString(dt, format))),
+ Q_ARG(QVariant, QVariant(format)));
+
+ QTime pd = l.toTime(l.toString(dt, format), format);
+ QCOMPARE(val.toTime(), pd);
+}
+
+void tst_qqmllocale::numberToLocaleString_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<char>("format");
+ QTest::addColumn<int>("prec");
+
+ QTest::newRow("en_US 1") << "en_US" << 'f' << 2;
+ QTest::newRow("en_US 2") << "en_US" << 'g' << 3;
+ QTest::newRow("en_US 3") << "en_US" << 'f' << 0;
+ QTest::newRow("en_US 4") << "en_US" << 'f' << -1;
+ QTest::newRow("de_DE 1") << "de_DE" << 'f' << 2;
+ QTest::newRow("de_DE 2") << "de_DE" << 'g' << 3;
+ QTest::newRow("ar_SA 1") << "ar_SA" << 'f' << 2;
+ QTest::newRow("ar_SA 2") << "ar_SA" << 'g' << 3;
+}
+
+void tst_qqmllocale::numberToLocaleString()
+{
+ QFETCH(QString, locale);
+ QFETCH(char, format);
+ QFETCH(int, prec);
+
+ QQmlComponent c(&engine, testFileUrl("number.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ double number = 2344423.3289;
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale l(locale);
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "toLocaleString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(number)),
+ Q_ARG(QVariant, QVariant(QString(format))),
+ Q_ARG(QVariant, QVariant(prec)));
+
+ if (prec < 0) prec = 2;
+ QCOMPARE(val.toString(), l.toString(number, format, prec));
+}
+
+void tst_qqmllocale::numberToLocaleCurrencyString_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<QString>("symbol");
+
+ QTest::newRow("en_US 1") << "en_US" << QString();
+ QTest::newRow("en_US 2") << "en_US" << "USD";
+ QTest::newRow("de_DE") << "de_DE" << QString();
+ QTest::newRow("ar_SA") << "ar_SA" << QString();
+ QTest::newRow("hi_IN") << "hi_IN" << QString();
+ QTest::newRow("zh_CN") << "zh_CN" << QString();
+ QTest::newRow("th_TH") << "th_TH" << QString();
+}
+
+void tst_qqmllocale::numberToLocaleCurrencyString()
+{
+ QFETCH(QString, locale);
+ QFETCH(QString, symbol);
+
+ QQmlComponent c(&engine, testFileUrl("number.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ double number = 2344423.3289;
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QLocale l(locale);
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "toLocaleCurrencyString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(number)),
+ Q_ARG(QVariant, QVariant(symbol)));
+
+ QCOMPARE(val.toString(), l.toCurrencyString(number, symbol));
+}
+
+void tst_qqmllocale::numberFromLocaleString_data()
+{
+ QTest::addColumn<QString>("locale");
+ QTest::addColumn<double>("number");
+
+ QTest::newRow("en_US 1") << "en_US" << 1234567.2345;
+ QTest::newRow("en_US 2") << "en_US" << 0.234;
+ QTest::newRow("en_US 3") << "en_US" << 234.0;
+ QTest::newRow("de_DE") << "de_DE" << 1234567.2345;
+ QTest::newRow("ar_SA") << "ar_SA" << 1234567.2345;
+ QTest::newRow("hi_IN") << "hi_IN" << 1234567.2345;
+ QTest::newRow("zh_CN") << "zh_CN" << 1234567.2345;
+ QTest::newRow("th_TH") << "th_TH" << 1234567.2345;
+}
+
+void tst_qqmllocale::numberFromLocaleString()
+{
+ QFETCH(QString, locale);
+ QFETCH(double, number);
+
+ QQmlComponent c(&engine, testFileUrl("number.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QLocale l(locale);
+ QString strNumber = l.toString(number, 'f');
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant(locale)));
+
+ QVariant val;
+ QMetaObject::invokeMethod(obj, "fromLocaleString", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, val),
+ Q_ARG(QVariant, QVariant(strNumber)));
+
+ QCOMPARE(val.toDouble(), l.toDouble(strNumber));
+}
+
+void tst_qqmllocale::numberConstToLocaleString()
+{
+ QQmlComponent c(&engine, testFileUrl("number.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QMetaObject::invokeMethod(obj, "setLocale", Qt::DirectConnection,
+ Q_ARG(QVariant, QVariant("en_US")));
+
+ QLocale l("en_US");
+ QCOMPARE(obj->property("const1").toString(), l.toString(1234.56, 'f', 2));
+ QCOMPARE(obj->property("const2").toString(), l.toString(1234., 'f', 2));
+}
+
+void tst_qqmllocale::stringLocaleCompare_data()
+{
+ QTest::addColumn<QString>("string1");
+ QTest::addColumn<QString>("string2");
+
+ QTest::newRow("before") << "a" << "b";
+ QTest::newRow("equal") << "a" << "a";
+ QTest::newRow("after") << "b" << "a";
+
+ // Copied from QString::localeAwareCompare tests
+ // We don't actually change locale - we just care that String.localeCompare()
+ // matches QString::localeAwareCompare();
+ QTest::newRow("swedish1") << QString("\xe5") << QString("\xe4");
+ QTest::newRow("swedish2") << QString("\xe4") << QString("\xf6");
+ QTest::newRow("swedish3") << QString("\xe5") << QString("\xf6");
+ QTest::newRow("swedish4") << QString("z") << QString("\xe5");
+
+ QTest::newRow("german1") << QString("z") << QString("\xe4");
+ QTest::newRow("german2") << QString("\xe4") << QString("\xf6");
+ QTest::newRow("german3") << QString("z") << QString("\xf6");
+}
+
+void tst_qqmllocale::stringLocaleCompare()
+{
+ QFETCH(QString, string1);
+ QFETCH(QString, string2);
+
+ QQmlComponent c(&engine, testFileUrl("localeCompare.qml"));
+
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ obj->setProperty("string1", string1);
+ obj->setProperty("string2", string2);
+
+ QCOMPARE(obj->property("comparison").toInt(), QString::localeAwareCompare(string1, string2));
+}
+
+QTEST_MAIN(tst_qqmllocale)
+
+#include "tst_qqmllocale.moc"
diff --git a/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro b/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro
new file mode 100644
index 0000000000..7c781dd9db
--- /dev/null
+++ b/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase
+TARGET = tst_qqmlmetatype
+SOURCES += tst_qqmlmetatype.cpp
+macx:CONFIG -= app_bundle
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private widgets testlib
diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
new file mode 100644
index 0000000000..6e577ec095
--- /dev/null
+++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp
@@ -0,0 +1,202 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <qqml.h>
+
+#include <private/qqmlmetatype_p.h>
+#include <private/qqmlpropertyvalueinterceptor_p.h>
+
+class tst_qqmlmetatype : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmlmetatype() {}
+
+private slots:
+ void initTestCase();
+
+ void qmlParserStatusCast();
+ void qmlPropertyValueSourceCast();
+ void qmlPropertyValueInterceptorCast();
+
+ void isList();
+
+ void defaultObject();
+};
+
+class TestType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int foo READ foo)
+
+ Q_CLASSINFO("DefaultProperty", "foo")
+public:
+ int foo() { return 0; }
+};
+QML_DECLARE_TYPE(TestType);
+
+class ParserStatusTestType : public QObject, public QQmlParserStatus
+{
+ Q_OBJECT
+ void classBegin(){}
+ void componentComplete(){}
+ Q_CLASSINFO("DefaultProperty", "foo") // Missing default property
+ Q_INTERFACES(QQmlParserStatus)
+};
+QML_DECLARE_TYPE(ParserStatusTestType);
+
+class ValueSourceTestType : public QObject, public QQmlPropertyValueSource
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlPropertyValueSource)
+public:
+ virtual void setTarget(const QQmlProperty &) {}
+};
+QML_DECLARE_TYPE(ValueSourceTestType);
+
+class ValueInterceptorTestType : public QObject, public QQmlPropertyValueInterceptor
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlPropertyValueInterceptor)
+public:
+ virtual void setTarget(const QQmlProperty &) {}
+ virtual void write(const QVariant &) {}
+};
+QML_DECLARE_TYPE(ValueInterceptorTestType);
+
+void tst_qqmlmetatype::initTestCase()
+{
+ qmlRegisterType<TestType>("Test", 1, 0, "TestType");
+ qmlRegisterType<ParserStatusTestType>("Test", 1, 0, "ParserStatusTestType");
+ qmlRegisterType<ValueSourceTestType>("Test", 1, 0, "ValueSourceTestType");
+ qmlRegisterType<ValueInterceptorTestType>("Test", 1, 0, "ValueInterceptorTestType");
+}
+
+void tst_qqmlmetatype::qmlParserStatusCast()
+{
+ QVERIFY(QQmlMetaType::qmlType(QVariant::Int) == 0);
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
+ QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>())->parserStatusCast(), -1);
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0);
+ QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>())->parserStatusCast(), -1);
+
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
+ int cast = QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->parserStatusCast();
+ QVERIFY(cast != -1);
+ QVERIFY(cast != 0);
+
+ ParserStatusTestType t;
+ QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QQmlParserStatus *)&t));
+
+ QQmlParserStatus *status = reinterpret_cast<QQmlParserStatus *>(reinterpret_cast<char *>((QObject *)&t) + cast);
+ QCOMPARE(status, (QQmlParserStatus*)&t);
+}
+
+void tst_qqmlmetatype::qmlPropertyValueSourceCast()
+{
+ QVERIFY(QQmlMetaType::qmlType(QVariant::Int) == 0);
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
+ QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueSourceCast(), -1);
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
+ QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->propertyValueSourceCast(), -1);
+
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0);
+ int cast = QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>())->propertyValueSourceCast();
+ QVERIFY(cast != -1);
+ QVERIFY(cast != 0);
+
+ ValueSourceTestType t;
+ QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QQmlPropertyValueSource *)&t));
+
+ QQmlPropertyValueSource *source = reinterpret_cast<QQmlPropertyValueSource *>(reinterpret_cast<char *>((QObject *)&t) + cast);
+ QCOMPARE(source, (QQmlPropertyValueSource*)&t);
+}
+
+void tst_qqmlmetatype::qmlPropertyValueInterceptorCast()
+{
+ QVERIFY(QQmlMetaType::qmlType(QVariant::Int) == 0);
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0);
+ QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueInterceptorCast(), -1);
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0);
+ QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>())->propertyValueInterceptorCast(), -1);
+
+ QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ValueInterceptorTestType *>()) != 0);
+ int cast = QQmlMetaType::qmlType(qMetaTypeId<ValueInterceptorTestType *>())->propertyValueInterceptorCast();
+ QVERIFY(cast != -1);
+ QVERIFY(cast != 0);
+
+ ValueInterceptorTestType t;
+ QVERIFY(reinterpret_cast<char *>((QObject *)&t) != reinterpret_cast<char *>((QQmlPropertyValueInterceptor *)&t));
+
+ QQmlPropertyValueInterceptor *interceptor = reinterpret_cast<QQmlPropertyValueInterceptor *>(reinterpret_cast<char *>((QObject *)&t) + cast);
+ QCOMPARE(interceptor, (QQmlPropertyValueInterceptor*)&t);
+}
+
+void tst_qqmlmetatype::isList()
+{
+ QCOMPARE(QQmlMetaType::isList(QVariant::Invalid), false);
+ QCOMPARE(QQmlMetaType::isList(QVariant::Int), false);
+
+ QQmlListProperty<TestType> list;
+
+ QCOMPARE(QQmlMetaType::isList(qMetaTypeId<QQmlListProperty<TestType> >()), true);
+}
+
+void tst_qqmlmetatype::defaultObject()
+{
+ QVERIFY(QQmlMetaType::defaultProperty(&QObject::staticMetaObject).name() == 0);
+ QVERIFY(QQmlMetaType::defaultProperty(&ParserStatusTestType::staticMetaObject).name() == 0);
+ QCOMPARE(QString(QQmlMetaType::defaultProperty(&TestType::staticMetaObject).name()), QString("foo"));
+
+ QObject o;
+ TestType t;
+ ParserStatusTestType p;
+
+ QVERIFY(QQmlMetaType::defaultProperty((QObject *)0).name() == 0);
+ QVERIFY(QQmlMetaType::defaultProperty(&o).name() == 0);
+ QVERIFY(QQmlMetaType::defaultProperty(&p).name() == 0);
+ QCOMPARE(QString(QQmlMetaType::defaultProperty(&t).name()), QString("foo"));
+}
+
+QTEST_MAIN(tst_qqmlmetatype)
+
+#include "tst_qqmlmetatype.moc"
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/implicitQmldir.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/implicitQmldir.errors.txt
index ce3b796e16..ce3b796e16 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/implicitQmldir.errors.txt
+++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/implicitQmldir.errors.txt
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/qmldir b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/qmldir
index 7f5b3a362d..7f5b3a362d 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/temptest.qml b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/temptest.qml
index 67fb18feb0..67fb18feb0 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit1/temptest.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit1/temptest.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/Test.qml b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/Test.qml
index ea9611691e..ea9611691e 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/Test.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/Test.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/implicitQmldir.2.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/implicitQmldir.2.errors.txt
index 9cafb78740..9cafb78740 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/implicitQmldir.2.errors.txt
+++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/implicitQmldir.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/qmldir b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/qmldir
index 7c4def92fc..7c4def92fc 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/temptest2.qml b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/temptest2.qml
index 0fa9f6e051..0fa9f6e051 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/implicit2/temptest2.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/implicit2/temptest2.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.2.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml
index a0ac0c72c7..a0ac0c72c7 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.2.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.2.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.qml b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml
index 1346cbdb7b..1346cbdb7b 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/importsMixedQmlCppPlugin.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/importsMixedQmlCppPlugin.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/incorrectCase.qml b/tests/auto/qml/qqmlmoduleplugin/data/incorrectCase.qml
index a21ece7058..a21ece7058 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/incorrectCase.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/incorrectCase.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/pluginWithQmlFile.qml b/tests/auto/qml/qqmlmoduleplugin/data/pluginWithQmlFile.qml
index a9e28e5d8b..a9e28e5d8b 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/pluginWithQmlFile.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/pluginWithQmlFile.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.errors.txt
index a40c1c8211..a40c1c8211 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.errors.txt
+++ b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.errors.txt
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.qml b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.qml
index bda59f0a32..bda59f0a32 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.2.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.2.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.errors.txt b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.errors.txt
index 2634223de7..2634223de7 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.errors.txt
+++ b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.errors.txt
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.qml b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.qml
index 2e556e76d6..2e556e76d6 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/versionNotInstalled.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/versionNotInstalled.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/works.qml b/tests/auto/qml/qqmlmoduleplugin/data/works.qml
index f29ae24ea2..f29ae24ea2 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/works.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/works.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/works2.qml b/tests/auto/qml/qqmlmoduleplugin/data/works2.qml
index cc322bf26b..cc322bf26b 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/works2.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/works2.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/works21.qml b/tests/auto/qml/qqmlmoduleplugin/data/works21.qml
index c08160ac5a..c08160ac5a 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/data/works21.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/data/works21.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml
index 617bdaaf67..617bdaaf67 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/MyQmlFile.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir
index 858ba1450e..858ba1450e 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestPluginWithQmlFile/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml
index 36d69e901f..36d69e901f 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/Foo.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir
index 065dc3b21f..065dc3b21f 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlMixedPluginType/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir
index 0a8b5d46eb..0a8b5d46eb 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2.1/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir
index 0a8b5d46eb..0a8b5d46eb 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType.2/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir
index 0a8b5d46eb..0a8b5d46eb 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlPluginType/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir
index 640967fe40..640967fe40 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/AutoTestQmlVersionPluginType/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml
index 617bdaaf67..617bdaaf67 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentA.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml
index fac5d8f4b9..fac5d8f4b9 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/ComponentB.qml
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/qmldir
index 167bb10c21..167bb10c21 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/PureQmlModule/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/PureQmlModule/qmldir
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/WrongCase/qmldir b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/WrongCase/qmldir
index 6c8787498f..6c8787498f 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/WrongCase/qmldir
+++ b/tests/auto/qml/qqmlmoduleplugin/imports/com/nokia/WrongCase/qmldir
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro
new file mode 100644
index 0000000000..ccb66abe0e
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.2.1.pro
@@ -0,0 +1,7 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType.2.1
+
+QT += core-private gui-private qml-private
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp
new file mode 100644
index 0000000000..53696b3598
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2.1/plugin.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class MyPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+ Q_PROPERTY(int valueOnlyIn2 READ value WRITE setValue)
+
+public:
+ MyPluginType(QObject *parent=0) : QObject(parent)
+ {
+ qWarning("import2.1 worked");
+ }
+
+ int value() const { return v; }
+ void setValue(int i) { v = i; }
+
+private:
+ int v;
+};
+
+
+class MyPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+public:
+ MyPlugin()
+ {
+ qWarning("plugin2.1 created");
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType");
+ qmlRegisterType<MyPluginType>(uri, 2, 1, "MyPluginType");
+ }
+};
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro
new file mode 100644
index 0000000000..7f3904f695
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.2.pro
@@ -0,0 +1,7 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType.2
+
+QT += core-private gui-private qml-private
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp
new file mode 100644
index 0000000000..f62b8addd4
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin.2/plugin.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class MyPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+ Q_PROPERTY(int valueOnlyIn2 READ value WRITE setValue)
+
+public:
+ MyPluginType(QObject *parent=0) : QObject(parent)
+ {
+ qWarning("import2 worked");
+ }
+
+ int value() const { return v; }
+ void setValue(int i) { v = i; }
+
+private:
+ int v;
+};
+
+
+class MyPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+public:
+ MyPlugin()
+ {
+ qWarning("plugin2 created");
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType");
+ qmlRegisterType<MyPluginType>(uri, 2, 0, "MyPluginType");
+ }
+};
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp
new file mode 100644
index 0000000000..470aa7a37c
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class MyPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+
+public:
+ MyPluginType(QObject *parent=0) : QObject(parent)
+ {
+ qWarning("import worked");
+ }
+
+ int value() const { return v; }
+ void setValue(int i) { v = i; }
+
+private:
+ int v;
+};
+
+
+class MyPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+public:
+ MyPlugin()
+ {
+ qWarning("plugin created");
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlPluginType");
+ qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType");
+ }
+};
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro
new file mode 100644
index 0000000000..dae8696cc8
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/plugin/plugin.pro
@@ -0,0 +1,7 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+DESTDIR = ../imports/com/nokia/AutoTestQmlPluginType
+
+QT += core-private gui-private qml-private
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp
new file mode 100644
index 0000000000..eec8e3f3af
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/plugin.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class BarPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value)
+
+public:
+ int value() const { return 16; }
+};
+
+
+class MyMixedPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+public:
+ MyMixedPlugin()
+ {
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlMixedPluginType");
+ qmlRegisterType<BarPluginType>(uri, 1, 0, "Bar");
+ }
+};
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(plugin, MyMixedPlugin);
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginMixed/pluginMixed.pro b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/pluginMixed.pro
new file mode 100644
index 0000000000..c0f314ab5e
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginMixed/pluginMixed.pro
@@ -0,0 +1,7 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+DESTDIR = ../imports/com/nokia/AutoTestQmlMixedPluginType
+
+QT += core-private gui-private qml-private
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp
new file mode 100644
index 0000000000..8645028317
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/plugin.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class FloorPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value);
+
+public:
+ int value() const { return 16; }
+};
+
+
+class MyMixedPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+public:
+ MyMixedPlugin()
+ {
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestQmlVersionPluginType");
+ qmlRegisterType<FloorPluginType>(uri, 1, 4, "Floor");
+ }
+};
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(plugin, MyMixedPlugin);
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginVersion/pluginVersion.pro b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/pluginVersion.pro
new file mode 100644
index 0000000000..ba9e4846ea
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginVersion/pluginVersion.pro
@@ -0,0 +1,7 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+DESTDIR = ../imports/com/nokia/AutoTestQmlVersionPluginType
+
+QT += core-private gui-private qml-private
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp
new file mode 100644
index 0000000000..1217df4d0e
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/plugin.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class MyPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+public:
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "com.nokia.AutoTestPluginWithQmlFile");
+ }
+};
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro
new file mode 100644
index 0000000000..15fe8d2f3e
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginWithQmlFile/pluginWithQmlFile.pro
@@ -0,0 +1,7 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+DESTDIR = ../imports/com/nokia/AutoTestPluginWithQmlFile
+
+QT += core-private gui-private qml-private
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp
new file mode 100644
index 0000000000..e0257fe249
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/plugin.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QStringList>
+#include <QtQml/qqmlextensionplugin.h>
+#include <QtQml/qqml.h>
+#include <QDebug>
+
+class MyPluginType : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int value READ value WRITE setValue)
+
+public:
+ MyPluginType(QObject *parent=0) : QObject(parent)
+ {
+ qWarning("import worked");
+ }
+
+ int value() const { return v; }
+ void setValue(int i) { v = i; }
+
+private:
+ int v;
+};
+
+
+class MyPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+public:
+ MyPlugin()
+ {
+ qWarning("plugin created");
+ }
+
+ void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == "com.nokia.WrongCase");
+ qmlRegisterType<MyPluginType>(uri, 1, 0, "MyPluginType");
+ }
+};
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(plugin, MyPlugin);
diff --git a/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/pluginWrongCase.pro b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/pluginWrongCase.pro
new file mode 100644
index 0000000000..d604613300
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/pluginWrongCase/pluginWrongCase.pro
@@ -0,0 +1,8 @@
+TEMPLATE = lib
+CONFIG += plugin
+SOURCES = plugin.cpp
+QT = core qml
+TARGET = Plugin
+DESTDIR = ../imports/com/nokia/WrongCase
+
+QT += core-private gui-private qml-private
diff --git a/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro
new file mode 100644
index 0000000000..42eedc20f2
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/qqmlmoduleplugin.pro
@@ -0,0 +1,9 @@
+QT = core
+TEMPLATE = subdirs
+SUBDIRS = plugin plugin.2 plugin.2.1 pluginWrongCase pluginWithQmlFile pluginMixed pluginVersion
+tst_qqmlmoduleplugin_pro.depends += plugin
+SUBDIRS += tst_qqmlmoduleplugin.pro
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private
diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
new file mode 100644
index 0000000000..b574bad595
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp
@@ -0,0 +1,353 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <qdir.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QDebug>
+
+#include "../../shared/testhttpserver.h"
+#include "../../shared/util.h"
+
+#define SERVER_ADDR "http://127.0.0.1:14450"
+#define SERVER_PORT 14450
+
+
+class tst_qqmlmoduleplugin : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+
+private slots:
+ virtual void initTestCase();
+ void importsPlugin();
+ void importsPlugin2();
+ void importsPlugin21();
+ void importsMixedQmlCppPlugin();
+ void incorrectPluginCase();
+ void importPluginWithQmlFile();
+ void remoteImportWithQuotedUrl();
+ void remoteImportWithUnquotedUri();
+ void versionNotInstalled();
+ void versionNotInstalled_data();
+ void implicitQmldir();
+ void implicitQmldir_data();
+
+private:
+ QString m_importsDirectory;
+};
+
+void tst_qqmlmoduleplugin::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ m_importsDirectory = directory() + QStringLiteral("/imports");
+ QVERIFY2(QFileInfo(m_importsDirectory).isDir(),
+ qPrintable(QString::fromLatin1("Imports directory '%1' does not exist.").arg(m_importsDirectory)));
+}
+
+#define VERIFY_ERRORS(errorfile) \
+ if (!errorfile) { \
+ if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
+ qWarning() << "Unexpected Errors:" << component.errors(); \
+ QVERIFY(!component.isError()); \
+ QVERIFY(component.errors().isEmpty()); \
+ } else { \
+ QString verify_errors_file_name = testFile(errorfile); \
+ QFile file(verify_errors_file_name); \
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \
+ QByteArray data = file.readAll(); \
+ file.close(); \
+ QList<QByteArray> expected = data.split('\n'); \
+ expected.removeAll(QByteArray("")); \
+ QList<QQmlError> errors = component.errors(); \
+ QList<QByteArray> actual; \
+ for (int ii = 0; ii < errors.count(); ++ii) { \
+ const QQmlError &error = errors.at(ii); \
+ QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
+ QByteArray::number(error.column()) + ":" + \
+ error.description().toUtf8(); \
+ actual << errorStr; \
+ } \
+ if (qgetenv("DEBUG") != "" && expected != actual) { \
+ qWarning() << "Expected:" << expected << "Actual:" << actual; \
+ } \
+ if (qgetenv("QDECLARATIVELANGUAGE_UPDATEERRORS") != "" && expected != actual) {\
+ QFile file(testFile(errorfile)); \
+ QVERIFY(file.open(QIODevice::WriteOnly)); \
+ for (int ii = 0; ii < actual.count(); ++ii) { \
+ file.write(actual.at(ii)); file.write("\n"); \
+ } \
+ file.close(); \
+ } else { \
+ QCOMPARE(expected, actual); \
+ } \
+ }
+
+void tst_qqmlmoduleplugin::importsPlugin()
+{
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+ QTest::ignoreMessage(QtWarningMsg, "plugin created");
+ QTest::ignoreMessage(QtWarningMsg, "import worked");
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("works.qml")));
+ foreach (QQmlError err, component.errors())
+ qWarning() << err;
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("value").toInt(),123);
+ delete object;
+}
+
+void tst_qqmlmoduleplugin::importsPlugin2()
+{
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+ QTest::ignoreMessage(QtWarningMsg, "plugin2 created");
+ QTest::ignoreMessage(QtWarningMsg, "import2 worked");
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("works2.qml")));
+ foreach (QQmlError err, component.errors())
+ qWarning() << err;
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("value").toInt(),123);
+ delete object;
+}
+
+void tst_qqmlmoduleplugin::importsPlugin21()
+{
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+ QTest::ignoreMessage(QtWarningMsg, "plugin2.1 created");
+ QTest::ignoreMessage(QtWarningMsg, "import2.1 worked");
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("works21.qml")));
+ foreach (QQmlError err, component.errors())
+ qWarning() << err;
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("value").toInt(),123);
+ delete object;
+}
+
+void tst_qqmlmoduleplugin::incorrectPluginCase()
+{
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("incorrectCase.qml")));
+
+ QList<QQmlError> errors = component.errors();
+ QCOMPARE(errors.count(), 1);
+
+#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
+#if defined(Q_OS_MAC)
+ QString libname = "libPluGin.dylib";
+#elif defined(Q_OS_WIN32)
+ QString libname = "PluGin.dll";
+#endif
+ QString expectedError = QLatin1String("plugin cannot be loaded for module \"com.nokia.WrongCase\": File name case mismatch for \"") + QDir(m_importsDirectory).filePath("com/nokia/WrongCase/" + libname) + QLatin1String("\"");
+#else
+ QString expectedError = QLatin1String("module \"com.nokia.WrongCase\" plugin \"PluGin\" not found");
+#endif
+
+ QCOMPARE(errors.at(0).description(), expectedError);
+}
+
+void tst_qqmlmoduleplugin::importPluginWithQmlFile()
+{
+ QString path = m_importsDirectory;
+
+ // QTBUG-16885: adding an import path with a lower-case "c:" causes assert failure
+ // (this only happens if the plugin includes pure QML files)
+ #ifdef Q_OS_WIN
+ QVERIFY(path.at(0).isUpper() && path.at(1) == QLatin1Char(':'));
+ path = path.at(0).toLower() + path.mid(1);
+ #endif
+
+ QQmlEngine engine;
+ engine.addImportPath(path);
+
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("pluginWithQmlFile.qml")));
+ foreach (QQmlError err, component.errors())
+ qWarning() << err;
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+void tst_qqmlmoduleplugin::remoteImportWithQuotedUrl()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(m_importsDirectory);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import \"http://127.0.0.1:14450/com/nokia/PureQmlModule\" \nComponentA { width: 300; ComponentB{} }", QUrl());
+
+ QTRY_COMPARE(component.status(), QQmlComponent::Ready);
+ QObject *object = component.create();
+ QCOMPARE(object->property("width").toInt(), 300);
+ QVERIFY(object != 0);
+ delete object;
+
+ foreach (QQmlError err, component.errors())
+ qWarning() << err;
+ VERIFY_ERRORS(0);
+}
+
+void tst_qqmlmoduleplugin::remoteImportWithUnquotedUri()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(m_importsDirectory);
+
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+ QQmlComponent component(&engine);
+ component.setData("import com.nokia.PureQmlModule 1.0 \nComponentA { width: 300; ComponentB{} }", QUrl());
+
+
+ QTRY_COMPARE(component.status(), QQmlComponent::Ready);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("width").toInt(), 300);
+ delete object;
+
+ foreach (QQmlError err, component.errors())
+ qWarning() << err;
+ VERIFY_ERRORS(0);
+}
+
+// QTBUG-17324
+
+void tst_qqmlmoduleplugin::importsMixedQmlCppPlugin()
+{
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+
+ {
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.qml")));
+
+ QObject *o = component.create();
+ QVERIFY2(o != 0, QQmlDataTest::msgComponentError(component, &engine));
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.2.qml")));
+
+ QObject *o = component.create();
+ QVERIFY2(o != 0, QQmlDataTest::msgComponentError(component, &engine));
+ QCOMPARE(o->property("test").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ delete o;
+ }
+
+
+}
+
+void tst_qqmlmoduleplugin::versionNotInstalled_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("errorFile");
+
+ QTest::newRow("versionNotInstalled") << "versionNotInstalled.qml" << "versionNotInstalled.errors.txt";
+ QTest::newRow("versionNotInstalled") << "versionNotInstalled.2.qml" << "versionNotInstalled.2.errors.txt";
+}
+
+void tst_qqmlmoduleplugin::versionNotInstalled()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, errorFile);
+
+ QQmlEngine engine;
+ engine.addImportPath(m_importsDirectory);
+
+ QQmlComponent component(&engine, testFileUrl(file));
+ VERIFY_ERRORS(errorFile.toLatin1().constData());
+}
+
+
+// test that errors are reporting correctly for plugin loading and qmldir parsing
+void tst_qqmlmoduleplugin::implicitQmldir_data()
+{
+ QTest::addColumn<QString>("directory");
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("errorFile");
+
+ // parsing qmldir succeeds, but plugin specified in the qmldir file doesn't exist
+ QTest::newRow("implicitQmldir") << "implicit1" << "temptest.qml" << "implicitQmldir.errors.txt";
+
+ // parsing qmldir fails due to syntax errors, etc.
+ QTest::newRow("implicitQmldir2") << "implicit2" << "temptest2.qml" << "implicitQmldir.2.errors.txt";
+}
+void tst_qqmlmoduleplugin::implicitQmldir()
+{
+ QFETCH(QString, directory);
+ QFETCH(QString, file);
+ QFETCH(QString, errorFile);
+
+ QString importPath = testFile(directory);
+ QString fileName = directory + QDir::separator() + file;
+ QString errorFileName = directory + QDir::separator() + errorFile;
+ QUrl testUrl = testFileUrl(fileName);
+
+ QQmlEngine engine;
+ engine.addImportPath(importPath);
+
+ QQmlComponent component(&engine, testUrl);
+ QList<QQmlError> errors = component.errors();
+ VERIFY_ERRORS(errorFileName.toLatin1().constData());
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ QObject *obj = component.create();
+ QVERIFY(!obj);
+ delete obj;
+}
+
+
+QTEST_MAIN(tst_qqmlmoduleplugin)
+
+#include "tst_qqmlmoduleplugin.moc"
diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.pro b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.pro
new file mode 100644
index 0000000000..3d5fe7d6ae
--- /dev/null
+++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.pro
@@ -0,0 +1,19 @@
+CONFIG += testcase
+TARGET = tst_qqmlmoduleplugin
+
+HEADERS = ../../shared/testhttpserver.h
+SOURCES = tst_qqmlmoduleplugin.cpp \
+ ../../shared/testhttpserver.cpp
+CONFIG -= app_bundle
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+testImportFiles.files = imports
+testImportFiles.path = .
+DEPLOYMENT += testImportFiles
+
+QT += core-private gui-private qml-private network testlib
diff --git a/tests/auto/qml/qqmlparser/qqmlparser.pro b/tests/auto/qml/qqmlparser/qqmlparser.pro
new file mode 100644
index 0000000000..e1b7b39402
--- /dev/null
+++ b/tests/auto/qml/qqmlparser/qqmlparser.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qqmlparser
+QT += qmldevtools-private testlib
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlparser.cpp
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
new file mode 100644
index 0000000000..5fb5b71533
--- /dev/null
+++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp
@@ -0,0 +1,210 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qqmljsengine_p.h>
+#include <private/qqmljsparser_p.h>
+#include <private/qqmljslexer_p.h>
+#include <private/qqmljsastvisitor_p.h>
+#include <private/qqmljsast_p.h>
+
+#include <qtest.h>
+#include <QDir>
+#include <QDebug>
+#include <cstdlib>
+
+class tst_qqmlparser : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmlparser();
+
+private slots:
+ void initTestCase();
+ void qmlParser_data();
+ void qmlParser();
+
+private:
+ QStringList excludedDirs;
+
+ QStringList findFiles(const QDir &);
+};
+
+namespace check {
+
+using namespace QQmlJS;
+
+class Check: public AST::Visitor
+{
+ Engine *engine;
+ QList<AST::Node *> nodeStack;
+
+public:
+ Check(Engine *engine)
+ : engine(engine)
+ {
+ }
+
+ void operator()(AST::Node *node)
+ {
+ AST::Node::accept(node, this);
+ }
+
+ void checkNode(AST::Node *node)
+ {
+ if (! nodeStack.isEmpty()) {
+ AST::Node *parent = nodeStack.last();
+ const quint32 parentBegin = parent->firstSourceLocation().begin();
+ const quint32 parentEnd = parent->lastSourceLocation().end();
+
+ QVERIFY(node->firstSourceLocation().begin() >= parentBegin);
+ QVERIFY(node->lastSourceLocation().end() <= parentEnd);
+ }
+ }
+
+ virtual bool preVisit(AST::Node *node)
+ {
+ checkNode(node);
+ nodeStack.append(node);
+ return true;
+ }
+
+ virtual void postVisit(AST::Node *)
+ {
+ nodeStack.removeLast();
+ }
+};
+
+}
+
+tst_qqmlparser::tst_qqmlparser()
+{
+}
+
+void tst_qqmlparser::initTestCase()
+{
+ // Add directories you want excluded here
+
+ // These snippets are not expected to run on their own.
+ excludedDirs << "doc/src/snippets/qml/visualdatamodel_rootindex";
+ excludedDirs << "doc/src/snippets/qml/qtbinding";
+ excludedDirs << "doc/src/snippets/qml/imports";
+ excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex";
+ excludedDirs << "doc/src/snippets/qtquick1/qtbinding";
+ excludedDirs << "doc/src/snippets/qtquick1/imports";
+}
+
+QStringList tst_qqmlparser::findFiles(const QDir &d)
+{
+ for (int ii = 0; ii < excludedDirs.count(); ++ii) {
+ QString s = excludedDirs.at(ii);
+ if (d.absolutePath().endsWith(s))
+ return QStringList();
+ }
+
+ QStringList rv;
+
+ QStringList files = d.entryList(QStringList() << QLatin1String("*.qml") << QLatin1String("*.js"),
+ QDir::Files);
+ foreach (const QString &file, files) {
+ rv << d.absoluteFilePath(file);
+ }
+
+ QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
+ QDir::NoSymLinks);
+ foreach (const QString &dir, dirs) {
+ QDir sub = d;
+ sub.cd(dir);
+ rv << findFiles(sub);
+ }
+
+ return rv;
+}
+
+/*
+This test checks all the qml and js files in the QtQml UI source tree
+and ensures that the subnode's source locations are inside parent node's source locations
+*/
+
+void tst_qqmlparser::qmlParser_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QString examples = QLatin1String(SRCDIR) + "/../../../../examples/";
+ QString tests = QLatin1String(SRCDIR) + "/../../../../tests/";
+
+ QStringList files;
+ files << findFiles(QDir(examples));
+ files << findFiles(QDir(tests));
+
+ foreach (const QString &file, files)
+ QTest::newRow(qPrintable(file)) << file;
+}
+
+void tst_qqmlparser::qmlParser()
+{
+ QFETCH(QString, file);
+
+ using namespace QQmlJS;
+
+ QString code;
+
+ QFile f(file);
+ if (f.open(QFile::ReadOnly))
+ code = QString::fromUtf8(f.readAll());
+
+ const bool qmlMode = file.endsWith(QLatin1String(".qml"));
+
+ Engine engine;
+ Lexer lexer(&engine);
+ lexer.setCode(code, 1, qmlMode);
+ Parser parser(&engine);
+ if (qmlMode)
+ parser.parse();
+ else
+ parser.parseProgram();
+
+ check::Check chk(&engine);
+ chk(parser.rootNode());
+}
+
+QTEST_MAIN(tst_qqmlparser)
+
+#include "tst_qqmlparser.moc"
diff --git a/tests/auto/declarative/qdeclarativepixmapcache/data/dataLeak.qml b/tests/auto/qml/qqmlpixmapcache/data/dataLeak.qml
index 724ce5d816..724ce5d816 100644
--- a/tests/auto/declarative/qdeclarativepixmapcache/data/dataLeak.qml
+++ b/tests/auto/qml/qqmlpixmapcache/data/dataLeak.qml
diff --git a/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeA.qml b/tests/auto/qml/qqmlproperty/data/NoContextTypeA.qml
index f58967cbb2..f58967cbb2 100644
--- a/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeA.qml
+++ b/tests/auto/qml/qqmlproperty/data/NoContextTypeA.qml
diff --git a/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeB.qml b/tests/auto/qml/qqmlproperty/data/NoContextTypeB.qml
index 4b3672873d..4b3672873d 100644
--- a/tests/auto/declarative/qdeclarativeproperty/data/NoContextTypeB.qml
+++ b/tests/auto/qml/qqmlproperty/data/NoContextTypeB.qml
diff --git a/tests/auto/declarative/qdeclarativeproperty/data/TestType.qml b/tests/auto/qml/qqmlproperty/data/TestType.qml
index 1fe150548a..1fe150548a 100644
--- a/tests/auto/declarative/qdeclarativeproperty/data/TestType.qml
+++ b/tests/auto/qml/qqmlproperty/data/TestType.qml
diff --git a/tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml b/tests/auto/qml/qqmlproperty/data/aliasPropertyBindings.qml
index f101f38a2d..f101f38a2d 100644
--- a/tests/auto/declarative/qdeclarativeproperty/data/aliasPropertyBindings.qml
+++ b/tests/auto/qml/qqmlproperty/data/aliasPropertyBindings.qml
diff --git a/tests/auto/declarative/qdeclarativeproperty/data/assignEmptyVariantMap.qml b/tests/auto/qml/qqmlproperty/data/assignEmptyVariantMap.qml
index a9e51c1255..a9e51c1255 100644
--- a/tests/auto/declarative/qdeclarativeproperty/data/assignEmptyVariantMap.qml
+++ b/tests/auto/qml/qqmlproperty/data/assignEmptyVariantMap.qml
diff --git a/tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml b/tests/auto/qml/qqmlproperty/data/readSynthesizedObject.qml
index 55010b69a9..55010b69a9 100644
--- a/tests/auto/declarative/qdeclarativeproperty/data/readSynthesizedObject.qml
+++ b/tests/auto/qml/qqmlproperty/data/readSynthesizedObject.qml
diff --git a/tests/auto/qml/qqmlproperty/qqmlproperty.pro b/tests/auto/qml/qqmlproperty/qqmlproperty.pro
new file mode 100644
index 0000000000..689db4d7cf
--- /dev/null
+++ b/tests/auto/qml/qqmlproperty/qqmlproperty.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlproperty
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlproperty.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private widgets testlib
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
new file mode 100644
index 0000000000..ae300900c9
--- /dev/null
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -0,0 +1,1721 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlproperty.h>
+#include <QtQml/private/qqmlproperty_p.h>
+#include <private/qqmlbinding_p.h>
+#include <QtWidgets/QLineEdit>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qdir.h>
+#include "../../shared/util.h"
+
+#include <QDebug>
+class MyQmlObject : public QObject
+{
+ Q_OBJECT
+public:
+ MyQmlObject() {}
+};
+
+QML_DECLARE_TYPE(MyQmlObject);
+
+class MyAttached : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int foo READ foo WRITE setFoo)
+public:
+ MyAttached(QObject *parent) : QObject(parent), m_foo(13) {}
+
+ int foo() const { return m_foo; }
+ void setFoo(int f) { m_foo = f; }
+
+private:
+ int m_foo;
+};
+
+class MyContainer : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<MyQmlObject> children READ children)
+public:
+ MyContainer() {}
+
+ QQmlListProperty<MyQmlObject> children() { return QQmlListProperty<MyQmlObject>(this, m_children); }
+
+ static MyAttached *qmlAttachedProperties(QObject *o) {
+ return new MyAttached(o);
+ }
+
+private:
+ QList<MyQmlObject*> m_children;
+};
+
+QML_DECLARE_TYPE(MyContainer);
+QML_DECLARE_TYPEINFO(MyContainer, QML_HAS_ATTACHED_PROPERTIES)
+
+class tst_qqmlproperty : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlproperty() {}
+
+private slots:
+ void initTestCase();
+
+ // Constructors
+ void qmlmetaproperty();
+ void qmlmetaproperty_object();
+ void qmlmetaproperty_object_string();
+ void qmlmetaproperty_object_context();
+ void qmlmetaproperty_object_string_context();
+
+ // Methods
+ void name();
+ void read();
+ void write();
+ void reset();
+
+ // Functionality
+ void writeObjectToList();
+ void writeListToList();
+
+ //writeToReadOnly();
+
+ void urlHandling_data();
+ void urlHandling();
+
+ void variantMapHandling_data();
+ void variantMapHandling();
+
+ // Bugs
+ void crashOnValueProperty();
+ void aliasPropertyBindings();
+ void noContext();
+ void assignEmptyVariantMap();
+
+ void copy();
+private:
+ QQmlEngine engine;
+};
+
+void tst_qqmlproperty::qmlmetaproperty()
+{
+ QQmlProperty prop;
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+}
+
+class PropertyObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int defaultProperty READ defaultProperty)
+ Q_PROPERTY(QRect rectProperty READ rectProperty)
+ Q_PROPERTY(QRect wrectProperty READ wrectProperty WRITE setWRectProperty)
+ Q_PROPERTY(QUrl url READ url WRITE setUrl)
+ Q_PROPERTY(QVariantMap variantMap READ variantMap WRITE setVariantMap)
+ Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty)
+ Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
+ Q_PROPERTY(MyQmlObject *qmlObject READ qmlObject)
+
+ Q_CLASSINFO("DefaultProperty", "defaultProperty")
+public:
+ PropertyObject() : m_resetProperty(9) {}
+
+ int defaultProperty() { return 10; }
+ QRect rectProperty() { return QRect(10, 10, 1, 209); }
+
+ QRect wrectProperty() { return m_rect; }
+ void setWRectProperty(const QRect &r) { m_rect = r; }
+
+ QUrl url() { return m_url; }
+ void setUrl(const QUrl &u) { m_url = u; }
+
+ QVariantMap variantMap() const { return m_variantMap; }
+ void setVariantMap(const QVariantMap &variantMap) { m_variantMap = variantMap; }
+
+ int resettableProperty() const { return m_resetProperty; }
+ void setResettableProperty(int r) { m_resetProperty = r; }
+ void resetProperty() { m_resetProperty = 9; }
+
+ int propertyWithNotify() const { return m_propertyWithNotify; }
+ void setPropertyWithNotify(int i) { m_propertyWithNotify = i; emit oddlyNamedNotifySignal(); }
+
+ MyQmlObject *qmlObject() { return &m_qmlObject; }
+
+signals:
+ void clicked();
+ void oddlyNamedNotifySignal();
+
+private:
+ int m_resetProperty;
+ QRect m_rect;
+ QUrl m_url;
+ QVariantMap m_variantMap;
+ int m_propertyWithNotify;
+ MyQmlObject m_qmlObject;
+};
+
+QML_DECLARE_TYPE(PropertyObject);
+
+void tst_qqmlproperty::qmlmetaproperty_object()
+{
+ QObject object; // Has no default property
+ PropertyObject dobject; // Has default property
+
+ {
+ QQmlProperty prop(&object);
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QQmlProperty prop(&dobject);
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding.data()->setTarget(prop);
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("defaultProperty"));
+ QCOMPARE(prop.read(), QVariant(10));
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), true);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Property);
+ QCOMPARE(prop.isProperty(), true);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), true);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(prop.propertyType(), (int)QVariant::Int);
+ QCOMPARE(prop.propertyTypeName(), "int");
+ QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int");
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data());
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+}
+
+void tst_qqmlproperty::qmlmetaproperty_object_string()
+{
+ QObject object;
+ PropertyObject dobject;
+
+ {
+ QQmlProperty prop(&object, QString("defaultProperty"));
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QQmlProperty prop(&dobject, QString("defaultProperty"));
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding.data()->setTarget(prop);
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("defaultProperty"));
+ QCOMPARE(prop.read(), QVariant(10));
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), true);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Property);
+ QCOMPARE(prop.isProperty(), true);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), true);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(prop.propertyType(), (int)QVariant::Int);
+ QCOMPARE(prop.propertyTypeName(), "int");
+ QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int");
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data());
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QQmlProperty prop(&dobject, QString("onClicked"));
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding.data()->setTarget(prop);
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("onClicked"));
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant("Hello")), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
+ QCOMPARE(prop.type(), QQmlProperty::SignalProperty);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), true);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QCOMPARE(prop.property().name(), (const char *)0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == expression.data());
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()"));
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged"));
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding.data()->setTarget(prop);
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("onOddlyNamedNotifySignal"));
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant("Hello")), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()"));
+ QCOMPARE(prop.type(), QQmlProperty::SignalProperty);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), true);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QCOMPARE(prop.property().name(), (const char *)0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == expression.data());
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()"));
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+}
+
+void tst_qqmlproperty::qmlmetaproperty_object_context()
+{
+ QObject object; // Has no default property
+ PropertyObject dobject; // Has default property
+
+ {
+ QQmlProperty prop(&object, engine.rootContext());
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QQmlProperty prop(&dobject, engine.rootContext());
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding.data()->setTarget(prop);
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("defaultProperty"));
+ QCOMPARE(prop.read(), QVariant(10));
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), true);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Property);
+ QCOMPARE(prop.isProperty(), true);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), true);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(prop.propertyType(), (int)QVariant::Int);
+ QCOMPARE(prop.propertyTypeName(), "int");
+ QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int");
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data());
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+}
+
+void tst_qqmlproperty::qmlmetaproperty_object_string_context()
+{
+ QObject object;
+ PropertyObject dobject;
+
+ {
+ QQmlProperty prop(&object, QString("defaultProperty"), engine.rootContext());
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString());
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Invalid);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), false);
+ QCOMPARE(prop.object(), (QObject *)0);
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QVERIFY(prop.property().name() == 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), -1);
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QQmlProperty prop(&dobject, QString("defaultProperty"), engine.rootContext());
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding.data()->setTarget(prop);
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("defaultProperty"));
+ QCOMPARE(prop.read(), QVariant(10));
+ QCOMPARE(prop.write(QVariant()), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), true);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QVERIFY(prop.method().signature() == 0);
+ QCOMPARE(prop.type(), QQmlProperty::Property);
+ QCOMPARE(prop.isProperty(), true);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), true);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), false);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(prop.propertyType(), (int)QVariant::Int);
+ QCOMPARE(prop.propertyTypeName(), "int");
+ QCOMPARE(QString(prop.property().name()), QString("defaultProperty"));
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int");
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding != 0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data());
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression == 0);
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty"));
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QQmlProperty prop(&dobject, QString("onClicked"), engine.rootContext());
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding.data()->setTarget(prop);
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("onClicked"));
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant("Hello")), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QCOMPARE(QString(prop.method().signature()), QString("clicked()"));
+ QCOMPARE(prop.type(), QQmlProperty::SignalProperty);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), true);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QCOMPARE(prop.property().name(), (const char *)0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == expression.data());
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()"));
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+
+ {
+ QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged"), engine.rootContext());
+
+ QWeakPointer<QQmlBinding> binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()));
+ binding.data()->setTarget(prop);
+ QVERIFY(binding != 0);
+ QWeakPointer<QQmlExpression> expression(new QQmlExpression());
+ QVERIFY(expression != 0);
+
+ QObject *obj = new QObject;
+
+ QCOMPARE(prop.name(), QString("onOddlyNamedNotifySignal"));
+ QCOMPARE(prop.read(), QVariant());
+ QCOMPARE(prop.write(QVariant("Hello")), false);
+ QCOMPARE(prop.hasNotifySignal(), false);
+ QCOMPARE(prop.needsNotifySignal(), false);
+ QCOMPARE(prop.connectNotifySignal(0, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, SLOT(deleteLater())), false);
+ QCOMPARE(prop.connectNotifySignal(obj, 0), false);
+ QCOMPARE(prop.connectNotifySignal(0, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, obj->metaObject()->indexOfMethod("deleteLater()")), false);
+ QCOMPARE(prop.connectNotifySignal(obj, -1), false);
+ QCOMPARE(QString(prop.method().signature()), QString("oddlyNamedNotifySignal()"));
+ QCOMPARE(prop.type(), QQmlProperty::SignalProperty);
+ QCOMPARE(prop.isProperty(), false);
+ QCOMPARE(prop.isWritable(), false);
+ QCOMPARE(prop.isDesignable(), false);
+ QCOMPARE(prop.isResettable(), false);
+ QCOMPARE(prop.isSignalProperty(), true);
+ QCOMPARE(prop.isValid(), true);
+ QCOMPARE(prop.object(), qobject_cast<QObject*>(&dobject));
+ QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory);
+ QCOMPARE(prop.propertyType(), 0);
+ QCOMPARE(prop.propertyTypeName(), (const char *)0);
+ QCOMPARE(prop.property().name(), (const char *)0);
+ QVERIFY(QQmlPropertyPrivate::binding(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0);
+ QVERIFY(binding == 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0);
+ QVERIFY(QQmlPropertyPrivate::setSignalExpression(prop, expression.data()) == 0);
+ QVERIFY(expression != 0);
+ QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == expression.data());
+ QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()"));
+ QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1);
+
+ delete obj;
+ }
+}
+
+void tst_qqmlproperty::name()
+{
+ {
+ QQmlProperty p;
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o);
+ QCOMPARE(p.name(), QString("defaultProperty"));
+ }
+
+ {
+ QObject o;
+ QQmlProperty p(&o, QString("objectName"));
+ QCOMPARE(p.name(), QString("objectName"));
+ }
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "onClicked");
+ QCOMPARE(p.name(), QString("onClicked"));
+ }
+
+ {
+ QObject o;
+ QQmlProperty p(&o, "onClicked");
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "onPropertyWithNotifyChanged");
+ QCOMPARE(p.name(), QString("onOddlyNamedNotifySignal"));
+ }
+
+ {
+ QObject o;
+ QQmlProperty p(&o, "onPropertyWithNotifyChanged");
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ QObject o;
+ QQmlProperty p(&o, "foo");
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ QQmlProperty p(0, "foo");
+ QCOMPARE(p.name(), QString());
+ }
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "rectProperty");
+ QCOMPARE(p.name(), QString("rectProperty"));
+ }
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "rectProperty.x");
+ QCOMPARE(p.name(), QString("rectProperty.x"));
+ }
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "rectProperty.foo");
+ QCOMPARE(p.name(), QString());
+ }
+}
+
+void tst_qqmlproperty::read()
+{
+ // Invalid
+ {
+ QQmlProperty p;
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Default prop
+ {
+ PropertyObject o;
+ QQmlProperty p(&o);
+ QCOMPARE(p.read(), QVariant(10));
+ }
+
+ // Invalid default prop
+ {
+ QObject o;
+ QQmlProperty p(&o);
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Value prop by name
+ {
+ QObject o;
+
+ QQmlProperty p(&o, "objectName");
+ QCOMPARE(p.read(), QVariant(QString()));
+
+ o.setObjectName("myName");
+
+ QCOMPARE(p.read(), QVariant("myName"));
+ }
+
+ // Value prop by name (static)
+ {
+ QObject o;
+
+ QCOMPARE(QQmlProperty::read(&o, "objectName"), QVariant(QString()));
+
+ o.setObjectName("myName");
+
+ QCOMPARE(QQmlProperty::read(&o, "objectName"), QVariant("myName"));
+ }
+
+ // Value-type prop
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "rectProperty.x");
+ QCOMPARE(p.read(), QVariant(10));
+ }
+
+ // Invalid value-type prop
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "rectProperty.foo");
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Signal property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "onClicked");
+ QCOMPARE(p.read(), QVariant());
+
+ QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlExpression()));
+ QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p));
+
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Automatic signal property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "onPropertyWithNotifyChanged");
+ QCOMPARE(p.read(), QVariant());
+
+ QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlExpression()));
+ QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p));
+
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Deleted object
+ {
+ PropertyObject *o = new PropertyObject;
+ QQmlProperty p(o, "rectProperty.x");
+ QCOMPARE(p.read(), QVariant(10));
+ delete o;
+ QCOMPARE(p.read(), QVariant());
+ }
+
+ // Object property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "qmlObject");
+ QCOMPARE(p.propertyTypeCategory(), QQmlProperty::Object);
+ QCOMPARE(p.propertyType(), qMetaTypeId<MyQmlObject*>());
+ QVariant v = p.read();
+ QVERIFY(v.userType() == QMetaType::QObjectStar);
+ QVERIFY(qvariant_cast<QObject *>(v) == o.qmlObject());
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("readSynthesizedObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QQmlProperty p(object, "test", &engine);
+
+ QCOMPARE(p.propertyTypeCategory(), QQmlProperty::Object);
+ QVERIFY(p.propertyType() != QMetaType::QObjectStar);
+
+ QVariant v = p.read();
+ QVERIFY(v.userType() == QMetaType::QObjectStar);
+ QCOMPARE(qvariant_cast<QObject *>(v)->property("a").toInt(), 10);
+ QCOMPARE(qvariant_cast<QObject *>(v)->property("b").toInt(), 19);
+ }
+ { // static
+ QQmlComponent component(&engine, testFileUrl("readSynthesizedObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVariant v = QQmlProperty::read(object, "test", &engine);
+ QVERIFY(v.userType() == QMetaType::QObjectStar);
+ QCOMPARE(qvariant_cast<QObject *>(v)->property("a").toInt(), 10);
+ QCOMPARE(qvariant_cast<QObject *>(v)->property("b").toInt(), 19);
+ }
+
+ // Attached property
+ {
+ QQmlComponent component(&engine);
+ component.setData("import Test 1.0\nMyContainer { }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QQmlProperty p(object, "MyContainer.foo", qmlContext(object));
+ QCOMPARE(p.read(), QVariant(13));
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine);
+ component.setData("import Test 1.0\nMyContainer { MyContainer.foo: 10 }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QQmlProperty p(object, "MyContainer.foo", qmlContext(object));
+ QCOMPARE(p.read(), QVariant(10));
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine);
+ component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QQmlProperty p(object, "Foo.MyContainer.foo", qmlContext(object));
+ QCOMPARE(p.read(), QVariant(10));
+ delete object;
+ }
+ { // static
+ QQmlComponent component(&engine);
+ component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(QQmlProperty::read(object, "Foo.MyContainer.foo", qmlContext(object)), QVariant(10));
+ delete object;
+ }
+}
+
+void tst_qqmlproperty::write()
+{
+ // Invalid
+ {
+ QQmlProperty p;
+ QCOMPARE(p.write(QVariant(10)), false);
+ }
+
+ // Read-only default prop
+ {
+ PropertyObject o;
+ QQmlProperty p(&o);
+ QCOMPARE(p.write(QVariant(10)), false);
+ }
+
+ // Invalid default prop
+ {
+ QObject o;
+ QQmlProperty p(&o);
+ QCOMPARE(p.write(QVariant(10)), false);
+ }
+
+ // Read-only prop by name
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, QString("defaultProperty"));
+ QCOMPARE(p.write(QVariant(10)), false);
+ }
+
+ // Writable prop by name
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, QString("objectName"));
+ QCOMPARE(o.objectName(), QString());
+ QCOMPARE(p.write(QVariant(QString("myName"))), true);
+ QCOMPARE(o.objectName(), QString("myName"));
+ }
+
+ // Writable prop by name (static)
+ {
+ PropertyObject o;
+ QCOMPARE(QQmlProperty::write(&o, QString("objectName"), QVariant(QString("myName"))), true);
+ QCOMPARE(o.objectName(), QString("myName"));
+ }
+
+ // Deleted object
+ {
+ PropertyObject *o = new PropertyObject;
+ QQmlProperty p(o, QString("objectName"));
+ QCOMPARE(p.write(QVariant(QString("myName"))), true);
+ QCOMPARE(o->objectName(), QString("myName"));
+
+ delete o;
+
+ QCOMPARE(p.write(QVariant(QString("myName"))), false);
+ }
+
+ // Signal property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "onClicked");
+ QCOMPARE(p.write(QVariant("console.log(1921)")), false);
+
+ QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlExpression()));
+ QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p));
+
+ QCOMPARE(p.write(QVariant("console.log(1921)")), false);
+
+ QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p));
+ }
+
+ // Automatic signal property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "onPropertyWithNotifyChanged");
+ QCOMPARE(p.write(QVariant("console.log(1921)")), false);
+
+ QVERIFY(0 == QQmlPropertyPrivate::setSignalExpression(p, new QQmlExpression()));
+ QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p));
+
+ QCOMPARE(p.write(QVariant("console.log(1921)")), false);
+
+ QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p));
+ }
+
+ // Value-type property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "wrectProperty");
+
+ QCOMPARE(o.wrectProperty(), QRect());
+ QCOMPARE(p.write(QRect(1, 13, 99, 8)), true);
+ QCOMPARE(o.wrectProperty(), QRect(1, 13, 99, 8));
+
+ QQmlProperty p2(&o, "wrectProperty.x");
+ QCOMPARE(p2.read(), QVariant(1));
+ QCOMPARE(p2.write(QVariant(6)), true);
+ QCOMPARE(p2.read(), QVariant(6));
+ QCOMPARE(o.wrectProperty(), QRect(6, 13, 99, 8));
+ }
+
+ // URL-property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "url");
+
+ QCOMPARE(p.write(QUrl("main.qml")), true);
+ QCOMPARE(o.url(), QUrl("main.qml"));
+
+ QQmlProperty p2(&o, "url", engine.rootContext());
+
+ QUrl result = engine.baseUrl().resolved(QUrl("main.qml"));
+ QVERIFY(result != QUrl("main.qml"));
+
+ QCOMPARE(p2.write(QUrl("main.qml")), true);
+ QCOMPARE(o.url(), result);
+ }
+ { // static
+ PropertyObject o;
+
+ QCOMPARE(QQmlProperty::write(&o, "url", QUrl("main.qml")), true);
+ QCOMPARE(o.url(), QUrl("main.qml"));
+
+ QUrl result = engine.baseUrl().resolved(QUrl("main.qml"));
+ QVERIFY(result != QUrl("main.qml"));
+
+ QCOMPARE(QQmlProperty::write(&o, "url", QUrl("main.qml"), engine.rootContext()), true);
+ QCOMPARE(o.url(), result);
+ }
+
+ // VariantMap-property
+ QVariantMap vm;
+ vm.insert("key", "value");
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "variantMap");
+
+ QCOMPARE(p.write(vm), true);
+ QCOMPARE(o.variantMap(), vm);
+
+ QQmlProperty p2(&o, "variantMap", engine.rootContext());
+
+ QCOMPARE(p2.write(vm), true);
+ QCOMPARE(o.variantMap(), vm);
+ }
+ { // static
+ PropertyObject o;
+
+ QCOMPARE(QQmlProperty::write(&o, "variantMap", vm), true);
+ QCOMPARE(o.variantMap(), vm);
+
+ QCOMPARE(QQmlProperty::write(&o, "variantMap", vm, engine.rootContext()), true);
+ QCOMPARE(o.variantMap(), vm);
+ }
+
+ // Attached property
+ {
+ QQmlComponent component(&engine);
+ component.setData("import Test 1.0\nMyContainer { }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QQmlProperty p(object, "MyContainer.foo", qmlContext(object));
+ p.write(QVariant(99));
+ QCOMPARE(p.read(), QVariant(99));
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine);
+ component.setData("import Test 1.0 as Foo\nFoo.MyContainer { Foo.MyContainer.foo: 10 }", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QQmlProperty p(object, "Foo.MyContainer.foo", qmlContext(object));
+ p.write(QVariant(99));
+ QCOMPARE(p.read(), QVariant(99));
+ delete object;
+ }
+}
+
+void tst_qqmlproperty::reset()
+{
+ // Invalid
+ {
+ QQmlProperty p;
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Read-only default prop
+ {
+ PropertyObject o;
+ QQmlProperty p(&o);
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Invalid default prop
+ {
+ QObject o;
+ QQmlProperty p(&o);
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Non-resettable-only prop by name
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, QString("defaultProperty"));
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Resettable prop by name
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, QString("resettableProperty"));
+
+ QCOMPARE(p.read(), QVariant(9));
+ QCOMPARE(p.write(QVariant(11)), true);
+ QCOMPARE(p.read(), QVariant(11));
+
+ QCOMPARE(p.isResettable(), true);
+ QCOMPARE(p.reset(), true);
+
+ QCOMPARE(p.read(), QVariant(9));
+ }
+
+ // Deleted object
+ {
+ PropertyObject *o = new PropertyObject;
+
+ QQmlProperty p(o, QString("resettableProperty"));
+
+ QCOMPARE(p.isResettable(), true);
+ QCOMPARE(p.reset(), true);
+
+ delete o;
+
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Signal property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "onClicked");
+
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+
+ // Automatic signal property
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "onPropertyWithNotifyChanged");
+
+ QCOMPARE(p.isResettable(), false);
+ QCOMPARE(p.reset(), false);
+ }
+}
+
+void tst_qqmlproperty::writeObjectToList()
+{
+ QQmlComponent containerComponent(&engine);
+ containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
+ MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
+ QVERIFY(container != 0);
+ QQmlListReference list(container, "children");
+ QVERIFY(list.count() == 1);
+
+ MyQmlObject *object = new MyQmlObject;
+ QQmlProperty prop(container, "children");
+ prop.write(qVariantFromValue(object));
+ QCOMPARE(list.count(), 1);
+ QCOMPARE(list.at(0), qobject_cast<QObject*>(object));
+}
+
+void tst_qqmlproperty::writeListToList()
+{
+ QQmlComponent containerComponent(&engine);
+ containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl());
+ MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create());
+ QVERIFY(container != 0);
+ QQmlListReference list(container, "children");
+ QVERIFY(list.count() == 1);
+
+ QList<QObject*> objList;
+ objList << new MyQmlObject() << new MyQmlObject() << new MyQmlObject() << new MyQmlObject();
+ QQmlProperty prop(container, "children");
+ prop.write(qVariantFromValue(objList));
+ QCOMPARE(list.count(), 4);
+
+ //XXX need to try this with read/write prop (for read-only it correctly doesn't write)
+ /*QList<MyQmlObject*> typedObjList;
+ typedObjList << new MyQmlObject();
+ prop.write(qVariantFromValue(&typedObjList));
+ QCOMPARE(container->children()->size(), 1);*/
+}
+
+void tst_qqmlproperty::urlHandling_data()
+{
+ QTest::addColumn<QByteArray>("input");
+ QTest::addColumn<QString>("scheme");
+ QTest::addColumn<QString>("path");
+ QTest::addColumn<QByteArray>("encoded");
+
+ QTest::newRow("unspecifiedFile")
+ << QByteArray("main.qml")
+ << QString("")
+ << QString("main.qml")
+ << QByteArray("main.qml");
+
+ QTest::newRow("specifiedFile")
+ << QByteArray("file:///main.qml")
+ << QString("file")
+ << QString("/main.qml")
+ << QByteArray("file:///main.qml");
+
+ QTest::newRow("httpFile")
+ << QByteArray("http://www.example.com/main.qml")
+ << QString("http")
+ << QString("/main.qml")
+ << QByteArray("http://www.example.com/main.qml");
+
+ QTest::newRow("pathFile")
+ << QByteArray("http://www.example.com/resources/main.qml")
+ << QString("http")
+ << QString("/resources/main.qml")
+ << QByteArray("http://www.example.com/resources/main.qml");
+
+ QTest::newRow("encodableName")
+ << QByteArray("http://www.example.com/main file.qml")
+ << QString("http")
+ << QString("/main file.qml")
+ << QByteArray("http://www.example.com/main%20file.qml");
+
+ QTest::newRow("preencodedName")
+ << QByteArray("http://www.example.com/resources%7cmain%20file.qml")
+ << QString("http")
+ << QString("/resources|main file.qml")
+ << QByteArray("http://www.example.com/resources%7cmain%20file.qml");
+
+ QTest::newRow("encodableQuery")
+ << QByteArray("http://www.example.com/main.qml?type=text/qml&comment=now working?")
+ << QString("http")
+ << QString("/main.qml")
+ << QByteArray("http://www.example.com/main.qml?type=text/qml&comment=now%20working?");
+
+ QTest::newRow("preencodedQuery")
+ << QByteArray("http://www.example.com/main.qml?type=text%2fqml&comment=now working%3f")
+ << QString("http")
+ << QString("/main.qml")
+ << QByteArray("http://www.example.com/main.qml?type=text%2fqml&comment=now%20working%3f");
+
+ QTest::newRow("encodableFragment")
+ << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000|volume+50%")
+ << QString("http")
+ << QString("/main.qml")
+ << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000%7Cvolume+50%25");
+
+ QTest::newRow("preencodedFragment")
+ << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000%7cvolume%2b50%")
+ << QString("http")
+ << QString("/main.qml")
+ << QByteArray("http://www.example.com/main.qml?type=text/qml#start+30000%7cvolume%2b50%25");
+}
+
+void tst_qqmlproperty::urlHandling()
+{
+ QFETCH(QByteArray, input);
+ QFETCH(QString, scheme);
+ QFETCH(QString, path);
+ QFETCH(QByteArray, encoded);
+
+ QString inputString(QString::fromUtf8(input));
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "url");
+
+ // Test url written as QByteArray
+ QCOMPARE(p.write(input), true);
+ QUrl byteArrayResult(o.url());
+
+ QCOMPARE(byteArrayResult.scheme(), scheme);
+ QCOMPARE(byteArrayResult.path(), path);
+ QCOMPARE(byteArrayResult.toEncoded(), encoded);
+ }
+
+ {
+ PropertyObject o;
+ QQmlProperty p(&o, "url");
+
+ // Test url written as QString
+ QCOMPARE(p.write(inputString), true);
+ QUrl stringResult(o.url());
+
+ QCOMPARE(stringResult.scheme(), scheme);
+ QCOMPARE(stringResult.path(), path);
+ QCOMPARE(stringResult.toEncoded(), encoded);
+ }
+}
+
+void tst_qqmlproperty::variantMapHandling_data()
+{
+ QTest::addColumn<QVariantMap>("vm");
+
+ // Object literals
+ {
+ QVariantMap m;
+ QTest::newRow("{}") << m;
+ }
+ {
+ QVariantMap m;
+ m["a"] = QVariantMap();
+ QTest::newRow("{ a:{} }") << m;
+ }
+ {
+ QVariantMap m, m2;
+ m2["b"] = 10;
+ m2["c"] = 20;
+ m["a"] = m2;
+ QTest::newRow("{ a:{b:10, c:20} }") << m;
+ }
+ {
+ QVariantMap m;
+ m["a"] = 10;
+ m["b"] = QVariantList() << 20 << 30;
+ QTest::newRow("{ a:10, b:[20, 30]}") << m;
+ }
+
+ // Cyclic objects
+ {
+ QVariantMap m;
+ m["p"] = QVariantMap();
+ QTest::newRow("var o={}; o.p=o") << m;
+ }
+ {
+ QVariantMap m;
+ m["p"] = 123;
+ m["q"] = QVariantMap();
+ QTest::newRow("var o={}; o.p=123; o.q=o") << m;
+ }
+}
+
+void tst_qqmlproperty::variantMapHandling()
+{
+ QFETCH(QVariantMap, vm);
+
+ PropertyObject o;
+ QQmlProperty p(&o, "variantMap");
+
+ QCOMPARE(p.write(vm), true);
+ QCOMPARE(o.variantMap(), vm);
+}
+
+void tst_qqmlproperty::crashOnValueProperty()
+{
+ QQmlEngine *engine = new QQmlEngine;
+ QQmlComponent component(engine);
+
+ component.setData("import Test 1.0\nPropertyObject { wrectProperty.x: 10 }", QUrl());
+ PropertyObject *obj = qobject_cast<PropertyObject*>(component.create());
+ QVERIFY(obj != 0);
+
+ QQmlProperty p(obj, "wrectProperty.x", qmlContext(obj));
+ QCOMPARE(p.name(), QString("wrectProperty.x"));
+
+ QCOMPARE(p.read(), QVariant(10));
+
+ //don't crash once the engine is deleted
+ delete engine;
+ engine = 0;
+
+ QCOMPARE(p.propertyTypeName(), "int");
+ QCOMPARE(p.read(), QVariant(10));
+ p.write(QVariant(20));
+ QCOMPARE(p.read(), QVariant(20));
+}
+
+// QTBUG-13719
+void tst_qqmlproperty::aliasPropertyBindings()
+{
+ QQmlComponent component(&engine, testFileUrl("aliasPropertyBindings.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("realProperty").toReal(), 90.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 90.);
+
+ object->setProperty("test", 10);
+
+ QCOMPARE(object->property("realProperty").toReal(), 110.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 110.);
+
+ QQmlProperty realProperty(object, QLatin1String("realProperty"));
+ QQmlProperty aliasProperty(object, QLatin1String("aliasProperty"));
+
+ // Check there is a binding on these two properties
+ QVERIFY(QQmlPropertyPrivate::binding(realProperty) != 0);
+ QVERIFY(QQmlPropertyPrivate::binding(aliasProperty) != 0);
+
+ // Check that its the same binding on these two properties
+ QCOMPARE(QQmlPropertyPrivate::binding(realProperty),
+ QQmlPropertyPrivate::binding(aliasProperty));
+
+ // Change the binding
+ object->setProperty("state", QString("switch"));
+
+ QVERIFY(QQmlPropertyPrivate::binding(realProperty) != 0);
+ QVERIFY(QQmlPropertyPrivate::binding(aliasProperty) != 0);
+ QCOMPARE(QQmlPropertyPrivate::binding(realProperty),
+ QQmlPropertyPrivate::binding(aliasProperty));
+
+ QCOMPARE(object->property("realProperty").toReal(), 96.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 96.);
+
+ // Check the old binding really has not effect any more
+ object->setProperty("test", 4);
+
+ QCOMPARE(object->property("realProperty").toReal(), 96.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 96.);
+
+ object->setProperty("test2", 9);
+
+ QCOMPARE(object->property("realProperty").toReal(), 288.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 288.);
+
+ // Revert
+ object->setProperty("state", QString(""));
+
+ QVERIFY(QQmlPropertyPrivate::binding(realProperty) != 0);
+ QVERIFY(QQmlPropertyPrivate::binding(aliasProperty) != 0);
+ QCOMPARE(QQmlPropertyPrivate::binding(realProperty),
+ QQmlPropertyPrivate::binding(aliasProperty));
+
+ QCOMPARE(object->property("realProperty").toReal(), 20.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 20.);
+
+ object->setProperty("test2", 3);
+
+ QCOMPARE(object->property("realProperty").toReal(), 20.);
+ QCOMPARE(object->property("aliasProperty").toReal(), 20.);
+
+ delete object;
+}
+
+void tst_qqmlproperty::copy()
+{
+ PropertyObject object;
+
+ QQmlProperty *property = new QQmlProperty(&object, QLatin1String("defaultProperty"));
+ QCOMPARE(property->name(), QString("defaultProperty"));
+ QCOMPARE(property->read(), QVariant(10));
+ QCOMPARE(property->type(), QQmlProperty::Property);
+ QCOMPARE(property->propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(property->propertyType(), (int)QVariant::Int);
+
+ QQmlProperty p1(*property);
+ QCOMPARE(p1.name(), QString("defaultProperty"));
+ QCOMPARE(p1.read(), QVariant(10));
+ QCOMPARE(p1.type(), QQmlProperty::Property);
+ QCOMPARE(p1.propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(p1.propertyType(), (int)QVariant::Int);
+
+ QQmlProperty p2(&object, QLatin1String("url"));
+ QCOMPARE(p2.name(), QString("url"));
+ p2 = *property;
+ QCOMPARE(p2.name(), QString("defaultProperty"));
+ QCOMPARE(p2.read(), QVariant(10));
+ QCOMPARE(p2.type(), QQmlProperty::Property);
+ QCOMPARE(p2.propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(p2.propertyType(), (int)QVariant::Int);
+
+ delete property; property = 0;
+
+ QCOMPARE(p1.name(), QString("defaultProperty"));
+ QCOMPARE(p1.read(), QVariant(10));
+ QCOMPARE(p1.type(), QQmlProperty::Property);
+ QCOMPARE(p1.propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(p1.propertyType(), (int)QVariant::Int);
+
+ QCOMPARE(p2.name(), QString("defaultProperty"));
+ QCOMPARE(p2.read(), QVariant(10));
+ QCOMPARE(p2.type(), QQmlProperty::Property);
+ QCOMPARE(p2.propertyTypeCategory(), QQmlProperty::Normal);
+ QCOMPARE(p2.propertyType(), (int)QVariant::Int);
+}
+
+void tst_qqmlproperty::noContext()
+{
+ QQmlComponent compA(&engine, testFileUrl("NoContextTypeA.qml"));
+ QQmlComponent compB(&engine, testFileUrl("NoContextTypeB.qml"));
+
+ QObject *a = compA.create();
+ QVERIFY(a != 0);
+ QObject *b = compB.create();
+ QVERIFY(b != 0);
+
+ QVERIFY(QQmlProperty::write(b, "myTypeA", QVariant::fromValue(a), &engine));
+
+ delete a;
+ delete b;
+}
+
+void tst_qqmlproperty::assignEmptyVariantMap()
+{
+ PropertyObject o;
+
+ QVariantMap map;
+ map.insert("key", "value");
+ o.setVariantMap(map);
+ QCOMPARE(o.variantMap().count(), 1);
+ QCOMPARE(o.variantMap().isEmpty(), false);
+
+ QQmlContext context(&engine);
+ context.setContextProperty("o", &o);
+
+ QQmlComponent component(&engine, testFileUrl("assignEmptyVariantMap.qml"));
+ QObject *obj = component.create(&context);
+ QVERIFY(obj);
+
+ QCOMPARE(o.variantMap().count(), 0);
+ QCOMPARE(o.variantMap().isEmpty(), true);
+
+ delete obj;
+}
+
+void tst_qqmlproperty::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ qmlRegisterType<MyQmlObject>("Test",1,0,"MyQmlObject");
+ qmlRegisterType<PropertyObject>("Test",1,0,"PropertyObject");
+ qmlRegisterType<MyContainer>("Test",1,0,"MyContainer");
+}
+
+QTEST_MAIN(tst_qqmlproperty)
+
+#include "tst_qqmlproperty.moc"
diff --git a/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro b/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro
new file mode 100644
index 0000000000..4beb961895
--- /dev/null
+++ b/tests/auto/qml/qqmlpropertycache/qqmlpropertycache.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+TARGET = tst_qqmlpropertycache
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlpropertycache.cpp
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private testlib v8-private
diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
new file mode 100644
index 0000000000..b702623fee
--- /dev/null
+++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
@@ -0,0 +1,281 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <private/qqmlpropertycache_p.h>
+#include <QtQml/qqmlengine.h>
+#include "../../shared/util.h"
+
+class tst_qqmlpropertycache : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qqmlpropertycache() {}
+
+private slots:
+ void properties();
+ void propertiesDerived();
+ void methods();
+ void methodsDerived();
+ void signalHandlers();
+ void signalHandlersDerived();
+
+private:
+ QQmlEngine engine;
+};
+
+class BaseObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int propertyA READ propertyA NOTIFY propertyAChanged)
+ Q_PROPERTY(QString propertyB READ propertyB NOTIFY propertyBChanged)
+public:
+ BaseObject(QObject *parent = 0) : QObject(parent) {}
+
+ int propertyA() const { return 0; }
+ QString propertyB() const { return QString(); }
+
+public Q_SLOTS:
+ void slotA() {}
+
+Q_SIGNALS:
+ void propertyAChanged();
+ void propertyBChanged();
+ void signalA();
+};
+
+class DerivedObject : public BaseObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int propertyC READ propertyC NOTIFY propertyCChanged)
+ Q_PROPERTY(QString propertyD READ propertyD NOTIFY propertyDChanged)
+public:
+ DerivedObject(QObject *parent = 0) : BaseObject(parent) {}
+
+ int propertyC() const { return 0; }
+ QString propertyD() const { return QString(); }
+
+public Q_SLOTS:
+ void slotB() {}
+
+Q_SIGNALS:
+ void propertyCChanged();
+ void propertyDChanged();
+ void signalB();
+};
+
+void tst_qqmlpropertycache::properties()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject));
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("propertyA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyA"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyB"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyC")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyC"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyD")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyD"));
+}
+
+void tst_qqmlpropertycache::propertiesDerived()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject));
+ QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copy());
+ cache->append(&engine, object.metaObject());
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("propertyA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyA"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyB"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyC")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyC"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyD")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfProperty("propertyD"));
+}
+
+void tst_qqmlpropertycache::methods()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject));
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("slotA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("slotB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("signalA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("signalB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyAChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyBChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyCChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyDChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
+}
+
+void tst_qqmlpropertycache::methodsDerived()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject));
+ QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copy());
+ cache->append(&engine, object.metaObject());
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("slotA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("slotB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("slotB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("signalA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("signalB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyAChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyBChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyCChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("propertyDChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
+}
+
+void tst_qqmlpropertycache::signalHandlers()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject));
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("onSignalA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onSignalB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyAChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyBChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyCChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyDChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
+}
+
+void tst_qqmlpropertycache::signalHandlersDerived()
+{
+ QQmlEngine engine;
+ DerivedObject object;
+ const QMetaObject *metaObject = object.metaObject();
+
+ QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject));
+ QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copy());
+ cache->append(&engine, object.metaObject());
+ QQmlPropertyData *data;
+
+ QVERIFY(data = cache->property(QLatin1String("onSignalA")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalA()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onSignalB")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("signalB()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyAChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyAChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyBChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyBChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyCChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyCChanged()"));
+
+ QVERIFY(data = cache->property(QLatin1String("onPropertyDChanged")));
+ QCOMPARE(data->coreIndex, metaObject->indexOfMethod("propertyDChanged()"));
+}
+
+QTEST_MAIN(tst_qqmlpropertycache)
+
+#include "tst_qqmlpropertycache.moc"
diff --git a/tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro b/tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro
new file mode 100644
index 0000000000..f67de8cea9
--- /dev/null
+++ b/tests/auto/qml/qqmlpropertymap/qqmlpropertymap.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qqmlpropertymap
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlpropertymap.cpp
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
new file mode 100644
index 0000000000..0ae05ce138
--- /dev/null
+++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
@@ -0,0 +1,241 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlpropertymap.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QSignalSpy>
+
+class tst_QQmlPropertyMap : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QQmlPropertyMap() {}
+
+private slots:
+ void insert();
+ void operatorInsert();
+ void operatorValue();
+ void clear();
+ void changed();
+ void count();
+
+ void crashBug();
+ void QTBUG_17868();
+};
+
+void tst_QQmlPropertyMap::insert()
+{
+ QQmlPropertyMap map;
+ map.insert(QLatin1String("key1"),100);
+ map.insert(QLatin1String("key2"),200);
+ QVERIFY(map.keys().count() == 2);
+ QVERIFY(map.contains(QLatin1String("key1")));
+
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
+ QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
+
+ map.insert(QLatin1String("key1"),"Hello World");
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
+
+ //inserting property names same with existing method(signal, slot, method) names is not allowed
+ //QQmlPropertyMap has an invokable keys() method
+ QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"keys\" is not permitted, conflicts with internal symbols. ");
+ map.insert(QLatin1String("keys"), 1);
+ QVERIFY(map.keys().count() == 2);
+ QVERIFY(!map.contains(QLatin1String("keys")));
+ QVERIFY(map.value(QLatin1String("keys")).isNull());
+
+ //QQmlPropertyMap has a deleteLater() slot
+ QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"deleteLater\" is not permitted, conflicts with internal symbols. ");
+ map.insert(QLatin1String("deleteLater"), 1);
+ QVERIFY(map.keys().count() == 2);
+ QVERIFY(!map.contains(QLatin1String("deleteLater")));
+ QVERIFY(map.value(QLatin1String("deleteLater")).isNull());
+
+ //QQmlPropertyMap has an valueChanged() signal
+ QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"valueChanged\" is not permitted, conflicts with internal symbols. ");
+ map.insert(QLatin1String("valueChanged"), 1);
+ QVERIFY(map.keys().count() == 2);
+ QVERIFY(!map.contains(QLatin1String("valueChanged")));
+ QVERIFY(map.value(QLatin1String("valueChanged")).isNull());
+
+ //but 'valueChange' should be ok
+ map.insert(QLatin1String("valueChange"), 1);
+ QVERIFY(map.keys().count() == 3);
+ QVERIFY(map.contains(QLatin1String("valueChange")));
+ QCOMPARE(map.value(QLatin1String("valueChange")), QVariant(1));
+
+ //'valueCHANGED' should be ok, too
+ map.insert(QLatin1String("valueCHANGED"), 1);
+ QVERIFY(map.keys().count() == 4);
+ QVERIFY(map.contains(QLatin1String("valueCHANGED")));
+ QCOMPARE(map.value(QLatin1String("valueCHANGED")), QVariant(1));
+}
+
+void tst_QQmlPropertyMap::operatorInsert()
+{
+ QQmlPropertyMap map;
+ map[QLatin1String("key1")] = 100;
+ map[QLatin1String("key2")] = 200;
+ QVERIFY(map.keys().count() == 2);
+
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
+ QCOMPARE(map.value(QLatin1String("key2")), QVariant(200));
+
+ map[QLatin1String("key1")] = "Hello World";
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
+}
+
+void tst_QQmlPropertyMap::operatorValue()
+{
+ QQmlPropertyMap map;
+ map.insert(QLatin1String("key1"),100);
+ map.insert(QLatin1String("key2"),200);
+ QVERIFY(map.count() == 2);
+ QVERIFY(map.contains(QLatin1String("key1")));
+
+ const QQmlPropertyMap &constMap = map;
+
+ QCOMPARE(constMap.value(QLatin1String("key1")), QVariant(100));
+ QCOMPARE(constMap.value(QLatin1String("key2")), QVariant(200));
+ QCOMPARE(constMap[QLatin1String("key1")], constMap.value(QLatin1String("key1")));
+ QCOMPARE(constMap[QLatin1String("key2")], constMap.value(QLatin1String("key2")));
+}
+
+void tst_QQmlPropertyMap::clear()
+{
+ QQmlPropertyMap map;
+ map.insert(QLatin1String("key1"),100);
+ QVERIFY(map.keys().count() == 1);
+
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant(100));
+
+ map.clear(QLatin1String("key1"));
+ QVERIFY(map.keys().count() == 1);
+ QVERIFY(map.contains(QLatin1String("key1")));
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant());
+}
+
+void tst_QQmlPropertyMap::changed()
+{
+ QQmlPropertyMap map;
+ QSignalSpy spy(&map, SIGNAL(valueChanged(const QString&, const QVariant&)));
+ map.insert(QLatin1String("key1"),100);
+ map.insert(QLatin1String("key2"),200);
+ QCOMPARE(spy.count(), 0);
+
+ map.clear(QLatin1String("key1"));
+ QCOMPARE(spy.count(), 0);
+
+ //make changes in QML
+ QQmlEngine engine;
+ QQmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty(QLatin1String("testdata"), &map);
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nText { text: { testdata.key1 = 'Hello World'; 'X' } }",
+ QUrl::fromLocalFile(""));
+ QVERIFY(component.isReady());
+ QQuickText *txt = qobject_cast<QQuickText*>(component.create());
+ QVERIFY(txt);
+ QCOMPARE(txt->text(), QString('X'));
+ QCOMPARE(spy.count(), 1);
+ QList<QVariant> arguments = spy.takeFirst();
+ QCOMPARE(arguments.count(), 2);
+ QCOMPARE(arguments.at(0).toString(),QLatin1String("key1"));
+ QCOMPARE(arguments.at(1).value<QVariant>(),QVariant("Hello World"));
+ QCOMPARE(map.value(QLatin1String("key1")), QVariant("Hello World"));
+}
+
+void tst_QQmlPropertyMap::count()
+{
+ QQmlPropertyMap map;
+ QCOMPARE(map.isEmpty(), true);
+ map.insert(QLatin1String("key1"),100);
+ map.insert(QLatin1String("key2"),200);
+ QCOMPARE(map.count(), 2);
+ QCOMPARE(map.isEmpty(), false);
+
+ map.insert(QLatin1String("key3"),"Hello World");
+ QCOMPARE(map.count(), 3);
+
+ //clearing doesn't remove the key
+ map.clear(QLatin1String("key3"));
+ QCOMPARE(map.count(), 3);
+ QCOMPARE(map.size(), map.count());
+}
+
+void tst_QQmlPropertyMap::crashBug()
+{
+ QQmlPropertyMap map;
+
+ QQmlEngine engine;
+ QQmlContext context(&engine);
+ context.setContextProperty("map", &map);
+
+ QQmlComponent c(&engine);
+ c.setData("import QtQuick 2.0\nBinding { target: map; property: \"myProp\"; value: 10 + 23 }",QUrl());
+ QObject *obj = c.create(&context);
+ delete obj;
+}
+
+void tst_QQmlPropertyMap::QTBUG_17868()
+{
+ QQmlPropertyMap map;
+
+ QQmlEngine engine;
+ QQmlContext context(&engine);
+ context.setContextProperty("map", &map);
+ map.insert("key", 1);
+ QQmlComponent c(&engine);
+ c.setData("import QtQuick 2.0\nItem {property bool error:false; Component.onCompleted: {try{ map.keys(); }catch(e) {error=true;}}}",QUrl());
+ QObject *obj = c.create(&context);
+ QVERIFY(obj);
+ QVERIFY(!obj->property("error").toBool());
+ delete obj;
+
+}
+
+QTEST_MAIN(tst_QQmlPropertyMap)
+
+#include "tst_qqmlpropertymap.moc"
diff --git a/tests/auto/declarative/qdeclarativeqt/data/atob.qml b/tests/auto/qml/qqmlqt/data/atob.qml
index 0d684003a1..0d684003a1 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/atob.qml
+++ b/tests/auto/qml/qqmlqt/data/atob.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/btoa.qml b/tests/auto/qml/qqmlqt/data/btoa.qml
index 0ecd01d284..0ecd01d284 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/btoa.qml
+++ b/tests/auto/qml/qqmlqt/data/btoa.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml b/tests/auto/qml/qqmlqt/data/createComponent.qml
index 3ebc9f14f8..3ebc9f14f8 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/createComponent.qml
+++ b/tests/auto/qml/qqmlqt/data/createComponent.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml b/tests/auto/qml/qqmlqt/data/createComponentData.qml
index 2a824e5362..2a824e5362 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/createComponentData.qml
+++ b/tests/auto/qml/qqmlqt/data/createComponentData.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js b/tests/auto/qml/qqmlqt/data/createComponent_lib.js
index 30499e943e..30499e943e 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js
+++ b/tests/auto/qml/qqmlqt/data/createComponent_lib.js
diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml b/tests/auto/qml/qqmlqt/data/createComponent_lib.qml
index a52453e8fa..a52453e8fa 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml
+++ b/tests/auto/qml/qqmlqt/data/createComponent_lib.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml b/tests/auto/qml/qqmlqt/data/createQmlObject.qml
index 87601b1cc8..87601b1cc8 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/createQmlObject.qml
+++ b/tests/auto/qml/qqmlqt/data/createQmlObject.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/darker.qml b/tests/auto/qml/qqmlqt/data/darker.qml
index ce6c705fb4..ce6c705fb4 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/darker.qml
+++ b/tests/auto/qml/qqmlqt/data/darker.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/dateTimeConversion.qml b/tests/auto/qml/qqmlqt/data/dateTimeConversion.qml
index 641ba6e1ca..641ba6e1ca 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/dateTimeConversion.qml
+++ b/tests/auto/qml/qqmlqt/data/dateTimeConversion.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/enums.qml b/tests/auto/qml/qqmlqt/data/enums.qml
index 5a2ff534af..5a2ff534af 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/enums.qml
+++ b/tests/auto/qml/qqmlqt/data/enums.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml b/tests/auto/qml/qqmlqt/data/fontFamilies.qml
index 70245ab159..70245ab159 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/fontFamilies.qml
+++ b/tests/auto/qml/qqmlqt/data/fontFamilies.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml b/tests/auto/qml/qqmlqt/data/formatting.qml
index 7a462c8eeb..7a462c8eeb 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml
+++ b/tests/auto/qml/qqmlqt/data/formatting.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/hsla.qml b/tests/auto/qml/qqmlqt/data/hsla.qml
index ff9622b339..ff9622b339 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/hsla.qml
+++ b/tests/auto/qml/qqmlqt/data/hsla.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/isQtObject.qml b/tests/auto/qml/qqmlqt/data/isQtObject.qml
index 6829209518..6829209518 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/isQtObject.qml
+++ b/tests/auto/qml/qqmlqt/data/isQtObject.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/lighter.qml b/tests/auto/qml/qqmlqt/data/lighter.qml
index 7db5e1edeb..7db5e1edeb 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/lighter.qml
+++ b/tests/auto/qml/qqmlqt/data/lighter.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/md5.qml b/tests/auto/qml/qqmlqt/data/md5.qml
index bec1ed1fe7..bec1ed1fe7 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/md5.qml
+++ b/tests/auto/qml/qqmlqt/data/md5.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml b/tests/auto/qml/qqmlqt/data/openUrlExternally.qml
index 37b9f513d9..37b9f513d9 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally.qml
+++ b/tests/auto/qml/qqmlqt/data/openUrlExternally.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.js b/tests/auto/qml/qqmlqt/data/openUrlExternally_lib.js
index 702357afbf..702357afbf 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.js
+++ b/tests/auto/qml/qqmlqt/data/openUrlExternally_lib.js
diff --git a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.qml b/tests/auto/qml/qqmlqt/data/openUrlExternally_lib.qml
index 4bf584d134..4bf584d134 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/openUrlExternally_lib.qml
+++ b/tests/auto/qml/qqmlqt/data/openUrlExternally_lib.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/point.qml b/tests/auto/qml/qqmlqt/data/point.qml
index fe12ee6232..fe12ee6232 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/point.qml
+++ b/tests/auto/qml/qqmlqt/data/point.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/quit.qml b/tests/auto/qml/qqmlqt/data/quit.qml
index e3b91660e7..e3b91660e7 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/quit.qml
+++ b/tests/auto/qml/qqmlqt/data/quit.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/rect.qml b/tests/auto/qml/qqmlqt/data/rect.qml
index b294b22c5b..b294b22c5b 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/rect.qml
+++ b/tests/auto/qml/qqmlqt/data/rect.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/resolvedUrl.qml b/tests/auto/qml/qqmlqt/data/resolvedUrl.qml
index 06ef48b82b..06ef48b82b 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/resolvedUrl.qml
+++ b/tests/auto/qml/qqmlqt/data/resolvedUrl.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/rgba.qml b/tests/auto/qml/qqmlqt/data/rgba.qml
index 3b010f68cb..3b010f68cb 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/rgba.qml
+++ b/tests/auto/qml/qqmlqt/data/rgba.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/size.qml b/tests/auto/qml/qqmlqt/data/size.qml
index 41051f4216..41051f4216 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/size.qml
+++ b/tests/auto/qml/qqmlqt/data/size.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/tint.qml b/tests/auto/qml/qqmlqt/data/tint.qml
index 816e6e9b08..816e6e9b08 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/tint.qml
+++ b/tests/auto/qml/qqmlqt/data/tint.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/vector.qml b/tests/auto/qml/qqmlqt/data/vector.qml
index 5a949515ed..5a949515ed 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/vector.qml
+++ b/tests/auto/qml/qqmlqt/data/vector.qml
diff --git a/tests/auto/declarative/qdeclarativeqt/data/vector4.qml b/tests/auto/qml/qqmlqt/data/vector4.qml
index 554dd1e9d4..554dd1e9d4 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/vector4.qml
+++ b/tests/auto/qml/qqmlqt/data/vector4.qml
diff --git a/tests/auto/qml/qqmlqt/qqmlqt.pro b/tests/auto/qml/qqmlqt/qqmlqt.pro
new file mode 100644
index 0000000000..890a7e7636
--- /dev/null
+++ b/tests/auto/qml/qqmlqt/qqmlqt.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlqt
+SOURCES += tst_qqmlqt.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private testlib
diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
new file mode 100644
index 0000000000..a679188cb7
--- /dev/null
+++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
@@ -0,0 +1,732 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <private/qqmlengine_p.h>
+
+#include <qtest.h>
+#include <QDebug>
+#include <QQmlEngine>
+#include <QFontDatabase>
+#include <QFileInfo>
+#include <QQmlComponent>
+#include <QDesktopServices>
+#include <QDir>
+#include <QVector3D>
+#include <QCryptographicHash>
+#include <QtQuick/QQuickItem>
+#include <QSignalSpy>
+#include "../../shared/util.h"
+
+class tst_qqmlqt : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlqt() {}
+
+private slots:
+ void enums();
+ void rgba();
+ void hsla();
+ void rect();
+ void point();
+ void size();
+ void vector();
+ void vector4d();
+ void lighter();
+ void darker();
+ void tint();
+ void openUrlExternally();
+ void openUrlExternally_pragmaLibrary();
+ void md5();
+ void createComponent();
+ void createComponent_pragmaLibrary();
+ void createQmlObject();
+ void dateTimeConversion();
+ void dateTimeFormatting();
+ void dateTimeFormatting_data();
+ void dateTimeFormattingVariants();
+ void dateTimeFormattingVariants_data();
+ void isQtObject();
+ void btoa();
+ void atob();
+ void fontFamilies();
+ void quit();
+ void resolvedUrl();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_qqmlqt::enums()
+{
+ QQmlComponent component(&engine, testFileUrl("enums.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toInt(), (int)Qt::Key_Escape);
+ QCOMPARE(object->property("test2").toInt(), (int)Qt::DescendingOrder);
+ QCOMPARE(object->property("test3").toInt(), (int)Qt::ElideMiddle);
+ QCOMPARE(object->property("test4").toInt(), (int)Qt::AlignRight);
+
+ delete object;
+}
+
+void tst_qqmlqt::rgba()
+{
+ QQmlComponent component(&engine, testFileUrl("rgba.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Error: Qt.rgba(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.rgba(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0, 0, 0.8));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0.5, 0.3, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromRgbF(1, 1, 1, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor::fromRgbF(0, 0, 0, 0));
+
+ delete object;
+}
+
+void tst_qqmlqt::hsla()
+{
+ QQmlComponent component(&engine, testFileUrl("hsla.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Error: Qt.hsla(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.hsla(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromHslF(1, 0, 0, 0.8));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHslF(1, 0.5, 0.3, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor::fromHslF(1, 1, 1, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor::fromHslF(0, 0, 0, 0));
+
+ delete object;
+}
+
+void tst_qqmlqt::rect()
+{
+ QQmlComponent component(&engine, testFileUrl("rect.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Error: Qt.rect(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.rect(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QRectF>(object->property("test1")), QRectF(10, 13, 100, 109));
+ QCOMPARE(qvariant_cast<QRectF>(object->property("test2")), QRectF(-10, 13, 100, 109.6));
+ QCOMPARE(qvariant_cast<QRectF>(object->property("test3")), QRectF());
+ QCOMPARE(qvariant_cast<QRectF>(object->property("test4")), QRectF());
+ QCOMPARE(qvariant_cast<QRectF>(object->property("test5")), QRectF(10, 13, 100, -109));
+
+ delete object;
+}
+
+void tst_qqmlqt::point()
+{
+ QQmlComponent component(&engine, testFileUrl("point.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Error: Qt.point(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.point(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QPointF>(object->property("test1")), QPointF(19, 34));
+ QCOMPARE(qvariant_cast<QPointF>(object->property("test2")), QPointF(-3, 109.2));
+ QCOMPARE(qvariant_cast<QPointF>(object->property("test3")), QPointF());
+ QCOMPARE(qvariant_cast<QPointF>(object->property("test4")), QPointF());
+
+ delete object;
+}
+
+void tst_qqmlqt::size()
+{
+ QQmlComponent component(&engine, testFileUrl("size.qml"));
+
+ QString warning1 = component.url().toString() + ":7: Error: Qt.size(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":8: Error: Qt.size(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QSizeF>(object->property("test1")), QSizeF(19, 34));
+ QCOMPARE(qvariant_cast<QSizeF>(object->property("test2")), QSizeF(3, 109.2));
+ QCOMPARE(qvariant_cast<QSizeF>(object->property("test3")), QSizeF(-3, 10));
+ QCOMPARE(qvariant_cast<QSizeF>(object->property("test4")), QSizeF());
+ QCOMPARE(qvariant_cast<QSizeF>(object->property("test5")), QSizeF());
+
+ delete object;
+}
+
+void tst_qqmlqt::vector()
+{
+ QQmlComponent component(&engine, testFileUrl("vector.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Error: Qt.vector(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.vector(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QVector3D>(object->property("test1")), QVector3D(1, 0, 0.9));
+ QCOMPARE(qvariant_cast<QVector3D>(object->property("test2")), QVector3D(102, -10, -982.1));
+ QCOMPARE(qvariant_cast<QVector3D>(object->property("test3")), QVector3D());
+ QCOMPARE(qvariant_cast<QVector3D>(object->property("test4")), QVector3D());
+
+ delete object;
+}
+
+void tst_qqmlqt::vector4d()
+{
+ QQmlComponent component(&engine, testFileUrl("vector4.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Error: Qt.vector4d(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.vector4d(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QVector4D>(object->property("test1")), QVector4D(1, 0, 0.9, 0.6));
+ QCOMPARE(qvariant_cast<QVector4D>(object->property("test2")), QVector4D(102, -10, -982.1, 10));
+ QCOMPARE(qvariant_cast<QVector4D>(object->property("test3")), QVector4D());
+ QCOMPARE(qvariant_cast<QVector4D>(object->property("test4")), QVector4D());
+
+ delete object;
+}
+
+void tst_qqmlqt::lighter()
+{
+ QQmlComponent component(&engine, testFileUrl("lighter.qml"));
+
+ QString warning1 = component.url().toString() + ":5: Error: Qt.lighter(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":10: Error: Qt.lighter(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).lighter());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).lighter(180));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").lighter());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
+
+ delete object;
+}
+
+void tst_qqmlqt::darker()
+{
+ QQmlComponent component(&engine, testFileUrl("darker.qml"));
+
+ QString warning1 = component.url().toString() + ":5: Error: Qt.darker(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":10: Error: Qt.darker(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).darker());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0.8, 0.3).darker(280));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor("red").darker());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor());
+
+ delete object;
+}
+
+void tst_qqmlqt::tint()
+{
+ QQmlComponent component(&engine, testFileUrl("tint.qml"));
+
+ QString warning1 = component.url().toString() + ":7: Error: Qt.tint(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":8: Error: Qt.tint(): Invalid arguments";
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(0, 0, 1));
+ QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0, 0));
+ QColor test3 = qvariant_cast<QColor>(object->property("test3"));
+ QCOMPARE(test3.rgba(), 0xFF7F0080);
+ QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor());
+ QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor());
+
+ delete object;
+}
+
+class MyUrlHandler : public QObject
+{
+ Q_OBJECT
+public:
+ MyUrlHandler() : called(0) { }
+ int called;
+ QUrl last;
+
+public slots:
+ void noteCall(const QUrl &url) { called++; last = url; }
+};
+
+void tst_qqmlqt::openUrlExternally()
+{
+ MyUrlHandler handler;
+
+ QDesktopServices::setUrlHandler("test", &handler, "noteCall");
+ QDesktopServices::setUrlHandler("file", &handler, "noteCall");
+
+ QQmlComponent component(&engine, testFileUrl("openUrlExternally.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(handler.called,1);
+ QCOMPARE(handler.last, QUrl("test:url"));
+
+ object->setProperty("testFile", true);
+
+ QCOMPARE(handler.called,2);
+ QCOMPARE(handler.last, testFileUrl("test.html"));
+
+ QDesktopServices::unsetUrlHandler("test");
+ QDesktopServices::unsetUrlHandler("file");
+}
+
+void tst_qqmlqt::openUrlExternally_pragmaLibrary()
+{
+ MyUrlHandler handler;
+
+ QDesktopServices::setUrlHandler("test", &handler, "noteCall");
+ QDesktopServices::setUrlHandler("file", &handler, "noteCall");
+
+ QQmlComponent component(&engine, testFileUrl("openUrlExternally_lib.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(handler.called,1);
+ QCOMPARE(handler.last, QUrl("test:url"));
+
+ object->setProperty("testFile", true);
+
+ QCOMPARE(handler.called,2);
+ QCOMPARE(handler.last, testFileUrl("test.html"));
+
+ QDesktopServices::unsetUrlHandler("test");
+ QDesktopServices::unsetUrlHandler("file");
+}
+
+void tst_qqmlqt::md5()
+{
+ QQmlComponent component(&engine, testFileUrl("md5.qml"));
+
+ QString warning1 = component.url().toString() + ":4: Error: Qt.md5(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test2").toString(), QLatin1String(QCryptographicHash::hash("Hello World", QCryptographicHash::Md5).toHex()));
+
+ delete object;
+}
+
+void tst_qqmlqt::createComponent()
+{
+ QQmlComponent component(&engine, testFileUrl("createComponent.qml"));
+
+ QString warning1 = component.url().toString() + ":9: Error: Qt.createComponent(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":10: Error: Qt.createComponent(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("absoluteUrl").toString(), QString("http://www.example.com/test.qml"));
+ QCOMPARE(object->property("relativeUrl").toString(), testFileUrl("createComponentData.qml").toString());
+
+ delete object;
+}
+
+void tst_qqmlqt::createComponent_pragmaLibrary()
+{
+ // Currently, just loading createComponent_lib.qml causes crash on some platforms
+ QQmlComponent component(&engine, testFileUrl("createComponent_lib.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("status").toInt(), int(QQmlComponent::Ready));
+ QCOMPARE(object->property("readValue").toInt(), int(1913));
+ delete object;
+}
+
+void tst_qqmlqt::createQmlObject()
+{
+ QQmlComponent component(&engine, testFileUrl("createQmlObject.qml"));
+
+ QString warning1 = component.url().toString() + ":7: Error: Qt.createQmlObject(): Invalid arguments";
+ QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("inline").toString() + ":2:10: Blah is not a type";
+ QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("main.qml").toString() + ":4:14: Duplicate property name";
+ QString warning4 = component.url().toString()+ ":9: Error: Qt.createQmlObject(): Missing parent object";
+ QString warning5 = component.url().toString()+ ":8: Error: Qt.createQmlObject(): Invalid arguments";
+ QString warning6 = "RunTimeError: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("inline").toString() + ":3: Cannot assign object type QObject with no default method";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning5));
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(warning6));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("emptyArg").toBool(), true);
+ QCOMPARE(object->property("success").toBool(), true);
+
+ QQuickItem *item = qobject_cast<QQuickItem *>(object);
+ QVERIFY(item != 0);
+ QVERIFY(item->childItems().count() == 1);
+
+ delete object;
+}
+
+
+void tst_qqmlqt::dateTimeConversion()
+{
+ QDate date(2008,12,24);
+ QTime time(14,15,38,200);
+ QDateTime dateTime(date, time);
+ //Note that when converting Date to QDateTime they can argue over historical DST data when converting to local time.
+ //Tests should use UTC or recent dates.
+ QDateTime dateTime2(QDate(2852,12,31), QTime(23,59,59,500));
+ QDateTime dateTime3(QDate(2000,1,1), QTime(0,0,0,0));
+ QDateTime dateTime4(QDate(2001,2,2), QTime(0,0,0,0));
+ QDateTime dateTime5(QDate(1999,1,1), QTime(2,3,4,0));
+ QDateTime dateTime6(QDate(2008,2,24), QTime(14,15,38,200));
+
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("dateTimeConversion.qml"));
+ QObject *obj = component.create();
+
+ QCOMPARE(obj->property("qdate").toDate(), date);
+ QCOMPARE(obj->property("qtime").toTime(), time);
+ QCOMPARE(obj->property("qdatetime").toDateTime(), dateTime);
+ QCOMPARE(obj->property("qdatetime2").toDateTime(), dateTime2);
+ QCOMPARE(obj->property("qdatetime3").toDateTime(), dateTime3);
+ QCOMPARE(obj->property("qdatetime4").toDateTime(), dateTime4);
+ QCOMPARE(obj->property("qdatetime5").toDateTime(), dateTime5);
+ QCOMPARE(obj->property("qdatetime6").toDateTime(), dateTime6);
+}
+
+void tst_qqmlqt::dateTimeFormatting()
+{
+ QFETCH(QString, method);
+ QFETCH(QStringList, inputProperties);
+ QFETCH(QStringList, expectedResults);
+
+ QDate date(2008,12,24);
+ QTime time(14,15,38,200);
+ QDateTime dateTime(date, time);
+
+ QQmlEngine eng;
+
+ eng.rootContext()->setContextProperty("qdate", date);
+ eng.rootContext()->setContextProperty("qtime", time);
+ eng.rootContext()->setContextProperty("qdatetime", dateTime);
+
+ QQmlComponent component(&eng, testFileUrl("formatting.qml"));
+
+ QStringList warnings;
+ warnings << component.url().toString() + ":37: Error: Qt.formatDate(): Invalid date format"
+ << component.url().toString() + ":36: Error: Qt.formatDate(): Invalid arguments"
+ << component.url().toString() + ":40: Error: Qt.formatTime(): Invalid time format"
+ << component.url().toString() + ":39: Error: Qt.formatTime(): Invalid arguments"
+ << component.url().toString() + ":43: Error: Qt.formatDateTime(): Invalid datetime format"
+ << component.url().toString() + ":42: Error: Qt.formatDateTime(): Invalid arguments";
+
+ foreach (const QString &warning, warnings)
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ QObject *object = component.create();
+ QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
+ QVERIFY(object != 0);
+
+ QVERIFY(inputProperties.count() > 0);
+ QVariant result;
+ foreach(const QString &prop, inputProperties) {
+ QVERIFY(QMetaObject::invokeMethod(object, method.toUtf8().constData(),
+ Q_RETURN_ARG(QVariant, result),
+ Q_ARG(QVariant, prop)));
+ QStringList output = result.toStringList();
+ QCOMPARE(output.size(), expectedResults.size());
+ for (int i=0; i<output.count(); i++)
+ QCOMPARE(output[i], expectedResults[i]);
+ }
+
+ delete object;
+}
+
+void tst_qqmlqt::dateTimeFormatting_data()
+{
+ QTest::addColumn<QString>("method");
+ QTest::addColumn<QStringList>("inputProperties");
+ QTest::addColumn<QStringList>("expectedResults");
+
+ QDate date(2008,12,24);
+ QTime time(14,15,38,200);
+ QDateTime dateTime(date, time);
+
+ QTest::newRow("formatDate")
+ << "formatDate"
+ << (QStringList() << "dateFromString" << "jsdate" << "qdate" << "qdatetime")
+ << (QStringList() << date.toString(Qt::DefaultLocaleShortDate)
+ << date.toString(Qt::DefaultLocaleLongDate)
+ << date.toString("ddd MMMM d yy"));
+
+ QTest::newRow("formatTime")
+ << "formatTime"
+ << (QStringList() << "jsdate" << "qtime" << "qdatetime")
+ << (QStringList() << time.toString(Qt::DefaultLocaleShortDate)
+ << time.toString(Qt::DefaultLocaleLongDate)
+ << time.toString("H:m:s a")
+ << time.toString("hh:mm:ss.zzz"));
+
+ QTest::newRow("formatDateTime")
+ << "formatDateTime"
+ << (QStringList() << "jsdate" << "qdatetime")
+ << (QStringList() << dateTime.toString(Qt::DefaultLocaleShortDate)
+ << dateTime.toString(Qt::DefaultLocaleLongDate)
+ << dateTime.toString("M/d/yy H:m:s a"));
+}
+
+void tst_qqmlqt::dateTimeFormattingVariants()
+{
+ QFETCH(QString, method);
+ QFETCH(QVariant, variant);
+ QFETCH(QStringList, expectedResults);
+
+ QQmlEngine eng;
+ eng.rootContext()->setContextProperty("qvariant", variant);
+ QQmlComponent component(&eng, testFileUrl("formatting.qml"));
+
+ QStringList warnings;
+ warnings << component.url().toString() + ":37: Error: Qt.formatDate(): Invalid date format"
+ << component.url().toString() + ":36: Error: Qt.formatDate(): Invalid arguments"
+ << component.url().toString() + ":40: Error: Qt.formatTime(): Invalid time format"
+ << component.url().toString() + ":39: Error: Qt.formatTime(): Invalid arguments"
+ << component.url().toString() + ":43: Error: Qt.formatDateTime(): Invalid datetime format"
+ << component.url().toString() + ":42: Error: Qt.formatDateTime(): Invalid arguments";
+
+ foreach (const QString &warning, warnings)
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ QObject *object = component.create();
+ QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
+ QVERIFY(object != 0);
+
+ QVariant result;
+ QVERIFY(QMetaObject::invokeMethod(object, method.toUtf8().constData(),
+ Q_RETURN_ARG(QVariant, result),
+ Q_ARG(QVariant, QString(QLatin1String("qvariant")))));
+ QStringList output = result.toStringList();
+ QCOMPARE(output, expectedResults);
+
+ delete object;
+}
+
+void tst_qqmlqt::dateTimeFormattingVariants_data()
+{
+ QTest::addColumn<QString>("method");
+ QTest::addColumn<QVariant>("variant");
+ QTest::addColumn<QStringList>("expectedResults");
+
+ QDateTime temporary;
+
+ QTime time(11, 16, 39, 755);
+ temporary = QDateTime(QDate(1970,1,1), time);
+ QTest::newRow("formatDate, qtime") << "formatDate" << QVariant::fromValue(time) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
+ QTest::newRow("formatDateTime, qtime") << "formatDateTime" << QVariant::fromValue(time) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
+ QTest::newRow("formatTime, qtime") << "formatTime" << QVariant::fromValue(time) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
+
+ QDate date(2011,5,31);
+ temporary = QDateTime(date);
+ QTest::newRow("formatDate, qdate") << "formatDate" << QVariant::fromValue(date) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
+ QTest::newRow("formatDateTime, qdate") << "formatDateTime" << QVariant::fromValue(date) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
+ QTest::newRow("formatTime, qdate") << "formatTime" << QVariant::fromValue(date) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
+
+ QDateTime dateTime(date, time);
+ temporary = dateTime;
+ QTest::newRow("formatDate, qdatetime") << "formatDate" << QVariant::fromValue(dateTime) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
+ QTest::newRow("formatDateTime, qdatetime") << "formatDateTime" << QVariant::fromValue(dateTime) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
+ QTest::newRow("formatTime, qdatetime") << "formatTime" << QVariant::fromValue(dateTime) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
+
+ QString string(QLatin1String("2011/05/31 11:16:39.755"));
+ temporary = QDateTime::fromString(string, "yyyy/MM/dd HH:mm:ss.zzz");
+ QTest::newRow("formatDate, qstring") << "formatDate" << QVariant::fromValue(string) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
+ QTest::newRow("formatDateTime, qstring") << "formatDateTime" << QVariant::fromValue(string) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
+ QTest::newRow("formatTime, qstring") << "formatTime" << QVariant::fromValue(string) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
+
+ QColor color(Qt::red);
+ temporary = QVariant::fromValue(color).toDateTime();
+ QTest::newRow("formatDate, qcolor") << "formatDate" << QVariant::fromValue(color) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
+ QTest::newRow("formatDateTime, qcolor") << "formatDateTime" << QVariant::fromValue(color) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
+ QTest::newRow("formatTime, qcolor") << "formatTime" << QVariant::fromValue(color) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
+
+ int integer(4);
+ temporary = QVariant::fromValue(integer).toDateTime();
+ QTest::newRow("formatDate, int") << "formatDate" << QVariant::fromValue(integer) << (QStringList() << temporary.date().toString(Qt::DefaultLocaleShortDate) << temporary.date().toString(Qt::DefaultLocaleLongDate) << temporary.date().toString("ddd MMMM d yy"));
+ QTest::newRow("formatDateTime, int") << "formatDateTime" << QVariant::fromValue(integer) << (QStringList() << temporary.toString(Qt::DefaultLocaleShortDate) << temporary.toString(Qt::DefaultLocaleLongDate) << temporary.toString("M/d/yy H:m:s a"));
+ QTest::newRow("formatTime, int") << "formatTime" << QVariant::fromValue(integer) << (QStringList() << temporary.time().toString(Qt::DefaultLocaleShortDate) << temporary.time().toString(Qt::DefaultLocaleLongDate) << temporary.time().toString("H:m:s a") << temporary.time().toString("hh:mm:ss.zzz"));
+}
+
+void tst_qqmlqt::isQtObject()
+{
+ QQmlComponent component(&engine, testFileUrl("isQtObject.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), false);
+ QCOMPARE(object->property("test3").toBool(), false);
+ QCOMPARE(object->property("test4").toBool(), false);
+ QCOMPARE(object->property("test5").toBool(), false);
+
+ delete object;
+}
+
+void tst_qqmlqt::btoa()
+{
+ QQmlComponent component(&engine, testFileUrl("btoa.qml"));
+
+ QString warning1 = component.url().toString() + ":4: Error: Qt.btoa(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test2").toString(), QString("SGVsbG8gd29ybGQh"));
+
+ delete object;
+}
+
+void tst_qqmlqt::atob()
+{
+ QQmlComponent component(&engine, testFileUrl("atob.qml"));
+
+ QString warning1 = component.url().toString() + ":4: Error: Qt.atob(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test2").toString(), QString("Hello world!"));
+
+ delete object;
+}
+
+void tst_qqmlqt::fontFamilies()
+{
+ QQmlComponent component(&engine, testFileUrl("fontFamilies.qml"));
+
+ QString warning1 = component.url().toString() + ":4: Error: Qt.fontFamilies(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QFontDatabase database;
+ QCOMPARE(object->property("test2"), QVariant::fromValue(database.families()));
+
+ delete object;
+}
+
+void tst_qqmlqt::quit()
+{
+ QQmlComponent component(&engine, testFileUrl("quit.qml"));
+
+ QSignalSpy spy(&engine, SIGNAL(quit()));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(spy.count(), 1);
+
+ delete object;
+}
+
+void tst_qqmlqt::resolvedUrl()
+{
+ QQmlComponent component(&engine, testFileUrl("resolvedUrl.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("result").toString(), component.url().toString());
+ QCOMPARE(object->property("isString").toBool(), true);
+
+ delete object;
+}
+
+QTEST_MAIN(tst_qqmlqt)
+
+#include "tst_qqmlqt.moc"
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/README b/tests/auto/qml/qqmlsqldatabase/data/README
index 7efca3a972..7efca3a972 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/README
+++ b/tests/auto/qml/qqmlsqldatabase/data/README
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/changeversion.js b/tests/auto/qml/qqmlsqldatabase/data/changeversion.js
index 178ff7c4af..178ff7c4af 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/changeversion.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/changeversion.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/creation-a.js b/tests/auto/qml/qqmlsqldatabase/data/creation-a.js
index 25cba05451..25cba05451 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/creation-a.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/creation-a.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/creation.js b/tests/auto/qml/qqmlsqldatabase/data/creation.js
index 64eb4c7b92..64eb4c7b92 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/creation.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/creation.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/error-a.js b/tests/auto/qml/qqmlsqldatabase/data/error-a.js
index d7e9b4fdff..d7e9b4fdff 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/error-a.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/error-a.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/error-b.js b/tests/auto/qml/qqmlsqldatabase/data/error-b.js
index 17e34c989e..17e34c989e 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/error-b.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/error-b.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/error-creation.js b/tests/auto/qml/qqmlsqldatabase/data/error-creation.js
index d66977d1e2..d66977d1e2 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/error-creation.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/error-creation.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/error-notransaction.js b/tests/auto/qml/qqmlsqldatabase/data/error-notransaction.js
index 2cce3f613c..2cce3f613c 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/error-notransaction.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/error-notransaction.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/error-outsidetransaction.js b/tests/auto/qml/qqmlsqldatabase/data/error-outsidetransaction.js
index 7af7c1c6a2..7af7c1c6a2 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/error-outsidetransaction.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/error-outsidetransaction.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/iteration-forwardonly.js b/tests/auto/qml/qqmlsqldatabase/data/iteration-forwardonly.js
index b3df1be113..b3df1be113 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/iteration-forwardonly.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/iteration-forwardonly.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/iteration.js b/tests/auto/qml/qqmlsqldatabase/data/iteration.js
index 8d96dc2154..8d96dc2154 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/iteration.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/iteration.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/readonly-error.js b/tests/auto/qml/qqmlsqldatabase/data/readonly-error.js
index 39eb398004..39eb398004 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/readonly-error.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/readonly-error.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/readonly.js b/tests/auto/qml/qqmlsqldatabase/data/readonly.js
index 985c9ecab5..985c9ecab5 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/readonly.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/readonly.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/reopen1.js b/tests/auto/qml/qqmlsqldatabase/data/reopen1.js
index 2171fb028e..2171fb028e 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/reopen1.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/reopen1.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/reopen2.js b/tests/auto/qml/qqmlsqldatabase/data/reopen2.js
index 12c6135145..12c6135145 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/reopen2.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/reopen2.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/selection-bindnames.js b/tests/auto/qml/qqmlsqldatabase/data/selection-bindnames.js
index 9333ccfacb..9333ccfacb 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/selection-bindnames.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/selection-bindnames.js
diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/selection.js b/tests/auto/qml/qqmlsqldatabase/data/selection.js
index 18d4dce80f..18d4dce80f 100644
--- a/tests/auto/declarative/qdeclarativesqldatabase/data/selection.js
+++ b/tests/auto/qml/qqmlsqldatabase/data/selection.js
diff --git a/tests/auto/qml/qqmlsqldatabase/qqmlsqldatabase.pro b/tests/auto/qml/qqmlsqldatabase/qqmlsqldatabase.pro
new file mode 100644
index 0000000000..c17e16bfdd
--- /dev/null
+++ b/tests/auto/qml/qqmlsqldatabase/qqmlsqldatabase.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qqmlsqldatabase
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmlsqldatabase.cpp
+
+include (../../shared/util.pri)
+
+CONFIG += parallel_test
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+QT += core-private gui-private v8-private qml-private quick-private sql testlib
diff --git a/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp b/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp
new file mode 100644
index 0000000000..c1a8a63a4d
--- /dev/null
+++ b/tests/auto/qml/qqmlsqldatabase/tst_qqmlsqldatabase.cpp
@@ -0,0 +1,243 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <private/qqmlengine_p.h>
+#include <QtCore/qcryptographichash.h>
+/*
+#include <QtWebKit/qwebpage.h>
+#include <QtWebKit/qwebframe.h>
+#include <QtWebKit/qwebdatabase.h>
+#include <QtWebKit/qwebsecurityorigin.h>
+*/
+#include <QtSql/qsqldatabase.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qfile.h>
+#include "../../shared/util.h"
+
+class tst_qqmlsqldatabase : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlsqldatabase()
+ {
+ qApp->setApplicationName("tst_qqmlsqldatabase");
+ qApp->setOrganizationName("Nokia");
+ qApp->setOrganizationDomain("nokia.com");
+ engine = new QQmlEngine;
+ }
+
+ ~tst_qqmlsqldatabase()
+ {
+ delete engine;
+ }
+
+private slots:
+ void initTestCase();
+
+ void checkDatabasePath();
+
+ void testQml_data();
+ void testQml();
+ void testQml_cleanopen_data();
+ void testQml_cleanopen();
+ void totalDatabases();
+
+ void cleanupTestCase();
+
+private:
+ QString dbDir() const;
+ QQmlEngine *engine;
+};
+
+void removeRecursive(const QString& dirname)
+{
+ QDir dir(dirname);
+ QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot));
+ for (int i = 0; i < entries.count(); ++i)
+ if (entries[i].isDir())
+ removeRecursive(entries[i].filePath());
+ else
+ dir.remove(entries[i].fileName());
+ QDir().rmdir(dirname);
+}
+
+void tst_qqmlsqldatabase::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ removeRecursive(dbDir());
+ QDir().mkpath(dbDir());
+}
+
+void tst_qqmlsqldatabase::cleanupTestCase()
+{
+ removeRecursive(dbDir());
+}
+
+QString tst_qqmlsqldatabase::dbDir() const
+{
+ static QString tmpd = QDir::tempPath()+"/tst_qqmlsqldatabase_output-"
+ + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss"));
+ return tmpd;
+}
+
+void tst_qqmlsqldatabase::checkDatabasePath()
+{
+ // Check default storage path (we can't use it since we don't want to mess with user's data)
+ QVERIFY(engine->offlineStoragePath().contains("tst_qqmlsqldatabase"));
+ QVERIFY(engine->offlineStoragePath().contains("OfflineStorage"));
+}
+
+static const int total_databases_created_by_tests = 12;
+void tst_qqmlsqldatabase::testQml_data()
+{
+ QTest::addColumn<QString>("jsfile"); // The input file
+
+ // Each test should use a newly named DB to avoid inter-test dependencies
+ QTest::newRow("creation") << "creation.js";
+ QTest::newRow("creation-a") << "creation-a.js";
+ QTest::newRow("creation") << "creation.js";
+ QTest::newRow("error-creation") << "error-creation.js"; // re-uses above DB
+ QTest::newRow("changeversion") << "changeversion.js";
+ QTest::newRow("readonly") << "readonly.js";
+ QTest::newRow("readonly-error") << "readonly-error.js";
+ QTest::newRow("selection") << "selection.js";
+ QTest::newRow("selection-bindnames") << "selection-bindnames.js";
+ QTest::newRow("iteration") << "iteration.js";
+ QTest::newRow("iteration-forwardonly") << "iteration-forwardonly.js";
+ QTest::newRow("error-a") << "error-a.js";
+ QTest::newRow("error-notransaction") << "error-notransaction.js";
+ QTest::newRow("error-outsidetransaction") << "error-outsidetransaction.js"; // reuse above
+ QTest::newRow("reopen1") << "reopen1.js";
+ QTest::newRow("reopen2") << "reopen2.js"; // re-uses above DB
+
+ // If you add a test, you should usually use a new database in the
+ // test - in which case increment total_databases_created_by_tests above.
+}
+
+/*
+class QWebPageWithJavaScriptConsoleMessages : public QWebPage {
+public:
+ void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID)
+ {
+ qWarning() << sourceID << ":" << lineNumber << ":" << message;
+ }
+};
+
+void tst_qqmlsqldatabase::validateAgainstWebkit()
+{
+ // Validates tests against WebKit (HTML5) support.
+ //
+ QFETCH(QString, jsfile);
+ QFETCH(QString, result);
+ QFETCH(int, databases);
+
+ QFile f(jsfile);
+ QVERIFY(f.open(QIODevice::ReadOnly));
+ QString js=f.readAll();
+
+ QWebPageWithJavaScriptConsoleMessages webpage;
+ webpage.settings()->setOfflineStoragePath(dbDir());
+ webpage.settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true);
+
+ QEXPECT_FAIL("","WebKit doesn't support openDatabaseSync yet", Continue);
+ QCOMPARE(webpage.mainFrame()->evaluateJavaScript(js).toString(),result);
+
+ QTest::qWait(100); // WebKit crashes if you quit it too fast
+
+ QWebSecurityOrigin origin = webpage.mainFrame()->securityOrigin();
+ QList<QWebDatabase> dbs = origin.databases();
+ QCOMPARE(dbs.count(), databases);
+}
+*/
+
+void tst_qqmlsqldatabase::testQml()
+{
+ // Tests QML SQL Database support with tests
+ // that have been validated against Webkit.
+ //
+ QFETCH(QString, jsfile);
+
+ QString qml=
+ "import QtQuick 2.0\n"
+ "import \""+jsfile+"\" as JS\n"
+ "Text { text: JS.test() }";
+
+ engine->setOfflineStoragePath(dbDir());
+ QQmlComponent component(engine);
+ component.setData(qml.toUtf8(), testFileUrl("empty.qml")); // just a file for relative local imports
+ QVERIFY(!component.isError());
+ QQuickText *text = qobject_cast<QQuickText*>(component.create());
+ QVERIFY(text != 0);
+ QCOMPARE(text->text(),QString("passed"));
+}
+
+void tst_qqmlsqldatabase::testQml_cleanopen_data()
+{
+ QTest::addColumn<QString>("jsfile"); // The input file
+ QTest::newRow("reopen1") << "reopen1.js";
+ QTest::newRow("reopen2") << "reopen2.js";
+ QTest::newRow("error-creation") << "error-creation.js"; // re-uses creation DB
+}
+
+void tst_qqmlsqldatabase::testQml_cleanopen()
+{
+ // Same as testQml, but clean connections between tests,
+ // making it more like the tests are running in new processes.
+ testQml();
+
+ engine->collectGarbage();
+
+ foreach (QString dbname, QSqlDatabase::connectionNames()) {
+ QSqlDatabase::removeDatabase(dbname);
+ }
+}
+
+void tst_qqmlsqldatabase::totalDatabases()
+{
+ QCOMPARE(QDir(dbDir()+"/Databases").entryInfoList(QDir::Files|QDir::NoDotAndDotDot).count(), total_databases_created_by_tests*2);
+}
+
+QTEST_MAIN(tst_qqmlsqldatabase)
+
+#include "tst_qqmlsqldatabase.moc"
diff --git a/tests/auto/declarative/qdeclarativetranslation/data/idtranslation.qml b/tests/auto/qml/qqmltranslation/data/idtranslation.qml
index b128a1e578..b128a1e578 100644
--- a/tests/auto/declarative/qdeclarativetranslation/data/idtranslation.qml
+++ b/tests/auto/qml/qqmltranslation/data/idtranslation.qml
diff --git a/tests/auto/declarative/qdeclarativetranslation/data/qml_fr.qm b/tests/auto/qml/qqmltranslation/data/qml_fr.qm
index 252022515a..252022515a 100644
--- a/tests/auto/declarative/qdeclarativetranslation/data/qml_fr.qm
+++ b/tests/auto/qml/qqmltranslation/data/qml_fr.qm
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetranslation/data/qml_fr.ts b/tests/auto/qml/qqmltranslation/data/qml_fr.ts
index b003e239bc..b003e239bc 100644
--- a/tests/auto/declarative/qdeclarativetranslation/data/qml_fr.ts
+++ b/tests/auto/qml/qqmltranslation/data/qml_fr.ts
diff --git a/tests/auto/declarative/qdeclarativetranslation/data/qmlid_fr.qm b/tests/auto/qml/qqmltranslation/data/qmlid_fr.qm
index 265164916f..265164916f 100644
--- a/tests/auto/declarative/qdeclarativetranslation/data/qmlid_fr.qm
+++ b/tests/auto/qml/qqmltranslation/data/qmlid_fr.qm
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetranslation/data/qmlid_fr.ts b/tests/auto/qml/qqmltranslation/data/qmlid_fr.ts
index bff39b80b6..bff39b80b6 100644
--- a/tests/auto/declarative/qdeclarativetranslation/data/qmlid_fr.ts
+++ b/tests/auto/qml/qqmltranslation/data/qmlid_fr.ts
diff --git a/tests/auto/declarative/qdeclarativetranslation/data/translation.qml b/tests/auto/qml/qqmltranslation/data/translation.qml
index 8435bedb28..8435bedb28 100644
--- a/tests/auto/declarative/qdeclarativetranslation/data/translation.qml
+++ b/tests/auto/qml/qqmltranslation/data/translation.qml
diff --git a/tests/auto/declarative/qdeclarativetranslation/data/translation.qrc b/tests/auto/qml/qqmltranslation/data/translation.qrc
index 2e2d0a0497..2e2d0a0497 100644
--- a/tests/auto/declarative/qdeclarativetranslation/data/translation.qrc
+++ b/tests/auto/qml/qqmltranslation/data/translation.qrc
diff --git a/tests/auto/qml/qqmltranslation/qqmltranslation.pro b/tests/auto/qml/qqmltranslation/qqmltranslation.pro
new file mode 100644
index 0000000000..d3f98e181f
--- /dev/null
+++ b/tests/auto/qml/qqmltranslation/qqmltranslation.pro
@@ -0,0 +1,16 @@
+CONFIG += testcase
+TARGET = tst_qqmltranslation
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qqmltranslation.cpp
+RESOURCES += data/translation.qrc
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private testlib
diff --git a/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp
new file mode 100644
index 0000000000..077fa18f5f
--- /dev/null
+++ b/tests/auto/qml/qqmltranslation/tst_qqmltranslation.cpp
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QTranslator>
+#include "../../shared/util.h"
+
+class tst_qqmltranslation : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmltranslation() {}
+
+private slots:
+ void translation();
+ void idTranslation();
+ void translationInQrc();
+};
+
+void tst_qqmltranslation::translation()
+{
+ QTranslator translator;
+ translator.load(QLatin1String("qml_fr"), dataDirectory());
+ QCoreApplication::installTranslator(&translator);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("translation.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("basic").toString(), QLatin1String("bonjour"));
+ QCOMPARE(object->property("basic2").toString(), QLatin1String("au revoir"));
+ QCOMPARE(object->property("basic3").toString(), QLatin1String("bonjour"));
+ QCOMPARE(object->property("disambiguation").toString(), QLatin1String("salut"));
+ QCOMPARE(object->property("disambiguation2").toString(), QString::fromUtf8("\xc3\xa0 plus tard"));
+ QCOMPARE(object->property("disambiguation3").toString(), QLatin1String("salut"));
+ QCOMPARE(object->property("noop").toString(), QLatin1String("bonjour"));
+ QCOMPARE(object->property("noop2").toString(), QLatin1String("au revoir"));
+ QCOMPARE(object->property("singular").toString(), QLatin1String("1 canard"));
+ QCOMPARE(object->property("singular2").toString(), QLatin1String("1 canard"));
+ QCOMPARE(object->property("plural").toString(), QLatin1String("2 canards"));
+ QCOMPARE(object->property("plural2").toString(), QLatin1String("2 canards"));
+
+ QCoreApplication::removeTranslator(&translator);
+ delete object;
+}
+
+void tst_qqmltranslation::idTranslation()
+{
+ QTranslator translator;
+ translator.load(QLatin1String("qmlid_fr"), dataDirectory());
+ QCoreApplication::installTranslator(&translator);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("idtranslation.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("idTranslation").toString(), QLatin1String("bonjour tout le monde"));
+ QCOMPARE(object->property("idTranslation2").toString(), QLatin1String("bonjour tout le monde"));
+ QCOMPARE(object->property("idTranslation3").toString(), QLatin1String("bonjour tout le monde"));
+
+ QCoreApplication::removeTranslator(&translator);
+ delete object;
+}
+
+void tst_qqmltranslation::translationInQrc()
+{
+ QTranslator translator;
+ translator.load(":/qml_fr.qm");
+ QCoreApplication::installTranslator(&translator);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl("qrc:/translation.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("basic").toString(), QLatin1String("bonjour"));
+ QCOMPARE(object->property("basic2").toString(), QLatin1String("au revoir"));
+ QCOMPARE(object->property("basic3").toString(), QLatin1String("bonjour"));
+ QCOMPARE(object->property("disambiguation").toString(), QLatin1String("salut"));
+ QCOMPARE(object->property("disambiguation2").toString(), QString::fromUtf8("\xc3\xa0 plus tard"));
+ QCOMPARE(object->property("disambiguation3").toString(), QLatin1String("salut"));
+ QCOMPARE(object->property("noop").toString(), QLatin1String("bonjour"));
+ QCOMPARE(object->property("noop2").toString(), QLatin1String("au revoir"));
+ QCOMPARE(object->property("singular").toString(), QLatin1String("1 canard"));
+ QCOMPARE(object->property("singular2").toString(), QLatin1String("1 canard"));
+ QCOMPARE(object->property("plural").toString(), QLatin1String("2 canards"));
+ QCOMPARE(object->property("plural2").toString(), QLatin1String("2 canards"));
+
+ QCoreApplication::removeTranslator(&translator);
+ delete object;
+}
+
+QTEST_MAIN(tst_qqmltranslation)
+
+#include "tst_qqmltranslation.moc"
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType.qml b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType.qml
index f625d081e5..f625d081e5 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType4.qml b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType4.qml
index 0bdccce5be..0bdccce5be 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType4.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType4.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType5.qml b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType5.qml
index 151c49971e..151c49971e 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/BindingsSpliceCorrectlyType5.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/BindingsSpliceCorrectlyType5.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.2.qml b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.2.qml
index ce2e82d0f8..ce2e82d0f8 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.2.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.2.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.3.qml
index d431b4ae08..d431b4ae08 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.3.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.3.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.qml b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.qml
index a8a72f515b..a8a72f515b 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/autoBindingRemoval.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/autoBindingRemoval.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingAssignment.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml
index a65218669b..a65218669b 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingAssignment.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingAssignment.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingConflict.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingConflict.qml
index fd25c9f0a7..fd25c9f0a7 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingConflict.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingConflict.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingRead.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingRead.qml
index 538d776fba..538d776fba 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingRead.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingRead.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingVariantCopy.qml
index 3a48c8bdb1..3a48c8bdb1 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingVariantCopy.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingVariantCopy.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.1.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.1.qml
index 2a1b936da6..2a1b936da6 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.1.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.1.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.2.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.2.qml
index 84b465c565..84b465c565 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.2.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.2.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.3.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.3.qml
index f1212f8039..f1212f8039 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.3.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.3.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.4.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.4.qml
index 9c5e950660..9c5e950660 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.4.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.4.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.5.qml b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.5.qml
index 7d87ba1782..7d87ba1782 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/bindingsSpliceCorrectly.5.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/bindingsSpliceCorrectly.5.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/color_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/color_compare.qml
index 8701dae612..8701dae612 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/color_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/color_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/color_read.qml b/tests/auto/qml/qqmlvaluetypes/data/color_read.qml
index bc92b1e5f9..bc92b1e5f9 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/color_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/color_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/color_write.qml b/tests/auto/qml/qqmlvaluetypes/data/color_write.qml
index 3f1bad4aa6..3f1bad4aa6 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/color_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/color_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.1.qml b/tests/auto/qml/qqmlvaluetypes/data/conflicting.1.qml
index 923922c55a..923922c55a 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.1.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/conflicting.1.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.2.qml b/tests/auto/qml/qqmlvaluetypes/data/conflicting.2.qml
index 9804af4df6..9804af4df6 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.2.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/conflicting.2.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.3.qml b/tests/auto/qml/qqmlvaluetypes/data/conflicting.3.qml
index b5bb7f8ccc..b5bb7f8ccc 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/conflicting.3.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/conflicting.3.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.js b/tests/auto/qml/qqmlvaluetypes/data/deletedObject.js
index af298ffbd0..af298ffbd0 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.js
+++ b/tests/auto/qml/qqmlvaluetypes/data/deletedObject.js
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml b/tests/auto/qml/qqmlvaluetypes/data/deletedObject.qml
index 4f7ad39db0..4f7ad39db0 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/deletedObject.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/deletedObject.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.1.qml
index cb01a80669..cb01a80669 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.1.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/enums.1.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.2.qml
index 93f1ed59bc..93f1ed59bc 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.2.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/enums.2.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.3.qml
index cc7861a122..cc7861a122 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.3.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/enums.3.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.4.qml
index cf41c90b90..cf41c90b90 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.4.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/enums.4.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml b/tests/auto/qml/qqmlvaluetypes/data/enums.5.qml
index de279dba6c..de279dba6c 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/enums.5.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/enums.5.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/font_compare.qml
index efbb0e3d0b..efbb0e3d0b 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/font_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml b/tests/auto/qml/qqmlvaluetypes/data/font_read.qml
index d73bb132d3..d73bb132d3 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/font_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.2.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.2.qml
index b559389efb..b559389efb 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.2.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.2.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.3.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.3.qml
index 913ac50738..913ac50738 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.3.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.3.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.4.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.4.qml
index 2ec69d7281..2ec69d7281 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.4.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.4.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.5.qml
index 5297a8260d..5297a8260d 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.5.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.5.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.qml b/tests/auto/qml/qqmlvaluetypes/data/font_write.qml
index ff4d0a1004..ff4d0a1004 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/font_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/font_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_compare.qml
index 94292302cc..94292302cc 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_read.qml b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_read.qml
index 6c4a68258c..6c4a68258c 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_write.qml b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_write.qml
index 2a9f154d6f..2a9f154d6f 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/matrix4x4_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/point_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/point_compare.qml
index c0041b4bb1..c0041b4bb1 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/point_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/point_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml b/tests/auto/qml/qqmlvaluetypes/data/point_read.qml
index 4bb6c5384c..4bb6c5384c 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/point_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/point_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/point_write.qml b/tests/auto/qml/qqmlvaluetypes/data/point_write.qml
index 063525a6f0..063525a6f0 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/point_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/point_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/pointf_compare.qml
index 0d70137934..0d70137934 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/pointf_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml b/tests/auto/qml/qqmlvaluetypes/data/pointf_read.qml
index 0eab6daabe..0eab6daabe 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/pointf_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_write.qml b/tests/auto/qml/qqmlvaluetypes/data/pointf_write.qml
index 9ee3fc1bda..9ee3fc1bda 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/pointf_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/pointf_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/quaternion_compare.qml
index 0e82f596af..0e82f596af 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/quaternion_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_read.qml b/tests/auto/qml/qqmlvaluetypes/data/quaternion_read.qml
index d1a21dc926..d1a21dc926 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/quaternion_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_write.qml b/tests/auto/qml/qqmlvaluetypes/data/quaternion_write.qml
index 0c3e5afd98..0c3e5afd98 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/quaternion_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/quaternion_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/rect_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/rect_compare.qml
index c511c2dfc4..c511c2dfc4 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/rect_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/rect_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml b/tests/auto/qml/qqmlvaluetypes/data/rect_read.qml
index c3b37a7099..c3b37a7099 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/rect_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/rect_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/rect_write.qml b/tests/auto/qml/qqmlvaluetypes/data/rect_write.qml
index 8add45305c..8add45305c 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/rect_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/rect_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/rectf_compare.qml
index 6ac4049558..6ac4049558 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/rectf_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml b/tests/auto/qml/qqmlvaluetypes/data/rectf_read.qml
index 6ff3ce30bf..6ff3ce30bf 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/rectf_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_write.qml b/tests/auto/qml/qqmlvaluetypes/data/rectf_write.qml
index 1e6ff4ff90..1e6ff4ff90 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/rectf_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/rectf_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml b/tests/auto/qml/qqmlvaluetypes/data/returnValues.qml
index 1f9816f666..1f9816f666 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/returnValues.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml b/tests/auto/qml/qqmlvaluetypes/data/scriptAccess.qml
index cbecb4379a..cbecb4379a 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/scriptAccess.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/scriptAccess.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml b/tests/auto/qml/qqmlvaluetypes/data/scriptVariantCopy.qml
index 42fccfac5a..42fccfac5a 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/scriptVariantCopy.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/scriptVariantCopy.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/size_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/size_compare.qml
index 1fd4711c15..1fd4711c15 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/size_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/size_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml b/tests/auto/qml/qqmlvaluetypes/data/size_read.qml
index a49fd9f760..a49fd9f760 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/size_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/size_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/size_write.qml b/tests/auto/qml/qqmlvaluetypes/data/size_write.qml
index 2f9d10e45f..2f9d10e45f 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/size_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/size_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/sizef_compare.qml
index c74a049454..c74a049454 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizef_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml b/tests/auto/qml/qqmlvaluetypes/data/sizef_read.qml
index 96cd425f17..96cd425f17 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizef_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_write.qml b/tests/auto/qml/qqmlvaluetypes/data/sizef_write.qml
index f16f0bdf93..f16f0bdf93 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizef_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizef_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_read.qml
index 7f708a0899..7f708a0899 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror.qml
index 3254557014..3254557014 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror2.qml
index 656d718b05..656d718b05 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror2.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror2.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror3.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror3.qml
index b8e3f0d41b..b8e3f0d41b 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror3.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror3.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror4.qml b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror4.qml
index 68b54b571e..68b54b571e 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/sizereadonly_writeerror4.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/sizereadonly_writeerror4.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/staticAssignment.qml b/tests/auto/qml/qqmlvaluetypes/data/staticAssignment.qml
index b687f89eef..b687f89eef 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/staticAssignment.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/staticAssignment.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml b/tests/auto/qml/qqmlvaluetypes/data/valueInterceptors.qml
index 0897847d2d..0897847d2d 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/valueInterceptors.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/valueInterceptors.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml b/tests/auto/qml/qqmlvaluetypes/data/valueSources.qml
index 717f3502c0..717f3502c0 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/valueSources.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/valueSources.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml b/tests/auto/qml/qqmlvaluetypes/data/varAssignment.qml
index 9b56abbbed..9b56abbbed 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/varAssignment.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/varAssignment.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/variant_read.qml b/tests/auto/qml/qqmlvaluetypes/data/variant_read.qml
index a08f3db94f..a08f3db94f 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/variant_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/variant_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/vector2d_compare.qml
index eb8fb5bb76..eb8fb5bb76 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector2d_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_read.qml b/tests/auto/qml/qqmlvaluetypes/data/vector2d_read.qml
index fc315f7abf..fc315f7abf 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector2d_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_write.qml b/tests/auto/qml/qqmlvaluetypes/data/vector2d_write.qml
index f0e35ff200..f0e35ff200 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector2d_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector2d_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/vector3d_compare.qml
index 7bda1d17f4..7bda1d17f4 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector3d_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml b/tests/auto/qml/qqmlvaluetypes/data/vector3d_read.qml
index f1e876dbb9..f1e876dbb9 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector3d_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_write.qml b/tests/auto/qml/qqmlvaluetypes/data/vector3d_write.qml
index 9c1bf7620a..9c1bf7620a 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector3d_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector3d_write.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/vector4d_compare.qml
index 3ea42a59ce..3ea42a59ce 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_compare.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector4d_compare.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_read.qml b/tests/auto/qml/qqmlvaluetypes/data/vector4d_read.qml
index f9d5d6053e..f9d5d6053e 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_read.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector4d_read.qml
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_write.qml b/tests/auto/qml/qqmlvaluetypes/data/vector4d_write.qml
index 548698126d..548698126d 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/data/vector4d_write.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/vector4d_write.qml
diff --git a/tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro b/tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro
new file mode 100644
index 0000000000..6051f65936
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/qqmlvaluetypes.pro
@@ -0,0 +1,18 @@
+CONFIG += testcase
+TARGET = tst_qqmlvaluetypes
+macx:CONFIG -= app_bundle
+
+HEADERS += testtypes.h
+
+SOURCES += tst_qqmlvaluetypes.cpp \
+ testtypes.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private testlib
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp b/tests/auto/qml/qqmlvaluetypes/testtypes.cpp
index ef9f268b2f..ef9f268b2f 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.cpp
+++ b/tests/auto/qml/qqmlvaluetypes/testtypes.cpp
diff --git a/tests/auto/qml/qqmlvaluetypes/testtypes.h b/tests/auto/qml/qqmlvaluetypes/testtypes.h
new file mode 100644
index 0000000000..813c58567f
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/testtypes.h
@@ -0,0 +1,219 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TESTTYPES_H
+#define TESTTYPES_H
+
+#include <QObject>
+#include <QPoint>
+#include <QPointF>
+#include <QSize>
+#include <QSizeF>
+#include <QRect>
+#include <QRectF>
+#include <QVector2D>
+#include <QVector3D>
+#include <QVector4D>
+#include <QQuaternion>
+#include <QMatrix4x4>
+#include <QFont>
+#include <QColor>
+#include <qqml.h>
+#include <QQmlPropertyValueSource>
+#include <QQmlProperty>
+#include <private/qqmlproperty_p.h>
+#include <private/qqmlpropertyvalueinterceptor_p.h>
+
+class MyTypeObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QPoint point READ point WRITE setPoint NOTIFY changed)
+ Q_PROPERTY(QPointF pointf READ pointf WRITE setPointf NOTIFY changed)
+ Q_PROPERTY(QPointF pointfpoint READ pointfpoint WRITE setPointfpoint NOTIFY changed)
+ Q_PROPERTY(QSize size READ size WRITE setSize NOTIFY changed)
+ Q_PROPERTY(QSizeF sizef READ sizef WRITE setSizef NOTIFY changed)
+ Q_PROPERTY(QSizeF sizefsize READ sizefsize WRITE setSizefsize NOTIFY changed)
+ Q_PROPERTY(QSize sizereadonly READ size NOTIFY changed)
+ Q_PROPERTY(QRect rect READ rect WRITE setRect NOTIFY changed)
+ Q_PROPERTY(QRectF rectf READ rectf WRITE setRectf NOTIFY changed)
+ Q_PROPERTY(QRectF rectfrect READ rectfrect WRITE setRectfrect NOTIFY changed)
+ Q_PROPERTY(QVector2D vector2 READ vector2 WRITE setVector2 NOTIFY changed)
+ Q_PROPERTY(QVector3D vector READ vector WRITE setVector NOTIFY changed)
+ Q_PROPERTY(QVector4D vector4 READ vector4 WRITE setVector4 NOTIFY changed)
+ Q_PROPERTY(QQuaternion quaternion READ quaternion WRITE setQuaternion NOTIFY changed)
+ Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY changed)
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed)
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY changed)
+ Q_PROPERTY(QVariant variant READ variant NOTIFY changed)
+
+public:
+ MyTypeObject() :
+ m_point(10, 4),
+ m_pointf(11.3, -10.9),
+ m_pointfpoint(10.0, 4.0),
+ m_size(1912, 1913),
+ m_sizef(0.1, 100923.2),
+ m_sizefsize(1912.0, 1913.0),
+ m_rect(2, 3, 109, 102),
+ m_rectf(103.8, 99.2, 88.1, 77.6),
+ m_rectfrect(2.0, 3.0, 109.0, 102.0),
+ m_vector2(32.88, 1.3),
+ m_vector(23.88, 3.1, 4.3),
+ m_vector4(54.2, 23.88, 3.1, 4.3),
+ m_quaternion(4.3, 54.2, 23.88, 3.1),
+ m_matrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
+ {
+ m_font.setFamily("Arial");
+ m_font.setBold(true);
+ m_font.setWeight(QFont::DemiBold);
+ m_font.setItalic(true);
+ m_font.setUnderline(true);
+ m_font.setOverline(true);
+ m_font.setStrikeOut(true);
+ m_font.setPointSize(29);
+ m_font.setCapitalization(QFont::AllLowercase);
+ m_font.setLetterSpacing(QFont::AbsoluteSpacing, 10.2);
+ m_font.setWordSpacing(19.7);
+ m_color.setRedF(0.2);
+ m_color.setGreenF(0.88);
+ m_color.setBlueF(0.6);
+ m_color.setAlphaF(0.34);
+ }
+
+ QPoint m_point;
+ QPoint point() const { return m_point; }
+ void setPoint(const QPoint &v) { m_point = v; emit changed(); }
+
+ QPointF m_pointf;
+ QPointF pointf() const { return m_pointf; }
+ void setPointf(const QPointF &v) { m_pointf = v; emit changed(); }
+
+ QPointF m_pointfpoint;
+ QPointF pointfpoint() const { return m_pointfpoint; }
+ void setPointfpoint(const QPointF &v) { m_pointfpoint = v; emit changed(); }
+
+ QSize m_size;
+ QSize size() const { return m_size; }
+ void setSize(const QSize &v) { m_size = v; emit changed(); }
+
+ QSizeF m_sizef;
+ QSizeF sizef() const { return m_sizef; }
+ void setSizef(const QSizeF &v) { m_sizef = v; emit changed(); }
+
+ QSizeF m_sizefsize;
+ QSizeF sizefsize() const { return m_sizefsize; }
+ void setSizefsize(const QSizeF &v) { m_sizefsize = v; emit changed(); }
+
+ QRect m_rect;
+ QRect rect() const { return m_rect; }
+ void setRect(const QRect &v) { m_rect = v; emit changed(); }
+
+ QRectF m_rectf;
+ QRectF rectf() const { return m_rectf; }
+ void setRectf(const QRectF &v) { m_rectf = v; emit changed(); }
+
+ QRectF m_rectfrect;
+ QRectF rectfrect() const { return m_rectfrect; }
+ void setRectfrect(const QRectF &v) { m_rectfrect = v; emit changed(); }
+
+ QVector2D m_vector2;
+ QVector2D vector2() const { return m_vector2; }
+ void setVector2(const QVector2D &v) { m_vector2 = v; emit changed(); }
+
+ QVector3D m_vector;
+ QVector3D vector() const { return m_vector; }
+ void setVector(const QVector3D &v) { m_vector = v; emit changed(); }
+
+ QVector4D m_vector4;
+ QVector4D vector4() const { return m_vector4; }
+ void setVector4(const QVector4D &v) { m_vector4 = v; emit changed(); }
+
+ QQuaternion m_quaternion;
+ QQuaternion quaternion() const { return m_quaternion; }
+ void setQuaternion(const QQuaternion &v) { m_quaternion = v; emit changed(); }
+
+ QMatrix4x4 m_matrix;
+ QMatrix4x4 matrix() const { return m_matrix; }
+ void setMatrix(const QMatrix4x4 &v) { m_matrix = v; emit changed(); }
+
+ QFont m_font;
+ QFont font() const { return m_font; }
+ void setFont(const QFont &v) { m_font = v; emit changed(); }
+
+ QColor m_color;
+ QColor color() const { return m_color; }
+ void setColor(const QColor &v) { m_color = v; emit changed(); }
+
+ QVariant variant() const { return sizef(); }
+
+ void emitRunScript() { emit runScript(); }
+
+signals:
+ void changed();
+ void runScript();
+
+public slots:
+ QSize method() { return QSize(13, 14); }
+};
+
+class MyConstantValueSource : public QObject, public QQmlPropertyValueSource
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlPropertyValueSource)
+public:
+ virtual void setTarget(const QQmlProperty &p) { p.write(3345); }
+};
+
+class MyOffsetValueInterceptor : public QObject, public QQmlPropertyValueInterceptor
+{
+ Q_OBJECT
+ Q_INTERFACES(QQmlPropertyValueInterceptor)
+public:
+ virtual void setTarget(const QQmlProperty &p) { prop = p; }
+ virtual void write(const QVariant &value) { QQmlPropertyPrivate::write(prop, value.toInt() + 13, QQmlPropertyPrivate::BypassInterceptor); }
+
+private:
+ QQmlProperty prop;
+};
+
+void registerTypes();
+
+#endif // TESTTYPES_H
diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
new file mode 100644
index 0000000000..695dbe4147
--- /dev/null
+++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp
@@ -0,0 +1,1306 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QDebug>
+#include <private/qqmlvaluetype_p.h>
+#include "../../shared/util.h"
+#include "testtypes.h"
+
+QT_BEGIN_NAMESPACE
+extern int qt_defaultDpi();
+QT_END_NAMESPACE
+
+class tst_qqmlvaluetypes : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlvaluetypes() {}
+
+private slots:
+ void initTestCase();
+
+ void point();
+ void pointf();
+ void size();
+ void sizef();
+ void sizereadonly();
+ void rect();
+ void rectf();
+ void vector2d();
+ void vector3d();
+ void vector4d();
+ void quaternion();
+ void matrix4x4();
+ void font();
+ void color();
+ void variant();
+
+ void bindingAssignment();
+ void bindingRead();
+ void staticAssignment();
+ void scriptAccess();
+ void autoBindingRemoval();
+ void valueSources();
+ void valueInterceptors();
+ void bindingConflict();
+ void deletedObject();
+ void bindingVariantCopy();
+ void scriptVariantCopy();
+ void cppClasses();
+ void enums();
+ void conflictingBindings();
+ void returnValues();
+ void varAssignment();
+ void bindingsSpliceCorrectly();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_qqmlvaluetypes::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ registerTypes();
+}
+
+void tst_qqmlvaluetypes::point()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("point_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("p_x").toInt(), 10);
+ QCOMPARE(object->property("p_y").toInt(), 4);
+ QCOMPARE(object->property("copy"), QVariant(QPoint(10, 4)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("point_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->point(), QPoint(11, 12));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("point_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QPoint(10, 4)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), true);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("pointEqualsPointf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::pointf()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("pointf_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(float(object->property("p_x").toDouble()), float(11.3));
+ QCOMPARE(float(object->property("p_y").toDouble()), float(-10.9));
+ QCOMPARE(object->property("copy"), QVariant(QPointF(11.3, -10.9)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("pointf_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->pointf(), QPointF(6.8, 9.3));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("pointf_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QPointF(11.3, -10.9)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), true);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("pointfEqualsPoint").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::size()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("size_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("s_width").toInt(), 1912);
+ QCOMPARE(object->property("s_height").toInt(), 1913);
+ QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("size_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->size(), QSize(13, 88));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("size_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QSize(1912, 1913)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), true);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("sizeEqualsSizef").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::sizef()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("sizef_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(float(object->property("s_width").toDouble()), float(0.1));
+ QCOMPARE(float(object->property("s_height").toDouble()), float(100923.2));
+ QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizef_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->sizef(), QSizeF(44.3, 92.8));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizef_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QSizeF(0.1, 100923)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), true);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("sizefEqualsSize").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::variant()
+{
+ QQmlComponent component(&engine, testFileUrl("variant_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(float(object->property("s_width").toDouble()), float(0.1));
+ QCOMPARE(float(object->property("s_height").toDouble()), float(100923.2));
+ QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2)));
+
+ delete object;
+}
+
+void tst_qqmlvaluetypes::sizereadonly()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("sizereadonly_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("s_width").toInt(), 1912);
+ QCOMPARE(object->property("s_height").toInt(), 1913);
+ QCOMPARE(object->property("copy"), QVariant(QSize(1912, 1913)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizereadonly_writeerror.qml"));
+ QVERIFY(component.isError());
+ QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizereadonly_writeerror2.qml"));
+ QVERIFY(component.isError());
+ QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizereadonly_writeerror3.qml"));
+ QVERIFY(component.isError());
+ QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("sizereadonly_writeerror4.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object);
+
+ QCOMPARE(object->property("sizereadonly").toSize(), QSize(1912, 1913));
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::rect()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("rect_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("r_x").toInt(), 2);
+ QCOMPARE(object->property("r_y").toInt(), 3);
+ QCOMPARE(object->property("r_width").toInt(), 109);
+ QCOMPARE(object->property("r_height").toInt(), 102);
+ QCOMPARE(object->property("copy"), QVariant(QRect(2, 3, 109, 102)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("rect_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect(), QRect(1234, 7, 56, 63));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("rect_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QRect(2, 3, 109, 102)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), true);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("rectEqualsRectf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::rectf()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("rectf_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(float(object->property("r_x").toDouble()), float(103.8));
+ QCOMPARE(float(object->property("r_y").toDouble()), float(99.2));
+ QCOMPARE(float(object->property("r_width").toDouble()), float(88.1));
+ QCOMPARE(float(object->property("r_height").toDouble()), float(77.6));
+ QCOMPARE(object->property("copy"), QVariant(QRectF(103.8, 99.2, 88.1, 77.6)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("rectf_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rectf(), QRectF(70.1, -113.2, 80924.8, 99.2));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("rectf_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QRectF(103.8, 99.2, 88.1, 77.6)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), true);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+ QCOMPARE(object->property("rectfEqualsRect").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::vector2d()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("vector2d_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)32.88);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)1.3);
+ QCOMPARE(object->property("copy"), QVariant(QVector2D(32.88, 1.3)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector2d_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->vector2(), QVector2D(-0.3, -12.9));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector2d_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QVector2D(32.88, 1.3)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::vector3d()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("vector3d_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)23.88);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)3.1);
+ QCOMPARE((float)object->property("v_z").toDouble(), (float)4.3);
+ QCOMPARE(object->property("copy"), QVariant(QVector3D(23.88, 3.1, 4.3)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector3d_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->vector(), QVector3D(-0.3, -12.9, 907.4));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector3d_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QVector3D(23.88, 3.1, 4.3)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), true);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+ QCOMPARE(object->property("equalsOther").toBool(), false);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::vector4d()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("vector4d_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)54.2);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)23.88);
+ QCOMPARE((float)object->property("v_z").toDouble(), (float)3.1);
+ QCOMPARE((float)object->property("v_w").toDouble(), (float)4.3);
+ QCOMPARE(object->property("copy"), QVariant(QVector4D(54.2, 23.88, 3.1, 4.3)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector4d_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->vector4(), QVector4D(-0.3, -12.9, 907.4, 88.5));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("vector4d_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QVector4D(54.2, 23.88, 3.1, 4.3)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::quaternion()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("quaternion_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_scalar").toDouble(), (float)4.3);
+ QCOMPARE((float)object->property("v_x").toDouble(), (float)54.2);
+ QCOMPARE((float)object->property("v_y").toDouble(), (float)23.88);
+ QCOMPARE((float)object->property("v_z").toDouble(), (float)3.1);
+ QCOMPARE(object->property("copy"), QVariant(QQuaternion(4.3, 54.2, 23.88, 3.1)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("quaternion_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->quaternion(), QQuaternion(88.5, -0.3, -12.9, 907.4));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("quaternion_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QQuaternion(4.3, 54.2, 23.88, 3.1)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::matrix4x4()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("matrix4x4_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_m11").toDouble(), (float)1);
+ QCOMPARE((float)object->property("v_m12").toDouble(), (float)2);
+ QCOMPARE((float)object->property("v_m13").toDouble(), (float)3);
+ QCOMPARE((float)object->property("v_m14").toDouble(), (float)4);
+ QCOMPARE((float)object->property("v_m21").toDouble(), (float)5);
+ QCOMPARE((float)object->property("v_m22").toDouble(), (float)6);
+ QCOMPARE((float)object->property("v_m23").toDouble(), (float)7);
+ QCOMPARE((float)object->property("v_m24").toDouble(), (float)8);
+ QCOMPARE((float)object->property("v_m31").toDouble(), (float)9);
+ QCOMPARE((float)object->property("v_m32").toDouble(), (float)10);
+ QCOMPARE((float)object->property("v_m33").toDouble(), (float)11);
+ QCOMPARE((float)object->property("v_m34").toDouble(), (float)12);
+ QCOMPARE((float)object->property("v_m41").toDouble(), (float)13);
+ QCOMPARE((float)object->property("v_m42").toDouble(), (float)14);
+ QCOMPARE((float)object->property("v_m43").toDouble(), (float)15);
+ QCOMPARE((float)object->property("v_m44").toDouble(), (float)16);
+ QCOMPARE(object->property("copy"),
+ QVariant(QMatrix4x4(1, 2, 3, 4,
+ 5, 6, 7, 8,
+ 9, 10, 11, 12,
+ 13, 14, 15, 16)));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("matrix4x4_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->matrix(), QMatrix4x4(11, 12, 13, 14,
+ 21, 22, 23, 24,
+ 31, 32, 33, 34,
+ 41, 42, 43, 44));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("matrix4x4_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QMatrix4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)");
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::font()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("font_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("f_family").toString(), object->font().family());
+ QCOMPARE(object->property("f_bold").toBool(), object->font().bold());
+ QCOMPARE(object->property("f_weight").toInt(), object->font().weight());
+ QCOMPARE(object->property("f_italic").toBool(), object->font().italic());
+ QCOMPARE(object->property("f_underline").toBool(), object->font().underline());
+ QCOMPARE(object->property("f_overline").toBool(), object->font().overline());
+ QCOMPARE(object->property("f_strikeout").toBool(), object->font().strikeOut());
+ QCOMPARE(object->property("f_pointSize").toDouble(), object->font().pointSizeF());
+ QCOMPARE(object->property("f_pixelSize").toInt(), int((object->font().pointSizeF() * qt_defaultDpi()) / qreal(72.)));
+ QCOMPARE(object->property("f_capitalization").toInt(), (int)object->font().capitalization());
+ QCOMPARE(object->property("f_letterSpacing").toDouble(), object->font().letterSpacing());
+ QCOMPARE(object->property("f_wordSpacing").toDouble(), object->font().wordSpacing());
+
+ QCOMPARE(object->property("copy"), QVariant(object->font()));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("font_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QFont font;
+ font.setFamily("Helvetica");
+ font.setBold(false);
+ font.setWeight(QFont::Normal);
+ font.setItalic(false);
+ font.setUnderline(false);
+ font.setStrikeOut(false);
+ font.setPointSize(15);
+ font.setCapitalization(QFont::AllLowercase);
+ font.setLetterSpacing(QFont::AbsoluteSpacing, 9.7);
+ font.setWordSpacing(11.2);
+
+ QFont f = object->font();
+ QCOMPARE(f.family(), font.family());
+ QCOMPARE(f.bold(), font.bold());
+ QCOMPARE(f.weight(), font.weight());
+ QCOMPARE(f.italic(), font.italic());
+ QCOMPARE(f.underline(), font.underline());
+ QCOMPARE(f.strikeOut(), font.strikeOut());
+ QCOMPARE(f.pointSize(), font.pointSize());
+ QCOMPARE(f.capitalization(), font.capitalization());
+ QCOMPARE(f.letterSpacing(), font.letterSpacing());
+ QCOMPARE(f.wordSpacing(), font.wordSpacing());
+
+ delete object;
+ }
+
+ // Test pixelSize
+ {
+ QQmlComponent component(&engine, testFileUrl("font_write.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->font().pixelSize(), 10);
+
+ delete object;
+ }
+
+ // Test pixelSize and pointSize
+ {
+ QQmlComponent component(&engine, testFileUrl("font_write.3.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. ");
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->font().pixelSize(), 10);
+
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("font_write.4.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. ");
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->font().pixelSize(), 10);
+
+ delete object;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("font_write.5.qml"));
+ QObject *object = qobject_cast<QObject *>(component.create());
+ QVERIFY(object != 0);
+ MyTypeObject *object1 = object->findChild<MyTypeObject *>("object1");
+ QVERIFY(object1 != 0);
+ MyTypeObject *object2 = object->findChild<MyTypeObject *>("object2");
+ QVERIFY(object2 != 0);
+
+ QCOMPARE(object1->font().pixelSize(), 19);
+ QCOMPARE(object2->font().pointSize(), 14);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("font_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QString tostring = QLatin1String("QFont(") + object->font().toString() + QLatin1Char(')');
+ QCOMPARE(object->property("tostring").toString(), tostring);
+ QCOMPARE(object->property("equalsString").toBool(), true);
+ QCOMPARE(object->property("equalsColor").toBool(), false);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+ QCOMPARE(object->property("equalsSelf").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::color()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("color_read.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE((float)object->property("v_r").toDouble(), (float)0.2);
+ QCOMPARE((float)object->property("v_g").toDouble(), (float)0.88);
+ QCOMPARE((float)object->property("v_b").toDouble(), (float)0.6);
+ QCOMPARE((float)object->property("v_a").toDouble(), (float)0.34);
+ QColor comparison;
+ comparison.setRedF(0.2);
+ comparison.setGreenF(0.88);
+ comparison.setBlueF(0.6);
+ comparison.setAlphaF(0.34);
+ QCOMPARE(object->property("copy"), QVariant(comparison));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("color_write.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QColor newColor;
+ newColor.setRedF(0.5);
+ newColor.setGreenF(0.38);
+ newColor.setBlueF(0.3);
+ newColor.setAlphaF(0.7);
+ QCOMPARE(object->color(), newColor);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("color_compare.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QString colorString("#33e199");
+ QCOMPARE(object->property("colorToString").toString(), colorString);
+ QCOMPARE(object->property("colorEqualsIdenticalRgba").toBool(), true);
+ QCOMPARE(object->property("colorEqualsDifferentAlpha").toBool(), false);
+ QCOMPARE(object->property("colorEqualsDifferentRgba").toBool(), false);
+ QCOMPARE(object->property("colorToStringEqualsColorString").toBool(), true);
+ QCOMPARE(object->property("colorToStringEqualsDifferentAlphaString").toBool(), true);
+ QCOMPARE(object->property("colorToStringEqualsDifferentRgbaString").toBool(), false);
+ QCOMPARE(object->property("colorEqualsColorString").toBool(), true); // maintaining behaviour with QtQuick 1.0
+ QCOMPARE(object->property("colorEqualsDifferentAlphaString").toBool(), true); // maintaining behaviour with QtQuick 1.0
+ QCOMPARE(object->property("colorEqualsDifferentRgbaString").toBool(), false);
+
+ QCOMPARE(object->property("equalsColor").toBool(), true);
+ QCOMPARE(object->property("equalsVector3d").toBool(), false);
+ QCOMPARE(object->property("equalsSize").toBool(), false);
+ QCOMPARE(object->property("equalsPoint").toBool(), false);
+ QCOMPARE(object->property("equalsRect").toBool(), false);
+
+ // Color == Property and Property == Color should return the same result.
+ QCOMPARE(object->property("equalsColorRHS").toBool(), object->property("equalsColor").toBool());
+ QCOMPARE(object->property("colorEqualsCopy").toBool(), true);
+ QCOMPARE(object->property("copyEqualsColor").toBool(), object->property("colorEqualsCopy").toBool());
+
+ delete object;
+ }
+}
+
+// Test bindings can write to value types
+void tst_qqmlvaluetypes::bindingAssignment()
+{
+ QQmlComponent component(&engine, testFileUrl("bindingAssignment.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 10);
+
+ object->setProperty("value", QVariant(92));
+
+ QCOMPARE(object->rect().x(), 92);
+
+ delete object;
+}
+
+// Test bindings can read from value types
+void tst_qqmlvaluetypes::bindingRead()
+{
+ QQmlComponent component(&engine, testFileUrl("bindingRead.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("value").toInt(), 2);
+
+ object->setRect(QRect(19, 3, 88, 2));
+
+ QCOMPARE(object->property("value").toInt(), 19);
+
+ delete object;
+}
+
+// Test static values can assign to value types
+void tst_qqmlvaluetypes::staticAssignment()
+{
+ QQmlComponent component(&engine, testFileUrl("staticAssignment.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 9);
+
+ delete object;
+}
+
+// Test scripts can read/write value types
+void tst_qqmlvaluetypes::scriptAccess()
+{
+ QQmlComponent component(&engine, testFileUrl("scriptAccess.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("valuePre").toInt(), 2);
+ QCOMPARE(object->rect().x(), 19);
+ QCOMPARE(object->property("valuePost").toInt(), 19);
+
+ delete object;
+}
+
+// Test that assigning a constant from script removes any binding
+void tst_qqmlvaluetypes::autoBindingRemoval()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 10);
+
+ object->setProperty("value", QVariant(13));
+
+ QCOMPARE(object->rect().x(), 13);
+
+ object->emitRunScript();
+
+ QCOMPARE(object->rect().x(), 42);
+
+ object->setProperty("value", QVariant(92));
+
+ QCOMPARE(object->rect().x(), 42);
+
+ delete object;
+ }
+
+ /*
+ {
+ QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 10);
+
+ object->setProperty("value", QVariant(13));
+
+ QCOMPARE(object->rect().x(), 13);
+
+ object->emitRunScript();
+
+ QCOMPARE(object->rect(), QRect(10, 10, 10, 10));
+
+ object->setProperty("value", QVariant(92));
+
+ QCOMPARE(object->rect(), QRect(10, 10, 10, 10));
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("autoBindingRemoval.3.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ object->setProperty("value", QVariant(QRect(9, 22, 33, 44)));
+
+ QCOMPARE(object->rect(), QRect(9, 22, 33, 44));
+
+ object->emitRunScript();
+
+ QCOMPARE(object->rect(), QRect(44, 22, 33, 44));
+
+ object->setProperty("value", QVariant(QRect(19, 3, 4, 8)));
+
+ QCOMPARE(object->rect(), QRect(44, 22, 33, 44));
+
+ delete object;
+ }
+*/
+}
+
+// Test that property value sources assign to value types
+void tst_qqmlvaluetypes::valueSources()
+{
+ QQmlComponent component(&engine, testFileUrl("valueSources.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 3345);
+
+ delete object;
+}
+
+static void checkNoErrors(QQmlComponent& component)
+{
+ QList<QQmlError> errors = component.errors();
+ if (errors.isEmpty())
+ return;
+ for (int ii = 0; ii < errors.count(); ++ii) {
+ const QQmlError &error = errors.at(ii);
+ qWarning("%d:%d:%s",error.line(),error.column(),error.description().toUtf8().constData());
+ }
+}
+
+// Test that property value interceptors can be applied to value types
+void tst_qqmlvaluetypes::valueInterceptors()
+{
+ QQmlComponent component(&engine, testFileUrl("valueInterceptors.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ checkNoErrors(component);
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect().x(), 13);
+
+ object->setProperty("value", 99);
+
+ QCOMPARE(object->rect().x(), 112);
+
+ delete object;
+}
+
+// Test that you can't assign a binding to the "root" value type, and a sub-property
+void tst_qqmlvaluetypes::bindingConflict()
+{
+ QQmlComponent component(&engine, testFileUrl("bindingConflict.qml"));
+ QCOMPARE(component.isError(), true);
+}
+
+#define CPP_TEST(type, v) \
+{ \
+ type *t = new type; \
+ QVariant value(v); \
+ t->setValue(value); \
+ QCOMPARE(t->value(), value); \
+ delete t; \
+}
+
+// Test that accessing a reference to a valuetype after the owning object is deleted
+// doesn't crash
+void tst_qqmlvaluetypes::deletedObject()
+{
+ QQmlComponent component(&engine, testFileUrl("deletedObject.qml"));
+ QTest::ignoreMessage(QtDebugMsg, "Test: 2");
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QObject *dObject = qvariant_cast<QObject *>(object->property("object"));
+ QVERIFY(dObject != 0);
+ delete dObject;
+
+ QTest::ignoreMessage(QtDebugMsg, "Test: undefined");
+ object->emitRunScript();
+
+ delete object;
+}
+
+// Test that value types can be assigned to another value type property in a binding
+void tst_qqmlvaluetypes::bindingVariantCopy()
+{
+ QQmlComponent component(&engine, testFileUrl("bindingVariantCopy.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect(), QRect(19, 33, 5, 99));
+
+ delete object;
+}
+
+// Test that value types can be assigned to another value type property in script
+void tst_qqmlvaluetypes::scriptVariantCopy()
+{
+ QQmlComponent component(&engine, testFileUrl("scriptVariantCopy.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->rect(), QRect(2, 3, 109, 102));
+
+ object->emitRunScript();
+
+ QCOMPARE(object->rect(), QRect(19, 33, 5, 99));
+
+ delete object;
+}
+
+
+// Test that the value type classes can be used manually
+void tst_qqmlvaluetypes::cppClasses()
+{
+ CPP_TEST(QQmlPointValueType, QPoint(19, 33));
+ CPP_TEST(QQmlPointFValueType, QPointF(33.6, -23));
+ CPP_TEST(QQmlSizeValueType, QSize(-100, 18));
+ CPP_TEST(QQmlSizeFValueType, QSizeF(-100.7, 18.2));
+ CPP_TEST(QQmlRectValueType, QRect(13, 39, 10928, 88));
+ CPP_TEST(QQmlRectFValueType, QRectF(88.2, -90.1, 103.2, 118));
+ CPP_TEST(QQmlVector2DValueType, QVector2D(19.7, 1002));
+ CPP_TEST(QQmlVector3DValueType, QVector3D(18.2, 19.7, 1002));
+ CPP_TEST(QQmlVector4DValueType, QVector4D(18.2, 19.7, 1002, 54));
+ CPP_TEST(QQmlQuaternionValueType, QQuaternion(18.2, 19.7, 1002, 54));
+ CPP_TEST(QQmlMatrix4x4ValueType,
+ QMatrix4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16));
+ CPP_TEST(QQmlFontValueType, QFont("Helvetica"));
+
+}
+
+void tst_qqmlvaluetypes::enums()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.1.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.2.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.3.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.4.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("enums.5.qml"));
+ MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
+ QVERIFY(object != 0);
+ QVERIFY(object->font().capitalization() == QFont::AllUppercase);
+ delete object;
+ }
+}
+
+// Tests switching between "conflicting" bindings (eg. a binding on the core
+// property, to a binding on the value-type sub-property)
+void tst_qqmlvaluetypes::conflictingBindings()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("conflicting.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("conflicting.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 6);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("conflicting.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 24);
+
+ QMetaObject::invokeMethod(object, "toggle");
+
+ QCOMPARE(qvariant_cast<QFont>(object->property("font")).pixelSize(), 12);
+
+ delete object;
+ }
+}
+
+void tst_qqmlvaluetypes::returnValues()
+{
+ QQmlComponent component(&engine, testFileUrl("returnValues.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").toBool(), true);
+ QCOMPARE(object->property("test2").toBool(), true);
+ QCOMPARE(object->property("size").toSize(), QSize(13, 14));
+
+ delete object;
+}
+
+void tst_qqmlvaluetypes::varAssignment()
+{
+ QQmlComponent component(&engine, testFileUrl("varAssignment.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("x").toInt(), 1);
+ QCOMPARE(object->property("y").toInt(), 2);
+ QCOMPARE(object->property("z").toInt(), 3);
+
+ delete object;
+}
+
+// Test bindings splice together correctly
+void tst_qqmlvaluetypes::bindingsSpliceCorrectly()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.4.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.5.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+ }
+}
+
+QTEST_MAIN(tst_qqmlvaluetypes)
+
+#include "tst_qqmlvaluetypes.moc"
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect b/tests/auto/qml/qqmlxmlhttprequest/data/abort.expect
index d6951a8255..d6951a8255 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml b/tests/auto/qml/qqmlxmlhttprequest/data/abort.qml
index 9ba97fac4b..9ba97fac4b 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply b/tests/auto/qml/qqmlxmlhttprequest/data/abort.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml b/tests/auto/qml/qqmlxmlhttprequest/data/abort_opened.qml
index d5bb84ddc0..d5bb84ddc0 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_opened.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort_opened.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/abort_unsent.qml
index 4f58062a26..4f58062a26 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/abort_unsent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/abort_unsent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml b/tests/auto/qml/qqmlxmlhttprequest/data/attr.qml
index b1c081c5fd..b1c081c5fd 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/attr.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml b/tests/auto/qml/qqmlxmlhttprequest/data/attr.xml
index 2aa64a3d00..2aa64a3d00 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.xml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/attr.xml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml b/tests/auto/qml/qqmlxmlhttprequest/data/callbackException.qml
index ee1043f97f..ee1043f97f 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/callbackException.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/callbackException.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml b/tests/auto/qml/qqmlxmlhttprequest/data/cdata.qml
index f558fdadc6..f558fdadc6 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/cdata.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml b/tests/auto/qml/qqmlxmlhttprequest/data/cdata.xml
index 061d37c0b6..061d37c0b6 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/cdata.xml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/cdata.xml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml b/tests/auto/qml/qqmlxmlhttprequest/data/constructor.qml
index 458066736e..458066736e 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/constructor.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/constructor.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml b/tests/auto/qml/qqmlxmlhttprequest/data/defaultState.qml
index 913fe59f99..913fe59f99 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/defaultState.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/defaultState.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml b/tests/auto/qml/qqmlxmlhttprequest/data/document.qml
index 7695cd76a1..7695cd76a1 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/document.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml b/tests/auto/qml/qqmlxmlhttprequest/data/document.xml
index fb693ea193..fb693ea193 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/document.xml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/document.xml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml b/tests/auto/qml/qqmlxmlhttprequest/data/domExceptionCodes.qml
index 092db3443d..092db3443d 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/domExceptionCodes.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/domExceptionCodes.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml b/tests/auto/qml/qqmlxmlhttprequest/data/element.qml
index 9b190f3a43..9b190f3a43 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/element.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml b/tests/auto/qml/qqmlxmlhttprequest/data/element.xml
index 071ffae057..071ffae057 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/element.xml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/element.xml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders.qml
index 580688b835..580688b835 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_args.qml
index 84a0bf3015..84a0bf3015 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_args.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_args.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_sent.qml
index 27edb4c4b7..27edb4c4b7 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_sent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_sent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml
index 3d57348cc5..3d57348cc5 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getAllResponseHeaders_unsent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getAllResponseHeaders_unsent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.expect
index cf5830ed0c..cf5830ed0c 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.qml
index 203967e539..203967e539 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.reply
index c4b4bb2763..c4b4bb2763 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_args.qml
index dccc71dfc3..dccc71dfc3 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_args.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_args.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_sent.qml
index cff7af79e2..cff7af79e2 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_sent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_sent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_unsent.qml
index ad2ea0bd33..ad2ea0bd33 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/getResponseHeader_unsent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/getResponseHeader_unsent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml b/tests/auto/qml/qqmlxmlhttprequest/data/instanceStateValues.qml
index b3a54e9b53..b3a54e9b53 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/instanceStateValues.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/instanceStateValues.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml b/tests/auto/qml/qqmlxmlhttprequest/data/invalidMethodUsage.qml
index 5a4093b9f1..5a4093b9f1 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/invalidMethodUsage.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/invalidMethodUsage.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open.qml
index 6e7681dfb4..6e7681dfb4 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.1.qml
index 61ef76d488..61ef76d488 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.1.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.1.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.2.qml
index 677759ccf3..677759ccf3 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_arg_count.2.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_arg_count.2.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_invalid_method.qml
index 0f29031e42..0f29031e42 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_invalid_method.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_invalid_method.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.expect
index cf5830ed0c..cf5830ed0c 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.wait
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_network.wait
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_network.wait
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_sync.qml
index eafdda761f..eafdda761f 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_sync.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_sync.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_user.qml
index 4eaef536b3..4eaef536b3 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_user.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_user.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml b/tests/auto/qml/qqmlxmlhttprequest/data/open_username.qml
index b8ce5361f3..b8ce5361f3 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/open_username.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/open_username.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml b/tests/auto/qml/qqmlxmlhttprequest/data/redirectError.qml
index e5c7b74553..e5c7b74553 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectError.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/redirectError.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml b/tests/auto/qml/qqmlxmlhttprequest/data/redirectRecur.qml
index 0894573ecc..0894573ecc 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirectRecur.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/redirectRecur.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml b/tests/auto/qml/qqmlxmlhttprequest/data/redirects.qml
index 003d1954e9..003d1954e9 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirects.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/redirects.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html b/tests/auto/qml/qqmlxmlhttprequest/data/redirecttarget.html
index 95f35e01c7..95f35e01c7 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/redirecttarget.html
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/redirecttarget.html
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml b/tests/auto/qml/qqmlxmlhttprequest/data/responseText.qml
index 4b216d9c85..4b216d9c85 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseText.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/responseText.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml b/tests/auto/qml/qqmlxmlhttprequest/data/responseXML_invalid.qml
index e9265e09ef..e9265e09ef 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/responseXML_invalid.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/responseXML_invalid.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html b/tests/auto/qml/qqmlxmlhttprequest/data/seconddocument.html
index a33f44bcb5..a33f44bcb5 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/seconddocument.html
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/seconddocument.html
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_alreadySent.qml
index 4e0caa7171..4e0caa7171 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_alreadySent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_alreadySent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.expect
index 9c07d4b633..9c07d4b633 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.qml
index 6faac0242f..6faac0242f 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.1.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.1.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.2.qml
index 383a76e75e..383a76e75e 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.2.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.2.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.3.qml
index 5cb8c926c2..5cb8c926c2 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.3.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.3.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.expect
index c2aba77881..c2aba77881 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.qml
index 884661c8ce..884661c8ce 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.4.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.4.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.5.qml
index c031b84418..c031b84418 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.5.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.5.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.expect
index b09b1bcec5..b09b1bcec5 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.qml
index 42eb360d14..42eb360d14 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.6.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.6.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.7.qml
index 5dc252f970..5dc252f970 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.7.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.7.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_data.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_data.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.qml
index 336971c919..336971c919 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_DELETE.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_DELETE.expect
index dd86b837f4..dd86b837f4 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_DELETE.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_DELETE.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_GET.expect
index cf5830ed0c..cf5830ed0c 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_GET.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_GET.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_HEAD.expect b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_HEAD.expect
index 7b7b282660..7b7b282660 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_ignoreData_HEAD.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_ignoreData_HEAD.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_unsent.qml
index ef56517bf5..ef56517bf5 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/send_unsent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_unsent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.expect
index e7f8e10780..e7f8e10780 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.qml
index 4229584af2..4229584af2 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_args.qml
index 1cef3e43da..1cef3e43da 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_args.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_args.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_caseInsensitive.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_caseInsensitive.qml
index e03f73431a..e03f73431a 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_caseInsensitive.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_caseInsensitive.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_illegalName.qml
index cd047cf8dd..cd047cf8dd 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_illegalName.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_illegalName.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_sent.qml
index 49888fdac8..49888fdac8 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_sent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_sent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_unsent.qml
index f528aa912c..f528aa912c 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/setRequestHeader_unsent.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/setRequestHeader_unsent.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml b/tests/auto/qml/qqmlxmlhttprequest/data/staticStateValues.qml
index 1b701e90ff..1b701e90ff 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/staticStateValues.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/staticStateValues.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply b/tests/auto/qml/qqmlxmlhttprequest/data/status.200.reply
index 7ae6951f9b..7ae6951f9b 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.200.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.200.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.400.reply b/tests/auto/qml/qqmlxmlhttprequest/data/status.400.reply
index e3f6944173..e3f6944173 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.400.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.400.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply b/tests/auto/qml/qqmlxmlhttprequest/data/status.404.reply
index 2e29f56d41..2e29f56d41 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.404.reply
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.404.reply
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect b/tests/auto/qml/qqmlxmlhttprequest/data/status.expect
index cf5830ed0c..cf5830ed0c 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.expect
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.expect
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml b/tests/auto/qml/qqmlxmlhttprequest/data/status.qml
index f5e10d79ad..f5e10d79ad 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/status.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml b/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml
index e7f658fc29..e7f658fc29 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/statusText.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/statusText.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html b/tests/auto/qml/qqmlxmlhttprequest/data/testdocument.html
index 8fe0f4b0e2..8fe0f4b0e2 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/testdocument.html
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/testdocument.html
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml b/tests/auto/qml/qqmlxmlhttprequest/data/text.qml
index b79e0bc7b1..b79e0bc7b1 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/text.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml b/tests/auto/qml/qqmlxmlhttprequest/data/text.xml
index e7416888fd..e7416888fd 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/text.xml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/text.xml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.html b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.html
index b640733f1e..b640733f1e 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.html
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.html
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.qml
index 7c024bfda6..7c024bfda6 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.qml
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.xml b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.xml
index 0fbb126ed8..0fbb126ed8 100644
--- a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.xml
+++ b/tests/auto/qml/qqmlxmlhttprequest/data/utf16.xml
Binary files differ
diff --git a/tests/auto/qml/qqmlxmlhttprequest/qqmlxmlhttprequest.pro b/tests/auto/qml/qqmlxmlhttprequest/qqmlxmlhttprequest.pro
new file mode 100644
index 0000000000..ed016fd9b6
--- /dev/null
+++ b/tests/auto/qml/qqmlxmlhttprequest/qqmlxmlhttprequest.pro
@@ -0,0 +1,19 @@
+CONFIG += testcase
+TARGET = tst_qqmlxmlhttprequest
+macx:CONFIG -= app_bundle
+
+INCLUDEPATH += ../../shared/
+HEADERS += ../../shared/testhttpserver.h
+
+SOURCES += tst_qqmlxmlhttprequest.cpp \
+ ../../shared/testhttpserver.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private network testlib
diff --git a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp
new file mode 100644
index 0000000000..f8d74c3cde
--- /dev/null
+++ b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp
@@ -0,0 +1,1160 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QQmlEngine>
+#include <QQmlComponent>
+#include <QDebug>
+#include <QScopedPointer>
+#include <QNetworkCookieJar>
+#include "testhttpserver.h"
+#include "../../shared/util.h"
+
+#define SERVER_PORT 14445
+
+class tst_qqmlxmlhttprequest : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qqmlxmlhttprequest() {}
+
+private slots:
+ void domExceptionCodes();
+ void callbackException();
+ void callbackException_data();
+ void staticStateValues();
+ void instanceStateValues();
+ void constructor();
+ void defaultState();
+ void open();
+ void open_data();
+ void open_invalid_method();
+ void open_sync();
+ void open_arg_count();
+ void setRequestHeader();
+ void setRequestHeader_caseInsensitive();
+ void setRequestHeader_unsent();
+ void setRequestHeader_illegalName_data();
+ void setRequestHeader_illegalName();
+ void setRequestHeader_sent();
+ void setRequestHeader_args();
+ void send_unsent();
+ void send_alreadySent();
+ void send_ignoreData();
+ void send_withdata();
+ void send_withdata_data();
+ void abort();
+ void abort_unsent();
+ void abort_opened();
+ void getResponseHeader();
+ void getResponseHeader_unsent();
+ void getResponseHeader_sent();
+ void getResponseHeader_args();
+ void getAllResponseHeaders();
+ void getAllResponseHeaders_unsent();
+ void getAllResponseHeaders_sent();
+ void getAllResponseHeaders_args();
+ void status();
+ void status_data();
+ void statusText();
+ void statusText_data();
+ void responseText();
+ void responseText_data();
+ void responseXML_invalid();
+ void invalidMethodUsage();
+ void redirects();
+ void nonUtf8();
+ void nonUtf8_data();
+
+ // Attributes
+ void document();
+ void element();
+ void attr();
+ void text();
+ void cdata();
+
+ // Crashes
+ // void outstanding_request_at_shutdown();
+
+ // void network_errors()
+ // void readyState()
+
+private:
+ QQmlEngine engine;
+};
+
+// Test that the dom exception codes are correct
+void tst_qqmlxmlhttprequest::domExceptionCodes()
+{
+ QQmlComponent component(&engine, testFileUrl("domExceptionCodes.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("index_size_err").toInt(), 1);
+ QCOMPARE(object->property("domstring_size_err").toInt(), 2);
+ QCOMPARE(object->property("hierarchy_request_err").toInt(), 3);
+ QCOMPARE(object->property("wrong_document_err").toInt(), 4);
+ QCOMPARE(object->property("invalid_character_err").toInt(), 5);
+ QCOMPARE(object->property("no_data_allowed_err").toInt(), 6);
+ QCOMPARE(object->property("no_modification_allowed_err").toInt(), 7);
+ QCOMPARE(object->property("not_found_err").toInt(), 8);
+ QCOMPARE(object->property("not_supported_err").toInt(), 9);
+ QCOMPARE(object->property("inuse_attribute_err").toInt(), 10);
+ QCOMPARE(object->property("invalid_state_err").toInt(), 11);
+ QCOMPARE(object->property("syntax_err").toInt(), 12);
+ QCOMPARE(object->property("invalid_modification_err").toInt(), 13);
+ QCOMPARE(object->property("namespace_err").toInt(), 14);
+ QCOMPARE(object->property("invalid_access_err").toInt(), 15);
+ QCOMPARE(object->property("validation_err").toInt(), 16);
+ QCOMPARE(object->property("type_mismatch_err").toInt(), 17);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::callbackException_data()
+{
+ QTest::addColumn<QString>("which");
+ QTest::addColumn<int>("line");
+
+ QTest::newRow("on-opened") << "1" << 15;
+ QTest::newRow("on-loading") << "3" << 15;
+ QTest::newRow("on-done") << "4" << 15;
+}
+
+void tst_qqmlxmlhttprequest::callbackException()
+{
+ // Test exception reporting for exceptions thrown at various points.
+
+ QFETCH(QString, which);
+ QFETCH(int, line);
+
+ QString expect = testFileUrl("callbackException.qml").toString() + ":"+QString::number(line)+": Error: Exception from Callback";
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+
+ QQmlComponent component(&engine, testFileUrl("callbackException.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "testdocument.html");
+ object->setProperty("which", which);
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("threw").toBool() == true);
+
+ delete object;
+}
+
+// Test that the state value properties on the XMLHttpRequest constructor have the correct values.
+// ### WebKit does not do this, but it seems to fit the standard and QML better
+void tst_qqmlxmlhttprequest::staticStateValues()
+{
+ QQmlComponent component(&engine, testFileUrl("staticStateValues.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("unsent").toInt(), 0);
+ QCOMPARE(object->property("opened").toInt(), 1);
+ QCOMPARE(object->property("headers_received").toInt(), 2);
+ QCOMPARE(object->property("loading").toInt(), 3);
+ QCOMPARE(object->property("done").toInt(), 4);
+
+ delete object;
+}
+
+// Test that the state value properties on instances have the correct values.
+void tst_qqmlxmlhttprequest::instanceStateValues()
+{
+ QQmlComponent component(&engine, testFileUrl("instanceStateValues.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("unsent").toInt(), 0);
+ QCOMPARE(object->property("opened").toInt(), 1);
+ QCOMPARE(object->property("headers_received").toInt(), 2);
+ QCOMPARE(object->property("loading").toInt(), 3);
+ QCOMPARE(object->property("done").toInt(), 4);
+
+ delete object;
+}
+
+// Test calling constructor
+void tst_qqmlxmlhttprequest::constructor()
+{
+ QQmlComponent component(&engine, testFileUrl("constructor.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("calledAsConstructor").toBool(), true);
+ QCOMPARE(object->property("calledAsFunction").toBool(), true);
+
+ delete object;
+}
+
+// Test that all the properties are set correctly before any request is sent
+void tst_qqmlxmlhttprequest::defaultState()
+{
+ QQmlComponent component(&engine, testFileUrl("defaultState.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("readState").toInt(), 0);
+ QCOMPARE(object->property("statusIsException").toBool(), true);
+ QCOMPARE(object->property("statusTextIsException").toBool(), true);
+ QCOMPARE(object->property("responseText").toString(), QString());
+ QCOMPARE(object->property("responseXMLIsNull").toBool(), true);
+
+ delete object;
+}
+
+// Test valid XMLHttpRequest.open() calls
+void tst_qqmlxmlhttprequest::open()
+{
+ QFETCH(QUrl, qmlFile);
+ QFETCH(QString, url);
+ QFETCH(bool, remote);
+
+ QScopedPointer<TestHTTPServer> server; // ensure deletion in case test fails
+ if (remote) {
+ server.reset(new TestHTTPServer(SERVER_PORT));
+ QVERIFY(server->isValid());
+ QVERIFY(server->wait(testFileUrl("open_network.expect"),
+ testFileUrl("open_network.reply"),
+ testFileUrl("testdocument.html")));
+ }
+
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", url);
+ component.completeCreate();
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::open_data()
+{
+ QTest::addColumn<QUrl>("qmlFile");
+ QTest::addColumn<QString>("url");
+ QTest::addColumn<bool>("remote");
+
+ QTest::newRow("Relative url)") << testFileUrl("open.qml") << "testdocument.html" << false;
+ QTest::newRow("Absolute url)") << testFileUrl("open.qml") << testFileUrl("testdocument.html").toString() << false;
+ QTest::newRow("Absolute network url)") << testFileUrl("open.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
+
+ // ### Check that the username/password were sent to the server
+ QTest::newRow("User/pass") << testFileUrl("open_user.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
+}
+
+// Test that calling XMLHttpRequest.open() with an invalid method raises an exception
+void tst_qqmlxmlhttprequest::open_invalid_method()
+{
+ QQmlComponent component(&engine, testFileUrl("open_invalid_method.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("exceptionThrown").toBool(), true);
+
+ delete object;
+}
+
+// Test that calling XMLHttpRequest.open() with sync raises an exception
+void tst_qqmlxmlhttprequest::open_sync()
+{
+ QQmlComponent component(&engine, testFileUrl("open_sync.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("exceptionThrown").toBool(), true);
+
+ delete object;
+}
+
+// Calling with incorrect arg count raises an exception
+void tst_qqmlxmlhttprequest::open_arg_count()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("open_arg_count.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("exceptionThrown").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("open_arg_count.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("exceptionThrown").toBool(), true);
+
+ delete object;
+ }
+}
+
+// Test valid setRequestHeader() calls
+void tst_qqmlxmlhttprequest::setRequestHeader()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"),
+ testFileUrl("setRequestHeader.reply"),
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("setRequestHeader.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test valid setRequestHeader() calls with different header cases
+void tst_qqmlxmlhttprequest::setRequestHeader_caseInsensitive()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"),
+ testFileUrl("setRequestHeader.reply"),
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("setRequestHeader_caseInsensitive.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+// Test setting headers before open() throws exception
+void tst_qqmlxmlhttprequest::setRequestHeader_unsent()
+{
+ QQmlComponent component(&engine, testFileUrl("setRequestHeader_unsent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::setRequestHeader_illegalName_data()
+{
+ QTest::addColumn<QString>("name");
+
+ QTest::newRow("Accept-Charset") << "AccePT-CHArset";
+ QTest::newRow("Accept-Encoding") << "AccEpt-EnCOding";
+ QTest::newRow("Connection") << "ConnECtion";
+ QTest::newRow("Content-Length") << "ContEnt-LenGth";
+ QTest::newRow("Cookie") << "CookIe";
+ QTest::newRow("Cookie2") << "CoOkie2";
+ QTest::newRow("Content-Transfer-Encoding") << "ConteNT-tRANSFER-eNCOding";
+ QTest::newRow("Date") << "DaTE";
+ QTest::newRow("Expect") << "ExPect";
+ QTest::newRow("Host") << "HoST";
+ QTest::newRow("Keep-Alive") << "KEEP-aLive";
+ QTest::newRow("Referer") << "ReferEr";
+ QTest::newRow("TE") << "Te";
+ QTest::newRow("Trailer") << "TraILEr";
+ QTest::newRow("Transfer-Encoding") << "tRANsfer-Encoding";
+ QTest::newRow("Upgrade") << "UpgrADe";
+ QTest::newRow("User-Agent") << "uSEr-Agent";
+ QTest::newRow("Via") << "vIa";
+ QTest::newRow("Proxy-") << "ProXy-";
+ QTest::newRow("Sec-") << "SeC-";
+ QTest::newRow("Proxy-*") << "Proxy-BLAH";
+ QTest::newRow("Sec-*") << "Sec-F";
+}
+
+// Tests that using illegal header names has no effect
+void tst_qqmlxmlhttprequest::setRequestHeader_illegalName()
+{
+ QFETCH(QString, name);
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("open_network.expect"),
+ testFileUrl("open_network.reply"),
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("setRequestHeader_illegalName.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("header", name);
+ component.completeCreate();
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test that attempting to set a header after a request is sent throws an exception
+void tst_qqmlxmlhttprequest::setRequestHeader_sent()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("open_network.expect"),
+ testFileUrl("open_network.reply"),
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("setRequestHeader_sent.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Invalid arg count throws exception
+void tst_qqmlxmlhttprequest::setRequestHeader_args()
+{
+ QQmlComponent component(&engine, testFileUrl("setRequestHeader_args.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("exceptionThrown").toBool(), true);
+
+ delete object;
+}
+
+// Test that calling send() in UNSENT state throws an exception
+void tst_qqmlxmlhttprequest::send_unsent()
+{
+ QQmlComponent component(&engine, testFileUrl("send_unsent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Test attempting to resend a sent request throws an exception
+void tst_qqmlxmlhttprequest::send_alreadySent()
+{
+ QQmlComponent component(&engine, testFileUrl("send_alreadySent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test that sends for GET, HEAD and DELETE ignore data
+void tst_qqmlxmlhttprequest::send_ignoreData()
+{
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("send_ignoreData_GET.expect"),
+ testFileUrl("send_ignoreData.reply"),
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("send_ignoreData.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("reqType", "GET");
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("send_ignoreData_HEAD.expect"),
+ testFileUrl("send_ignoreData.reply"),
+ QUrl()));
+
+ QQmlComponent component(&engine, testFileUrl("send_ignoreData.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("reqType", "HEAD");
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("send_ignoreData_DELETE.expect"),
+ testFileUrl("send_ignoreData.reply"),
+ QUrl()));
+
+ QQmlComponent component(&engine, testFileUrl("send_ignoreData.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("reqType", "DELETE");
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+ }
+}
+
+// Test that send()'ing data works
+void tst_qqmlxmlhttprequest::send_withdata()
+{
+ QFETCH(QString, file_expected);
+ QFETCH(QString, file_qml);
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl(file_expected),
+ testFileUrl("send_data.reply"),
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl(file_qml));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::send_withdata_data()
+{
+ QTest::addColumn<QString>("file_expected");
+ QTest::addColumn<QString>("file_qml");
+
+ QTest::newRow("No content-type") << "send_data.1.expect" << "send_data.1.qml";
+ QTest::newRow("Correct content-type") << "send_data.1.expect" << "send_data.2.qml";
+ QTest::newRow("Incorrect content-type") << "send_data.1.expect" << "send_data.3.qml";
+ QTest::newRow("Correct content-type - out of order") << "send_data.4.expect" << "send_data.4.qml";
+ QTest::newRow("Incorrect content-type - out of order") << "send_data.4.expect" << "send_data.5.qml";
+ QTest::newRow("PUT") << "send_data.6.expect" << "send_data.6.qml";
+ QTest::newRow("Correct content-type - no charset") << "send_data.1.expect" << "send_data.7.qml";
+}
+
+// Test abort() has no effect in unsent state
+void tst_qqmlxmlhttprequest::abort_unsent()
+{
+ QQmlComponent component(&engine, testFileUrl("abort_unsent.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test abort() cancels an open (but unsent) request
+void tst_qqmlxmlhttprequest::abort_opened()
+{
+ QQmlComponent component(&engine, testFileUrl("abort_opened.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+// Test abort() aborts in progress send
+void tst_qqmlxmlhttprequest::abort()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("abort.expect"),
+ testFileUrl("abort.reply"),
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("abort.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("urlDummy", "http://127.0.0.1:14449/testdocument.html");
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("seenDone").toBool(), true);
+ QCOMPARE(object->property("didNotSeeUnsent").toBool(), true);
+ QCOMPARE(object->property("endStateUnsent").toBool(), true);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::getResponseHeader()
+{
+ QQmlEngine engine; // Avoid cookie contamination
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"),
+ testFileUrl("getResponseHeader.reply"),
+ testFileUrl("testdocument.html")));
+
+
+ QQmlComponent component(&engine, testFileUrl("getResponseHeader.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("unsentException").toBool(), true);
+ QCOMPARE(object->property("openedException").toBool(), true);
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("headersReceivedState").toBool(), true);
+ QCOMPARE(object->property("headersReceivedNullHeader").toBool(), true);
+ QCOMPARE(object->property("headersReceivedValidHeader").toBool(), true);
+ QCOMPARE(object->property("headersReceivedMultiValidHeader").toBool(), true);
+ QCOMPARE(object->property("headersReceivedCookieHeader").toBool(), true);
+
+ QCOMPARE(object->property("doneState").toBool(), true);
+ QCOMPARE(object->property("doneNullHeader").toBool(), true);
+ QCOMPARE(object->property("doneValidHeader").toBool(), true);
+ QCOMPARE(object->property("doneMultiValidHeader").toBool(), true);
+ QCOMPARE(object->property("doneCookieHeader").toBool(), true);
+
+ delete object;
+}
+
+// Test getResponseHeader throws an exception in an invalid state
+void tst_qqmlxmlhttprequest::getResponseHeader_unsent()
+{
+ QQmlComponent component(&engine, testFileUrl("getResponseHeader_unsent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Test getResponseHeader throws an exception in an invalid state
+void tst_qqmlxmlhttprequest::getResponseHeader_sent()
+{
+ QQmlComponent component(&engine, testFileUrl("getResponseHeader_sent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Invalid arg count throws exception
+void tst_qqmlxmlhttprequest::getResponseHeader_args()
+{
+ QQmlComponent component(&engine, testFileUrl("getResponseHeader_args.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QTRY_VERIFY(object->property("exceptionThrown").toBool() == true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::getAllResponseHeaders()
+{
+ QQmlEngine engine; // Avoid cookie contamination
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"),
+ testFileUrl("getResponseHeader.reply"),
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ component.completeCreate();
+
+ QCOMPARE(object->property("unsentException").toBool(), true);
+ QCOMPARE(object->property("openedException").toBool(), true);
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("openedState").toBool(), true);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("headersReceivedState").toBool(), true);
+ QCOMPARE(object->property("headersReceivedHeader").toBool(), true);
+
+ QCOMPARE(object->property("doneState").toBool(), true);
+ QCOMPARE(object->property("doneHeader").toBool(), true);
+
+ delete object;
+}
+
+// Test getAllResponseHeaders throws an exception in an invalid state
+void tst_qqmlxmlhttprequest::getAllResponseHeaders_unsent()
+{
+ QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders_unsent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Test getAllResponseHeaders throws an exception in an invalid state
+void tst_qqmlxmlhttprequest::getAllResponseHeaders_sent()
+{
+ QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders_sent.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test").toBool(), true);
+
+ delete object;
+}
+
+// Invalid arg count throws exception
+void tst_qqmlxmlhttprequest::getAllResponseHeaders_args()
+{
+ QQmlComponent component(&engine, testFileUrl("getAllResponseHeaders_args.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QTRY_VERIFY(object->property("exceptionThrown").toBool() == true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::status()
+{
+ QFETCH(QUrl, replyUrl);
+ QFETCH(int, status);
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("status.expect"),
+ replyUrl,
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("status.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("expectedStatus", status);
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("unsentException").toBool(), true);
+ QCOMPARE(object->property("openedException").toBool(), true);
+ QCOMPARE(object->property("sentException").toBool(), true);
+ QCOMPARE(object->property("headersReceived").toBool(), true);
+ QCOMPARE(object->property("loading").toBool(), true);
+ QCOMPARE(object->property("done").toBool(), true);
+ QCOMPARE(object->property("resetException").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::status_data()
+{
+ QTest::addColumn<QUrl>("replyUrl");
+ QTest::addColumn<int>("status");
+
+ QTest::newRow("OK") << testFileUrl("status.200.reply") << 200;
+ QTest::newRow("Not Found") << testFileUrl("status.404.reply") << 404;
+ QTest::newRow("Bad Request") << testFileUrl("status.400.reply") << 400;
+}
+
+void tst_qqmlxmlhttprequest::statusText()
+{
+ QFETCH(QUrl, replyUrl);
+ QFETCH(QString, statusText);
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("status.expect"),
+ replyUrl,
+ testFileUrl("testdocument.html")));
+
+ QQmlComponent component(&engine, testFileUrl("statusText.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("expectedStatus", statusText);
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("unsentException").toBool(), true);
+ QCOMPARE(object->property("openedException").toBool(), true);
+ QCOMPARE(object->property("sentException").toBool(), true);
+ QCOMPARE(object->property("headersReceived").toBool(), true);
+ QCOMPARE(object->property("loading").toBool(), true);
+ QCOMPARE(object->property("done").toBool(), true);
+ QCOMPARE(object->property("resetException").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::statusText_data()
+{
+ QTest::addColumn<QUrl>("replyUrl");
+ QTest::addColumn<QString>("statusText");
+
+ QTest::newRow("OK") << testFileUrl("status.200.reply") << "OK";
+ QTest::newRow("Not Found") << testFileUrl("status.404.reply") << "Document not found";
+ QTest::newRow("Bad Request") << testFileUrl("status.400.reply") << "Bad request";
+}
+
+void tst_qqmlxmlhttprequest::responseText()
+{
+ QFETCH(QUrl, replyUrl);
+ QFETCH(QUrl, bodyUrl);
+ QFETCH(QString, responseText);
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ QVERIFY(server.wait(testFileUrl("status.expect"),
+ replyUrl,
+ bodyUrl));
+
+ QQmlComponent component(&engine, testFileUrl("responseText.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
+ object->setProperty("expectedText", responseText);
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("unsent").toBool(), true);
+ QCOMPARE(object->property("opened").toBool(), true);
+ QCOMPARE(object->property("sent").toBool(), true);
+ QCOMPARE(object->property("headersReceived").toBool(), true);
+ QCOMPARE(object->property("loading").toBool(), true);
+ QCOMPARE(object->property("done").toBool(), true);
+ QCOMPARE(object->property("reset").toBool(), true);
+
+ delete object;
+}
+
+void tst_qqmlxmlhttprequest::responseText_data()
+{
+ QTest::addColumn<QUrl>("replyUrl");
+ QTest::addColumn<QUrl>("bodyUrl");
+ QTest::addColumn<QString>("responseText");
+
+ QTest::newRow("OK") << testFileUrl("status.200.reply") << testFileUrl("testdocument.html") << "QML Rocks!\n";
+ QTest::newRow("empty body") << testFileUrl("status.200.reply") << QUrl() << "";
+ QTest::newRow("Not Found") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << "";
+ QTest::newRow("Bad Request") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << "";
+}
+
+void tst_qqmlxmlhttprequest::nonUtf8()
+{
+ QFETCH(QString, fileName);
+ QFETCH(QString, responseText);
+ QFETCH(QString, xmlRootNodeValue);
+
+ QQmlComponent component(&engine, testFileUrl("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_qqmlxmlhttprequest::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);
+
+ 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
+// throws an exception
+void tst_qqmlxmlhttprequest::invalidMethodUsage()
+{
+ QQmlComponent component(&engine, testFileUrl("invalidMethodUsage.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("readyState").toBool(), true);
+ QCOMPARE(object->property("status").toBool(), true);
+ QCOMPARE(object->property("statusText").toBool(), true);
+ QCOMPARE(object->property("responseText").toBool(), true);
+ QCOMPARE(object->property("responseXML").toBool(), true);
+
+ QCOMPARE(object->property("open").toBool(), true);
+ QCOMPARE(object->property("setRequestHeader").toBool(), true);
+ QCOMPARE(object->property("send").toBool(), true);
+ QCOMPARE(object->property("abort").toBool(), true);
+ QCOMPARE(object->property("getResponseHeader").toBool(), true);
+ QCOMPARE(object->property("getAllResponseHeaders").toBool(), true);
+
+ delete object;
+}
+
+// Test that XMLHttpRequest transparently redirects
+void tst_qqmlxmlhttprequest::redirects()
+{
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirecttarget.html");
+ server.serveDirectory(dataDirectory());
+
+ QQmlComponent component(&engine, testFileUrl("redirects.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
+ object->setProperty("expectedText", "");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("done").toBool() == true);
+ QCOMPARE(object->property("dataOK").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirectmissing.html");
+ server.serveDirectory(dataDirectory());
+
+ QQmlComponent component(&engine, testFileUrl("redirectError.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
+ object->setProperty("expectedText", "");
+ component.completeCreate();
+
+ QTRY_VERIFY(object->property("done").toBool() == true);
+ QCOMPARE(object->property("dataOK").toBool(), true);
+
+ delete object;
+ }
+
+ {
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirect.html");
+ server.serveDirectory(dataDirectory());
+
+ QQmlComponent component(&engine, testFileUrl("redirectRecur.qml"));
+ QObject *object = component.beginCreate(engine.rootContext());
+ QVERIFY(object != 0);
+ object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
+ object->setProperty("expectedText", "");
+ component.completeCreate();
+
+ for (int ii = 0; ii < 60; ++ii) {
+ if (object->property("done").toBool()) break;
+ QTest::qWait(50);
+ }
+ QVERIFY(object->property("done").toBool() == true);
+
+ QCOMPARE(object->property("dataOK").toBool(), true);
+
+ delete object;
+ }
+}
+
+void tst_qqmlxmlhttprequest::responseXML_invalid()
+{
+ QQmlComponent component(&engine, testFileUrl("responseXML_invalid.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlNull").toBool(), true);
+
+ delete object;
+}
+
+// Test the Document DOM element
+void tst_qqmlxmlhttprequest::document()
+{
+ QQmlComponent component(&engine, testFileUrl("document.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlTest").toBool(), true);
+
+ delete object;
+}
+
+// Test the Element DOM element
+void tst_qqmlxmlhttprequest::element()
+{
+ QQmlComponent component(&engine, testFileUrl("element.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlTest").toBool(), true);
+
+ delete object;
+}
+
+// Test the Attr DOM element
+void tst_qqmlxmlhttprequest::attr()
+{
+ QQmlComponent component(&engine, testFileUrl("attr.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlTest").toBool(), true);
+
+ delete object;
+}
+
+// Test the Text DOM element
+void tst_qqmlxmlhttprequest::text()
+{
+ QQmlComponent component(&engine, testFileUrl("text.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlTest").toBool(), true);
+
+ delete object;
+}
+
+// Test the CDataSection DOM element
+void tst_qqmlxmlhttprequest::cdata()
+{
+ QQmlComponent component(&engine, testFileUrl("cdata.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QTRY_VERIFY(object->property("dataOK").toBool() == true);
+
+ QCOMPARE(object->property("xmlTest").toBool(), true);
+
+ delete object;
+}
+
+QTEST_MAIN(tst_qqmlxmlhttprequest)
+
+#include "tst_qqmlxmlhttprequest.moc"
diff --git a/tests/auto/declarative/qdeclarativebinding/data/deletedObject.qml b/tests/auto/qml/qquickbinding/data/deletedObject.qml
index f9cf869ba3..f9cf869ba3 100644
--- a/tests/auto/declarative/qdeclarativebinding/data/deletedObject.qml
+++ b/tests/auto/qml/qquickbinding/data/deletedObject.qml
diff --git a/tests/auto/declarative/qdeclarativebinding/data/restoreBinding.qml b/tests/auto/qml/qquickbinding/data/restoreBinding.qml
index 9491c0f1d3..9491c0f1d3 100644
--- a/tests/auto/declarative/qdeclarativebinding/data/restoreBinding.qml
+++ b/tests/auto/qml/qquickbinding/data/restoreBinding.qml
diff --git a/tests/auto/declarative/qdeclarativebinding/data/restoreBindingWithLoop.qml b/tests/auto/qml/qquickbinding/data/restoreBindingWithLoop.qml
index ee07104817..ee07104817 100644
--- a/tests/auto/declarative/qdeclarativebinding/data/restoreBindingWithLoop.qml
+++ b/tests/auto/qml/qquickbinding/data/restoreBindingWithLoop.qml
diff --git a/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml b/tests/auto/qml/qquickbinding/data/test-binding.qml
index 87aabe975a..87aabe975a 100644
--- a/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml
+++ b/tests/auto/qml/qquickbinding/data/test-binding.qml
diff --git a/tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml b/tests/auto/qml/qquickbinding/data/test-binding2.qml
index 4a08141d11..4a08141d11 100644
--- a/tests/auto/declarative/qdeclarativebinding/data/test-binding2.qml
+++ b/tests/auto/qml/qquickbinding/data/test-binding2.qml
diff --git a/tests/auto/qml/qquickbinding/qquickbinding.pro b/tests/auto/qml/qquickbinding/qquickbinding.pro
new file mode 100644
index 0000000000..b87e93495d
--- /dev/null
+++ b/tests/auto/qml/qquickbinding/qquickbinding.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickbinding
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickbinding.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/qml/qquickbinding/tst_qquickbinding.cpp b/tests/auto/qml/qquickbinding/tst_qquickbinding.cpp
new file mode 100644
index 0000000000..939c4a9e3d
--- /dev/null
+++ b/tests/auto/qml/qquickbinding/tst_qquickbinding.cpp
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <private/qquickbind_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include "../../shared/util.h"
+
+class tst_qquickbinding : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickbinding();
+
+private slots:
+ void binding();
+ void whenAfterValue();
+ void restoreBinding();
+ void restoreBindingWithLoop();
+ void deletedObject();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquickbinding::tst_qquickbinding()
+{
+}
+
+void tst_qquickbinding::binding()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-binding.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickBind *binding3 = qobject_cast<QQuickBind*>(rect->findChild<QQuickBind*>("binding3"));
+ QVERIFY(binding3 != 0);
+
+ QCOMPARE(rect->color(), QColor("yellow"));
+ QCOMPARE(rect->property("text").toString(), QString("Hello"));
+ QCOMPARE(binding3->when(), false);
+
+ rect->setProperty("changeColor", true);
+ QCOMPARE(rect->color(), QColor("red"));
+
+ QCOMPARE(binding3->when(), true);
+
+ QQuickBind *binding = qobject_cast<QQuickBind*>(rect->findChild<QQuickBind*>("binding1"));
+ QVERIFY(binding != 0);
+ QCOMPARE(binding->object(), qobject_cast<QObject*>(rect));
+ QCOMPARE(binding->property(), QLatin1String("text"));
+ QCOMPARE(binding->value().toString(), QLatin1String("Hello"));
+
+ delete rect;
+}
+
+void tst_qquickbinding::whenAfterValue()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-binding2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+
+ QVERIFY(rect != 0);
+ QCOMPARE(rect->color(), QColor("yellow"));
+ QCOMPARE(rect->property("text").toString(), QString("Hello"));
+
+ rect->setProperty("changeColor", true);
+ QCOMPARE(rect->color(), QColor("red"));
+
+ delete rect;
+}
+
+void tst_qquickbinding::restoreBinding()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("restoreBinding.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *myItem = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("myItem"));
+ QVERIFY(myItem != 0);
+
+ myItem->setY(25);
+ QCOMPARE(myItem->x(), qreal(100-25));
+
+ myItem->setY(13);
+ QCOMPARE(myItem->x(), qreal(100-13));
+
+ //Binding takes effect
+ myItem->setY(51);
+ QCOMPARE(myItem->x(), qreal(51));
+
+ myItem->setY(88);
+ QCOMPARE(myItem->x(), qreal(88));
+
+ //original binding restored
+ myItem->setY(49);
+ QCOMPARE(myItem->x(), qreal(100-49));
+
+ delete rect;
+}
+
+void tst_qquickbinding::restoreBindingWithLoop()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("restoreBindingWithLoop.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *myItem = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("myItem"));
+ QVERIFY(myItem != 0);
+
+ myItem->setY(25);
+ QCOMPARE(myItem->x(), qreal(25 + 100));
+
+ myItem->setY(13);
+ QCOMPARE(myItem->x(), qreal(13 + 100));
+
+ //Binding takes effect
+ rect->setProperty("activateBinding", true);
+ myItem->setY(51);
+ QCOMPARE(myItem->x(), qreal(51));
+
+ myItem->setY(88);
+ QCOMPARE(myItem->x(), qreal(88));
+
+ //original binding restored
+ QString warning = c.url().toString() + QLatin1String(":9:5: QML Rectangle: Binding loop detected for property \"x\"");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ rect->setProperty("activateBinding", false);
+ QCOMPARE(myItem->x(), qreal(88 + 100)); //if loop handling changes this could be 90 + 100
+
+ myItem->setY(49);
+ QCOMPARE(myItem->x(), qreal(49 + 100));
+
+ delete rect;
+}
+
+//QTBUG-20692
+void tst_qquickbinding::deletedObject()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("deletedObject.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QGuiApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+
+ //don't crash
+ rect->setProperty("activateBinding", true);
+
+ delete rect;
+}
+
+QTEST_MAIN(tst_qquickbinding)
+
+#include "tst_qquickbinding.moc"
diff --git a/tests/auto/qml/qquickchangeset/qquickchangeset.pro b/tests/auto/qml/qquickchangeset/qquickchangeset.pro
new file mode 100644
index 0000000000..726b18665b
--- /dev/null
+++ b/tests/auto/qml/qquickchangeset/qquickchangeset.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qquickchangeset
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickchangeset.cpp
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/qml/qquickchangeset/tst_qquickchangeset.cpp b/tests/auto/qml/qquickchangeset/tst_qquickchangeset.cpp
new file mode 100644
index 0000000000..4bd3df90ac
--- /dev/null
+++ b/tests/auto/qml/qquickchangeset/tst_qquickchangeset.cpp
@@ -0,0 +1,812 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <private/qquickchangeset_p.h>
+
+#define VERIFY_EXPECTED_OUTPUT
+
+class tst_qquickchangeset : public QObject
+{
+ Q_OBJECT
+public:
+ struct Signal
+ {
+ int index;
+ int count;
+ int to;
+ int moveId;
+
+ bool isInsert() const { return to == -1; }
+ bool isRemove() const { return to == -2; }
+ bool isMove() const { return to >= 0; }
+ bool isChange() const { return to == -3; }
+ };
+
+ static Signal Insert(int index, int count, int moveId = -1) { Signal signal = { index, count, -1, moveId }; return signal; }
+ static Signal Remove(int index, int count, int moveId = -1) { Signal signal = { index, count, -2, moveId }; return signal; }
+ static Signal Move(int from, int to, int count) { Signal signal = { from, count, to, -1 }; return signal; }
+ static Signal Change(int index, int count) { Signal signal = { index, count, -3, -1 }; return signal; }
+
+ typedef QVector<Signal> SignalList;
+
+
+#ifdef VERIFY_EXPECTED_OUTPUT
+
+ template<typename T>
+ void move(int from, int to, int n, T *items)
+ {
+ if (from > to) {
+ // Only move forwards - flip if backwards moving
+ int tfrom = from;
+ int tto = to;
+ from = tto;
+ to = tto+n;
+ n = tfrom-tto;
+ }
+
+ T replaced;
+ int i=0;
+ typename T::ConstIterator it=items->begin(); it += from+n;
+ for (; i<to-from; ++i,++it)
+ replaced.append(*it);
+ i=0;
+ it=items->begin(); it += from;
+ for (; i<n; ++i,++it)
+ replaced.append(*it);
+ typename T::ConstIterator f=replaced.begin();
+ typename T::Iterator t=items->begin(); t += from;
+ for (; f != replaced.end(); ++f, ++t)
+ *t = *f;
+ }
+
+ QVector<int> applyChanges(const QVector<int> &list, const QVector<Signal> &changes)
+ {
+ QHash<int, QVector<int> > removedValues;
+ QVector<int> alteredList = list;
+ foreach (const Signal &signal, changes) {
+ if (signal.isInsert()) {
+ if (signal.moveId != -1) {
+ QVector<int> tail = alteredList.mid(signal.index);
+ alteredList = alteredList.mid(0, signal.index) + removedValues.take(signal.moveId) + tail;
+ } else {
+ alteredList.insert(signal.index, signal.count, 100);
+ }
+ } else if (signal.isRemove()) {
+ if (signal.moveId != -1)
+ removedValues.insert(signal.moveId, alteredList.mid(signal.index, signal.count));
+ alteredList.erase(alteredList.begin() + signal.index, alteredList.begin() + signal.index + signal.count);
+ } else if (signal.isMove()) {
+ move(signal.index, signal.to, signal.count, &alteredList);
+ } else if (signal.isChange()) {
+ for (int i = signal.index; i < signal.index + signal.count; ++i) {
+ if (alteredList[i] < 100)
+ alteredList[i] = 100;
+ }
+ }
+ }
+ return alteredList;
+ }
+
+#endif
+
+private slots:
+ void sequence_data();
+ void sequence();
+};
+
+bool operator ==(const tst_qquickchangeset::Signal &left, const tst_qquickchangeset::Signal &right)
+{
+ return left.index == right.index
+ && left.count == right.count
+ && left.to == right.to
+ && ((left.moveId == -1 && right.moveId == -1) || (left.moveId != -1 && right.moveId != -1));
+}
+
+
+QDebug operator <<(QDebug debug, const tst_qquickchangeset::Signal &signal)
+{
+ if (signal.isInsert())
+ debug.nospace() << "Insert(" << signal.index << "," << signal.count << "," << signal.moveId << ")";
+ else if (signal.isRemove())
+ debug.nospace() << "Remove(" << signal.index << "," << signal.count << "," << signal.moveId << ")";
+ else if (signal.isMove())
+ debug.nospace() << "Move(" << signal.index << "," << signal.to << "," << signal.count << ")";
+ else if (signal.isChange())
+ debug.nospace() << "Change(" << signal.index << "," << signal.count << ")";
+ return debug;
+}
+
+Q_DECLARE_METATYPE(tst_qquickchangeset::SignalList)
+
+void tst_qquickchangeset::sequence_data()
+{
+ QTest::addColumn<SignalList>("input");
+ QTest::addColumn<SignalList>("output");
+
+ // Insert
+ QTest::newRow("i(12,5)")
+ << (SignalList() << Insert(12,5))
+ << (SignalList() << Insert(12,5));
+ QTest::newRow("i(2,3),i(12,5)")
+ << (SignalList() << Insert(2,3) << Insert(12,5))
+ << (SignalList() << Insert(2,3) << Insert(12,5));
+ QTest::newRow("i(12,5),i(2,3)")
+ << (SignalList() << Insert(12,5) << Insert(2,3))
+ << (SignalList() << Insert(2,3) << Insert(15,5));
+ QTest::newRow("i(12,5),i(12,3)")
+ << (SignalList() << Insert(12,5) << Insert(12,3))
+ << (SignalList() << Insert(12,8));
+ QTest::newRow("i(12,5),i(17,3)")
+ << (SignalList() << Insert(12,5) << Insert(17,3))
+ << (SignalList() << Insert(12,8));
+ QTest::newRow("i(12,5),i(15,3)")
+ << (SignalList() << Insert(12,5) << Insert(15,3))
+ << (SignalList() << Insert(12,8));
+
+ // Remove
+ QTest::newRow("r(3,9)")
+ << (SignalList() << Remove(3,9))
+ << (SignalList() << Remove(3,9));
+ QTest::newRow("r(3,4),r(3,2)")
+ << (SignalList() << Remove(3,4) << Remove(3,2))
+ << (SignalList() << Remove(3,6));
+ QTest::newRow("r(4,3),r(14,5)")
+ << (SignalList() << Remove(4,3) << Remove(14,5))
+ << (SignalList() << Remove(4,3) << Remove(14,5));
+ QTest::newRow("r(14,5),r(4,3)")
+ << (SignalList() << Remove(14,5) << Remove(4,3))
+ << (SignalList() << Remove(4,3) << Remove(11,5));
+ QTest::newRow("r(4,3),r(2,9)")
+ << (SignalList() << Remove(4,3) << Remove(2,9))
+ << (SignalList() << Remove(2,12));
+
+ // Move
+ QTest::newRow("m(8-10,2)")
+ << (SignalList() << Move(8,10,2))
+ << (SignalList() << Remove(8,2,1) << Insert(10,2,1));
+
+ QTest::newRow("m(23-12,6),m(13-15,5)")
+ << (SignalList() << Move(23,12,6) << Move(13,15,5))
+ << (SignalList() << Remove(23,1,0) << Remove(23,5,1) << Insert(12,1,0) << Insert(15,5,1));
+ QTest::newRow("m(23-12,6),m(13-15,2)")
+ << (SignalList() << Move(23,12,6) << Move(13,20,2))
+ << (SignalList() << Remove(23,1,0) << Remove(23,2,1) << Remove(23,3,2) << Insert(12,1,0) << Insert(13,3,2) << Insert(20,2,1));
+ QTest::newRow("m(23-12,6),m(13-2,2)")
+ << (SignalList() << Move(23,12,6) << Move(13,2,2))
+ << (SignalList() << Remove(23,1,0) << Remove(23,2,1) << Remove(23,3,2) << Insert(2,2,1) << Insert(14,1,0) << Insert(15,3,2));
+ QTest::newRow("m(23-12,6),m(12-6,5)")
+ << (SignalList() << Move(23,12,6) << Move(12,6,5))
+ << (SignalList() << Remove(23,5,0) << Remove(23,1,1) << Insert(6,5,0) << Insert(17,1,1));
+ QTest::newRow("m(23-12,6),m(10-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(10,5,4))
+ << (SignalList() << Remove(10,2,0) << Remove(21,2,1) << Remove(21,4,2) << Insert(5,2,0) << Insert(7,2,1) << Insert(14,4,2));
+ QTest::newRow("m(23-12,6),m(16-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(16,5,4))
+ << (SignalList() << Remove(12,2,0) << Remove(21,4,1) << Remove(21,2,2) << Insert(5,2,2) << Insert(7,2,0) << Insert(16,4,1));
+ QTest::newRow("m(23-12,6),m(13-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(13,5,4))
+ << (SignalList() << Remove(23,1,0) << Remove(23,4,1) << Remove(23,1,2) << Insert(5,4,1) << Insert(16,1,0) << Insert(17,1,2));
+ QTest::newRow("m(23-12,6),m(14-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(14,5,4))
+ << (SignalList() << Remove(23,2,0) << Remove(23,4,1) << Insert(5,4,1) << Insert(16,2,0));
+ QTest::newRow("m(23-12,6),m(12-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(12,5,4))
+ << (SignalList() << Remove(23,4,0) << Remove(23,2,1) << Insert(5,4,0) << Insert(16,2,1));
+ QTest::newRow("m(23-12,6),m(11-5,8)")
+ << (SignalList() << Move(23,12,6) << Move(11,5,8))
+ << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Remove(21,6,2) << Insert(5,1,0) << Insert(6,6,2) << Insert(12,1,1));
+ QTest::newRow("m(23-12,6),m(8-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(8,5,4))
+ << (SignalList() << Remove(8,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(12,6,1));
+ QTest::newRow("m(23-12,6),m(2-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(2,5,4))
+ << (SignalList() << Remove(2,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(12,6,1));
+ QTest::newRow("m(23-12,6),m(18-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(18,5,4))
+ << (SignalList() << Remove(12,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(16,6,1));
+ QTest::newRow("m(23-12,6),m(20-5,4)")
+ << (SignalList() << Move(23,12,6) << Move(20,5,4))
+ << (SignalList() << Remove(14,4,0) << Remove(19,6,1) << Insert(5,4,0) << Insert(16,6,1));
+
+ QTest::newRow("m(23-12,6),m(5-13,11)")
+ << (SignalList() << Move(23,12,6) << Move(5,13,11))
+ << (SignalList() << Remove(5,7,0) << Remove(16,4,1) << Remove(16,2,2) << Insert(5,2,2) << Insert(13,7,0) << Insert(20,4,1));
+
+ QTest::newRow("m(23-12,6),m(12-23,6)")
+ << (SignalList() << Move(23,12,6) << Move(12,23,6))
+ << (SignalList() << Remove(23,6,0) << Insert(23,6,0)); // ### These cancel out.
+ QTest::newRow("m(23-12,6),m(10-23,4)")
+ << (SignalList() << Move(23,12,6) << Move(10,23,4))
+ << (SignalList() << Remove(10,2 ,0) << Remove(21,2,1) << Remove(21,4,2) << Insert(10,4,2) << Insert(23,2,0) << Insert(25,2,1));
+ QTest::newRow("m(23-12,6),m(16-23.4)")
+ << (SignalList() << Move(23,12,6) << Move(16,23,4))
+ << (SignalList() << Remove(12,2,0) << Remove(21,4,1) << Remove(21,2,2) << Insert(12,4,1) << Insert(23,2,2) << Insert(25,2,0));
+ QTest::newRow("m(23-12,6),m(13-23,4)")
+ << (SignalList() << Move(23,12,6) << Move(13,23,4))
+ << (SignalList() << Remove(23,1,0) << Remove(23,4,1) << Remove(23,1,2) << Insert(12,1,0) << Insert(13,1,2) << Insert(23,4,1));
+ QTest::newRow("m(23-12,6),m(14-23,)")
+ << (SignalList() << Move(23,12,6) << Move(14,23,4))
+ << (SignalList() << Remove(23,2,0) << Remove(23,4,1) << Insert(12,2,0) << Insert(23,4,1));
+ QTest::newRow("m(23-12,6),m(12-23,4)")
+ << (SignalList() << Move(23,12,6) << Move(12,23,4))
+ << (SignalList() << Remove(23,4,0) << Remove(23,2,1) << Insert(12,2,1) << Insert(23,4,0));
+ QTest::newRow("m(23-12,6),m(11-23,8)")
+ << (SignalList() << Move(23,12,6) << Move(11,23,8))
+ << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Remove(21,6,2) << Insert(23,1,0) << Insert(24,6,2) << Insert(30,1,1));
+ QTest::newRow("m(23-12,6),m(8-23,4)")
+ << (SignalList() << Move(23,12,6) << Move(8,23,4))
+ << (SignalList() << Remove(8,4,0) << Remove(19,6,1) << Insert(8,6,1) << Insert(23,4,0));
+ QTest::newRow("m(23-12,6),m(2-23,4)")
+ << (SignalList() << Move(23,12,6) << Move(2,23,4))
+ << (SignalList() << Remove(2,4,0) << Remove(19,6,1) << Insert(8,6,1) << Insert(23,4,0));
+ QTest::newRow("m(23-12,6),m(18-23,4)")
+ << (SignalList() << Move(23,12,6) << Move(18,23,4))
+ << (SignalList() << Remove(12,4,0) << Remove(19,6,1) << Insert(12,6,1) << Insert(23,4,0));
+ QTest::newRow("m(23-12,6),m(20-23,4)")
+ << (SignalList() << Move(23,12,6) << Move(20,23,4))
+ << (SignalList() << Remove(14,4,1) << Remove(19,6,0) << Insert(12,6,0) << Insert(23,4,1));
+
+ QTest::newRow("m(23-12,6),m(11-23,10)")
+ << (SignalList() << Move(23,12,6) << Move(11,23,10))
+ << (SignalList() << Remove(11,1,3) << Remove(11,3,1) << Remove(19,6,2) << Insert(23,1,3) << Insert(24,6,2) << Insert(30,3,1));
+
+ QTest::newRow("m(3-9,12),m(13-5,12)")
+ << (SignalList() << Move(3,9,12) << Move(13,15,5))
+ << (SignalList() << Remove(3,4,2) << Remove(3,5,1) << Remove(3,2,0) << Remove(3,1,3) << Insert(9,4,2) << Insert(13,2,0) << Insert(15,5,1) << Insert(20,1,3));
+ QTest::newRow("m(3-9,12),m(13-15,20)")
+ << (SignalList() << Move(3,9,12) << Move(13,15,20))
+ << (SignalList() << Remove(3,4,0) << Remove(3,8,1) << Remove(9,12,2) << Insert(9,4,0) << Insert(15,8,1) << Insert(23,12,2));
+ QTest::newRow("m(3-9,12),m(13-15,2)")
+ << (SignalList() << Move(3,9,12) << Move(13,15,2))
+ << (SignalList() << Remove(3,4,2) << Remove(3,2,1) << Remove(3,2,0) << Remove(3,4,3) << Insert(9,4,2) << Insert(13,2,0) << Insert(15,2,1) << Insert(17,4,3));
+ QTest::newRow("m(3-9,12),m(12-5,6)")
+ << (SignalList() << Move(3,9,12) << Move(12,5,6))
+ << (SignalList() << Remove(3,3,0) << Remove(3,6,1) << Remove(3,3,2) << Insert(5,6,1) << Insert(15,3,0) << Insert(18,3,2));
+ QTest::newRow("m(3-9,12),m(10-14,5)")
+ << (SignalList() << Move(3,9,12) << Move(10,14,5))
+ << (SignalList() << Remove(3,1,2) << Remove(3,5,1) << Remove(3,4,0) << Remove(3,2,3) << Insert(9,1,2) << Insert(10,4,0) << Insert(14,5,1) << Insert(19,2,3));
+ QTest::newRow("m(3-9,12),m(16-20,5)")
+ << (SignalList() << Move(3,9,12) << Move(16,20,5))
+ << (SignalList() << Remove(3,7,0) << Remove(3,5,1) << Insert(9,7,0) << Insert(20,5,1));
+ QTest::newRow("m(3-9,12),m(13-17,5)")
+ << (SignalList() << Move(3,9,12) << Move(13,17,5))
+ << (SignalList() << Remove(3,4,0) << Remove(3,5,1) << Remove(3,3,2) << Insert(9,4,0) << Insert(13,3,2) << Insert(17,5,1));
+ QTest::newRow("m(3-9,12),m(14-18,5)")
+ << (SignalList() << Move(3,9,12) << Move(14,18,5))
+ << (SignalList() << Remove(3,5,0) << Remove(3,5,1) << Remove(3,2,2) << Insert(9,5,0) << Insert(14,2,2) << Insert(18,5,1));
+ QTest::newRow("m(3-9,12),m(12-16,5)")
+ << (SignalList() << Move(3,9,12) << Move(12,16,5))
+ << (SignalList() << Remove(3,3,2) << Remove(3,5,1) << Remove(3,4,0) << Insert(9,3,2) << Insert(12,4,0) << Insert(16,5,1));
+ QTest::newRow("m(3-9,12),m(11-19,5)")
+ << (SignalList() << Move(3,9,12) << Move(11,19,5))
+ << (SignalList() << Remove(3,2,0) << Remove(3,5,1) << Remove(3,5,2) << Insert(9,2,0) << Insert(11,5,2) << Insert(19,5,1));
+ QTest::newRow("m(3-9,12),m(8-12,5)")
+ << (SignalList() << Move(3,9,12) << Move(8,12,5))
+ << (SignalList() << Remove(3,4,1) << Remove(3,4,0) << Remove(3,4,4) << Remove(8,1,2) << Insert(8,4,0) << Insert(12,1,2) << Insert(13,4,1) << Insert(17,4,4));
+ QTest::newRow("m(3-9,12),m(2-6,5)")
+ << (SignalList() << Move(3,9,12) << Move(2,6,5))
+ << (SignalList() << Remove(2,1,2) << Remove(2,2,0) << Remove(2,10,3) << Remove(2,4,1) << Insert(4,2,0) << Insert(6,1,2) << Insert(7,4,1) << Insert(11,10,3));
+ QTest::newRow("m(3-9,12),m(18-22,5)")
+ << (SignalList() << Move(3,9,12) << Move(18,22,5))
+ << (SignalList() << Remove(3,9,0) << Remove(3,3,1) << Remove(9,2,2) << Insert(9,9,0) << Insert(22,3,1) << Insert(25,2,2));
+ QTest::newRow("m(3-9,12),m(20-24,5)")
+ << (SignalList() << Move(3,9,12) << Move(20,24,5))
+ << (SignalList() << Remove(3,11,0) << Remove(3,1,1) << Remove(9,4,2) << Insert(9,11,0) << Insert(24,1,1) << Insert(25,4,2));
+
+ QTest::newRow("m(3-9,12),m(5-11,8)")
+ << (SignalList() << Move(3,9,12) << Move(5,11,8))
+ << (SignalList() << Remove(3,4,1) << Remove(3,6,0) << Remove(3,2,3) << Remove(5,4,2) << Insert(5,6,0) << Insert(11,4,2) << Insert(15,2,3) << Insert(15,4,1));
+
+ QTest::newRow("m(3-9,12),m(12-23,6)")
+ << (SignalList() << Move(3,9,12) << Move(12,23,6))
+ << (SignalList() << Remove(3,3,2) << Remove(3,6,1) << Remove(3,3,0) << Insert(9,3,2) << Insert(12,3,0) << Insert(23,6,1));
+ QTest::newRow("m(3-9,12),m(10-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(10,23,4))
+ << (SignalList() << Remove(3,1,2) << Remove(3,4,1) << Remove(3,7,0) << Insert(9,1,2) << Insert(10,7,0) << Insert(23,4,1));
+ QTest::newRow("m(3-9,12),m(16-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(16,23,4))
+ << (SignalList() << Remove(3,7,2) << Remove(3,4,1) << Remove(3,1,0) << Insert(9,7,2) << Insert(16,1,0) << Insert(23,4,1));
+ QTest::newRow("m(3-9,12),m(13-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(13,23,4))
+ << (SignalList() << Remove(3,4,2) << Remove(3,4,1) << Remove(3,4,0) << Insert(9,4,2) << Insert(13,4,0) << Insert(23,4,1));
+ QTest::newRow("m(3-9,12),m(14-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(14,23,4))
+ << (SignalList() << Remove(3,5,2) << Remove(3,4,1) << Remove(3,3,0) << Insert(9,5,2) << Insert(14,3,0) << Insert(23,4,1));
+ QTest::newRow("m(3-9,12),m(12-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(12,23,4))
+ << (SignalList() << Remove(3,3,2) << Remove(3,4,1) << Remove(3,5,0) << Insert(9,3,2) << Insert(12,5,0) << Insert(23,4,1));
+ QTest::newRow("m(3-9,12),m(11-23,8)")
+ << (SignalList() << Move(3,9,12) << Move(11,23,8))
+ << (SignalList() << Remove(3,2,2) << Remove(3,8,1) << Remove(3,2,0) << Insert(9,2,2) << Insert(11,2,0) << Insert(23,8,1));
+ QTest::newRow("m(3-9,12),m(8-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(8,23,4))
+ << (SignalList() << Remove(3,3,1) << Remove(3,9,0) << Remove(8,1,2) << Insert(8,9,0) << Insert(23,1,2) << Insert(24,3,1));
+ QTest::newRow("m(3-9,12),m(2-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(2,23,4))
+ << (SignalList() << Remove(2,1,2) << Remove(2,12,0) << Remove(2,3,1) << Insert(5,12,0) << Insert(23,1,2) << Insert(24,3,1));
+ QTest::newRow("m(3-9,12),m(18-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(18,23,4))
+ << (SignalList() << Remove(3,9,3) << Remove(3,3,2) << Remove(9,1,1) << Insert(9,9,3) << Insert(23,3,2) << Insert(26,1,1));
+ QTest::newRow("m(3-9,12),m(20-23,4)")
+ << (SignalList() << Move(3,9,12) << Move(20,23,4))
+ << (SignalList() << Remove(3,11,3) << Remove(3,1,2) << Remove(9,3,1) << Insert(9,11,3) << Insert(23,1,2) << Insert(24,3,1));
+
+ QTest::newRow("m(3-9,12),m(11-23,10)")
+ << (SignalList() << Move(3,9,12) << Move(11,23,10))
+ << (SignalList() << Remove(3,2,2) << Remove(3,10,1) << Insert(9,2,2) << Insert(23,10,1));
+
+ // Change
+ QTest::newRow("c(4,5)")
+ << (SignalList() << Change(4,5))
+ << (SignalList() << Change(4,5));
+ QTest::newRow("c(4,5),c(12,2)")
+ << (SignalList() << Change(4,5) << Change(12,2))
+ << (SignalList() << Change(4,5) << Change(12,2));
+ QTest::newRow("c(12,2),c(4,5)")
+ << (SignalList() << Change(12,2) << Change(4,5))
+ << (SignalList() << Change(4,5) << Change(12,2));
+ QTest::newRow("c(4,5),c(2,2)")
+ << (SignalList() << Change(4,5) << Change(2,2))
+ << (SignalList() << Change(2,7));
+ QTest::newRow("c(4,5),c(9,2)")
+ << (SignalList() << Change(4,5) << Change(9,2))
+ << (SignalList() << Change(4,7));
+ QTest::newRow("c(4,5),c(3,2)")
+ << (SignalList() << Change(4,5) << Change(3,2))
+ << (SignalList() << Change(3,6));
+ QTest::newRow("c(4,5),c(8,2)")
+ << (SignalList() << Change(4,5) << Change(8,2))
+ << (SignalList() << Change(4,6));
+ QTest::newRow("c(4,5),c(3,2)")
+ << (SignalList() << Change(4,5) << Change(3,2))
+ << (SignalList() << Change(3,6));
+ QTest::newRow("c(4,5),c(2,9)")
+ << (SignalList() << Change(4,5) << Change(2,9))
+ << (SignalList() << Change(2,9));
+ QTest::newRow("c(4,5),c(12,3),c(8,6)")
+ << (SignalList() << Change(4,5) << Change(12,3) << Change(8,6))
+ << (SignalList() << Change(4,11));
+
+ // Insert,then remove.
+ QTest::newRow("i(12,6),r(12,6)")
+ << (SignalList() << Insert(12,6) << Remove(12,6))
+ << (SignalList());
+ QTest::newRow("i(12,6),r(10,4)")
+ << (SignalList() << Insert(12,6) << Remove(10,4))
+ << (SignalList() << Remove(10,2) << Insert(10,4));
+ QTest::newRow("i(12,6),r(16,4)")
+ << (SignalList() << Insert(12,6) << Remove(16,4))
+ << (SignalList() << Remove(12,2) << Insert(12,4));
+ QTest::newRow("i(12,6),r(13,4)")
+ << (SignalList() << Insert(12,6) << Remove(13,4))
+ << (SignalList() << Insert(12,2));
+ QTest::newRow("i(12,6),r(14,4)")
+ << (SignalList() << Insert(12,6) << Remove(14,4))
+ << (SignalList() << Insert(12,2));
+ QTest::newRow("i(12,6),r(12,4)")
+ << (SignalList() << Insert(12,6) << Remove(12,4))
+ << (SignalList() << Insert(12,2));
+ QTest::newRow("i(12,6),r(11,8)")
+ << (SignalList() << Insert(12,6) << Remove(11,8))
+ << (SignalList() << Remove(11,2));
+ QTest::newRow("i(12,6),r(8,4)")
+ << (SignalList() << Insert(12,6) << Remove(8,4))
+ << (SignalList() << Remove(8,4) << Insert(8,6));
+ QTest::newRow("i(12,6),r(2,4)")
+ << (SignalList() << Insert(12,6) << Remove(2,4))
+ << (SignalList() << Remove(2,4) << Insert(8,6));
+ QTest::newRow("i(12,6),r(18,4)")
+ << (SignalList() << Insert(12,6) << Remove(18,4))
+ << (SignalList() << Remove(12,4) << Insert(12,6));
+ QTest::newRow("i(12,6),r(20,4)")
+ << (SignalList() << Insert(12,6) << Remove(20,4))
+ << (SignalList() << Remove(14,4) << Insert(12,6));
+
+ // Insert,then move
+ QTest::newRow("i(12,6),m(12-5,6)")
+ << (SignalList() << Insert(12,6) << Move(12,5,6))
+ << (SignalList() << Insert(5,6));
+ QTest::newRow("i(12,6),m(10-5,4)")
+ << (SignalList() << Insert(12,6) << Move(10,5,4))
+ << (SignalList() << Remove(10,2,0) << Insert(5,2,0) << Insert(7,2) << Insert(14,4));
+ QTest::newRow("i(12,6),m(16-5,4)")
+ << (SignalList() << Insert(12,6) << Move(16,5,4))
+ << (SignalList() << Remove(12,2,0) << Insert(5,2) << Insert(7,2,0) << Insert(16,4));
+ QTest::newRow("i(12,6),m(13-5,4)")
+ << (SignalList() << Insert(12,6) << Move(13,5,4))
+ << (SignalList() << Insert(5,4) << Insert(16,2));
+ QTest::newRow("i(12,6),m(14-5,4)")
+ << (SignalList() << Insert(12,6) << Move(14,5,4))
+ << (SignalList() << Insert(5,4) << Insert(16,2));
+ QTest::newRow("i(12,6),m(12-5,4)")
+ << (SignalList() << Insert(12,6) << Move(12,5,4))
+ << (SignalList() << Insert(5,4) << Insert(16,2));
+ QTest::newRow("i(12,6),m(11-5,8)")
+ << (SignalList() << Insert(12,6) << Move(11,5,8))
+ << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Insert(5,1,0) << Insert(6,6) << Insert(12,1,1));
+ QTest::newRow("i(12,6),m(8-5,4)")
+ << (SignalList() << Insert(12,6) << Move(8,5,4))
+ << (SignalList() << Remove(8,4,0) << Insert(5,4,0) << Insert(12,6));
+ QTest::newRow("i(12,6),m(2-5,4)")
+ << (SignalList() << Insert(12,6) << Move(2,5,4))
+ << (SignalList() << Remove(2,4,0) << Insert(5,4,0) << Insert(12,6));
+ QTest::newRow("i(12,6),m(18-5,4)")
+ << (SignalList() << Insert(12,6) << Move(18,5,4))
+ << (SignalList() << Remove(12,4,0) << Insert(5,4,0) << Insert(16,6));
+ QTest::newRow("i(12,6),m(20-5,4)")
+ << (SignalList() << Insert(12,6) << Move(20,5,4))
+ << (SignalList() << Remove(14,4,0) << Insert(5,4,0) << Insert(16,6));
+
+ QTest::newRow("i(12,6),m(5-13,11)")
+ << (SignalList() << Insert(12,6) << Move(5,11,8))
+ << (SignalList() << Remove(5,7,0) << Insert(5,5) << Insert(11,7,0) << Insert(18,1));
+
+ QTest::newRow("i(12,6),m(12-23,6)")
+ << (SignalList() << Insert(12,6) << Move(12,23,6))
+ << (SignalList() << Insert(23,6));
+ QTest::newRow("i(12,6),m(10-23,4)")
+ << (SignalList() << Insert(12,6) << Move(10,23,4))
+ << (SignalList() << Remove(10,2,0) << Insert(10,4) << Insert(23,2,0) << Insert(25,2));
+ QTest::newRow("i(12,6),m(16-23,4)")
+ << (SignalList() << Insert(12,6) << Move(16,23,4))
+ << (SignalList() << Remove(12,2,0) << Insert(12,4) << Insert(23,2) << Insert(25,2,0));
+ QTest::newRow("i(12,6),m(13-23,4)")
+ << (SignalList() << Insert(12,6) << Move(13,23,4))
+ << (SignalList() << Insert(12,2) << Insert(23,4));
+ QTest::newRow("i(12,6),m(14-23,4)")
+ << (SignalList() << Insert(12,6) << Move(14,23,4))
+ << (SignalList() << Insert(12,2) << Insert(23,4));
+ QTest::newRow("i(12,6),m(12-23,4)")
+ << (SignalList() << Insert(12,6) << Move(12,23,4))
+ << (SignalList() << Insert(12,2) << Insert(23,4));
+ QTest::newRow("i(12,6),m(11-23,8)")
+ << (SignalList() << Insert(12,6) << Move(11,23,8))
+ << (SignalList() << Remove(11,1,0) << Remove(11,1,1) << Insert(23,1,0)<< Insert(24,6) << Insert(30,1,1));
+ QTest::newRow("i(12,6),m(8-23,4)")
+ << (SignalList() << Insert(12,6) << Move(8,23,4))
+ << (SignalList() << Remove(8,4,0) << Insert(8,6) << Insert(23,4,0));
+ QTest::newRow("i(12,6),m(2-23,4)")
+ << (SignalList() << Insert(12,6) << Move(2,23,4))
+ << (SignalList() << Remove(2,4,0) << Insert(8,6) << Insert(23,4,0));
+ QTest::newRow("i(12,6),m(18-23,4)")
+ << (SignalList() << Insert(12,6) << Move(18,23,4))
+ << (SignalList() << Remove(12,4,0) << Insert(12,6) << Insert(23,4,0));
+ QTest::newRow("i(12,6),m(20-23,4)")
+ << (SignalList() << Insert(12,6) << Move(20,23,4))
+ << (SignalList() << Remove(14,4,0) << Insert(12,6) << Insert(23,4,0));
+
+ QTest::newRow("i(12,6),m(11-23,10)")
+ << (SignalList() << Insert(12,6) << Move(11,23,10))
+ << (SignalList() << Remove(11,1,0) << Remove(11,3,1) << Insert(23,1,0) << Insert(24,6) << Insert(30,3,1));
+
+ // Insert,then change
+ QTest::newRow("i(12,6),c(12,6)")
+ << (SignalList() << Insert(12,6) << Change(12,6))
+ << (SignalList() << Insert(12,6));
+ QTest::newRow("i(12,6),c(10,6)")
+ << (SignalList() << Insert(12,6) << Change(10,6))
+ << (SignalList() << Insert(12,6) << Change(10,2));
+ QTest::newRow("i(12,6),c(16,4)")
+ << (SignalList() << Insert(12,6) << Change(16,4))
+ << (SignalList() << Insert(12,6) << Change(18,2));
+ QTest::newRow("i(12,6),c(13,4)")
+ << (SignalList() << Insert(12,6) << Change(13,4))
+ << (SignalList() << Insert(12,6));
+ QTest::newRow("i(12,6),c(14,4)")
+ << (SignalList() << Insert(12,6) << Change(14,4))
+ << (SignalList() << Insert(12,6));
+ QTest::newRow("i(12,6),c(12,4)")
+ << (SignalList() << Insert(12,6) << Change(12,4))
+ << (SignalList() << Insert(12,6));
+ QTest::newRow("i(12,6),c(11,8)")
+ << (SignalList() << Insert(12,6) << Change(11,8))
+ << (SignalList() << Insert(12,6) << Change(11,1) << Change(18,1));
+ QTest::newRow("i(12,6),c(8,4)")
+ << (SignalList() << Insert(12,6) << Change(8,4))
+ << (SignalList() << Insert(12,6) << Change(8,4));
+ QTest::newRow("i(12,6),c(2,4)")
+ << (SignalList() << Insert(12,6) << Change(2,4))
+ << (SignalList() << Insert(12,6) << Change(2,4));
+ QTest::newRow("i(12,6),c(18,4)")
+ << (SignalList() << Insert(12,6) << Change(18,4))
+ << (SignalList() << Insert(12,6) << Change(18,4));
+ QTest::newRow("i(12,6),c(20,4)")
+ << (SignalList() << Insert(12,6) << Change(20,4))
+ << (SignalList() << Insert(12,6) << Change(20,4));
+
+ // Remove,then insert
+ QTest::newRow("r(12,6),i(12,6)")
+ << (SignalList() << Remove(12,6) << Insert(12,6))
+ << (SignalList() << Remove(12,6) << Insert(12,6));
+ QTest::newRow("r(12,6),i(10,4)")
+ << (SignalList() << Remove(12,6) << Insert(10,14))
+ << (SignalList() << Remove(12,6) << Insert(10,14));
+ QTest::newRow("r(12,6),i(16,4)")
+ << (SignalList() << Remove(12,6) << Insert(16,4))
+ << (SignalList() << Remove(12,6) << Insert(16,4));
+ QTest::newRow("r(12,6),i(13,4)")
+ << (SignalList() << Remove(12,6) << Insert(13,4))
+ << (SignalList() << Remove(12,6) << Insert(13,4));
+ QTest::newRow("r(12,6),i(14,4)")
+ << (SignalList() << Remove(12,6) << Insert(14,4))
+ << (SignalList() << Remove(12,6) << Insert(14,4));
+ QTest::newRow("r(12,6),i(12,4)")
+ << (SignalList() << Remove(12,6) << Insert(12,4))
+ << (SignalList() << Remove(12,6) << Insert(12,4));
+ QTest::newRow("r(12,6),i(11,8)")
+ << (SignalList() << Remove(12,6) << Insert(11,8))
+ << (SignalList() << Remove(12,6) << Insert(11,8));
+ QTest::newRow("r(12,6),i(8,4)")
+ << (SignalList() << Remove(12,6) << Insert(8,4))
+ << (SignalList() << Remove(12,6) << Insert(8,4));
+ QTest::newRow("r(12,6),i(2,4)")
+ << (SignalList() << Remove(12,6) << Insert(2,4))
+ << (SignalList() << Remove(12,6) << Insert(2,4));
+ QTest::newRow("r(12,6),i(18,4)")
+ << (SignalList() << Remove(12,6) << Insert(18,4))
+ << (SignalList() << Remove(12,6) << Insert(18,4));
+ QTest::newRow("r(12,6),i(20,4)")
+ << (SignalList() << Remove(12,6) << Insert(20,4))
+ << (SignalList() << Remove(12,6) << Insert(20,4));
+
+ // Move,then insert
+ QTest::newRow("m(12-5,6),i(12,6)")
+ << (SignalList() << Move(12,5,6) << Insert(12,6))
+ << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(12,6));
+ QTest::newRow("m(12-5,6),i(10,4)")
+ << (SignalList() << Move(12,5,6) << Insert(10,4))
+ << (SignalList() << Remove(12,5,0) << Remove(12,1,1) << Insert(5,5,0) << Insert(10,4) << Insert(14,1,1));
+ QTest::newRow("m(12-5,6),i(16,4)")
+ << (SignalList() << Move(12,5,6) << Insert(16,4))
+ << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(16,4));
+ QTest::newRow("m(12-5,6),i(13,4)")
+ << (SignalList() << Move(12,5,6) << Insert(13,4))
+ << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(13,4));
+ QTest::newRow("m(12-5,6),i(14,4)")
+ << (SignalList() << Move(12,5,6) << Insert(14,4))
+ << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(14,4));
+ QTest::newRow("m(12-5,6),i(12,4)")
+ << (SignalList() << Move(12,5,6) << Insert(12,4))
+ << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(12,4));
+ QTest::newRow("m(12-5,6),i(11,8)")
+ << (SignalList() << Move(12,5,6) << Insert(11,8))
+ << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(11,8));
+ QTest::newRow("m(12-5,6),i(8,4)")
+ << (SignalList() << Move(12,5,6) << Insert(8,4))
+ << (SignalList() << Remove(12,3,0) << Remove(12,3,1) << Insert(5,3,0) << Insert(8,4) << Insert(12,3,1));
+ QTest::newRow("m(12-5,6),i(2,4)")
+ << (SignalList() << Move(12,5,6) << Insert(2,4))
+ << (SignalList() << Remove(12,6,0) << Insert(2,4) << Insert(9,6,0));
+ QTest::newRow("m(12-5,6),i(18,4)")
+ << (SignalList() << Move(12,5,6) << Insert(18,4))
+ << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(18,4));
+ QTest::newRow("m(12-5,6),i(20,4)")
+ << (SignalList() << Move(12,5,6) << Insert(20,4))
+ << (SignalList() << Remove(12,6,0) << Insert(5,6,0) << Insert(20,4));
+
+ QTest::newRow("m(12-23,6),i(12,6)")
+ << (SignalList() << Move(12,23,6) << Insert(12,6))
+ << (SignalList() << Remove(12,6,0) << Insert(12,6) << Insert(29,6,0));
+ QTest::newRow("m(12-23,6),i(10,4)")
+ << (SignalList() << Move(12,23,6) << Insert(10,4))
+ << (SignalList() << Remove(12,6,0) << Insert(10,4) << Insert(27,6,0));
+ QTest::newRow("m(12-23,6),i(16,4)")
+ << (SignalList() << Move(12,23,6) << Insert(16,4))
+ << (SignalList() << Remove(12,6,0) << Insert(16,4) << Insert(27,6,0));
+ QTest::newRow("m(12-23,6),i(13,4)")
+ << (SignalList() << Move(12,23,6) << Insert(13,4))
+ << (SignalList() << Remove(12,6,0) << Insert(13,4) << Insert(27,6,0));
+ QTest::newRow("m(12-23,6),i(14,4)")
+ << (SignalList() << Move(12,23,6) << Insert(14,4))
+ << (SignalList() << Remove(12,6,0) << Insert(14,4) << Insert(27,6,0));
+ QTest::newRow("m(12-23,6),i(12,4)")
+ << (SignalList() << Move(12,23,6) << Insert(12,4))
+ << (SignalList() << Remove(12,6,0) << Insert(12,4) << Insert(27,6,0));
+ QTest::newRow("m(12-23,6),i(11,8)")
+ << (SignalList() << Move(12,23,6) << Insert(11,8))
+ << (SignalList() << Remove(12,6,0) << Insert(11,8) << Insert(31,6,0));
+ QTest::newRow("m(12-23,6),i(8,4)")
+ << (SignalList() << Move(12,23,6) << Insert(8,4))
+ << (SignalList() << Remove(12,6,0) << Insert(8,4) << Insert(27,6,0));
+ QTest::newRow("m(12-23,6),i(2,4)")
+ << (SignalList() << Move(12,23,6) << Insert(2,4))
+ << (SignalList() << Remove(12,6,0) << Insert(2,4) << Insert(27,6,0));
+ QTest::newRow("m(12-23,6),i(18,4)")
+ << (SignalList() << Move(12,23,6) << Insert(18,4))
+ << (SignalList() << Remove(12,6,0) << Insert(18,4) << Insert(27,6,0));
+ QTest::newRow("m(12-23,6),i(20,4)")
+ << (SignalList() << Move(12,23,6) << Insert(20,4))
+ << (SignalList() << Remove(12,6,0) << Insert(20,4) << Insert(27,6,0));
+
+ // Move,then remove
+ QTest::newRow("m(12-5,6),r(12,6)")
+ << (SignalList() << Move(12,5,6) << Remove(12,6))
+ << (SignalList() << Remove(6,6) << Remove(6,6,0) << Insert(5,6,0));
+ QTest::newRow("m(12-5,6),r(10,4)")
+ << (SignalList() << Move(12,5,6) << Remove(10,4))
+ << (SignalList() << Remove(5,3) << Remove(9,5,0) << Remove(9,1) << Insert(5,5,0));
+ QTest::newRow("m(12-5,6),r(16,4)")
+ << (SignalList() << Move(12,5,6) << Remove(16,4))
+ << (SignalList() << Remove(10,2) << Remove(10,6,0) << Remove(10,2) << Insert(5,6,0));
+ QTest::newRow("m(12-5,6),r(13,4)")
+ << (SignalList() << Move(12,5,6) << Remove(13,4))
+ << (SignalList() << Remove(7,4) << Remove(8,6,0) << Insert(5,6,0));
+ QTest::newRow("m(12-5,6),r(14,4)")
+ << (SignalList() << Move(12,5,6) << Remove(14,4))
+ << (SignalList() << Remove(8,4) << Remove(8,6,0) << Insert(5,6,0));
+ QTest::newRow("m(12-5,6),r(12,4)")
+ << (SignalList() << Move(12,5,6) << Remove(12,4))
+ << (SignalList() << Remove(6,4) << Remove(8,6,0) << Insert(5,6,0));
+ QTest::newRow("m(12-5,6),r(11,8)")
+ << (SignalList() << Move(12,5,6) << Remove(11,8))
+ << (SignalList() << Remove(5,7) << Remove(5,6,0) << Remove(5,1) << Insert(5,6,0));
+ QTest::newRow("m(12-5,6),r(8,4)")
+ << (SignalList() << Move(12,5,6) << Remove(8,4))
+ << (SignalList() << Remove(5,1) << Remove(11,3,0) << Remove(11,3) << Insert(5,3,0));
+ QTest::newRow("m(12-5,6),r(2,4)")
+ << (SignalList() << Move(12,5,6) << Remove(2,4))
+ << (SignalList() << Remove(2,3) << Remove(9,1) << Remove(9,5,0) << Insert(2,5,0));
+ QTest::newRow("m(12-5,6),r(6,4)")
+ << (SignalList() << Move(12,5,6) << Remove(6,4))
+ << (SignalList() << Remove(12,1,0) << Remove(12,4) << Remove(12,1,1) << Insert(5,1,0) << Insert(6,1,1));
+ QTest::newRow("m(12-5,6),r(18,4)")
+ << (SignalList() << Move(12,5,6) << Remove(18,4))
+ << (SignalList() << Remove(12,6,0) << Remove(12,4) << Insert(5,6,0));
+ QTest::newRow("m(12-5,6),r(20,4)")
+ << (SignalList() << Move(12,5,6) << Remove(20,4))
+ << (SignalList() << Remove(12,6,0) << Remove(14,4) << Insert(5,6,0));
+
+ QTest::newRow("m(12-23,6),r(12,6)")
+ << (SignalList() << Move(12,23,6) << Remove(12,6))
+ << (SignalList() << Remove(12,6,0) << Remove(12,6) << Insert(17,6,0));
+ QTest::newRow("m(12-23,6),r(10,4)")
+ << (SignalList() << Move(12,23,6) << Remove(10,4))
+ << (SignalList() << Remove(10,2) << Remove(10,6,0) << Remove(10,2) << Insert(19,6,0));
+ QTest::newRow("m(12-23,6),r(16,4)")
+ << (SignalList() << Move(12,23,6) << Remove(16,4))
+ << (SignalList() << Remove(12,6,0) << Remove(16,4) << Insert(19,6,0));
+ QTest::newRow("m(12-23,6),r(13,4)")
+ << (SignalList() << Move(12,23,6) << Remove(13,4))
+ << (SignalList() << Remove(12,6,0) << Remove(13,4) << Insert(19,6,0));
+ QTest::newRow("m(12-23,6),r(14,4)")
+ << (SignalList() << Move(12,23,6) << Remove(14,4))
+ << (SignalList() << Remove(12,6,0) << Remove(14,4) << Insert(19,6,0));
+ QTest::newRow("m(12-23,6),r(12,4)")
+ << (SignalList() << Move(12,23,6) << Remove(12,4))
+ << (SignalList() << Remove(12,6,0) << Remove(12,4) << Insert(19,6,0));
+ QTest::newRow("m(12-23,6),r(11,8)")
+ << (SignalList() << Move(12,23,6) << Remove(11,8))
+ << (SignalList() << Remove(11,1) << Remove(11,6,0) << Remove(11,7) << Insert(15,6,0));
+ QTest::newRow("m(12-23,6),r(8,4)")
+ << (SignalList() << Move(12,23,6) << Remove(8,4))
+ << (SignalList() << Remove(8,4) << Remove(8,6,0) << Insert(19,6,0));
+ QTest::newRow("m(12-23,6),r(2,4)")
+ << (SignalList() << Move(12,23,6) << Remove(2,4))
+ << (SignalList() << Remove(2,4) << Remove(8,6,0) << Insert(19,6,0));
+ QTest::newRow("m(12-23,6),r(18,4)")
+ << (SignalList() << Move(12,23,6) << Remove(18,4))
+ << (SignalList() << Remove(12,6,0) << Remove(18,4) << Insert(19,6,0));
+ QTest::newRow("m(12-23,6),r(20,4)")
+ << (SignalList() << Move(12,23,6) << Remove(20,4))
+ << (SignalList() << Remove(12,1) << Remove(12,5,0) << Remove(20,3) << Insert(20,5,0));
+
+
+ // Complex
+ QTest::newRow("r(15,1),r(22,1)")
+ << (SignalList() << Remove(15,1) << Remove(22,1))
+ << (SignalList() << Remove(15,1) << Remove(22,1));
+ QTest::newRow("r(15,1),r(22,1),r(25,1)")
+ << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1))
+ << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1));
+ QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1)")
+ << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1))
+ << (SignalList() << Remove(15,2) << Remove(21,1) << Remove(24,1));
+ QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1)")
+ << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1))
+ << (SignalList() << Remove(13,1) << Remove(14,2) << Remove(20,1) << Remove(23,1));
+ QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1),r(13,1)")
+ << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1) << Remove(13,1))
+ << (SignalList() << Remove(13,4) << Remove(19,1) << Remove(22,1));
+ QTest::newRow("r(15,1),r(22,1),r(25,1),r(15,1),r(13,1),r(13,1),m(12,13,1)")
+ << (SignalList() << Remove(15,1) << Remove(22,1) << Remove(25,1) << Remove(15,1) << Remove(13,1) << Remove(13,1) << Move(12,13,1))
+ << (SignalList() << Remove(12,1,0) << Remove(12,4) << Remove(18,1) << Remove(21,1) << Insert(13,1,0));
+
+}
+
+void tst_qquickchangeset::sequence()
+{
+ QFETCH(SignalList, input);
+ QFETCH(SignalList, output);
+
+ QQuickChangeSet set;
+
+ foreach (const Signal &signal, input) {
+ if (signal.isRemove())
+ set.remove(signal.index, signal.count);
+ else if (signal.isInsert())
+ set.insert(signal.index, signal.count);
+ else if (signal.isMove())
+ set.move(signal.index, signal.to, signal.count);
+ else if (signal.isChange())
+ set.change(signal.index, signal.count);
+ }
+
+ SignalList changes;
+ foreach (const QQuickChangeSet::Remove &remove, set.removes())
+ changes << Remove(remove.index, remove.count, remove.moveId);
+ foreach (const QQuickChangeSet::Insert &insert, set.inserts())
+ changes << Insert(insert.index, insert.count, insert.moveId);
+ foreach (const QQuickChangeSet::Change &change, set.changes())
+ changes << Change(change.index, change.count);
+
+#ifdef VERIFY_EXPECTED_OUTPUT
+ QVector<int> list;
+ for (int i = 0; i < 40; ++i)
+ list.append(i);
+ QVector<int> inputList = applyChanges(list, input);
+ QVector<int> outputList = applyChanges(list, output);
+ if (outputList != inputList /* || changes != output*/) {
+ qDebug() << input;
+ qDebug() << output;
+ qDebug() << changes;
+ qDebug() << inputList;
+ qDebug() << outputList;
+ } else if (changes != output) {
+ qDebug() << output;
+ qDebug() << changes;
+ }
+ QCOMPARE(outputList, inputList);
+#else
+
+ if (changes != output) {
+ qDebug() << output;
+ qDebug() << changes;
+ }
+
+#endif
+
+ QCOMPARE(changes, output);
+}
+
+
+QTEST_MAIN(tst_qquickchangeset)
+
+#include "tst_qquickchangeset.moc"
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-targetchange.qml b/tests/auto/qml/qquickconnection/data/connection-targetchange.qml
index 154c309c9c..154c309c9c 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/connection-targetchange.qml
+++ b/tests/auto/qml/qquickconnection/data/connection-targetchange.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-ignored.qml
index 05d06bda94..05d06bda94 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml
+++ b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-ignored.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-notarget.qml
index 9d25cba649..9d25cba649 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml
+++ b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-notarget.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-parent.qml
index bcd281256f..bcd281256f 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals-parent.qml
+++ b/tests/auto/qml/qquickconnection/data/connection-unknownsignals-parent.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml b/tests/auto/qml/qquickconnection/data/connection-unknownsignals.qml
index ad8d4d91a8..ad8d4d91a8 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/connection-unknownsignals.qml
+++ b/tests/auto/qml/qquickconnection/data/connection-unknownsignals.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml b/tests/auto/qml/qquickconnection/data/error-object.qml
index 256b2626a7..256b2626a7 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml
+++ b/tests/auto/qml/qquickconnection/data/error-object.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml b/tests/auto/qml/qquickconnection/data/error-property.qml
index a602479783..a602479783 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml
+++ b/tests/auto/qml/qquickconnection/data/error-property.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml b/tests/auto/qml/qquickconnection/data/error-property2.qml
index 8123afe707..8123afe707 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml
+++ b/tests/auto/qml/qquickconnection/data/error-property2.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml b/tests/auto/qml/qquickconnection/data/error-syntax.qml
index 16c0534b68..16c0534b68 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml
+++ b/tests/auto/qml/qquickconnection/data/error-syntax.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/moduleapi-target.qml b/tests/auto/qml/qquickconnection/data/moduleapi-target.qml
index 8803f24542..8803f24542 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/moduleapi-target.qml
+++ b/tests/auto/qml/qquickconnection/data/moduleapi-target.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml b/tests/auto/qml/qquickconnection/data/test-connection.qml
index ce851fc3db..ce851fc3db 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/test-connection.qml
+++ b/tests/auto/qml/qquickconnection/data/test-connection.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml b/tests/auto/qml/qquickconnection/data/test-connection2.qml
index b23d2fc145..b23d2fc145 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/test-connection2.qml
+++ b/tests/auto/qml/qquickconnection/data/test-connection2.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml b/tests/auto/qml/qquickconnection/data/test-connection3.qml
index 9e88f0ff8f..9e88f0ff8f 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/test-connection3.qml
+++ b/tests/auto/qml/qquickconnection/data/test-connection3.qml
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml b/tests/auto/qml/qquickconnection/data/trimming.qml
index 6692050deb..6692050deb 100644
--- a/tests/auto/declarative/qdeclarativeconnection/data/trimming.qml
+++ b/tests/auto/qml/qquickconnection/data/trimming.qml
diff --git a/tests/auto/qml/qquickconnection/qquickconnection.pro b/tests/auto/qml/qquickconnection/qquickconnection.pro
new file mode 100644
index 0000000000..bea1f1df00
--- /dev/null
+++ b/tests/auto/qml/qquickconnection/qquickconnection.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickconnection
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickconnection.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp b/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp
new file mode 100644
index 0000000000..ad687dd085
--- /dev/null
+++ b/tests/auto/qml/qquickconnection/tst_qquickconnection.cpp
@@ -0,0 +1,292 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <private/qquickconnections_p.h>
+#include <private/qquickitem_p.h>
+#include "../../shared/util.h"
+#include <QtQml/qqmlscriptstring.h>
+
+class tst_qquickconnection : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickconnection();
+
+private slots:
+ void defaultValues();
+ void properties();
+ void connection();
+ void trimming();
+ void targetChanged();
+ void unknownSignals_data();
+ void unknownSignals();
+ void errors_data();
+ void errors();
+ void moduleApiTarget();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquickconnection::tst_qquickconnection()
+{
+}
+
+void tst_qquickconnection::defaultValues()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-connection3.qml"));
+ QQuickConnections *item = qobject_cast<QQuickConnections*>(c.create());
+
+ QVERIFY(item != 0);
+ QVERIFY(item->target() == 0);
+
+ delete item;
+}
+
+void tst_qquickconnection::properties()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-connection2.qml"));
+ QQuickConnections *item = qobject_cast<QQuickConnections*>(c.create());
+
+ QVERIFY(item != 0);
+
+ QVERIFY(item != 0);
+ QVERIFY(item->target() == item);
+
+ delete item;
+}
+
+void tst_qquickconnection::connection()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-connection.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
+
+ QVERIFY(item != 0);
+
+ QCOMPARE(item->property("tested").toBool(), false);
+ QCOMPARE(item->width(), 50.);
+ emit item->setWidth(100.);
+ QCOMPARE(item->width(), 100.);
+ QCOMPARE(item->property("tested").toBool(), true);
+
+ delete item;
+}
+
+void tst_qquickconnection::trimming()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("trimming.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
+
+ QVERIFY(item != 0);
+
+ QCOMPARE(item->property("tested").toString(), QString(""));
+ int index = item->metaObject()->indexOfSignal("testMe(int,QString)");
+ QMetaMethod method = item->metaObject()->method(index);
+ method.invoke(item,
+ Qt::DirectConnection,
+ Q_ARG(int, 5),
+ Q_ARG(QString, "worked"));
+ QCOMPARE(item->property("tested").toString(), QString("worked5"));
+
+ delete item;
+}
+
+// Confirm that target can be changed by one of our signal handlers
+void tst_qquickconnection::targetChanged()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("connection-targetchange.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
+ QVERIFY(item != 0);
+
+ QQuickConnections *connections = item->findChild<QQuickConnections*>("connections");
+ QVERIFY(connections);
+
+ QQuickItem *item1 = item->findChild<QQuickItem*>("item1");
+ QVERIFY(item1);
+
+ item1->setWidth(200);
+
+ QQuickItem *item2 = item->findChild<QQuickItem*>("item2");
+ QVERIFY(item2);
+ QVERIFY(connections->target() == item2);
+
+ // If we don't crash then we're OK
+
+ delete item;
+}
+
+void tst_qquickconnection::unknownSignals_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("basic") << "connection-unknownsignals.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\"";
+ QTest::newRow("parent") << "connection-unknownsignals-parent.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\"";
+ QTest::newRow("ignored") << "connection-unknownsignals-ignored.qml" << ""; // should be NO error
+ QTest::newRow("notarget") << "connection-unknownsignals-notarget.qml" << ""; // should be NO error
+}
+
+void tst_qquickconnection::unknownSignals()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, error);
+
+ QUrl url = testFileUrl(file);
+ if (!error.isEmpty()) {
+ QTest::ignoreMessage(QtWarningMsg, (url.toString() + error).toLatin1());
+ } else {
+ // QTest has no way to insist no message (i.e. fail)
+ }
+
+ QQmlEngine engine;
+ QQmlComponent c(&engine, url);
+ QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
+ QVERIFY(item != 0);
+
+ // check that connection is created (they are all runtime errors)
+ QQuickConnections *connections = item->findChild<QQuickConnections*>("connections");
+ QVERIFY(connections);
+
+ if (file == "connection-unknownsignals-ignored.qml")
+ QVERIFY(connections->ignoreUnknownSignals());
+
+ delete item;
+}
+
+void tst_qquickconnection::errors_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("no \"on\"") << "error-property.qml" << "Cannot assign to non-existent property \"fakeProperty\"";
+ QTest::newRow("3rd letter lowercase") << "error-property2.qml" << "Cannot assign to non-existent property \"onfakeProperty\"";
+ QTest::newRow("child object") << "error-object.qml" << "Connections: nested objects not allowed";
+ QTest::newRow("grouped object") << "error-syntax.qml" << "Connections: syntax error";
+}
+
+void tst_qquickconnection::errors()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, error);
+
+ QUrl url = testFileUrl(file);
+
+ QQmlEngine engine;
+ QQmlComponent c(&engine, url);
+ QVERIFY(c.isError() == true);
+ QList<QQmlError> errors = c.errors();
+ QVERIFY(errors.count() == 1);
+ QCOMPARE(errors.at(0).description(), error);
+}
+
+
+class MyTestModuleApi : public QObject
+{
+Q_OBJECT
+Q_PROPERTY(int intProp READ intProp WRITE setIntProp NOTIFY intPropChanged)
+
+public:
+ MyTestModuleApi(QObject *parent = 0) : QObject(parent), m_intProp(0), m_changeCount(0) {}
+ ~MyTestModuleApi() {}
+
+ Q_INVOKABLE int otherMethod(int val) { return val + 4; }
+
+ int intProp() const { return m_intProp; }
+ void setIntProp(int val)
+ {
+ if (++m_changeCount % 3 == 0) emit otherSignal();
+ m_intProp = val; emit intPropChanged();
+ }
+
+signals:
+ void intPropChanged();
+ void otherSignal();
+
+private:
+ int m_intProp;
+ int m_changeCount;
+};
+
+static QObject *module_api_factory(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(engine)
+ Q_UNUSED(scriptEngine)
+ MyTestModuleApi *api = new MyTestModuleApi();
+ return api;
+}
+
+// QTBUG-20937
+void tst_qquickconnection::moduleApiTarget()
+{
+ qmlRegisterModuleApi("MyTestModuleApi", 1, 0, module_api_factory);
+ QQmlComponent component(&engine, testFileUrl("moduleapi-target.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 0);
+ QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0);
+
+ QMetaObject::invokeMethod(object, "setModuleIntProp");
+ QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 1);
+ QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0);
+
+ QMetaObject::invokeMethod(object, "setModuleIntProp");
+ QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 2);
+ QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 0);
+
+ // the module API emits otherSignal every 3 times the int property changes.
+ QMetaObject::invokeMethod(object, "setModuleIntProp");
+ QCOMPARE(object->property("moduleIntPropChangedCount").toInt(), 3);
+ QCOMPARE(object->property("moduleOtherSignalCount").toInt(), 1);
+
+ delete object;
+}
+
+QTEST_MAIN(tst_qquickconnection)
+
+#include "tst_qquickconnection.moc"
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml b/tests/auto/qml/qquickfolderlistmodel/data/basic.qml
index 2c4977d08b..2c4977d08b 100644
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml
+++ b/tests/auto/qml/qquickfolderlistmodel/data/basic.qml
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml b/tests/auto/qml/qquickfolderlistmodel/data/dummy.qml
index 609638bec6..609638bec6 100644
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml
+++ b/tests/auto/qml/qquickfolderlistmodel/data/dummy.qml
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/data/resetFiltering.qml b/tests/auto/qml/qquickfolderlistmodel/data/resetFiltering.qml
index d9a8ec4535..d9a8ec4535 100644
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/data/resetFiltering.qml
+++ b/tests/auto/qml/qquickfolderlistmodel/data/resetFiltering.qml
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/data/resetfiltering/innerdir/test2.txt b/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/innerdir/test2.txt
index 97e64bb130..97e64bb130 100644
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/data/resetfiltering/innerdir/test2.txt
+++ b/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/innerdir/test2.txt
diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/data/resetfiltering/test.txt b/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test.txt
index 97e64bb130..97e64bb130 100644
--- a/tests/auto/declarative/qdeclarativefolderlistmodel/data/resetfiltering/test.txt
+++ b/tests/auto/qml/qquickfolderlistmodel/data/resetfiltering/test.txt
diff --git a/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro b/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro
new file mode 100644
index 0000000000..bdf4a45865
--- /dev/null
+++ b/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro
@@ -0,0 +1,14 @@
+CONFIG += testcase
+TARGET = tst_qquickfolderlistmodel
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickfolderlistmodel.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private testlib
diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
new file mode 100644
index 0000000000..a6d90cf688
--- /dev/null
+++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
@@ -0,0 +1,179 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qabstractitemmodel.h>
+#include <QDebug>
+#include "../../shared/util.h"
+
+// From qquickfolderlistmodel.h
+const int FileNameRole = Qt::UserRole+1;
+const int FilePathRole = Qt::UserRole+2;
+enum SortField { Unsorted, Name, Time, Size, Type };
+
+class tst_qquickfolderlistmodel : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickfolderlistmodel() : removeStart(0), removeEnd(0) {}
+
+public slots:
+ void removed(const QModelIndex &, int start, int end) {
+ removeStart = start;
+ removeEnd = end;
+ }
+
+private slots:
+ void basicProperties();
+ void resetFiltering();
+ void refresh();
+
+private:
+ void checkNoErrors(const QQmlComponent& component);
+ QQmlEngine engine;
+
+ int removeStart;
+ int removeEnd;
+};
+
+void tst_qquickfolderlistmodel::checkNoErrors(const QQmlComponent& component)
+{
+ // Wait until the component is ready
+ QTRY_VERIFY(component.isReady() || component.isError());
+
+ if (component.isError()) {
+ QList<QQmlError> errors = component.errors();
+ for (int ii = 0; ii < errors.count(); ++ii) {
+ const QQmlError &error = errors.at(ii);
+ QByteArray errorStr = QByteArray::number(error.line()) + ":" +
+ QByteArray::number(error.column()) + ":" +
+ error.description().toUtf8();
+ qWarning() << errorStr;
+ }
+ }
+ QVERIFY(!component.isError());
+}
+
+void tst_qquickfolderlistmodel::basicProperties()
+{
+ QQmlComponent component(&engine, testFileUrl("basic.qml"));
+ checkNoErrors(component);
+
+ QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
+ QVERIFY(flm != 0);
+
+ flm->setProperty("folder", dataDirectoryUrl());
+ QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh
+ QCOMPARE(flm->property("folder").toUrl(), dataDirectoryUrl());
+ QCOMPARE(flm->property("parentFolder").toUrl(), QUrl::fromLocalFile(QDir(directory()).canonicalPath()));
+ QCOMPARE(flm->property("sortField").toInt(), int(Name));
+ QCOMPARE(flm->property("nameFilters").toStringList(), QStringList() << "*.qml");
+ QCOMPARE(flm->property("sortReversed").toBool(), false);
+ QCOMPARE(flm->property("showDirs").toBool(), true);
+ QCOMPARE(flm->property("showDotAndDotDot").toBool(), false);
+ QCOMPARE(flm->property("showOnlyReadable").toBool(), false);
+ QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String("basic.qml"));
+ QCOMPARE(flm->data(flm->index(1),FileNameRole).toString(), QLatin1String("dummy.qml"));
+
+ flm->setProperty("folder",QUrl::fromLocalFile(""));
+ QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(""));
+}
+
+void tst_qquickfolderlistmodel::resetFiltering()
+{
+ // see QTBUG-17837
+ QQmlComponent component(&engine, testFileUrl("resetFiltering.qml"));
+ checkNoErrors(component);
+
+ QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
+ QVERIFY(flm != 0);
+
+ connect(flm, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
+ this, SLOT(removed(const QModelIndex&,int,int)));
+
+ flm->setProperty("folder", testFileUrl("resetfiltering"));
+ QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test.txt" visible
+ int count = flm->rowCount();
+ QCOMPARE(removeStart, 0);
+ QCOMPARE(removeEnd, count-1);
+
+ flm->setProperty("folder", testFileUrl("resetfiltering/innerdir"));
+ QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test2.txt" visible
+ count = flm->rowCount();
+ QCOMPARE(removeStart, 0);
+ QCOMPARE(removeEnd, count-1);
+
+ flm->setProperty("folder", testFileUrl("resetfiltering"));
+ QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test.txt" visible
+ count = flm->rowCount();
+ QCOMPARE(removeStart, 0);
+ QCOMPARE(removeEnd, count-1);
+}
+
+void tst_qquickfolderlistmodel::refresh()
+{
+ QQmlComponent component(&engine, testFileUrl("basic.qml"));
+ checkNoErrors(component);
+
+ QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
+ QVERIFY(flm != 0);
+
+ flm->setProperty("folder", dataDirectoryUrl());
+ QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh
+
+ int count = flm->rowCount();
+
+ connect(flm, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
+ this, SLOT(removed(const QModelIndex&,int,int)));
+
+ flm->setProperty("sortReversed", true);
+
+ QCOMPARE(removeStart, 0);
+ QCOMPARE(removeEnd, count-1);
+}
+
+QTEST_MAIN(tst_qquickfolderlistmodel)
+
+#include "tst_qquickfolderlistmodel.moc"
diff --git a/tests/auto/qml/qquicklistcompositor/qquicklistcompositor.pro b/tests/auto/qml/qquicklistcompositor/qquicklistcompositor.pro
new file mode 100644
index 0000000000..0e7a1af4c5
--- /dev/null
+++ b/tests/auto/qml/qquicklistcompositor/qquicklistcompositor.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qquicklistcompositor
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicklistcompositor.cpp
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/qml/qquicklistcompositor/tst_qquicklistcompositor.cpp b/tests/auto/qml/qquicklistcompositor/tst_qquicklistcompositor.cpp
new file mode 100644
index 0000000000..a5d66661f0
--- /dev/null
+++ b/tests/auto/qml/qquicklistcompositor/tst_qquicklistcompositor.cpp
@@ -0,0 +1,1637 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <private/qquicklistcompositor_p.h>
+
+template<typename T, int N> int lengthOf(const T (&)[N]) { return N; }
+
+typedef QQuickListCompositor C;
+
+struct Range
+{
+ Range() {}
+ Range(void *list, int index, int count, int flags)
+ : list(list), index(index), count(count), flags(flags) {}
+ void *list;
+ int index;
+ int count;
+ int flags;
+};
+
+template <typename T> struct Array
+{
+ Array() : array(0), count(0) {}
+ template<int N> Array(const T (&array)[N]) : array(array), count(N) {}
+
+ T operator [](int index) const { return array[index]; }
+
+ const T *array;
+ int count;
+};
+
+typedef Array<int> IndexArray;
+typedef Array<const void *> ListArray;
+
+typedef QVector<QQuickListCompositor::Remove> RemoveList;
+typedef QVector<QQuickListCompositor::Insert> InsertList;
+typedef QVector<QQuickListCompositor::Change> ChangeList;
+
+typedef QVector<Range> RangeList;
+
+Q_DECLARE_METATYPE(RangeList)
+Q_DECLARE_METATYPE(RemoveList)
+Q_DECLARE_METATYPE(InsertList)
+Q_DECLARE_METATYPE(ChangeList)
+Q_DECLARE_METATYPE(void *)
+Q_DECLARE_METATYPE(IndexArray)
+Q_DECLARE_METATYPE(ListArray)
+Q_DECLARE_METATYPE(C::Group)
+
+QT_BEGIN_NAMESPACE
+bool operator ==(const C::Change &left, const C::Change &right)
+{
+ return left.index[3] == right.index[3]
+ && left.index[2] == right.index[2]
+ && left.index[1] == right.index[1]
+ && left.index[0] == right.index[0]
+ && left.count == right.count
+ && left.groups() == right.groups()
+ && left.inCache() == right.inCache()
+ && (left.moveId == -1) == (right.moveId == -1);
+}
+QT_END_NAMESPACE
+
+static const C::Group Visible = C::Group(2);
+static const C::Group Selection = C::Group(3);
+
+class tst_qquicklistcompositor : public QObject
+{
+ Q_OBJECT
+
+ enum {
+ VisibleFlag = 0x04,
+ SelectionFlag = 0x08
+ };
+
+ void populateChange(
+ C::Change &change, int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId)
+ {
+ change.index[Selection] = sIndex;
+ change.index[Visible] = vIndex;
+ change.index[C::Default] = dIndex;
+ change.index[C::Cache] = cIndex;
+ change.count = count;
+ change.flags = flags;
+ change.moveId = moveId;
+ }
+
+ C::Remove Remove(
+ int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId = -1)
+ {
+ C::Remove remove;
+ populateChange(remove, sIndex, vIndex, dIndex, cIndex, count, flags, moveId);
+ return remove;
+ }
+
+ C::Insert Insert(
+ int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId = -1)
+ {
+ C::Insert insert;
+ populateChange(insert, sIndex, vIndex, dIndex, cIndex, count, flags, moveId);
+ return insert;
+ }
+
+ C::Change Change(
+ int sIndex, int vIndex, int dIndex, int cIndex, int count, int flags, int moveId = -1)
+ {
+ C::Change change;
+ populateChange(change, sIndex, vIndex, dIndex, cIndex, count, flags, moveId);
+ return change;
+ }
+
+private slots:
+ void find_data();
+ void find();
+ void findInsertPosition_data();
+ void findInsertPosition();
+ void insert();
+ void clearFlags_data();
+ void clearFlags();
+ void setFlags_data();
+ void setFlags();
+ void move_data();
+ void move();
+ void moveFromEnd();
+ void clear();
+ void listItemsInserted_data();
+ void listItemsInserted();
+ void listItemsRemoved_data();
+ void listItemsRemoved();
+ void listItemsMoved_data();
+ void listItemsMoved();
+ void listItemsChanged_data();
+ void listItemsChanged();
+};
+
+void tst_qquicklistcompositor::find_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<C::Group>("startGroup");
+ QTest::addColumn<int>("startIndex");
+ QTest::addColumn<C::Group>("group");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<int>("selectionIndex");
+ QTest::addColumn<int>("visibleIndex");
+ QTest::addColumn<int>("defaultIndex");
+ QTest::addColumn<int>("cacheIndex");
+ QTest::addColumn<uint>("rangeFlags");
+ QTest::addColumn<int>("rangeIndex");
+
+ int listA; void *a = &listA;
+
+ QTest::newRow("Start")
+ << (RangeList()
+ << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 1, 1, int(C::AppendFlag | C::PrependFlag | C::CacheFlag))
+ << Range(0, 0, 1, int(VisibleFlag| C::CacheFlag)))
+ << C::Cache << 2
+ << Selection << 0
+ << 0 << 0 << 0 << 0
+ << uint(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag) << 0;
+}
+
+void tst_qquicklistcompositor::find()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(C::Group, startGroup);
+ QFETCH(int, startIndex);
+ QFETCH(C::Group, group);
+ QFETCH(int, index);
+ QFETCH(int, cacheIndex);
+ QFETCH(int, defaultIndex);
+ QFETCH(int, visibleIndex);
+ QFETCH(int, selectionIndex);
+ QFETCH(uint, rangeFlags);
+ QFETCH(int, rangeIndex);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ compositor.find(startGroup, startIndex);
+
+ QQuickListCompositor::iterator it = compositor.find(group, index);
+ QCOMPARE(it.index[C::Cache], cacheIndex);
+ QCOMPARE(it.index[C::Default], defaultIndex);
+ QCOMPARE(it.index[Visible], visibleIndex);
+ QCOMPARE(it.index[Selection], selectionIndex);
+ QCOMPARE(it->flags, rangeFlags);
+ QCOMPARE(it->index, rangeIndex);
+}
+
+void tst_qquicklistcompositor::findInsertPosition_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<C::Group>("group");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<int>("selectionIndex");
+ QTest::addColumn<int>("visibleIndex");
+ QTest::addColumn<int>("defaultIndex");
+ QTest::addColumn<int>("cacheIndex");
+ QTest::addColumn<uint>("rangeFlags");
+ QTest::addColumn<int>("rangeIndex");
+
+ int listA; void *a = &listA;
+
+ QTest::newRow("Start")
+ << (RangeList()
+ << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 1, 1, int(C::AppendFlag | C::PrependFlag | C::CacheFlag))
+ << Range(0, 0, 1, int(VisibleFlag| C::CacheFlag)))
+ << Selection << 0
+ << 0 << 0 << 0 << 0
+ << uint(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag) << 0;
+ QTest::newRow("1")
+ << (RangeList()
+ << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 1, 1, int(C::AppendFlag | C::PrependFlag | C::CacheFlag))
+ << Range(0, 0, 1, int(VisibleFlag| C::CacheFlag)))
+ << Selection << 1
+ << 1 << 0 << 1 << 1
+ << uint(C::AppendFlag | C::PrependFlag | C::CacheFlag) << 1;
+}
+
+void tst_qquicklistcompositor::findInsertPosition()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(C::Group, group);
+ QFETCH(int, index);
+ QFETCH(int, cacheIndex);
+ QFETCH(int, defaultIndex);
+ QFETCH(int, visibleIndex);
+ QFETCH(int, selectionIndex);
+ QFETCH(uint, rangeFlags);
+ QFETCH(int, rangeIndex);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ QQuickListCompositor::insert_iterator it = compositor.findInsertPosition(group, index);
+ QCOMPARE(it.index[C::Cache], cacheIndex);
+ QCOMPARE(it.index[C::Default], defaultIndex);
+ QCOMPARE(it.index[Visible], visibleIndex);
+ QCOMPARE(it.index[Selection], selectionIndex);
+ QCOMPARE(it->flags, rangeFlags);
+ QCOMPARE(it->index, rangeIndex);
+}
+
+void tst_qquicklistcompositor::insert()
+{
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ C::iterator it;
+
+ int listA; int *a = &listA;
+ int listB; int *b = &listB;
+ int listC; int *c = &listC;
+
+ {
+ compositor.append(a, 0, 12, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
+ const int indexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
+ const int *lists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
+ QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
+ for (int i = 0; i < lengthOf(indexes); ++i) {
+ it = compositor.find(C::Default, i);
+ QCOMPARE(it.list<int>(), lists[i]);
+ if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
+ }
+ } {
+ compositor.append(b, 4, 4, C::DefaultFlag);
+ const int indexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7};
+ const int *lists[] = {a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b};
+ QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
+ for (int i = 0; i < lengthOf(indexes); ++i) {
+ it = compositor.find(C::Default, i);
+ QCOMPARE(it.list<int>(), lists[i]);
+ if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
+ }
+ } { // Insert at end.
+ compositor.insert(
+ C::Default, 16, c, 2, 2, C::DefaultFlag);
+ const int indexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
+ const int *lists[] = {a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
+ QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
+ for (int i = 0; i < lengthOf(indexes); ++i) {
+ it = compositor.find(C::Default, i);
+ QCOMPARE(it.list<int>(), lists[i]);
+ if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
+ }
+ } { // Insert at start
+ compositor.insert(
+ C::Default, 0, c, 6, 4, C::DefaultFlag);
+ const int indexes[] = {6,7,8,9,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
+ const int *lists[] = {c,c,c,c,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
+ QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
+ for (int i = 0; i < lengthOf(indexes); ++i) {
+ it = compositor.find(C::Default, i);
+ QCOMPARE(it.list<int>(), lists[i]);
+ if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
+ }
+ } { // Insert after static range.
+ compositor.insert(
+ C::Default, 4, b, 0, 8, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
+ const int indexes[] = {6,7,8,9,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
+ const int *lists[] = {c,c,c,c,b,b,b,b,b,b,b,b,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
+ QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
+ for (int i = 0; i < lengthOf(indexes); ++i) {
+ it = compositor.find(C::Default, i);
+ QCOMPARE(it.list<int>(), lists[i]);
+ if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
+ }
+ } { // Insert at end of dynamic range.
+ compositor.insert(
+ C::Default, 12, c, 0, 4, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
+ const int indexes[] = {6,7,8,9,0,1,2,3,4,5,6,7,0,1,2,3,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
+ const int *lists[] = {c,c,c,c,b,b,b,b,b,b,b,b,c,c,c,c,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
+ QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
+ for (int i = 0; i < lengthOf(indexes); ++i) {
+ it = compositor.find(C::Default, i);
+ QCOMPARE(it.list<int>(), lists[i]);
+ if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
+ }
+ } { // Insert into range.
+ compositor.insert(
+ C::Default, 8, c, 0, 4, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
+ const int indexes[] = {6,7,8,9,0,1,2,3,0,1,2,3,4,5,6,7,0,1,2,3,0,1,2,3,4,5,6,7,8,9,10,11,4,5,6,7,2,3};
+ const int *lists[] = {c,c,c,c,b,b,b,b,c,c,c,c,b,b,b,b,c,c,c,c,a,a,a,a,a,a,a,a,a,a, a, a,b,b,b,b,c,c};
+ QCOMPARE(compositor.count(C::Default), lengthOf(indexes));
+ for (int i = 0; i < lengthOf(indexes); ++i) {
+ it = compositor.find(C::Default, i);
+ QCOMPARE(it.list<int>(), lists[i]);
+ if (lists[i]) QCOMPARE(it.modelIndex(), indexes[i]);
+ }
+ }
+}
+
+void tst_qquicklistcompositor::clearFlags_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<C::Group>("group");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<int>("flags");
+ QTest::addColumn<RemoveList>("expectedRemoves");
+ QTest::addColumn<IndexArray>("cacheIndexes");
+ QTest::addColumn<ListArray>("cacheLists");
+ QTest::addColumn<IndexArray>("defaultIndexes");
+ QTest::addColumn<ListArray>("defaultLists");
+ QTest::addColumn<IndexArray>("visibleIndexes");
+ QTest::addColumn<ListArray>("visibleLists");
+ QTest::addColumn<IndexArray>("selectionIndexes");
+ QTest::addColumn<ListArray>("selectionLists");
+
+ int listA; void *a = &listA;
+
+ { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ static const int visibleIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *visibleLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ QTest::newRow("Default, 2, 2, Selection")
+ << (RangeList()
+ << Range(a, 0, 12, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(0, 0, 4, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
+ << C::Default << 2 << 2 << int(SelectionFlag)
+ << (RemoveList()
+ << Remove(2, 2, 2, 2, 2, SelectionFlag | C::CacheFlag))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray(selectionIndexes) << ListArray(selectionLists);
+ } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ QTest::newRow("Selection, 1, 2, Visible")
+ << (RangeList()
+ << Range(a, 0, 2, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 4, 8, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(0, 0, 4, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
+ << Selection << 1 << 2 << int(VisibleFlag)
+ << (RemoveList()
+ << Remove(1, 1, 1, 1, 1, VisibleFlag | C::CacheFlag)
+ << Remove(2, 3, 4, 4, 1, VisibleFlag | C::CacheFlag))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray(selectionIndexes) << ListArray(selectionLists);
+ } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0,0};
+ static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0};
+ static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,11,0,0,0};
+ static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0};
+ static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0};
+ static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0};
+ QTest::newRow("Default, 13, 1, Prepend | Selection | Visible | Default")
+ << (RangeList()
+ << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 1, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 4, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 5, 7, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(0, 0, 4, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
+ << C::Default << 13 << 1 << int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag)
+ << (RemoveList()
+ << Remove(11, 11, 13, 13, 1, SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray(selectionIndexes) << ListArray(selectionLists);
+ } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,0};
+ static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11,0,0,0};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a,0,0,0};
+ static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,11,0,0,0};
+ static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0};
+ static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,11,0,0,0};
+ static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a, a,0,0,0};
+ QTest::newRow("Cache, 11, 4, Cache")
+ << (RangeList()
+ << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 1, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 4, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 5, 7, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(0, 0, 1, int(C::CacheFlag))
+ << Range(0, 0, 3, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
+ << C::Cache << 11 << 4 << int(C::CacheFlag)
+ << (RemoveList())
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray(selectionIndexes) << ListArray(selectionLists);
+ } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,0};
+ static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,0};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a,0};
+ static const int visibleIndexes[] = {0,2,3,5,6,7,8,9,10,0};
+ static const void *visibleLists[] = {a,a,a,a,a,a,a,a, a,0};
+ static const int selectionIndexes[] = {0,1,4,5,6,7,8,9,10,0};
+ static const void *selectionLists[] = {a,a,a,a,a,a,a,a, a,0};
+ QTest::newRow("Default, 11, 3, Default | Visible | Selection")
+ << (RangeList()
+ << Range(a, 0, 1, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 1, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 2, 2, int(C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 4, 1, int(C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 5, 6, int(C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << Range(a, 11, 1, int(C::AppendFlag | C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag))
+ << Range(0, 0, 2, int(SelectionFlag | VisibleFlag | C::DefaultFlag))
+ << Range(0, 0, 1, int(SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)))
+ << C::Default << 11 << 3 << int(C::DefaultFlag | VisibleFlag| SelectionFlag)
+ << (RemoveList()
+ << Remove(9, 9, 11, 11, 1, SelectionFlag | VisibleFlag | C::DefaultFlag)
+ << Remove(9, 9, 11, 11, 2, SelectionFlag | VisibleFlag | C::DefaultFlag))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray(selectionIndexes) << ListArray(selectionLists);
+ }
+}
+
+void tst_qquicklistcompositor::clearFlags()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(C::Group, group);
+ QFETCH(int, index);
+ QFETCH(int, count);
+ QFETCH(int, flags);
+ QFETCH(RemoveList, expectedRemoves);
+ QFETCH(IndexArray, cacheIndexes);
+ QFETCH(ListArray, cacheLists);
+ QFETCH(IndexArray, defaultIndexes);
+ QFETCH(ListArray, defaultLists);
+ QFETCH(IndexArray, visibleIndexes);
+ QFETCH(ListArray, visibleLists);
+ QFETCH(IndexArray, selectionIndexes);
+ QFETCH(ListArray, selectionLists);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ QVector<C::Remove> removes;
+ compositor.clearFlags(group, index, count, flags, &removes);
+
+ QCOMPARE(removes, expectedRemoves);
+
+ QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
+ for (int i = 0; i < cacheIndexes.count; ++i) {
+ C::iterator it = compositor.find(C::Cache, i);
+ QCOMPARE(it->list, cacheLists[i]);
+ if (cacheLists[i])
+ QCOMPARE(it.modelIndex(), cacheIndexes[i]);
+ }
+ QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
+ for (int i = 0; i < defaultIndexes.count; ++i) {
+ C::iterator it = compositor.find(C::Default, i);
+ QCOMPARE(it->list, defaultLists[i]);
+ if (defaultLists[i])
+ QCOMPARE(it.modelIndex(), defaultIndexes[i]);
+ }
+ QCOMPARE(compositor.count(Visible), visibleIndexes.count);
+ for (int i = 0; i < visibleIndexes.count; ++i) {
+ C::iterator it = compositor.find(Visible, i);
+ QCOMPARE(it->list, visibleLists[i]);
+ if (visibleLists[i])
+ QCOMPARE(it.modelIndex(), visibleIndexes[i]);
+ }
+ QCOMPARE(compositor.count(Selection), selectionIndexes.count);
+ for (int i = 0; i < selectionIndexes.count; ++i) {
+ C::iterator it = compositor.find(Selection, i);
+ QCOMPARE(it->list, selectionLists[i]);
+ if (selectionLists[i])
+ QCOMPARE(it.modelIndex(), selectionIndexes[i]);
+ }
+}
+
+void tst_qquicklistcompositor::setFlags_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<C::Group>("group");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<int>("flags");
+ QTest::addColumn<InsertList>("expectedInserts");
+ QTest::addColumn<IndexArray>("cacheIndexes");
+ QTest::addColumn<ListArray>("cacheLists");
+ QTest::addColumn<IndexArray>("defaultIndexes");
+ QTest::addColumn<ListArray>("defaultLists");
+ QTest::addColumn<IndexArray>("visibleIndexes");
+ QTest::addColumn<ListArray>("visibleLists");
+ QTest::addColumn<IndexArray>("selectionIndexes");
+ QTest::addColumn<ListArray>("selectionLists");
+
+ int listA; void *a = &listA;
+
+ { static const int cacheIndexes[] = {0,0,0,0};
+ static const void *cacheLists[] = {0,0,0,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
+ QTest::newRow("Default, 2, 2, Default")
+ << (RangeList()
+ << Range(a, 0, 12, C::DefaultFlag)
+ << Range(0, 0, 4, C::CacheFlag))
+ << C::Default << 2 << 2 << int(C::DefaultFlag)
+ << (InsertList())
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray() << ListArray()
+ << IndexArray() << ListArray();
+ } { static const int cacheIndexes[] = {0,0,0,0};
+ static const void *cacheLists[] = {0,0,0,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
+ static const int visibleIndexes[] = {2,3};
+ static const void *visibleLists[] = {a,a};
+ QTest::newRow("Default, 2, 2, Visible")
+ << (RangeList()
+ << Range(a, 0, 12, C::DefaultFlag)
+ << Range(0, 0, 4, C::CacheFlag))
+ << C::Default << 2 << 2 << int(VisibleFlag)
+ << (InsertList()
+ << Insert(0, 0, 2, 0, 2, VisibleFlag))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray() << ListArray();
+ } { static const int cacheIndexes[] = {3,6,0,0,0,0};
+ static const void *cacheLists[] = {a,a,0,0,0,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
+ static const int visibleIndexes[] = {2,3,6,7};
+ static const void *visibleLists[] = {a,a,a,a};
+ static const int selectionIndexes[] = {3,6};
+ static const void *selectionLists[] = {a,a};
+ QTest::newRow("Visible, 1, 2, Selection | Cache")
+ << (RangeList()
+ << Range(a, 0, 2, C::DefaultFlag)
+ << Range(a, 2, 2, VisibleFlag | C::DefaultFlag)
+ << Range(a, 4, 2, C::DefaultFlag)
+ << Range(a, 6, 2, VisibleFlag | C::DefaultFlag)
+ << Range(a, 8, 4, C::DefaultFlag)
+ << Range(0, 0, 4, C::CacheFlag))
+ << Visible << 1 << 2 << int(SelectionFlag | C::CacheFlag)
+ << (InsertList()
+ << Insert(0, 1, 3, 0, 1, SelectionFlag | C::CacheFlag)
+ << Insert(1, 2, 6, 1, 1, SelectionFlag | C::CacheFlag))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray(selectionIndexes) << ListArray(selectionLists);
+ } { static const int cacheIndexes[] = {3,6,0,0,0,0};
+ static const void *cacheLists[] = {a,a,0,0,0,0};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
+ static const int visibleIndexes[] = {2,3,6,7,0};
+ static const void *visibleLists[] = {a,a,a,a,0};
+ static const int selectionIndexes[] = {3,6};
+ static const void *selectionLists[] = {a,a};
+ QTest::newRow("Cache, 3, 1, Visible")
+ << (RangeList()
+ << Range(a, 0, 2, C::DefaultFlag)
+ << Range(a, 2, 1, VisibleFlag | C::DefaultFlag)
+ << Range(a, 3, 1, SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 4, 2, C::DefaultFlag)
+ << Range(a, 6, 1, SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 7, 1, VisibleFlag | C::DefaultFlag)
+ << Range(a, 8, 4, C::DefaultFlag)
+ << Range(0, 0, 4, C::CacheFlag))
+ << C::Cache << 3 << 1 << int(VisibleFlag)
+ << (InsertList()
+ << Insert(2, 4, 12, 3, 1, VisibleFlag | C::CacheFlag))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray(selectionIndexes) << ListArray(selectionLists);
+ } { static const int cacheIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
+ static const void *cacheLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
+ static const int defaultIndexes[] = {0,1,2,3,4,5,6,7,8,9,10,11};
+ static const void *defaultLists[] = {a,a,a,a,a,a,a,a,a,a, a, a};
+ static const int visibleIndexes[] = {0,1,3,4,5,6,7,8,9,10,11};
+ static const void *visibleLists[] = {a,a,a,a,a,a,a,a,a, a, a};
+ static const int selectionIndexes[] = {2,6,7,8,9};
+ static const void *selectionLists[] = {a,a,a,a,a};
+ QTest::newRow("Existing flag, sparse selection")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 2, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 3, 3, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 6, 4, C::PrependFlag | SelectionFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a,10, 2, C::AppendFlag | C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag))
+ << C::Cache << 3 << 1 << int(VisibleFlag)
+ << InsertList()
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray(selectionIndexes) << ListArray(selectionLists);
+ }
+}
+
+void tst_qquicklistcompositor::setFlags()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(C::Group, group);
+ QFETCH(int, index);
+ QFETCH(int, count);
+ QFETCH(int, flags);
+ QFETCH(InsertList, expectedInserts);
+ QFETCH(IndexArray, cacheIndexes);
+ QFETCH(ListArray, cacheLists);
+ QFETCH(IndexArray, defaultIndexes);
+ QFETCH(ListArray, defaultLists);
+ QFETCH(IndexArray, visibleIndexes);
+ QFETCH(ListArray, visibleLists);
+ QFETCH(IndexArray, selectionIndexes);
+ QFETCH(ListArray, selectionLists);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ QVector<C::Insert> inserts;
+ compositor.setFlags(group, index, count, flags, &inserts);
+
+ QCOMPARE(inserts, expectedInserts);
+
+ QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
+ for (int i = 0; i < cacheIndexes.count; ++i) {
+ C::iterator it = compositor.find(C::Cache, i);
+ QCOMPARE(it->list, cacheLists[i]);
+ if (cacheLists[i])
+ QCOMPARE(it.modelIndex(), cacheIndexes[i]);
+ }
+ QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
+ for (int i = 0; i < defaultIndexes.count; ++i) {
+ C::iterator it = compositor.find(C::Default, i);
+ QCOMPARE(it->list, defaultLists[i]);
+ if (defaultLists[i])
+ QCOMPARE(it.modelIndex(), defaultIndexes[i]);
+ }
+ QCOMPARE(compositor.count(Visible), visibleIndexes.count);
+ for (int i = 0; i < visibleIndexes.count; ++i) {
+ C::iterator it = compositor.find(Visible, i);
+ QCOMPARE(it->list, visibleLists[i]);
+ if (visibleLists[i])
+ QCOMPARE(it.modelIndex(), visibleIndexes[i]);
+ }
+ QCOMPARE(compositor.count(Selection), selectionIndexes.count);
+ for (int i = 0; i < selectionIndexes.count; ++i) {
+ C::iterator it = compositor.find(Selection, i);
+ QCOMPARE(it->list, selectionLists[i]);
+ if (selectionLists[i])
+ QCOMPARE(it.modelIndex(), selectionIndexes[i]);
+ }
+}
+
+void tst_qquicklistcompositor::move_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<C::Group>("fromGroup");
+ QTest::addColumn<int>("from");
+ QTest::addColumn<C::Group>("toGroup");
+ QTest::addColumn<int>("to");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<RemoveList>("expectedRemoves");
+ QTest::addColumn<InsertList>("expectedInserts");
+ QTest::addColumn<IndexArray>("cacheIndexes");
+ QTest::addColumn<ListArray>("cacheLists");
+ QTest::addColumn<IndexArray>("defaultIndexes");
+ QTest::addColumn<ListArray>("defaultLists");
+ QTest::addColumn<IndexArray>("visibleIndexes");
+ QTest::addColumn<ListArray>("visibleLists");
+ QTest::addColumn<IndexArray>("selectionIndexes");
+ QTest::addColumn<ListArray>("selectionLists");
+
+ int listA; void *a = &listA;
+ int listB; void *b = &listB;
+ int listC; void *c = &listC;
+
+ { static const int cacheIndexes[] = {0,0,0,0,2,3};
+ static const void *cacheLists[] = {0,0,0,0,c,c};
+ static const int defaultIndexes[] = {0,0,1,2,3,4,5,0,1,2,3,4,5,1,2,3,0,1,2,3,4,5};
+ static const void *defaultLists[] = {0,a,a,a,a,a,a,b,b,b,b,b,b,0,0,0,c,c,c,c,c,c};
+ QTest::newRow("15, 0, 1")
+ << (RangeList()
+ << Range(a, 0, 6, C::DefaultFlag)
+ << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(0, 0, 4, C::DefaultFlag | C::CacheFlag)
+ << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
+ << C::Default << 15 << C::Default << 0 << 1
+ << (RemoveList()
+ << Remove(0, 0, 15, 3, 1, C::DefaultFlag | C::CacheFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 0, 0, 1, C::DefaultFlag | C::CacheFlag, 0))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray() << ListArray()
+ << IndexArray() << ListArray();
+ } { static const int cacheIndexes[] = {0,0,0,0,2,3};
+ static const void *cacheLists[] = {0,0,0,0,c,c};
+ static const int defaultIndexes[] = {0,1,0,1,2,3,4,5,0,1,2,3,4,5,2,3,0,1,2,3,4,5};
+ static const void *defaultLists[] = {0,0,a,a,a,a,a,a,b,b,b,b,b,b,0,0,c,c,c,c,c,c};
+ QTest::newRow("15, 1, 1")
+ << (RangeList()
+ << Range(0, 0, 1, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 0, 6, C::DefaultFlag)
+ << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(0, 0, 3, C::DefaultFlag | C::CacheFlag)
+ << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
+ << C::Default << 15 << C::Default << 1 << 1
+ << (RemoveList()
+ << Remove(0, 0, 15, 3, 1, C::DefaultFlag | C::CacheFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 1, 1, 1, C::DefaultFlag | C::CacheFlag, 0))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray() << ListArray()
+ << IndexArray() << ListArray();
+ } { static const int cacheIndexes[] = {0,0,0,0,2,3};
+ static const void *cacheLists[] = {0,0,0,0,c,c};
+ static const int defaultIndexes[] = {0,1,2,0,1,3,4,5,0,1,2,3,4,5,2,3,0,1,2,3,4,5};
+ static const void *defaultLists[] = {a,a,a,0,0,a,a,a,b,b,b,b,b,b,0,0,c,c,c,c,c,c};
+ QTest::newRow("0, 3, 2")
+ << (RangeList()
+ << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 0, 6, C::DefaultFlag)
+ << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
+ << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
+ << C::Default << 0 << C::Default << 3 << 2
+ << (RemoveList()
+ << Remove(0, 0, 0, 0, 2, C::DefaultFlag | C::CacheFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 3, 0, 2, C::DefaultFlag | C::CacheFlag, 0))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray() << ListArray()
+ << IndexArray() << ListArray();
+ } { static const int cacheIndexes[] = {0,0,0,0,2,3};
+ static const void *cacheLists[] = {0,0,0,0,c,c};
+ static const int defaultIndexes[] = {0,5,0,1,2,3,4,5,0,1,0,1,2,2,3,3,4,1,2,3,4,5};
+ static const void *defaultLists[] = {a,a,b,b,b,b,b,b,0,0,c,a,a,0,0,a,a,c,c,c,c,c};
+ QTest::newRow("7, 1, 10")
+ << (RangeList()
+ << Range(a, 0, 3, C::DefaultFlag)
+ << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 3, 3, C::DefaultFlag)
+ << Range(b, 0, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
+ << Range(c, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
+ << C::Default << 7 << C::Default << 1 << 10
+ << (RemoveList()
+ << Remove(0, 0, 7, 2, 1, C::DefaultFlag, 0)
+ << Remove(0, 0, 7, 2, 6, C::DefaultFlag, 1)
+ << Remove(0, 0, 7, 2, 2, C::DefaultFlag | C::CacheFlag, 2)
+ << Remove(0, 0, 7, 2, 1, C::DefaultFlag, 3))
+ << (InsertList()
+ << Insert(0, 0, 1, 0, 1, C::DefaultFlag, 0)
+ << Insert(0, 0, 2, 0, 6, C::DefaultFlag, 1)
+ << Insert(0, 0, 8, 0, 2, C::DefaultFlag | C::CacheFlag, 2)
+ << Insert(0, 0, 10, 2, 1, C::DefaultFlag, 3))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray() << ListArray()
+ << IndexArray() << ListArray();
+ } { static const int cacheIndexes[] = {0,0,0,0,3,2};
+ static const void *cacheLists[] = {0,0,0,0,c,c};
+ static const int defaultIndexes[] = {0,5,0,1,2,3,4,5,0,1,0,1,2,2,3,3,4,3,4,5,1,2};
+ static const void *defaultLists[] = {a,a,b,b,b,b,b,b,0,0,c,a,a,0,0,a,a,c,c,c,c,c};
+ QTest::newRow("17, 20, 2")
+ << (RangeList()
+ << Range(a, 0, 1, C::DefaultFlag)
+ << Range(a, 5, 1, C::DefaultFlag)
+ << Range(b, 0, 6, C::DefaultFlag)
+ << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
+ << Range(c, 0, 1, C::DefaultFlag)
+ << Range(a, 1, 2, C::DefaultFlag)
+ << Range(0, 0, 2, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 3, 2, C::DefaultFlag)
+ << Range(b, 0, 6, C::AppendFlag | C::PrependFlag)
+ << Range(c, 0, 1, C::PrependFlag)
+ << Range(c, 1, 1, C::PrependFlag | C::DefaultFlag)
+ << Range(c, 2, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(c, 4, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
+ << C::Default << 17 << C::Default << 20 << 2
+ << (RemoveList()
+ << Remove(0, 0, 17, 4, 1, C::DefaultFlag, 0)
+ << Remove(0, 0, 17, 4, 1, C::DefaultFlag | C::CacheFlag, 1))
+ << (InsertList()
+ << Insert(0, 0, 20, 5, 1, C::DefaultFlag, 0)
+ << Insert(0, 0, 21, 5, 1, C::DefaultFlag | C::CacheFlag, 1))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray() << ListArray()
+ << IndexArray() << ListArray();
+ } { static const int cacheIndexes[] = {8,9,10,4,11,0,1,2,3,5,6,7};
+ static const void *cacheLists[] = {a,a, a,a, a,a,a,a,a,a,a,a};
+ static const int defaultIndexes[] = {8,9,10,4,11,0,1,2,3,5,6,7};
+ static const void *defaultLists[] = {a,a, a,a, a,a,a,a,a,a,a,a};
+ static const int visibleIndexes[] = {8,9,10,4,11,0,1,2,3,5,6,7};
+ static const void *visibleLists[] = {a,a, a,a, a,a,a,a,a,a,a,a};
+ QTest::newRow("3, 4, 5")
+ << (RangeList()
+ << Range(a, 8, 4, VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 2, 1, C::PrependFlag)
+ << Range(a, 2, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 3, 5, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 8, 4, C::AppendFlag | C::PrependFlag))
+ << C::Default << 3 << C::Default << 4 << 5
+ << (RemoveList()
+ << Remove(0, 3, 3, 3, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 0)
+ << Remove(0, 3, 3, 3, 2, VisibleFlag | C::DefaultFlag | C::CacheFlag, 1)
+ << Remove(0, 3, 3, 3, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 2)
+ << Remove(0, 3, 3, 3, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 3))
+ << (InsertList()
+ << Insert(0, 4, 4, 4, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 0)
+ << Insert(0, 5, 5, 5, 2, VisibleFlag | C::DefaultFlag | C::CacheFlag, 1)
+ << Insert(0, 7, 7, 7, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 2)
+ << Insert(0, 8, 8, 8, 1, VisibleFlag | C::DefaultFlag | C::CacheFlag, 3))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray(visibleIndexes) << ListArray(visibleLists)
+ << IndexArray() << ListArray();
+ } { static const int cacheIndexes[] = {0,1};
+ static const void *cacheLists[] = {a,a};
+ static const int defaultIndexes[] = {0,1};
+ static const void *defaultLists[] = {a,a};
+ QTest::newRow("0, 1, 1")
+ << (RangeList()
+ << Range(a, 0, 1, C::PrependFlag)
+ << Range(a, 1, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 2, 0, C::AppendFlag | C::PrependFlag)
+ << Range(a, 0, 1, C::DefaultFlag | C::CacheFlag))
+ << C::Default << 0 << C::Default << 1 << 1
+ << (RemoveList()
+ << Remove(0, 0, 0, 0, 1, C::DefaultFlag | C::CacheFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 1, 1, 1, C::DefaultFlag | C::CacheFlag, 0))
+ << IndexArray(cacheIndexes) << ListArray(cacheLists)
+ << IndexArray(defaultIndexes) << ListArray(defaultLists)
+ << IndexArray() << ListArray()
+ << IndexArray() << ListArray();
+ }
+}
+
+void tst_qquicklistcompositor::move()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(C::Group, fromGroup);
+ QFETCH(int, from);
+ QFETCH(C::Group, toGroup);
+ QFETCH(int, to);
+ QFETCH(int, count);
+ QFETCH(RemoveList, expectedRemoves);
+ QFETCH(InsertList, expectedInserts);
+ QFETCH(IndexArray, cacheIndexes);
+ QFETCH(ListArray, cacheLists);
+ QFETCH(IndexArray, defaultIndexes);
+ QFETCH(ListArray, defaultLists);
+ QFETCH(IndexArray, visibleIndexes);
+ QFETCH(ListArray, visibleLists);
+ QFETCH(IndexArray, selectionIndexes);
+ QFETCH(ListArray, selectionLists);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ QVector<C::Remove> removes;
+ QVector<C::Insert> inserts;
+ compositor.move(fromGroup, from, toGroup, to, count, fromGroup, &removes, &inserts);
+
+ QCOMPARE(removes, expectedRemoves);
+ QCOMPARE(inserts, expectedInserts);
+
+ QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
+ for (int i = 0; i < cacheIndexes.count; ++i) {
+ C::iterator it = compositor.find(C::Cache, i);
+ QCOMPARE(it->list, cacheLists[i]);
+ if (cacheLists[i])
+ QCOMPARE(it.modelIndex(), cacheIndexes[i]);
+ }
+ QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
+ for (int i = 0; i < defaultIndexes.count; ++i) {
+ C::iterator it = compositor.find(C::Default, i);
+ QCOMPARE(it->list, defaultLists[i]);
+ if (defaultLists[i])
+ QCOMPARE(it.modelIndex(), defaultIndexes[i]);
+ }
+ QCOMPARE(compositor.count(Visible), visibleIndexes.count);
+ for (int i = 0; i < visibleIndexes.count; ++i) {
+ C::iterator it = compositor.find(Visible, i);
+ QCOMPARE(it->list, visibleLists[i]);
+ if (visibleLists[i])
+ QCOMPARE(it.modelIndex(), visibleIndexes[i]);
+ }
+ QCOMPARE(compositor.count(Selection), selectionIndexes.count);
+ for (int i = 0; i < selectionIndexes.count; ++i) {
+ C::iterator it = compositor.find(Selection, i);
+ QCOMPARE(it->list, selectionLists[i]);
+ if (selectionLists[i])
+ QCOMPARE(it.modelIndex(), selectionIndexes[i]);
+ }
+}
+
+void tst_qquicklistcompositor::moveFromEnd()
+{
+ int listA; void *a = &listA;
+
+ QQuickListCompositor compositor;
+ compositor.append(a, 0, 1, C::AppendFlag | C::PrependFlag | C::DefaultFlag);
+
+ // Moving an item anchors it to that position.
+ compositor.move(C::Default, 0, C::Default, 0, 1, C::Default);
+
+ // The existing item is anchored at 0 so prepending an item to the source will append it here
+ QVector<C::Insert> inserts;
+ compositor.listItemsInserted(a, 0, 1, &inserts);
+
+ QCOMPARE(inserts.count(), 1);
+ QCOMPARE(inserts.at(0).index[1], 1);
+ QCOMPARE(inserts.at(0).count, 1);
+
+ C::iterator it;
+ it = compositor.find(C::Default, 0);
+ QCOMPARE(it.modelIndex(), 1);
+
+ it = compositor.find(C::Default, 1);
+ QCOMPARE(it.modelIndex(), 0);
+}
+
+void tst_qquicklistcompositor::clear()
+{
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ int listA; void *a = &listA;
+ int listB; void *b = &listB;
+
+ compositor.append(a, 0, 8, C::AppendFlag | C::PrependFlag | VisibleFlag | C::DefaultFlag);
+ compositor.append(b, 4, 5, VisibleFlag | C::DefaultFlag);
+ compositor.append(0, 0, 3, VisibleFlag | C::DefaultFlag | C::CacheFlag);
+
+ QCOMPARE(compositor.count(C::Default), 16);
+ QCOMPARE(compositor.count(Visible), 16);
+ QCOMPARE(compositor.count(C::Cache), 3);
+
+ compositor.clear();
+ QCOMPARE(compositor.count(C::Default), 0);
+ QCOMPARE(compositor.count(Visible), 0);
+ QCOMPARE(compositor.count(C::Cache), 0);
+}
+
+void tst_qquicklistcompositor::listItemsInserted_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<void *>("list");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<InsertList>("expectedInserts");
+ QTest::addColumn<IndexArray>("cacheIndexes");
+ QTest::addColumn<IndexArray>("defaultIndexes");
+ QTest::addColumn<IndexArray>("visibleIndexes");
+ QTest::addColumn<IndexArray>("selectionIndexes");
+
+ int listA; void *a = &listA;
+ int listB; void *b = &listB;
+
+ { static const int defaultIndexes[] = {/*A*/0,1,5,6,/*B*/0,1,2,3,/*A*/2,3,4};
+ QTest::newRow("A 10, 2")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 2, 3, C::PrependFlag)
+ << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 2, 3, C::DefaultFlag))
+ << a << 10 << 2
+ << InsertList()
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int defaultIndexes[] = {/*A*/0,1,5,6,/*B*/0,1,2,3,/*A*/2,3,4};
+ QTest::newRow("B 10, 2")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 2, 3, C::PrependFlag)
+ << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 2, 3, C::DefaultFlag))
+ << b << 10 << 2
+ << InsertList()
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int defaultIndexes[] = {/*A*/0,1,2,3,7,8,/*B*/0,1,2,3,/*A*/4,5,6};
+ static const int visibleIndexes[] = {/*A*/0,1};
+ QTest::newRow("A 0, 2")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 2, 3, C::PrependFlag)
+ << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 2, 3, C::DefaultFlag))
+ << a << 0 << 2
+ << (InsertList()
+ << Insert(0, 0, 0, 0, 2, VisibleFlag | C::DefaultFlag))
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray(visibleIndexes)
+ << IndexArray();
+ } { static const int defaultIndexes[] = {/*A*/0,1,2,3,5,8,9,/*B*/0,1,2,3,/*A*/4,6,7};
+ static const int visibleIndexes[] = {/*A*/0,1,5};
+ QTest::newRow("A 5, 1")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag)
+ << Range(a, 2, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 4, 3, C::PrependFlag)
+ << Range(a, 7, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 4, 3, C::DefaultFlag))
+ << a << 5 << 1
+ << (InsertList()
+ << Insert(0, 2, 4, 0, 1, VisibleFlag | C::DefaultFlag))
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray(visibleIndexes)
+ << IndexArray();
+ } { static const int defaultIndexes[] = {/*A*/0,1,2,3,5,8,9,10,11,/*B*/0,1,2,3,/*A*/4,6,7};
+ static const int visibleIndexes[] = {/*A*/0,1,5,10,11};
+ QTest::newRow("A 10, 2")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | VisibleFlag | C::DefaultFlag)
+ << Range(a, 2, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 4, 1, C::PrependFlag)
+ << Range(a, 5, 1, C::PrependFlag | VisibleFlag | C::DefaultFlag)
+ << Range(a, 6, 2, C::PrependFlag)
+ << Range(a, 8, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 4, 1, C::DefaultFlag)
+ << Range(a, 6, 2, C::DefaultFlag))
+ << a << 10 << 2
+ << (InsertList()
+ << Insert(0, 3, 7, 0, 2, VisibleFlag | C::DefaultFlag))
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray(visibleIndexes)
+ << IndexArray();
+ } { static const int cacheIndexes[] = {/*A*/0,1,-1,-1,-1,2,5,6,7,8,9};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7,8,9};
+ static const int visibleIndexes[] = {/*A*/3,4};
+ QTest::newRow("Insert after remove")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 2, 3, C::CacheFlag)
+ << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
+ << a << 3 << 2
+ << (InsertList()
+ << Insert(0, 0, 3, 6, 2, VisibleFlag | C::DefaultFlag))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray(visibleIndexes)
+ << IndexArray();
+ } { static const int cacheIndexes[] = {/*A*/0,1,2,3,4};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6};
+ static const int visibleIndexes[] = {/*A*/0,1,2,3,4,5,6};
+ QTest::newRow("Consecutive appends")
+ << (RangeList()
+ << Range(a, 0, 5, C::PrependFlag | VisibleFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 5, 1, C::PrependFlag | VisibleFlag | C::DefaultFlag)
+ << Range(a, 6, 0, C::AppendFlag | VisibleFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
+ << a << 6 << 1
+ << (InsertList()
+ << Insert(0, 6, 6, 5, 1, VisibleFlag | C::DefaultFlag))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray(visibleIndexes)
+ << IndexArray();
+ }
+}
+
+void tst_qquicklistcompositor::listItemsInserted()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(void *, list);
+ QFETCH(int, index);
+ QFETCH(int, count);
+ QFETCH(InsertList, expectedInserts);
+ QFETCH(IndexArray, cacheIndexes);
+ QFETCH(IndexArray, defaultIndexes);
+ QFETCH(IndexArray, visibleIndexes);
+ QFETCH(IndexArray, selectionIndexes);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ QVector<C::Insert> inserts;
+ compositor.listItemsInserted(list, index, count, &inserts);
+
+ QCOMPARE(inserts, expectedInserts);
+
+ QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
+ for (int i = 0; i < cacheIndexes.count; ++i) {
+ if (cacheIndexes[i] != -1) {
+ QCOMPARE(compositor.find(C::Cache, i).modelIndex(), cacheIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
+ for (int i = 0; i < defaultIndexes.count; ++i) {
+ if (defaultIndexes[i] != -1) {
+ QCOMPARE(compositor.find(C::Default, i).modelIndex(), defaultIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(Visible), visibleIndexes.count);
+ for (int i = 0; i < visibleIndexes.count; ++i) {
+ if (visibleIndexes[i] != -1) {
+ QCOMPARE(compositor.find(Visible, i).modelIndex(), visibleIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(Selection), selectionIndexes.count);
+ for (int i = 0; i < selectionIndexes.count; ++i) {
+ if (selectionIndexes[i] != -1) {
+ QCOMPARE(compositor.find(Selection, i).modelIndex(), selectionIndexes[i]);
+ }
+ }
+}
+
+void tst_qquicklistcompositor::listItemsRemoved_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<void *>("list");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<RemoveList>("expectedRemoves");
+ QTest::addColumn<IndexArray>("cacheIndexes");
+ QTest::addColumn<IndexArray>("defaultIndexes");
+ QTest::addColumn<IndexArray>("visibleIndexes");
+ QTest::addColumn<IndexArray>("selectionIndexes");
+
+ int listA; void *a = &listA;
+ int listB; void *b = &listB;
+
+ { static const int defaultIndexes[] = {/*A*/0,1,5,6,/*B*/0,1,2,3,/*A*/2,3,4};
+ QTest::newRow("12, 2")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 2, 3, C::PrependFlag)
+ << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 2, 3, C::DefaultFlag))
+ << a << 12 << 2
+ << RemoveList()
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int defaultIndexes[] = {/*A*/0,1,/*B*/0,1,2,3,/*A*/2,3};
+ QTest::newRow("4, 3")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 2, 3, C::PrependFlag)
+ << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 2, 3, C::DefaultFlag))
+ << a << 4 << 3
+ << (RemoveList()
+ << Remove(0, 0, 2, 0, 2, C::DefaultFlag)
+ << Remove(0, 0, 8, 0, 1, C::DefaultFlag))
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int cacheIndexes[] = {/*A*/0,1,-1,-1,-1,2,-1,-1,3,4,5};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5};
+ QTest::newRow("Remove after remove")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 2, 3, C::CacheFlag)
+ << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
+ << a << 3 << 2
+ << (RemoveList()
+ << Remove(0, 0, 3, 6, 2, C::DefaultFlag | C::CacheFlag))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int cacheIndexes[] = {/*A*/-1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6};
+ QTest::newRow("Sparse remove")
+ << (RangeList()
+ << Range(a, 0, 2, C::CacheFlag)
+ << Range(a, 0, 1, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 0, 1, C::CacheFlag)
+ << Range(a, 1, 5, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 0, 1, C::CacheFlag)
+ << Range(a, 6, 2, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 0, 1, C::CacheFlag)
+ << Range(a, 8, 3, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 0, 1, C::CacheFlag)
+ << Range(a, 11, 1, C::DefaultFlag | C::CacheFlag)
+ << Range(a, 12, 5, C::DefaultFlag))
+ << a << 1 << 10
+ << (RemoveList()
+ << Remove(0, 0, 1, 4, 5, C::DefaultFlag | C::CacheFlag)
+ << Remove(0, 0, 1,10, 2, C::DefaultFlag | C::CacheFlag)
+ << Remove(0, 0, 1,13, 3, C::DefaultFlag | C::CacheFlag))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ }
+}
+
+void tst_qquicklistcompositor::listItemsRemoved()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(void *, list);
+ QFETCH(int, index);
+ QFETCH(int, count);
+ QFETCH(RemoveList, expectedRemoves);
+ QFETCH(IndexArray, cacheIndexes);
+ QFETCH(IndexArray, defaultIndexes);
+ QFETCH(IndexArray, visibleIndexes);
+ QFETCH(IndexArray, selectionIndexes);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ QVector<C::Remove> removes;
+ compositor.listItemsRemoved(list, index, count, &removes);
+
+ QCOMPARE(removes, expectedRemoves);
+
+ QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
+ for (int i = 0; i < cacheIndexes.count; ++i) {
+ if (cacheIndexes[i] != -1) {
+ QCOMPARE(compositor.find(C::Cache, i).modelIndex(), cacheIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
+ for (int i = 0; i < defaultIndexes.count; ++i) {
+ if (defaultIndexes[i] != -1) {
+ QCOMPARE(compositor.find(C::Default, i).modelIndex(), defaultIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(Visible), visibleIndexes.count);
+ for (int i = 0; i < visibleIndexes.count; ++i) {
+ if (visibleIndexes[i] != -1) {
+ QCOMPARE(compositor.find(Visible, i).modelIndex(), visibleIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(Selection), selectionIndexes.count);
+ for (int i = 0; i < selectionIndexes.count; ++i) {
+ if (selectionIndexes[i] != -1) {
+ QCOMPARE(compositor.find(Selection, i).modelIndex(), selectionIndexes[i]);
+ }
+ }
+}
+
+void tst_qquicklistcompositor::listItemsMoved_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<void *>("list");
+ QTest::addColumn<int>("from");
+ QTest::addColumn<int>("to");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<RemoveList>("expectedRemoves");
+ QTest::addColumn<InsertList>("expectedInserts");
+ QTest::addColumn<IndexArray>("cacheIndexes");
+ QTest::addColumn<IndexArray>("defaultIndexes");
+ QTest::addColumn<IndexArray>("visibleIndexes");
+ QTest::addColumn<IndexArray>("selectionIndexes");
+
+ int listA; void *a = &listA;
+ int listB; void *b = &listB;
+
+ { static const int defaultIndexes[] = {/*A*/0,2,3,4,/*B*/0,1,2,3,/*A*/5,6,1};
+ QTest::newRow("4, 1, 3")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 2, 3, C::PrependFlag)
+ << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 2, 3, C::DefaultFlag))
+ << a << 4 << 1 << 3
+ << (RemoveList()
+ << Remove(0, 0, 2, 0, 2, C::DefaultFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 1, 0, 2, C::DefaultFlag, 0))
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int defaultIndexes[] = {/*A*/1,2,3,6,/*B*/0,1,2,3,/*A*/4,5,0};
+ QTest::newRow("0, 6, 1")
+ << (RangeList()
+ << Range(a, 0, 1, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 1, 1, C::PrependFlag)
+ << Range(a, 2, 3, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 5, 2, C::PrependFlag)
+ << Range(a, 7, 0, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 5, 2, C::DefaultFlag)
+ << Range(a, 1, 1, C::DefaultFlag))
+ << a << 0 << 6 << 1
+ << (RemoveList()
+ << Remove(0, 0, 0, 0, 1, C::DefaultFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 3, 0, 1, C::DefaultFlag, 0))
+ << IndexArray()
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int cacheIndexes[] = {/*A*/0,1,3,4};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7};
+ QTest::newRow("6, 2, 1")
+ << (RangeList()
+ << Range(a, 0, 4, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 4, 4, C::AppendFlag | C::PrependFlag | C::DefaultFlag))
+ << a << 6 << 2 << 1
+ << (RemoveList()
+ << Remove(0, 0, 6, 4, 1, C::DefaultFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 2, 2, 1, C::DefaultFlag, 0))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int cacheIndexes[] = {/*A*/0,1,-1,-1,-1,2,3,4,5,6,7};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7};
+ QTest::newRow("Move after remove")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 2, 3, C::CacheFlag)
+ << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
+ << a << 4 << 2 << 2
+ << (RemoveList()
+ << Remove(0, 0, 4, 7, 2, C::DefaultFlag | C::CacheFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 2, 5, 2, C::DefaultFlag | C::CacheFlag, 0))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int cacheIndexes[] = {/*A*/0,1,5,6,7,8,9,10,11,12};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7,8,9,10,11,12};
+ QTest::newRow("Move merge tail")
+ << (RangeList()
+ << Range(a, 0, 10, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 10, 3, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 13, 0, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
+ << a << 8 << 0 << 5
+ << (RemoveList()
+ << Remove(0, 0, 8, 8, 2, C::DefaultFlag | C::CacheFlag, 0)
+ << Remove(0, 0, 8, 8, 3, C::DefaultFlag, 1))
+ << (InsertList()
+ << Insert(0, 0, 0, 0, 2, C::DefaultFlag | C::CacheFlag, 0)
+ << Insert(0, 0, 2, 2, 3, C::DefaultFlag, 1))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ } { static const int cacheIndexes[] = {/*A*/0,1,2,3};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3};
+ static const int selectionIndexes[] = {/*A*/3};
+ QTest::newRow("Move selection")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 2, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 3, 1, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
+ << a << 2 << 3 << 1
+ << (RemoveList()
+ << Remove(0, 0, 2, 2, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag, 0))
+ << (InsertList()
+ << Insert(0, 0, 3, 3, 1, C::PrependFlag | SelectionFlag | C::DefaultFlag | C::CacheFlag, 0))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray(selectionIndexes);
+ } { static const int cacheIndexes[] = {/*A*/0,1,2,3,4,5,8,9};
+ static const int defaultIndexes[] = {/*A*/0,1,2,3,4,5,6,7,8,9,10,11};
+ QTest::newRow("move mixed cached items")
+ << (RangeList()
+ << Range(a, 0, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 1, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 3, 7, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 10, 2, C::PrependFlag | C::DefaultFlag))
+ << a << 1 << 6 << 3
+ << (RemoveList()
+ << Remove(0, 0, 1, 1, 2, C::PrependFlag | C::DefaultFlag, 0)
+ << Remove(0, 0, 1, 1, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag, 1))
+ << (InsertList()
+ << Insert(0, 0, 6, 6, 2, C::PrependFlag | C::DefaultFlag, 0)
+ << Insert(0, 0, 8, 6, 1, C::PrependFlag | C::DefaultFlag | C::CacheFlag, 1))
+ << IndexArray(cacheIndexes)
+ << IndexArray(defaultIndexes)
+ << IndexArray()
+ << IndexArray();
+ }
+}
+
+void tst_qquicklistcompositor::listItemsMoved()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(void *, list);
+ QFETCH(int, from);
+ QFETCH(int, to);
+ QFETCH(int, count);
+ QFETCH(RemoveList, expectedRemoves);
+ QFETCH(InsertList, expectedInserts);
+ QFETCH(IndexArray, cacheIndexes);
+ QFETCH(IndexArray, defaultIndexes);
+ QFETCH(IndexArray, visibleIndexes);
+ QFETCH(IndexArray, selectionIndexes);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ QVector<C::Remove> removes;
+ QVector<C::Insert> inserts;
+ compositor.listItemsMoved(list, from, to, count, &removes, &inserts);
+
+ QCOMPARE(removes, expectedRemoves);
+ QCOMPARE(inserts, expectedInserts);
+
+ QCOMPARE(compositor.count(C::Cache), cacheIndexes.count);
+ for (int i = 0; i < cacheIndexes.count; ++i) {
+ if (cacheIndexes[i] != -1) {
+ QCOMPARE(compositor.find(C::Cache, i).modelIndex(), cacheIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(C::Default), defaultIndexes.count);
+ for (int i = 0; i < defaultIndexes.count; ++i) {
+ if (defaultIndexes[i] != -1) {
+ QCOMPARE(compositor.find(C::Default, i).modelIndex(), defaultIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(Visible), visibleIndexes.count);
+ for (int i = 0; i < visibleIndexes.count; ++i) {
+ if (visibleIndexes[i] != -1) {
+ QCOMPARE(compositor.find(Visible, i).modelIndex(), visibleIndexes[i]);
+ }
+ }
+ QCOMPARE(compositor.count(Selection), selectionIndexes.count);
+ for (int i = 0; i < selectionIndexes.count; ++i) {
+ if (selectionIndexes[i] != -1) {
+ QCOMPARE(compositor.find(Selection, i).modelIndex(), selectionIndexes[i]);
+ }
+ }
+}
+
+void tst_qquicklistcompositor::listItemsChanged_data()
+{
+ QTest::addColumn<RangeList>("ranges");
+ QTest::addColumn<void *>("list");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<ChangeList>("expectedChanges");
+
+ int listA; void *a = &listA;
+ int listB; void *b = &listB;
+
+ QTest::newRow("overlapping")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag)
+ << Range(a, 2, 3, C::PrependFlag)
+ << Range(a, 5, 2, C::AppendFlag | C::PrependFlag | C::DefaultFlag)
+ << Range(b, 0, 4, C::DefaultFlag)
+ << Range(a, 2, 3, C::DefaultFlag))
+ << a << 3 << 4
+ << (ChangeList()
+ << Change(0, 0, 2, 0, 2, C::DefaultFlag)
+ << Change(0, 0, 9, 0, 2, C::DefaultFlag));
+ QTest::newRow("Change after remove")
+ << (RangeList()
+ << Range(a, 0, 2, C::PrependFlag | C::DefaultFlag | C::CacheFlag)
+ << Range(a, 2, 3, C::CacheFlag)
+ << Range(a, 2, 6, C::AppendFlag | C::PrependFlag | C::DefaultFlag | C::CacheFlag))
+ << a << 3 << 2
+ << (ChangeList()
+ << Change(0, 0, 3, 6, 2, C::DefaultFlag | C::CacheFlag));
+}
+
+void tst_qquicklistcompositor::listItemsChanged()
+{
+ QFETCH(RangeList, ranges);
+ QFETCH(void *, list);
+ QFETCH(int, index);
+ QFETCH(int, count);
+ QFETCH(ChangeList, expectedChanges);
+
+ QQuickListCompositor compositor;
+ compositor.setGroupCount(4);
+ compositor.setDefaultGroups(VisibleFlag | C::DefaultFlag);
+
+ foreach (const Range &range, ranges)
+ compositor.append(range.list, range.index, range.count, range.flags);
+
+ QVector<C::Change> changes;
+ compositor.listItemsChanged(list, index, count, &changes);
+
+ QCOMPARE(changes, expectedChanges);
+}
+
+QTEST_MAIN(tst_qquicklistcompositor)
+
+#include "tst_qquicklistcompositor.moc"
+
+
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/enumerate.qml b/tests/auto/qml/qquicklistmodel/data/enumerate.qml
index f73d66b318..f73d66b318 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/enumerate.qml
+++ b/tests/auto/qml/qquicklistmodel/data/enumerate.qml
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/model.qml b/tests/auto/qml/qquicklistmodel/data/model.qml
index 5973ea8adf..5973ea8adf 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/model.qml
+++ b/tests/auto/qml/qquicklistmodel/data/model.qml
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml b/tests/auto/qml/qquicklistmodel/data/multipleroles.qml
index 4a331e2b3e..4a331e2b3e 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml
+++ b/tests/auto/qml/qquicklistmodel/data/multipleroles.qml
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/script.js b/tests/auto/qml/qquicklistmodel/data/script.js
index 66a4acb8a8..66a4acb8a8 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/script.js
+++ b/tests/auto/qml/qquicklistmodel/data/script.js
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/setmodelcachelist.qml b/tests/auto/qml/qquicklistmodel/data/setmodelcachelist.qml
index 58bf1ccd04..58bf1ccd04 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/setmodelcachelist.qml
+++ b/tests/auto/qml/qquicklistmodel/data/setmodelcachelist.qml
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/signalhandlers.qml b/tests/auto/qml/qquicklistmodel/data/signalhandlers.qml
index 750d99c5a3..750d99c5a3 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/signalhandlers.qml
+++ b/tests/auto/qml/qquicklistmodel/data/signalhandlers.qml
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/workerremoveelement.js b/tests/auto/qml/qquicklistmodel/data/workerremoveelement.js
index cb9dfa66aa..cb9dfa66aa 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/workerremoveelement.js
+++ b/tests/auto/qml/qquicklistmodel/data/workerremoveelement.js
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/workerremoveelement.qml b/tests/auto/qml/qquicklistmodel/data/workerremoveelement.qml
index e2361acf6b..e2361acf6b 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/workerremoveelement.qml
+++ b/tests/auto/qml/qquicklistmodel/data/workerremoveelement.qml
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/workerremovelist.js b/tests/auto/qml/qquicklistmodel/data/workerremovelist.js
index f63dd68839..f63dd68839 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/workerremovelist.js
+++ b/tests/auto/qml/qquicklistmodel/data/workerremovelist.js
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/workerremovelist.qml b/tests/auto/qml/qquicklistmodel/data/workerremovelist.qml
index bdb5e024d8..bdb5e024d8 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/workerremovelist.qml
+++ b/tests/auto/qml/qquicklistmodel/data/workerremovelist.qml
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/workersync.js b/tests/auto/qml/qquicklistmodel/data/workersync.js
index 9b8d8fa7f3..9b8d8fa7f3 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/workersync.js
+++ b/tests/auto/qml/qquicklistmodel/data/workersync.js
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/workersync.qml b/tests/auto/qml/qquicklistmodel/data/workersync.qml
index c21cd43e7e..c21cd43e7e 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/data/workersync.qml
+++ b/tests/auto/qml/qquicklistmodel/data/workersync.qml
diff --git a/tests/auto/qml/qquicklistmodel/qquicklistmodel.pro b/tests/auto/qml/qquicklistmodel/qquicklistmodel.pro
new file mode 100644
index 0000000000..9b96fa0659
--- /dev/null
+++ b/tests/auto/qml/qquicklistmodel/qquicklistmodel.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquicklistmodel
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicklistmodel.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp b/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp
new file mode 100644
index 0000000000..3fcce60bfb
--- /dev/null
+++ b/tests/auto/qml/qquicklistmodel/tst_qquicklistmodel.cpp
@@ -0,0 +1,1632 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQml/private/qqmlengine_p.h>
+#include <QtQml/private/qquicklistmodel_p.h>
+#include <QtQml/private/qqmlexpression_p.h>
+#include <QQmlComponent>
+
+#include <QtCore/qtimer.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qtranslator.h>
+#include <QSignalSpy>
+
+#include "../../shared/util.h"
+
+Q_DECLARE_METATYPE(QList<int>)
+Q_DECLARE_METATYPE(QList<QVariantHash>)
+
+#define RUNEVAL(object, string) \
+ QVERIFY(QMetaObject::invokeMethod(object, "runEval", Q_ARG(QVariant, QString(string))));
+
+inline QVariant runexpr(QQmlEngine *engine, const QString &str)
+{
+ QQmlExpression expr(engine->rootContext(), 0, str);
+ return expr.evaluate();
+}
+
+#define RUNEXPR(string) runexpr(&engine, QString(string))
+
+static bool isValidErrorMessage(const QString &msg, bool dynamicRoleTest)
+{
+ bool valid = true;
+
+ if (msg.isEmpty()) {
+ valid = false;
+ } else if (dynamicRoleTest) {
+ if (msg.contains("Can't assign to existing role") || msg.contains("Can't create role for unsupported data type"))
+ valid = false;
+ }
+
+ return valid;
+}
+
+class tst_qquicklistmodel : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquicklistmodel() {}
+
+private:
+ int roleFromName(const QQuickListModel *model, const QString &roleName);
+ QQuickItem *createWorkerTest(QQmlEngine *eng, QQmlComponent *component, QQuickListModel *model);
+ void waitForWorker(QQuickItem *item);
+
+ static bool compareVariantList(const QVariantList &testList, QVariant object);
+
+private slots:
+ void static_types();
+ void static_types_data();
+ void static_i18n();
+ void static_i18n_data();
+ void static_nestedElements();
+ void static_nestedElements_data();
+ void dynamic_data();
+ void dynamic();
+ void dynamic_worker_data();
+ void dynamic_worker();
+ void dynamic_worker_sync_data();
+ void dynamic_worker_sync();
+ void enumerate();
+ void error_data();
+ void error();
+ void syncError();
+ void get();
+ void set_data();
+ void set();
+ void get_data();
+ void get_worker();
+ void get_worker_data();
+ void get_nested();
+ void get_nested_data();
+ void crash_model_with_multiple_roles();
+ void set_model_cache();
+ void property_changes();
+ void property_changes_data();
+ void property_changes_worker();
+ void property_changes_worker_data();
+ void clear_data();
+ void clear();
+ void signal_handlers_data();
+ void signal_handlers();
+ void worker_sync_data();
+ void worker_sync();
+ void worker_remove_element_data();
+ void worker_remove_element();
+ void worker_remove_list_data();
+ void worker_remove_list();
+ void role_mode_data();
+ void role_mode();
+ void dynamic_role();
+ void dynamic_role_data();
+};
+
+bool tst_qquicklistmodel::compareVariantList(const QVariantList &testList, QVariant object)
+{
+ bool allOk = true;
+
+ QQuickListModel *model = qobject_cast<QQuickListModel *>(object.value<QObject *>());
+ if (model == 0)
+ return false;
+
+ if (model->count() != testList.count())
+ return false;
+
+ for (int i=0 ; i < testList.count() ; ++i) {
+ const QVariant &testVariant = testList.at(i);
+ if (testVariant.type() != QVariant::Map)
+ return false;
+ const QVariantMap &map = testVariant.toMap();
+
+ const QList<int> &roles = model->roles();
+
+ QVariantMap::const_iterator it = map.begin();
+ QVariantMap::const_iterator end = map.end();
+
+ while (it != end) {
+ const QString &testKey = it.key();
+ const QVariant &testData = it.value();
+
+ int roleIndex = -1;
+ for (int j=0 ; j < roles.count() ; ++j) {
+ if (model->toString(roles[j]).compare(testKey) == 0) {
+ roleIndex = j;
+ break;
+ }
+ }
+
+ if (roleIndex == -1)
+ return false;
+
+ const QVariant &modelData = model->data(i, roleIndex);
+
+ if (testData.type() == QVariant::List) {
+ const QVariantList &subList = testData.toList();
+ allOk = allOk && compareVariantList(subList, modelData);
+ } else {
+ allOk = allOk && (testData == modelData);
+ }
+
+ ++it;
+ }
+ }
+
+ return allOk;
+}
+
+int tst_qquicklistmodel::roleFromName(const QQuickListModel *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];
+ }
+ return -1;
+}
+
+QQuickItem *tst_qquicklistmodel::createWorkerTest(QQmlEngine *eng, QQmlComponent *component, QQuickListModel *model)
+{
+ QQuickItem *item = qobject_cast<QQuickItem*>(component->create());
+ QQmlEngine::setContextForObject(model, eng->rootContext());
+ if (item)
+ item->setProperty("model", qVariantFromValue(model));
+ return item;
+}
+
+void tst_qquicklistmodel::waitForWorker(QQuickItem *item)
+{
+ QEventLoop loop;
+ QTimer timer;
+ timer.setSingleShot(true);
+ connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+
+ QQmlProperty prop(item, "done");
+ QVERIFY(prop.isValid());
+ QVERIFY(prop.connectNotifySignal(&loop, SLOT(quit())));
+ timer.start(10000);
+ loop.exec();
+ QVERIFY(timer.isActive());
+}
+
+void tst_qquicklistmodel::static_types_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QVariant>("value");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("string")
+ << "ListElement { foo: \"bar\" }"
+ << QVariant(QString("bar"))
+ << QString();
+
+ QTest::newRow("real")
+ << "ListElement { foo: 10.5 }"
+ << QVariant(10.5)
+ << QString();
+
+ QTest::newRow("real0")
+ << "ListElement { foo: 0 }"
+ << QVariant(double(0))
+ << QString();
+
+ QTest::newRow("bool")
+ << "ListElement { foo: false }"
+ << QVariant(false)
+ << QString();
+
+ QTest::newRow("bool")
+ << "ListElement { foo: true }"
+ << QVariant(true)
+ << QString();
+
+ QTest::newRow("enum")
+ << "ListElement { foo: Text.AlignHCenter }"
+ << QVariant(double(QQuickText::AlignHCenter))
+ << QString();
+
+ QTest::newRow("Qt enum")
+ << "ListElement { foo: Qt.AlignBottom }"
+ << QVariant(double(Qt::AlignBottom))
+ << QString();
+
+ QTest::newRow("role error")
+ << "ListElement { foo: 1 } ListElement { foo: 'string' }"
+ << QVariant()
+ << QString("<Unknown File>: Can't assign to existing role 'foo' of different type [String -> Number]");
+
+ QTest::newRow("list type error")
+ << "ListElement { foo: 1 } ListElement { foo: ListElement { bar: 1 } }"
+ << QVariant()
+ << QString("<Unknown File>: Can't assign to existing role 'foo' of different type [List -> Number]");
+}
+
+void tst_qquicklistmodel::static_types()
+{
+ QFETCH(QString, qml);
+ QFETCH(QVariant, value);
+ QFETCH(QString, error);
+
+ qml = "import QtQuick 2.0\nItem { property variant test: model.get(0).foo; ListModel { id: model; " + qml + " } }";
+
+ if (!error.isEmpty()) {
+ QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
+ }
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(qml.toUtf8(),
+ QUrl::fromLocalFile(QString("dummy.qml")));
+
+ QVERIFY(!component.isError());
+
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+
+ if (error.isEmpty()) {
+ QVariant actual = obj->property("test");
+
+ QCOMPARE(actual, value);
+ QCOMPARE(actual.toString(), value.toString());
+ }
+
+ delete obj;
+}
+
+void tst_qquicklistmodel::static_i18n_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QVariant>("value");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("QT_TR_NOOP")
+ << QString::fromUtf8("ListElement { foo: QT_TR_NOOP(\"na\303\257ve\") }")
+ << QVariant(QString::fromUtf8("na\303\257ve"))
+ << QString();
+
+ QTest::newRow("QT_TRANSLATE_NOOP")
+ << "ListElement { foo: QT_TRANSLATE_NOOP(\"MyListModel\", \"hello\") }"
+ << QVariant(QString("hello"))
+ << QString();
+
+ QTest::newRow("QT_TRID_NOOP")
+ << QString::fromUtf8("ListElement { foo: QT_TRID_NOOP(\"qtn_1st_text\") }")
+ << QVariant(QString("qtn_1st_text"))
+ << QString();
+
+ QTest::newRow("QT_TR_NOOP extra param")
+ << QString::fromUtf8("ListElement { foo: QT_TR_NOOP(\"hello\",\"world\") }")
+ << QVariant(QString())
+ << QString("ListElement: improperly specified QT_TR_NOOP");
+
+ QTest::newRow("QT_TRANSLATE_NOOP missing params")
+ << "ListElement { foo: QT_TRANSLATE_NOOP() }"
+ << QVariant(QString())
+ << QString("ListElement: improperly specified QT_TRANSLATE_NOOP");
+
+ QTest::newRow("QT_TRID_NOOP missing param")
+ << QString::fromUtf8("ListElement { foo: QT_TRID_NOOP() }")
+ << QVariant(QString())
+ << QString("ListElement: improperly specified QT_TRID_NOOP");
+}
+
+void tst_qquicklistmodel::static_i18n()
+{
+ QFETCH(QString, qml);
+ QFETCH(QVariant, value);
+ QFETCH(QString, error);
+
+ qml = "import QtQuick 2.0\nItem { property variant test: model.get(0).foo; ListModel { id: model; " + qml + " } }";
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(qml.toUtf8(),
+ QUrl::fromLocalFile(QString("dummy.qml")));
+
+ if (!error.isEmpty()) {
+ QVERIFY(component.isError());
+ QCOMPARE(component.errors().at(0).description(), error);
+ return;
+ }
+
+ QVERIFY(!component.isError());
+
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+
+ QVariant actual = obj->property("test");
+
+ QCOMPARE(actual, value);
+ QCOMPARE(actual.toString(), value.toString());
+
+ delete obj;
+}
+
+void tst_qquicklistmodel::static_nestedElements()
+{
+ QFETCH(int, elementCount);
+
+ QStringList elements;
+ for (int i=0; i<elementCount; i++)
+ elements.append("ListElement { a: 1; b: 2 }");
+ QString elementsStr = elements.join(",\n") + "\n";
+
+ QString componentStr =
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ " property variant count: model.get(0).attributes.count\n"
+ " ListModel {\n"
+ " id: model\n"
+ " ListElement {\n"
+ " attributes: [\n";
+ componentStr += elementsStr.toUtf8().constData();
+ componentStr +=
+ " ]\n"
+ " }\n"
+ " }\n"
+ "}";
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toUtf8(), QUrl::fromLocalFile(""));
+
+ QObject *obj = component.create();
+ QVERIFY(obj != 0);
+
+ QVariant count = obj->property("count");
+ QCOMPARE(count.type(), QVariant::Int);
+ QCOMPARE(count.toInt(), elementCount);
+
+ delete obj;
+}
+
+void tst_qquicklistmodel::static_nestedElements_data()
+{
+ QTest::addColumn<int>("elementCount");
+
+ QTest::newRow("0 items") << 0;
+ QTest::newRow("1 item") << 1;
+ QTest::newRow("2 items") << 2;
+ QTest::newRow("many items") << 5;
+}
+
+void tst_qquicklistmodel::dynamic_data()
+{
+ QTest::addColumn<QString>("script");
+ QTest::addColumn<int>("result");
+ QTest::addColumn<QString>("warning");
+ QTest::addColumn<bool>("dynamicRoles");
+
+ for (int i=0 ; i < 2 ; ++i) {
+ bool dr = (i != 0);
+
+ // Simple flat model
+ QTest::newRow("count") << "count" << 0 << "" << dr;
+
+ QTest::newRow("get1") << "{get(0) === undefined}" << 1 << "" << dr;
+ QTest::newRow("get2") << "{get(-1) === undefined}" << 1 << "" << dr;
+ QTest::newRow("get3") << "{append({'foo':123});get(0) != undefined}" << 1 << "" << dr;
+ QTest::newRow("get4") << "{append({'foo':123});get(0).foo}" << 123 << "" << dr;
+ QTest::newRow("get-modify1") << "{append({'foo':123,'bar':456});get(0).foo = 333;get(0).foo}" << 333 << "" << dr;
+ QTest::newRow("get-modify2") << "{append({'z':1});append({'foo':123,'bar':456});get(1).bar = 999;get(1).bar}" << 999 << "" << dr;
+
+ QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << "" << dr;
+ QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << "" << dr;
+ QTest::newRow("append3a") << "{append({'foo':123});append({'foo':456});get(0).foo}" << 123 << "" << dr;
+ QTest::newRow("append3b") << "{append({'foo':123});append({'foo':456});get(1).foo}" << 456 << "" << dr;
+ QTest::newRow("append4a") << "{append(123)}" << 0 << "<Unknown File>: QML ListModel: append: value is not an object" << dr;
+ QTest::newRow("append4b") << "{append([{'foo':123},{'foo':456},{'foo':789}]);count}" << 3 << "" << dr;
+ QTest::newRow("append4c") << "{append([{'foo':123},{'foo':456},{'foo':789}]);get(1).foo}" << 456 << "" << dr;
+
+ QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << "" << dr;
+ QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << "" << dr;
+ QTest::newRow("clear3") << "{append({'foo':123});clear()}" << 0 << "" << dr;
+
+ QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << "" << dr;
+ QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << "" << dr;
+ QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << "" << dr;
+ QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << "" << dr;
+ QTest::newRow("remove3") << "{append({'foo':123});remove(0)}" << 0 << "" << dr;
+ QTest::newRow("remove3a") << "{append({'foo':123});remove(-1);count}" << 1 << "<Unknown File>: QML ListModel: remove: indices [-1 - 0] out of range [0 - 1]" << dr;
+ QTest::newRow("remove4a") << "{remove(0)}" << 0 << "<Unknown File>: QML ListModel: remove: indices [0 - 1] out of range [0 - 0]" << dr;
+ QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0);count}" << 0 << "<Unknown File>: QML ListModel: remove: indices [0 - 1] out of range [0 - 0]" << dr;
+ QTest::newRow("remove4c") << "{append({'foo':123});remove(1);count}" << 1 << "<Unknown File>: QML ListModel: remove: indices [1 - 2] out of range [0 - 1]" << dr;
+ QTest::newRow("remove5a") << "{append({'foo':123});append({'foo':456});remove(0,2);count}" << 0 << "" << dr;
+ QTest::newRow("remove5b") << "{append({'foo':123});append({'foo':456});remove(0,1);count}" << 1 << "" << dr;
+ QTest::newRow("remove5c") << "{append({'foo':123});append({'foo':456});remove(1,1);count}" << 1 << "" << dr;
+ QTest::newRow("remove5d") << "{append({'foo':123});append({'foo':456});remove(0,1);get(0).foo}" << 456 << "" << dr;
+ QTest::newRow("remove5e") << "{append({'foo':123});append({'foo':456});remove(1,1);get(0).foo}" << 123 << "" << dr;
+ QTest::newRow("remove5f") << "{append({'foo':123});append({'foo':456});append({'foo':789});remove(0,1);remove(1,1);get(0).foo}" << 456 << "" << dr;
+ QTest::newRow("remove6a") << "{remove();count}" << 0 << "<Unknown File>: QML ListModel: remove: incorrect number of arguments" << dr;
+ QTest::newRow("remove6b") << "{remove(1,2,3);count}" << 0 << "<Unknown File>: QML ListModel: remove: incorrect number of arguments" << dr;
+ QTest::newRow("remove7a") << "{append({'foo':123});remove(0,0);count}" << 1 << "<Unknown File>: QML ListModel: remove: indices [0 - 0] out of range [0 - 1]" << dr;
+ QTest::newRow("remove7b") << "{append({'foo':123});remove(0,-1);count}" << 1 << "<Unknown File>: QML ListModel: remove: indices [0 - -1] out of range [0 - 1]" << dr;
+
+ QTest::newRow("insert1") << "{insert(0,{'foo':123});count}" << 1 << "" << dr;
+ QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << "<Unknown File>: QML ListModel: insert: index 1 out of range" << dr;
+ QTest::newRow("insert3a") << "{append({'foo':123});insert(1,{'foo':456});count}" << 2 << "" << dr;
+ QTest::newRow("insert3b") << "{append({'foo':123});insert(1,{'foo':456});get(0).foo}" << 123 << "" << dr;
+ QTest::newRow("insert3c") << "{append({'foo':123});insert(1,{'foo':456});get(1).foo}" << 456 << "" << dr;
+ QTest::newRow("insert3d") << "{append({'foo':123});insert(0,{'foo':456});get(0).foo}" << 456 << "" << dr;
+ QTest::newRow("insert3e") << "{append({'foo':123});insert(0,{'foo':456});get(1).foo}" << 123 << "" << dr;
+ QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456});count}" << 1 << "<Unknown File>: QML ListModel: insert: index -1 out of range" << dr;
+ QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << "<Unknown File>: QML ListModel: insert: value is not an object" << dr;
+ QTest::newRow("insert5b") << "{insert(0,[{'foo':11},{'foo':22},{'foo':33}]);count}" << 3 << "" << dr;
+ QTest::newRow("insert5c") << "{insert(0,[{'foo':11},{'foo':22},{'foo':33}]);get(2).foo}" << 33 << "" << dr;
+
+ QTest::newRow("set1") << "{append({'foo':123});set(0,{'foo':456});count}" << 1 << "" << dr;
+ QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << "" << dr;
+ QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << "" << dr;
+ QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << "" << dr;
+ QTest::newRow("set4a") << "{set(0,{'foo':456});count}" << 1 << "" << dr;
+ QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << "<Unknown File>: QML ListModel: set: index -1 out of range" << dr;
+ QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123);count}" << 1 << "<Unknown File>: QML ListModel: set: value is not an object" << dr;
+ QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << "<Unknown File>: QML ListModel: set: value is not an object" << dr;
+ QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << "" << dr;
+
+ QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << "" << dr;
+ QTest::newRow("setprop2") << "{append({'foo':123});setProperty(0,'foo',456);get(0).foo}" << 456 << "" << dr;
+ QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).foo}" << 999 << "" << dr;
+ QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).bar}" << 456 << "" << dr;
+ QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << "<Unknown File>: QML ListModel: set: index 0 out of range" << dr;
+ QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << "<Unknown File>: QML ListModel: set: index -1 out of range" << dr;
+ QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456);count}" << 1 << "<Unknown File>: QML ListModel: set: index 1 out of range" << dr;
+ QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});setProperty(1,'bar',222);get(1).bar}" << 222 << "" << dr;
+
+ QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << "" << dr;
+ QTest::newRow("move1b") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(0).foo}" << 456 << "" << dr;
+ QTest::newRow("move1c") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(1).foo}" << 123 << "" << dr;
+ QTest::newRow("move1d") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(0).foo}" << 456 << "" << dr;
+ QTest::newRow("move1e") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(1).foo}" << 123 << "" << dr;
+ QTest::newRow("move2a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);count}" << 3 << "" << dr;
+ QTest::newRow("move2b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(0).foo}" << 789 << "" << dr;
+ QTest::newRow("move2c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(1).foo}" << 123 << "" << dr;
+ QTest::newRow("move2d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(2).foo}" << 456 << "" << dr;
+ QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range" << dr;
+ QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range" << dr;
+ QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range" << dr;
+ QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1);count}" << 3 << "<Unknown File>: QML ListModel: move: out of range" << dr;
+
+ QTest::newRow("large1") << "{append({'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8});get(0).h}" << 8 << "" << dr;
+
+ QTest::newRow("datatypes1") << "{append({'a':1});append({'a':'string'});}" << 0 << "<Unknown File>: Can't assign to existing role 'a' of different type [String -> Number]" << dr;
+
+ QTest::newRow("null") << "{append({'a':null});}" << 0 << "" << dr;
+ QTest::newRow("setNull") << "{append({'a':1});set(0, {'a':null});}" << 0 << "" << dr;
+ QTest::newRow("setString") << "{append({'a':'hello'});set(0, {'a':'world'});get(0).a == 'world'}" << 1 << "" << dr;
+ QTest::newRow("setInt") << "{append({'a':5});set(0, {'a':10});get(0).a}" << 10 << "" << dr;
+ QTest::newRow("setNumber") << "{append({'a':6});set(0, {'a':5.5});get(0).a < 5.6}" << 1 << "" << dr;
+ QTest::newRow("badType0") << "{append({'a':'hello'});set(0, {'a':1});}" << 0 << "<Unknown File>: Can't assign to existing role 'a' of different type [Number -> String]" << dr;
+ QTest::newRow("invalidInsert0") << "{insert(0);}" << 0 << "<Unknown File>: QML ListModel: insert: value is not an object" << dr;
+ QTest::newRow("invalidAppend0") << "{append();}" << 0 << "<Unknown File>: QML ListModel: append: value is not an object" << dr;
+ QTest::newRow("invalidInsert1") << "{insert(0, 34);}" << 0 << "<Unknown File>: QML ListModel: insert: value is not an object" << dr;
+ QTest::newRow("invalidAppend1") << "{append(37);}" << 0 << "<Unknown File>: QML ListModel: append: value is not an object" << dr;
+
+ // QObjects
+ QTest::newRow("qobject0") << "{append({'a':dummyItem0});}" << 0 << "" << dr;
+ QTest::newRow("qobject1") << "{append({'a':dummyItem0});set(0,{'a':dummyItem1});get(0).a == dummyItem1;}" << 1 << "" << dr;
+ QTest::newRow("qobject2") << "{append({'a':dummyItem0});get(0).a == dummyItem0;}" << 1 << "" << dr;
+ QTest::newRow("qobject3") << "{append({'a':dummyItem0});append({'b':1});}" << 0 << "" << dr;
+
+ // JS objects
+ QTest::newRow("js1") << "{append({'foo':{'prop':1}});count}" << 1 << "" << dr;
+ QTest::newRow("js2") << "{append({'foo':{'prop':27}});get(0).foo.prop}" << 27 << "" << dr;
+ QTest::newRow("js3") << "{append({'foo':{'prop':27}});append({'bar':1});count}" << 2 << "" << dr;
+ QTest::newRow("js4") << "{append({'foo':{'prop':27}});append({'bar':1});set(0, {'foo':{'prop':28}});get(0).foo.prop}" << 28 << "" << dr;
+ QTest::newRow("js5") << "{append({'foo':{'prop':27}});append({'bar':1});set(1, {'foo':{'prop':33}});get(1).foo.prop}" << 33 << "" << dr;
+ QTest::newRow("js6") << "{append({'foo':{'prop':27}});clear();count}" << 0 << "" << dr;
+ QTest::newRow("js7") << "{append({'foo':{'prop':27}});set(0, {'foo':null});count}" << 1 << "" << dr;
+ QTest::newRow("js8") << "{append({'foo':{'prop':27}});set(0, {'foo':{'prop2':31}});get(0).foo.prop2}" << 31 << "" << dr;
+
+ // Nested models
+ QTest::newRow("nested-append1") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});count}" << 1 << "" << dr;
+ QTest::newRow("nested-append2") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.get(1).a}" << 2 << "" << dr;
+ QTest::newRow("nested-append3") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.append({'a':4});get(0).bars.get(3).a}" << 4 << "" << dr;
+
+ QTest::newRow("nested-insert") << "{append({'foo':123});insert(0,{'bars':[{'a':1},{'b':2},{'c':3}]});get(0).bars.get(0).a}" << 1 << "" << dr;
+ QTest::newRow("nested-set") << "{append({'foo':[{'x':1}]});set(0,{'foo':[{'x':123}]});get(0).foo.get(0).x}" << 123 << "" << dr;
+
+ QTest::newRow("nested-count") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.count}" << 3 << "" << dr;
+ QTest::newRow("nested-clear") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.clear(); get(0).bars.count}" << 0 << "" << dr;
+ }
+}
+
+void tst_qquicklistmodel::dynamic()
+{
+ QFETCH(QString, script);
+ QFETCH(int, result);
+ QFETCH(QString, warning);
+ QFETCH(bool, dynamicRoles);
+
+ QQuickItem dummyItem0, dummyItem1;
+ QQmlEngine engine;
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine::setContextForObject(&model,engine.rootContext());
+ engine.rootContext()->setContextObject(&model);
+ engine.rootContext()->setContextProperty("dummyItem0", QVariant::fromValue(&dummyItem0));
+ engine.rootContext()->setContextProperty("dummyItem1", QVariant::fromValue(&dummyItem1));
+ QQmlExpression e(engine.rootContext(), &model, script);
+ if (isValidErrorMessage(warning, dynamicRoles))
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+
+ QSignalSpy spyCount(&model, SIGNAL(countChanged()));
+
+ int actual = e.evaluate().toInt();
+ if (e.hasError())
+ qDebug() << e.error(); // errors not expected
+
+ QCOMPARE(actual,result);
+
+ if (model.count() > 0)
+ QVERIFY(spyCount.count() > 0);
+}
+
+void tst_qquicklistmodel::dynamic_worker_data()
+{
+ dynamic_data();
+}
+
+void tst_qquicklistmodel::dynamic_worker()
+{
+ QFETCH(QString, script);
+ QFETCH(int, result);
+ QFETCH(QString, warning);
+ QFETCH(bool, dynamicRoles);
+
+ if (QByteArray(QTest::currentDataTag()).startsWith("qobject"))
+ return;
+
+ // This is same as dynamic() except it applies the test to a ListModel called
+ // from a WorkerScript.
+
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("model.qml"));
+ QQuickItem *item = createWorkerTest(&eng, &component, &model);
+ QVERIFY(item != 0);
+
+ QSignalSpy spyCount(&model, SIGNAL(countChanged()));
+
+ 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 (isValidErrorMessage(warning, dynamicRoles))
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+
+ QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
+ Q_ARG(QVariant, operations)));
+ waitForWorker(item);
+ QCOMPARE(QQmlProperty(item, "result").read().toInt(), result);
+
+ if (model.count() > 0)
+ QVERIFY(spyCount.count() > 0);
+
+ delete item;
+ qApp->processEvents();
+}
+
+void tst_qquicklistmodel::dynamic_worker_sync_data()
+{
+ dynamic_data();
+}
+
+void tst_qquicklistmodel::dynamic_worker_sync()
+{
+ QFETCH(QString, script);
+ QFETCH(int, result);
+ QFETCH(QString, warning);
+ QFETCH(bool, dynamicRoles);
+
+ if (QByteArray(QTest::currentDataTag()).startsWith("qobject"))
+ return;
+
+ // 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
+
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("model.qml"));
+ QQuickItem *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 (isValidErrorMessage(warning, dynamicRoles))
+ 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
+ QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
+ Q_ARG(QVariant, operations.mid(0, operations.length()-1))));
+ waitForWorker(item);
+
+ QQmlExpression e(eng.rootContext(), &model, operations.last().toString());
+ QCOMPARE(e.evaluate().toInt(), result);
+
+ delete item;
+ qApp->processEvents();
+}
+
+void tst_qquicklistmodel::enumerate()
+{
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("enumerate.qml"));
+ QVERIFY(!component.isError());
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item != 0);
+
+ QLatin1String expectedStrings[] = {
+ QLatin1String("val1=1Y"),
+ QLatin1String("val2=2Y"),
+ QLatin1String("val3=strY"),
+ QLatin1String("val4=falseN"),
+ QLatin1String("val5=trueY")
+ };
+
+ int expectedStringCount = sizeof(expectedStrings) / sizeof(expectedStrings[0]);
+
+ QStringList r = item->property("result").toString().split(":");
+
+ int matchCount = 0;
+ for (int i=0 ; i < expectedStringCount ; ++i) {
+ const QLatin1String &expectedString = expectedStrings[i];
+
+ QStringList::const_iterator it = r.begin();
+ QStringList::const_iterator end = r.end();
+
+ while (it != end) {
+ if (it->compare(expectedString) == 0) {
+ ++matchCount;
+ break;
+ }
+ ++it;
+ }
+ }
+
+ QVERIFY(matchCount == expectedStringCount);
+
+ delete item;
+}
+
+void tst_qquicklistmodel::error_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("id not allowed in ListElement")
+ << "import QtQuick 2.0\nListModel { ListElement { id: fred } }"
+ << "ListElement: cannot use reserved \"id\" property";
+
+ QTest::newRow("id allowed in ListModel")
+ << "import QtQuick 2.0\nListModel { id:model }"
+ << "";
+
+ QTest::newRow("random properties not allowed in ListModel")
+ << "import QtQuick 2.0\nListModel { foo:123 }"
+ << "ListModel: undefined property 'foo'";
+
+ QTest::newRow("random properties allowed in ListElement")
+ << "import QtQuick 2.0\nListModel { ListElement { foo:123 } }"
+ << "";
+
+ QTest::newRow("bindings not allowed in ListElement")
+ << "import QtQuick 2.0\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }"
+ << "ListElement: cannot use script for property value";
+
+ QTest::newRow("random object list properties allowed in ListElement")
+ << "import QtQuick 2.0\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }"
+ << "";
+
+ QTest::newRow("default properties not allowed in ListElement")
+ << "import QtQuick 2.0\nListModel { ListElement { Item { } } }"
+ << "ListElement: cannot contain nested elements";
+
+ QTest::newRow("QML elements not allowed in ListElement")
+ << "import QtQuick 2.0\nListModel { ListElement { a: Item { } } }"
+ << "ListElement: cannot contain nested elements";
+
+ QTest::newRow("qualified ListElement supported")
+ << "import QtQuick 2.0 as Foo\nFoo.ListModel { Foo.ListElement { a: 123 } }"
+ << "";
+
+ QTest::newRow("qualified ListElement required")
+ << "import QtQuick 2.0 as Foo\nFoo.ListModel { ListElement { a: 123 } }"
+ << "ListElement is not a type";
+
+ QTest::newRow("unknown qualified ListElement not allowed")
+ << "import QtQuick 2.0\nListModel { Foo.ListElement { a: 123 } }"
+ << "Foo.ListElement - Foo is not a namespace";
+}
+
+void tst_qquicklistmodel::error()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, error);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(qml.toUtf8(),
+ QUrl::fromLocalFile(QString("dummy.qml")));
+ if (error.isEmpty()) {
+ QVERIFY(!component.isError());
+ } else {
+ QVERIFY(component.isError());
+ QList<QQmlError> errors = component.errors();
+ QCOMPARE(errors.count(),1);
+ QCOMPARE(errors.at(0).description(),error);
+ }
+}
+
+void tst_qquicklistmodel::syncError()
+{
+ QString qml = "import QtQuick 2.0\nListModel { id: lm; Component.onCompleted: lm.sync() }";
+ QString error = "file:dummy.qml:2:1: QML ListModel: List sync() can only be called from a WorkerScript";
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(qml.toUtf8(),
+ QUrl::fromLocalFile(QString("dummy.qml")));
+ QTest::ignoreMessage(QtWarningMsg,error.toUtf8());
+ QObject *obj = component.create();
+ QVERIFY(obj);
+ delete obj;
+}
+
+/*
+ Test model changes from set() are available to the view
+*/
+void tst_qquicklistmodel::set_data()
+{
+ QTest::addColumn<bool>("dynamicRoles");
+
+ QTest::newRow("staticRoles") << false;
+ QTest::newRow("dynamicRoles") << true;
+}
+
+void tst_qquicklistmodel::set()
+{
+ QFETCH(bool, dynamicRoles);
+
+ QQmlEngine engine;
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine::setContextForObject(&model,engine.rootContext());
+ engine.rootContext()->setContextProperty("model", &model);
+
+ RUNEXPR("model.append({test:false})");
+ RUNEXPR("model.set(0, {test:true})");
+
+ QCOMPARE(RUNEXPR("model.get(0).test").toBool(), true); // triggers creation of model cache
+ QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(true));
+
+ RUNEXPR("model.set(0, {test:false})");
+ QCOMPARE(RUNEXPR("model.get(0).test").toBool(), false); // tests model cache is updated
+ QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(false));
+
+ QString warning = QString::fromLatin1("<Unknown File>: Can't create role for unsupported data type");
+ if (isValidErrorMessage(warning, dynamicRoles))
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+ QVariant invalidData = QColor();
+ model.setProperty(0, "test", invalidData);
+}
+
+/*
+ Test model changes on values returned by get() are available to the view
+*/
+void tst_qquicklistmodel::get()
+{
+ QFETCH(QString, expression);
+ QFETCH(int, index);
+ QFETCH(QString, roleName);
+ QFETCH(QVariant, roleValue);
+ QFETCH(bool, dynamicRoles);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "ListModel {}\n", QUrl());
+ QQuickListModel *model = qobject_cast<QQuickListModel*>(component.create());
+ model->setDynamicRoles(dynamicRoles);
+ engine.rootContext()->setContextProperty("model", model);
+
+ RUNEXPR("model.append({roleA: 100})");
+ RUNEXPR("model.append({roleA: 200, roleB: 400})");
+ RUNEXPR("model.append({roleA: 200, roleB: 400})");
+ RUNEXPR("model.append({roleC: {} })");
+ RUNEXPR("model.append({roleD: [ { a:1, b:2 }, { c: 3 } ] })");
+
+ QSignalSpy spy(model, SIGNAL(itemsChanged(int, int, QList<int>)));
+ QQmlExpression expr(engine.rootContext(), model, expression);
+ expr.evaluate();
+ QVERIFY(!expr.hasError());
+
+ int role = roleFromName(model, roleName);
+ QVERIFY(role >= 0);
+
+ if (roleValue.type() == QVariant::List) {
+ const QVariantList &list = roleValue.toList();
+ QVERIFY(compareVariantList(list, model->data(index, role)));
+ } 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
+ QCOMPARE(spyResult.at(2).value<QList<int> >(), (QList<int>() << role));
+
+ delete model;
+}
+
+void tst_qquicklistmodel::get_data()
+{
+ QTest::addColumn<QString>("expression");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<QString>("roleName");
+ QTest::addColumn<QVariant>("roleValue");
+ QTest::addColumn<bool>("dynamicRoles");
+
+ for (int i=0 ; i < 2 ; ++i) {
+ bool dr = (i != 0);
+
+ QTest::newRow("simple value") << "get(0).roleA = 500" << 0 << "roleA" << QVariant(500) << dr;
+ QTest::newRow("simple value 2") << "get(1).roleB = 500" << 1 << "roleB" << QVariant(500) << dr;
+
+ QVariantMap 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).roleD = [{'a': 50, 'b': 500}, {'c': 1000}]" << 2 << "roleD" << QVariant::fromValue(list) << dr;
+ }
+}
+
+void tst_qquicklistmodel::get_worker()
+{
+ QFETCH(QString, expression);
+ QFETCH(int, index);
+ QFETCH(QString, roleName);
+ QFETCH(QVariant, roleValue);
+ QFETCH(bool, dynamicRoles);
+
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("model.qml"));
+ QQuickItem *item = createWorkerTest(&eng, &component, &model);
+ QVERIFY(item != 0);
+
+ // Add some values like get() test
+ RUNEVAL(item, "model.append({roleA: 100})");
+ RUNEVAL(item, "model.append({roleA: 200, roleB: 400})");
+ RUNEVAL(item, "model.append({roleA: 200, roleB: 400})");
+ RUNEVAL(item, "model.append({roleC: {} })");
+ RUNEVAL(item, "model.append({roleD: [ { a:1, b:2 }, { c: 3 } ] })");
+
+ int role = roleFromName(&model, roleName);
+ QVERIFY(role >= 0);
+
+ 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) {
+ const QVariantList &list = roleValue.toList();
+ QVERIFY(compareVariantList(list, model.data(index, role)));
+ } 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_qquicklistmodel::get_worker_data()
+{
+ get_data();
+}
+
+/*
+ Test that the tests run in get() also work for nested list data
+*/
+void tst_qquicklistmodel::get_nested()
+{
+ QFETCH(QString, expression);
+ QFETCH(int, index);
+ QFETCH(QString, roleName);
+ QFETCH(QVariant, roleValue);
+ QFETCH(bool, dynamicRoles);
+
+ if (roleValue.type() == QVariant::Map)
+ return;
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "ListModel {}", QUrl());
+ QQuickListModel *model = qobject_cast<QQuickListModel*>(component.create());
+ model->setDynamicRoles(dynamicRoles);
+ QVERIFY(component.errorString().isEmpty());
+ QQuickListModel *childModel;
+ engine.rootContext()->setContextProperty("model", model);
+
+ RUNEXPR("model.append({ listRoleA: [\n"
+ "{ roleA: 100 },\n"
+ "{ roleA: 200, roleB: 400 },\n"
+ "{ roleA: 200, roleB: 400 }, \n"
+ "{ roleC: {} }, \n"
+ "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n"
+ "] })\n");
+
+ RUNEXPR("model.append({ listRoleA: [\n"
+ "{ roleA: 100 },\n"
+ "{ roleA: 200, roleB: 400 },\n"
+ "{ roleA: 200, roleB: 400 }, \n"
+ "{ roleC: {} }, \n"
+ "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n"
+ "],\n"
+ "listRoleB: [\n"
+ "{ roleA: 100 },\n"
+ "{ roleA: 200, roleB: 400 },\n"
+ "{ roleA: 200, roleB: 400 }, \n"
+ "{ roleC: {} }, \n"
+ "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n"
+ "],\n"
+ "listRoleC: [\n"
+ "{ roleA: 100 },\n"
+ "{ roleA: 200, roleB: 400 },\n"
+ "{ roleA: 200, roleB: 400 }, \n"
+ "{ roleC: {} }, \n"
+ "{ roleD: [ { a: 1, b:2 }, { c: 3 } ] } \n"
+ "] })\n");
+
+ // 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);
+ QVERIFY(outerListRole >= 0);
+
+ childModel = qobject_cast<QQuickListModel*>(model->data(outerListIndex, outerListRole).value<QObject*>());
+ QVERIFY(childModel);
+
+ QString extendedExpression = QString("get(%1).%2.%3").arg(outerListIndex).arg(outerListRoleName).arg(expression);
+ QQmlExpression expr(engine.rootContext(), model, extendedExpression);
+
+ QSignalSpy spy(childModel, SIGNAL(itemsChanged(int, int, QList<int>)));
+ expr.evaluate();
+ QVERIFY(!expr.hasError());
+
+ int role = roleFromName(childModel, roleName);
+ QVERIFY(role >= 0);
+ if (roleValue.type() == QVariant::List) {
+ QVERIFY(compareVariantList(roleValue.toList(), childModel->data(index, role)));
+ } else {
+ 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));
+ }
+
+ delete model;
+}
+
+void tst_qquicklistmodel::get_nested_data()
+{
+ get_data();
+}
+
+//QTBUG-13754
+void tst_qquicklistmodel::crash_model_with_multiple_roles()
+{
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("multipleroles.qml"));
+ QObject *rootItem = component.create();
+ QVERIFY(component.errorString().isEmpty());
+ QVERIFY(rootItem != 0);
+ QQuickListModel *model = rootItem->findChild<QQuickListModel*>("listModel");
+ QVERIFY(model != 0);
+
+ // used to cause a crash
+ model->setProperty(0, "black", true);
+
+ delete rootItem;
+}
+
+//QTBUG-15190
+void tst_qquicklistmodel::set_model_cache()
+{
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("setmodelcachelist.qml"));
+ QObject *model = component.create();
+ QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
+ QVERIFY(model != 0);
+ QVERIFY(model->property("ok").toBool());
+
+ delete model;
+}
+
+void tst_qquicklistmodel::property_changes()
+{
+ QFETCH(QString, script_setup);
+ QFETCH(QString, script_change);
+ QFETCH(QString, roleName);
+ QFETCH(int, listIndex);
+ QFETCH(bool, itemsChanged);
+ QFETCH(QString, testExpression);
+ QFETCH(bool, dynamicRoles);
+
+ QQmlEngine engine;
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine::setContextForObject(&model, engine.rootContext());
+ engine.rootContext()->setContextObject(&model);
+
+ QQmlExpression expr(engine.rootContext(), &model, script_setup);
+ expr.evaluate();
+ QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString()));
+
+ QString signalHandler = "on" + QString(roleName[0].toUpper()) + roleName.mid(1, roleName.length()) + "Changed:";
+ QString qml = "import QtQuick 2.0\n"
+ "Connections {\n"
+ "property bool gotSignal: false\n"
+ "target: model.get(" + QString::number(listIndex) + ")\n"
+ + signalHandler + " gotSignal = true\n"
+ "}\n";
+
+ QQmlComponent component(&engine);
+ component.setData(qml.toUtf8(), QUrl::fromLocalFile(""));
+ engine.rootContext()->setContextProperty("model", &model);
+ QObject *connectionsObject = component.create();
+ QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
+
+ QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList<int>)));
+
+ expr.setExpression(script_change);
+ expr.evaluate();
+ QVERIFY2(!expr.hasError(), QTest::toString(expr.error()));
+
+ // test the object returned by get() emits the correct signals
+ QCOMPARE(connectionsObject->property("gotSignal").toBool(), itemsChanged);
+
+ // test itemsChanged() is emitted correctly
+ if (itemsChanged) {
+ QCOMPARE(spyItemsChanged.count(), 1);
+ QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex);
+ QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1);
+ } else {
+ QCOMPARE(spyItemsChanged.count(), 0);
+ }
+
+ expr.setExpression(testExpression);
+ QCOMPARE(expr.evaluate().toBool(), true);
+
+ delete connectionsObject;
+}
+
+void tst_qquicklistmodel::property_changes_data()
+{
+ QTest::addColumn<QString>("script_setup");
+ QTest::addColumn<QString>("script_change");
+ QTest::addColumn<QString>("roleName");
+ QTest::addColumn<int>("listIndex");
+ QTest::addColumn<bool>("itemsChanged");
+ QTest::addColumn<QString>("testExpression");
+ QTest::addColumn<bool>("dynamicRoles");
+
+ for (int i=0 ; i < 2 ; ++i) {
+ bool dr = (i != 0);
+
+ QTest::newRow("set: plain") << "append({'a':123, 'b':456, 'c':789});" << "set(0,{'b':123});"
+ << "b" << 0 << true << "get(0).b == 123" << dr;
+ QTest::newRow("setProperty: plain") << "append({'a':123, 'b':456, 'c':789});" << "setProperty(0, 'b', 123);"
+ << "b" << 0 << true << "get(0).b == 123" << dr;
+
+ QTest::newRow("set: plain, no changes") << "append({'a':123, 'b':456, 'c':789});" << "set(0,{'b':456});"
+ << "b" << 0 << false << "get(0).b == 456" << dr;
+ QTest::newRow("setProperty: plain, no changes") << "append({'a':123, 'b':456, 'c':789});" << "setProperty(0, 'b', 456);"
+ << "b" << 0 << false << "get(0).b == 456" << dr;
+
+ QTest::newRow("set: inserted item")
+ << "{append({'a':123, 'b':456, 'c':789}); get(0); insert(0, {'a':0, 'b':0, 'c':0});}"
+ << "set(1, {'a':456});"
+ << "a" << 1 << true << "get(1).a == 456" << dr;
+ QTest::newRow("setProperty: inserted item")
+ << "{append({'a':123, 'b':456, 'c':789}); get(0); insert(0, {'a':0, 'b':0, 'c':0});}"
+ << "setProperty(1, 'a', 456);"
+ << "a" << 1 << true << "get(1).a == 456" << dr;
+ QTest::newRow("get: inserted item")
+ << "{append({'a':123, 'b':456, 'c':789}); get(0); insert(0, {'a':0, 'b':0, 'c':0});}"
+ << "get(1).a = 456;"
+ << "a" << 1 << true << "get(1).a == 456" << dr;
+ QTest::newRow("set: removed item")
+ << "{append({'a':0, 'b':0, 'c':0}); append({'a':123, 'b':456, 'c':789}); get(1); remove(0);}"
+ << "set(0, {'a':456});"
+ << "a" << 0 << true << "get(0).a == 456" << dr;
+ QTest::newRow("setProperty: removed item")
+ << "{append({'a':0, 'b':0, 'c':0}); append({'a':123, 'b':456, 'c':789}); get(1); remove(0);}"
+ << "setProperty(0, 'a', 456);"
+ << "a" << 0 << true << "get(0).a == 456" << dr;
+ QTest::newRow("get: removed item")
+ << "{append({'a':0, 'b':0, 'c':0}); append({'a':123, 'b':456, 'c':789}); get(1); remove(0);}"
+ << "get(0).a = 456;"
+ << "a" << 0 << true << "get(0).a == 456" << dr;
+
+ // Following tests only call set() since setProperty() only allows plain
+ // values, not lists, as the argument.
+ // Note that when a list is changed, itemsChanged() is currently always
+ // emitted regardless of whether it actually changed or not.
+
+ QTest::newRow("nested-set: list, new size") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2}]});"
+ << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2" << dr;
+
+ QTest::newRow("nested-set: list, empty -> non-empty") << "append({'a':123, 'b':[], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2},{'a':3}]});"
+ << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2 && get(0).b.get(2).a == 3" << dr;
+
+ QTest::newRow("nested-set: list, non-empty -> empty") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[]});"
+ << "b" << 0 << true << "get(0).b.count == 0" << dr;
+
+ QTest::newRow("nested-set: list, same size, different values") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':222},{'a':3}]});"
+ << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 222 && get(0).b.get(2).a == 3" << dr;
+
+ QTest::newRow("nested-set: list, no changes") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2},{'a':3}]});"
+ << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2 && get(0).b.get(2).a == 3" << dr;
+
+ QTest::newRow("nested-set: list, no changes, empty") << "append({'a':123, 'b':[], 'c':789});" << "set(0,{'b':[]});"
+ << "b" << 0 << true << "get(0).b.count == 0" << dr;
+ }
+}
+
+void tst_qquicklistmodel::property_changes_worker()
+{
+ QFETCH(QString, script_setup);
+ QFETCH(QString, script_change);
+ QFETCH(QString, roleName);
+ QFETCH(int, listIndex);
+ QFETCH(bool, itemsChanged);
+ QFETCH(bool, dynamicRoles);
+
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("model.qml"));
+ QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8());
+ QQuickItem *item = createWorkerTest(&engine, &component, &model);
+ QVERIFY(item != 0);
+
+ QQmlExpression expr(engine.rootContext(), &model, script_setup);
+ expr.evaluate();
+ QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString()));
+
+ QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList<int>)));
+
+ QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
+ Q_ARG(QVariant, QStringList(script_change))));
+ waitForWorker(item);
+
+ // test itemsChanged() is emitted correctly
+ if (itemsChanged) {
+ QCOMPARE(spyItemsChanged.count(), 1);
+ QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex);
+ QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1);
+ } else {
+ QCOMPARE(spyItemsChanged.count(), 0);
+ }
+
+ delete item;
+ qApp->processEvents();
+}
+
+void tst_qquicklistmodel::property_changes_worker_data()
+{
+ property_changes_data();
+}
+
+void tst_qquicklistmodel::clear_data()
+{
+ QTest::addColumn<bool>("dynamicRoles");
+
+ QTest::newRow("staticRoles") << false;
+ QTest::newRow("dynamicRoles") << true;
+}
+
+void tst_qquicklistmodel::clear()
+{
+ QFETCH(bool, dynamicRoles);
+
+ QQmlEngine engine;
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine::setContextForObject(&model, engine.rootContext());
+ engine.rootContext()->setContextProperty("model", &model);
+
+ model.clear();
+ QCOMPARE(model.count(), 0);
+
+ RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})");
+ QCOMPARE(model.count(), 1);
+
+ model.clear();
+ QCOMPARE(model.count(), 0);
+
+ RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})");
+ RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})");
+ QCOMPARE(model.count(), 2);
+
+ model.clear();
+ QCOMPARE(model.count(), 0);
+
+ // clearing does not remove the roles
+ RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\", propertyC: \"value c\"})");
+ QList<int> roles = model.roles();
+ model.clear();
+ QCOMPARE(model.count(), 0);
+ QCOMPARE(model.roles(), roles);
+ QCOMPARE(model.toString(roles[0]), QString("propertyA"));
+ QCOMPARE(model.toString(roles[1]), QString("propertyB"));
+ QCOMPARE(model.toString(roles[2]), QString("propertyC"));
+}
+
+void tst_qquicklistmodel::signal_handlers_data()
+{
+ QTest::addColumn<bool>("dynamicRoles");
+
+ QTest::newRow("staticRoles") << false;
+ QTest::newRow("dynamicRoles") << true;
+}
+
+void tst_qquicklistmodel::signal_handlers()
+{
+ QFETCH(bool, dynamicRoles);
+
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("signalhandlers.qml"));
+ QObject *model = component.create();
+ QQuickListModel *lm = qobject_cast<QQuickListModel *>(model);
+ QVERIFY(lm != 0);
+ lm->setDynamicRoles(dynamicRoles);
+ QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
+ QVERIFY(model != 0);
+ QVERIFY(model->property("ok").toBool());
+
+ delete model;
+}
+
+void tst_qquicklistmodel::worker_sync_data()
+{
+ QTest::addColumn<bool>("dynamicRoles");
+
+ QTest::newRow("staticRoles") << false;
+ QTest::newRow("dynamicRoles") << true;
+}
+
+void tst_qquicklistmodel::worker_sync()
+{
+ QFETCH(bool, dynamicRoles);
+
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("workersync.qml"));
+ QQuickItem *item = createWorkerTest(&eng, &component, &model);
+ QVERIFY(item != 0);
+
+ QVERIFY(model.count() == 0);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "addItem0"));
+
+ QVERIFY(model.count() == 2);
+ QVariant childData = model.data(0, 0);
+ QQuickListModel *childModel = qobject_cast<QQuickListModel *>(childData.value<QObject *>());
+ QVERIFY(childModel);
+ QVERIFY(childModel->count() == 1);
+
+ QSignalSpy spyModelInserted(&model, SIGNAL(itemsInserted(int,int)));
+ QSignalSpy spyChildInserted(childModel, SIGNAL(itemsInserted(int,int)));
+
+ QVERIFY(QMetaObject::invokeMethod(item, "addItemViaWorker"));
+ waitForWorker(item);
+
+ QVERIFY(model.count() == 2);
+ QVERIFY(childModel->count() == 1);
+ QVERIFY(spyModelInserted.count() == 0);
+ QVERIFY(spyChildInserted.count() == 0);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
+ waitForWorker(item);
+
+ QVERIFY(model.count() == 2);
+ QVERIFY(childModel->count() == 2);
+ QVERIFY(spyModelInserted.count() == 0);
+ QVERIFY(spyChildInserted.count() == 1);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "addItemViaWorker"));
+ waitForWorker(item);
+
+ QVERIFY(model.count() == 2);
+ QVERIFY(childModel->count() == 2);
+ QVERIFY(spyModelInserted.count() == 0);
+ QVERIFY(spyChildInserted.count() == 1);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
+ waitForWorker(item);
+
+ QVERIFY(model.count() == 2);
+ QVERIFY(childModel->count() == 3);
+ QVERIFY(spyModelInserted.count() == 0);
+ QVERIFY(spyChildInserted.count() == 2);
+
+ delete item;
+ qApp->processEvents();
+}
+
+void tst_qquicklistmodel::worker_remove_element_data()
+{
+ worker_sync_data();
+}
+
+void tst_qquicklistmodel::worker_remove_element()
+{
+ QFETCH(bool, dynamicRoles);
+
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("workerremoveelement.qml"));
+ QQuickItem *item = createWorkerTest(&eng, &component, &model);
+ QVERIFY(item != 0);
+
+ QSignalSpy spyModelRemoved(&model, SIGNAL(itemsRemoved(int,int)));
+
+ QVERIFY(model.count() == 0);
+ QVERIFY(spyModelRemoved.count() == 0);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "addItem"));
+
+ QVERIFY(model.count() == 1);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "removeItemViaWorker"));
+ waitForWorker(item);
+
+ QVERIFY(model.count() == 1);
+ QVERIFY(spyModelRemoved.count() == 0);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
+ waitForWorker(item);
+
+ QVERIFY(model.count() == 0);
+ QVERIFY(spyModelRemoved.count() == 1);
+
+ delete item;
+ qApp->processEvents();
+
+ {
+ //don't crash if model was deleted earlier
+ QQuickListModel* model = new QQuickListModel;
+ model->setDynamicRoles(dynamicRoles);
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("workerremoveelement.qml"));
+ QQuickItem *item = createWorkerTest(&eng, &component, model);
+ QVERIFY(item != 0);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "addItem"));
+
+ QVERIFY(model->count() == 1);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "removeItemViaWorker"));
+ QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
+ delete model;
+ qApp->processEvents(); //must not crash here
+ waitForWorker(item);
+
+ delete item;
+ }
+}
+
+void tst_qquicklistmodel::worker_remove_list_data()
+{
+ worker_sync_data();
+}
+
+void tst_qquicklistmodel::worker_remove_list()
+{
+ QFETCH(bool, dynamicRoles);
+
+ QQuickListModel model;
+ model.setDynamicRoles(dynamicRoles);
+ QQmlEngine eng;
+ QQmlComponent component(&eng, testFileUrl("workerremovelist.qml"));
+ QQuickItem *item = createWorkerTest(&eng, &component, &model);
+ QVERIFY(item != 0);
+
+ QSignalSpy spyModelRemoved(&model, SIGNAL(itemsRemoved(int,int)));
+
+ QVERIFY(model.count() == 0);
+ QVERIFY(spyModelRemoved.count() == 0);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "addList"));
+
+ QVERIFY(model.count() == 1);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "removeListViaWorker"));
+ waitForWorker(item);
+
+ QVERIFY(model.count() == 1);
+ QVERIFY(spyModelRemoved.count() == 0);
+
+ QVERIFY(QMetaObject::invokeMethod(item, "doSync"));
+ waitForWorker(item);
+
+ QVERIFY(model.count() == 0);
+ QVERIFY(spyModelRemoved.count() == 1);
+
+ delete item;
+ qApp->processEvents();
+}
+
+void tst_qquicklistmodel::role_mode_data()
+{
+ QTest::addColumn<QString>("script");
+ QTest::addColumn<int>("result");
+ QTest::addColumn<QString>("warning");
+
+ QTest::newRow("default0") << "{dynamicRoles}" << 0 << "";
+ QTest::newRow("default1") << "{append({'a':1});dynamicRoles}" << 0 << "";
+
+ QTest::newRow("enableDynamic0") << "{dynamicRoles=true;dynamicRoles}" << 1 << "";
+ QTest::newRow("enableDynamic1") << "{append({'a':1});dynamicRoles=true;dynamicRoles}" << 0 << "<Unknown File>: QML ListModel: unable to enable dynamic roles as this model is not empty!";
+ QTest::newRow("enableDynamic2") << "{dynamicRoles=true;append({'a':1});dynamicRoles=false;dynamicRoles}" << 1 << "<Unknown File>: QML ListModel: unable to enable static roles as this model is not empty!";
+}
+
+void tst_qquicklistmodel::role_mode()
+{
+ QFETCH(QString, script);
+ QFETCH(int, result);
+ QFETCH(QString, warning);
+
+ QQmlEngine engine;
+ QQuickListModel model;
+ QQmlEngine::setContextForObject(&model,engine.rootContext());
+ engine.rootContext()->setContextObject(&model);
+ QQmlExpression e(engine.rootContext(), &model, script);
+ if (!warning.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+
+ int actual = e.evaluate().toInt();
+ if (e.hasError())
+ qDebug() << e.error(); // errors not expected
+
+ QCOMPARE(actual,result);
+}
+
+void tst_qquicklistmodel::dynamic_role_data()
+{
+ QTest::addColumn<QString>("preamble");
+ QTest::addColumn<QString>("script");
+ QTest::addColumn<int>("result");
+
+ QTest::newRow("sync1") << "{append({'a':[{'b':1},{'b':2}]})}" << "{get(0).a = 'string';count}" << 1;
+}
+
+void tst_qquicklistmodel::dynamic_role()
+{
+ QFETCH(QString, preamble);
+ QFETCH(QString, script);
+ QFETCH(int, result);
+
+ QQuickListModel model;
+ model.setDynamicRoles(true);
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("model.qml"));
+ QQuickItem *item = createWorkerTest(&engine, &component, &model);
+ QVERIFY(item != 0);
+
+ QQmlExpression preExp(engine.rootContext(), &model, preamble);
+ QCOMPARE(preExp.evaluate().toInt(), 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;
+ }
+
+ // execute a set of commands on the worker list model, then check the
+ // changes are reflected in the list model in the main thread
+ QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker",
+ Q_ARG(QVariant, operations.mid(0, operations.length()-1))));
+ waitForWorker(item);
+
+ QQmlExpression e(engine.rootContext(), &model, operations.last().toString());
+ QCOMPARE(e.evaluate().toInt(), result);
+
+ delete item;
+ qApp->processEvents();
+}
+
+QTEST_MAIN(tst_qquicklistmodel)
+
+#include "tst_qquicklistmodel.moc"
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml b/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml
index 0ac56d9b66..0ac56d9b66 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/BaseWorker.qml
+++ b/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/Global.js b/tests/auto/qml/qquickworkerscript/data/Global.js
index 6bdb4a56b9..6bdb4a56b9 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/Global.js
+++ b/tests/auto/qml/qquickworkerscript/data/Global.js
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/externalObjectWorker.qml b/tests/auto/qml/qquickworkerscript/data/externalObjectWorker.qml
index 1dae608b50..1dae608b50 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/externalObjectWorker.qml
+++ b/tests/auto/qml/qquickworkerscript/data/externalObjectWorker.qml
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script.js b/tests/auto/qml/qquickworkerscript/data/script.js
index 90aae263a1..90aae263a1 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/script.js
+++ b/tests/auto/qml/qquickworkerscript/data/script.js
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onCall.js b/tests/auto/qml/qquickworkerscript/data/script_error_onCall.js
index f589b0ef40..f589b0ef40 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onCall.js
+++ b/tests/auto/qml/qquickworkerscript/data/script_error_onCall.js
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onLoad.js b/tests/auto/qml/qquickworkerscript/data/script_error_onLoad.js
index 1d6eab2285..1d6eab2285 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/script_error_onLoad.js
+++ b/tests/auto/qml/qquickworkerscript/data/script_error_onLoad.js
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_fixed_return.js b/tests/auto/qml/qquickworkerscript/data/script_fixed_return.js
index 14f6f178ae..14f6f178ae 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/script_fixed_return.js
+++ b/tests/auto/qml/qquickworkerscript/data/script_fixed_return.js
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js b/tests/auto/qml/qquickworkerscript/data/script_include.js
index 0385d91170..0385d91170 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/script_include.js
+++ b/tests/auto/qml/qquickworkerscript/data/script_include.js
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/script_pragma.js b/tests/auto/qml/qquickworkerscript/data/script_pragma.js
index cb3b6d3398..cb3b6d3398 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/script_pragma.js
+++ b/tests/auto/qml/qquickworkerscript/data/script_pragma.js
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.js b/tests/auto/qml/qquickworkerscript/data/stressDispose.js
index 5c4c5ec906..5c4c5ec906 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.js
+++ b/tests/auto/qml/qquickworkerscript/data/stressDispose.js
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml b/tests/auto/qml/qquickworkerscript/data/stressDispose.qml
index 3e8465d6fe..3e8465d6fe 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml
+++ b/tests/auto/qml/qquickworkerscript/data/stressDispose.qml
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml b/tests/auto/qml/qquickworkerscript/data/worker.qml
index b5a92bf1f5..b5a92bf1f5 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker.qml
+++ b/tests/auto/qml/qquickworkerscript/data/worker.qml
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onCall.qml b/tests/auto/qml/qquickworkerscript/data/worker_error_onCall.qml
index aa20783e76..aa20783e76 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onCall.qml
+++ b/tests/auto/qml/qquickworkerscript/data/worker_error_onCall.qml
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onLoad.qml b/tests/auto/qml/qquickworkerscript/data/worker_error_onLoad.qml
index 8a33aeb44c..8a33aeb44c 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_error_onLoad.qml
+++ b/tests/auto/qml/qquickworkerscript/data/worker_error_onLoad.qml
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml b/tests/auto/qml/qquickworkerscript/data/worker_include.qml
index 100b8d4551..100b8d4551 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_include.qml
+++ b/tests/auto/qml/qquickworkerscript/data/worker_include.qml
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml b/tests/auto/qml/qquickworkerscript/data/worker_pragma.qml
index 7e313b3c42..7e313b3c42 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/data/worker_pragma.qml
+++ b/tests/auto/qml/qquickworkerscript/data/worker_pragma.qml
diff --git a/tests/auto/qml/qquickworkerscript/qquickworkerscript.pro b/tests/auto/qml/qquickworkerscript/qquickworkerscript.pro
new file mode 100644
index 0000000000..e9c358c3cc
--- /dev/null
+++ b/tests/auto/qml/qquickworkerscript/qquickworkerscript.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickworkerscript
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickworkerscript.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private testlib
diff --git a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp
new file mode 100644
index 0000000000..6569b877fe
--- /dev/null
+++ b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp
@@ -0,0 +1,300 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qfileinfo.h>
+#include <QtQml/qjsengine.h>
+
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlengine.h>
+
+#include <private/qquickworkerscript_p.h>
+#include <private/qqmlengine_p.h>
+#include "../../shared/util.h"
+
+class tst_QQuickWorkerScript : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickWorkerScript() {}
+private slots:
+ void source();
+ void messaging();
+ void messaging_data();
+ void messaging_sendQObjectList();
+ void messaging_sendJsObject();
+ void messaging_sendExternalObject();
+ void script_with_pragma();
+ void script_included();
+ void scriptError_onLoad();
+ void scriptError_onCall();
+ void stressDispose();
+
+private:
+ void waitForEchoMessage(QQuickWorkerScript *worker) {
+ QEventLoop loop;
+ QVERIFY(connect(worker, SIGNAL(done()), &loop, SLOT(quit())));
+ QTimer timer;
+ timer.setSingleShot(true);
+ connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ timer.start(10000);
+ loop.exec();
+ QVERIFY(timer.isActive());
+ }
+
+ QQmlEngine m_engine;
+};
+
+void tst_QQuickWorkerScript::source()
+{
+ QQmlComponent component(&m_engine, testFileUrl("worker.qml"));
+ QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+ const QMetaObject *mo = worker->metaObject();
+
+ QVariant value(100);
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
+
+ QUrl source = testFileUrl("script_fixed_return.js");
+ worker->setSource(source);
+ QCOMPARE(worker->source(), source);
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), qVariantFromValue(QString("Hello_World")));
+
+ qApp->processEvents();
+ delete worker;
+}
+
+void tst_QQuickWorkerScript::messaging()
+{
+ QFETCH(QVariant, value);
+
+ QQmlComponent component(&m_engine, testFileUrl("worker.qml"));
+ QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+
+ const QMetaObject *mo = worker->metaObject();
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
+
+ qApp->processEvents();
+ delete worker;
+}
+
+void tst_QQuickWorkerScript::messaging_data()
+{
+ QTest::addColumn<QVariant>("value");
+
+ QTest::newRow("invalid") << QVariant();
+ QTest::newRow("bool") << qVariantFromValue(true);
+ QTest::newRow("int") << qVariantFromValue(1001);
+ QTest::newRow("real") << qVariantFromValue(10334.375);
+ QTest::newRow("string") << qVariantFromValue(QString("More cheeeese, Gromit!"));
+ QTest::newRow("variant list") << qVariantFromValue((QVariantList() << "a" << "b" << "c"));
+ QTest::newRow("date time") << qVariantFromValue(QDateTime::currentDateTime());
+#ifndef QT_NO_REGEXP
+ // QtScript's QScriptValue -> QRegExp uses RegExp2 pattern syntax
+ QTest::newRow("regexp") << qVariantFromValue(QRegExp("^\\d\\d?$", Qt::CaseInsensitive, QRegExp::RegExp2));
+#endif
+}
+
+void tst_QQuickWorkerScript::messaging_sendQObjectList()
+{
+ // Not allowed to send QObjects other than QQuickListModelWorkerAgent
+ // instances. If objects are sent in a list, they will be sent as 'undefined'
+ // js values.
+
+ QQmlComponent component(&m_engine, testFileUrl("worker.qml"));
+ QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QVariantList objects;
+ for (int i=0; i<3; i++)
+ objects << qVariantFromValue(new QObject(this));
+
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, qVariantFromValue(objects))));
+ waitForEchoMessage(worker);
+
+ const QMetaObject *mo = worker->metaObject();
+ QVariantList result = mo->property(mo->indexOfProperty("response")).read(worker).value<QVariantList>();
+ QCOMPARE(result, (QVariantList() << QVariant() << QVariant() << QVariant()));
+
+ qApp->processEvents();
+ delete worker;
+}
+
+void tst_QQuickWorkerScript::messaging_sendJsObject()
+{
+ QQmlComponent component(&m_engine, testFileUrl("worker.qml"));
+ QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ // Properties are in alphabetical order to enable string-based comparison after
+ // QVariant roundtrip, since the properties will be stored in a QVariantMap.
+ QString jsObject = "{'haste': 1125, 'name': 'zyz', 'spell power': 3101}";
+
+ QVariantMap map;
+ map.insert("haste", 1125);
+ map.insert("name", "zyz");
+ map.insert("spell power", 3101);
+
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, qVariantFromValue(map))));
+ waitForEchoMessage(worker);
+
+ QVariant result = qVariantFromValue(false);
+ QVERIFY(QMetaObject::invokeMethod(worker, "compareLiteralResponse", Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, jsObject)));
+ QVERIFY(result.toBool());
+
+ qApp->processEvents();
+ delete worker;
+}
+
+void tst_QQuickWorkerScript::messaging_sendExternalObject()
+{
+ QQmlComponent component(&m_engine, testFileUrl("externalObjectWorker.qml"));
+ QObject *obj = component.create();
+ QVERIFY(obj);
+ QMetaObject::invokeMethod(obj, "testExternalObject");
+ QTest::qWait(100); // shouldn't crash.
+ delete obj;
+}
+
+void tst_QQuickWorkerScript::script_with_pragma()
+{
+ QVariant value(100);
+
+ QQmlComponent component(&m_engine, testFileUrl("worker_pragma.qml"));
+ QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+
+ const QMetaObject *mo = worker->metaObject();
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
+
+ qApp->processEvents();
+ delete worker;
+}
+
+void tst_QQuickWorkerScript::script_included()
+{
+ QQmlComponent component(&m_engine, testFileUrl("worker_include.qml"));
+ QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QString value("Hello");
+
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+ waitForEchoMessage(worker);
+
+ const QMetaObject *mo = worker->metaObject();
+ QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).toString(), value + " World");
+
+ qApp->processEvents();
+ delete worker;
+}
+
+static QString qquickworkerscript_lastWarning;
+static void qquickworkerscript_warningsHandler(QtMsgType type, const char *msg)
+{
+ if (type == QtWarningMsg)
+ qquickworkerscript_lastWarning = QString::fromUtf8(msg);
+}
+
+void tst_QQuickWorkerScript::scriptError_onLoad()
+{
+ QQmlComponent component(&m_engine, testFileUrl("worker_error_onLoad.qml"));
+
+ QtMsgHandler previousMsgHandler = qInstallMsgHandler(qquickworkerscript_warningsHandler);
+ QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QTRY_COMPARE(qquickworkerscript_lastWarning,
+ testFileUrl("script_error_onLoad.js").toString() + QLatin1String(":3: SyntaxError: Unexpected identifier"));
+
+ qInstallMsgHandler(previousMsgHandler);
+ qApp->processEvents();
+ delete worker;
+}
+
+void tst_QQuickWorkerScript::scriptError_onCall()
+{
+ QQmlComponent component(&m_engine, testFileUrl("worker_error_onCall.qml"));
+ QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create());
+ QVERIFY(worker != 0);
+
+ QtMsgHandler previousMsgHandler = qInstallMsgHandler(qquickworkerscript_warningsHandler);
+ QVariant value;
+ QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
+
+ QTRY_COMPARE(qquickworkerscript_lastWarning,
+ testFileUrl("script_error_onCall.js").toString() + QLatin1String(":4: ReferenceError: Can't find variable: getData"));
+
+ qInstallMsgHandler(previousMsgHandler);
+ qApp->processEvents();
+ delete worker;
+}
+
+// Rapidly create and destroy worker scripts to test resources are being disposed
+// in the correct isolate
+void tst_QQuickWorkerScript::stressDispose()
+{
+ for (int ii = 0; ii < 100; ++ii) {
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("stressDispose.qml"));
+ QObject *o = component.create();
+ QVERIFY(o);
+ delete o;
+ }
+}
+
+QTEST_MAIN(tst_QQuickWorkerScript)
+
+#include "tst_qquickworkerscript.moc"
diff --git a/tests/auto/qml/runall.sh b/tests/auto/qml/runall.sh
new file mode 100644
index 0000000000..9580d8445e
--- /dev/null
+++ b/tests/auto/qml/runall.sh
@@ -0,0 +1,100 @@
+#!/bin/bash
+#
+#############################################################################
+##
+## Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+## Contact: http://www.qt-project.org/
+##
+## This file is part of the test suite of the Qt Toolkit.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## GNU Lesser General Public License Usage
+## 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.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU General
+## Public License version 3.0 as published by the Free Software Foundation
+## and appearing in the file LICENSE.GPL included in the packaging of this
+## file. Please review the following information to ensure the GNU General
+## Public License version 3.0 requirements will be met:
+## http://www.gnu.org/copyleft/gpl.html.
+##
+## Other Usage
+## Alternatively, this file may be used in accordance with the terms and
+## conditions contained in a signed written agreement between you and Nokia.
+##
+##
+##
+##
+##
+##
+## $QT_END_LICENSE$
+##
+############################################################################/
+
+if [ "$(uname)" = Linux ]
+then
+ Xnest :7 2>/dev/null &
+ sleep 1
+ trap "kill $!" EXIT
+ export DISPLAY=:7
+ export LANG=en_US
+ kwin 2>/dev/null &
+ sleep 1
+fi
+
+function filter
+{
+ exe=$1
+ skip=0
+ while read line
+ do
+ if [ $skip != 0 ]
+ then
+ let skip=skip-1
+ else
+ case "$line" in
+ make*Error) echo "$line";;
+ make*Stop) echo "$line";;
+ /*/bin/make*) ;;
+ make*) ;;
+ install*) ;;
+ QQmlDebugServer:*Waiting*) ;;
+ QQmlDebugServer:*Connection*) ;;
+ */qmake*) ;;
+ */bin/moc*) ;;
+ *targ.debug*) ;;
+ g++*) ;;
+ cd*) ;;
+ XFAIL*) skip=1;;
+ SKIP*) skip=1;;
+ PASS*) ;;
+ QDEBUG*) ;;
+ Makefile*) ;;
+ Config*) ;;
+ Totals*) ;;
+ \**) ;;
+ ./*) ;;
+ *tst_*) echo "$line" ;;
+ *) echo "$exe: $line"
+ esac
+ fi
+ done
+}
+
+make -k -j1 install 2>&1 | filter build
+for exe in $(make install | sed -n 's/^install .* "\([^"]*qt4\/tst_[^"]*\)".*/\1/p')
+do
+ echo $exe
+ $exe 2>&1 | filter $exe
+done
+
diff --git a/tests/auto/declarative/v4/data/conditionalExpr.qml b/tests/auto/qml/v4/data/conditionalExpr.qml
index b74a95a94b..b74a95a94b 100644
--- a/tests/auto/declarative/v4/data/conditionalExpr.qml
+++ b/tests/auto/qml/v4/data/conditionalExpr.qml
diff --git a/tests/auto/declarative/v4/data/doubleBoolJump.qml b/tests/auto/qml/v4/data/doubleBoolJump.qml
index 2eea73b573..2eea73b573 100644
--- a/tests/auto/declarative/v4/data/doubleBoolJump.qml
+++ b/tests/auto/qml/v4/data/doubleBoolJump.qml
diff --git a/tests/auto/declarative/v4/data/fetchException.qml b/tests/auto/qml/v4/data/fetchException.qml
index 6431fcfae8..6431fcfae8 100644
--- a/tests/auto/declarative/v4/data/fetchException.qml
+++ b/tests/auto/qml/v4/data/fetchException.qml
diff --git a/tests/auto/declarative/v4/data/logicalOr.2.qml b/tests/auto/qml/v4/data/logicalOr.2.qml
index 54fb78b127..54fb78b127 100644
--- a/tests/auto/declarative/v4/data/logicalOr.2.qml
+++ b/tests/auto/qml/v4/data/logicalOr.2.qml
diff --git a/tests/auto/declarative/v4/data/logicalOr.qml b/tests/auto/qml/v4/data/logicalOr.qml
index 406a7d83eb..406a7d83eb 100644
--- a/tests/auto/declarative/v4/data/logicalOr.qml
+++ b/tests/auto/qml/v4/data/logicalOr.qml
diff --git a/tests/auto/declarative/v4/data/nestedLogicalOr.qml b/tests/auto/qml/v4/data/nestedLogicalOr.qml
index c4478a3e7b..c4478a3e7b 100644
--- a/tests/auto/declarative/v4/data/nestedLogicalOr.qml
+++ b/tests/auto/qml/v4/data/nestedLogicalOr.qml
diff --git a/tests/auto/declarative/v4/data/nestedObjectAccess.qml b/tests/auto/qml/v4/data/nestedObjectAccess.qml
index 56cd17e41e..56cd17e41e 100644
--- a/tests/auto/declarative/v4/data/nestedObjectAccess.qml
+++ b/tests/auto/qml/v4/data/nestedObjectAccess.qml
diff --git a/tests/auto/declarative/v4/data/nullQObject.qml b/tests/auto/qml/v4/data/nullQObject.qml
index 00185b3988..00185b3988 100644
--- a/tests/auto/declarative/v4/data/nullQObject.qml
+++ b/tests/auto/qml/v4/data/nullQObject.qml
diff --git a/tests/auto/declarative/v4/data/qrealToIntRounding.qml b/tests/auto/qml/v4/data/qrealToIntRounding.qml
index ee3d405073..ee3d405073 100644
--- a/tests/auto/declarative/v4/data/qrealToIntRounding.qml
+++ b/tests/auto/qml/v4/data/qrealToIntRounding.qml
diff --git a/tests/auto/declarative/v4/data/qtbug_21883.qml b/tests/auto/qml/v4/data/qtbug_21883.qml
index a51f97c944..a51f97c944 100644
--- a/tests/auto/declarative/v4/data/qtbug_21883.qml
+++ b/tests/auto/qml/v4/data/qtbug_21883.qml
diff --git a/tests/auto/declarative/v4/data/qtbug_22816.qml b/tests/auto/qml/v4/data/qtbug_22816.qml
index bfa8d4948c..bfa8d4948c 100644
--- a/tests/auto/declarative/v4/data/qtbug_22816.qml
+++ b/tests/auto/qml/v4/data/qtbug_22816.qml
diff --git a/tests/auto/declarative/v4/data/stringComparison.qml b/tests/auto/qml/v4/data/stringComparison.qml
index 64b6798c69..64b6798c69 100644
--- a/tests/auto/declarative/v4/data/stringComparison.qml
+++ b/tests/auto/qml/v4/data/stringComparison.qml
diff --git a/tests/auto/declarative/v4/data/subscriptionsInConditionalExpressions.qml b/tests/auto/qml/v4/data/subscriptionsInConditionalExpressions.qml
index a8e05eeda1..a8e05eeda1 100644
--- a/tests/auto/declarative/v4/data/subscriptionsInConditionalExpressions.qml
+++ b/tests/auto/qml/v4/data/subscriptionsInConditionalExpressions.qml
diff --git a/tests/auto/declarative/v4/data/unaryMinus.qml b/tests/auto/qml/v4/data/unaryMinus.qml
index 410654fc3c..410654fc3c 100644
--- a/tests/auto/declarative/v4/data/unaryMinus.qml
+++ b/tests/auto/qml/v4/data/unaryMinus.qml
diff --git a/tests/auto/declarative/v4/data/unaryPlus.qml b/tests/auto/qml/v4/data/unaryPlus.qml
index cd5315a7cc..cd5315a7cc 100644
--- a/tests/auto/declarative/v4/data/unaryPlus.qml
+++ b/tests/auto/qml/v4/data/unaryPlus.qml
diff --git a/tests/auto/declarative/v4/data/unnecessaryReeval.qml b/tests/auto/qml/v4/data/unnecessaryReeval.qml
index 48662d7a2d..48662d7a2d 100644
--- a/tests/auto/declarative/v4/data/unnecessaryReeval.qml
+++ b/tests/auto/qml/v4/data/unnecessaryReeval.qml
diff --git a/tests/auto/qml/v4/testtypes.cpp b/tests/auto/qml/v4/testtypes.cpp
new file mode 100644
index 0000000000..c879cf2226
--- /dev/null
+++ b/tests/auto/qml/v4/testtypes.cpp
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "testtypes.h"
+
+#include <QtQml/qqml.h>
+
+void registerTypes()
+{
+ qmlRegisterType<ResultObject>("Qt.v4", 1,0, "Result");
+ qmlRegisterType<NestedObject>();
+}
diff --git a/tests/auto/declarative/v4/testtypes.h b/tests/auto/qml/v4/testtypes.h
index 02ba721839..02ba721839 100644
--- a/tests/auto/declarative/v4/testtypes.h
+++ b/tests/auto/qml/v4/testtypes.h
diff --git a/tests/auto/qml/v4/tst_v4.cpp b/tests/auto/qml/v4/tst_v4.cpp
new file mode 100644
index 0000000000..559abf7388
--- /dev/null
+++ b/tests/auto/qml/v4/tst_v4.cpp
@@ -0,0 +1,353 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qdir.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtCore/qdebug.h>
+
+#include <private/qv4compiler_p.h>
+
+#include "../../shared/util.h"
+#include "testtypes.h"
+
+class tst_v4 : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_v4() {}
+
+private slots:
+ void initTestCase();
+
+ void unnecessaryReeval();
+ void logicalOr();
+ void nestedLogicalOr();
+ void conditionalExpr();
+ void qtscript();
+ void qtscript_data();
+ void nestedObjectAccess();
+ void subscriptionsInConditionalExpressions();
+ void qtbug_21883();
+ void qtbug_22816();
+ void stringComparison();
+ void unaryMinus();
+ void unaryPlus();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_v4::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ registerTypes();
+}
+
+static int v4ErrorsMsgCount = 0;
+static void v4ErrorsMsgHandler(QtMsgType, const char *message)
+{
+ QByteArray m(message);
+ if (m.contains("QV4"))
+ v4ErrorsMsgCount++;
+}
+
+void tst_v4::qtscript()
+{
+ QFETCH(QString, file);
+ QV4Compiler::enableBindingsTest(true);
+
+ QQmlComponent component(&engine, testFileUrl(file));
+
+ v4ErrorsMsgCount = 0;
+ QtMsgHandler old = qInstallMsgHandler(v4ErrorsMsgHandler);
+
+ QObject *o = component.create();
+ delete o;
+
+ qInstallMsgHandler(old);
+
+ QCOMPARE(v4ErrorsMsgCount, 0);
+
+ QV4Compiler::enableBindingsTest(false);
+}
+
+void tst_v4::qtscript_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QTest::newRow("qreal -> int rounding") << "qrealToIntRounding.qml";
+ QTest::newRow("exception on fetch") << "fetchException.qml";
+ QTest::newRow("logical or") << "logicalOr.qml";
+ QTest::newRow("conditional expressions") << "conditionalExpr.qml";
+ QTest::newRow("double bool jump") << "doubleBoolJump.qml";
+ QTest::newRow("unary minus") << "unaryMinus.qml";
+ QTest::newRow("null qobject") << "nullQObject.qml";
+}
+
+void tst_v4::unnecessaryReeval()
+{
+ QQmlComponent component(&engine, testFileUrl("unnecessaryReeval.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->resultCounter(), 1);
+ QCOMPARE(ro->result(), 19);
+ ro->resetResultCounter();
+
+ ro->setProperty("b", 6);
+
+ QCOMPARE(ro->resultCounter(), 1);
+ QCOMPARE(ro->result(), 6);
+ ro->resetResultCounter();
+
+ ro->setProperty("a", 14);
+
+ QCOMPARE(ro->resultCounter(), 1);
+ QCOMPARE(ro->result(), 7);
+ ro->resetResultCounter();
+
+ ro->setProperty("b", 14);
+ QCOMPARE(ro->resultCounter(), 0);
+ QCOMPARE(ro->result(), 7);
+
+ delete o;
+}
+
+void tst_v4::logicalOr()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("logicalOr.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 0);
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("logicalOr.2.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 1);
+ delete o;
+ }
+}
+
+void tst_v4::nestedLogicalOr()
+{
+ //we are primarily testing that v4 does not get caught in a loop (QTBUG-24038)
+ QQmlComponent component(&engine, testFileUrl("nestedLogicalOr.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 1);
+ delete o;
+}
+
+void tst_v4::conditionalExpr()
+{
+ {
+ QQmlComponent component(&engine, testFileUrl("conditionalExpr.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 0);
+ delete o;
+ }
+}
+
+// This would previously use the metaObject of the root element to result the nested access.
+// That is, the index for accessing "result" would have been RootObject::result, instead of
+// NestedObject::result.
+void tst_v4::nestedObjectAccess()
+{
+ QQmlComponent component(&engine, testFileUrl("nestedObjectAccess.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ ResultObject *ro = qobject_cast<ResultObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->result(), 37);
+
+ delete o;
+}
+
+void tst_v4::subscriptionsInConditionalExpressions()
+{
+ QQmlComponent component(&engine, testFileUrl("subscriptionsInConditionalExpressions.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QObject *ro = qobject_cast<QObject *>(o);
+ QVERIFY(ro != 0);
+
+ QCOMPARE(ro->property("result").toReal(), qreal(2));
+
+ delete o;
+}
+
+// Crash test
+void tst_v4::qtbug_21883()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_21883.qml"));
+
+ QString warning = component.url().toString() + ":4: Unable to assign null to ResultObject*";
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ delete o;
+}
+
+void tst_v4::qtbug_22816()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_22816.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test1").toBool(), false);
+ QCOMPARE(o->property("test2").toBool(), false);
+ delete o;
+}
+
+void tst_v4::stringComparison()
+{
+ QQmlComponent component(&engine, testFileUrl("stringComparison.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+ QCOMPARE(o->property("test6").toBool(), true);
+ QCOMPARE(o->property("test7").toBool(), true);
+ QCOMPARE(o->property("test8").toBool(), true);
+ QCOMPARE(o->property("test9").toBool(), true);
+ QCOMPARE(o->property("test10").toBool(), true);
+ QCOMPARE(o->property("test11").toBool(), true);
+ QCOMPARE(o->property("test12").toBool(), true);
+ QCOMPARE(o->property("test13").toBool(), true);
+ QCOMPARE(o->property("test14").toBool(), true);
+ QCOMPARE(o->property("test15").toBool(), true);
+ QCOMPARE(o->property("test16").toBool(), true);
+ QCOMPARE(o->property("test17").toBool(), true);
+ QCOMPARE(o->property("test18").toBool(), true);
+ QCOMPARE(o->property("test19").toBool(), true);
+ QCOMPARE(o->property("test20").toBool(), true);
+ QCOMPARE(o->property("test21").toBool(), true);
+ QCOMPARE(o->property("test22").toBool(), true);
+ delete o;
+}
+
+void tst_v4::unaryMinus()
+{
+ QQmlComponent component(&engine, testFileUrl("unaryMinus.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toReal(), qreal(-18));
+ QCOMPARE(o->property("test2").toInt(), -18);
+ QCOMPARE(o->property("test3").toReal(), qreal(3.7));
+ QCOMPARE(o->property("test4").toInt(), 4);
+ QCOMPARE(o->property("test5").toReal(), qreal(3.3));
+ QCOMPARE(o->property("test6").toInt(), 3);
+ QCOMPARE(o->property("test7").toReal(), qreal(7));
+ QCOMPARE(o->property("test8").toInt(), 7);
+ QCOMPARE(o->property("test9").toReal(), qreal(-4.4));
+ QCOMPARE(o->property("test10").toInt(), -4);
+
+ delete o;
+}
+
+void tst_v4::unaryPlus()
+{
+ QQmlComponent component(&engine, testFileUrl("unaryPlus.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toReal(), qreal(18));
+ QCOMPARE(o->property("test2").toInt(), 18);
+ QCOMPARE(o->property("test3").toReal(), qreal(-3.7));
+ QCOMPARE(o->property("test4").toInt(), -4);
+ QCOMPARE(o->property("test5").toReal(), qreal(-3.3));
+ QCOMPARE(o->property("test6").toInt(), -3);
+ QCOMPARE(o->property("test7").toReal(), qreal(-7));
+ QCOMPARE(o->property("test8").toInt(), -7);
+ QCOMPARE(o->property("test9").toReal(), qreal(4.4));
+ QCOMPARE(o->property("test10").toInt(), 4);
+
+ delete o;
+}
+
+QTEST_MAIN(tst_v4)
+
+#include "tst_v4.moc"
diff --git a/tests/auto/qml/v4/v4.pro b/tests/auto/qml/v4/v4.pro
new file mode 100644
index 0000000000..df8e7b1c3c
--- /dev/null
+++ b/tests/auto/qml/v4/v4.pro
@@ -0,0 +1,17 @@
+CONFIG += testcase
+TARGET = tst_qqmlv4
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_v4.cpp \
+ testtypes.cpp
+HEADERS += testtypes.h
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private network testlib
diff --git a/tests/auto/qmldevtools/compile/tst_compile.cpp b/tests/auto/qmldevtools/compile/tst_compile.cpp
index bcd602b8bc..0955eb4a8e 100644
--- a/tests/auto/qmldevtools/compile/tst_compile.cpp
+++ b/tests/auto/qmldevtools/compile/tst_compile.cpp
@@ -40,11 +40,11 @@
****************************************************************************/
#include <qtest.h>
-#include <private/qdeclarativejsengine_p.h>
-#include <private/qdeclarativejslexer_p.h>
-#include <private/qdeclarativejsparser_p.h>
-#include <private/qdeclarativejsastvisitor_p.h>
-#include <private/qdeclarativejsast_p.h>
+#include <private/qqmljsengine_p.h>
+#include <private/qqmljslexer_p.h>
+#include <private/qqmljsparser_p.h>
+#include <private/qqmljsastvisitor_p.h>
+#include <private/qqmljsast_p.h>
class tst_compile : public QObject
{
diff --git a/tests/auto/qmltest/createbenchmark/item.qml b/tests/auto/qmltest/createbenchmark/item.qml
index ebc50ceb13..af6c2f3f59 100644
--- a/tests/auto/qmltest/createbenchmark/item.qml
+++ b/tests/auto/qmltest/createbenchmark/item.qml
@@ -3,7 +3,7 @@
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
+** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/tests/auto/qmltest/qmltest.pro b/tests/auto/qmltest/qmltest.pro
index d0bc8a89cd..b1b2ee2228 100644
--- a/tests/auto/qmltest/qmltest.pro
+++ b/tests/auto/qmltest/qmltest.pro
@@ -4,7 +4,7 @@ CONFIG += warn_on qmltestcase
SOURCES += tst_qmltest.cpp
-importFiles.files = borderimage buttonclick createbenchmark events qdeclarativebinding selftests
+importFiles.files = borderimage buttonclick createbenchmark events qqmlbinding selftests
importFiles.path = .
DEPLOYMENT += importFiles
diff --git a/tests/auto/qmltest/qdeclarativebinding/tst_binding.qml b/tests/auto/qmltest/qqmlbinding/tst_binding.qml
index 0948046bcf..0948046bcf 100644
--- a/tests/auto/qmltest/qdeclarativebinding/tst_binding.qml
+++ b/tests/auto/qmltest/qqmlbinding/tst_binding.qml
diff --git a/tests/auto/qmltest/qdeclarativebinding/tst_binding2.qml b/tests/auto/qmltest/qqmlbinding/tst_binding2.qml
index 87a30e2c14..87a30e2c14 100644
--- a/tests/auto/qmltest/qdeclarativebinding/tst_binding2.qml
+++ b/tests/auto/qmltest/qqmlbinding/tst_binding2.qml
diff --git a/tests/auto/qtquick2/examples/examples.pro b/tests/auto/qtquick2/examples/examples.pro
deleted file mode 100644
index 577c145e77..0000000000
--- a/tests/auto/qtquick2/examples/examples.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_examples
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_examples.cpp
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-#temporary
-QT += core-private gui-private declarative-private quick-private widgets-private v8-private testlib
diff --git a/tests/auto/qtquick2/examples/tst_examples.cpp b/tests/auto/qtquick2/examples/tst_examples.cpp
deleted file mode 100644
index 0e420f7277..0000000000
--- a/tests/auto/qtquick2/examples/tst_examples.cpp
+++ /dev/null
@@ -1,307 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QLibraryInfo>
-#include <QDir>
-#include <QProcess>
-#include <QDebug>
-#include <QtQuick/QQuickItem>
-#include <QtQuick/QQuickView>
-#include <QDeclarativeComponent>
-#include <QDeclarativeEngine>
-#include <QDeclarativeError>
-
-static QtMsgHandler testlibMsgHandler = 0;
-void msgHandlerFilter(QtMsgType type, const char *msg)
-{
- if (type == QtCriticalMsg || type == QtFatalMsg)
- (*testlibMsgHandler)(type, msg);
-}
-
-class tst_examples : public QObject
-{
- Q_OBJECT
-public:
- tst_examples();
-
-private slots:
- void init();
- void cleanup();
-
- void sgexamples_data();
- void sgexamples();
- void sgsnippets_data();
- void sgsnippets();
-
- void namingConvention();
-private:
- QStringList excludedDirs;
- QStringList excludedFiles;
-
- void namingConvention(const QDir &);
- QStringList findQmlFiles(const QDir &);
-
- QDeclarativeEngine engine;
-};
-
-tst_examples::tst_examples()
-{
- // Add files to exclude here
- excludedFiles << "doc/src/snippets/declarative/listmodel.qml"; //Just a ListModel, no root QQuickItem
-
- // Add directories you want excluded here
- excludedDirs << "examples/declarative/text/fonts"; // QTBUG-21415
- excludedDirs << "doc/src/snippets/declarative/path"; //No root QQuickItem
-
- // Not run in QQuickView
- excludedDirs << "examples/declarative/qtquick1";
-
- // These snippets are not expected to run on their own.
- excludedDirs << "doc/src/snippets/declarative/visualdatamodel_rootindex";
- excludedDirs << "doc/src/snippets/declarative/qtbinding";
- excludedDirs << "doc/src/snippets/declarative/imports";
- excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex";
- excludedDirs << "doc/src/snippets/qtquick1/qtbinding";
- excludedDirs << "doc/src/snippets/qtquick1/imports";
-
-#ifdef QT_NO_WEBKIT
- excludedDirs << "examples/declarative/modelviews/webview";
- excludedDirs << "examples/declarative/webbrowser";
- excludedDirs << "doc/src/snippets/declarative/webview";
- excludedDirs << "doc/src/snippets/qtquick1/webview";
-#endif
-
-#ifdef QT_NO_XMLPATTERNS
- excludedDirs << "examples/declarative/xml/xmldata";
- excludedDirs << "examples/declarative/twitter";
- excludedDirs << "examples/declarative/flickr";
- excludedDirs << "examples/declarative/photoviewer";
-#endif
-}
-
-void tst_examples::init()
-{
- if (!qstrcmp(QTest::currentTestFunction(), "sgsnippets"))
- testlibMsgHandler = qInstallMsgHandler(msgHandlerFilter);
-}
-
-void tst_examples::cleanup()
-{
- if (!qstrcmp(QTest::currentTestFunction(), "sgsnippets"))
- qInstallMsgHandler(testlibMsgHandler);
-}
-
-/*
-This tests that the examples follow the naming convention required
-to have them tested by the examples() test.
-*/
-void tst_examples::namingConvention(const QDir &d)
-{
- for (int ii = 0; ii < excludedDirs.count(); ++ii) {
- QString s = excludedDirs.at(ii);
- if (d.absolutePath().endsWith(s))
- return;
- }
-
- QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
- QDir::Files);
-
- bool seenQml = !files.isEmpty();
- bool seenLowercase = false;
-
- foreach (const QString &file, files) {
- if (file.at(0).isLower())
- seenLowercase = true;
- }
-
- if (!seenQml) {
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
- QDir::NoSymLinks);
- foreach (const QString &dir, dirs) {
- QDir sub = d;
- sub.cd(dir);
- namingConvention(sub);
- }
- } else if(!seenLowercase) {
- QFAIL(qPrintable(QString(
- "Directory %1 violates naming convention; expected at least one qml file "
- "starting with lower case, got: %2"
- ).arg(d.absolutePath()).arg(files.join(","))));
- }
-}
-
-void tst_examples::namingConvention()
-{
- QString examples = QLibraryInfo::location(QLibraryInfo::ExamplesPath);
-
- namingConvention(QDir(examples));
-}
-
-QStringList tst_examples::findQmlFiles(const QDir &d)
-{
- for (int ii = 0; ii < excludedDirs.count(); ++ii) {
- QString s = excludedDirs.at(ii);
- if (d.absolutePath().endsWith(s))
- return QStringList();
- }
-
- QStringList rv;
-
- QStringList cppfiles = d.entryList(QStringList() << QLatin1String("*.cpp"), QDir::Files);
- if (cppfiles.isEmpty()) {
- QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
- QDir::Files);
- foreach (const QString &file, files) {
- if (file.at(0).isLower()) {
- bool superContinue = false;
- for (int ii = 0; ii < excludedFiles.count(); ++ii) {
- QString e = excludedFiles.at(ii);
- if (d.absoluteFilePath(file).endsWith(e)) {
- superContinue = true;
- break;
- }
- }
- if (superContinue)
- continue;
- rv << d.absoluteFilePath(file);
- }
- }
- }
-
-
- QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
- QDir::NoSymLinks);
- foreach (const QString &dir, dirs) {
- QDir sub = d;
- sub.cd(dir);
- rv << findQmlFiles(sub);
- }
-
- return rv;
-}
-
-/*
-This test runs all the examples in the declarative UI source tree and ensures
-that they start and exit cleanly.
-
-Examples are any .qml files under the examples/ directory that start
-with a lower case letter.
-*/
-void tst_examples::sgexamples_data()
-{
- QTest::addColumn<QString>("file");
-
- QString examples = QLatin1String(SRCDIR) + "/../../../../examples/declarative/";
- QString tutorials = QLatin1String(SRCDIR) + "/../../../../examples/tutorials/"; //Only declarative tutorials since modularization
-
- QStringList files;
- files << findQmlFiles(QDir(examples));
- files << findQmlFiles(QDir(tutorials));
-
- foreach (const QString &file, files)
- QTest::newRow(qPrintable(file)) << file;
-}
-
-void tst_examples::sgexamples()
-{
- QFETCH(QString, file);
-
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(file));
- if (component.status() == QDeclarativeComponent::Error)
- qWarning() << component.errors();
- QCOMPARE(component.status(), QDeclarativeComponent::Ready);
-
- QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
- QQuickItem *root = qobject_cast<QQuickItem *>(object.data());
- if (!root)
- component.completeCreate();
- QVERIFY(root);
-
- QQuickCanvas canvas;
- root->setParentItem(canvas.rootItem());
- component.completeCreate();
- canvas.show();
-
- QTest::qWaitForWindowShown(&canvas);
-
-}
-
-void tst_examples::sgsnippets_data()
-{
- QTest::addColumn<QString>("file");
-
- QString snippets = QLatin1String(SRCDIR) + "/../../../../doc/src/snippets/declarative";
-
- QStringList files;
- files << findQmlFiles(QDir(snippets));
-
- foreach (const QString &file, files)
- QTest::newRow(qPrintable(file)) << file;
-}
-
-void tst_examples::sgsnippets()
-{
- QFETCH(QString, file);
-
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(file));
- if (component.status() == QDeclarativeComponent::Error)
- qWarning() << component.errors();
- QCOMPARE(component.status(), QDeclarativeComponent::Ready);
-
- QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
- QQuickItem *root = qobject_cast<QQuickItem *>(object.data());
- if (!root)
- component.completeCreate();
- QVERIFY(root);
-
- QQuickCanvas canvas;
- root->setParentItem(canvas.rootItem());
- component.completeCreate();
- canvas.show();
-
- QTest::qWaitForWindowShown(&canvas);
-
-}
-
-QTEST_MAIN(tst_examples)
-
-#include "tst_examples.moc"
diff --git a/tests/auto/qtquick2/geometry/geometry.pro b/tests/auto/qtquick2/geometry/geometry.pro
deleted file mode 100644
index 04d529cfb8..0000000000
--- a/tests/auto/qtquick2/geometry/geometry.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_geometry
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_geometry.cpp
-
-CONFIG+=parallel_test
-
-QT += core-private gui-private declarative-private quick-private opengl testlib
diff --git a/tests/auto/qtquick2/nodes/nodes.pro b/tests/auto/qtquick2/nodes/nodes.pro
deleted file mode 100644
index 40eeb2ab78..0000000000
--- a/tests/auto/qtquick2/nodes/nodes.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-CONFIG += testcase
-TARGET = tst_nodestest
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_nodestest.cpp
-
-CONFIG+=parallel_test
-
-QT += core-private gui-private declarative-private quick-private opengl widgets testlib
diff --git a/tests/auto/qtquick2/qdeclarativeanimationcontroller/qdeclarativeanimationcontroller.pro b/tests/auto/qtquick2/qdeclarativeanimationcontroller/qdeclarativeanimationcontroller.pro
deleted file mode 100644
index 52cafc33a6..0000000000
--- a/tests/auto/qtquick2/qdeclarativeanimationcontroller/qdeclarativeanimationcontroller.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-QT += core-private gui-private declarative-private
-TEMPLATE=app
-TARGET=tst_qdeclarativeanimationcontroller
-
-CONFIG += warn_on qmltestcase
-SOURCES += tst_qdeclarativeanimationcontroller.cpp
-
-importFiles.files = data
-importFiles.path = .
-DEPLOYMENT += importFiles
diff --git a/tests/auto/qtquick2/qdeclarativeanimationcontroller/tst_qdeclarativeanimationcontroller.cpp b/tests/auto/qtquick2/qdeclarativeanimationcontroller/tst_qdeclarativeanimationcontroller.cpp
deleted file mode 100644
index 744f92b99d..0000000000
--- a/tests/auto/qtquick2/qdeclarativeanimationcontroller/tst_qdeclarativeanimationcontroller.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtQuickTest/quicktest.h>
-QUICK_TEST_MAIN(qdeclarativeanimationcontroller)
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/qdeclarativeanimations.pro b/tests/auto/qtquick2/qdeclarativeanimations/qdeclarativeanimations.pro
deleted file mode 100644
index e13dbb974e..0000000000
--- a/tests/auto/qtquick2/qdeclarativeanimations/qdeclarativeanimations.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeanimations
-SOURCES += tst_qdeclarativeanimations.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
-
-# QTBUG-23385 - color mixing tests failing on Ubuntu 11.10 x64
-linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
deleted file mode 100644
index c7a0717dd3..0000000000
--- a/tests/auto/qtquick2/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
+++ /dev/null
@@ -1,1319 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/private/qanimationgroupjob_p.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtQuick/private/qdeclarativeanimation_p.h>
-#include <QtQuick/private/qdeclarativetransition_p.h>
-#include <QtQuick/private/qquickanimation_p.h>
-#include <QtQuick/private/qdeclarativepathinterpolator_p.h>
-#include <QtQuick/private/qquickitem_p.h>
-#include <QEasingCurve>
-
-#include <limits.h>
-#include <math.h>
-
-#include "../../shared/util.h"
-
-class tst_qdeclarativeanimations : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativeanimations() {}
-
-private slots:
- void initTestCase()
- {
- QDeclarativeEngine engine; // ensure types are registered
- QDeclarativeDataTest::initTestCase();
- }
-
- void simpleProperty();
- void simpleNumber();
- void simpleColor();
- void simpleRotation();
- void simplePath();
- void simpleAnchor();
- void reparent();
- void pathInterpolator();
- void pathInterpolatorBackwardJump();
- void pathWithNoStart();
- void alwaysRunToEnd();
- void complete();
- void resume();
- void dotProperty();
- void badTypes();
- void badProperties();
- void mixedTypes();
- void properties();
- void propertiesTransition();
- void pathTransition();
- void disabledTransition();
- void invalidDuration();
- void attached();
- void propertyValueSourceDefaultStart();
- void dontStart();
- void easingProperties();
- void rotation();
- void runningTrueBug();
- void nonTransitionBug();
- void registrationBug();
- void doubleRegistrationBug();
- void alwaysRunToEndRestartBug();
- void transitionAssignmentBug();
- void pauseBindingBug();
- void pauseBug();
- void loopingBug();
-};
-
-#define QTIMED_COMPARE(lhs, rhs) do { \
- for (int ii = 0; ii < 5; ++ii) { \
- if (lhs == rhs) \
- break; \
- QTest::qWait(50); \
- } \
- QCOMPARE(lhs, rhs); \
-} while (false)
-
-void tst_qdeclarativeanimations::simpleProperty()
-{
- QQuickRectangle rect;
- QDeclarativePropertyAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("x");
- animation.setTo(200);
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "x");
- QVERIFY(animation.to().toReal() == 200.0);
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTIMED_COMPARE(rect.x(), 200.0);
-
- rect.setPos(QPointF(0,0));
- animation.start();
- QVERIFY(animation.isRunning());
- animation.pause();
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.x(),100.0);
-}
-
-void tst_qdeclarativeanimations::simpleNumber()
-{
- QQuickRectangle rect;
- QDeclarativeNumberAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("x");
- animation.setTo(200);
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "x");
- QVERIFY(animation.to() == 200);
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTIMED_COMPARE(rect.x(), qreal(200));
-
- rect.setX(0);
- animation.start();
- animation.pause();
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.x(), qreal(100));
-}
-
-void tst_qdeclarativeanimations::simpleColor()
-{
- QQuickRectangle rect;
- QDeclarativeColorAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("color");
- animation.setTo(QColor("red"));
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "color");
- QVERIFY(animation.to() == QColor("red"));
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTIMED_COMPARE(rect.color(), QColor("red"));
-
- rect.setColor(QColor("blue"));
- animation.start();
- animation.pause();
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
-#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__)
- QEXPECT_FAIL("", "Fails on this platform - QTBUG-23385", Abort);
-#endif
- QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
-
- rect.setColor(QColor("green"));
- animation.setFrom(QColor("blue"));
- QVERIFY(animation.from() == QColor("blue"));
- animation.restart();
- QCOMPARE(rect.color(), QColor("blue"));
- QVERIFY(animation.isRunning());
- animation.setCurrentTime(125);
- QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
-}
-
-void tst_qdeclarativeanimations::simpleRotation()
-{
- QQuickRectangle rect;
- QDeclarativeRotationAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("rotation");
- animation.setTo(270);
- QVERIFY(animation.target() == &rect);
- QVERIFY(animation.property() == "rotation");
- QVERIFY(animation.to() == 270);
- QVERIFY(animation.direction() == QDeclarativeRotationAnimation::Numerical);
- animation.start();
- QVERIFY(animation.isRunning());
- QTest::qWait(animation.duration());
- QTIMED_COMPARE(rect.rotation(), qreal(270));
-
- rect.setRotation(0);
- animation.start();
- animation.pause();
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.rotation(), qreal(135));
-}
-
-void tst_qdeclarativeanimations::simplePath()
-{
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathAnimation.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
- QVERIFY(redRect);
- QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
- QVERIFY(pathAnim);
-
- QCOMPARE(pathAnim->duration(), 100);
- QCOMPARE(pathAnim->target(), redRect);
-
- pathAnim->start();
- pathAnim->pause();
-
- pathAnim->setCurrentTime(30);
- QCOMPARE(redRect->x(), qreal(167));
- QCOMPARE(redRect->y(), qreal(104));
-
- pathAnim->setCurrentTime(100);
- QCOMPARE(redRect->x(), qreal(300));
- QCOMPARE(redRect->y(), qreal(300));
-
- //verify animation runs to end
- pathAnim->start();
- QCOMPARE(redRect->x(), qreal(50));
- QCOMPARE(redRect->y(), qreal(50));
- QTRY_COMPARE(redRect->x(), qreal(300));
- QCOMPARE(redRect->y(), qreal(300));
-
- pathAnim->setOrientation(QQuickPathAnimation::RightFirst);
- QCOMPARE(pathAnim->orientation(), QQuickPathAnimation::RightFirst);
- pathAnim->start();
- QTRY_VERIFY(redRect->rotation() != 0);
- pathAnim->stop();
-
- delete rect;
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathAnimation2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
- QVERIFY(redRect);
- QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
- QVERIFY(pathAnim);
-
- QCOMPARE(pathAnim->orientation(), QQuickPathAnimation::RightFirst);
- QCOMPARE(pathAnim->endRotation(), qreal(0));
- QCOMPARE(pathAnim->orientationEntryDuration(), 10);
- QCOMPARE(pathAnim->orientationExitDuration(), 10);
-
- pathAnim->start();
- pathAnim->pause();
- QCOMPARE(redRect->x(), qreal(50));
- QCOMPARE(redRect->y(), qreal(50));
- QCOMPARE(redRect->rotation(), qreal(-360));
-
- pathAnim->setCurrentTime(50);
- QCOMPARE(redRect->x(), qreal(175));
- QCOMPARE(redRect->y(), qreal(175));
- QCOMPARE(redRect->rotation(), qreal(-315));
-
- pathAnim->setCurrentTime(100);
- QCOMPARE(redRect->x(), qreal(300));
- QCOMPARE(redRect->y(), qreal(300));
- QCOMPARE(redRect->rotation(), qreal(0));
-
- delete rect;
- }
-}
-
-void tst_qdeclarativeanimations::simpleAnchor()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("reanchor.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *greenRect = rect->findChild<QQuickRectangle*>();
- QVERIFY(greenRect);
-
- QCOMPARE(rect->state(), QLatin1String("reanchored"));
- QCOMPARE(greenRect->x(), qreal(10));
- QCOMPARE(greenRect->y(), qreal(0));
- QCOMPARE(greenRect->width(), qreal(190));
- QCOMPARE(greenRect->height(), qreal(150));
-
- rect->setState("");
-
- //verify animation in progress
- QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0);
- QVERIFY(greenRect->y() > 0 && greenRect->y() < 10);
- QVERIFY(greenRect->width() < 190 && greenRect->width() > 150);
- QVERIFY(greenRect->height() > 150 && greenRect->height() < 190);
-
- //verify end state ("")
- QTRY_COMPARE(greenRect->x(), qreal(0));
- QCOMPARE(greenRect->y(), qreal(10));
- QCOMPARE(greenRect->width(), qreal(150));
- QCOMPARE(greenRect->height(), qreal(190));
-
- rect->setState("reanchored2");
-
- //verify animation in progress
- QTRY_VERIFY(greenRect->y() > 10 && greenRect->y() < 50);
- QVERIFY(greenRect->height() > 125 && greenRect->height() < 190);
- //NOTE: setting left/right anchors to undefined removes the anchors, but does not resize.
- QCOMPARE(greenRect->x(), qreal(0));
- QCOMPARE(greenRect->width(), qreal(150));
-
- //verify end state ("reanchored2")
- QTRY_COMPARE(greenRect->y(), qreal(50));
- QCOMPARE(greenRect->height(), qreal(125));
- QCOMPARE(greenRect->x(), qreal(0));
- QCOMPARE(greenRect->width(), qreal(150));
-
- rect->setState("reanchored");
-
- //verify animation in progress
- QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0);
- QVERIFY(greenRect->y() > 0 && greenRect->y() < 50);
- QVERIFY(greenRect->width() < 190 && greenRect->width() > 150);
- QVERIFY(greenRect->height() > 125 && greenRect->height() < 150);
-
- //verify end state ("reanchored")
- QTRY_COMPARE(greenRect->x(), qreal(10));
- QCOMPARE(greenRect->y(), qreal(0));
- QCOMPARE(greenRect->width(), qreal(190));
- QCOMPARE(greenRect->height(), qreal(150));
-
- rect->setState("reanchored2");
-
- //verify animation in progress
- QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0);
- QVERIFY(greenRect->y() > 0 && greenRect->y() < 50);
- QVERIFY(greenRect->width() < 190 && greenRect->width() > 150);
- QVERIFY(greenRect->height() > 125 && greenRect->height() < 150);
-
- //verify end state ("reanchored2")
- QTRY_COMPARE(greenRect->x(), qreal(0));
- QCOMPARE(greenRect->y(), qreal(50));
- QCOMPARE(greenRect->width(), qreal(150));
- QCOMPARE(greenRect->height(), qreal(125));
-
- delete rect;
-}
-
-void tst_qdeclarativeanimations::reparent()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("reparent.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *target = rect->findChild<QQuickRectangle*>("target");
- QVERIFY(target);
-
- QCOMPARE(target->parentItem(), rect);
- QCOMPARE(target->x(), qreal(0));
- QCOMPARE(target->y(), qreal(0));
- QCOMPARE(target->width(), qreal(50));
- QCOMPARE(target->height(), qreal(50));
- QCOMPARE(target->rotation(), qreal(0));
- QCOMPARE(target->scale(), qreal(1));
-
- rect->setState("state1");
-
- QQuickRectangle *viaParent = rect->findChild<QQuickRectangle*>("viaParent");
- QVERIFY(viaParent);
-
- QQuickRectangle *newParent = rect->findChild<QQuickRectangle*>("newParent");
- QVERIFY(newParent);
-
- QTest::qWait(100);
-
- //animation in progress
- QTRY_COMPARE(target->parentItem(), viaParent);
- QVERIFY(target->x() > -100 && target->x() < 50);
- QVERIFY(target->y() > -100 && target->y() < 50);
- QVERIFY(target->width() > 50 && target->width() < 100);
- QCOMPARE(target->height(), qreal(50));
- QCOMPARE(target->rotation(), qreal(-45));
- QCOMPARE(target->scale(), qreal(.5));
-
- //end state
- QTRY_COMPARE(target->parentItem(), newParent);
- QCOMPARE(target->x(), qreal(50));
- QCOMPARE(target->y(), qreal(50));
- QCOMPARE(target->width(), qreal(100));
- QCOMPARE(target->height(), qreal(50));
- QCOMPARE(target->rotation(), qreal(0));
- QCOMPARE(target->scale(), qreal(1));
-
- delete rect;
-}
-
-void tst_qdeclarativeanimations::pathInterpolator()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathInterpolator.qml"));
- QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create());
- QVERIFY(interpolator);
-
- QCOMPARE(interpolator->progress(), qreal(0));
- QCOMPARE(interpolator->x(), qreal(50));
- QCOMPARE(interpolator->y(), qreal(50));
- QCOMPARE(interpolator->angle(), qreal(0));
-
- interpolator->setProgress(.5);
- QCOMPARE(interpolator->progress(), qreal(.5));
- QCOMPARE(interpolator->x(), qreal(175));
- QCOMPARE(interpolator->y(), qreal(175));
- QCOMPARE(interpolator->angle(), qreal(90));
-
- interpolator->setProgress(1);
- QCOMPARE(interpolator->progress(), qreal(1));
- QCOMPARE(interpolator->x(), qreal(300));
- QCOMPARE(interpolator->y(), qreal(300));
- QCOMPARE(interpolator->angle(), qreal(0));
-}
-
-void tst_qdeclarativeanimations::pathInterpolatorBackwardJump()
-{
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathInterpolatorBack.qml"));
- QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create());
- QVERIFY(interpolator);
-
- QCOMPARE(interpolator->progress(), qreal(0));
- QCOMPARE(interpolator->x(), qreal(50));
- QCOMPARE(interpolator->y(), qreal(50));
- QCOMPARE(interpolator->angle(), qreal(90));
-
- interpolator->setProgress(.5);
- QCOMPARE(interpolator->progress(), qreal(.5));
- QCOMPARE(interpolator->x(), qreal(100));
- QCOMPARE(interpolator->y(), qreal(75));
- QCOMPARE(interpolator->angle(), qreal(270));
-
- interpolator->setProgress(1);
- QCOMPARE(interpolator->progress(), qreal(1));
- QCOMPARE(interpolator->x(), qreal(200));
- QCOMPARE(interpolator->y(), qreal(50));
- QCOMPARE(interpolator->angle(), qreal(0));
-
- //make sure we don't get caught in infinite loop here
- interpolator->setProgress(0);
- QCOMPARE(interpolator->progress(), qreal(0));
- QCOMPARE(interpolator->x(), qreal(50));
- QCOMPARE(interpolator->y(), qreal(50));
- QCOMPARE(interpolator->angle(), qreal(90));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathInterpolatorBack2.qml"));
- QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create());
- QVERIFY(interpolator);
-
- QCOMPARE(interpolator->progress(), qreal(0));
- QCOMPARE(interpolator->x(), qreal(200));
- QCOMPARE(interpolator->y(), qreal(280));
- QCOMPARE(interpolator->angle(), qreal(180));
-
- interpolator->setProgress(1);
- QCOMPARE(interpolator->progress(), qreal(1));
- QCOMPARE(interpolator->x(), qreal(0));
- QCOMPARE(interpolator->y(), qreal(80));
- QCOMPARE(interpolator->angle(), qreal(180));
-
- //make sure we don't get caught in infinite loop here
- interpolator->setProgress(0);
- QCOMPARE(interpolator->progress(), qreal(0));
- QCOMPARE(interpolator->x(), qreal(200));
- QCOMPARE(interpolator->y(), qreal(280));
- QCOMPARE(interpolator->angle(), qreal(180));
- }
-}
-
-void tst_qdeclarativeanimations::pathWithNoStart()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathAnimationNoStart.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
- QVERIFY(redRect);
- QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
- QVERIFY(pathAnim);
-
- pathAnim->start();
- pathAnim->pause();
- QCOMPARE(redRect->x(), qreal(50));
- QCOMPARE(redRect->y(), qreal(50));
-
- pathAnim->setCurrentTime(50);
- QCOMPARE(redRect->x(), qreal(175));
- QCOMPARE(redRect->y(), qreal(175));
-
- pathAnim->setCurrentTime(100);
- QCOMPARE(redRect->x(), qreal(300));
- QCOMPARE(redRect->y(), qreal(300));
-
- redRect->setX(100);
- redRect->setY(100);
- pathAnim->start();
- QCOMPARE(redRect->x(), qreal(100));
- QCOMPARE(redRect->y(), qreal(100));
- QTRY_COMPARE(redRect->x(), qreal(300));
- QCOMPARE(redRect->y(), qreal(300));
-}
-
-void tst_qdeclarativeanimations::alwaysRunToEnd()
-{
- QQuickRectangle rect;
- QDeclarativePropertyAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("x");
- animation.setTo(200);
- animation.setDuration(1000);
- animation.setLoops(-1);
- animation.setAlwaysRunToEnd(true);
- QVERIFY(animation.loops() == -1);
- QVERIFY(animation.alwaysRunToEnd() == true);
- animation.start();
- QTest::qWait(1500);
- animation.stop();
- QVERIFY(rect.x() != qreal(200));
- QTest::qWait(500);
- QTIMED_COMPARE(rect.x(), qreal(200));
-}
-
-void tst_qdeclarativeanimations::complete()
-{
- QQuickRectangle rect;
- QDeclarativePropertyAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("x");
- animation.setFrom(1);
- animation.setTo(200);
- animation.setDuration(500);
- QVERIFY(animation.from() == 1);
- animation.start();
- QTest::qWait(50);
- animation.stop();
- QVERIFY(rect.x() != qreal(200));
- animation.start();
- QTest::qWait(50);
- QVERIFY(animation.isRunning());
- animation.complete();
- QCOMPARE(rect.x(), qreal(200));
-}
-
-void tst_qdeclarativeanimations::resume()
-{
- QQuickRectangle rect;
- QDeclarativePropertyAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("x");
- animation.setFrom(10);
- animation.setTo(200);
- animation.setDuration(1000);
- QVERIFY(animation.from() == 10);
-
- animation.start();
- QTest::qWait(400);
- animation.pause();
- qreal x = rect.x();
- QVERIFY(x != qreal(200) && x != qreal(10));
- QVERIFY(animation.isRunning());
- QVERIFY(animation.isPaused());
-
- animation.resume();
- QVERIFY(animation.isRunning());
- QVERIFY(!animation.isPaused());
- QTest::qWait(400);
- animation.stop();
- QVERIFY(rect.x() > x);
-}
-
-void tst_qdeclarativeanimations::dotProperty()
-{
- QQuickRectangle rect;
- QDeclarativeNumberAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("border.width");
- animation.setTo(10);
- animation.start();
- QTest::qWait(animation.duration()+50);
- QTIMED_COMPARE(rect.border()->width(), 10.0);
-
- rect.border()->setWidth(0);
- animation.start();
- animation.pause();
- animation.setCurrentTime(125);
- QVERIFY(animation.currentTime() == 125);
- QCOMPARE(rect.border()->width(), 5.0);
-}
-
-void tst_qdeclarativeanimations::badTypes()
-{
- //don't crash
- {
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("badtype1.qml"));
-
- qApp->processEvents();
-
- delete view;
- }
-
- //make sure we get a compiler error
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("badtype2.qml"));
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- c.create();
-
- QVERIFY(c.errors().count() == 1);
- QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: number expected"));
- }
-
- //make sure we get a compiler error
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("badtype3.qml"));
- QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- c.create();
-
- QVERIFY(c.errors().count() == 1);
- QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: color expected"));
- }
-
- //don't crash
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("badtype4.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("state1");
- QTest::qWait(1000 + 50);
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("MyRect");
- QVERIFY(myRect);
- QCOMPARE(myRect->x(),qreal(200));
- }
-}
-
-void tst_qdeclarativeanimations::badProperties()
-{
- //make sure we get a runtime error
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c1(&engine, testFileUrl("badproperty1.qml"));
- QByteArray message = testFileUrl("badproperty1.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\"";
- QTest::ignoreMessage(QtWarningMsg, message);
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c1.create());
- QVERIFY(rect);
-
- QDeclarativeComponent c2(&engine, testFileUrl("badproperty2.qml"));
- message = testFileUrl("badproperty2.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\"";
- QTest::ignoreMessage(QtWarningMsg, message);
- rect = qobject_cast<QQuickRectangle*>(c2.create());
- QVERIFY(rect);
-
- //### should we warn here are well?
- //rect->setState("state1");
- }
-}
-
-//test animating mixed types with property animation in a transition
-//for example, int + real; color + real; etc
-void tst_qdeclarativeanimations::mixedTypes()
-{
- //assumes border.width stays a real -- not real robust
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("mixedtype1.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("state1");
- QTest::qWait(500);
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("MyRect");
- QVERIFY(myRect);
-
- //rather inexact -- is there a better way?
- QVERIFY(myRect->x() > 100 && myRect->x() < 200);
- QVERIFY(myRect->border()->width() > 1 && myRect->border()->width() < 10);
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("mixedtype2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("state1");
- QTest::qWait(500);
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("MyRect");
- QVERIFY(myRect);
-
- //rather inexact -- is there a better way?
- QVERIFY(myRect->x() > 100 && myRect->x() < 200);
-#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__)
- QEXPECT_FAIL("", "Fails on this platform - QTBUG-23385", Continue);
-#endif
- QVERIFY(myRect->color() != QColor("red") && myRect->color() != QColor("blue"));
- }
-}
-
-void tst_qdeclarativeanimations::properties()
-{
- const int waitDuration = 300;
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("properties2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("properties3.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(300));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("properties4.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->y(),qreal(200));
- QTIMED_COMPARE(myRect->x(),qreal(100));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("properties5.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(100));
- QTIMED_COMPARE(myRect->y(),qreal(200));
- }
-}
-
-void tst_qdeclarativeanimations::propertiesTransition()
-{
- const int waitDuration = 300;
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QQuickItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(200));
- QCOMPARE(myRect->y(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->y(),qreal(200));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition3.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QQuickItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(200));
- QCOMPARE(myRect->y(),qreal(100));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition4.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QQuickItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition5.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QQuickItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
- /*{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition6.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QQuickItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(100));
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(100));
- }*/
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition7.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
- QTest::qWait(waitDuration);
- QTIMED_COMPARE(myRect->x(),qreal(200));
- }
-
-}
-
-void tst_qdeclarativeanimations::pathTransition()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathTransition.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("redRect");
- QVERIFY(myRect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- QTRY_VERIFY(myRect->x() < 500 && myRect->x() > 100 && myRect->y() > 50 && myRect->y() < 700 ); //animation started
- QTRY_VERIFY(qFuzzyCompare(myRect->x(), qreal(100)) && qFuzzyCompare(myRect->y(), qreal(700)));
- QTest::qWait(100);
-
- QQuickItemPrivate::get(rect)->setState("");
- QTRY_VERIFY(myRect->x() < 500 && myRect->x() > 100 && myRect->y() > 50 && myRect->y() < 700 ); //animation started
- QTRY_VERIFY(qFuzzyCompare(myRect->x(), qreal(500)) && qFuzzyCompare(myRect->y(), qreal(50)));
-}
-
-void tst_qdeclarativeanimations::disabledTransition()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("disabledTransition.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
- QVERIFY(myRect);
-
- QDeclarativeTransition *trans = rect->findChild<QDeclarativeTransition*>();
- QVERIFY(trans);
-
- QCOMPARE(trans->enabled(), false);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- QCOMPARE(myRect->x(),qreal(200));
-
- trans->setEnabled(true);
-
- QQuickItemPrivate::get(rect)->setState("");
- QCOMPARE(myRect->x(),qreal(200));
- QTest::qWait(300);
- QTIMED_COMPARE(myRect->x(),qreal(100));
-}
-
-void tst_qdeclarativeanimations::invalidDuration()
-{
- QDeclarativePropertyAnimation *animation = new QDeclarativePropertyAnimation;
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML PropertyAnimation: Cannot set a duration of < 0");
- animation->setDuration(-1);
- QCOMPARE(animation->duration(), 250);
-
- QDeclarativePauseAnimation *pauseAnimation = new QDeclarativePauseAnimation;
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML PauseAnimation: Cannot set a duration of < 0");
- pauseAnimation->setDuration(-1);
- QCOMPARE(pauseAnimation->duration(), 250);
-}
-
-void tst_qdeclarativeanimations::attached()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("attached.qml"));
- QTest::ignoreMessage(QtDebugMsg, "off");
- QTest::ignoreMessage(QtDebugMsg, "on");
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-}
-
-void tst_qdeclarativeanimations::propertyValueSourceDefaultStart()
-{
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("valuesource.qml"));
-
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim);
- QVERIFY(myAnim->isRunning());
- }
-
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("valuesource2.qml"));
-
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim);
- QVERIFY(myAnim->isRunning() == false);
- }
-
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("dontAutoStart.qml"));
-
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && !myAnim->qtAnimation());
- //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped);
- }
-}
-
-
-void tst_qdeclarativeanimations::dontStart()
-{
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("dontStart.qml"));
-
- QString warning = c.url().toString() + ":14:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && !myAnim->qtAnimation());
- //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped);
- }
-
- {
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("dontStart2.qml"));
-
- QString warning = c.url().toString() + ":15:17: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && !myAnim->qtAnimation());
- //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped);
- }
-}
-
-void tst_qdeclarativeanimations::easingProperties()
-{
- {
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 2.0\nNumberAnimation { easing.type: \"InOutQuad\" }";
- QDeclarativeComponent animationComponent(&engine);
- animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
-
- QVERIFY(animObject != 0);
- QCOMPARE(animObject->easing().type(), QEasingCurve::InOutQuad);
- }
-
- {
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"OutBounce\"; easing.amplitude: 5.0 }";
- QDeclarativeComponent animationComponent(&engine);
- animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
-
- QVERIFY(animObject != 0);
- QCOMPARE(animObject->easing().type(), QEasingCurve::OutBounce);
- QCOMPARE(animObject->easing().amplitude(), 5.0);
- }
-
- {
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"OutElastic\"; easing.amplitude: 5.0; easing.period: 3.0}";
- QDeclarativeComponent animationComponent(&engine);
- animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
-
- QVERIFY(animObject != 0);
- QCOMPARE(animObject->easing().type(), QEasingCurve::OutElastic);
- QCOMPARE(animObject->easing().amplitude(), 5.0);
- QCOMPARE(animObject->easing().period(), 3.0);
- }
-
- {
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"InOutBack\"; easing.overshoot: 2 }";
- QDeclarativeComponent animationComponent(&engine);
- animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
-
- QVERIFY(animObject != 0);
- QCOMPARE(animObject->easing().type(), QEasingCurve::InOutBack);
- QCOMPARE(animObject->easing().overshoot(), 2.0);
- }
-
- {
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"Bezier\"; easing.bezierCurve: [0.5, 0.2, 0.13, 0.65, 1.0, 1.0] }";
- QDeclarativeComponent animationComponent(&engine);
- animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativePropertyAnimation *animObject = qobject_cast<QDeclarativePropertyAnimation*>(animationComponent.create());
-
- QVERIFY(animObject != 0);
- QCOMPARE(animObject->easing().type(), QEasingCurve::BezierSpline);
- QList<QPointF> points = animObject->easing().cubicBezierSpline();
- QCOMPARE(points.count(), 3);
- QCOMPARE(points.at(0), QPointF(0.5, 0.2));
- QCOMPARE(points.at(1), QPointF(0.13, 0.65));
- QCOMPARE(points.at(2), QPointF(1.0, 1.0));
- }
-}
-
-void tst_qdeclarativeanimations::rotation()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("rotation.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *rr = rect->findChild<QQuickRectangle*>("rr");
- QQuickRectangle *rr2 = rect->findChild<QQuickRectangle*>("rr2");
- QQuickRectangle *rr3 = rect->findChild<QQuickRectangle*>("rr3");
- QQuickRectangle *rr4 = rect->findChild<QQuickRectangle*>("rr4");
-
- QQuickItemPrivate::get(rect)->setState("state1");
- QTest::qWait(800);
- qreal r1 = rr->rotation();
- qreal r2 = rr2->rotation();
- qreal r3 = rr3->rotation();
- qreal r4 = rr4->rotation();
-
- QVERIFY(r1 > qreal(0) && r1 < qreal(370));
- QVERIFY(r2 > qreal(0) && r2 < qreal(370));
- QVERIFY(r3 < qreal(0) && r3 > qreal(-350));
- QVERIFY(r4 > qreal(0) && r4 < qreal(10));
- QCOMPARE(r1,r2);
- QVERIFY(r4 < r2);
-
- QTest::qWait(800);
- QTIMED_COMPARE(rr->rotation() + rr2->rotation() + rr3->rotation() + rr4->rotation(), qreal(370*4));
-}
-
-void tst_qdeclarativeanimations::runningTrueBug()
-{
- //ensure we start correctly when "running: true" is explicitly set
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("runningTrueBug.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *cloud = rect->findChild<QQuickRectangle*>("cloud");
- QVERIFY(cloud);
- QTest::qWait(1000);
- 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, testFileUrl("nonTransitionBug.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QQuickRectangle *mover = rect->findChild<QQuickRectangle*>("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));
-}
-
-//QTBUG-14042
-void tst_qdeclarativeanimations::registrationBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("registrationBug.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
- QTRY_COMPARE(rect->property("value"), QVariant(int(100)));
-}
-
-void tst_qdeclarativeanimations::doubleRegistrationBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("doubleRegistrationBug.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QDeclarativeAbstractAnimation *anim = rect->findChild<QDeclarativeAbstractAnimation*>("animation");
- QVERIFY(anim != 0);
- QTRY_COMPARE(anim->qtAnimation()->state(), QAbstractAnimationJob::Stopped);
-}
-
-//QTBUG-16736
-void tst_qdeclarativeanimations::alwaysRunToEndRestartBug()
-{
- QQuickRectangle rect;
- QDeclarativePropertyAnimation animation;
- animation.setTargetObject(&rect);
- animation.setProperty("x");
- animation.setTo(200);
- animation.setDuration(1000);
- animation.setLoops(-1);
- animation.setAlwaysRunToEnd(true);
- QVERIFY(animation.loops() == -1);
- QVERIFY(animation.alwaysRunToEnd() == true);
- animation.start();
- animation.stop();
- animation.start();
- animation.stop();
- QTest::qWait(500);
- QVERIFY(rect.x() != qreal(200));
- QTest::qWait(800);
- QTIMED_COMPARE(rect.x(), qreal(200));
- QCOMPARE(static_cast<QDeclarativeAbstractAnimation*>(&animation)->qtAnimation()->state(), QAbstractAnimationJob::Stopped);
-}
-
-//QTBUG-20227
-void tst_qdeclarativeanimations::transitionAssignmentBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("transitionAssignmentBug.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->property("nullObject").toBool(), false);
-}
-
-//QTBUG-19080
-void tst_qdeclarativeanimations::pauseBindingBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("pauseBindingBug.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
- QDeclarativeAbstractAnimation *anim = rect->findChild<QDeclarativeAbstractAnimation*>("animation");
- QVERIFY(anim->qtAnimation()->state() == QAbstractAnimationJob::Paused);
-
- delete rect;
-}
-
-//QTBUG-13598
-void tst_qdeclarativeanimations::pauseBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("pauseBug.qml"));
- QDeclarativeAbstractAnimation *anim = qobject_cast<QDeclarativeAbstractAnimation*>(c.create());
- QVERIFY(anim != 0);
- QCOMPARE(anim->qtAnimation()->state(), QAbstractAnimationJob::Paused);
- QCOMPARE(anim->isPaused(), true);
- QCOMPARE(anim->isRunning(), true);
-
- delete anim;
-}
-
-//QTBUG-23092
-void tst_qdeclarativeanimations::loopingBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("looping.qml"));
- QObject *obj = c.create();
-
- QDeclarativeAbstractAnimation *anim = obj->findChild<QDeclarativeAbstractAnimation*>();
- QVERIFY(anim != 0);
- QCOMPARE(anim->qtAnimation()->totalDuration(), 300);
- QCOMPARE(anim->isRunning(), true);
- QTRY_COMPARE(static_cast<QAnimationGroupJob*>(anim->qtAnimation())->firstChild()->currentLoop(), 2);
- QTRY_COMPARE(anim->isRunning(), false);
-
- QQuickRectangle *rect = obj->findChild<QQuickRectangle*>();
- QVERIFY(rect != 0);
- QCOMPARE(rect->rotation(), qreal(90));
-
- delete obj;
-}
-
-QTEST_MAIN(tst_qdeclarativeanimations)
-
-#include "tst_qdeclarativeanimations.moc"
diff --git a/tests/auto/qtquick2/qdeclarativeapplication/qdeclarativeapplication.pro b/tests/auto/qtquick2/qdeclarativeapplication/qdeclarativeapplication.pro
deleted file mode 100644
index b86f431d31..0000000000
--- a/tests/auto/qtquick2/qdeclarativeapplication/qdeclarativeapplication.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativeapplication
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativeapplication.cpp
-QT += core-private gui-private declarative-private quick-private testlib
-
diff --git a/tests/auto/qtquick2/qdeclarativeapplication/tst_qdeclarativeapplication.cpp b/tests/auto/qtquick2/qdeclarativeapplication/tst_qdeclarativeapplication.cpp
deleted file mode 100644
index 6b921a7356..0000000000
--- a/tests/auto/qtquick2/qdeclarativeapplication/tst_qdeclarativeapplication.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickview.h>
-#include <QtGui/qinputmethod.h>
-
-class tst_qdeclarativeapplication : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativeapplication();
-
-private slots:
- void active();
- void layoutDirection();
- void inputPanel();
- void inputMethod();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativeapplication::tst_qdeclarativeapplication()
-{
-}
-
-void tst_qdeclarativeapplication::active()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Item { property bool active: Qt.application.active }", QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
- QVERIFY(item);
- QQuickView view;
- item->setParentItem(view.rootObject());
-
- // not active
- QVERIFY(!item->property("active").toBool());
- QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0);
-
- // active
- view.show();
- view.requestActivateWindow();
- QTest::qWait(50);
- QEXPECT_FAIL("", "QTBUG-21573", Abort);
- QTRY_COMPARE(view.status(), QQuickView::Ready);
- QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0);
-
-#if 0
- // QGuiApplication has no equivalent of setActiveWindow(0). QTBUG-21573
- // Is this different to clearing the active state of the window or can it be removed?
- // On Mac, setActiveWindow(0) on mac does not deactivate the current application,
- // must switch to a different app or hide the current app to trigger this
- // on mac, setActiveWindow(0) on mac does not deactivate the current application
- // (you have to switch to a different app or hide the current app to trigger this)
-
- // not active again
- QGuiApplication::setActiveWindow(0);
- QVERIFY(!item->property("active").toBool());
- QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0);
-#endif
-
-}
-
-void tst_qdeclarativeapplication::layoutDirection()
-{
-
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Item { property bool layoutDirection: Qt.application.layoutDirection }", QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
- QVERIFY(item);
- QQuickView view;
- item->setParentItem(view.rootObject());
-
- // not mirrored
- QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight);
-
- // mirrored
- QGuiApplication::setLayoutDirection(Qt::RightToLeft);
- QEXPECT_FAIL("", "QTBUG-21573", Abort);
- QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::RightToLeft);
-
- // not mirrored again
- QGuiApplication::setLayoutDirection(Qt::LeftToRight);
- QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight);
-}
-
-void tst_qdeclarativeapplication::inputPanel()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Item { property variant inputPanel: Qt.application.inputPanel }", QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
- QVERIFY(item);
- QQuickView view;
- item->setParentItem(view.rootObject());
-
- // check that the inputPanel property maches with application's input panel
- QCOMPARE(qvariant_cast<QObject*>(item->property("inputPanel")), qApp->inputMethod());
-}
-
-void tst_qdeclarativeapplication::inputMethod()
-{
- // technically not in QDeclarativeApplication, but testing anyway here
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Item { property variant inputMethod: Qt.inputMethod }", QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
- QVERIFY(item);
- QQuickView view;
- item->setParentItem(view.rootObject());
-
- // check that the inputMethod property maches with application's input method
- QCOMPARE(qvariant_cast<QObject*>(item->property("inputMethod")), qApp->inputMethod());
-}
-
-
-QTEST_MAIN(tst_qdeclarativeapplication)
-
-#include "tst_qdeclarativeapplication.moc"
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/qdeclarativebehaviors.pro b/tests/auto/qtquick2/qdeclarativebehaviors/qdeclarativebehaviors.pro
deleted file mode 100644
index 7089f1ce57..0000000000
--- a/tests/auto/qtquick2/qdeclarativebehaviors/qdeclarativebehaviors.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativebehaviors
-SOURCES += tst_qdeclarativebehaviors.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/qtquick2/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
deleted file mode 100644
index c1e60f1560..0000000000
--- a/tests/auto/qtquick2/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
+++ /dev/null
@@ -1,473 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <qsignalspy.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qdeclarativebehavior_p.h>
-#include <QtQuick/private/qdeclarativeanimation_p.h>
-#include <private/qquickitem_p.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativebehaviors : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativebehaviors() {}
-
-private slots:
- void init() { qApp->processEvents(); } //work around animation timer bug (QTBUG-22865)
- void simpleBehavior();
- void scriptTriggered();
- void cppTriggered();
- void loop();
- void colorBehavior();
- void parentBehavior();
- void replaceBinding();
- //void transitionOverrides();
- void group();
- void valueType();
- void emptyBehavior();
- void explicitSelection();
- void nonSelectingBehavior();
- void reassignedAnimation();
- void disabled();
- void dontStart();
- void startup();
- void groupedPropertyCrash();
- void runningTrue();
- void sameValue();
- void delayedRegistration();
- void startOnCompleted();
-};
-
-void tst_qdeclarativebehaviors::simpleBehavior()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("simple.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
- QTRY_VERIFY(qobject_cast<QDeclarativeBehavior*>(rect->findChild<QDeclarativeBehavior*>("MyBehavior"))->animation());
-
- QQuickItemPrivate::get(rect)->setState("moved");
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
- //i.e. the behavior has been triggered
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::scriptTriggered()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("scripttrigger.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- rect->setColor(QColor("red"));
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
- //i.e. the behavior has been triggered
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::cppTriggered()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("cpptrigger.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QTRY_VERIFY(innerRect);
-
- innerRect->setProperty("x", 200);
- QTRY_VERIFY(innerRect->x() > 0);
- QTRY_VERIFY(innerRect->x() < 200); //i.e. the behavior has been triggered
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::loop()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("loop.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- //don't crash
- QQuickItemPrivate::get(rect)->setState("moved");
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::colorBehavior()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("color.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("red");
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->color() != QColor("red"));
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->color() != QColor("green"));
- //i.e. the behavior has been triggered
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::parentBehavior()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("parent.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("reparented");
- QTRY_VERIFY(rect->findChild<QQuickRectangle*>("MyRect")->parentItem() != rect->findChild<QQuickItem*>("NewParent"));
- QTRY_VERIFY(rect->findChild<QQuickRectangle*>("MyRect")->parentItem() == rect->findChild<QQuickItem*>("NewParent"));
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::replaceBinding()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("binding.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QTRY_VERIFY(innerRect);
- QTRY_VERIFY(innerRect->x() > 0);
- QTRY_VERIFY(innerRect->x() < 200);
- //i.e. the behavior has been triggered
- QTRY_COMPARE(innerRect->x(), (qreal)200);
- rect->setProperty("basex", 10);
- QTRY_COMPARE(innerRect->x(), (qreal)200);
- rect->setProperty("movedx", 210);
- QTRY_COMPARE(innerRect->x(), (qreal)210);
-
- QQuickItemPrivate::get(rect)->setState("");
- QTRY_VERIFY(innerRect->x() > 10);
- QTRY_VERIFY(innerRect->x() < 210); //i.e. the behavior has been triggered
- QTRY_COMPARE(innerRect->x(), (qreal)10);
- rect->setProperty("movedx", 200);
- QTRY_COMPARE(innerRect->x(), (qreal)10);
- rect->setProperty("basex", 20);
- QTRY_COMPARE(innerRect->x(), (qreal)20);
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::group()
-{
- /* XXX TODO Create a test element for this case.
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("groupProperty.qml")));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- qDebug() << c.errorString();
- QTRY_VERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- //QTest::qWait(200);
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
- //i.e. the behavior has been triggered
-
- delete rect;
- }
- */
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("groupProperty2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QTRY_VERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->border()->width() > 0);
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->border()->width() < 4);
- //i.e. the behavior has been triggered
-
- delete rect;
- }
-}
-
-void tst_qdeclarativebehaviors::valueType()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("valueType.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- //QTBUG-20827
- QCOMPARE(rect->color(), QColor::fromRgb(255,0,255));
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::emptyBehavior()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("empty.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- qreal x = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::explicitSelection()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("explicit.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
- QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
- //i.e. the behavior has been triggered
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::nonSelectingBehavior()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("nonSelecting2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- qreal x = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::reassignedAnimation()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("reassignedAnimation.qml"));
- QString warning = testFileUrl("reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior.";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
- QCOMPARE(qobject_cast<QDeclarativeNumberAnimation*>(
- rect->findChild<QDeclarativeBehavior*>("MyBehavior")->animation())->duration(), 200);
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::disabled()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("disabled.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
- QCOMPARE(rect->findChild<QDeclarativeBehavior*>("MyBehavior")->enabled(), false);
-
- QQuickItemPrivate::get(rect)->setState("moved");
- qreal x = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x();
- QCOMPARE(x, qreal(200)); //should change immediately
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::dontStart()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("dontStart.qml"));
-
- QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
- QVERIFY(myAnim && !myAnim->qtAnimation());
-
- delete rect;
-}
-
-void tst_qdeclarativebehaviors::startup()
-{
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("startup.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *innerRect = rect->findChild<QQuickRectangle*>("innerRect");
- QVERIFY(innerRect);
-
- QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately
-
- delete rect;
- }
-
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("startup2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *innerRect = rect->findChild<QQuickRectangle*>("innerRect");
- QVERIFY(innerRect);
-
- QQuickText *text = rect->findChild<QQuickText*>();
- QVERIFY(text);
-
- QCOMPARE(innerRect->x(), text->width()); //should be set immediately
-
- delete rect;
- }
-}
-
-//QTBUG-10799
-void tst_qdeclarativebehaviors::groupedPropertyCrash()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("groupedPropertyCrash.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect); //don't crash
-
- delete rect;
-}
-
-//QTBUG-5491
-void tst_qdeclarativebehaviors::runningTrue()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("runningTrue.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeAbstractAnimation *animation = rect->findChild<QDeclarativeAbstractAnimation*>("rotAnim");
- QVERIFY(animation);
-
- QSignalSpy runningSpy(animation, SIGNAL(runningChanged(bool)));
- rect->setProperty("myValue", 180);
- QTRY_VERIFY(runningSpy.count() > 0);
-
- delete rect;
-}
-
-//QTBUG-12295
-void tst_qdeclarativebehaviors::sameValue()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("qtbug12295.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *target = rect->findChild<QQuickRectangle*>("myRect");
- QVERIFY(target);
-
- target->setX(100);
- QCOMPARE(target->x(), qreal(100));
-
- target->setProperty("x", 0);
- QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100));
- QTRY_VERIFY(target->x() == qreal(0)); //make sure Behavior has finished.
-
- target->setX(100);
- QCOMPARE(target->x(), qreal(100));
-
- //this is the main point of the test -- the behavior needs to be triggered again
- //even though we set 0 twice in a row.
- target->setProperty("x", 0);
- QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100));
-
- delete rect;
-}
-
-//QTBUG-18362
-void tst_qdeclarativebehaviors::delayedRegistration()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("delayedRegistration.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickItem *innerRect = rect->property("myItem").value<QQuickItem*>();
- QVERIFY(innerRect != 0);
-
- QCOMPARE(innerRect->property("x").toInt(), int(0));
-
- QTRY_COMPARE(innerRect->property("x").toInt(), int(100));
-}
-
-//QTBUG-22555
-void tst_qdeclarativebehaviors::startOnCompleted()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("startOnCompleted.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickItem *innerRect = rect->findChild<QQuickRectangle*>();
- QVERIFY(innerRect != 0);
-
- QCOMPARE(innerRect->property("x").toInt(), int(0));
-
- QTRY_COMPARE(innerRect->property("x").toInt(), int(100));
-
- delete rect;
-}
-
-QTEST_MAIN(tst_qdeclarativebehaviors)
-
-#include "tst_qdeclarativebehaviors.moc"
diff --git a/tests/auto/qtquick2/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/qtquick2/qdeclarativefontloader/qdeclarativefontloader.pro
deleted file mode 100644
index 0e84fc9dce..0000000000
--- a/tests/auto/qtquick2/qdeclarativefontloader/qdeclarativefontloader.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativefontloader
-macx:CONFIG -= app_bundle
-
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qdeclarativefontloader.cpp \
- ../../shared/testhttpserver.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/qtquick2/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
deleted file mode 100644
index e3571a411c..0000000000
--- a/tests/auto/qtquick2/qdeclarativefontloader/tst_qdeclarativefontloader.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtQuick/private/qdeclarativefontloader_p.h>
-#include "../../shared/util.h"
-#include "../../shared/testhttpserver.h"
-#include <QtQuick/QQuickView>
-#include <QtQuick/QQuickItem>
-
-#define SERVER_PORT 14448
-
-class tst_qdeclarativefontloader : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativefontloader();
-
-private slots:
- void initTestCase();
- void noFont();
- void namedFont();
- void localFont();
- void failLocalFont();
- void webFont();
- void redirWebFont();
- void failWebFont();
- void changeFont();
- void changeFontSourceViaState();
-
-private:
- QDeclarativeEngine engine;
- TestHTTPServer server;
-};
-
-tst_qdeclarativefontloader::tst_qdeclarativefontloader() :
- server(SERVER_PORT)
-{
-}
-
-void tst_qdeclarativefontloader::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- server.serveDirectory(dataDirectory());
- QVERIFY(server.isValid());
-}
-
-void tst_qdeclarativefontloader::noFont()
-{
- QString componentStr = "import QtQuick 2.0\nFontLoader { }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QCOMPARE(fontObject->name(), QString(""));
- QCOMPARE(fontObject->source(), QUrl(""));
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Null);
-
- delete fontObject;
-}
-
-void tst_qdeclarativefontloader::namedFont()
-{
- QString componentStr = "import QtQuick 2.0\nFontLoader { name: \"Helvetica\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QCOMPARE(fontObject->source(), QUrl(""));
- QCOMPARE(fontObject->name(), QString("Helvetica"));
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
-}
-
-void tst_qdeclarativefontloader::localFont()
-{
- QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFile("tarzeau_ocr_a.ttf") + "\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
-}
-
-void tst_qdeclarativefontloader::failLocalFont()
-{
- QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFileUrl("dummy.ttf").toString() + "\" }";
- QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + testFileUrl("dummy.ttf").toString() + "\"").toUtf8().constData());
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString(""));
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Error);
-}
-
-void tst_qdeclarativefontloader::webFont()
-{
- QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/tarzeau_ocr_a.ttf\" }";
- QDeclarativeComponent component(&engine);
-
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
-}
-
-void tst_qdeclarativefontloader::redirWebFont()
-{
- server.addRedirect("olddir/oldname.ttf","../tarzeau_ocr_a.ttf");
-
- QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/olddir/oldname.ttf\" }";
- QDeclarativeComponent component(&engine);
-
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
-}
-
-void tst_qdeclarativefontloader::failWebFont()
-{
- QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/nonexist.ttf\" }";
- QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML FontLoader: Cannot load font: \"http://localhost:14448/nonexist.ttf\"");
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
-
- QVERIFY(fontObject != 0);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString(""));
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Error);
-}
-
-void tst_qdeclarativefontloader::changeFont()
-{
- QString componentStr = "import QtQuick 2.0\nFontLoader { source: font }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("font", testFileUrl("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", testFileUrl("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"));
-}
-
-void tst_qdeclarativefontloader::changeFontSourceViaState()
-{
- QQuickView canvas(testFileUrl("qtbug-20268.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(qvariant_cast<QObject *>(canvas.rootObject()->property("fontloader")));
- QVERIFY(fontObject != 0);
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
- QVERIFY(fontObject->source() != QUrl(""));
- QTRY_COMPARE(fontObject->name(), QString("OCRA"));
-
- canvas.rootObject()->setProperty("usename", true);
-
- // This warning should probably not be printed once QTBUG-20268 is fixed
- QString warning = QString(testFileUrl("qtbug-20268.qml").toString()) +
- QLatin1String(":13:5: QML FontLoader: Cannot load font: \"\"");
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- QEXPECT_FAIL("", "QTBUG-20268", Abort);
- QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
- QCOMPARE(canvas.rootObject()->property("name").toString(), QString("Tahoma"));
-}
-
-QTEST_MAIN(tst_qdeclarativefontloader)
-
-#include "tst_qdeclarativefontloader.moc"
diff --git a/tests/auto/qtquick2/qdeclarativepath/qdeclarativepath.pro b/tests/auto/qtquick2/qdeclarativepath/qdeclarativepath.pro
deleted file mode 100644
index 1936d53050..0000000000
--- a/tests/auto/qtquick2/qdeclarativepath/qdeclarativepath.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativepath
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativepath.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp b/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp
deleted file mode 100644
index cdf2566531..0000000000
--- a/tests/auto/qtquick2/qdeclarativepath/tst_qdeclarativepath.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/private/qdeclarativepath_p.h>
-
-#include "../../shared/util.h"
-
-class tst_QDeclarativePath : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QDeclarativePath() {}
-
-private slots:
- void arc();
- void catmullromCurve();
- void closedCatmullromCurve();
- void svg();
-};
-
-void tst_QDeclarativePath::arc()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("arc.qml"));
- QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->startX(), 0.);
- QCOMPARE(obj->startY(), 0.);
-
- QDeclarativeListReference list(obj, "pathElements");
- QCOMPARE(list.count(), 1);
-
- QDeclarativePathArc* arc = qobject_cast<QDeclarativePathArc*>(list.at(0));
- QVERIFY(arc != 0);
- QCOMPARE(arc->x(), 100.);
- QCOMPARE(arc->y(), 100.);
- QCOMPARE(arc->radiusX(), 100.);
- QCOMPARE(arc->radiusY(), 100.);
- QCOMPARE(arc->useLargeArc(), false);
- QCOMPARE(arc->direction(), QDeclarativePathArc::Clockwise);
-
- QPainterPath path = obj->path();
- QVERIFY(path != QPainterPath());
-
- QPointF pos = obj->pointAt(0);
- QCOMPARE(pos, QPointF(0,0));
- pos = obj->pointAt(.25);
- QCOMPARE(pos.toPoint(), QPoint(39,8)); //fuzzy compare
- pos = obj->pointAt(.75);
- QCOMPARE(pos.toPoint(), QPoint(92,61)); //fuzzy compare
- pos = obj->pointAt(1);
- QCOMPARE(pos, QPointF(100,100));
-}
-
-void tst_QDeclarativePath::catmullromCurve()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("curve.qml"));
- QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->startX(), 0.);
- QCOMPARE(obj->startY(), 0.);
-
- QDeclarativeListReference list(obj, "pathElements");
- QCOMPARE(list.count(), 3);
-
- QDeclarativePathCatmullRomCurve* curve = qobject_cast<QDeclarativePathCatmullRomCurve*>(list.at(0));
- QVERIFY(curve != 0);
- QCOMPARE(curve->x(), 100.);
- QCOMPARE(curve->y(), 50.);
-
- curve = qobject_cast<QDeclarativePathCatmullRomCurve*>(list.at(2));
- QVERIFY(curve != 0);
- QCOMPARE(curve->x(), 100.);
- QCOMPARE(curve->y(), 150.);
-
- QPainterPath path = obj->path();
- QVERIFY(path != QPainterPath());
-
- QPointF pos = obj->pointAt(0);
- QCOMPARE(pos, QPointF(0,0));
- pos = obj->pointAt(.25);
- QCOMPARE(pos.toPoint(), QPoint(63,26)); //fuzzy compare
- pos = obj->pointAt(.75);
- QCOMPARE(pos.toPoint(), QPoint(51,105)); //fuzzy compare
- pos = obj->pointAt(1);
- QCOMPARE(pos, QPointF(100,150));
-}
-
-void tst_QDeclarativePath::closedCatmullromCurve()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("closedcurve.qml"));
- QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->startX(), 50.);
- QCOMPARE(obj->startY(), 50.);
-
- QDeclarativeListReference list(obj, "pathElements");
- QCOMPARE(list.count(), 3);
-
- QDeclarativePathCatmullRomCurve* curve = qobject_cast<QDeclarativePathCatmullRomCurve*>(list.at(2));
- QVERIFY(curve != 0);
- QCOMPARE(curve->x(), 50.);
- QCOMPARE(curve->y(), 50.);
-
- QVERIFY(obj->isClosed());
-
- QPainterPath path = obj->path();
- QVERIFY(path != QPainterPath());
-
- QPointF pos = obj->pointAt(0);
- QCOMPARE(pos, QPointF(50,50));
- pos = obj->pointAt(.1);
- QCOMPARE(pos.toPoint(), QPoint(67,56)); //fuzzy compare
- pos = obj->pointAt(.75);
- QCOMPARE(pos.toPoint(), QPoint(44,116)); //fuzzy compare
- pos = obj->pointAt(1);
- QCOMPARE(pos, QPointF(50,50));
-}
-
-void tst_QDeclarativePath::svg()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("svg.qml"));
- QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->startX(), 0.);
- QCOMPARE(obj->startY(), 0.);
-
- QDeclarativeListReference list(obj, "pathElements");
- QCOMPARE(list.count(), 1);
-
- QDeclarativePathSvg* svg = qobject_cast<QDeclarativePathSvg*>(list.at(0));
- QVERIFY(svg != 0);
- QCOMPARE(svg->path(), QLatin1String("M200,300 Q400,50 600,300 T1000,300"));
-
- QPainterPath path = obj->path();
- QVERIFY(path != QPainterPath());
-
- QPointF pos = obj->pointAt(0);
- QCOMPARE(pos, QPointF(200,300));
- pos = obj->pointAt(.25);
- QCOMPARE(pos.toPoint(), QPoint(400,175)); //fuzzy compare
- pos = obj->pointAt(.75);
- QCOMPARE(pos.toPoint(), QPoint(800,425)); //fuzzy compare
- pos = obj->pointAt(1);
- QCOMPARE(pos, QPointF(1000,300));
-}
-
-
-QTEST_MAIN(tst_QDeclarativePath)
-
-#include "tst_qdeclarativepath.moc"
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/qdeclarativepixmapcache.pro b/tests/auto/qtquick2/qdeclarativepixmapcache/qdeclarativepixmapcache.pro
deleted file mode 100644
index 006489cce7..0000000000
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/qdeclarativepixmapcache.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativepixmapcache
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativepixmapcache.cpp \
- ../../shared/testhttpserver.cpp
-HEADERS += ../../shared/testhttpserver.h
-INCLUDEPATH += ../../shared/
-
-include (../../shared/util.pri)
-
-importFiles.files = data
-importFiles.path = .
-DEPLOYMENT += importFiles
-
-# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
-# LIBS += -lgcov
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib concurrent
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/qtquick2/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp
deleted file mode 100644
index 84ea9ec3a9..0000000000
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp
+++ /dev/null
@@ -1,467 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QtTest>
-#include <QtQuick/private/qdeclarativepixmapcache_p.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeimageprovider.h>
-#include <QNetworkReply>
-#include "../../shared/util.h"
-#include "testhttpserver.h"
-
-#ifndef QT_NO_CONCURRENT
-#include <qtconcurrentrun.h>
-#include <qfuture.h>
-#endif
-
-#define PIXMAP_DATA_LEAK_TEST 0
-
-class tst_qdeclarativepixmapcache : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativepixmapcache() : server(14452) {}
-
-private slots:
- void initTestCase();
- void single();
- void single_data();
- void parallel();
- void parallel_data();
- void massive();
- void cancelcrash();
- void shrinkcache();
-#ifndef QT_NO_CONCURRENT
- void networkCrash();
-#endif
- void lockingCrash();
-#if PIXMAP_DATA_LEAK_TEST
- void dataLeak();
-#endif
-private:
- QDeclarativeEngine engine;
- TestHTTPServer server;
-};
-
-static int slotters=0;
-
-class Slotter : public QObject
-{
- Q_OBJECT
-public:
- Slotter()
- {
- gotslot = false;
- slotters++;
- }
- bool gotslot;
-
-public slots:
- void got()
- {
- gotslot = true;
- --slotters;
- if (slotters==0)
- QTestEventLoop::instance().exitLoop();
- }
-};
-
-#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
-static const bool localfile_optimized = true;
-#else
-static const bool localfile_optimized = false;
-#endif
-
-
-void tst_qdeclarativepixmapcache::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- server.serveDirectory(testFile("http"));
-}
-
-void tst_qdeclarativepixmapcache::single_data()
-{
- // Note, since QDeclarativePixmapCache is shared, tests affect each other!
- // so use different files fore all test functions.
-
- QTest::addColumn<QUrl>("target");
- QTest::addColumn<bool>("incache");
- QTest::addColumn<bool>("exists");
- QTest::addColumn<bool>("neterror");
-
- // File URLs are optimized
- QTest::newRow("local") << testFileUrl("exists.png") << localfile_optimized << true << false;
- QTest::newRow("local") << testFileUrl("notexists.png") << localfile_optimized << false << false;
- QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/exists.png") << false << true << false;
- QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/notexists.png") << false << false << true;
-}
-
-void tst_qdeclarativepixmapcache::single()
-{
- QFETCH(QUrl, target);
- QFETCH(bool, incache);
- QFETCH(bool, exists);
- QFETCH(bool, neterror);
-
- QString expectedError;
- if (neterror) {
- expectedError = "Error downloading " + target.toString() + " - server replied: Not found";
- } else if (!exists) {
- expectedError = "Cannot open: " + target.toString();
- }
-
- QDeclarativePixmap pixmap;
- QVERIFY(pixmap.width() <= 0); // Check Qt assumption
-
- pixmap.load(&engine, target);
-
- if (incache) {
- QCOMPARE(pixmap.error(), expectedError);
- if (exists) {
- QVERIFY(pixmap.status() == QDeclarativePixmap::Ready);
- QVERIFY(pixmap.width() > 0);
- } else {
- QVERIFY(pixmap.status() == QDeclarativePixmap::Error);
- QVERIFY(pixmap.width() <= 0);
- }
- } else {
- QVERIFY(pixmap.width() <= 0);
-
- Slotter getter;
- pixmap.connectFinished(&getter, SLOT(got()));
- QTestEventLoop::instance().enterLoop(10);
- QVERIFY(!QTestEventLoop::instance().timeout());
- QVERIFY(getter.gotslot);
- if (exists) {
- QVERIFY(pixmap.status() == QDeclarativePixmap::Ready);
- QVERIFY(pixmap.width() > 0);
- } else {
- QVERIFY(pixmap.status() == QDeclarativePixmap::Error);
- QVERIFY(pixmap.width() <= 0);
- }
- QCOMPARE(pixmap.error(), expectedError);
- }
-}
-
-void tst_qdeclarativepixmapcache::parallel_data()
-{
- // Note, since QDeclarativePixmapCache is shared, tests affect each other!
- // so use different files fore all test functions.
-
- QTest::addColumn<QUrl>("target1");
- QTest::addColumn<QUrl>("target2");
- QTest::addColumn<int>("incache");
- QTest::addColumn<int>("cancel"); // which one to cancel
-
- QTest::newRow("local")
- << testFileUrl("exists1.png")
- << testFileUrl("exists2.png")
- << (localfile_optimized ? 2 : 0)
- << -1;
-
- QTest::newRow("remote")
- << QUrl("http://127.0.0.1:14452/exists2.png")
- << QUrl("http://127.0.0.1:14452/exists3.png")
- << 0
- << -1;
-
- QTest::newRow("remoteagain")
- << QUrl("http://127.0.0.1:14452/exists2.png")
- << QUrl("http://127.0.0.1:14452/exists3.png")
- << 2
- << -1;
-
- QTest::newRow("remotecopy")
- << QUrl("http://127.0.0.1:14452/exists4.png")
- << QUrl("http://127.0.0.1:14452/exists4.png")
- << 0
- << -1;
-
- QTest::newRow("remotecopycancel")
- << QUrl("http://127.0.0.1:14452/exists5.png")
- << QUrl("http://127.0.0.1:14452/exists5.png")
- << 0
- << 0;
-}
-
-void tst_qdeclarativepixmapcache::parallel()
-{
- QFETCH(QUrl, target1);
- QFETCH(QUrl, target2);
- QFETCH(int, incache);
- QFETCH(int, cancel);
-
- QList<QUrl> targets;
- targets << target1 << target2;
-
- QList<QDeclarativePixmap *> pixmaps;
- QList<bool> pending;
- QList<Slotter*> getters;
-
- for (int i=0; i<targets.count(); ++i) {
- QUrl target = targets.at(i);
- QDeclarativePixmap *pixmap = new QDeclarativePixmap;
-
- pixmap->load(&engine, target);
-
- QVERIFY(pixmap->status() != QDeclarativePixmap::Error);
- pixmaps.append(pixmap);
- if (pixmap->isReady()) {
- QVERIFY(pixmap->width() > 0);
- getters.append(0);
- pending.append(false);
- } else {
- QVERIFY(pixmap->width() <= 0);
- getters.append(new Slotter);
- pixmap->connectFinished(getters[i], SLOT(got()));
- pending.append(true);
- }
- }
-
- QCOMPARE(incache+slotters, targets.count());
-
- if (cancel >= 0) {
- pixmaps.at(cancel)->clear(getters[cancel]);
- slotters--;
- }
-
- if (slotters) {
- QTestEventLoop::instance().enterLoop(10);
- QVERIFY(!QTestEventLoop::instance().timeout());
- }
-
- for (int i=0; i<targets.count(); ++i) {
- QDeclarativePixmap *pixmap = pixmaps[i];
-
- if (i == cancel) {
- QVERIFY(!getters[i]->gotslot);
- } else {
- if (pending[i])
- QVERIFY(getters[i]->gotslot);
-
- QVERIFY(pixmap->isReady());
- QVERIFY(pixmap->width() > 0);
- delete getters[i];
- }
- }
-
- qDeleteAll(pixmaps);
-}
-
-void tst_qdeclarativepixmapcache::massive()
-{
- QDeclarativeEngine engine;
- QUrl url = testFileUrl("massive.png");
-
- // Confirm that massive images remain in the cache while they are
- // in use by the application.
- {
- qint64 cachekey = 0;
- QDeclarativePixmap p(&engine, url);
- QVERIFY(p.isReady());
- QVERIFY(p.image().size() == QSize(10000, 1000));
- cachekey = p.image().cacheKey();
-
- QDeclarativePixmap p2(&engine, url);
- QVERIFY(p2.isReady());
- QVERIFY(p2.image().size() == QSize(10000, 1000));
-
- QVERIFY(p2.image().cacheKey() == cachekey);
- }
-
- // Confirm that massive images are removed from the cache when
- // they become unused
- {
- qint64 cachekey = 0;
- {
- QDeclarativePixmap p(&engine, url);
- QVERIFY(p.isReady());
- QVERIFY(p.image().size() == QSize(10000, 1000));
- cachekey = p.image().cacheKey();
- }
-
- QDeclarativePixmap p2(&engine, url);
- QVERIFY(p2.isReady());
- QVERIFY(p2.image().size() == QSize(10000, 1000));
-
- QVERIFY(p2.image().cacheKey() != cachekey);
- }
-}
-
-// QTBUG-12729
-void tst_qdeclarativepixmapcache::cancelcrash()
-{
- QUrl url("http://127.0.0.1:14452/cancelcrash_notexist.png");
- for (int ii = 0; ii < 1000; ++ii) {
- QDeclarativePixmap pix(&engine, url);
- }
-}
-
-class MyPixmapProvider : public QDeclarativeImageProvider
-{
-public:
- MyPixmapProvider()
- : QDeclarativeImageProvider(Pixmap) {}
-
- virtual QPixmap requestPixmap(const QString &d, QSize *, const QSize &) {
- Q_UNUSED(d)
- 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);
- }
-}
-
-#ifndef QT_NO_CONCURRENT
-
-void createNetworkServer()
-{
- QEventLoop eventLoop;
- TestHTTPServer server(14453);
- server.serveDirectory(QDeclarativeDataTest::instance()->testFile("http"));
- QTimer::singleShot(100, &eventLoop, SLOT(quit()));
- eventLoop.exec();
-}
-
-#ifndef QT_NO_CONCURRENT
-// QT-3957
-void tst_qdeclarativepixmapcache::networkCrash()
-{
- QFuture<void> future = QtConcurrent::run(createNetworkServer);
- QDeclarativeEngine engine;
- for (int ii = 0; ii < 100 ; ++ii) {
- QDeclarativePixmap* pixmap = new QDeclarativePixmap;
- pixmap->load(&engine, QUrl(QString("http://127.0.0.1:14453/exists.png")));
- QTest::qSleep(1);
- pixmap->clear();
- delete pixmap;
- }
- future.cancel();
-}
-#endif
-
-#endif
-
-// QTBUG-22125
-void tst_qdeclarativepixmapcache::lockingCrash()
-{
- TestHTTPServer server(14453);
- server.serveDirectory(testFile("http"), TestHTTPServer::Delay);
-
- {
- QDeclarativePixmap* p = new QDeclarativePixmap;
- {
- QDeclarativeEngine e;
- p->load(&e, QUrl(QString("http://127.0.0.1:14453/exists6.png")));
- }
- p->clear();
- QVERIFY(p->isNull());
- delete p;
- }
-}
-
-
-#if PIXMAP_DATA_LEAK_TEST
-// This test should not be enabled by default as it
-// produces spurious output in the expected case.
-#include <QtQuick/QQuickView>
-class DataLeakView : public QQuickView
-{
- Q_OBJECT
-
-public:
- explicit DataLeakView() : QQuickView()
- {
- setSource(testFileUrl("dataLeak.qml"));
- }
-
- void showFor2Seconds()
- {
- showFullScreen();
- QTimer::singleShot(2000, this, SIGNAL(ready()));
- }
-
-signals:
- void ready();
-};
-
-// QTBUG-22742
-Q_GLOBAL_STATIC(QDeclarativePixmap, dataLeakPixmap)
-void tst_qdeclarativepixmapcache::dataLeak()
-{
- // Should not leak cached QDeclarativePixmapData.
- // Unfortunately, since the QDeclarativePixmapStore
- // is a global static, and it releases the cache
- // entries on dtor (application exit), we must use
- // valgrind to determine whether it leaks or not.
- QDeclarativePixmap *p1 = new QDeclarativePixmap;
- QDeclarativePixmap *p2 = new QDeclarativePixmap;
- {
- QScopedPointer<DataLeakView> test(new DataLeakView);
- test->showFor2Seconds();
- dataLeakPixmap()->load(test->engine(), testFileUrl("exists.png"));
- p1->load(test->engine(), testFileUrl("exists.png"));
- p2->load(test->engine(), testFileUrl("exists2.png"));
- QTest::qWait(2005); // 2 seconds + a few more millis.
- }
-
- // When the (global static) dataLeakPixmap is deleted, it
- // shouldn't attempt to dereference a QDeclarativePixmapData
- // which has been deleted by the QDeclarativePixmapStore
- // destructor.
-}
-#endif
-#undef PIXMAP_DATA_LEAK_TEST
-
-QTEST_MAIN(tst_qdeclarativepixmapcache)
-
-#include "tst_qdeclarativepixmapcache.moc"
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro b/tests/auto/qtquick2/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro
deleted file mode 100644
index 41650c523f..0000000000
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativesmoothedanimation
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativesmoothedanimation.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp b/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp
deleted file mode 100644
index 09bde4ad76..0000000000
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/private/qdeclarativesmoothedanimation_p.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativesmoothedanimation : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativesmoothedanimation();
-
-private slots:
- void defaultValues();
- void values();
- void disabled();
- void simpleAnimation();
- void valueSource();
- void behavior();
- void deleteOnUpdate();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativesmoothedanimation::tst_qdeclarativesmoothedanimation()
-{
-}
-
-void tst_qdeclarativesmoothedanimation::defaultValues()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("smoothedanimation1.qml"));
- QDeclarativeSmoothedAnimation *obj = qobject_cast<QDeclarativeSmoothedAnimation*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 0.);
- QCOMPARE(obj->velocity(), 200.);
- QCOMPARE(obj->duration(), -1);
- QCOMPARE(obj->maximumEasingTime(), -1);
- QCOMPARE(obj->reversingMode(), QDeclarativeSmoothedAnimation::Eased);
-
- delete obj;
-}
-
-void tst_qdeclarativesmoothedanimation::values()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("smoothedanimation2.qml"));
- QDeclarativeSmoothedAnimation *obj = qobject_cast<QDeclarativeSmoothedAnimation*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 10.);
- QCOMPARE(obj->velocity(), 200.);
- QCOMPARE(obj->duration(), 300);
- QCOMPARE(obj->maximumEasingTime(), -1);
- QCOMPARE(obj->reversingMode(), QDeclarativeSmoothedAnimation::Immediate);
-
- delete obj;
-}
-
-void tst_qdeclarativesmoothedanimation::disabled()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("smoothedanimation3.qml"));
- QDeclarativeSmoothedAnimation *obj = qobject_cast<QDeclarativeSmoothedAnimation*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 10.);
- QCOMPARE(obj->velocity(), 250.);
- QCOMPARE(obj->maximumEasingTime(), 150);
- QCOMPARE(obj->reversingMode(), QDeclarativeSmoothedAnimation::Sync);
-
- delete obj;
-}
-
-void tst_qdeclarativesmoothedanimation::simpleAnimation()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("simpleanimation.qml"));
- QObject *obj = c.create();
- QVERIFY(obj);
-
- QQuickRectangle *rect = obj->findChild<QQuickRectangle*>("rect");
- QVERIFY(rect);
-
- QDeclarativeSmoothedAnimation *animation = obj->findChild<QDeclarativeSmoothedAnimation*>("anim");
- QVERIFY(animation);
-
- animation->setTargetObject(rect);
- animation->setProperty("x");
- animation->setTo(200);
- animation->setDuration(250);
- QVERIFY(animation->target() == rect);
- QVERIFY(animation->property() == "x");
- QVERIFY(animation->to() == 200);
- animation->start();
- QVERIFY(animation->isRunning());
- QTest::qWait(animation->duration());
- QTRY_COMPARE(rect->x(), qreal(200));
- QTest::qWait(100); //smoothed animation doesn't report stopped until delayed timer fires
-
- QVERIFY(!animation->isRunning());
- rect->setX(0);
- animation->start();
- QVERIFY(animation->isRunning());
- animation->pause();
- QVERIFY(animation->isRunning());
- QVERIFY(animation->isPaused());
- animation->setCurrentTime(125);
- QVERIFY(animation->currentTime() == 125);
- QCOMPARE(rect->x(), qreal(100));
-}
-
-void tst_qdeclarativesmoothedanimation::valueSource()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("smoothedanimationValueSource.qml"));
-
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *theRect = rect->findChild<QQuickRectangle*>("theRect");
- QVERIFY(theRect);
-
- QDeclarativeSmoothedAnimation *easeX = rect->findChild<QDeclarativeSmoothedAnimation*>("easeX");
- QVERIFY(easeX);
- QVERIFY(easeX->isRunning());
-
- QDeclarativeSmoothedAnimation *easeY = rect->findChild<QDeclarativeSmoothedAnimation*>("easeY");
- QVERIFY(easeY);
- QVERIFY(easeY->isRunning());
-
- // XXX get the proper duration
- QTest::qWait(100);
-
- QTRY_VERIFY(!easeX->isRunning());
- QTRY_VERIFY(!easeY->isRunning());
-
- QTRY_COMPARE(theRect->x(), qreal(200));
- QTRY_COMPARE(theRect->y(), qreal(200));
-
- delete rect;
-}
-
-void tst_qdeclarativesmoothedanimation::behavior()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("smoothedanimationBehavior.qml"));
-
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QQuickRectangle *theRect = rect->findChild<QQuickRectangle*>("theRect");
- QVERIFY(theRect);
-
- QDeclarativeSmoothedAnimation *easeX = rect->findChild<QDeclarativeSmoothedAnimation*>("easeX");
- QVERIFY(easeX);
-
- QDeclarativeSmoothedAnimation *easeY = rect->findChild<QDeclarativeSmoothedAnimation*>("easeY");
- QVERIFY(easeY);
-
- // XXX get the proper duration
- QTest::qWait(400);
-
- QTRY_VERIFY(!easeX->isRunning());
- QTRY_VERIFY(!easeY->isRunning());
-
- QTRY_COMPARE(theRect->x(), qreal(200));
- QTRY_COMPARE(theRect->y(), qreal(200));
-
- delete rect;
-}
-
-void tst_qdeclarativesmoothedanimation::deleteOnUpdate()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("deleteOnUpdate.qml"));
-
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeSmoothedAnimation *anim = rect->findChild<QDeclarativeSmoothedAnimation*>("anim");
- QVERIFY(anim);
-
- //don't crash
- QTest::qWait(500);
-
- delete rect;
-}
-
-QTEST_MAIN(tst_qdeclarativesmoothedanimation)
-
-#include "tst_qdeclarativesmoothedanimation.moc"
diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/qdeclarativespringanimation.pro b/tests/auto/qtquick2/qdeclarativespringanimation/qdeclarativespringanimation.pro
deleted file mode 100644
index d90cf3dca3..0000000000
--- a/tests/auto/qtquick2/qdeclarativespringanimation/qdeclarativespringanimation.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativespringanimation
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativespringanimation.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp b/tests/auto/qtquick2/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp
deleted file mode 100644
index 64956d7753..0000000000
--- a/tests/auto/qtquick2/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qdeclarativespringanimation_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include "../../shared/util.h"
-
-class tst_qdeclarativespringanimation : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativespringanimation();
-
-private slots:
- void defaultValues();
- void values();
- void disabled();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativespringanimation::tst_qdeclarativespringanimation()
-{
-}
-
-void tst_qdeclarativespringanimation::defaultValues()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("springanimation1.qml"));
- QDeclarativeSpringAnimation *obj = qobject_cast<QDeclarativeSpringAnimation*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 0.);
- QCOMPARE(obj->velocity(), 0.);
- QCOMPARE(obj->spring(), 0.);
- QCOMPARE(obj->damping(), 0.);
- QCOMPARE(obj->epsilon(), 0.01);
- QCOMPARE(obj->modulus(), 0.);
- QCOMPARE(obj->mass(), 1.);
- QCOMPARE(obj->isRunning(), false);
-
- delete obj;
-}
-
-void tst_qdeclarativespringanimation::values()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("springanimation2.qml"));
- QObject *root = c.create();
-
- QDeclarativeSpringAnimation *obj = root->findChild<QDeclarativeSpringAnimation*>();
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 1.44);
- QCOMPARE(obj->velocity(), 0.9);
- QCOMPARE(obj->spring(), 1.0);
- QCOMPARE(obj->damping(), 0.5);
- QCOMPARE(obj->epsilon(), 0.25);
- QCOMPARE(obj->modulus(), 360.0);
- QCOMPARE(obj->mass(), 2.0);
- QCOMPARE(obj->isRunning(), true);
-
- QTRY_COMPARE(obj->isRunning(), false);
-
- delete obj;
-}
-
-void tst_qdeclarativespringanimation::disabled()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("springanimation3.qml"));
- QDeclarativeSpringAnimation *obj = qobject_cast<QDeclarativeSpringAnimation*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 1.44);
- QCOMPARE(obj->velocity(), 0.9);
- QCOMPARE(obj->spring(), 1.0);
- QCOMPARE(obj->damping(), 0.5);
- QCOMPARE(obj->epsilon(), 0.25);
- QCOMPARE(obj->modulus(), 360.0);
- QCOMPARE(obj->mass(), 2.0);
- QCOMPARE(obj->isRunning(), false);
-
- delete obj;
-}
-
-QTEST_MAIN(tst_qdeclarativespringanimation)
-
-#include "tst_qdeclarativespringanimation.moc"
diff --git a/tests/auto/qtquick2/qdeclarativestates/qdeclarativestates.pro b/tests/auto/qtquick2/qdeclarativestates/qdeclarativestates.pro
deleted file mode 100644
index 74f5bef417..0000000000
--- a/tests/auto/qtquick2/qdeclarativestates/qdeclarativestates.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativestates
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativestates.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
diff --git a/tests/auto/qtquick2/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/qtquick2/qdeclarativestates/tst_qdeclarativestates.cpp
deleted file mode 100644
index 391a4f7cfe..0000000000
--- a/tests/auto/qtquick2/qdeclarativestates/tst_qdeclarativestates.cpp
+++ /dev/null
@@ -1,1608 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <private/qquickstateoperations_p.h>
-#include <private/qquickanchors_p_p.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <private/qquickimage_p.h>
-#include <QtQuick/private/qdeclarativepropertychanges_p.h>
-#include <QtQuick/private/qdeclarativestategroup_p.h>
-#include <private/qquickitem_p.h>
-#include <private/qdeclarativeproperty_p.h>
-#include "../../shared/util.h"
-
-class MyAttached : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int foo READ foo WRITE setFoo)
-public:
- MyAttached(QObject *parent) : QObject(parent), m_foo(13) {}
-
- int foo() const { return m_foo; }
- void setFoo(int f) { m_foo = f; }
-
-private:
- int m_foo;
-};
-
-class MyRect : public QQuickRectangle
-{
- Q_OBJECT
- Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
-public:
- MyRect() {}
-
- void doSomething() { emit didSomething(); }
-
- int propertyWithNotify() const { return m_prop; }
- void setPropertyWithNotify(int i) { m_prop = i; emit oddlyNamedNotifySignal(); }
-
- static MyAttached *qmlAttachedProperties(QObject *o) {
- return new MyAttached(o);
- }
-Q_SIGNALS:
- void didSomething();
- void oddlyNamedNotifySignal();
-
-private:
- int m_prop;
-};
-
-QML_DECLARE_TYPE(MyRect)
-QML_DECLARE_TYPEINFO(MyRect, QML_HAS_ATTACHED_PROPERTIES)
-
-class tst_qdeclarativestates : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qdeclarativestates() {}
-
-private:
- QByteArray fullDataPath(const QString &path) const;
-
-private slots:
- void initTestCase();
-
- void basicChanges();
- void attachedPropertyChanges();
- void basicExtension();
- void basicBinding();
- void signalOverride();
- void signalOverrideCrash();
- void signalOverrideCrash2();
- void signalOverrideCrash3();
- void parentChange();
- void parentChangeErrors();
- void anchorChanges();
- void anchorChanges2();
- void anchorChanges3();
- void anchorChanges4();
- void anchorChanges5();
- void anchorChangesRTL();
- void anchorChangesRTL2();
- void anchorChangesRTL3();
- void anchorChangesCrash();
- void anchorRewindBug();
- void anchorRewindBug2();
- void script();
- void restoreEntryValues();
- void explicitChanges();
- void propertyErrors();
- void incorrectRestoreBug();
- void autoStateAtStartupRestoreBug();
- void deletingChange();
- void deletingState();
- void tempState();
- void illegalTempState();
- void nonExistantProperty();
- void reset();
- void illegalObjectCreation();
- void whenOrdering();
- void urlResolution();
- void unnamedWhen();
- void returnToBase();
- void extendsBug();
- void editProperties();
- void QTBUG_14830();
- void avoidFastForward();
- void revertListBug();
-};
-
-void tst_qdeclarativestates::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- qmlRegisterType<MyRect>("Qt.test", 1, 0, "MyRectangle");
-}
-
-QByteArray tst_qdeclarativestates::fullDataPath(const QString &path) const
-{
- return testFileUrl(path).toString().toUtf8();
-}
-
-void tst_qdeclarativestates::basicChanges()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges3.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1.0);
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1.0);
-
- rectPrivate->setState("bordered");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),2.0);
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1.0);
- //### we should be checking that this is an implicit rather than explicit 1 (which currently fails)
-
- rectPrivate->setState("bordered");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),2.0);
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1.0);
-
- }
-
- {
- // Test basicChanges4.qml can magically connect to propertyWithNotify's notify
- // signal using 'onPropertyWithNotifyChanged' even though the signal name is
- // actually 'oddlyNamedNotifySignal'
-
- QDeclarativeComponent component(&engine, testFileUrl("basicChanges4.qml"));
- QVERIFY(component.isReady());
-
- MyRect *rect = qobject_cast<MyRect*>(component.create());
- QVERIFY(rect != 0);
-
- QMetaProperty prop = rect->metaObject()->property(rect->metaObject()->indexOfProperty("propertyWithNotify"));
- QVERIFY(prop.hasNotifySignal());
- QString notifySignal = QByteArray(prop.notifySignal().signature());
- QVERIFY(!notifySignal.startsWith("propertyWithNotifyChanged("));
-
- QCOMPARE(rect->color(), QColor(Qt::red));
-
- rect->setPropertyWithNotify(100);
- QCOMPARE(rect->color(), QColor(Qt::blue));
- }
-}
-
-void tst_qdeclarativestates::attachedPropertyChanges()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent component(&engine, testFileUrl("attachedPropertyChanges.qml"));
- QVERIFY(component.isReady());
-
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item != 0);
- QCOMPARE(item->width(), 50.0);
-
- // Ensure attached property has been changed
- QObject *attObj = qmlAttachedPropertiesObject<MyRect>(item, false);
- QVERIFY(attObj);
-
- MyAttached *att = qobject_cast<MyAttached*>(attObj);
- QVERIFY(att);
-
- QCOMPARE(att->foo(), 1);
-}
-
-void tst_qdeclarativestates::basicExtension()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicExtension.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1.0);
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1.0);
-
- rectPrivate->setState("bordered");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),2.0);
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),1.0);
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1.0);
-
- rectPrivate->setState("bordered");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->border()->width(),2.0);
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->border()->width(),1.0);
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("fakeExtension.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
- }
-}
-
-void tst_qdeclarativestates::basicBinding()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("yellow"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("green"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("yellow"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding3.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("red"));
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor2", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor2", QColor("green"));
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding4.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("yellow"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
- rect->setProperty("sourceColor", QColor("purple"));
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("purple"));
-
- rectPrivate->setState("green");
- QCOMPARE(rect->color(),QColor("green"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- }
-}
-
-void tst_qdeclarativestates::signalOverride()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverride.qml"));
- MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("blue"));
-
- QQuickItemPrivate::get(rect)->setState("green");
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("green"));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverride2.qml"));
- MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("white"));
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("blue"));
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("extendedRect"));
- QQuickItemPrivate::get(innerRect)->setState("green");
- rect->doSomething();
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(innerRect->color(),QColor("green"));
- QCOMPARE(innerRect->property("extendedColor").value<QColor>(),QColor("green"));
- }
-}
-
-void tst_qdeclarativestates::signalOverrideCrash()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverrideCrash.qml"));
- MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickItemPrivate::get(rect)->setState("overridden");
- rect->doSomething();
-}
-
-void tst_qdeclarativestates::signalOverrideCrash2()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverrideCrash2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickItemPrivate::get(rect)->setState("state1");
- QQuickItemPrivate::get(rect)->setState("state2");
- QQuickItemPrivate::get(rect)->setState("state1");
-
- delete rect;
-}
-
-void tst_qdeclarativestates::signalOverrideCrash3()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverrideCrash3.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickItemPrivate::get(rect)->setState("state1");
- QQuickItemPrivate::get(rect)->setState("");
- QQuickItemPrivate::get(rect)->setState("state2");
- QQuickItemPrivate::get(rect)->setState("");
-
- delete rect;
-}
-
-void tst_qdeclarativestates::parentChange()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange1.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QQuickParentChange *pChange = qobject_cast<QQuickParentChange*>(state->operationAt(0));
- QVERIFY(pChange != 0);
- QQuickItem *nParent = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("NewParent"));
- QVERIFY(nParent != 0);
-
- QCOMPARE(pChange->parent(), nParent);
-
- QQuickItemPrivate::get(rect)->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(-133));
- QCOMPARE(innerRect->y(), qreal(-300));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- rectPrivate->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(15));
- QCOMPARE(innerRect->scale(), qreal(.5));
- QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-19.9075));
- QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-8.73433));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange3.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- rectPrivate->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(-37));
- QCOMPARE(innerRect->scale(), qreal(.25));
- QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-217.305));
- QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-164.413));
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(5));
- //do a non-qFuzzyCompare fuzzy compare
- QVERIFY(innerRect->y() < qreal(0.00001) && innerRect->y() > qreal(-0.00001));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange6.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QQuickItemPrivate::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()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange4.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QTest::ignoreMessage(QtWarningMsg, fullDataPath("parentChange4.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under non-uniform scale");
- QQuickItemPrivate::get(rect)->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(5));
- QCOMPARE(innerRect->y(), qreal(5));
- }
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange5.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QTest::ignoreMessage(QtWarningMsg, fullDataPath("parentChange5.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under complex transform");
- QQuickItemPrivate::get(rect)->setState("reparented");
- QCOMPARE(innerRect->rotation(), qreal(0));
- QCOMPARE(innerRect->scale(), qreal(1));
- QCOMPARE(innerRect->x(), qreal(5));
- QCOMPARE(innerRect->y(), qreal(5));
- }
-}
-
-void tst_qdeclarativestates::anchorChanges()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges1.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- QCOMPARE(aChanges->anchors()->left().script(), QLatin1String("undefined"));
- QCOMPARE(aChanges->anchors()->right().script(), QLatin1String("container.right"));
-
- rectPrivate->setState("right");
- QCOMPARE(innerRect->x(), qreal(150));
- QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), qreal(5));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChanges2()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- rectPrivate->setState("right");
- QCOMPARE(innerRect->x(), qreal(150));
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), qreal(5));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChanges3()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges3.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QQuickItem *leftGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QQuickItem *bottomGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- QCOMPARE(aChanges->anchors()->top().script(), QLatin1String("container.top"));
- QCOMPARE(aChanges->anchors()->bottom().script(), QLatin1String("bottomGuideline.bottom"));
-
- rectPrivate->setState("reanchored");
- QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().item, QQuickItemPrivate::get(leftGuideline)->left().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickItemPrivate::get(leftGuideline)->left().anchorLine);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().item, QQuickItemPrivate::get(bottomGuideline)->bottom().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QQuickItemPrivate::get(bottomGuideline)->bottom().anchorLine);
-
- QCOMPARE(innerRect->x(), qreal(10));
- QCOMPARE(innerRect->y(), qreal(0));
- QCOMPARE(innerRect->width(), qreal(190));
- QCOMPARE(innerRect->height(), qreal(150));
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), qreal(0));
- QCOMPARE(innerRect->y(), qreal(10));
- QCOMPARE(innerRect->width(), qreal(150));
- QCOMPARE(innerRect->height(), qreal(190));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChanges4()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges4.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QQuickItem *leftGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QQuickItem *bottomGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- QCOMPARE(aChanges->anchors()->horizontalCenter().script(), QLatin1String("bottomGuideline.horizontalCenter"));
- QCOMPARE(aChanges->anchors()->verticalCenter().script(), QLatin1String("leftGuideline.verticalCenter"));
-
- QQuickItemPrivate::get(rect)->setState("reanchored");
- QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->verticalCenter().item, QQuickItemPrivate::get(leftGuideline)->verticalCenter().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->verticalCenter().anchorLine, QQuickItemPrivate::get(leftGuideline)->verticalCenter().anchorLine);
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChanges5()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges5.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
-
- QQuickItem *leftGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QQuickItem *bottomGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- QCOMPARE(aChanges->anchors()->baseline().script(), QLatin1String("leftGuideline.baseline"));
-
- QQuickItemPrivate::get(rect)->setState("reanchored");
- QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->baseline().item, QQuickItemPrivate::get(leftGuideline)->baseline().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->baseline().anchorLine, QQuickItemPrivate::get(leftGuideline)->baseline().anchorLine);
-
- delete rect;
-}
-
-void mirrorAnchors(QQuickItem *item) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->setLayoutMirror(true);
-}
-
-qreal offsetRTL(QQuickItem *anchorItem, QQuickItem *item) {
- return anchorItem->width()+2*anchorItem->x()-item->width();
-}
-
-void tst_qdeclarativestates::anchorChangesRTL()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges1.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
- mirrorAnchors(innerRect);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- rectPrivate->setState("right");
- QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150));
- QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) -qreal(5));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChangesRTL2()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
- mirrorAnchors(innerRect);
-
- rectPrivate->setState("right");
- QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150));
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(5));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::anchorChangesRTL3()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges3.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
- mirrorAnchors(innerRect);
-
- QQuickItem *leftGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("LeftGuideline"));
- QVERIFY(leftGuideline != 0);
-
- QQuickItem *bottomGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("BottomGuideline"));
- QVERIFY(bottomGuideline != 0);
-
- QDeclarativeListReference list(rect, "states");
- QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
- QVERIFY(aChanges != 0);
-
- rectPrivate->setState("reanchored");
- QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().item, QQuickItemPrivate::get(leftGuideline)->left().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickItemPrivate::get(leftGuideline)->left().anchorLine);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().item, QQuickItemPrivate::get(bottomGuideline)->bottom().item);
- QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QQuickItemPrivate::get(bottomGuideline)->bottom().anchorLine);
-
- QCOMPARE(innerRect->x(), offsetRTL(leftGuideline, innerRect) - qreal(10));
- QCOMPARE(innerRect->y(), qreal(0));
- // between left side of parent and leftGuideline.x: 10, which has width 0
- QCOMPARE(innerRect->width(), qreal(10));
- QCOMPARE(innerRect->height(), qreal(150));
-
- rectPrivate->setState("");
- QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(0));
- QCOMPARE(innerRect->y(), qreal(10));
- // between right side of parent and left side of rightGuideline.x: 150, which has width 0
- QCOMPARE(innerRect->width(), qreal(50));
- QCOMPARE(innerRect->height(), qreal(190));
-
- delete rect;
-}
-
-//QTBUG-9609
-void tst_qdeclarativestates::anchorChangesCrash()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChangesCrash.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickItemPrivate::get(rect)->setState("reanchored");
-
- delete rect;
-}
-
-// QTBUG-12273
-void tst_qdeclarativestates::anchorRewindBug()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("anchorRewindBug.qml"));
-
- view->show();
- view->requestActivateWindow();
-
- QTest::qWaitForWindowShown(view);
-
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(view->rootObject());
- QVERIFY(rect != 0);
-
- QQuickItem * column = rect->findChild<QQuickItem*>("column");
-
- QVERIFY(column != 0);
- QVERIFY(!QQuickItemPrivate::get(column)->heightValid);
- QVERIFY(!QQuickItemPrivate::get(column)->widthValid);
- QCOMPARE(column->height(), 200.0);
- QQuickItemPrivate::get(rect)->setState("reanchored");
-
- // column height and width should stay implicit
- // and column's implicit resizing should still work
- QVERIFY(!QQuickItemPrivate::get(column)->heightValid);
- QVERIFY(!QQuickItemPrivate::get(column)->widthValid);
- QTRY_COMPARE(column->height(), 100.0);
-
- QQuickItemPrivate::get(rect)->setState("");
-
- // column height and width should stay implicit
- // and column's implicit resizing should still work
- QVERIFY(!QQuickItemPrivate::get(column)->heightValid);
- QVERIFY(!QQuickItemPrivate::get(column)->widthValid);
- QTRY_COMPARE(column->height(), 200.0);
-
- delete view;
-}
-
-// QTBUG-11834
-void tst_qdeclarativestates::anchorRewindBug2()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorRewindBug2.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *mover = rect->findChild<QQuickRectangle*>("mover");
-
- QVERIFY(mover != 0);
- QCOMPARE(mover->y(), qreal(0.0));
- QCOMPARE(mover->width(), qreal(50.0));
-
- QQuickItemPrivate::get(rect)->setState("anchored");
- QCOMPARE(mover->y(), qreal(250.0));
- QCOMPARE(mover->width(), qreal(200.0));
-
- QQuickItemPrivate::get(rect)->setState("");
- QCOMPARE(mover->y(), qreal(0.0));
- QCOMPARE(mover->width(), qreal(50.0));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::script()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent rectComponent(&engine, testFileUrl("script.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted
- }
-}
-
-void tst_qdeclarativestates::restoreEntryValues()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("restoreEntryValues.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("blue"));
-}
-
-void tst_qdeclarativestates::explicitChanges()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("explicit.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QDeclarativeListReference list(rect, "states");
- QDeclarativeState *state = qobject_cast<QDeclarativeState*>(list.at(0));
- QVERIFY(state != 0);
-
- qmlExecuteDeferred(state);
- QDeclarativePropertyChanges *changes = qobject_cast<QDeclarativePropertyChanges*>(rect->findChild<QDeclarativePropertyChanges*>("changes"));
- QVERIFY(changes != 0);
- QVERIFY(changes->isExplicit());
-
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rect->setProperty("sourceColor", QColor("green"));
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- rect->setProperty("sourceColor", QColor("yellow"));
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("yellow"));
-}
-
-void tst_qdeclarativestates::propertyErrors()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, testFileUrl("propertyErrors.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QCOMPARE(rect->color(),QColor("red"));
-
- QTest::ignoreMessage(QtWarningMsg, fullDataPath("propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\"");
- QTest::ignoreMessage(QtWarningMsg, fullDataPath("propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"activeFocus\"");
- QQuickItemPrivate::get(rect)->setState("blue");
-}
-
-void tst_qdeclarativestates::incorrectRestoreBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QCOMPARE(rect->color(),QColor("red"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- // make sure if we change the base state value, we then restore to it correctly
- rect->setColor(QColor("green"));
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("green"));
-}
-
-void tst_qdeclarativestates::autoStateAtStartupRestoreBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent component(&engine, testFileUrl("autoStateAtStartupRestoreBug.qml"));
- QObject *obj = component.create();
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->property("test").toInt(), 3);
-
- obj->setProperty("input", 2);
-
- QCOMPARE(obj->property("test").toInt(), 9);
-
- delete obj;
-}
-
-void tst_qdeclarativestates::deletingChange()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("deleting.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
- QCOMPARE(rect->radius(),qreal(5));
-
- rectPrivate->setState("");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->radius(),qreal(0));
-
- QDeclarativePropertyChanges *pc = rect->findChild<QDeclarativePropertyChanges*>("pc1");
- QVERIFY(pc != 0);
- delete pc;
-
- QDeclarativeState *state = rect->findChild<QDeclarativeState*>();
- QVERIFY(state != 0);
- qmlExecuteDeferred(state);
- QCOMPARE(state->operationCount(), 1);
-
- rectPrivate->setState("blue");
- QCOMPARE(rect->color(),QColor("red"));
- QCOMPARE(rect->radius(),qreal(5));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::deletingState()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("deletingState.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
-
- QDeclarativeStateGroup *sg = rect->findChild<QDeclarativeStateGroup*>();
- QVERIFY(sg != 0);
- QVERIFY(sg->findState("blue") != 0);
-
- sg->setState("blue");
- QCOMPARE(rect->color(),QColor("blue"));
-
- sg->setState("");
- QCOMPARE(rect->color(),QColor("red"));
-
- QDeclarativeState *state = rect->findChild<QDeclarativeState*>();
- QVERIFY(state != 0);
- delete state;
-
- QVERIFY(sg->findState("blue") == 0);
-
- //### should we warn that state doesn't exist
- sg->setState("blue");
- QCOMPARE(rect->color(),QColor("red"));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::tempState()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("legalTempState.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QTest::ignoreMessage(QtDebugMsg, "entering placed");
- QTest::ignoreMessage(QtDebugMsg, "entering idle");
- rectPrivate->setState("placed");
- QCOMPARE(rectPrivate->state(), QLatin1String("idle"));
-}
-
-void tst_qdeclarativestates::illegalTempState()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("illegalTempState.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML StateGroup: Can't apply a state change as part of a state definition.");
- rectPrivate->setState("placed");
- QCOMPARE(rectPrivate->state(), QLatin1String("placed"));
-}
-
-void tst_qdeclarativestates::nonExistantProperty()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent rectComponent(&engine, testFileUrl("nonExistantProp.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QTest::ignoreMessage(QtWarningMsg, fullDataPath("nonExistantProp.qml") + ":9:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\"");
- rectPrivate->setState("blue");
- QCOMPARE(rectPrivate->state(), QLatin1String("blue"));
-}
-
-void tst_qdeclarativestates::reset()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("reset.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickImage *image = rect->findChild<QQuickImage*>();
- QVERIFY(image != 0);
- QCOMPARE(image->width(), qreal(40.));
- QCOMPARE(image->height(), qreal(20.));
-
- QQuickItemPrivate::get(rect)->setState("state1");
-
- QCOMPARE(image->width(), 20.0);
- QCOMPARE(image->height(), qreal(20.));
-
- delete rect;
-}
-
-void tst_qdeclarativestates::illegalObjectCreation()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent component(&engine, testFileUrl("illegalObj.qml"));
- QList<QDeclarativeError> errors = component.errors();
- QVERIFY(errors.count() == 1);
- const QDeclarativeError &error = errors.at(0);
- QCOMPARE(error.line(), 9);
- QCOMPARE(error.column(), 23);
- QCOMPARE(error.description().toUtf8().constData(), "PropertyChanges does not support creating state-specific objects.");
-}
-
-void tst_qdeclarativestates::whenOrdering()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("whenOrdering.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
- rect->setProperty("condition2", true);
- QCOMPARE(rectPrivate->state(), QLatin1String("state2"));
- rect->setProperty("condition1", true);
- QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
- rect->setProperty("condition2", false);
- QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
- rect->setProperty("condition2", true);
- QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
- rect->setProperty("condition1", false);
- rect->setProperty("condition2", false);
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
-}
-
-void tst_qdeclarativestates::urlResolution()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("urlResolution.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickItem *myType = rect->findChild<QQuickItem*>("MyType");
- QQuickImage *image1 = rect->findChild<QQuickImage*>("image1");
- QQuickImage *image2 = rect->findChild<QQuickImage*>("image2");
- QQuickImage *image3 = rect->findChild<QQuickImage*>("image3");
- QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0);
-
- QQuickItemPrivate::get(myType)->setState("SetImageState");
- QUrl resolved = testFileUrl("Implementation/images/qt-logo.png");
- QCOMPARE(image1->source(), resolved);
- QCOMPARE(image2->source(), resolved);
- QCOMPARE(image3->source(), resolved);
-
- delete rect;
-}
-
-void tst_qdeclarativestates::unnamedWhen()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("unnamedWhen.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
- rect->setProperty("triggerState", true);
- QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1"));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState"));
- rect->setProperty("triggerState", false);
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
-}
-
-void tst_qdeclarativestates::returnToBase()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("returnToBase.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
- rect->setProperty("triggerState", true);
- QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1"));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState"));
- rect->setProperty("triggerState", false);
- QCOMPARE(rectPrivate->state(), QLatin1String(""));
- QCOMPARE(rect->property("stateString").toString(), QLatin1String("originalState"));
-}
-
-//QTBUG-12559
-void tst_qdeclarativestates::extendsBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("extendsBug.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QQuickRectangle *greenRect = rect->findChild<QQuickRectangle*>("greenRect");
-
- rectPrivate->setState("b");
- QCOMPARE(greenRect->x(), qreal(100));
- QCOMPARE(greenRect->y(), qreal(100));
-}
-
-void tst_qdeclarativestates::editProperties()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("editProperties.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::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);
-
- QQuickRectangle *childRect = rect->findChild<QQuickRectangle*>("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));
-}
-
-void tst_qdeclarativestates::QTBUG_14830()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("QTBUG-14830.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
- QQuickItem *item = rect->findChild<QQuickItem*>("area");
-
- QCOMPARE(item->width(), qreal(171));
-}
-
-void tst_qdeclarativestates::avoidFastForward()
-{
- QDeclarativeEngine engine;
-
- //shouldn't fast forward if there isn't a transition
- QDeclarativeComponent c(&engine, testFileUrl("avoidFastForward.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- rectPrivate->setState("a");
- QCOMPARE(rect->property("updateCount").toInt(), 1);
-}
-
-//QTBUG-22583
-void tst_qdeclarativestates::revertListBug()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, testFileUrl("revertListBug.qml"));
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
- QVERIFY(rect != 0);
-
- QQuickRectangle *rect1 = rect->findChild<QQuickRectangle*>("rect1");
- QQuickRectangle *rect2 = rect->findChild<QQuickRectangle*>("rect2");
- QQuickItem *origParent1 = rect->findChild<QQuickItem*>("originalParent1");
- QQuickItem *origParent2 = rect->findChild<QQuickItem*>("originalParent2");
- QQuickItem *newParent = rect->findChild<QQuickItem*>("newParent");
-
- QCOMPARE(rect1->parentItem(), origParent1);
- QCOMPARE(rect2->parentItem(), origParent2);
-
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- rectPrivate->setState("reparented");
-
- QCOMPARE(rect1->parentItem(), newParent);
- QCOMPARE(rect2->parentItem(), origParent2);
-
- rectPrivate->setState("");
-
- QCOMPARE(rect1->parentItem(), origParent1);
- QCOMPARE(rect2->parentItem(), origParent2);
-
- QMetaObject::invokeMethod(rect, "switchTargetItem");
-
- rectPrivate->setState("reparented");
-
- QCOMPARE(rect1->parentItem(), origParent1);
- QCOMPARE(rect2->parentItem(), newParent);
-
- rectPrivate->setState("");
-
- QCOMPARE(rect1->parentItem(), origParent1);
- QCOMPARE(rect2->parentItem(), origParent2); //QTBUG-22583 causes rect2's parent item to be origParent1
-}
-
-QTEST_MAIN(tst_qdeclarativestates)
-
-#include "tst_qdeclarativestates.moc"
diff --git a/tests/auto/qtquick2/qdeclarativestyledtext/qdeclarativestyledtext.pro b/tests/auto/qtquick2/qdeclarativestyledtext/qdeclarativestyledtext.pro
deleted file mode 100644
index 84532f611e..0000000000
--- a/tests/auto/qtquick2/qdeclarativestyledtext/qdeclarativestyledtext.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativestyledtext
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativestyledtext.cpp
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp b/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp
deleted file mode 100644
index fd0d1abd29..0000000000
--- a/tests/auto/qtquick2/qdeclarativestyledtext/tst_qdeclarativestyledtext.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QtTest>
-#include <QtGui/QTextLayout>
-#include <QtCore/QList>
-#include <QtQuick/private/qdeclarativestyledtext_p.h>
-
-class tst_qdeclarativestyledtext : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativestyledtext()
- {
- }
-
- struct Format {
- enum Type {
- Bold = 0x01,
- Underline = 0x02,
- Italic = 0x04
- };
- Format(int t, int s, int l)
- : type(t), start(s), length(l) {}
- int type;
- int start;
- int length;
- };
- typedef QList<Format> FormatList;
-
- static const QChar bullet;
- static const QChar disc;
- static const QChar square;
-
-private slots:
- void textOutput();
- void textOutput_data();
-};
-
-Q_DECLARE_METATYPE(tst_qdeclarativestyledtext::FormatList);
-
-const QChar tst_qdeclarativestyledtext::bullet(0x2022);
-const QChar tst_qdeclarativestyledtext::disc(0x25e6);
-const QChar tst_qdeclarativestyledtext::square(0x25a1);
-
-// For malformed input all we test is that we get the expected text and format out.
-//
-void tst_qdeclarativestyledtext::textOutput_data()
-{
- QTest::addColumn<QString>("input");
- QTest::addColumn<QString>("output");
- QTest::addColumn<FormatList>("formats");
-
- QTest::newRow("bold") << "<b>bold</b>" << "bold" << (FormatList() << Format(Format::Bold, 0, 4));
- QTest::newRow("italic") << "<i>italic</i>" << "italic" << (FormatList() << Format(Format::Italic, 0, 6));
- QTest::newRow("underline") << "<u>underline</u>" << "underline" << (FormatList() << Format(Format::Underline, 0, 9));
- QTest::newRow("strong") << "<strong>strong</strong>" << "strong" << (FormatList() << Format(Format::Bold, 0, 6));
- QTest::newRow("underline") << "<u>underline</u>" << "underline" << (FormatList() << Format(Format::Underline, 0, 9));
- QTest::newRow("missing >") << "<b>text</b" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
- QTest::newRow("missing b>") << "<b>text</" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
- QTest::newRow("missing /b>") << "<b>text<" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
- QTest::newRow("missing </b>") << "<b>text" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
- QTest::newRow("nested") << "<b>text <i>italic</i> bold</b>" << "text italic bold" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6) << Format(Format::Bold, 11, 5));
- QTest::newRow("bad nest") << "<b>text <i>italic</b></i>" << "text italic" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6));
- QTest::newRow("font color") << "<font color=\"red\">red text</font>" << "red text" << (FormatList() << Format(0, 0, 8));
- QTest::newRow("font color: single quote") << "<font color='red'>red text</font>" << "red text" << (FormatList() << Format(0, 0, 8));
- QTest::newRow("font size") << "<font size=\"1\">text</font>" << "text" << (FormatList() << Format(0, 0, 4));
- QTest::newRow("font empty") << "<font>text</font>" << "text" << FormatList();
- QTest::newRow("font bad 1") << "<font ezis=\"blah\">text</font>" << "text" << FormatList();
- QTest::newRow("font bad 2") << "<font size=\"1>text</font>" << "" << FormatList();
- QTest::newRow("extra close") << "<b>text</b></b>" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
- QTest::newRow("extra space") << "<b >text</b>" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
- QTest::newRow("entities") << "&lt;b&gt;this &amp; that&lt;/b&gt;" << "<b>this & that</b>" << FormatList();
- QTest::newRow("newline") << "text<br>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
- QTest::newRow("paragraph") << "text<p>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
- QTest::newRow("paragraph closed") << "text<p>more text</p>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
- QTest::newRow("paragraph closed bold") << "<b>text<p>more text</p>more text</b>" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << (FormatList() << Format(Format::Bold, 0, 24));
- QTest::newRow("self-closing newline") << "text<br/>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
- QTest::newRow("empty") << "" << "" << FormatList();
- QTest::newRow("unknown tag") << "<a href='#'><foo>underline</foo></a> not" << "underline not" << (FormatList() << Format(Format::Underline, 0, 9));
- QTest::newRow("ordered list") << "<ol><li>one<li>two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList();
- QTest::newRow("ordered list closed") << "<ol><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("ordered list alpha") << "<ol type=\"a\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("a.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("b.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("ordered list upper alpha") << "<ol type=\"A\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("A.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("B.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("ordered list roman") << "<ol type=\"i\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("i.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("ii.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("ordered list upper roman") << "<ol type=\"I\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("I.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("II.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("ordered list bad") << "<ol type=\"z\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("unordered list") << "<ul><li>one<li>two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList();
- QTest::newRow("unordered list closed") << "<ul><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("unordered list disc") << "<ul type=\"disc\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("unordered list square") << "<ul type=\"square\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("unordered list bad") << "<ul type=\"bad\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
- QTest::newRow("header close") << "<h1>head</h1>more" << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) + QLatin1String("more") << (FormatList() << Format(Format::Bold, 0, 5));
- QTest::newRow("h0") << "<h0>head" << "head" << FormatList();
- QTest::newRow("h1") << "<h1>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
- QTest::newRow("h2") << "<h2>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
- QTest::newRow("h3") << "<h3>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
- QTest::newRow("h4") << "<h4>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
- QTest::newRow("h5") << "<h5>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
- QTest::newRow("h6") << "<h6>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
- QTest::newRow("h7") << "<h7>head" << "head" << FormatList();
- QTest::newRow("pre") << "normal<pre>pre text</pre>normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 9));
- QTest::newRow("pre lb") << "normal<pre>pre\n text</pre>normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::LineSeparator) + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 10));
- QTest::newRow("line feed") << "line\nfeed" << "line feed" << FormatList();
- QTest::newRow("leading whitespace") << " leading whitespace" << "leading whitespace" << FormatList();
- QTest::newRow("trailing whitespace") << "trailing whitespace " << "trailing whitespace" << FormatList();
- QTest::newRow("consecutive whitespace") << " consecutive \t \n whitespace" << "consecutive whitespace" << FormatList();
- QTest::newRow("space after newline") << "text<br/> more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
- QTest::newRow("space after paragraph") << "text<p> more text</p> more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
- QTest::newRow("space in header") << "<h1> head</h1> " << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) << (FormatList() << Format(Format::Bold, 0, 5));
- QTest::newRow("space before bold") << "this is <b>bold</b>" << "this is bold" << (FormatList() << Format(Format::Bold, 8, 4));
- QTest::newRow("space leading bold") << "this is<b> bold</b>" << "this is bold" << (FormatList() << Format(Format::Bold, 7, 5));
- QTest::newRow("space trailing bold") << "this is <b>bold </b>" << "this is bold " << (FormatList() << Format(Format::Bold, 8, 5));
- QTest::newRow("img") << "a<img src=\"blah.png\"/>b" << "a b" << FormatList();
-}
-
-void tst_qdeclarativestyledtext::textOutput()
-{
- QFETCH(QString, input);
- QFETCH(QString, output);
- QFETCH(FormatList, formats);
-
- QTextLayout layout;
- QList<QDeclarativeStyledTextImgTag*> imgTags;
- QDeclarativeStyledText::parse(input, layout, imgTags, QUrl(), 0, false);
-
- QCOMPARE(layout.text(), output);
-
- QList<QTextLayout::FormatRange> layoutFormats = layout.additionalFormats();
-
- QCOMPARE(layoutFormats.count(), formats.count());
- for (int i = 0; i < formats.count(); ++i) {
- QCOMPARE(layoutFormats.at(i).start, formats.at(i).start);
- QCOMPARE(layoutFormats.at(i).length, formats.at(i).length);
- if (formats.at(i).type & Format::Bold)
- QVERIFY(layoutFormats.at(i).format.fontWeight() == QFont::Bold);
- else
- QVERIFY(layoutFormats.at(i).format.fontWeight() == QFont::Normal);
- QVERIFY(layoutFormats.at(i).format.fontItalic() == bool(formats.at(i).type & Format::Italic));
- QVERIFY(layoutFormats.at(i).format.fontUnderline() == bool(formats.at(i).type & Format::Underline));
- }
-}
-
-
-QTEST_MAIN(tst_qdeclarativestyledtext)
-
-#include "tst_qdeclarativestyledtext.moc"
diff --git a/tests/auto/qtquick2/qdeclarativesystempalette/qdeclarativesystempalette.pro b/tests/auto/qtquick2/qdeclarativesystempalette/qdeclarativesystempalette.pro
deleted file mode 100644
index 87c2af2190..0000000000
--- a/tests/auto/qtquick2/qdeclarativesystempalette/qdeclarativesystempalette.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativesystempalette
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativesystempalette.cpp
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private quick-private widgets testlib
diff --git a/tests/auto/qtquick2/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp b/tests/auto/qtquick2/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp
deleted file mode 100644
index f2b1eeb602..0000000000
--- a/tests/auto/qtquick2/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDebug>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/private/qdeclarativesystempalette_p.h>
-#include <qpalette.h>
-
-class tst_qdeclarativesystempalette : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativesystempalette();
-
-private slots:
- void activePalette();
- void inactivePalette();
- void disabledPalette();
- void paletteChanged();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativesystempalette::tst_qdeclarativesystempalette()
-{
-}
-
-void tst_qdeclarativesystempalette::activePalette()
-{
- QString componentStr = "import QtQuick 2.0\nSystemPalette { }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeSystemPalette *object = qobject_cast<QDeclarativeSystemPalette*>(component.create());
-
- QVERIFY(object != 0);
-
- QPalette palette;
- palette.setCurrentColorGroup(QPalette::Active);
- QCOMPARE(palette.window().color(), object->window());
- QCOMPARE(palette.windowText().color(), object->windowText());
- QCOMPARE(palette.base().color(), object->base());
- QCOMPARE(palette.text().color(), object->text());
- QCOMPARE(palette.alternateBase().color(), object->alternateBase());
- QCOMPARE(palette.button().color(), object->button());
- QCOMPARE(palette.buttonText().color(), object->buttonText());
- QCOMPARE(palette.light().color(), object->light());
- QCOMPARE(palette.midlight().color(), object->midlight());
- QCOMPARE(palette.dark().color(), object->dark());
- QCOMPARE(palette.mid().color(), object->mid());
- QCOMPARE(palette.shadow().color(), object->shadow());
- QCOMPARE(palette.highlight().color(), object->highlight());
- QCOMPARE(palette.highlightedText().color(), object->highlightedText());
-
- delete object;
-}
-
-void tst_qdeclarativesystempalette::inactivePalette()
-{
- QString componentStr = "import QtQuick 2.0\nSystemPalette { colorGroup: SystemPalette.Inactive }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeSystemPalette *object = qobject_cast<QDeclarativeSystemPalette*>(component.create());
-
- QVERIFY(object != 0);
- QVERIFY(object->colorGroup() == QDeclarativeSystemPalette::Inactive);
-
- QPalette palette;
- palette.setCurrentColorGroup(QPalette::Inactive);
- QCOMPARE(palette.window().color(), object->window());
- QCOMPARE(palette.windowText().color(), object->windowText());
- QCOMPARE(palette.base().color(), object->base());
- QCOMPARE(palette.text().color(), object->text());
- QCOMPARE(palette.alternateBase().color(), object->alternateBase());
- QCOMPARE(palette.button().color(), object->button());
- QCOMPARE(palette.buttonText().color(), object->buttonText());
- QCOMPARE(palette.light().color(), object->light());
- QCOMPARE(palette.midlight().color(), object->midlight());
- QCOMPARE(palette.dark().color(), object->dark());
- QCOMPARE(palette.mid().color(), object->mid());
- QCOMPARE(palette.shadow().color(), object->shadow());
- QCOMPARE(palette.highlight().color(), object->highlight());
- QCOMPARE(palette.highlightedText().color(), object->highlightedText());
-
- delete object;
-}
-
-void tst_qdeclarativesystempalette::disabledPalette()
-{
- QString componentStr = "import QtQuick 2.0\nSystemPalette { colorGroup: SystemPalette.Disabled }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeSystemPalette *object = qobject_cast<QDeclarativeSystemPalette*>(component.create());
-
- QVERIFY(object != 0);
- QVERIFY(object->colorGroup() == QDeclarativeSystemPalette::Disabled);
-
- QPalette palette;
- palette.setCurrentColorGroup(QPalette::Disabled);
- QCOMPARE(palette.window().color(), object->window());
- QCOMPARE(palette.windowText().color(), object->windowText());
- QCOMPARE(palette.base().color(), object->base());
- QCOMPARE(palette.text().color(), object->text());
- QCOMPARE(palette.alternateBase().color(), object->alternateBase());
- QCOMPARE(palette.button().color(), object->button());
- QCOMPARE(palette.buttonText().color(), object->buttonText());
- QCOMPARE(palette.light().color(), object->light());
- QCOMPARE(palette.midlight().color(), object->midlight());
- QCOMPARE(palette.dark().color(), object->dark());
- QCOMPARE(palette.mid().color(), object->mid());
- QCOMPARE(palette.shadow().color(), object->shadow());
- QCOMPARE(palette.highlight().color(), object->highlight());
- QCOMPARE(palette.highlightedText().color(), object->highlightedText());
-
- delete object;
-}
-
-void tst_qdeclarativesystempalette::paletteChanged()
-{
- QString componentStr = "import QtQuick 2.0\nSystemPalette { }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QDeclarativeSystemPalette *object = qobject_cast<QDeclarativeSystemPalette*>(component.create());
-
- QVERIFY(object != 0);
-
- QPalette p;
- p.setCurrentColorGroup(QPalette::Active);
- p.setColor(QPalette::Active, QPalette::Text, QColor("red"));
- p.setColor(QPalette::Active, QPalette::ButtonText, QColor("green"));
- p.setColor(QPalette::Active, QPalette::WindowText, QColor("blue"));
-
- qApp->setPalette(p);
-
- object->setColorGroup(QDeclarativeSystemPalette::Active);
- QTRY_COMPARE(QColor("red"), object->text());
- QTRY_COMPARE(QColor("green"), object->buttonText());
- QTRY_COMPARE(QColor("blue"), object->windowText());
-
- delete object;
-}
-
-QTEST_MAIN(tst_qdeclarativesystempalette)
-
-#include "tst_qdeclarativesystempalette.moc"
diff --git a/tests/auto/qtquick2/qdeclarativetimer/qdeclarativetimer.pro b/tests/auto/qtquick2/qdeclarativetimer/qdeclarativetimer.pro
deleted file mode 100644
index d990dc449f..0000000000
--- a/tests/auto/qtquick2/qdeclarativetimer/qdeclarativetimer.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativetimer
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativetimer.cpp
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private quick-private gui testlib
diff --git a/tests/auto/qtquick2/qdeclarativetimer/tst_qdeclarativetimer.cpp b/tests/auto/qtquick2/qdeclarativetimer/tst_qdeclarativetimer.cpp
deleted file mode 100644
index 4aa35d7488..0000000000
--- a/tests/auto/qtquick2/qdeclarativetimer/tst_qdeclarativetimer.cpp
+++ /dev/null
@@ -1,393 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QSignalSpy>
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/private/qdeclarativetimer_p.h>
-#include <QtQuick/qquickitem.h>
-#include <QDebug>
-
-class tst_qdeclarativetimer : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativetimer();
-
-private slots:
- void notRepeating();
- void notRepeatingStart();
- void repeat();
- void noTriggerIfNotRunning();
- void triggeredOnStart();
- void triggeredOnStartRepeat();
- void changeDuration();
- void restart();
- void restartFromTriggered();
- void runningFromTriggered();
- void parentProperty();
-};
-
-class TimerHelper : public QObject
-{
- Q_OBJECT
-public:
- TimerHelper() : QObject(), count(0)
- {
- }
-
- int count;
-
-public slots:
- void timeout() {
- ++count;
- }
-};
-
-#define TIMEOUT_TIMEOUT 200
-
-tst_qdeclarativetimer::tst_qdeclarativetimer()
-{
-}
-
-void tst_qdeclarativetimer::notRepeating()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true }"), QUrl::fromLocalFile(""));
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
- QVERIFY(timer != 0);
- QVERIFY(timer->isRunning());
- QVERIFY(!timer->isRepeating());
- QCOMPARE(timer->interval(), 100);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 1);
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 1);
- QVERIFY(timer->isRunning() == false);
-}
-
-void tst_qdeclarativetimer::notRepeatingStart()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100 }"), QUrl::fromLocalFile(""));
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
- QVERIFY(timer != 0);
- QVERIFY(!timer->isRunning());
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 0);
-
- timer->start();
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 1);
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 1);
- QVERIFY(timer->isRunning() == false);
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::repeat()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; repeat: true; running: true }"), QUrl::fromLocalFile(""));
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QCOMPARE(helper.count, 0);
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count > 0);
- int oldCount = helper.count;
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count > oldCount);
- QVERIFY(timer->isRunning());
-
- oldCount = helper.count;
- timer->stop();
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count == oldCount);
- QVERIFY(timer->isRunning() == false);
-
- QSignalSpy spy(timer, SIGNAL(repeatChanged()));
-
- timer->setRepeating(false);
- QVERIFY(!timer->isRepeating());
- QCOMPARE(spy.count(),1);
-
- timer->setRepeating(false);
- QCOMPARE(spy.count(),1);
-
- timer->setRepeating(true);
- QCOMPARE(spy.count(),2);
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::triggeredOnStart()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true; triggeredOnStart: true }"), QUrl::fromLocalFile(""));
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
- QVERIFY(timer != 0);
- QVERIFY(timer->triggeredOnStart());
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QTest::qWait(1);
- QCOMPARE(helper.count, 1);
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 2);
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(helper.count, 2);
- QVERIFY(timer->isRunning() == false);
-
- QSignalSpy spy(timer, SIGNAL(triggeredOnStartChanged()));
-
- timer->setTriggeredOnStart(false);
- QVERIFY(!timer->triggeredOnStart());
- QCOMPARE(spy.count(),1);
-
- timer->setTriggeredOnStart(false);
- QCOMPARE(spy.count(),1);
-
- timer->setTriggeredOnStart(true);
- QCOMPARE(spy.count(),2);
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::triggeredOnStartRepeat()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true; triggeredOnStart: true; repeat: true }"), QUrl::fromLocalFile(""));
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QTest::qWait(1);
- QCOMPARE(helper.count, 1);
-
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count > 1);
- int oldCount = helper.count;
- QTest::qWait(TIMEOUT_TIMEOUT);
- QVERIFY(helper.count > oldCount);
- QVERIFY(timer->isRunning());
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::noTriggerIfNotRunning()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray(
- "import QtQuick 2.0\n"
- "Item { property bool ok: true\n"
- "Timer { id: t1; interval: 100; repeat: true; running: true; onTriggered: if (!running) ok=false }"
- "Timer { interval: 10; running: true; onTriggered: t1.running=false }"
- "}"
- ), QUrl::fromLocalFile(""));
- QObject *item = component.create();
- QVERIFY(item != 0);
- QTest::qWait(TIMEOUT_TIMEOUT);
- QCOMPARE(item->property("ok").toBool(), true);
-
- delete item;
-}
-
-void tst_qdeclarativetimer::changeDuration()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 200; repeat: true; running: true }"), QUrl::fromLocalFile(""));
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QCOMPARE(helper.count, 0);
-
- QTest::qWait(500);
- QCOMPARE(helper.count, 2);
-
- timer->setInterval(500);
-
- QTest::qWait(600);
- QCOMPARE(helper.count, 3);
- QVERIFY(timer->isRunning());
-
- QSignalSpy spy(timer, SIGNAL(intervalChanged()));
-
- timer->setInterval(200);
- QCOMPARE(timer->interval(), 200);
- QCOMPARE(spy.count(),1);
-
- timer->setInterval(200);
- QCOMPARE(spy.count(),1);
-
- timer->setInterval(300);
- QCOMPARE(spy.count(),2);
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::restart()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 500; repeat: true; running: true }"), QUrl::fromLocalFile(""));
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(component.create());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QCOMPARE(helper.count, 0);
-
- QTest::qWait(600);
- QCOMPARE(helper.count, 1);
-
- QTest::qWait(300);
-
- timer->restart();
-
- QTest::qWait(700);
-
- QCOMPARE(helper.count, 2);
- QVERIFY(timer->isRunning());
-
- delete timer;
-}
-
-void tst_qdeclarativetimer::restartFromTriggered()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { "
- "interval: 500; "
- "repeat: false; "
- "running: true; "
- "onTriggered: restart()"
- " }"), QUrl::fromLocalFile(""));
- QScopedPointer<QObject> object(component.create());
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(object.data());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QCOMPARE(helper.count, 0);
-
- QTest::qWait(600);
- QCOMPARE(helper.count, 1);
- QVERIFY(timer->isRunning());
-
- QTest::qWait(600);
- QCOMPARE(helper.count, 2);
- QVERIFY(timer->isRunning());
-}
-
-void tst_qdeclarativetimer::runningFromTriggered()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nTimer { "
- "property bool ok: false; "
- "interval: 500; "
- "repeat: false; "
- "running: true; "
- "onTriggered: { ok = !running; running = true }"
- " }"), QUrl::fromLocalFile(""));
- QScopedPointer<QObject> object(component.create());
- QDeclarativeTimer *timer = qobject_cast<QDeclarativeTimer*>(object.data());
- QVERIFY(timer != 0);
-
- TimerHelper helper;
- connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
- QCOMPARE(helper.count, 0);
-
- QTest::qWait(600);
- QCOMPARE(helper.count, 1);
- QVERIFY(timer->property("ok").toBool());
- QVERIFY(timer->isRunning());
-
- QTest::qWait(600);
- QCOMPARE(helper.count, 2);
- QVERIFY(timer->property("ok").toBool());
- QVERIFY(timer->isRunning());
-}
-
-void tst_qdeclarativetimer::parentProperty()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nItem { Timer { objectName: \"timer\"; running: parent.visible } }"), QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item != 0);
- QDeclarativeTimer *timer = item->findChild<QDeclarativeTimer*>("timer");
- QVERIFY(timer != 0);
-
- QVERIFY(timer->isRunning());
-
- delete timer;
-}
-
-QTEST_MAIN(tst_qdeclarativetimer)
-
-#include "tst_qdeclarativetimer.moc"
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro b/tests/auto/qtquick2/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
deleted file mode 100644
index 37f1c65c92..0000000000
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qdeclarativexmllistmodel
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativexmllistmodel.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private network testlib xmlpatterns
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/qtquick2/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
deleted file mode 100644
index 80ceb9a712..0000000000
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
+++ /dev/null
@@ -1,962 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtGlobal>
-#include <math.h>
-#include <QMetaObject>
-#include <qtest.h>
-#include <QtTest/qsignalspy.h>
-#include <QtDeclarative/qdeclarativenetworkaccessmanagerfactory.h>
-#include <QtNetwork/qnetworkaccessmanager.h>
-#include <QtNetwork/qnetworkrequest.h>
-#include <QtCore/qtimer.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qtemporaryfile.h>
-#include "../../shared/util.h"
-#include <private/qdeclarativeengine_p.h>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qlistmodelinterface_p.h>
-#include "../../../../src/imports/xmllistmodel/qdeclarativexmllistmodel_p.h"
-
-typedef QPair<int, int> QDeclarativeXmlListRange;
-typedef QList<QVariantList> QDeclarativeXmlModelData;
-
-Q_DECLARE_METATYPE(QList<QDeclarativeXmlListRange>)
-Q_DECLARE_METATYPE(QDeclarativeXmlModelData)
-Q_DECLARE_METATYPE(QDeclarativeXmlListModel::Status)
-
-class tst_qdeclarativexmllistmodel : public QDeclarativeDataTest
-
-{
- Q_OBJECT
-public:
- tst_qdeclarativexmllistmodel() {}
-
-private slots:
- void initTestCase() {
- QDeclarativeDataTest::initTestCase();
- qRegisterMetaType<QDeclarativeXmlListModel::Status>();
- }
-
- void buildModel();
- void testTypes();
- void testTypes_data();
- void cdata();
- void attributes();
- void roles();
- void roleErrors();
- void uniqueRoleNames();
- void headers();
- void xml();
- void xml_data();
- void source();
- void source_data();
- void data();
- void get();
- void reload();
- void useKeys();
- void useKeys_data();
- void noKeysValueChanges();
- void keysChanged();
- void threading();
- void threading_data();
- void propertyChanges();
-
- void roleCrash();
-
-private:
- QString errorString(QListModelInterface* model) {
- QString ret;
- QMetaObject::invokeMethod(model, "errorString", Q_RETURN_ARG(QString, ret));
- return ret;
- }
-
- QString makeItemXmlAndData(const QString &data, QDeclarativeXmlModelData *modelData = 0) const
- {
- if (modelData)
- modelData->clear();
- QString xml;
-
- if (!data.isEmpty()) {
- QStringList items = data.split(";");
- foreach(const QString &item, items) {
- if (item.isEmpty())
- continue;
- QVariantList variants;
- xml += QLatin1String("<item>");
- QStringList fields = item.split(",");
- foreach(const QString &field, fields) {
- QStringList values = field.split("=");
- if (values.count() != 2) {
- qWarning() << "makeItemXmlAndData: invalid field:" << field;
- continue;
- }
- xml += QString("<%1>%2</%1>").arg(values[0], values[1]);
- if (!modelData)
- continue;
- bool isNum = false;
- int number = values[1].toInt(&isNum);
- if (isNum)
- variants << number;
- else
- variants << values[1];
- }
- xml += QLatin1String("</item>");
- if (modelData)
- modelData->append(variants);
- }
- }
-
- QString decl = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>";
- return decl + QLatin1String("<data>") + xml + QLatin1String("</data>");
- }
-
- QDeclarativeEngine engine;
-};
-
-class CustomNetworkAccessManagerFactory : public QObject, public QDeclarativeNetworkAccessManagerFactory
-{
- Q_OBJECT
-public:
- QVariantMap lastSentHeaders;
-
-protected:
- QNetworkAccessManager *create(QObject *parent);
-};
-
-class CustomNetworkAccessManager : public QNetworkAccessManager
-{
- Q_OBJECT
-public:
- CustomNetworkAccessManager(CustomNetworkAccessManagerFactory *factory, QObject *parent)
- : QNetworkAccessManager(parent), m_factory(factory) {}
-
-protected:
- QNetworkReply *createRequest(Operation op, const QNetworkRequest &req, QIODevice * outgoingData = 0)
- {
- if (m_factory) {
- QVariantMap map;
- foreach (const QString &header, req.rawHeaderList())
- map[header] = req.rawHeader(header.toUtf8());
- m_factory->lastSentHeaders = map;
- }
- return QNetworkAccessManager::createRequest(op, req, outgoingData);
- }
-
- QPointer<CustomNetworkAccessManagerFactory> m_factory;
-};
-
-QNetworkAccessManager *CustomNetworkAccessManagerFactory::create(QObject *parent)
-{
- return new CustomNetworkAccessManager(this, parent);
-}
-
-
-void tst_qdeclarativexmllistmodel::buildModel()
-{
- QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
- QCOMPARE(model->data(3, Qt::UserRole).toString(), QLatin1String("Spot"));
- QCOMPARE(model->data(3, Qt::UserRole+1).toString(), QLatin1String("Dog"));
- QCOMPARE(model->data(3, Qt::UserRole+2).toInt(), 9);
- QCOMPARE(model->data(3, Qt::UserRole+3).toString(), QLatin1String("Medium"));
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::testTypes()
-{
- QFETCH(QString, xml);
- QFETCH(QString, roleName);
- QFETCH(QVariant, expectedValue);
-
- QDeclarativeComponent component(&engine, testFileUrl("testtypes.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- model->setProperty("xml",xml.toUtf8());
- QMetaObject::invokeMethod(model, "reload");
- QTRY_COMPARE(model->count(), 1);
-
- int role = -1;
- foreach (int i, model->roles()) {
- if (model->toString(i) == roleName) {
- role = i;
- break;
- }
- }
- QVERIFY(role >= 0);
-
- if (expectedValue.toString() == "nan")
- QVERIFY(qIsNaN(model->data(0, role).toDouble()));
- else
- QCOMPARE(model->data(0, role), expectedValue);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::testTypes_data()
-{
- QTest::addColumn<QString>("xml");
- QTest::addColumn<QString>("roleName");
- QTest::addColumn<QVariant>("expectedValue");
-
- QTest::newRow("missing string field") << "<data></data>"
- << "stringValue" << QVariant("");
- QTest::newRow("empty string") << "<data><a-string></a-string></data>"
- << "stringValue" << QVariant("");
- QTest::newRow("1-char string") << "<data><a-string>5</a-string></data>"
- << "stringValue" << QVariant("5");
- QTest::newRow("string ok") << "<data><a-string>abc def g</a-string></data>"
- << "stringValue" << QVariant("abc def g");
-
- QTest::newRow("missing number field") << "<data></data>"
- << "numberValue" << QVariant("");
- double nan = qQNaN();
- QTest::newRow("empty number field") << "<data><a-number></a-number></data>"
- << "numberValue" << QVariant(nan);
- QTest::newRow("number field with string") << "<data><a-number>a string</a-number></data>"
- << "numberValue" << QVariant(nan);
- QTest::newRow("-1") << "<data><a-number>-1</a-number></data>"
- << "numberValue" << QVariant("-1");
- QTest::newRow("-1.5") << "<data><a-number>-1.5</a-number></data>"
- << "numberValue" << QVariant("-1.5");
- QTest::newRow("0") << "<data><a-number>0</a-number></data>"
- << "numberValue" << QVariant("0");
- QTest::newRow("+1") << "<data><a-number>1</a-number></data>"
- << "numberValue" << QVariant("1");
- QTest::newRow("+1.5") << "<data><a-number>1.5</a-number></data>"
- << "numberValue" << QVariant("1.5");
-}
-
-void tst_qdeclarativexmllistmodel::cdata()
-{
- QDeclarativeComponent component(&engine, testFileUrl("recipes.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 5);
-
- QVERIFY(model->data(2, Qt::UserRole+2).toString().startsWith(QLatin1String("<html>")));
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::attributes()
-{
- QDeclarativeComponent component(&engine, testFileUrl("recipes.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 5);
- QCOMPARE(model->data(2, Qt::UserRole).toString(), QLatin1String("Vegetable Soup"));
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::roles()
-{
- QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
- QList<int> roles = model->roles();
- QCOMPARE(roles.count(), 4);
- QCOMPARE(model->toString(roles.at(0)), QLatin1String("name"));
- QCOMPARE(model->toString(roles.at(1)), QLatin1String("type"));
- QCOMPARE(model->toString(roles.at(2)), QLatin1String("age"));
- QCOMPARE(model->toString(roles.at(3)), QLatin1String("size"));
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::roleErrors()
-{
- QDeclarativeComponent component(&engine, testFileUrl("roleErrors.qml"));
- QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":7:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData());
- QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":10:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData());
-
- //### make sure we receive all expected warning messages.
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
-
- //### should any of these return valid values?
- QCOMPARE(model->data(3, Qt::UserRole), QVariant());
- QCOMPARE(model->data(3, Qt::UserRole+1), QVariant());
- QCOMPARE(model->data(3, Qt::UserRole+2), QVariant());
-
- QEXPECT_FAIL("", "QTBUG-10797", Continue);
- QCOMPARE(model->data(3, Qt::UserRole+3), QVariant());
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::uniqueRoleNames()
-{
- QDeclarativeComponent component(&engine, testFileUrl("unique.qml"));
- QTest::ignoreMessage(QtWarningMsg, (testFileUrl("unique.qml").toString() + ":8:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData());
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
- QList<int> roles = model->roles();
- QCOMPARE(roles.count(), 1);
-
- delete model;
-}
-
-
-void tst_qdeclarativexmllistmodel::xml()
-{
- QFETCH(QString, xml);
- QFETCH(int, count);
-
- QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
-
- QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status)));
- QVERIFY(errorString(model).isEmpty());
- QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Loading);
- QTRY_COMPARE(spy.count(), 1); spy.clear();
- QTest::qWait(50);
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Ready);
- QVERIFY(errorString(model).isEmpty());
- QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
- QCOMPARE(model->count(), 9);
-
- // if xml is empty (i.e. clearing) it won't have any effect if a source is set
- if (xml.isEmpty())
- model->setProperty("source",QUrl());
- model->setProperty("xml",xml);
- QCOMPARE(model->property("progress").toDouble(), qreal(1.0)); // immediately goes to 1.0 if using setXml()
- QTRY_COMPARE(spy.count(), 1); spy.clear();
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Loading);
- QTRY_COMPARE(spy.count(), 1); spy.clear();
- if (xml.isEmpty())
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Null);
- else
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Ready);
- QVERIFY(errorString(model).isEmpty());
- QCOMPARE(model->count(), count);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::xml_data()
-{
- QTest::addColumn<QString>("xml");
- QTest::addColumn<int>("count");
-
- QTest::newRow("xml with no items") << "<Pets></Pets>" << 0;
- QTest::newRow("empty xml") << "" << 0;
- QTest::newRow("one item") << "<Pets><Pet><name>Hobbes</name><type>Tiger</type><age>7</age><size>Large</size></Pet></Pets>" << 1;
-}
-
-void tst_qdeclarativexmllistmodel::headers()
-{
- // ensure the QNetworkAccessManagers created for this test are immediately deleted
- QDeclarativeEngine qmlEng;
-
- CustomNetworkAccessManagerFactory factory;
- qmlEng.setNetworkAccessManagerFactory(&factory);
-
- QDeclarativeComponent component(&qmlEng, testFileUrl("model.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Ready);
-
- QVariantMap expectedHeaders;
- expectedHeaders["Accept"] = "application/xml,*/*";
-
- QCOMPARE(factory.lastSentHeaders.count(), expectedHeaders.count());
- foreach (const QString &header, expectedHeaders.keys()) {
- QVERIFY(factory.lastSentHeaders.contains(header));
- QCOMPARE(factory.lastSentHeaders[header].toString(), expectedHeaders[header].toString());
- }
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::source()
-{
- QFETCH(QUrl, source);
- QFETCH(int, count);
- QFETCH(QDeclarativeXmlListModel::Status, status);
-
- QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status)));
-
- QVERIFY(errorString(model).isEmpty());
- QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Loading);
- QTRY_COMPARE(spy.count(), 1); spy.clear();
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Ready);
- QVERIFY(errorString(model).isEmpty());
- QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
- QCOMPARE(model->count(), 9);
-
- model->setProperty("source",source);
- if (model->property("source").toString().isEmpty())
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Null);
- QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
- QTRY_COMPARE(spy.count(), 1); spy.clear();
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
- QDeclarativeXmlListModel::Loading);
- QVERIFY(errorString(model).isEmpty());
-
- QEventLoop loop;
- QTimer timer;
- timer.setSingleShot(true);
- connect(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status)), &loop, SLOT(quit()));
- connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
- timer.start(20000);
- loop.exec();
-
- if (spy.count() == 0 && status != QDeclarativeXmlListModel::Ready) {
- qWarning("QDeclarativeXmlListModel invalid source test timed out");
- } else {
- QCOMPARE(spy.count(), 1); spy.clear();
- }
-
- QCOMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")), status);
- QCOMPARE(model->count(), count);
-
- if (status == QDeclarativeXmlListModel::Ready)
- QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
-
- QCOMPARE(errorString(model).isEmpty(), status == QDeclarativeXmlListModel::Ready);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::source_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<int>("count");
- QTest::addColumn<QDeclarativeXmlListModel::Status>("status");
-
- QTest::newRow("valid") << testFileUrl("model2.xml") << 2
- << QDeclarativeXmlListModel::Ready;
- QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0
- << QDeclarativeXmlListModel::Error;
-
- // empty file
- QTemporaryFile *temp = new QTemporaryFile(this);
- if (temp->open())
- QTest::newRow("empty file") << QUrl::fromLocalFile(temp->fileName()) << 0
- << QDeclarativeXmlListModel::Ready;
- temp->close();
-}
-
-void tst_qdeclarativexmllistmodel::data()
-{
- QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
-
- for (int i=0; i<9; i++) {
- for (int j=0; j<model->roles().count(); j++) {
- QCOMPARE(model->data(i, j), QVariant());
- }
- }
- QTRY_COMPARE(model->count(), 9);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::get()
-{
- QDeclarativeComponent component(&engine, testFileUrl("get.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
-
- QVERIFY(model != 0);
-
- QVERIFY(QMetaObject::invokeMethod(model, "runPreTest"));
- QCOMPARE(model->property("preTest").toBool(), true);
-
- QTRY_COMPARE(model->count(), 9);
-
- QVERIFY(QMetaObject::invokeMethod(model, "runPostTest"));
- QCOMPARE(model->property("postTest").toBool(), true);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::reload()
-{
- // If no keys are used, the model should be rebuilt from scratch when
- // reload() is called.
-
- QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
- QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
- QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
- QSignalSpy spyCount(model, SIGNAL(countChanged()));
- //reload multiple times to test the xml query aborting
- QMetaObject::invokeMethod(model, "reload");
- QMetaObject::invokeMethod(model, "reload");
- QCoreApplication::processEvents();
- QMetaObject::invokeMethod(model, "reload");
- QMetaObject::invokeMethod(model, "reload");
- QTRY_COMPARE(spyCount.count(), 1);
- QTRY_COMPARE(spyInsert.count(), 1);
- QTRY_COMPARE(spyRemove.count(), 1);
-
- QCOMPARE(spyInsert[0][0].toInt(), 0);
- QCOMPARE(spyInsert[0][1].toInt(), 9);
-
- QCOMPARE(spyRemove[0][0].toInt(), 0);
- QCOMPARE(spyRemove[0][1].toInt(), 9);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::useKeys()
-{
- // If using incremental updates through keys, the model should only
- // insert & remove some of the items, instead of throwing everything
- // away and causing the view to repaint the whole view.
-
- QFETCH(QString, oldXml);
- QFETCH(int, oldCount);
- QFETCH(QString, newXml);
- QFETCH(QDeclarativeXmlModelData, newData);
- QFETCH(QList<QDeclarativeXmlListRange>, insertRanges);
- QFETCH(QList<QDeclarativeXmlListRange>, removeRanges);
-
- QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
-
- model->setProperty("xml",oldXml);
- QTRY_COMPARE(model->count(), oldCount);
-
- QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
- QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
- QSignalSpy spyCount(model, SIGNAL(countChanged()));
-
- model->setProperty("xml",newXml);
-
- if (oldCount != newData.count()) {
- QTRY_COMPARE(model->count(), newData.count());
- QCOMPARE(spyCount.count(), 1);
- } else {
- QTRY_VERIFY(spyInsert.count() > 0 || spyRemove.count() > 0);
- QCOMPARE(spyCount.count(), 0);
- }
-
- QList<int> roles = model->roles();
- for (int i=0; i<model->count(); i++) {
- for (int j=0; j<roles.count(); j++)
- QCOMPARE(model->data(i, roles[j]), newData[i][j]);
- }
-
- QCOMPARE(spyInsert.count(), insertRanges.count());
- for (int i=0; i<spyInsert.count(); i++) {
- QCOMPARE(spyInsert[i][0].toInt(), insertRanges[i].first);
- QCOMPARE(spyInsert[i][1].toInt(), insertRanges[i].second);
- }
-
- QCOMPARE(spyRemove.count(), removeRanges.count());
- for (int i=0; i<spyRemove.count(); i++) {
- QCOMPARE(spyRemove[i][0].toInt(), removeRanges[i].first);
- QCOMPARE(spyRemove[i][1].toInt(), removeRanges[i].second);
- }
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::useKeys_data()
-{
- QTest::addColumn<QString>("oldXml");
- QTest::addColumn<int>("oldCount");
- QTest::addColumn<QString>("newXml");
- QTest::addColumn<QDeclarativeXmlModelData>("newData");
- QTest::addColumn<QList<QDeclarativeXmlListRange> >("insertRanges");
- QTest::addColumn<QList<QDeclarativeXmlListRange> >("removeRanges");
-
- QDeclarativeXmlModelData modelData;
-
- QTest::newRow("append 1")
- << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1))
- << QList<QDeclarativeXmlListRange>();
-
- QTest::newRow("append multiple")
- << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 2))
- << QList<QDeclarativeXmlListRange>();
-
- QTest::newRow("insert in different spots")
- << makeItemXmlAndData("name=B,age=35,sport=Athletics") << 1
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1) << qMakePair(2,2))
- << QList<QDeclarativeXmlListRange>();
-
- QTest::newRow("insert in middle")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=D,age=55,sport=Golf") << 2
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 2))
- << QList<QDeclarativeXmlListRange>();
-
- QTest::newRow("remove first")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2
- << makeItemXmlAndData("name=B,age=35,sport=Athletics", &modelData)
- << modelData
- << QList<QDeclarativeXmlListRange>()
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1));
-
- QTest::newRow("remove last")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2
- << makeItemXmlAndData("name=A,age=25,sport=Football", &modelData)
- << modelData
- << QList<QDeclarativeXmlListRange>()
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1));
-
- QTest::newRow("remove from multiple spots")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 5
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=C,age=45,sport=Curling", &modelData)
- << modelData
- << QList<QDeclarativeXmlListRange>()
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1) << qMakePair(3,2));
-
- QTest::newRow("remove all")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3
- << makeItemXmlAndData("", &modelData)
- << modelData
- << QList<QDeclarativeXmlListRange>()
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 3));
-
- QTest::newRow("replace item")
- << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
- << makeItemXmlAndData("name=ZZZ,age=25,sport=Football", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1));
-
- QTest::newRow("add and remove simultaneously, in different spots")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf") << 4
- << makeItemXmlAndData("name=B,age=35,sport=Athletics;name=E,age=65,sport=Fencing", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 1))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 1) << qMakePair(2,2));
-
- QTest::newRow("insert at start, remove at end i.e. rss feed")
- << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 3
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 2))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 2));
-
- QTest::newRow("remove at start, insert at end")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3
- << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(1, 2))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 2));
-
- QTest::newRow("all data has changed")
- << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35") << 2
- << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
- << modelData
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 2))
- << (QList<QDeclarativeXmlListRange>() << qMakePair(0, 2));
-}
-
-void tst_qdeclarativexmllistmodel::noKeysValueChanges()
-{
- // The 'key' roles are 'name' and 'age', as defined in roleKeys.qml.
- // If a 'sport' value is changed, the model should not be reloaded,
- // since 'sport' is not marked as a key.
-
- QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
-
- QString xml;
-
- xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
- model->setProperty("xml",xml);
- QTRY_COMPARE(model->count(), 2);
-
- model->setProperty("xml","");
-
- QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
- QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
- QSignalSpy spyCount(model, SIGNAL(countChanged()));
-
- xml = makeItemXmlAndData("name=A,age=25,sport=AussieRules;name=B,age=35,sport=Athletics");
- model->setProperty("xml",xml);
-
- // wait for the new xml data to be set, and verify no signals were emitted
- QTRY_VERIFY(model->data(0, model->roles()[2]).toString() != QLatin1String("Football"));
- QCOMPARE(model->data(0, model->roles()[2]).toString(), QLatin1String("AussieRules"));
-
- QVERIFY(spyInsert.count() == 0);
- QVERIFY(spyRemove.count() == 0);
- QVERIFY(spyCount.count() == 0);
-
- QCOMPARE(model->count(), 2);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::keysChanged()
-{
- // If the key roles change, the next time the data is reloaded, it should
- // delete all its data and build a clean model (i.e. same behaviour as
- // if no keys are set).
-
- QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
-
- QString xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
- model->setProperty("xml",xml);
- QTRY_COMPARE(model->count(), 2);
-
- model->setProperty("xml","");
-
- QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
- QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
- QSignalSpy spyCount(model, SIGNAL(countChanged()));
-
- QVERIFY(QMetaObject::invokeMethod(model, "disableNameKey"));
- model->setProperty("xml",xml);
-
- QTRY_VERIFY(spyInsert.count() > 0 && spyRemove.count() > 0);
-
- QCOMPARE(spyInsert.count(), 1);
- QCOMPARE(spyInsert[0][0].toInt(), 0);
- QCOMPARE(spyInsert[0][1].toInt(), 2);
-
- QCOMPARE(spyRemove.count(), 1);
- QCOMPARE(spyRemove[0][0].toInt(), 0);
- QCOMPARE(spyRemove[0][1].toInt(), 2);
-
- QCOMPARE(spyCount.count(), 0);
-
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::threading()
-{
- QFETCH(int, xmlDataCount);
-
- QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml"));
-
- QListModelInterface *m1 = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(m1 != 0);
- QListModelInterface *m2 = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(m2 != 0);
- QListModelInterface *m3 = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(m3 != 0);
-
- for (int dataCount=0; dataCount<xmlDataCount; dataCount++) {
-
- QString data1, data2, data3;
- for (int i=0; i<dataCount; i++) {
- data1 += "name=A" + QString::number(i) + ",age=1" + QString::number(i) + ",sport=Football;";
- data2 += "name=B" + QString::number(i) + ",age=2" + QString::number(i) + ",sport=Athletics;";
- data3 += "name=C" + QString::number(i) + ",age=3" + QString::number(i) + ",sport=Curling;";
- }
-
- //Set the xml data multiple times with randomized order and mixed with multiple event loops
- //to test the xml query reloading/aborting, the result should be stable.
- m1->setProperty("xml",makeItemXmlAndData(data1));
- m2->setProperty("xml",makeItemXmlAndData(data2));
- m3->setProperty("xml",makeItemXmlAndData(data3));
- QCoreApplication::processEvents();
- m2->setProperty("xml",makeItemXmlAndData(data2));
- m1->setProperty("xml",makeItemXmlAndData(data1));
- m2->setProperty("xml",makeItemXmlAndData(data2));
- QCoreApplication::processEvents();
- m3->setProperty("xml",makeItemXmlAndData(data3));
- QCoreApplication::processEvents();
- m2->setProperty("xml",makeItemXmlAndData(data2));
- m1->setProperty("xml",makeItemXmlAndData(data1));
- m2->setProperty("xml",makeItemXmlAndData(data2));
- m3->setProperty("xml",makeItemXmlAndData(data3));
- QCoreApplication::processEvents();
- m2->setProperty("xml",makeItemXmlAndData(data2));
- m3->setProperty("xml",makeItemXmlAndData(data3));
- m3->setProperty("xml",makeItemXmlAndData(data3));
- QCoreApplication::processEvents();
-
- QTRY_VERIFY(m1->count() == dataCount && m2->count() == dataCount && m3->count() == dataCount);
-
- for (int i=0; i<dataCount; i++) {
- QCOMPARE(m1->data(i, m1->roles()[0]).toString(), QString("A" + QString::number(i)));
- QCOMPARE(m1->data(i, m1->roles()[1]).toString(), QString("1" + QString::number(i)));
- QCOMPARE(m1->data(i, m1->roles()[2]).toString(), QString("Football"));
-
- QCOMPARE(m2->data(i, m2->roles()[0]).toString(), QString("B" + QString::number(i)));
- QCOMPARE(m2->data(i, m2->roles()[1]).toString(), QString("2" + QString::number(i)));
- QCOMPARE(m2->data(i, m2->roles()[2]).toString(), QString("Athletics"));
-
- QCOMPARE(m3->data(i, m3->roles()[0]).toString(), QString("C" + QString::number(i)));
- QCOMPARE(m3->data(i, m3->roles()[1]).toString(), QString("3" + QString::number(i)));
- QCOMPARE(m3->data(i, m3->roles()[2]).toString(), QString("Curling"));
- }
- }
-
- delete m1;
- delete m2;
- delete m3;
-}
-
-void tst_qdeclarativexmllistmodel::threading_data()
-{
- QTest::addColumn<int>("xmlDataCount");
-
- QTest::newRow("1") << 1;
- QTest::newRow("2") << 2;
- QTest::newRow("10") << 10;
-}
-
-void tst_qdeclarativexmllistmodel::propertyChanges()
-{
- QDeclarativeComponent component(&engine, testFileUrl("propertychanges.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- QTRY_COMPARE(model->count(), 9);
-
- QObject *role = model->findChild<QObject*>("role");
- QVERIFY(role);
-
- QSignalSpy nameSpy(role, SIGNAL(nameChanged()));
- QSignalSpy querySpy(role, SIGNAL(queryChanged()));
- QSignalSpy isKeySpy(role, SIGNAL(isKeyChanged()));
-
- role->setProperty("name","size");
- role->setProperty("query","size/string()");
- role->setProperty("isKey",true);
-
- QCOMPARE(role->property("name").toString(), QString("size"));
- QCOMPARE(role->property("query").toString(), QString("size/string()"));
- QVERIFY(role->property("isKey").toBool());
-
- QCOMPARE(nameSpy.count(),1);
- QCOMPARE(querySpy.count(),1);
- QCOMPARE(isKeySpy.count(),1);
-
- role->setProperty("name","size");
- role->setProperty("query","size/string()");
- role->setProperty("isKey",true);
-
- QCOMPARE(nameSpy.count(),1);
- QCOMPARE(querySpy.count(),1);
- QCOMPARE(isKeySpy.count(),1);
-
- QSignalSpy sourceSpy(model, SIGNAL(sourceChanged()));
- QSignalSpy xmlSpy(model, SIGNAL(xmlChanged()));
- QSignalSpy modelQuerySpy(model, SIGNAL(queryChanged()));
- QSignalSpy namespaceDeclarationsSpy(model, SIGNAL(namespaceDeclarationsChanged()));
-
- model->setProperty("source",QUrl(""));
- model->setProperty("xml","<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
- model->setProperty("query","/Pets");
- model->setProperty("namespaceDeclarations","declare namespace media=\"http://search.yahoo.com/mrss/\";");
-
- QCOMPARE(model->property("source").toUrl(), QUrl(""));
- QCOMPARE(model->property("xml").toString(), QString("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>"));
- QCOMPARE(model->property("query").toString(), QString("/Pets"));
- QCOMPARE(model->property("namespaceDeclarations").toString(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";"));
-
- QTRY_VERIFY(model->count() == 1);
-
- QCOMPARE(sourceSpy.count(),1);
- QCOMPARE(xmlSpy.count(),1);
- QCOMPARE(modelQuerySpy.count(),1);
- QCOMPARE(namespaceDeclarationsSpy.count(),1);
-
- model->setProperty("source",QUrl(""));
- model->setProperty("xml","<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
- model->setProperty("query","/Pets");
- model->setProperty("namespaceDeclarations","declare namespace media=\"http://search.yahoo.com/mrss/\";");
-
- QCOMPARE(sourceSpy.count(),1);
- QCOMPARE(xmlSpy.count(),1);
- QCOMPARE(modelQuerySpy.count(),1);
- QCOMPARE(namespaceDeclarationsSpy.count(),1);
-
- QTRY_VERIFY(model->count() == 1);
- delete model;
-}
-
-void tst_qdeclarativexmllistmodel::roleCrash()
-{
- // don't crash
- QDeclarativeComponent component(&engine, testFileUrl("roleCrash.qml"));
- QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model != 0);
- delete model;
-}
-
-QTEST_MAIN(tst_qdeclarativexmllistmodel)
-
-#include "tst_qdeclarativexmllistmodel.moc"
diff --git a/tests/auto/qtquick2/qquickaccessible/data/hittest.qml b/tests/auto/qtquick2/qquickaccessible/data/hittest.qml
deleted file mode 100644
index 23d3b95157..0000000000
--- a/tests/auto/qtquick2/qquickaccessible/data/hittest.qml
+++ /dev/null
@@ -1,176 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-import QtQuick 2.0
-import "widgets"
-
-Rectangle {
- id: page
- width: 640
- height: 480
- color: "white"
- Rectangle {
- id: header
- color: "#c0c0c0"
- height: usage.height + chkClip.height
- anchors.left: parent.left
- anchors.right: parent.right
- Text {
- id: usage
- text: "Use an a11y inspect tool to see if all visible rectangles can be found with hit testing."
- }
- Rectangle {
- id: chkClip
- property bool checked: true
-
- color: (checked ? "#f0f0f0" : "#c0c0c0")
- height: label.height
- width: label.width
- anchors.left: parent.left
- anchors.bottom: parent.bottom
-
- MouseArea {
- anchors.fill: parent
- onClicked: chkClip.checked = !chkClip.checked
- }
- Text {
- id: label
- text: "Click here to toggle clipping"
- }
- }
- }
- TextRect {
- clip: chkClip.checked
- z: 2
- id: rect1
- text: "rect1"
- width: 100
- height: 100
- color: "#ffc0c0"
- anchors.top: header.bottom
- TextRect {
- id: rect10
- text: "rect10"
- width: 100
- height: 100
- x: 50
- y: 50
- color: "#ffa0a0"
- TextRect {
- id: rect100
- text: "rect100"
- width: 100
- height: 100
- x: 80
- y: 80
- color: "#ff8080"
- }
- TextRect {
- id: rect101
- text: "rect101"
- x: 100
- y: 70
- z: 3
- width: 100
- height: 100
- color: "#e06060"
- }
- TextRect {
- id: rect102
- text: "rect102"
- width: 100
- height: 100
- x: 150
- y: 60
- color: "#c04040"
- }
- }
- }
-
- TextRect {
- x: 0
- y: 50
- id: rect2
- text: "rect2"
- width: 100
- height: 100
- color: "#c0c0ff"
- TextRect {
- id: rect20
- text: "rect20"
- width: 100
- height: 100
- x: 50
- y: 50
- color: "#a0a0ff"
- TextRect {
- id: rect200
- text: "rect200"
- width: 100
- height: 100
- x: 80
- y: 80
- color: "#8080ff"
- }
- TextRect {
- id: rect201
- text: "rect201"
- x: 100
- y: 70
- z: 100
- width: 100
- height: 100
- color: "#6060e0"
- }
- TextRect {
- id: rect202
- text: "rect202"
- width: 100
- height: 100
- x: 150
- y: 60
- color: "#4040c0"
- }
- }
- }
-
-}
diff --git a/tests/auto/qtquick2/qquickaccessible/qquickaccessible.pro b/tests/auto/qtquick2/qquickaccessible/qquickaccessible.pro
deleted file mode 100644
index dc32316e28..0000000000
--- a/tests/auto/qtquick2/qquickaccessible/qquickaccessible.pro
+++ /dev/null
@@ -1,25 +0,0 @@
-CONFIG += testcase
-
-TARGET = tst_qquickaccessible
-QT += declarative-private network quick-private testlib
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickaccessible.cpp
-
-include (../../shared/util.pri)
-
-OTHER_FILES += data/checkbuttons.qml
-OTHER_FILES += data/hittest.qml
-OTHER_FILES += data/pushbutton.qml
-OTHER_FILES += data/statictext.qml
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
-CONFIG += parallel_test
-
-wince*: {
- accessneeded.files = $$QT_BUILD_TREE\\plugins\\accessible\\*.dll
- accessneeded.path = accessible
- DEPLOYMENT += accessneeded
-}
-
diff --git a/tests/auto/qtquick2/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/qtquick2/qquickaccessible/tst_qquickaccessible.cpp
deleted file mode 100644
index 2e1c2b883c..0000000000
--- a/tests/auto/qtquick2/qquickaccessible/tst_qquickaccessible.cpp
+++ /dev/null
@@ -1,410 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <QtTest/QtTest>
-#include "QtTest/qtestaccessible.h"
-
-#include <QtGui/qaccessible.h>
-
-#include <QtQuick/qquickview.h>
-#include <QtQuick/qquickitem.h>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeproperty.h>
-#include <QtQuick/private/qquickaccessibleattached_p.h>
-
-#include "../../shared/util.h"
-
-
-typedef QSharedPointer<QAccessibleInterface> QAI;
-
-#define EXPECT(cond) \
- do { \
- if (!errorAt && !(cond)) { \
- errorAt = __LINE__; \
- qWarning("level: %d, middle: %d, role: %d (%s)", treelevel, middle, iface->role(), #cond); \
- } \
- } while (0)
-
-static int verifyHierarchy(QAccessibleInterface *iface)
-{
- int errorAt = 0;
- static int treelevel = 0; // for error diagnostics
- QAccessibleInterface *middleChild, *if2;
- middleChild = 0;
- ++treelevel;
- int middle = iface->childCount()/2 + 1;
- if (iface->childCount() >= 2) {
- middleChild = iface->child(middle - 1);
- }
- for (int i = 0; i < iface->childCount() && !errorAt; ++i) {
- if2 = iface->child(i);
- EXPECT(if2 != 0);
- // navigate Ancestor...
- QAccessibleInterface *parent = if2->parent();
- EXPECT(iface->object() == parent->object());
- delete parent;
-
- // verify children...
- if (!errorAt)
- errorAt = verifyHierarchy(if2);
- delete if2;
- }
- delete middleChild;
-
- --treelevel;
- return errorAt;
-}
-
-
-//TESTED_FILES=
-
-class tst_QQuickAccessible : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickAccessible();
- virtual ~tst_QQuickAccessible();
-
-private slots:
- void commonTests_data();
- void commonTests();
-
- void declarativeAttachedProperties();
- void basicPropertiesTest();
- void hitTest();
- void checkableTest();
-};
-
-tst_QQuickAccessible::tst_QQuickAccessible()
-{
-
-}
-
-tst_QQuickAccessible::~tst_QQuickAccessible()
-{
-
-}
-
-void tst_QQuickAccessible::commonTests_data()
-{
- QTest::addColumn<QString>("accessibleRoleFileName");
-
- QTest::newRow("StaticText") << SRCDIR "/data/statictext.qml";
- QTest::newRow("PushButton") << SRCDIR "/data/pushbutton.qml";
-}
-
-void tst_QQuickAccessible::commonTests()
-{
- QFETCH(QString, accessibleRoleFileName);
-
- qDebug() << "testing" << accessibleRoleFileName;
-
- QQuickView *view = new QQuickView();
-// view->setFixedSize(240,320);
- view->setSource(QUrl::fromLocalFile(accessibleRoleFileName));
- view->show();
-// view->setFocus();
- QVERIFY(view->rootObject() != 0);
-
- QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(view);
- QVERIFY(iface);
-
- delete iface;
- delete view;
-}
-
-
-
-QString eventName(const int ev)
-{
- switch (ev) {
- case 0x0001: return "SoundPlayed";
- case 0x0002: return "Alert";
- case 0x0003: return "ForegroundChanged";
- case 0x0004: return "MenuStart";
- case 0x0005: return "MenuEnd";
- case 0x0006: return "PopupMenuStart";
- case 0x0007: return "PopupMenuEnd";
- case 0x000C: return "ContextHelpStart";
- case 0x000D: return "ContextHelpEnd";
- case 0x000E: return "DragDropStart";
- case 0x000F: return "DragDropEnd";
- case 0x0010: return "DialogStart";
- case 0x0011: return "DialogEnd";
- case 0x0012: return "ScrollingStart";
- case 0x0013: return "ScrollingEnd";
- case 0x0018: return "MenuCommand";
- case 0x8000: return "ObjectCreated";
- case 0x8001: return "ObjectDestroyed";
- case 0x8002: return "ObjectShow";
- case 0x8003: return "ObjectHide";
- case 0x8004: return "ObjectReorder";
- case 0x8005: return "Focus";
- case 0x8006: return "Selection";
- case 0x8007: return "SelectionAdd";
- case 0x8008: return "SelectionRemove";
- case 0x8009: return "SelectionWithin";
- case 0x800A: return "StateChanged";
- case 0x800B: return "LocationChanged";
- case 0x800C: return "NameChanged";
- case 0x800D: return "DescriptionChanged";
- case 0x800E: return "ValueChanged";
- case 0x800F: return "ParentChanged";
- case 0x80A0: return "HelpChanged";
- case 0x80B0: return "DefaultActionChanged";
- case 0x80C0: return "AcceleratorChanged";
- default: return "Unknown Event";
- }
-}
-
-void tst_QQuickAccessible::declarativeAttachedProperties()
-{
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nItem {\n"
- "}", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
- QCOMPARE(attachedObject, static_cast<QObject*>(0));
- delete object;
- }
-
- // Attached property
- {
- QObject parent;
- QQuickAccessibleAttached *attachedObj = new QQuickAccessibleAttached(&parent);
-
- attachedObj->name();
-
- QVariant pp = attachedObj->property("name");
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nItem {\n"
- "Accessible.role: Accessible.Button\n"
- "}", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
- QVERIFY(attachedObject);
- if (attachedObject) {
- QVariant p = attachedObject->property("role");
- QCOMPARE(p.isNull(), false);
- QCOMPARE(p.toInt(), int(QAccessible::PushButton));
- p = attachedObject->property("name");
- QCOMPARE(p.isNull(), true);
- p = attachedObject->property("description");
- QCOMPARE(p.isNull(), true);
- }
- delete object;
- }
-
- // Attached property
- {
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nItem {\n"
- "Accessible.role: Accessible.Button\n"
- "Accessible.name: \"Donald\"\n"
- "Accessible.description: \"Duck\"\n"
- "}", QUrl());
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
- QVERIFY(attachedObject);
- if (attachedObject) {
- QVariant p = attachedObject->property("role");
- QCOMPARE(p.isNull(), false);
- QCOMPARE(p.toInt(), int(QAccessible::PushButton));
- p = attachedObject->property("name");
- QCOMPARE(p.isNull(), false);
- QCOMPARE(p.toString(), QLatin1String("Donald"));
- p = attachedObject->property("description");
- QCOMPARE(p.isNull(), false);
- QCOMPARE(p.toString(), QLatin1String("Duck"));
- }
- delete object;
- }
-}
-
-
-void tst_QQuickAccessible::basicPropertiesTest()
-{
- QAI app = QAI(QAccessible::queryAccessibleInterface(qApp));
- QCOMPARE(app->childCount(), 0);
-
- QQuickView *canvas = new QQuickView();
- canvas->setSource(testFileUrl("statictext.qml"));
- canvas->show();
- QCOMPARE(app->childCount(), 1);
-
- QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas));
- QVERIFY(iface.data());
- QCOMPARE(iface->childCount(), 1);
-
- QAI item = QAI(iface->child(0));
- QVERIFY(item.data());
- QCOMPARE(item->childCount(), 2);
- QCOMPARE(item->rect().size(), QSize(400, 400));
- QCOMPARE(item->role(), QAccessible::Pane);
- QCOMPARE(iface->indexOfChild(item.data()), 0);
-
- QAI text = QAI(item->child(0));
- QVERIFY(text.data());
- QCOMPARE(text->childCount(), 0);
-
- QCOMPARE(text->text(QAccessible::Name), QLatin1String("Hello Accessibility"));
- QCOMPARE(text->rect().size(), QSize(200, 50));
- QCOMPARE(text->rect().x(), item->rect().x() + 100);
- QCOMPARE(text->rect().y(), item->rect().y() + 20);
- QCOMPARE(text->role(), QAccessible::StaticText);
- QCOMPARE(item->indexOfChild(text.data()), 0);
-
- QAI text2 = QAI(item->child(1));
- QVERIFY(text2.data());
- QCOMPARE(text2->childCount(), 0);
-
- QCOMPARE(text2->text(QAccessible::Name), QLatin1String("The Hello 2 accessible text"));
- QCOMPARE(text2->rect().size(), QSize(100, 40));
- QCOMPARE(text2->rect().x(), item->rect().x() + 100);
- QCOMPARE(text2->rect().y(), item->rect().y() + 40);
- QCOMPARE(text2->role(), QAccessible::StaticText);
- QCOMPARE(item->indexOfChild(text2.data()), 1);
-
- QCOMPARE(iface->indexOfChild(text2.data()), -1);
- QCOMPARE(text2->indexOfChild(item.data()), -1);
-
- delete canvas;
-}
-
-QAI topLevelChildAt(QAccessibleInterface *iface, int x, int y)
-{
- QAI child = QAI(iface->childAt(x, y));
- if (!child)
- return QAI();
-
- QAI childOfChild;
- while (childOfChild = QAI(child->childAt(x, y))) {
- child = childOfChild;
- }
- return child;
-}
-
-void tst_QQuickAccessible::hitTest()
-{
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("hittest.qml"));
- canvas->show();
-
- QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas));
- QVERIFY(iface.data());
- QAI rootItem = QAI(iface->child(0));
- QRect rootRect = rootItem->rect();
-
- // hit the root item
- QAI itemHit(iface->childAt(rootRect.x() + 200, rootRect.y() + 50));
- QVERIFY(itemHit);
- QCOMPARE(rootRect, itemHit->rect());
-
- // hit rect1
- QAI rect1(rootItem->child(1));
- QRect rect1Rect = rect1->rect();
- itemHit = QAI(rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10));
- QVERIFY(itemHit);
- QCOMPARE(rect1Rect, itemHit->rect());
- QCOMPARE(itemHit->text(QAccessible::Name), QLatin1String("rect1"));
-
- // should also work from top level (app)
- QAI app(QAccessible::queryAccessibleInterface(qApp));
- QAI itemHit2(topLevelChildAt(app.data(), rect1Rect.x() + 10, rect1Rect.y() + 10));
- QVERIFY(itemHit2);
- QCOMPARE(itemHit2->rect(), rect1Rect);
- QCOMPARE(itemHit2->text(QAccessible::Name), QLatin1String("rect1"));
-
- // hit rect201
- QAI rect2(rootItem->child(2));
- QAI rect20(rect2->child(1));
- QAI rect201(rect20->child(2));
- QVERIFY(rect201);
-
- QRect rect201Rect = rect201->rect();
- itemHit = QAI(iface->childAt(rect201Rect.x() + 20, rect201Rect.y() + 20));
- QVERIFY(itemHit);
- QCOMPARE(itemHit->rect(), rect201Rect);
- QCOMPARE(itemHit->text(QAccessible::Name), QLatin1String("rect201"));
-
- delete canvas;
-}
-
-void tst_QQuickAccessible::checkableTest()
-{
- QQuickView *canvas = new QQuickView();
- canvas->setSource(testFileUrl("checkbuttons.qml"));
- canvas->show();
-
- QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas));
- QVERIFY(iface.data());
- QAI root = QAI(iface->child(0));
-
- QAI button1 = QAI(root->child(0));
- QCOMPARE(button1->role(), QAccessible::Button);
- QVERIFY(!(button1->state().checked));
- QAI button2 = QAI(root->child(1));
- QVERIFY(!(button2->state().checked));
- QAI button3 = QAI(root->child(2));
- QVERIFY(button3->state().checked);
-
- QAI checkBox1 = QAI(root->child(3));
- QCOMPARE(checkBox1->role(), QAccessible::CheckBox);
- QVERIFY((checkBox1->state().checked));
- QAI checkBox2 = QAI(root->child(4));
- QVERIFY(!(checkBox2->state().checked));
-}
-
-QTEST_MAIN(tst_QQuickAccessible)
-
-#include "tst_qquickaccessible.moc"
diff --git a/tests/auto/qtquick2/qquickanchors/qquickanchors.pro b/tests/auto/qtquick2/qquickanchors/qquickanchors.pro
deleted file mode 100644
index bd94f9cceb..0000000000
--- a/tests/auto/qtquick2/qquickanchors/qquickanchors.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = tst_qquickanchors
-CONFIG += testcase
-SOURCES += tst_qquickanchors.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private v8-private testlib
diff --git a/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp b/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp
deleted file mode 100644
index 8d82abc53b..0000000000
--- a/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp
+++ /dev/null
@@ -1,669 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <private/qquickitem_p.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qquickanchors_p_p.h>
-#include <QtQuick/private/qquickitem_p.h>
-#include "../../shared/util.h"
-#include "../shared/visualtestutil.h"
-
-Q_DECLARE_METATYPE(QQuickAnchors::Anchor)
-Q_DECLARE_METATYPE(QQuickAnchorLine::AnchorLine)
-
-using namespace QQuickVisualTestUtil;
-
-class tst_qquickanchors : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquickanchors() {}
-
-private slots:
- void basicAnchors();
- void basicAnchorsRTL();
- void loops();
- void illegalSets();
- void illegalSets_data();
- void reset();
- void reset_data();
- void resetConvenience();
- void nullItem();
- void nullItem_data();
- void crash1();
- void centerIn();
- void centerInRTL();
- void centerInRotation();
- void hvCenter();
- void hvCenterRTL();
- void fill();
- void fillRTL();
- void margins();
- void marginsRTL();
-};
-
-void tst_qquickanchors::basicAnchors()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("anchors.qml"));
-
- qApp->processEvents();
-
- //sibling horizontal
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect1"))->x(), 26.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect2"))->x(), 122.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect3"))->x(), 74.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect4"))->x(), 16.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect5"))->x(), 112.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect6"))->x(), 64.0);
-
- //parent horizontal
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect7"))->x(), 0.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect8"))->x(), 240.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect9"))->x(), 120.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect10"))->x(), -10.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect11"))->x(), 230.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect12"))->x(), 110.0);
-
- //vertical
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect13"))->y(), 20.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect14"))->y(), 155.0);
-
- //stretch
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect15"))->x(), 26.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect15"))->width(), 96.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect16"))->x(), 26.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect16"))->width(), 192.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect17"))->x(), -70.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect17"))->width(), 192.0);
-
- //vertical stretch
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect18"))->y(), 20.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect18"))->height(), 40.0);
-
- //more parent horizontal
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect19"))->x(), 115.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect20"))->x(), 235.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect21"))->x(), -5.0);
-
- //centerIn
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect22"))->x(), 69.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect22"))->y(), 5.0);
-
- //margins
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect23"))->x(), 31.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect23"))->y(), 5.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect23"))->width(), 86.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect23"))->height(), 10.0);
-
- // offsets
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect24"))->x(), 26.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect25"))->y(), 60.0);
- QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect26"))->y(), 5.0);
-
- //baseline
- QQuickText *text1 = findItem<QQuickText>(view->rootObject(), QLatin1String("text1"));
- QQuickText *text2 = findItem<QQuickText>(view->rootObject(), QLatin1String("text2"));
- QCOMPARE(text1->y(), text2->y());
-
- delete view;
-}
-
-QQuickItem* childItem(QQuickItem *parentItem, const char * itemString) {
- return findItem<QQuickItem>(parentItem, QLatin1String(itemString));
-}
-
-qreal offsetMasterRTL(QQuickItem *rootItem, const char * itemString) {
- QQuickItem* masterItem = findItem<QQuickItem>(rootItem, QLatin1String("masterRect"));
- return masterItem->width()+2*masterItem->x()-findItem<QQuickItem>(rootItem, QLatin1String(itemString))->width();
-}
-
-qreal offsetParentRTL(QQuickItem *rootItem, const char * itemString) {
- return rootItem->width()+2*rootItem->x()-findItem<QQuickItem>(rootItem, QLatin1String(itemString))->width();
-}
-
-void mirrorAnchors(QQuickItem *item) {
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- itemPrivate->setLayoutMirror(true);
-}
-
-void tst_qquickanchors::basicAnchorsRTL()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("anchors.qml"));
-
- qApp->processEvents();
-
- QQuickItem* rootItem = qobject_cast<QQuickItem*>(view->rootObject());
- foreach (QObject *child, rootItem->children()) {
- bool mirrored = QQuickItemPrivate::get(qobject_cast<QQuickItem*>(child))->anchors()->property("mirrored").toBool();
- QCOMPARE(mirrored, false);
- }
-
- foreach (QObject *child, rootItem->children())
- mirrorAnchors(qobject_cast<QQuickItem*>(child));
-
- foreach (QObject *child, rootItem->children()) {
- bool mirrored = QQuickItemPrivate::get(qobject_cast<QQuickItem*>(child))->anchors()->property("mirrored").toBool();
- QCOMPARE(mirrored, true);
- }
-
- //sibling horizontal
- QCOMPARE(childItem(rootItem, "rect1")->x(), offsetMasterRTL(rootItem, "rect1")-26.0);
- QCOMPARE(childItem(rootItem, "rect2")->x(), offsetMasterRTL(rootItem, "rect2")-122.0);
- QCOMPARE(childItem(rootItem, "rect3")->x(), offsetMasterRTL(rootItem, "rect3")-74.0);
- QCOMPARE(childItem(rootItem, "rect4")->x(), offsetMasterRTL(rootItem, "rect4")-16.0);
- QCOMPARE(childItem(rootItem, "rect5")->x(), offsetMasterRTL(rootItem, "rect5")-112.0);
- QCOMPARE(childItem(rootItem, "rect6")->x(), offsetMasterRTL(rootItem, "rect6")-64.0);
-
- //parent horizontal
- QCOMPARE(childItem(rootItem, "rect7")->x(), offsetParentRTL(rootItem, "rect7")-0.0);
- QCOMPARE(childItem(rootItem, "rect8")->x(), offsetParentRTL(rootItem, "rect8")-240.0);
- QCOMPARE(childItem(rootItem, "rect9")->x(), offsetParentRTL(rootItem, "rect9")-120.0);
- QCOMPARE(childItem(rootItem, "rect10")->x(), offsetParentRTL(rootItem, "rect10")+10.0);
- QCOMPARE(childItem(rootItem, "rect11")->x(), offsetParentRTL(rootItem, "rect11")-230.0);
- QCOMPARE(childItem(rootItem, "rect12")->x(), offsetParentRTL(rootItem, "rect12")-110.0);
-
- //vertical
- QCOMPARE(childItem(rootItem, "rect13")->y(), 20.0);
- QCOMPARE(childItem(rootItem, "rect14")->y(), 155.0);
-
- //stretch
- QCOMPARE(childItem(rootItem, "rect15")->x(), offsetMasterRTL(rootItem, "rect15")-26.0);
- QCOMPARE(childItem(rootItem, "rect15")->width(), 96.0);
- QCOMPARE(childItem(rootItem, "rect16")->x(), offsetMasterRTL(rootItem, "rect16")-26.0);
- QCOMPARE(childItem(rootItem, "rect16")->width(), 192.0);
- QCOMPARE(childItem(rootItem, "rect17")->x(), offsetMasterRTL(rootItem, "rect17")+70.0);
- QCOMPARE(childItem(rootItem, "rect17")->width(), 192.0);
-
- //vertical stretch
- QCOMPARE(childItem(rootItem, "rect18")->y(), 20.0);
- QCOMPARE(childItem(rootItem, "rect18")->height(), 40.0);
-
- //more parent horizontal
- QCOMPARE(childItem(rootItem, "rect19")->x(), offsetParentRTL(rootItem, "rect19")-115.0);
- QCOMPARE(childItem(rootItem, "rect20")->x(), offsetParentRTL(rootItem, "rect20")-235.0);
- QCOMPARE(childItem(rootItem, "rect21")->x(), offsetParentRTL(rootItem, "rect21")+5.0);
-
- //centerIn
- QCOMPARE(childItem(rootItem, "rect22")->x(), offsetMasterRTL(rootItem, "rect22")-69.0);
- QCOMPARE(childItem(rootItem, "rect22")->y(), 5.0);
-
- //margins
- QCOMPARE(childItem(rootItem, "rect23")->x(), offsetMasterRTL(rootItem, "rect23")-31.0);
- QCOMPARE(childItem(rootItem, "rect23")->y(), 5.0);
- QCOMPARE(childItem(rootItem, "rect23")->width(), 86.0);
- QCOMPARE(childItem(rootItem, "rect23")->height(), 10.0);
-
- // offsets
- QCOMPARE(childItem(rootItem, "rect24")->x(), offsetMasterRTL(rootItem, "rect24")-26.0);
- QCOMPARE(childItem(rootItem, "rect25")->y(), 60.0);
- QCOMPARE(childItem(rootItem, "rect26")->y(), 5.0);
-
- //baseline
- QQuickText *text1 = findItem<QQuickText>(rootItem, QLatin1String("text1"));
- QQuickText *text2 = findItem<QQuickText>(rootItem, QLatin1String("text2"));
- QCOMPARE(text1->y(), text2->y());
-
- delete view;
-}
-
-// mostly testing that we don't crash
-void tst_qquickanchors::loops()
-{
- {
- QUrl source(testFileUrl("loop1.qml"));
-
- QString expect = source.toString() + ":6:5: QML Text: Possible anchor loop detected on horizontal anchor.";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
-
- QQuickView *view = new QQuickView;
- view->setSource(source);
- qApp->processEvents();
-
- delete view;
- }
-
- {
- QUrl source(testFileUrl("loop2.qml"));
-
- QString expect = source.toString() + ":8:3: QML Image: Possible anchor loop detected on horizontal anchor.";
- QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
-
- QQuickView *view = new QQuickView;
- view->setSource(source);
- qApp->processEvents();
-
- delete view;
- }
-}
-
-void tst_qquickanchors::illegalSets()
-{
- QFETCH(QString, qml);
- QFETCH(QString, warning);
-
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\n" + qml.toUtf8()), QUrl::fromLocalFile(""));
- if (!component.isReady())
- qWarning() << "Test errors:" << component.errors();
- QVERIFY(component.isReady());
- QObject *o = component.create();
- delete o;
-}
-
-void tst_qquickanchors::illegalSets_data()
-{
- QTest::addColumn<QString>("qml");
- QTest::addColumn<QString>("warning");
-
- QTest::newRow("H - too many anchors")
- << "Rectangle { id: rect; Rectangle { anchors.left: rect.left; anchors.right: rect.right; anchors.horizontalCenter: rect.horizontalCenter } }"
- << "file::2:23: QML Rectangle: Cannot specify left, right, and hcenter anchors.";
-
- foreach (const QString &side, QStringList() << "left" << "right") {
- QTest::newRow("H - anchor to V")
- << QString("Rectangle { Rectangle { anchors.%1: parent.top } }").arg(side)
- << "file::2:13: QML Rectangle: Cannot anchor a horizontal edge to a vertical edge.";
-
- QTest::newRow("H - anchor to non parent/sibling")
- << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side)
- << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
-
- QTest::newRow("H - anchor to self")
- << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side)
- << "file::2:1: QML Rectangle: Cannot anchor item to self.";
- }
-
-
- QTest::newRow("V - too many anchors")
- << "Rectangle { id: rect; Rectangle { anchors.top: rect.top; anchors.bottom: rect.bottom; anchors.verticalCenter: rect.verticalCenter } }"
- << "file::2:23: QML Rectangle: Cannot specify top, bottom, and vcenter anchors.";
-
- QTest::newRow("V - too many anchors with baseline")
- << "Rectangle { Text { id: text1; text: \"Hello\" } Text { anchors.baseline: text1.baseline; anchors.top: text1.top; } }"
- << "file::2:47: QML Text: Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors.";
-
- foreach (const QString &side, QStringList() << "top" << "bottom" << "baseline") {
-
- QTest::newRow("V - anchor to H")
- << QString("Rectangle { Rectangle { anchors.%1: parent.left } }").arg(side)
- << "file::2:13: QML Rectangle: Cannot anchor a vertical edge to a horizontal edge.";
-
- QTest::newRow("V - anchor to non parent/sibling")
- << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side)
- << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
-
- QTest::newRow("V - anchor to self")
- << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side)
- << "file::2:1: QML Rectangle: Cannot anchor item to self.";
- }
-
-
- QTest::newRow("centerIn - anchor to non parent/sibling")
- << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }"
- << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
-
-
- QTest::newRow("fill - anchor to non parent/sibling")
- << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.fill: rect} }"
- << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
-}
-
-void tst_qquickanchors::reset()
-{
- QFETCH(QString, side);
- QFETCH(QQuickAnchorLine::AnchorLine, anchorLine);
- QFETCH(QQuickAnchors::Anchor, usedAnchor);
-
- QQuickItem *baseItem = new QQuickItem;
-
- QQuickAnchorLine anchor;
- anchor.item = baseItem;
- anchor.anchorLine = anchorLine;
-
- QQuickItem *item = new QQuickItem;
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
-
- const QMetaObject *meta = itemPrivate->anchors()->metaObject();
- QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
-
- QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor)));
- QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), true);
-
- QVERIFY(p.reset(itemPrivate->anchors()));
- QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), false);
-
- delete item;
- delete baseItem;
-}
-
-void tst_qquickanchors::reset_data()
-{
- QTest::addColumn<QString>("side");
- QTest::addColumn<QQuickAnchorLine::AnchorLine>("anchorLine");
- QTest::addColumn<QQuickAnchors::Anchor>("usedAnchor");
-
- QTest::newRow("left") << "left" << QQuickAnchorLine::Left << QQuickAnchors::LeftAnchor;
- QTest::newRow("top") << "top" << QQuickAnchorLine::Top << QQuickAnchors::TopAnchor;
- QTest::newRow("right") << "right" << QQuickAnchorLine::Right << QQuickAnchors::RightAnchor;
- QTest::newRow("bottom") << "bottom" << QQuickAnchorLine::Bottom << QQuickAnchors::BottomAnchor;
-
- QTest::newRow("hcenter") << "horizontalCenter" << QQuickAnchorLine::HCenter << QQuickAnchors::HCenterAnchor;
- QTest::newRow("vcenter") << "verticalCenter" << QQuickAnchorLine::VCenter << QQuickAnchors::VCenterAnchor;
- QTest::newRow("baseline") << "baseline" << QQuickAnchorLine::Baseline << QQuickAnchors::BaselineAnchor;
-}
-
-void tst_qquickanchors::resetConvenience()
-{
- QQuickItem *baseItem = new QQuickItem;
- QQuickItem *item = new QQuickItem;
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
-
- //fill
- itemPrivate->anchors()->setFill(baseItem);
- QVERIFY(itemPrivate->anchors()->fill() == baseItem);
- itemPrivate->anchors()->resetFill();
- QVERIFY(itemPrivate->anchors()->fill() == 0);
-
- //centerIn
- itemPrivate->anchors()->setCenterIn(baseItem);
- QVERIFY(itemPrivate->anchors()->centerIn() == baseItem);
- itemPrivate->anchors()->resetCenterIn();
- QVERIFY(itemPrivate->anchors()->centerIn() == 0);
-
- delete item;
- delete baseItem;
-}
-
-void tst_qquickanchors::nullItem()
-{
- QFETCH(QString, side);
-
- QQuickAnchorLine anchor;
- QQuickItem *item = new QQuickItem;
- QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
-
- const QMetaObject *meta = itemPrivate->anchors()->metaObject();
- QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML Item: Cannot anchor to a null item.");
- QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor)));
-
- delete item;
-}
-
-void tst_qquickanchors::nullItem_data()
-{
- QTest::addColumn<QString>("side");
-
- QTest::newRow("left") << "left";
- QTest::newRow("top") << "top";
- QTest::newRow("right") << "right";
- QTest::newRow("bottom") << "bottom";
-
- QTest::newRow("hcenter") << "horizontalCenter";
- QTest::newRow("vcenter") << "verticalCenter";
- QTest::newRow("baseline") << "baseline";
-}
-
-//QTBUG-5428
-void tst_qquickanchors::crash1()
-{
- QUrl source(testFileUrl("crash1.qml"));
-
- QQuickView *view = new QQuickView(source);
- qApp->processEvents();
-
- delete view;
-}
-
-void tst_qquickanchors::fill()
-{
- QQuickView *view = new QQuickView(testFileUrl("fill.qml"));
-
- qApp->processEvents();
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QCOMPARE(rect->x(), 0.0 + 10.0);
- QCOMPARE(rect->y(), 0.0 + 30.0);
- QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0);
- //Alter Offsets (tests QTBUG-6631)
- rectPrivate->anchors()->setLeftMargin(20.0);
- rectPrivate->anchors()->setRightMargin(0.0);
- rectPrivate->anchors()->setBottomMargin(0.0);
- rectPrivate->anchors()->setTopMargin(10.0);
- QCOMPARE(rect->x(), 0.0 + 20.0);
- QCOMPARE(rect->y(), 0.0 + 10.0);
- QCOMPARE(rect->width(), 200.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 10.0);
-
- delete view;
-}
-
-void tst_qquickanchors::fillRTL()
-{
- QQuickView *view = new QQuickView(testFileUrl("fill.qml"));
-
- qApp->processEvents();
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- mirrorAnchors(rect);
-
- QCOMPARE(rect->x(), 0.0 + 20.0);
- QCOMPARE(rect->y(), 0.0 + 30.0);
- QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0);
- //Alter Offsets (tests QTBUG-6631)
- rectPrivate->anchors()->setLeftMargin(20.0);
- rectPrivate->anchors()->setRightMargin(0.0);
- rectPrivate->anchors()->setBottomMargin(0.0);
- rectPrivate->anchors()->setTopMargin(10.0);
- QCOMPARE(rect->x(), 0.0 + 0.0);
- QCOMPARE(rect->y(), 0.0 + 10.0);
- QCOMPARE(rect->width(), 200.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 10.0);
-
- delete view;
-}
-
-void tst_qquickanchors::centerIn()
-{
- QQuickView *view = new QQuickView(testFileUrl("centerin.qml"));
-
- qApp->processEvents();
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- QCOMPARE(rect->x(), 75.0 + 10);
- QCOMPARE(rect->y(), 75.0 + 30);
- //Alter Offsets (tests QTBUG-6631)
- rectPrivate->anchors()->setHorizontalCenterOffset(-20.0);
- rectPrivate->anchors()->setVerticalCenterOffset(-10.0);
- QCOMPARE(rect->x(), 75.0 - 20.0);
- QCOMPARE(rect->y(), 75.0 - 10.0);
-
- //QTBUG-21730 (use actual center to prevent animation jitter)
- QQuickRectangle* rect2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered2"));
- QCOMPARE(rect2->x(), 94.5);
- QCOMPARE(rect2->y(), 94.5);
-
- delete view;
-}
-
-void tst_qquickanchors::centerInRTL()
-{
- QQuickView *view = new QQuickView(testFileUrl("centerin.qml"));
-
- qApp->processEvents();
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- mirrorAnchors(rect);
-
- QCOMPARE(rect->x(), 75.0 - 10);
- QCOMPARE(rect->y(), 75.0 + 30);
- //Alter Offsets (tests QTBUG-6631)
- rectPrivate->anchors()->setHorizontalCenterOffset(-20.0);
- rectPrivate->anchors()->setVerticalCenterOffset(-10.0);
- QCOMPARE(rect->x(), 75.0 + 20.0);
- QCOMPARE(rect->y(), 75.0 - 10.0);
-
- delete view;
-}
-
-//QTBUG-12441
-void tst_qquickanchors::centerInRotation()
-{
- QQuickView *view = new QQuickView(testFileUrl("centerinRotation.qml"));
-
- qApp->processEvents();
- QQuickRectangle* outer = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("outer"));
- QQuickRectangle* inner = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("inner"));
-
- QCOMPARE(outer->x(), qreal(49.5));
- QCOMPARE(outer->y(), qreal(49.5));
- QCOMPARE(inner->x(), qreal(25.5));
- QCOMPARE(inner->y(), qreal(25.5));
-
- delete view;
-}
-
-void tst_qquickanchors::hvCenter()
-{
- QQuickView *view = new QQuickView(testFileUrl("hvCenter.qml"));
-
- qApp->processEvents();
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
-
- // test QTBUG-10999
- QCOMPARE(rect->x(), 10.0);
- QCOMPARE(rect->y(), 19.0);
-
- rectPrivate->anchors()->setHorizontalCenterOffset(-5.0);
- rectPrivate->anchors()->setVerticalCenterOffset(5.0);
- QCOMPARE(rect->x(), 10.0 - 5.0);
- QCOMPARE(rect->y(), 19.0 + 5.0);
-
- delete view;
-}
-
-void tst_qquickanchors::hvCenterRTL()
-{
- QQuickView *view = new QQuickView(testFileUrl("hvCenter.qml"));
-
- qApp->processEvents();
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- mirrorAnchors(rect);
-
- // test QTBUG-10999
- QCOMPARE(rect->x(), 10.0);
- QCOMPARE(rect->y(), 19.0);
-
- rectPrivate->anchors()->setHorizontalCenterOffset(-5.0);
- rectPrivate->anchors()->setVerticalCenterOffset(5.0);
- QCOMPARE(rect->x(), 10.0 + 5.0);
- QCOMPARE(rect->y(), 19.0 + 5.0);
-
- delete view;
-}
-void tst_qquickanchors::margins()
-{
- QQuickView *view = new QQuickView(testFileUrl("margins.qml"));
-
- qApp->processEvents();
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- QCOMPARE(rect->x(), 5.0);
- QCOMPARE(rect->y(), 6.0);
- QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0);
- QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0);
-
- rectPrivate->anchors()->setTopMargin(0.0);
- rectPrivate->anchors()->setMargins(20.0);
-
- QCOMPARE(rect->x(), 5.0);
- QCOMPARE(rect->y(), 20.0);
- QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0);
-
- delete view;
-}
-
-void tst_qquickanchors::marginsRTL()
-{
- QQuickView *view = new QQuickView(testFileUrl("margins.qml"));
-
- QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- mirrorAnchors(rect);
-
- QCOMPARE(rect->x(), 10.0);
- QCOMPARE(rect->y(), 6.0);
- QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0);
- QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0);
-
- rectPrivate->anchors()->setTopMargin(0.0);
- rectPrivate->anchors()->setMargins(20.0);
-
- QCOMPARE(rect->x(), 20.0);
- QCOMPARE(rect->y(), 20.0);
- QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0);
- QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0);
-
- delete view;
-}
-
-
-QTEST_MAIN(tst_qquickanchors)
-
-#include "tst_qquickanchors.moc"
diff --git a/tests/auto/qtquick2/qquickanimatedimage/qquickanimatedimage.pro b/tests/auto/qtquick2/qquickanimatedimage/qquickanimatedimage.pro
deleted file mode 100644
index d776a73b21..0000000000
--- a/tests/auto/qtquick2/qquickanimatedimage/qquickanimatedimage.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickanimatedimage
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qquickanimatedimage.cpp \
- ../../shared/testhttpserver.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/qtquick2/qquickanimatedimage/tst_qquickanimatedimage.cpp
deleted file mode 100644
index c124e4f62b..0000000000
--- a/tests/auto/qtquick2/qquickanimatedimage/tst_qquickanimatedimage.cpp
+++ /dev/null
@@ -1,374 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <private/qquickimage_p.h>
-#include <private/qquickanimatedimage_p.h>
-#include <QSignalSpy>
-#include <QtDeclarative/qdeclarativecontext.h>
-
-#include "../../shared/testhttpserver.h"
-#include "../../shared/util.h"
-
-Q_DECLARE_METATYPE(QQuickImageBase::Status)
-
-class tst_qquickanimatedimage : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquickanimatedimage() {}
-
-private slots:
- void play();
- void pause();
- void stopped();
- void setFrame();
- void frameCount();
- void mirror_running();
- void mirror_notRunning();
- void mirror_notRunning_data();
- void remote();
- void remote_data();
- void sourceSize();
- void sourceSizeReadOnly();
- void invalidSource();
- void qtbug_16520();
- void progressAndStatusChanges();
-
-};
-
-void tst_qquickanimatedimage::play()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("stickman.qml"));
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
-
- delete anim;
-}
-
-void tst_qquickanimatedimage::pause()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("stickmanpause.qml"));
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
- QVERIFY(anim->isPaused());
-
- delete anim;
-}
-
-void tst_qquickanimatedimage::stopped()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("stickmanstopped.qml"));
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(!anim->isPlaying());
- QCOMPARE(anim->currentFrame(), 0);
-
- delete anim;
-}
-
-void tst_qquickanimatedimage::setFrame()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("stickmanpause.qml"));
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
- QCOMPARE(anim->currentFrame(), 2);
-
- delete anim;
-}
-
-void tst_qquickanimatedimage::frameCount()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("colors.qml"));
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
- QVERIFY(anim);
- QVERIFY(anim->isPlaying());
- QCOMPARE(anim->frameCount(), 3);
-
- delete anim;
-}
-
-void tst_qquickanimatedimage::mirror_running()
-{
- // test where mirror is set to true after animation has started
-
- QQuickView canvas;
- canvas.show();
-
- canvas.setSource(testFileUrl("hearts.qml"));
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(canvas.rootObject());
- QVERIFY(anim);
-
- int width = anim->property("width").toInt();
-
- QCOMPARE(anim->currentFrame(), 0);
- QPixmap frame0 = QPixmap::fromImage(canvas.grabFrameBuffer());
-
- anim->setCurrentFrame(1);
- QPixmap frame1 = QPixmap::fromImage(canvas.grabFrameBuffer());
-
- anim->setCurrentFrame(0);
-
- QSignalSpy spy(anim, SIGNAL(frameChanged()));
- anim->setPlaying(true);
-
- QTRY_VERIFY(spy.count() == 1); spy.clear();
- anim->setProperty("mirror", true);
-
- QCOMPARE(anim->currentFrame(), 1);
- QPixmap frame1_flipped = QPixmap::fromImage(canvas.grabFrameBuffer());
-
- QTRY_VERIFY(spy.count() == 1); spy.clear();
- QCOMPARE(anim->currentFrame(), 0); // animation only has 2 frames, should cycle back to first
- QPixmap frame0_flipped = QPixmap::fromImage(canvas.grabFrameBuffer());
-
- QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved");
-
- QTransform transform;
- transform.translate(width, 0).scale(-1, 1.0);
- QPixmap frame0_expected = frame0.transformed(transform);
- QPixmap frame1_expected = frame1.transformed(transform);
-
- QCOMPARE(frame0_flipped, frame0_expected);
- QCOMPARE(frame1_flipped, frame1_expected);
-}
-
-void tst_qquickanimatedimage::mirror_notRunning()
-{
- QFETCH(QUrl, fileUrl);
-
- QQuickView canvas;
- canvas.show();
-
- canvas.setSource(fileUrl);
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(canvas.rootObject());
- QVERIFY(anim);
-
- int width = anim->property("width").toInt();
- QPixmap screenshot = QPixmap::fromImage(canvas.grabFrameBuffer());
-
- QTransform transform;
- transform.translate(width, 0).scale(-1, 1.0);
- QPixmap expected = screenshot.transformed(transform);
-
- int frame = anim->currentFrame();
- bool playing = anim->isPlaying();
- bool paused = anim->isPlaying();
-
- anim->setProperty("mirror", true);
- screenshot = QPixmap::fromImage(canvas.grabFrameBuffer());
-
- QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved");
- QCOMPARE(screenshot, expected);
-
- // mirroring should not change the current frame or playing status
- QCOMPARE(anim->currentFrame(), frame);
- QCOMPARE(anim->isPlaying(), playing);
- QCOMPARE(anim->isPaused(), paused);
-}
-
-void tst_qquickanimatedimage::mirror_notRunning_data()
-{
- QTest::addColumn<QUrl>("fileUrl");
-
- QTest::newRow("paused") << testFileUrl("stickmanpause.qml");
- QTest::newRow("stopped") << testFileUrl("stickmanstopped.qml");
-}
-
-void tst_qquickanimatedimage::remote()
-{
- QFETCH(QString, fileName);
- QFETCH(bool, paused);
-
- TestHTTPServer server(14449);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName));
- QTRY_VERIFY(component.isReady());
-
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
- QVERIFY(anim);
-
- QTRY_VERIFY(anim->isPlaying());
- if (paused) {
- QTRY_VERIFY(anim->isPaused());
- QCOMPARE(anim->currentFrame(), 2);
- }
- QVERIFY(anim->status() != QQuickAnimatedImage::Error);
-
- delete anim;
-}
-
-void tst_qquickanimatedimage::sourceSize()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("stickmanscaled.qml"));
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
- QVERIFY(anim);
- QCOMPARE(anim->width(),240.0);
- QCOMPARE(anim->height(),180.0);
- QCOMPARE(anim->sourceSize(),QSize(160,120));
-
- delete anim;
-}
-
-void tst_qquickanimatedimage::sourceSizeReadOnly()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("stickmanerror1.qml"));
- QVERIFY(component.isError());
- QCOMPARE(component.errors().at(0).description(), QString("Invalid property assignment: \"sourceSize\" is a read-only property"));
-}
-
-void tst_qquickanimatedimage::remote_data()
-{
- QTest::addColumn<QString>("fileName");
- QTest::addColumn<bool>("paused");
-
- QTest::newRow("playing") << "stickman.qml" << false;
- QTest::newRow("paused") << "stickmanpause.qml" << true;
-}
-
-void tst_qquickanimatedimage::invalidSource()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl::fromLocalFile(""));
- QVERIFY(component.isReady());
-
- QTest::ignoreMessage(QtWarningMsg, "file::2:2: QML AnimatedImage: Error Reading Animated Image File file:no-such-file.gif");
-
- QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
- QVERIFY(anim);
-
- QVERIFY(!anim->isPlaying());
- QVERIFY(!anim->isPaused());
- QCOMPARE(anim->currentFrame(), 0);
- QCOMPARE(anim->frameCount(), 0);
- QTRY_VERIFY(anim->status() == 3);
-}
-
-void tst_qquickanimatedimage::qtbug_16520()
-{
- TestHTTPServer server(14449);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
-
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("qtbug-16520.qml"));
- QTRY_VERIFY(component.isReady());
-
- QQuickRectangle *root = qobject_cast<QQuickRectangle *>(component.create());
- QVERIFY(root);
- QQuickAnimatedImage *anim = root->findChild<QQuickAnimatedImage*>("anim");
-
- anim->setProperty("source", "http://127.0.0.1:14449/stickman.gif");
-
- QTRY_VERIFY(anim->opacity() == 0);
- QTRY_VERIFY(anim->opacity() == 1);
-
- delete anim;
-}
-
-void tst_qquickanimatedimage::progressAndStatusChanges()
-{
- TestHTTPServer server(14449);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
-
- QDeclarativeEngine engine;
- QString componentStr = "import QtQuick 2.0\nAnimatedImage { source: srcImage }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", testFileUrl("stickman.gif"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
-
- qRegisterMetaType<QQuickImageBase::Status>();
- QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &)));
- QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal)));
- QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status)));
-
- // Loading local file
- ctxt->setContextProperty("srcImage", testFileUrl("colors.gif"));
- QTRY_VERIFY(obj->status() == QQuickImage::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", "http://127.0.0.1:14449/stickman.gif");
- QTRY_VERIFY(obj->status() == QQuickImage::Loading);
- QTRY_VERIFY(obj->progress() == 0.0);
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
- QTRY_COMPARE(sourceSpy.count(), 2);
- QTRY_VERIFY(progressSpy.count() > 1);
- QTRY_COMPARE(statusSpy.count(), 2);
-
- ctxt->setContextProperty("srcImage", "");
- QTRY_VERIFY(obj->status() == QQuickImage::Null);
- QTRY_VERIFY(obj->progress() == 0.0);
- QTRY_COMPARE(sourceSpy.count(), 3);
- QTRY_VERIFY(progressSpy.count() > 2);
- QTRY_COMPARE(statusSpy.count(), 3);
-}
-
-QTEST_MAIN(tst_qquickanimatedimage)
-
-#include "tst_qquickanimatedimage.moc"
diff --git a/tests/auto/qtquick2/qquickborderimage/qquickborderimage.pro b/tests/auto/qtquick2/qquickborderimage/qquickborderimage.pro
deleted file mode 100644
index 2073b4492f..0000000000
--- a/tests/auto/qtquick2/qquickborderimage/qquickborderimage.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickborderimage
-macx:CONFIG -= app_bundle
-
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qquickborderimage.cpp \
- ../../shared/testhttpserver.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network widgets testlib
diff --git a/tests/auto/qtquick2/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/qtquick2/qquickborderimage/tst_qquickborderimage.cpp
deleted file mode 100644
index dad44d6ee7..0000000000
--- a/tests/auto/qtquick2/qquickborderimage/tst_qquickborderimage.cpp
+++ /dev/null
@@ -1,373 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QTextDocument>
-#include <QTcpServer>
-#include <QTcpSocket>
-#include <QDir>
-#include <QGraphicsScene>
-#include <QPainter>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qquickborderimage_p.h>
-#include <private/qquickimagebase_p.h>
-#include <private/qquickscalegrid_p_p.h>
-#include <private/qquickloader_p.h>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-
-#include "../../shared/testhttpserver.h"
-#include "../../shared/util.h"
-
-#define SERVER_PORT 14446
-#define SERVER_ADDR "http://127.0.0.1:14446"
-
-class tst_qquickborderimage : public QDeclarativeDataTest
-
-{
- Q_OBJECT
-public:
- tst_qquickborderimage();
-
-private slots:
- void noSource();
- void imageSource();
- void imageSource_data();
- void clearSource();
- void resized();
- void smooth();
- void mirror();
- void tileModes();
- void sciSource();
- void sciSource_data();
- void invalidSciFile();
- void pendingRemoteRequest();
- void pendingRemoteRequest_data();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qquickborderimage::tst_qquickborderimage()
-{
-}
-
-void tst_qquickborderimage::noSource()
-{
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->source(), QUrl());
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qquickborderimage::imageSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<bool>("remote");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("local") << testFileUrl("colors.png").toString() << false << "";
- QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << false
- << "file::2:1: QML BorderImage: Cannot open: " + testFileUrl("no-such-file.png").toString();
- QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << "";
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true
- << "file::2:1: QML BorderImage: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found";
-}
-
-void tst_qquickborderimage::imageSource()
-{
- QFETCH(QString, source);
- QFETCH(bool, remote);
- QFETCH(QString, error);
-
- TestHTTPServer *server = 0;
- if (remote) {
- server = new TestHTTPServer(SERVER_PORT);
- QVERIFY(server->isValid());
- server->serveDirectory(dataDirectory());
- }
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
-
- if (remote)
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading);
-
- QCOMPARE(obj->source(), remote ? source : QUrl(source));
-
- if (error.isEmpty()) {
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
- QCOMPARE(obj->sourceSize().width(), 120);
- QCOMPARE(obj->sourceSize().height(), 120);
- QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
- } else {
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Error);
- }
-
- delete obj;
- delete server;
-}
-
-void tst_qquickborderimage::clearSource()
-{
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: srcImage }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->status() == QQuickBorderImage::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
-
- ctxt->setContextProperty("srcImage", "");
- QVERIFY(obj->source().isEmpty());
- QVERIFY(obj->status() == QQuickBorderImage::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
-}
-
-void tst_qquickborderimage::resized()
-{
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFileUrl("colors.png").toString() + "\"; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->sourceSize().width(), 120);
- QCOMPARE(obj->sourceSize().height(), 120);
- QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qquickborderimage::smooth()
-{
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; smooth: true; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->smooth(), true);
- QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qquickborderimage::mirror()
-{
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("mirror.qml"));
- QQuickBorderImage *image = qobject_cast<QQuickBorderImage*>(canvas->rootObject());
- QVERIFY(image != 0);
-
- QImage screenshot = canvas->grabFrameBuffer();
-
- QImage srcPixmap(screenshot);
- QTransform transform;
- transform.translate(image->width(), 0).scale(-1, 1.0);
- srcPixmap = srcPixmap.transformed(transform);
-
- image->setProperty("mirror", true);
- screenshot = canvas->grabFrameBuffer();
- QCOMPARE(screenshot, srcPixmap);
-
- delete canvas;
-}
-
-void tst_qquickborderimage::tileModes()
-{
- {
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 100.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Repeat);
- QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Repeat);
-
- delete obj;
- }
- {
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 150.);
- QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Round);
- QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Round);
-
- delete obj;
- }
-}
-
-void tst_qquickborderimage::sciSource()
-{
- QFETCH(QString, source);
- QFETCH(bool, valid);
-
- bool remote = source.startsWith("http");
- TestHTTPServer *server = 0;
- if (remote) {
- server = new TestHTTPServer(SERVER_PORT);
- QVERIFY(server->isValid());
- server->serveDirectory(dataDirectory());
- }
-
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
-
- if (remote)
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading);
-
- QCOMPARE(obj->source(), remote ? source : QUrl(source));
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
-
- if (valid) {
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready);
- QCOMPARE(obj->border()->left(), 10);
- QCOMPARE(obj->border()->top(), 20);
- QCOMPARE(obj->border()->right(), 30);
- QCOMPARE(obj->border()->bottom(), 40);
- QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Round);
- QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Repeat);
- } else {
- QTRY_VERIFY(obj->status() == QQuickBorderImage::Error);
- }
-
- delete obj;
- delete server;
-}
-
-void tst_qquickborderimage::sciSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<bool>("valid");
-
- QTest::newRow("local") << testFileUrl("colors-round.sci").toString() << true;
- QTest::newRow("local quoted filename") << testFileUrl("colors-round-quotes.sci").toString() << true;
- QTest::newRow("local not found") << testFileUrl("no-such-file.sci").toString() << false;
- QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
- QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true;
- QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true;
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false;
-}
-
-void tst_qquickborderimage::invalidSciFile()
-{
- QTest::ignoreMessage(QtWarningMsg, "QQuickGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Roun"
- QTest::ignoreMessage(QtWarningMsg, "QQuickGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Repea"
-
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFileUrl("invalid.sci").toString() +"\"; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->status(), QQuickImageBase::Error);
- QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
-
- delete obj;
-}
-
-void tst_qquickborderimage::pendingRemoteRequest()
-{
- QFETCH(QString, source);
-
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->status(), QQuickBorderImage::Loading);
-
- // verify no crash
- // This will cause a delayed "QThread: Destroyed while thread is still running" warning
- delete obj;
- QTest::qWait(50);
-}
-
-void tst_qquickborderimage::pendingRemoteRequest_data()
-{
- QTest::addColumn<QString>("source");
-
- QTest::newRow("png file") << "http://localhost/none.png";
- QTest::newRow("sci file") << "http://localhost/none.sci";
-}
-
-QTEST_MAIN(tst_qquickborderimage)
-
-#include "tst_qquickborderimage.moc"
diff --git a/tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro b/tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro
deleted file mode 100644
index b21b492e0b..0000000000
--- a/tests/auto/qtquick2/qquickcanvas/qquickcanvas.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickcanvas
-SOURCES += tst_qquickcanvas.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private quick-private testlib
-
-testData.files = data
-testData.path = .
-DEPLOYMENT += testData
-
-OTHER_FILES += \
- data/AnimationsWhileHidden.qml \
- data/Headless.qml
-
-
diff --git a/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp b/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp
deleted file mode 100644
index 8f0c4e6fce..0000000000
--- a/tests/auto/qtquick2/qquickcanvas/tst_qquickcanvas.cpp
+++ /dev/null
@@ -1,775 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDebug>
-#include <QTouchEvent>
-#include <QtQuick/QQuickItem>
-#include <QtQuick/QQuickCanvas>
-#include <QtDeclarative/QDeclarativeEngine>
-#include <QtDeclarative/QDeclarativeComponent>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtGui/QWindowSystemInterface>
-#include "../../shared/util.h"
-#include <QSignalSpy>
-
-struct TouchEventData {
- QEvent::Type type;
- QWidget *widget;
- QWindow *window;
- Qt::TouchPointStates states;
- QList<QTouchEvent::TouchPoint> touchPoints;
-};
-
-static QTouchEvent::TouchPoint makeTouchPoint(QQuickItem *item, const QPointF &p, const QPointF &lastPoint = QPointF())
-{
- QPointF last = lastPoint.isNull() ? p : lastPoint;
-
- QTouchEvent::TouchPoint tp;
-
- tp.setPos(p);
- tp.setLastPos(last);
- tp.setScenePos(item->mapToScene(p));
- tp.setLastScenePos(item->mapToScene(last));
- tp.setScreenPos(item->canvas()->mapToGlobal(tp.scenePos().toPoint()));
- tp.setLastScreenPos(item->canvas()->mapToGlobal(tp.lastScenePos().toPoint()));
- return tp;
-}
-
-static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, Qt::TouchPointStates states = 0,
- const QList<QTouchEvent::TouchPoint>& touchPoints = QList<QTouchEvent::TouchPoint>())
-{
- TouchEventData d = { type, 0, w, states, touchPoints };
- return d;
-}
-static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, Qt::TouchPointStates states, const QTouchEvent::TouchPoint &touchPoint)
-{
- QList<QTouchEvent::TouchPoint> points;
- points << touchPoint;
- return makeTouchData(type, w, states, points);
-}
-
-#define COMPARE_TOUCH_POINTS(tp1, tp2) \
-{ \
- QCOMPARE(tp1.pos(), tp2.pos()); \
- QCOMPARE(tp1.lastPos(), tp2.lastPos()); \
- QCOMPARE(tp1.scenePos(), tp2.scenePos()); \
- QCOMPARE(tp1.lastScenePos(), tp2.lastScenePos()); \
- QCOMPARE(tp1.screenPos(), tp2.screenPos()); \
- QCOMPARE(tp1.lastScreenPos(), tp2.lastScreenPos()); \
-}
-
-#define COMPARE_TOUCH_DATA(d1, d2) \
-{ \
- QCOMPARE((int)d1.type, (int)d2.type); \
- QCOMPARE(d1.widget, d2.widget); \
- QCOMPARE((int)d1.states, (int)d2.states); \
- QCOMPARE(d1.touchPoints.count(), d2.touchPoints.count()); \
- for (int i=0; i<d1.touchPoints.count(); i++) { \
- COMPARE_TOUCH_POINTS(d1.touchPoints[i], d2.touchPoints[i]); \
- } \
-}
-
-class TestTouchItem : public QQuickRectangle
-{
- Q_OBJECT
-public:
- TestTouchItem(QQuickItem *parent = 0)
- : QQuickRectangle(parent), acceptEvents(true), mousePressId(0)
- {
- border()->setWidth(1);
- setAcceptedMouseButtons(Qt::LeftButton);
- setFiltersChildMouseEvents(true);
- }
-
- void reset() {
- acceptEvents = true;
- setEnabled(true);
- setOpacity(1.0);
-
- lastEvent = makeTouchData(QEvent::None, canvas(), 0, QList<QTouchEvent::TouchPoint>());//CHECK_VALID
- }
-
- static void clearMousePressCounter()
- {
- mousePressNum = 0;
- }
-
- bool acceptEvents;
- TouchEventData lastEvent;
- int mousePressId;
-protected:
- virtual void touchEvent(QTouchEvent *event) {
- if (!acceptEvents) {
- event->ignore();
- return;
- }
- lastEvent = makeTouchData(event->type(), event->window(), event->touchPointStates(), event->touchPoints());
- event->accept();
- }
-
- virtual void mousePressEvent(QMouseEvent *) {
- mousePressId = ++mousePressNum;
- }
-
- bool childMouseEventFilter(QQuickItem *, QEvent *event) {
- if (event->type() == QEvent::MouseButtonPress)
- mousePressId = ++mousePressNum;
- return false;
- }
-
- static int mousePressNum;
-};
-
-int TestTouchItem::mousePressNum = 0;
-
-class ConstantUpdateItem : public QQuickItem
-{
-Q_OBJECT
-public:
- ConstantUpdateItem(QQuickItem *parent = 0) : QQuickItem(parent), iterations(0) {setFlag(ItemHasContents);}
-
- int iterations;
-protected:
- QSGNode* updatePaintNode(QSGNode *, UpdatePaintNodeData *){
- iterations++;
- update();
- return 0;
- }
-};
-
-class tst_qquickcanvas : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
-
-private slots:
- void initTestCase()
- {
- QDeclarativeDataTest::initTestCase();
- touchDevice = new QTouchDevice();
- touchDevice->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(touchDevice);
- }
-
-
- void constantUpdates();
- void mouseFiltering();
- void headless();
-
- void touchEvent_basic();
- void touchEvent_propagation();
- void touchEvent_propagation_data();
- void touchEvent_cancel();
-
- void clearCanvas();
-
- void qmlCreation();
- void clearColor();
-
- void grab();
- void multipleWindows();
-
- void animationsWhileHidden();
-
- void focusObject();
-
- void ignoreUnhandledMouseEvents();
-
-private:
- QTouchDevice *touchDevice;
-};
-
-//If the item calls update inside updatePaintNode, it should schedule another update
-void tst_qquickcanvas::constantUpdates()
-{
- QQuickCanvas canvas;
- canvas.resize(250, 250);
- ConstantUpdateItem item(canvas.rootItem());
- canvas.show();
- QTRY_VERIFY(item.iterations > 60);
-}
-
-void tst_qquickcanvas::touchEvent_basic()
-{
- TestTouchItem::clearMousePressCounter();
-
- QQuickCanvas *canvas = new QQuickCanvas;
- canvas->resize(250, 250);
- canvas->move(100, 100);
- canvas->show();
-
- TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem());
- bottomItem->setObjectName("Bottom Item");
- bottomItem->setSize(QSizeF(150, 150));
-
- TestTouchItem *middleItem = new TestTouchItem(bottomItem);
- middleItem->setObjectName("Middle Item");
- middleItem->setPos(QPointF(50, 50));
- middleItem->setSize(QSizeF(150, 150));
-
- TestTouchItem *topItem = new TestTouchItem(middleItem);
- topItem->setObjectName("Top Item");
- topItem->setPos(QPointF(50, 50));
- topItem->setSize(QSizeF(150, 150));
-
- QPointF pos(10, 10);
-
- // press single point
- QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas);
- QTest::qWait(50);
-
- QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
-
- QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
- QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
- TouchEventData d = makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem,pos));
- COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos)));
- topItem->reset();
-
- // press multiple points
- QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas)
- .press(1, bottomItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
- QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
- QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
- COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos)));
- COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos)));
- topItem->reset();
- bottomItem->reset();
-
- // touch point on top item moves to bottom item, but top item should still receive the event
- QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QTest::touchEvent(canvas, touchDevice).move(0, bottomItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
- COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchUpdate, canvas, Qt::TouchPointMoved,
- makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos), pos)));
- topItem->reset();
-
- // touch point on bottom item moves to top item, but bottom item should still receive the event
- QTest::touchEvent(canvas, touchDevice).press(0, bottomItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QTest::touchEvent(canvas, touchDevice).move(0, topItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
- COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchUpdate, canvas, Qt::TouchPointMoved,
- makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos), pos)));
- bottomItem->reset();
-
- // a single stationary press on an item shouldn't cause an event
- QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QTest::touchEvent(canvas, touchDevice).stationary(0)
- .press(1, bottomItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); // received press only, not stationary
- QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
- QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
- COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos)));
- COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos)));
- topItem->reset();
- bottomItem->reset();
-
- // move touch point from top item to bottom, and release
- QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas);
- QTest::qWait(50);
- QTest::touchEvent(canvas, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(),canvas);
- QTest::qWait(50);
- QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
- COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, canvas, Qt::TouchPointReleased,
- makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos), pos)));
- topItem->reset();
-
- // release while another point is pressed
- QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas)
- .press(1, bottomItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QTest::touchEvent(canvas, touchDevice).move(0, bottomItem->mapToScene(pos).toPoint(), canvas);
- QTest::qWait(50);
- QTest::touchEvent(canvas, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(), canvas)
- .stationary(1);
- QTest::qWait(50);
- QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
- QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
- QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
- COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, canvas, Qt::TouchPointReleased,
- makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos))));
- COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos)));
- topItem->reset();
- bottomItem->reset();
-
- delete topItem;
- delete middleItem;
- delete bottomItem;
- delete canvas;
-}
-
-void tst_qquickcanvas::touchEvent_propagation()
-{
- TestTouchItem::clearMousePressCounter();
-
- QFETCH(bool, acceptEvents);
- QFETCH(bool, enableItem);
- QFETCH(qreal, itemOpacity);
-
- QQuickCanvas *canvas = new QQuickCanvas;
- canvas->resize(250, 250);
- canvas->move(100, 100);
- canvas->show();
-
- TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem());
- bottomItem->setObjectName("Bottom Item");
- bottomItem->setSize(QSizeF(150, 150));
-
- TestTouchItem *middleItem = new TestTouchItem(bottomItem);
- middleItem->setObjectName("Middle Item");
- middleItem->setPos(QPointF(50, 50));
- middleItem->setSize(QSizeF(150, 150));
-
- TestTouchItem *topItem = new TestTouchItem(middleItem);
- topItem->setObjectName("Top Item");
- topItem->setPos(QPointF(50, 50));
- topItem->setSize(QSizeF(150, 150));
-
- QPointF pos(10, 10);
- QPoint pointInBottomItem = bottomItem->mapToScene(pos).toPoint(); // (10, 10)
- QPoint pointInMiddleItem = middleItem->mapToScene(pos).toPoint(); // (60, 60) overlaps with bottomItem
- QPoint pointInTopItem = topItem->mapToScene(pos).toPoint(); // (110, 110) overlaps with bottom & top items
-
- // disable topItem
- topItem->acceptEvents = acceptEvents;
- topItem->setEnabled(enableItem);
- topItem->setOpacity(itemOpacity);
-
- // single touch to top item, should be received by middle item
- QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas);
- QTest::qWait(50);
- QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
- QCOMPARE(middleItem->lastEvent.touchPoints.count(), 1);
- QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
- COMPARE_TOUCH_DATA(middleItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
- makeTouchPoint(middleItem, middleItem->mapFromItem(topItem, pos))));
-
- // touch top and middle items, middle item should get both events
- QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas)
- .press(1, pointInMiddleItem, canvas);
- QTest::qWait(50);
- QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
- QCOMPARE(middleItem->lastEvent.touchPoints.count(), 2);
- QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
- COMPARE_TOUCH_DATA(middleItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
- (QList<QTouchEvent::TouchPoint>() << makeTouchPoint(middleItem, middleItem->mapFromItem(topItem, pos))
- << makeTouchPoint(middleItem, pos) )));
- middleItem->reset();
-
- // disable middleItem as well
- middleItem->acceptEvents = acceptEvents;
- middleItem->setEnabled(enableItem);
- middleItem->setOpacity(itemOpacity);
-
- // touch top and middle items, bottom item should get all events
- QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas)
- .press(1, pointInMiddleItem, canvas);
- QTest::qWait(50);
- QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
- QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
- QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 2);
- COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
- (QList<QTouchEvent::TouchPoint>() << makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos))
- << makeTouchPoint(bottomItem, bottomItem->mapFromItem(middleItem, pos)) )));
- bottomItem->reset();
-
- // disable bottom item as well
- bottomItem->acceptEvents = acceptEvents;
- bottomItem->setEnabled(enableItem);
- bottomItem->setOpacity(itemOpacity);
-
- // no events should be received
- QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas)
- .press(1, pointInMiddleItem, canvas)
- .press(2, pointInBottomItem, canvas);
- QTest::qWait(50);
- QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
- QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
- QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
-
- topItem->reset();
- middleItem->reset();
- bottomItem->reset();
-
- // disable middle item, touch on top item
- middleItem->acceptEvents = acceptEvents;
- middleItem->setEnabled(enableItem);
- middleItem->setOpacity(itemOpacity);
- QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas);
- QTest::qWait(50);
- if (!enableItem || itemOpacity == 0) {
- // middle item is disabled or has 0 opacity, bottom item receives the event
- QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
- QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
- QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
- COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
- makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos))));
- } else {
- // middle item ignores event, sends it to the top item (top-most child)
- QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
- QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
- QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
- COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
- makeTouchPoint(topItem, pos)));
- }
-
- delete topItem;
- delete middleItem;
- delete bottomItem;
- delete canvas;
-}
-
-void tst_qquickcanvas::touchEvent_propagation_data()
-{
- QTest::addColumn<bool>("acceptEvents");
- QTest::addColumn<bool>("enableItem");
- QTest::addColumn<qreal>("itemOpacity");
-
- QTest::newRow("disable events") << false << true << 1.0;
- QTest::newRow("disable item") << true << false << 1.0;
- QTest::newRow("opacity of 0") << true << true << 0.0;
-}
-
-void tst_qquickcanvas::touchEvent_cancel()
-{
- TestTouchItem::clearMousePressCounter();
-
- QQuickCanvas *canvas = new QQuickCanvas;
- canvas->resize(250, 250);
- canvas->move(100, 100);
- canvas->show();
-
- TestTouchItem *item = new TestTouchItem(canvas->rootItem());
- item->setPos(QPointF(50, 50));
- item->setSize(QSizeF(150, 150));
-
- QPointF pos(10, 10);
- QTest::touchEvent(canvas, touchDevice).press(0, item->mapToScene(pos).toPoint(),canvas);
- QCoreApplication::processEvents();
-
- QTRY_COMPARE(item->lastEvent.touchPoints.count(), 1);
- TouchEventData d = makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(item,pos));
- COMPARE_TOUCH_DATA(item->lastEvent, d);
- item->reset();
-
- QWindowSystemInterface::handleTouchCancelEvent(0, touchDevice);
- QCoreApplication::processEvents();
- d = makeTouchData(QEvent::TouchCancel, canvas);
- COMPARE_TOUCH_DATA(item->lastEvent, d);
-
- delete item;
- delete canvas;
-}
-
-void tst_qquickcanvas::clearCanvas()
-{
- QQuickCanvas *canvas = new QQuickCanvas;
- QQuickItem *item = new QQuickItem;
- item->setParentItem(canvas->rootItem());
-
- QVERIFY(item->canvas() == canvas);
-
- delete canvas;
-
- QVERIFY(item->canvas() == 0);
-
- delete item;
-}
-
-void tst_qquickcanvas::mouseFiltering()
-{
- TestTouchItem::clearMousePressCounter();
-
- QQuickCanvas *canvas = new QQuickCanvas;
- canvas->resize(250, 250);
- canvas->move(100, 100);
- canvas->show();
-
- TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem());
- bottomItem->setObjectName("Bottom Item");
- bottomItem->setSize(QSizeF(150, 150));
-
- TestTouchItem *middleItem = new TestTouchItem(bottomItem);
- middleItem->setObjectName("Middle Item");
- middleItem->setPos(QPointF(50, 50));
- middleItem->setSize(QSizeF(150, 150));
-
- TestTouchItem *topItem = new TestTouchItem(middleItem);
- topItem->setObjectName("Top Item");
- topItem->setPos(QPointF(50, 50));
- topItem->setSize(QSizeF(150, 150));
-
- QPoint pos(100, 100);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, pos);
-
- // Mouse filtering propagates down the stack, so the
- // correct order is
- // 1. middleItem filters event
- // 2. bottomItem filters event
- // 3. topItem receives event
- QTRY_COMPARE(middleItem->mousePressId, 1);
- QTRY_COMPARE(bottomItem->mousePressId, 2);
- QTRY_COMPARE(topItem->mousePressId, 3);
-
- delete canvas;
-}
-
-void tst_qquickcanvas::qmlCreation()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.loadUrl(testFileUrl("window.qml"));
- QObject* created = component.create();
- QVERIFY(created);
-
- QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created);
- QVERIFY(canvas);
- QCOMPARE(canvas->clearColor(), QColor(Qt::green));
-
- QQuickItem* item = canvas->findChild<QQuickItem*>("item");
- QVERIFY(item);
- QCOMPARE(item->canvas(), canvas);
-
- delete canvas;
-}
-
-void tst_qquickcanvas::clearColor()
-{
- //### Can we examine rendering to make sure it is really blue?
- QQuickCanvas *canvas = new QQuickCanvas;
- canvas->resize(250, 250);
- canvas->move(100, 100);
- canvas->setClearColor(Qt::blue);
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
- QCOMPARE(canvas->clearColor(), QColor(Qt::blue));
- delete canvas;
-}
-
-void tst_qquickcanvas::grab()
-{
- QQuickCanvas canvas;
- canvas.setClearColor(Qt::red);
-
- canvas.resize(250, 250);
- canvas.show();
-
- QTest::qWaitForWindowShown(&canvas);
-
- QImage content = canvas.grabFrameBuffer();
- QCOMPARE(content.width(), canvas.width());
- QCOMPARE(content.height(), canvas.height());
- QCOMPARE((uint) content.convertToFormat(QImage::Format_RGB32).pixel(0, 0), (uint) 0xffff0000);
-}
-
-void tst_qquickcanvas::multipleWindows()
-{
- QList<QQuickCanvas *> windows;
- for (int i=0; i<6; ++i) {
- QQuickCanvas *c = new QQuickCanvas();
- c->setClearColor(Qt::GlobalColor(Qt::red + i));
- c->resize(300, 200);
- c->setPos(100 + i * 30, 100 + i * 20);
- c->show();
- windows << c;
- QVERIFY(c->visible());
- }
-
- // move them
- for (int i=0; i<windows.size(); ++i) {
- QQuickCanvas *c = windows.at(i);
- c->setPos(c->x() - 10, c->y() - 10);
- }
-
- // resize them
- for (int i=0; i<windows.size(); ++i) {
- QQuickCanvas *c = windows.at(i);
- c->resize(200, 150);
- }
-
- qDeleteAll(windows);
-}
-
-void tst_qquickcanvas::animationsWhileHidden()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.loadUrl(testFileUrl("AnimationsWhileHidden.qml"));
- QObject* created = component.create();
-
- QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created);
- QVERIFY(canvas);
- QVERIFY(canvas->visible());
-
- // Now hide the window and verify that it went off screen
- canvas->hide();
- QTest::qWait(10);
- QVERIFY(!canvas->visible());
-
- // Running animaiton should cause it to become visible again shortly.
- QTRY_VERIFY(canvas->visible());
-
- delete canvas;
-}
-
-
-void tst_qquickcanvas::headless()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.loadUrl(testFileUrl("Headless.qml"));
- QObject* created = component.create();
-
- QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created);
- QVERIFY(canvas);
-
- QTest::qWaitForWindowShown(canvas);
- QVERIFY(canvas->visible());
-
- QSignalSpy initialized(canvas, SIGNAL(sceneGraphInitialized()));
- QSignalSpy invalidated(canvas, SIGNAL(sceneGraphInvalidated()));
-
- // Verify that the canvas is alive and kicking
- QVERIFY(canvas->openglContext() != 0);
-
- // Store the visual result
- QImage originalContent = canvas->grabFrameBuffer();
-
- // Hide the canvas and verify signal emittion and GL context deletion
- canvas->hide();
- canvas->releaseResources();
-
- QTRY_COMPARE(invalidated.size(), 1);
- QVERIFY(canvas->openglContext() == 0);
-
- // Destroy the native windowing system buffers
- canvas->destroy();
- QVERIFY(canvas->handle() == 0);
-
- // Show and verify that we are back and running
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
-
- QCOMPARE(initialized.size(), 1);
- QVERIFY(canvas->openglContext() != 0);
-
- // Verify that the visual output is the same
- QImage newContent = canvas->grabFrameBuffer();
-
- QCOMPARE(originalContent, newContent);
-
- delete canvas;
-}
-
-void tst_qquickcanvas::focusObject()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
- component.loadUrl(testFileUrl("focus.qml"));
- QObject *created = component.create();
- QVERIFY(created);
-
- QQuickCanvas *canvas = qobject_cast<QQuickCanvas*>(created);
- QVERIFY(canvas);
-
- QQuickItem *item1 = canvas->findChild<QQuickItem*>("item1");
- QVERIFY(item1);
- item1->setFocus(true);
- QCOMPARE(item1, canvas->focusObject());
-
- QQuickItem *item2 = canvas->findChild<QQuickItem*>("item2");
- QVERIFY(item2);
- item2->setFocus(true);
- QCOMPARE(item2, canvas->focusObject());
-
- delete canvas;
-}
-
-void tst_qquickcanvas::ignoreUnhandledMouseEvents()
-{
- QQuickCanvas* canvas = new QQuickCanvas;
- canvas->resize(100, 100);
- canvas->show();
-
- QQuickItem* item = new QQuickItem;
- item->setSize(QSizeF(100, 100));
- item->setParentItem(canvas->rootItem());
-
- {
- QMouseEvent me(QEvent::MouseButtonPress, QPointF(50, 50), Qt::LeftButton, Qt::LeftButton,
- Qt::NoModifier);
- me.setAccepted(true);
- QVERIFY(QCoreApplication::sendEvent(canvas, &me));
- QVERIFY(!me.isAccepted());
- }
-
- {
- QMouseEvent me(QEvent::MouseMove, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton,
- Qt::NoModifier);
- me.setAccepted(true);
- QVERIFY(QCoreApplication::sendEvent(canvas, &me));
- QVERIFY(!me.isAccepted());
- }
-
- {
- QMouseEvent me(QEvent::MouseButtonRelease, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton,
- Qt::NoModifier);
- me.setAccepted(true);
- QVERIFY(QCoreApplication::sendEvent(canvas, &me));
- QVERIFY(!me.isAccepted());
- }
-
- delete canvas;
-}
-
-QTEST_MAIN(tst_qquickcanvas)
-
-#include "tst_qquickcanvas.moc"
diff --git a/tests/auto/qtquick2/qquickcanvasitem/qquickcanvasitem.pro b/tests/auto/qtquick2/qquickcanvasitem/qquickcanvasitem.pro
deleted file mode 100644
index 93539dab15..0000000000
--- a/tests/auto/qtquick2/qquickcanvasitem/qquickcanvasitem.pro
+++ /dev/null
@@ -1,34 +0,0 @@
-QT += core-private gui-private declarative-private widgets
-TEMPLATE=app
-TARGET=tst_qquickcanvasitem
-
-CONFIG += warn_on qmltestcase
-SOURCES += tst_qquickcanvasitem.cpp
-
-importFiles.files = data
-importFiles.path = .
-DEPLOYMENT += importFiles
-
-OTHER_FILES += \
- data/testhelper.js \
- data/tst_transform.qml \
- data/tst_text.qml \
- data/tst_strokeStyle.qml \
- data/tst_state.qml \
- data/tst_shadow.qml \
- data/tst_pattern.qml \
- data/tst_path.qml \
- data/tst_line.qml \
- data/tst_fillStyle.qml \
- data/tst_fillrect.qml \
- data/tst_drawimage.qml \
- data/tst_composite.qml \
- data/tst_canvas.qml \
- data/tst_pixel.qml \
- data/tst_gradient.qml \
- data/tst_arcto.qml \
- data/tst_arc.qml \
- data/tst_context.qml
-
-
-
diff --git a/tests/auto/qtquick2/qquickdrag/qquickdrag.pro b/tests/auto/qtquick2/qquickdrag/qquickdrag.pro
deleted file mode 100644
index 4fdfa7b355..0000000000
--- a/tests/auto/qtquick2/qquickdrag/qquickdrag.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-TARGET = tst_qquickdrag
-CONFIG += testcase
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickdrag.cpp
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qquickdrag/tst_qquickdrag.cpp b/tests/auto/qtquick2/qquickdrag/tst_qquickdrag.cpp
deleted file mode 100644
index 91edf8c7b6..0000000000
--- a/tests/auto/qtquick2/qquickdrag/tst_qquickdrag.cpp
+++ /dev/null
@@ -1,1034 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-
-template <typename T> static T evaluate(QObject *scope, const QString &expression)
-{
- QDeclarativeExpression expr(qmlContext(scope), scope, expression);
- QVariant result = expr.evaluate();
- if (expr.hasError())
- qWarning() << expr.error().toString();
- return result.value<T>();
-}
-
-template <> void evaluate<void>(QObject *scope, const QString &expression)
-{
- QDeclarativeExpression expr(qmlContext(scope), scope, expression);
- expr.evaluate();
- if (expr.hasError())
- qWarning() << expr.error().toString();
-}
-
-Q_DECLARE_METATYPE(Qt::DropActions)
-
-class TestDropTarget : public QQuickItem
-{
- Q_OBJECT
-public:
- TestDropTarget(QQuickItem *parent = 0)
- : QQuickItem(parent)
- , enterEvents(0)
- , moveEvents(0)
- , leaveEvents(0)
- , dropEvents(0)
- , acceptAction(Qt::MoveAction)
- , defaultAction(Qt::IgnoreAction)
- , proposedAction(Qt::IgnoreAction)
- , accept(true)
- {
- setFlags(ItemAcceptsDrops);
- }
-
- void reset()
- {
- enterEvents = 0;
- moveEvents = 0;
- leaveEvents = 0;
- dropEvents = 0;
- defaultAction = Qt::IgnoreAction;
- proposedAction = Qt::IgnoreAction;
- supportedActions = Qt::IgnoreAction;
- }
-
- void dragEnterEvent(QDragEnterEvent *event)
- {
- ++enterEvents;
- position = event->pos();
- defaultAction = event->dropAction();
- proposedAction = event->proposedAction();
- supportedActions = event->possibleActions();
- event->setAccepted(accept);
- }
-
- void dragMoveEvent(QDragMoveEvent *event)
- {
- ++moveEvents;
- position = event->pos();
- defaultAction = event->dropAction();
- proposedAction = event->proposedAction();
- supportedActions = event->possibleActions();
- event->setAccepted(accept);
- }
-
- void dragLeaveEvent(QDragLeaveEvent *event)
- {
- ++leaveEvents;
- event->setAccepted(accept);
- }
-
- void dropEvent(QDropEvent *event)
- {
- ++dropEvents;
- position = event->pos();
- defaultAction = event->dropAction();
- proposedAction = event->proposedAction();
- supportedActions = event->possibleActions();
- event->setDropAction(acceptAction);
- event->setAccepted(accept);
- }
-
- int enterEvents;
- int moveEvents;
- int leaveEvents;
- int dropEvents;
- Qt::DropAction acceptAction;
- Qt::DropAction defaultAction;
- Qt::DropAction proposedAction;
- Qt::DropActions supportedActions;
- QPointF position;
- bool accept;
-};
-
-class tst_QQuickDrag: public QObject
-{
- Q_OBJECT
-private slots:
- void initTestCase();
- void cleanupTestCase();
-
- void active();
- void drop();
- void move();
- void hotSpot();
- void supportedActions();
- void proposedAction();
- void keys();
- void source();
- void recursion_data();
- void recursion();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_QQuickDrag::initTestCase()
-{
-
-}
-
-void tst_QQuickDrag::cleanupTestCase()
-{
-
-}
-
-void tst_QQuickDrag::active()
-{
- QQuickCanvas canvas;
- TestDropTarget dropTarget(canvas.rootItem());
- dropTarget.setSize(QSizeF(100, 100));
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "property bool dragActive: Drag.active\n"
- "property Item dragTarget: Drag.target\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
- item->setParentItem(&dropTarget);
-
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
-
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = false");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1);
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.cancel()");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.start()");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
-
- // Start while a drag is active, cancels the previous drag and starts a new one.
- dropTarget.reset();
- evaluate<void>(item, "Drag.start()");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 1);
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.cancel()");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1);
-
- // Enter events aren't sent to items without the QQuickItem::ItemAcceptsDrops flag.
- dropTarget.setFlags(QQuickItem::Flags());
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = false");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
-
- dropTarget.setFlags(QQuickItem::ItemAcceptsDrops);
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
-
- dropTarget.setFlags(QQuickItem::Flags());
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = false");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1);
-
- // Follow up events aren't sent to items if the enter event isn't accepted.
- dropTarget.setFlags(QQuickItem::ItemAcceptsDrops);
- dropTarget.accept = false;
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = false");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
-
- dropTarget.accept = true;
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
- QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
-
- dropTarget.accept = false;
-
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = false");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1);
-
- // Events are sent to hidden or disabled items.
- dropTarget.accept = true;
- dropTarget.setVisible(false);
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
-
- evaluate<void>(item, "Drag.active = false");
- dropTarget.setVisible(true);
-
- dropTarget.setOpacity(0.0);
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
-
- evaluate<void>(item, "Drag.active = false");
- dropTarget.setOpacity(1.0);
-
- dropTarget.setEnabled(false);
- dropTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
-}
-
-void tst_QQuickDrag::drop()
-{
- QQuickCanvas canvas;
- TestDropTarget outerTarget(canvas.rootItem());
- outerTarget.setSize(QSizeF(100, 100));
- outerTarget.acceptAction = Qt::CopyAction;
- TestDropTarget innerTarget(&outerTarget);
- innerTarget.setSize(QSizeF(100, 100));
- innerTarget.acceptAction = Qt::MoveAction;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "property bool dragActive: Drag.active\n"
- "property Item dragTarget: Drag.target\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
- item->setParentItem(&outerTarget);
-
- innerTarget.reset(); outerTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&innerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&innerTarget));
- QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
- QCOMPARE(innerTarget.enterEvents, 1); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
-
- innerTarget.reset(); outerTarget.reset();
- QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.MoveAction"), true);
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&innerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&innerTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 1); QCOMPARE(outerTarget.dropEvents, 0);
- QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 1);
-
- innerTarget.reset(); outerTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&innerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&innerTarget));
- QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
- QCOMPARE(innerTarget.enterEvents, 1); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
-
- // Inner target declines the drop so it is propagated to the outer target.
- innerTarget.accept = false;
-
- innerTarget.reset(); outerTarget.reset();
- QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.CopyAction"), true);
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1);
- QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 1);
-
-
- // Inner target doesn't accept enter so drop goes directly to outer.
- innerTarget.accept = true;
- innerTarget.setFlags(QQuickItem::Flags());
-
- innerTarget.reset(); outerTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
- QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
-
- innerTarget.reset(); outerTarget.reset();
- QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.CopyAction"), true);
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1);
- QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
-
- // Neither target accepts drop so Qt::IgnoreAction is returned.
- innerTarget.reset(); outerTarget.reset();
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
- QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
-
- outerTarget.accept = false;
-
- innerTarget.reset(); outerTarget.reset();
- QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.IgnoreAction"), true);
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1);
- QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
-
- // drop doesn't send an event and returns Qt.IgnoreAction if not active.
- innerTarget.accept = true;
- outerTarget.accept = true;
- innerTarget.reset(); outerTarget.reset();
- QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.IgnoreAction"), true);
- QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
- QCOMPARE(evaluate<bool>(item, "dragActive"), false);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
- QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
-}
-
-void tst_QQuickDrag::move()
-{
- QQuickCanvas canvas;
- TestDropTarget outerTarget(canvas.rootItem());
- outerTarget.setSize(QSizeF(100, 100));
- TestDropTarget leftTarget(&outerTarget);
- leftTarget.setPos(QPointF(0, 35));
- leftTarget.setSize(QSizeF(30, 30));
- TestDropTarget rightTarget(&outerTarget);
- rightTarget.setPos(QPointF(70, 35));
- rightTarget.setSize(QSizeF(30, 30));
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "property bool dragActive: Drag.active\n"
- "property Item dragTarget: Drag.target\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
- item->setParentItem(&outerTarget);
-
- evaluate<void>(item, "Drag.active = true");
- QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
- QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 0);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(50)); QCOMPARE(outerTarget.position.y(), qreal(50));
-
- // Move within the outer target.
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(60, 50));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(60)); QCOMPARE(outerTarget.position.y(), qreal(50));
-
- // Move into the right target.
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(75, 50));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&rightTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&rightTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 1); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(75)); QCOMPARE(outerTarget.position.y(), qreal(50));
- QCOMPARE(rightTarget.position.x(), qreal(5)); QCOMPARE(rightTarget.position.y(), qreal(15));
-
- // Move into the left target.
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(25, 50));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&leftTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&leftTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
- QCOMPARE(leftTarget .enterEvents, 1); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 1); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(50));
- QCOMPARE(leftTarget.position.x(), qreal(25)); QCOMPARE(leftTarget.position.y(), qreal(15));
-
- // Move within the left target.
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(25, 40));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&leftTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&leftTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 1);
- QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(40));
- QCOMPARE(leftTarget.position.x(), qreal(25)); QCOMPARE(leftTarget.position.y(), qreal(5));
-
- // Move out of all targets.
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(110, 50));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 1); QCOMPARE(outerTarget.moveEvents, 0);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 1); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
-
- // Stop the right target accepting drag events and move into it.
- rightTarget.accept = false;
-
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(80, 50));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 0);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 1); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(80)); QCOMPARE(outerTarget.position.y(), qreal(50));
-
- // Stop the outer target accepting drag events after it has accepted an enter event.
- outerTarget.accept = false;
-
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(60, 50));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(60)); QCOMPARE(outerTarget.position.y(), qreal(50));
-
- // Clear the QQuickItem::ItemAcceptsDrops flag from the outer target after it accepted an enter event.
- outerTarget.setFlags(QQuickItem::Flags());
-
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(40, 50));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(40)); QCOMPARE(outerTarget.position.y(), qreal(50));
-
- // Clear the QQuickItem::ItemAcceptsDrops flag from the left target before it accepts an enter event.
- leftTarget.setFlags(QQuickItem::Flags());
-
- outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
- item->setPos(QPointF(25, 50));
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
- QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
- QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
- QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
- QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(50));
-}
-
-
-void tst_QQuickDrag::hotSpot()
-{
- QQuickCanvas canvas;
- TestDropTarget dropTarget(canvas.rootItem());
- dropTarget.setSize(QSizeF(100, 100));
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "property real hotSpotX: Drag.hotSpot.x\n"
- "property real hotSpotY: Drag.hotSpot.y\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
- item->setParentItem(&dropTarget);
-
- QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.x"), qreal(0));
- QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.y"), qreal(0));
- QCOMPARE(evaluate<qreal>(item, "hotSpotX"), qreal(0));
- QCOMPARE(evaluate<qreal>(item, "hotSpotY"), qreal(0));
-
- evaluate<void>(item, "{ Drag.start(); Drag.cancel() }");
- QCOMPARE(dropTarget.position.x(), qreal(50));
- QCOMPARE(dropTarget.position.y(), qreal(50));
-
- evaluate<void>(item, "{ Drag.hotSpot.x = 5, Drag.hotSpot.y = 5 }");
- QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.x"), qreal(5));
- QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.y"), qreal(5));
- QCOMPARE(evaluate<qreal>(item, "hotSpotX"), qreal(5));
- QCOMPARE(evaluate<qreal>(item, "hotSpotY"), qreal(5));
-
- evaluate<void>(item, "Drag.start()");
- QCOMPARE(dropTarget.position.x(), qreal(55));
- QCOMPARE(dropTarget.position.y(), qreal(55));
-
- item->setPos(QPointF(30, 20));
- QCOMPARE(dropTarget.position.x(), qreal(35));
- QCOMPARE(dropTarget.position.y(), qreal(25));
-
- evaluate<void>(item, "{ Drag.hotSpot.x = 10; Drag.hotSpot.y = 10 }");
- QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.x"), qreal(10));
- QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.y"), qreal(10));
- QCOMPARE(evaluate<qreal>(item, "hotSpotX"), qreal(10));
- QCOMPARE(evaluate<qreal>(item, "hotSpotY"), qreal(10));
- // Changing the hotSpot won't generate a move event so the position is unchanged. Should it?
- QCOMPARE(dropTarget.position.x(), qreal(35));
- QCOMPARE(dropTarget.position.y(), qreal(25));
-
- item->setPos(QPointF(10, 20));
- QCOMPARE(dropTarget.position.x(), qreal(20));
- QCOMPARE(dropTarget.position.y(), qreal(30));
-}
-
-void tst_QQuickDrag::supportedActions()
-{
- QQuickCanvas canvas;
- TestDropTarget dropTarget(canvas.rootItem());
- dropTarget.setSize(QSizeF(100, 100));
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "property int supportedActions: Drag.supportedActions\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
- item->setParentItem(&dropTarget);
-
- QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.CopyAction | Qt.MoveAction | Qt.LinkAction"), true);
- QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.CopyAction | Qt.MoveAction | Qt.LinkAction"), true);
- evaluate<void>(item, "{ Drag.start(); Drag.cancel() }");
- QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction | Qt::LinkAction);
-
- evaluate<void>(item, "Drag.supportedActions = Qt.CopyAction | Qt.MoveAction");
- QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.CopyAction | Qt.MoveAction"), true);
- QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.CopyAction | Qt.MoveAction"), true);
- evaluate<void>(item, "Drag.start()");
- QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction);
-
- // Once a drag is started the proposed actions are locked in for future events.
- evaluate<void>(item, "Drag.supportedActions = Qt.MoveAction");
- QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.MoveAction"), true);
- QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.MoveAction"), true);
- item->setPos(QPointF(60, 60));
- QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction);
-
- // Calling start with proposed actions will override the current actions for the next sequence.
- evaluate<void>(item, "Drag.start(Qt.CopyAction)");
- QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.MoveAction"), true);
- QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.MoveAction"), true);
- QCOMPARE(dropTarget.supportedActions, Qt::CopyAction);
-
- evaluate<void>(item, "Drag.start()");
- QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.MoveAction"), true);
- QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.MoveAction"), true);
- QCOMPARE(dropTarget.supportedActions, Qt::MoveAction);
-}
-
-void tst_QQuickDrag::proposedAction()
-{
- QQuickCanvas canvas;
- TestDropTarget dropTarget(canvas.rootItem());
- dropTarget.setSize(QSizeF(100, 100));
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "property int proposedAction: Drag.proposedAction\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
- item->setParentItem(&dropTarget);
-
-
- QCOMPARE(evaluate<bool>(item, "Drag.proposedAction == Qt.MoveAction"), true);
- QCOMPARE(evaluate<bool>(item, "proposedAction == Qt.MoveAction"), true);
- evaluate<void>(item, "{ Drag.start(); Drag.cancel() }");
- QCOMPARE(dropTarget.defaultAction, Qt::MoveAction);
- QCOMPARE(dropTarget.proposedAction, Qt::MoveAction);
-
- evaluate<void>(item, "Drag.proposedAction = Qt.CopyAction");
- QCOMPARE(evaluate<bool>(item, "Drag.proposedAction == Qt.CopyAction"), true);
- QCOMPARE(evaluate<bool>(item, "proposedAction == Qt.CopyAction"), true);
- evaluate<void>(item, "Drag.start()");
- QCOMPARE(dropTarget.defaultAction, Qt::CopyAction);
- QCOMPARE(dropTarget.proposedAction, Qt::CopyAction);
-
- // The proposed action can change during a drag.
- evaluate<void>(item, "Drag.proposedAction = Qt.MoveAction");
- QCOMPARE(evaluate<bool>(item, "Drag.proposedAction == Qt.MoveAction"), true);
- QCOMPARE(evaluate<bool>(item, "proposedAction == Qt.MoveAction"), true);
- item->setPos(QPointF(60, 60));
- QCOMPARE(dropTarget.defaultAction, Qt::MoveAction);
- QCOMPARE(dropTarget.proposedAction, Qt::MoveAction);
-
- evaluate<void>(item, "Drag.proposedAction = Qt.LinkAction");
- QCOMPARE(evaluate<bool>(item, "Drag.proposedAction == Qt.LinkAction"), true);
- QCOMPARE(evaluate<bool>(item, "proposedAction == Qt.LinkAction"), true);
- evaluate<void>(item, "Drag.drop()");
- QCOMPARE(dropTarget.defaultAction, Qt::LinkAction);
- QCOMPARE(dropTarget.proposedAction, Qt::LinkAction);
-}
-
-void tst_QQuickDrag::keys()
-{
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "property variant keys: Drag.keys\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
-
-// QCOMPARE(evaluate<QStringList>(item, "Drag.keys"), QStringList());
-// QCOMPARE(evaluate<QStringList>(item, "keys"), QStringList());
- QCOMPARE(item->property("keys").toStringList(), QStringList());
-
- evaluate<void>(item, "Drag.keys = [\"red\", \"blue\"]");
-// QCOMPARE(evaluate<QStringList>(item, "Drag.keys"), QStringList() << "red" << "blue");
-// QCOMPARE(evaluate<QStringList>(item, "keys"), QStringList() << "red" << "blue");
- QCOMPARE(item->property("keys").toStringList(), QStringList() << "red" << "blue");
-}
-
-void tst_QQuickDrag::source()
-{
-
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "property Item source: Drag.source\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "Item { id: proxySource; objectName: \"proxySource\" }\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
-
- QCOMPARE(evaluate<QObject *>(item, "Drag.source"), static_cast<QObject *>(item));
- QCOMPARE(evaluate<QObject *>(item, "source"), static_cast<QObject *>(item));
-
- QQuickItem *proxySource = item->findChild<QQuickItem *>("proxySource");
- QVERIFY(proxySource);
-
- evaluate<void>(item, "Drag.source = proxySource");
- QCOMPARE(evaluate<QObject *>(item, "Drag.source"), static_cast<QObject *>(proxySource));
- QCOMPARE(evaluate<QObject *>(item, "source"), static_cast<QObject *>(proxySource));
-
- evaluate<void>(item, "Drag.source = undefined");
- QCOMPARE(evaluate<QObject *>(item, "Drag.source"), static_cast<QObject *>(item));
- QCOMPARE(evaluate<QObject *>(item, "source"), static_cast<QObject *>(item));
-}
-
-class RecursingDropTarget : public TestDropTarget
-{
-public:
- RecursingDropTarget(const QString &script, int type, QQuickItem *parent)
- : TestDropTarget(parent), script(script), type(type), item(0) {}
-
- void setItem(QQuickItem *i) { item = i; }
-
-protected:
- void dragEnterEvent(QDragEnterEvent *event)
- {
- TestDropTarget::dragEnterEvent(event);
- if (type == QEvent::DragEnter && enterEvents < 2)
- evaluate<void>(item, script);
- }
-
- void dragMoveEvent(QDragMoveEvent *event)
- {
- TestDropTarget::dragMoveEvent(event);
- if (type == QEvent::DragMove && moveEvents < 2)
- evaluate<void>(item, script);
- }
-
- void dragLeaveEvent(QDragLeaveEvent *event)
- {
- TestDropTarget::dragLeaveEvent(event);
- if (type == QEvent::DragLeave && leaveEvents < 2)
- evaluate<void>(item, script);
- }
-
- void dropEvent(QDropEvent *event)
- {
- TestDropTarget::dropEvent(event);
- if (type == QEvent::Drop && dropEvents < 2)
- evaluate<void>(item, script);
- }
-
-private:
- QString script;
- int type;
- QQuickItem *item;
-
-};
-
-void tst_QQuickDrag::recursion_data()
-{
- QTest::addColumn<QString>("script");
- QTest::addColumn<int>("type");
- QTest::addColumn<QByteArray>("warning");
-
- QTest::newRow("Drag.start() in Enter")
- << QString("Drag.start()")
- << int(QEvent::DragEnter)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
- QTest::newRow("Drag.cancel() in Enter")
- << QString("Drag.cancel()")
- << int(QEvent::DragEnter)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
- QTest::newRow("Drag.drop() in Enter")
- << QString("Drag.drop()")
- << int(QEvent::DragEnter)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
- QTest::newRow("Drag.active = true in Enter")
- << QString("Drag.active = true")
- << int(QEvent::DragEnter)
- << QByteArray();
- QTest::newRow("Drag.active = false in Enter")
- << QString("Drag.active = false")
- << int(QEvent::DragEnter)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
- QTest::newRow("move in Enter")
- << QString("x = 23")
- << int(QEvent::DragEnter)
- << QByteArray();
-
- QTest::newRow("Drag.start() in Move")
- << QString("Drag.start()")
- << int(QEvent::DragMove)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
- QTest::newRow("Drag.cancel() in Move")
- << QString("Drag.cancel()")
- << int(QEvent::DragMove)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
- QTest::newRow("Drag.drop() in Move")
- << QString("Drag.drop()")
- << int(QEvent::DragMove)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
- QTest::newRow("Drag.active = true in Move")
- << QString("Drag.active = true")
- << int(QEvent::DragMove)
- << QByteArray();
- QTest::newRow("Drag.active = false in Move")
- << QString("Drag.active = false")
- << int(QEvent::DragMove)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
- QTest::newRow("move in Move")
- << QString("x = 23")
- << int(QEvent::DragMove)
- << QByteArray();
-
- QTest::newRow("Drag.start() in Leave")
- << QString("Drag.start()")
- << int(QEvent::DragLeave)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
- QTest::newRow("Drag.cancel() in Leave")
- << QString("Drag.cancel()")
- << int(QEvent::DragLeave)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
- QTest::newRow("Drag.drop() in Leave")
- << QString("Drag.drop()")
- << int(QEvent::DragLeave)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
- QTest::newRow("Drag.active = true in Leave")
- << QString("Drag.active = true")
- << int(QEvent::DragLeave)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
- QTest::newRow("Drag.active = false in Leave")
- << QString("Drag.active = false")
- << int(QEvent::DragLeave)
- << QByteArray();
- QTest::newRow("move in Leave")
- << QString("x = 23")
- << int(QEvent::DragLeave)
- << QByteArray();
-
- QTest::newRow("Drag.start() in Drop")
- << QString("Drag.start()")
- << int(QEvent::Drop)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
- QTest::newRow("Drag.cancel() in Drop")
- << QString("Drag.cancel()")
- << int(QEvent::Drop)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
- QTest::newRow("Drag.drop() in Drop")
- << QString("Drag.drop()")
- << int(QEvent::Drop)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
- QTest::newRow("Drag.active = true in Drop")
- << QString("Drag.active = true")
- << int(QEvent::Drop)
- << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
- QTest::newRow("Drag.active = false in Drop")
- << QString("Drag.active = false")
- << int(QEvent::Drop)
- << QByteArray();
- QTest::newRow("move in Drop")
- << QString("x = 23")
- << int(QEvent::Drop)
- << QByteArray();
-}
-
-void tst_QQuickDrag::recursion()
-{
- QFETCH(QString, script);
- QFETCH(int, type);
- QFETCH(QByteArray, warning);
-
- if (!warning.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, warning.constData());
-
- QQuickCanvas canvas;
- RecursingDropTarget dropTarget(script, type, canvas.rootItem());
- dropTarget.setSize(QSizeF(100, 100));
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "Item {\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(item);
- item->setParentItem(canvas.rootItem());
-
- dropTarget.setItem(item);
-
- evaluate<void>(item, "Drag.start()");
- QCOMPARE(dropTarget.enterEvents, 1);
- QCOMPARE(dropTarget.moveEvents, 0);
- QCOMPARE(dropTarget.dropEvents, 0);
- QCOMPARE(dropTarget.leaveEvents, 0);
-
- evaluate<void>(item, "y = 15");
- QCOMPARE(dropTarget.enterEvents, 1);
- QCOMPARE(dropTarget.moveEvents, 1);
- QCOMPARE(dropTarget.dropEvents, 0);
- QCOMPARE(dropTarget.leaveEvents, 0);
-
- if (type == QEvent::Drop) {
- QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.MoveAction"), true);
- QCOMPARE(dropTarget.enterEvents, 1);
- QCOMPARE(dropTarget.moveEvents, 1);
- QCOMPARE(dropTarget.dropEvents, 1);
- QCOMPARE(dropTarget.leaveEvents, 0);
- } else {
- evaluate<void>(item, "Drag.cancel()");
- QCOMPARE(dropTarget.enterEvents, 1);
- QCOMPARE(dropTarget.moveEvents, 1);
- QCOMPARE(dropTarget.dropEvents, 0);
- QCOMPARE(dropTarget.leaveEvents, 1);
- }
-}
-
-
-QTEST_MAIN(tst_QQuickDrag)
-
-#include "tst_qquickdrag.moc"
diff --git a/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro b/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro
deleted file mode 100644
index 46fe08c145..0000000000
--- a/tests/auto/qtquick2/qquickdroparea/qquickdroparea.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-TARGET = tst_qquickdroparea
-CONFIG += testcase
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickdroparea.cpp
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp b/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp
deleted file mode 100644
index 0cd3fa9416..0000000000
--- a/tests/auto/qtquick2/qquickdroparea/tst_qquickdroparea.cpp
+++ /dev/null
@@ -1,1117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-
-#include <QtGui/qwindowsysteminterface_qpa.h>
-
-template <typename T> static T evaluate(QObject *scope, const QString &expression)
-{
- QDeclarativeExpression expr(qmlContext(scope), scope, expression);
- QVariant result = expr.evaluate();
- if (expr.hasError())
- qWarning() << expr.error().toString();
- return result.value<T>();
-}
-
-template <> void evaluate<void>(QObject *scope, const QString &expression)
-{
- QDeclarativeExpression expr(qmlContext(scope), scope, expression);
- expr.evaluate();
- if (expr.hasError())
- qWarning() << expr.error().toString();
-}
-
-class tst_QQuickDropArea: public QObject
-{
- Q_OBJECT
-private slots:
- void initTestCase();
- void cleanupTestCase();
-
- void containsDrag_internal();
- void containsDrag_external();
- void keys_internal();
- void keys_external();
- void source_internal();
-// void source_external();
- void position_internal();
- void position_external();
- void drop_internal();
-// void drop_external();
- void simultaneousDrags();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_QQuickDropArea::initTestCase()
-{
-
-}
-
-void tst_QQuickDropArea::cleanupTestCase()
-{
-
-}
-
-void tst_QQuickDropArea::containsDrag_internal()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property bool hasDrag: containsDrag\n"
- "property int enterEvents: 0\n"
- "property int exitEvents: 0\n"
- "width: 100; height: 100\n"
- "onEntered: {++enterEvents}\n"
- "onExited: {++exitEvents}\n"
- "Item {\n"
- "objectName: \"dragItem\"\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(dropArea);
- dropArea->setParentItem(canvas.rootItem());
-
- QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
- QVERIFY(dragItem);
-
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
-
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
-
- evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
-
- evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
-
- dragItem->setPos(QPointF(150, 50));
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
-
- dragItem->setPos(QPointF(50, 50));
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
-
- evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
- dragItem->setPos(QPointF(150, 50));
-
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
-
- evaluate<void>(dragItem, "Drag.active = false");
-}
-
-void tst_QQuickDropArea::containsDrag_external()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property bool hasDrag: containsDrag\n"
- "property int enterEvents: 0\n"
- "property int exitEvents: 0\n"
- "width: 100; height: 100\n"
- "onEntered: {++enterEvents}\n"
- "onExited: {++exitEvents}\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(dropArea);
- dropArea->setParentItem(canvas.rootItem());
-
- QMimeData data;
- QQuickCanvas alternateCanvas;
-
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
-
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
-
- evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
-
- evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
-
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50));
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
-
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
-
- evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
-
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50));
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
-
- QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(150, 50));
-}
-
-void tst_QQuickDropArea::keys_internal()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property variant dragKeys\n"
- "property variant dropKeys: keys\n"
- "property int enterEvents: 0\n"
- "width: 100; height: 100\n"
- "onEntered: {++enterEvents; dragKeys = drag.keys }\n"
- "Item {\n"
- "objectName: \"dragItem\"\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "Drag.keys: [\"red\", \"blue\"]\n"
- "}\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(dropArea);
- dropArea->setParentItem(canvas.rootItem());
-
- QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
- QVERIFY(dragItem);
-
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
-
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
-
- evaluate<void>(dragItem, "Drag.active = false");
- evaluate<void>(dropArea, "keys = \"blue\"");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "blue");
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "blue");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
-
- evaluate<void>(dragItem, "Drag.active = false");
- evaluate<void>(dropArea, "keys = \"red\"");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "red");
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "red");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
-
- evaluate<void>(dragItem, "Drag.active = false");
- evaluate<void>(dropArea, "keys = \"green\"");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "green");
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "green");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
-
- evaluate<void>(dragItem, "Drag.active = false");
- evaluate<void>(dropArea, "keys = [\"red\", \"green\"]");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "red" << "green");
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "red" << "green");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
-
- evaluate<void>(dragItem, "Drag.active = false");
- evaluate<void>(dragItem, "Drag.keys = []");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
-
- evaluate<void>(dragItem, "Drag.active = false");
- evaluate<void>(dropArea, "keys = []");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList());
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList());
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList());
-
- evaluate<void>(dragItem, "Drag.active = false");
- evaluate<void>(dropArea, "keys = []");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList());
-
- evaluate<void>(dragItem, "Drag.active = false");
- evaluate<void>(dragItem, "Drag.keys = [\"red\", \"blue\"]");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
-}
-
-void tst_QQuickDropArea::keys_external()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property variant dragKeys\n"
- "property variant dropKeys: keys\n"
- "property int enterEvents: 0\n"
- "width: 100; height: 100\n"
- "onEntered: {++enterEvents; dragKeys = drag.keys }\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
- dropArea->setParentItem(canvas.rootItem());
-
- QMimeData data;
- QQuickCanvas alternateCanvas;
-
- data.setData("text/x-red", "red");
- data.setData("text/x-blue", "blue");
-
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
-
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
- evaluate<void>(dropArea, "keys = \"text/x-blue\"");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-blue");
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-blue");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
- evaluate<void>(dropArea, "keys = \"text/x-red\"");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red");
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
- evaluate<void>(dropArea, "keys = \"text/x-green\"");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-green");
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-green");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
- evaluate<void>(dropArea, "keys = [\"text/x-red\", \"text/x-green\"]");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red" << "text/x-green");
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red" << "text/x-green");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
- data.removeFormat("text/x-red");
- data.removeFormat("text/x-blue");
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
- evaluate<void>(dropArea, "keys = []");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList());
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList());
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList());
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
- data.setData("text/x-red", "red");
- data.setData("text/x-blue", "blue");
- QCOMPARE(dropArea->property("keys").toStringList(), QStringList());
- QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList());
- evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
-
- QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(50, 50));
-}
-
-void tst_QQuickDropArea::source_internal()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property Item source: drag.source\n"
- "property Item eventSource\n"
- "width: 100; height: 100\n"
- "onEntered: {eventSource = drag.source}\n"
- "Item {\n"
- "objectName: \"dragItem\"\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}\n"
- "Item { id: dragSource; objectName: \"dragSource\" }\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(dropArea);
- dropArea->setParentItem(canvas.rootItem());
-
- QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
- QVERIFY(dragItem);
-
- QQuickItem *dragSource = dropArea->findChild<QQuickItem *>("dragSource");
- QVERIFY(dragSource);
-
- QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(0));
-
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(dragItem));
- QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(dragItem));
- QCOMPARE(evaluate<QObject *>(dropArea, "eventSource"), static_cast<QObject *>(dragItem));
-
- evaluate<void>(dragItem, "Drag.active = false");
- QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(0));
-
-
- evaluate<void>(dropArea, "{ eventSource = null }");
- evaluate<void>(dragItem, "Drag.source = dragSource");
-
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(dragSource));
- QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(dragSource));
- QCOMPARE(evaluate<QObject *>(dropArea, "eventSource"), static_cast<QObject *>(dragSource));
-
- evaluate<void>(dragItem, "Drag.active = false");
- QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(0));
-}
-
-// Setting a source can't be emulated using the QWindowSystemInterface API.
-
-//void tst_QQuickDropArea::source_external()
-//{
-//}
-
-void tst_QQuickDropArea::position_internal()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property real dragX: drag.x\n"
- "property real dragY: drag.y\n"
- "property real eventX\n"
- "property real eventY\n"
- "property int enterEvents: 0\n"
- "property int moveEvents: 0\n"
- "width: 100; height: 100\n"
- "onEntered: {++enterEvents; eventX = drag.x; eventY = drag.y}\n"
- "onPositionChanged: {++moveEvents; eventX = drag.x; eventY = drag.y}\n"
- "Item {\n"
- "objectName: \"dragItem\"\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(dropArea);
- dropArea->setParentItem(canvas.rootItem());
-
- QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
- QVERIFY(dragItem);
-
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 0);
- QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
-
- evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
- dragItem->setPos(QPointF(40, 50));
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
- QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(40));
- QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(40));
- QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(40));
- QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
-
- evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
- dragItem->setPos(QPointF(75, 25));
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
- QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(75));
- QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(25));
- QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(75));
- QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(25));
- QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(75));
- QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(25));
-
- evaluate<void>(dragItem, "Drag.active = false");
-}
-
-void tst_QQuickDropArea::position_external()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property real dragX: drag.x\n"
- "property real dragY: drag.y\n"
- "property real eventX\n"
- "property real eventY\n"
- "property int enterEvents: 0\n"
- "property int moveEvents: 0\n"
- "width: 100; height: 100\n"
- "onEntered: {++enterEvents; eventX = drag.x; eventY = drag.y}\n"
- "onPositionChanged: {++moveEvents; eventX = drag.x; eventY = drag.y}\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(dropArea);
- dropArea->setParentItem(canvas.rootItem());
-
- QMimeData data;
-
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
- QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
-
- evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(40, 50));
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
- QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(40));
- QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(40));
- QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(50));
- QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(40));
- QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
-
- evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(75, 25));
- QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
- QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(75));
- QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(25));
- QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(75));
- QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(25));
- QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(75));
- QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(25));
-
- QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(75, 25));
-}
-
-void tst_QQuickDropArea::drop_internal()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property bool accept: false\n"
- "property bool setAccepted: false\n"
- "property bool acceptDropAction: false\n"
- "property bool setDropAction: false\n"
- "property int dropAction: Qt.IgnoreAction\n"
- "property int proposedAction: Qt.IgnoreAction\n"
- "property int supportedActions: Qt.IgnoreAction\n"
- "property int dropEvents: 0\n"
- "width: 100; height: 100\n"
- "onDropped: {\n"
- "++dropEvents\n"
- "supportedActions = drop.supportedActions\n"
- "proposedAction = drop.action\n"
- "if (setDropAction)\n"
- "drop.action = dropAction\n"
- "if (acceptDropAction)\n"
- "drop.accept(dropAction)\n"
- "else if (setAccepted)\n"
- "drop.accepted = accept\n"
- "else if (accept)\n"
- "drop.accept()\n"
- "}\n"
- "Item {\n"
- "objectName: \"dragItem\"\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "}\n"
- "}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(dropArea);
- dropArea->setParentItem(canvas.rootItem());
-
- QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
- QVERIFY(dragItem);
-
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::IgnoreAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ accept = true; setDropAction = true; dropAction = Qt.LinkAction }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ setAccepted = true; }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ accept = false; setAccepted = true; }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::IgnoreAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ setAccepted = false; setDropAction = false; acceptDropAction = true; }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ acceptDropAction = false; dropAction = Qt.IgnoreAction; accept = true }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::MoveAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ setAccepted = true }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::MoveAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ setAccepted = false }");
- evaluate<void>(dragItem, "Drag.supportedActions = Qt.LinkAction");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::MoveAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ setAccepted = true }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::MoveAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ setAccepted = false }");
- evaluate<void>(dragItem, "Drag.proposedAction = Qt.LinkAction");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::LinkAction));
-
- evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
- evaluate<void>(dropArea, "{ setAccepted = true }");
- evaluate<void>(dragItem, "Drag.active = true");
- QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::LinkAction));
- QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::LinkAction));
-}
-
-// Setting the supportedActions can't be emulated using the QWindowSystemInterface API.
-
-//void tst_QQuickDropArea::drop_external()
-//{
-//}
-
-void tst_QQuickDropArea::simultaneousDrags()
-{
- QQuickCanvas canvas;
- QDeclarativeComponent component(&engine);
- component.setData(
- "import QtQuick 2.0\n"
- "DropArea {\n"
- "property int enterEvents: 0\n"
- "property int exitEvents: 0\n"
- "width: 100; height: 100\n"
- "keys: [\"red\", \"text/x-red\"]\n"
- "onEntered: {++enterEvents}\n"
- "onExited: {++exitEvents}\n"
- "DropArea {\n"
- "objectName: \"dropArea2\"\n"
- "property int enterEvents: 0\n"
- "property int exitEvents: 0\n"
- "width: 100; height: 100\n"
- "keys: [\"blue\", \"text/x-blue\"]\n"
- "onEntered: {++enterEvents}\n"
- "onExited: {++exitEvents}\n"
- "}\n"
- "Item {\n"
- "objectName: \"dragItem1\"\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "Drag.keys: [\"red\", \"blue\"]"
- "}\n"
- "Item {\n"
- "objectName: \"dragItem2\"\n"
- "x: 50; y: 50\n"
- "width: 10; height: 10\n"
- "Drag.keys: [\"red\", \"blue\"]"
- "}\n"
- "}", QUrl());
-
- QScopedPointer<QObject> object(component.create());
- QQuickItem *dropArea1 = qobject_cast<QQuickItem *>(object.data());
- QVERIFY(dropArea1);
- dropArea1->setParentItem(canvas.rootItem());
-
- QQuickItem *dropArea2 = dropArea1->findChild<QQuickItem *>("dropArea2");
- QVERIFY(dropArea2);
-
- QQuickItem *dragItem1 = dropArea1->findChild<QQuickItem *>("dragItem1");
- QVERIFY(dragItem1);
-
- QQuickItem *dragItem2 = dropArea1->findChild<QQuickItem *>("dragItem2");
- QVERIFY(dragItem2);
-
- QMimeData data;
- data.setData("text/x-red", "red");
- data.setData("text/x-blue", "blue");
-
- QQuickCanvas alternateCanvas;
-
- // Mixed internal drags.
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem1, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem2, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dragItem2, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dragItem2, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dragItem1, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem2, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- // internal then external.
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem1, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dragItem1, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- // external then internal.
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem2, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dragItem2, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dragItem2, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem2, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- // Different acceptance
- evaluate<void>(dragItem1, "Drag.keys = \"red\"");
- evaluate<void>(dragItem2, "Drag.keys = \"blue\"");
- data.removeFormat("text/x-red");
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem1, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem2, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem2, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem2, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem1, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem2, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
-
- // internal then external
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem1, "Drag.active = true");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dragItem1, "Drag.active = false");
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
-
- evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
- evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
- QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
- QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
- QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
- QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
- QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
-
- QWindowSystemInterface::handleDrop(&alternateCanvas, &data, QPoint(50, 50));
-}
-
-QTEST_MAIN(tst_QQuickDropArea)
-
-#include "tst_qquickdroparea.moc"
diff --git a/tests/auto/qtquick2/qquickflickable/qquickflickable.pro b/tests/auto/qtquick2/qquickflickable/qquickflickable.pro
deleted file mode 100644
index d1b8b6948f..0000000000
--- a/tests/auto/qtquick2/qquickflickable/qquickflickable.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickflickable
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickflickable.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qquickflickable/tst_qquickflickable.cpp b/tests/auto/qtquick2/qquickflickable/tst_qquickflickable.cpp
deleted file mode 100644
index d357877ed5..0000000000
--- a/tests/auto/qtquick2/qquickflickable/tst_qquickflickable.cpp
+++ /dev/null
@@ -1,663 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <private/qquickflickable_p.h>
-#include <private/qquickflickable_p_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include <math.h>
-#include "../../shared/util.h"
-#include "../shared/viewtestutil.h"
-#include "../shared/visualtestutil.h"
-#include <QtOpenGL/QGLShaderProgram>
-
-using namespace QQuickViewTestUtil;
-using namespace QQuickVisualTestUtil;
-
-class tst_qquickflickable : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
-
-private slots:
- void create();
- void horizontalViewportSize();
- void verticalViewportSize();
- void properties();
- void boundsBehavior();
- void maximumFlickVelocity();
- void flickDeceleration();
- void pressDelay();
- void nestedPressDelay();
- void flickableDirection();
- void resizeContent();
- void returnToBounds();
- void wheel();
- void movingAndDragging();
- void disabled();
- void flickVelocity();
- void margins();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qquickflickable::create()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("flickable01.qml"));
- QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->isAtXBeginning(), true);
- QCOMPARE(obj->isAtXEnd(), false);
- QCOMPARE(obj->isAtYBeginning(), true);
- QCOMPARE(obj->isAtYEnd(), false);
- QCOMPARE(obj->contentX(), 0.);
- QCOMPARE(obj->contentY(), 0.);
-
- QCOMPARE(obj->horizontalVelocity(), 0.);
- QCOMPARE(obj->verticalVelocity(), 0.);
-
- QCOMPARE(obj->isInteractive(), true);
- QCOMPARE(obj->boundsBehavior(), QQuickFlickable::DragAndOvershootBounds);
- QCOMPARE(obj->pressDelay(), 0);
- QCOMPARE(obj->maximumFlickVelocity(), 2500.);
-
- delete obj;
-}
-
-void tst_qquickflickable::horizontalViewportSize()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("flickable02.qml"));
- QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->contentWidth(), 800.);
- QCOMPARE(obj->contentHeight(), 300.);
- QCOMPARE(obj->isAtXBeginning(), true);
- QCOMPARE(obj->isAtXEnd(), false);
- QCOMPARE(obj->isAtYBeginning(), true);
- QCOMPARE(obj->isAtYEnd(), false);
-
- delete obj;
-}
-
-void tst_qquickflickable::verticalViewportSize()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("flickable03.qml"));
- QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->contentWidth(), 200.);
- QCOMPARE(obj->contentHeight(), 6000.);
- QCOMPARE(obj->isAtXBeginning(), true);
- QCOMPARE(obj->isAtXEnd(), false);
- QCOMPARE(obj->isAtYBeginning(), true);
- QCOMPARE(obj->isAtYEnd(), false);
-
- delete obj;
-}
-
-void tst_qquickflickable::properties()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("flickable04.qml"));
- QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->isInteractive(), false);
- QCOMPARE(obj->boundsBehavior(), QQuickFlickable::StopAtBounds);
- QCOMPARE(obj->pressDelay(), 200);
- QCOMPARE(obj->maximumFlickVelocity(), 2000.);
-
- QVERIFY(obj->property("ok").toBool() == false);
- QMetaObject::invokeMethod(obj, "check");
- QVERIFY(obj->property("ok").toBool() == true);
-
- delete obj;
-}
-
-void tst_qquickflickable::boundsBehavior()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Flickable { boundsBehavior: Flickable.StopAtBounds }", QUrl::fromLocalFile(""));
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(boundsBehaviorChanged()));
-
- QVERIFY(flickable);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds);
-
- flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragAndOvershootBounds);
- QCOMPARE(spy.count(),1);
- flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
- QCOMPARE(spy.count(),1);
-
- flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragOverBounds);
- QCOMPARE(spy.count(),2);
- flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds);
- QCOMPARE(spy.count(),2);
-
- flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds);
- QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds);
- QCOMPARE(spy.count(),3);
- flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds);
- QCOMPARE(spy.count(),3);
-}
-
-void tst_qquickflickable::maximumFlickVelocity()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile(""));
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged()));
-
- QVERIFY(flickable);
- QCOMPARE(flickable->maximumFlickVelocity(), 1.0);
-
- flickable->setMaximumFlickVelocity(2.0);
- QCOMPARE(flickable->maximumFlickVelocity(), 2.0);
- QCOMPARE(spy.count(),1);
- flickable->setMaximumFlickVelocity(2.0);
- QCOMPARE(spy.count(),1);
-}
-
-void tst_qquickflickable::flickDeceleration()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile(""));
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged()));
-
- QVERIFY(flickable);
- QCOMPARE(flickable->flickDeceleration(), 1.0);
-
- flickable->setFlickDeceleration(2.0);
- QCOMPARE(flickable->flickDeceleration(), 2.0);
- QCOMPARE(spy.count(),1);
- flickable->setFlickDeceleration(2.0);
- QCOMPARE(spy.count(),1);
-}
-
-void tst_qquickflickable::pressDelay()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Flickable { pressDelay: 100; }", QUrl::fromLocalFile(""));
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(pressDelayChanged()));
-
- QVERIFY(flickable);
- QCOMPARE(flickable->pressDelay(), 100);
-
- flickable->setPressDelay(200);
- QCOMPARE(flickable->pressDelay(), 200);
- QCOMPARE(spy.count(),1);
- flickable->setPressDelay(200);
- QCOMPARE(spy.count(),1);
-}
-
-// QTBUG-17361
-void tst_qquickflickable::nestedPressDelay()
-{
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("nestedPressDelay.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(canvas->rootObject());
- QVERIFY(outer != 0);
-
- QQuickFlickable *inner = canvas->rootObject()->findChild<QQuickFlickable*>("innerFlickable");
- QVERIFY(inner != 0);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(150, 150));
- // the MouseArea is not pressed immediately
- QVERIFY(outer->property("pressed").toBool() == false);
-
- // The outer pressDelay will prevail (50ms, vs. 10sec)
- // QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec.
- QTRY_VERIFY(outer->property("pressed").toBool() == true);
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(150, 150));
-
- delete canvas;
-}
-
-void tst_qquickflickable::flickableDirection()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Flickable { flickableDirection: Flickable.VerticalFlick; }", QUrl::fromLocalFile(""));
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
- QSignalSpy spy(flickable, SIGNAL(flickableDirectionChanged()));
-
- QVERIFY(flickable);
- QCOMPARE(flickable->flickableDirection(), QQuickFlickable::VerticalFlick);
-
- flickable->setFlickableDirection(QQuickFlickable::HorizontalAndVerticalFlick);
- QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalAndVerticalFlick);
- QCOMPARE(spy.count(),1);
-
- flickable->setFlickableDirection(QQuickFlickable::AutoFlickDirection);
- QCOMPARE(flickable->flickableDirection(), QQuickFlickable::AutoFlickDirection);
- QCOMPARE(spy.count(),2);
-
- flickable->setFlickableDirection(QQuickFlickable::HorizontalFlick);
- QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalFlick);
- QCOMPARE(spy.count(),3);
-
- flickable->setFlickableDirection(QQuickFlickable::HorizontalFlick);
- QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalFlick);
- QCOMPARE(spy.count(),3);
-}
-
-// QtQuick 1.1
-void tst_qquickflickable::resizeContent()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("resize.qml"));
- QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
- QQuickFlickable *obj = findItem<QQuickFlickable>(root, "flick");
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->contentX(), 0.);
- QCOMPARE(obj->contentY(), 0.);
- QCOMPARE(obj->contentWidth(), 300.);
- QCOMPARE(obj->contentHeight(), 300.);
-
- QMetaObject::invokeMethod(root, "resizeContent");
-
- QCOMPARE(obj->contentX(), 100.);
- QCOMPARE(obj->contentY(), 100.);
- QCOMPARE(obj->contentWidth(), 600.);
- QCOMPARE(obj->contentHeight(), 600.);
-
- delete root;
-}
-
-// QtQuick 1.1
-void tst_qquickflickable::returnToBounds()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("resize.qml"));
- QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
- QQuickFlickable *obj = findItem<QQuickFlickable>(root, "flick");
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->contentX(), 0.);
- QCOMPARE(obj->contentY(), 0.);
- QCOMPARE(obj->contentWidth(), 300.);
- QCOMPARE(obj->contentHeight(), 300.);
-
- obj->setContentX(100);
- obj->setContentY(400);
- QTRY_COMPARE(obj->contentX(), 100.);
- QTRY_COMPARE(obj->contentY(), 400.);
-
- QMetaObject::invokeMethod(root, "returnToBounds");
-
- QTRY_COMPARE(obj->contentX(), 0.);
- QTRY_COMPARE(obj->contentY(), 0.);
-
- delete root;
-}
-
-void tst_qquickflickable::wheel()
-{
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("wheel.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickFlickable *flick = canvas->rootObject()->findChild<QQuickFlickable*>("flick");
- QVERIFY(flick != 0);
-
- {
- QWheelEvent event(QPoint(200, 200), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical);
- event.setAccepted(false);
- QGuiApplication::sendEvent(canvas, &event);
- }
-
- QTRY_VERIFY(flick->contentY() > 0);
- QVERIFY(flick->contentX() == 0);
-
- flick->setContentY(0);
- QVERIFY(flick->contentY() == 0);
-
- {
- QWheelEvent event(QPoint(200, 200), -120, Qt::NoButton, Qt::NoModifier, Qt::Horizontal);
- event.setAccepted(false);
- QGuiApplication::sendEvent(canvas, &event);
- }
-
- QTRY_VERIFY(flick->contentX() > 0);
- QVERIFY(flick->contentY() == 0);
-
- delete canvas;
-}
-
-void tst_qquickflickable::movingAndDragging()
-{
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("flickable03.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(canvas->rootObject());
- QVERIFY(flickable != 0);
-
- QSignalSpy vDragSpy(flickable, SIGNAL(draggingVerticallyChanged()));
- QSignalSpy hDragSpy(flickable, SIGNAL(draggingHorizontallyChanged()));
- QSignalSpy dragSpy(flickable, SIGNAL(draggingChanged()));
- QSignalSpy vMoveSpy(flickable, SIGNAL(movingVerticallyChanged()));
- QSignalSpy hMoveSpy(flickable, SIGNAL(movingHorizontallyChanged()));
- QSignalSpy moveSpy(flickable, SIGNAL(movingChanged()));
- QSignalSpy dragStartSpy(flickable, SIGNAL(dragStarted()));
- QSignalSpy dragEndSpy(flickable, SIGNAL(dragEnded()));
-
- //Vertical
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90));
-
- QTest::mouseMove(canvas, QPoint(50, 80));
- QTest::mouseMove(canvas, QPoint(50, 70));
- QTest::mouseMove(canvas, QPoint(50, 60));
-
- QMouseEvent moveEvent(QEvent::MouseMove, QPoint(50, 80), Qt::LeftButton, Qt::LeftButton, 0);
-
- QVERIFY(!flickable->isDraggingHorizontally());
- QVERIFY(flickable->isDraggingVertically());
- QVERIFY(flickable->isDragging());
- QCOMPARE(vDragSpy.count(), 1);
- QCOMPARE(dragSpy.count(), 1);
- QCOMPARE(hDragSpy.count(), 0);
- QCOMPARE(dragStartSpy.count(), 1);
- QCOMPARE(dragEndSpy.count(), 0);
-
- QVERIFY(!flickable->isMovingHorizontally());
- QVERIFY(flickable->isMovingVertically());
- QVERIFY(flickable->isMoving());
- QCOMPARE(vMoveSpy.count(), 1);
- QCOMPARE(moveSpy.count(), 1);
- QCOMPARE(hMoveSpy.count(), 0);
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 60));
-
- QTRY_VERIFY(!flickable->isDraggingVertically());
- QVERIFY(!flickable->isDragging());
- QCOMPARE(vDragSpy.count(), 2);
- QCOMPARE(dragSpy.count(), 2);
- QCOMPARE(hDragSpy.count(), 0);
- QCOMPARE(dragStartSpy.count(), 1);
- QCOMPARE(dragEndSpy.count(), 1);
-
- // wait for any motion to end
- QTRY_VERIFY(flickable->isMoving() == false);
-
- //Horizontal
- vDragSpy.clear();
- hDragSpy.clear();
- dragSpy.clear();
- vMoveSpy.clear();
- hMoveSpy.clear();
- moveSpy.clear();
- dragStartSpy.clear();
- dragEndSpy.clear();
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(90, 50));
-
- QTest::mouseMove(canvas, QPoint(80, 50));
- QTest::mouseMove(canvas, QPoint(70, 50));
- QTest::mouseMove(canvas, QPoint(60, 50));
-
- QVERIFY(!flickable->isDraggingVertically());
- QVERIFY(flickable->isDraggingHorizontally());
- QVERIFY(flickable->isDragging());
- QCOMPARE(vDragSpy.count(), 0);
- QCOMPARE(dragSpy.count(), 1);
- QCOMPARE(hDragSpy.count(), 1);
- QCOMPARE(dragStartSpy.count(), 1);
- QCOMPARE(dragEndSpy.count(), 0);
-
- QVERIFY(!flickable->isMovingVertically());
- QVERIFY(flickable->isMovingHorizontally());
- QVERIFY(flickable->isMoving());
- QCOMPARE(vMoveSpy.count(), 0);
- QCOMPARE(moveSpy.count(), 1);
- QCOMPARE(hMoveSpy.count(), 1);
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(60, 50));
-
- QTRY_VERIFY(!flickable->isDraggingHorizontally());
- QVERIFY(!flickable->isDragging());
- QCOMPARE(vDragSpy.count(), 0);
- QCOMPARE(dragSpy.count(), 2);
- QCOMPARE(hDragSpy.count(), 2);
- QCOMPARE(dragStartSpy.count(), 1);
- QCOMPARE(dragEndSpy.count(), 1);
- // Don't test moving because a flick could occur
-
-#ifdef Q_OS_MAC
- QSKIP("Producing flicks on Mac CI impossible due to timing problems");
-#endif
-
- QTRY_VERIFY(!flickable->isMoving());
-
- vMoveSpy.clear();
- hMoveSpy.clear();
- moveSpy.clear();
- QSignalSpy vFlickSpy(flickable, SIGNAL(flickingVerticallyChanged()));
- QSignalSpy hFlickSpy(flickable, SIGNAL(flickingHorizontallyChanged()));
- QSignalSpy flickSpy(flickable, SIGNAL(flickingChanged()));
-
- // flick then press while it is still moving
- // flicking == false, moving == true;
- flick(canvas, QPoint(20,190), QPoint(20, 50), 200);
- QVERIFY(flickable->verticalVelocity() > 0.0);
- QVERIFY(flickable->isFlicking());
- QVERIFY(flickable->isFlickingVertically());
- QVERIFY(!flickable->isFlickingHorizontally());
- QVERIFY(flickable->isMoving());
- QVERIFY(flickable->isMovingVertically());
- QVERIFY(!flickable->isMovingHorizontally());
- QCOMPARE(vMoveSpy.count(), 1);
- QCOMPARE(hMoveSpy.count(), 0);
- QCOMPARE(moveSpy.count(), 1);
- QCOMPARE(vFlickSpy.count(), 1);
- QCOMPARE(hFlickSpy.count(), 0);
- QCOMPARE(flickSpy.count(), 1);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(20, 50));
- QTRY_VERIFY(!flickable->isFlicking());
- QVERIFY(!flickable->isFlickingVertically());
- QVERIFY(flickable->isMoving());
- QVERIFY(flickable->isMovingVertically());
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(20,50));
- QVERIFY(!flickable->isFlicking());
- QVERIFY(!flickable->isFlickingVertically());
- QTRY_VERIFY(!flickable->isMoving());
- QVERIFY(!flickable->isMovingVertically());
-
- delete canvas;
-}
-
-void tst_qquickflickable::disabled()
-{
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("disabled.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickFlickable *flick = canvas->rootObject()->findChild<QQuickFlickable*>("flickable");
- QVERIFY(flick != 0);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90));
-
- QTest::mouseMove(canvas, QPoint(50, 80));
- QTest::mouseMove(canvas, QPoint(50, 70));
- QTest::mouseMove(canvas, QPoint(50, 60));
-
- QVERIFY(flick->isMoving() == false);
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 60));
-
- // verify that mouse clicks on other elements still work (QTBUG-20584)
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 10));
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 10));
-
- QTRY_VERIFY(canvas->rootObject()->property("clicked").toBool() == true);
-}
-
-void tst_qquickflickable::flickVelocity()
-{
-#ifdef Q_OS_MAC
- QSKIP("Producing flicks on Mac CI impossible due to timing problems");
-#endif
-
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("flickable03.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(canvas->rootObject());
- QVERIFY(flickable != 0);
-
- // flick up
- flick(canvas, QPoint(20,190), QPoint(20, 50), 200);
- QVERIFY(flickable->verticalVelocity() > 0.0);
- QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
-
- // flick down
- flick(canvas, QPoint(20,10), QPoint(20, 140), 200);
- QVERIFY(flickable->verticalVelocity() < 0.0);
- QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
-
- // Flick multiple times and verify that flick acceleration is applied.
- QQuickFlickablePrivate *fp = QQuickFlickablePrivate::get(flickable);
- bool boosted = false;
- for (int i = 0; i < 6; ++i) {
- flick(canvas, QPoint(20,390), QPoint(20, 50), 200);
- boosted |= fp->flickBoost > 1.0;
- }
- QVERIFY(boosted);
-
- // Flick in opposite direction -> boost cancelled.
- flick(canvas, QPoint(20,10), QPoint(20, 340), 200);
- QTRY_VERIFY(flickable->verticalVelocity() < 0.0);
- QVERIFY(fp->flickBoost == 1.0);
-
- delete canvas;
-}
-
-void tst_qquickflickable::margins()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("margins.qml"));
- QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
- QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(root);
- QVERIFY(obj != 0);
-
- // starting state
- QCOMPARE(obj->contentX(), -40.);
- QCOMPARE(obj->contentY(), -20.);
- QCOMPARE(obj->contentWidth(), 1600.);
- QCOMPARE(obj->contentHeight(), 600.);
- QCOMPARE(obj->xOrigin(), 0.);
- QCOMPARE(obj->yOrigin(), 0.);
-
- // Reduce left margin
- obj->setLeftMargin(30);
- QTRY_COMPARE(obj->contentX(), -30.);
-
- // Reduce top margin
- obj->setTopMargin(20);
- QTRY_COMPARE(obj->contentY(), -20.);
-
- // position to the far right, including margin
- obj->setContentX(1600 + 50 - obj->width());
- obj->returnToBounds();
- QTest::qWait(200);
- QCOMPARE(obj->contentX(), 1600. + 50. - obj->width());
-
- // position beyond the far right, including margin
- obj->setContentX(1600 + 50 - obj->width() + 1.);
- obj->returnToBounds();
- QTRY_COMPARE(obj->contentX(), 1600. + 50. - obj->width());
-
- // Reduce right margin
- obj->setRightMargin(40);
- QTRY_COMPARE(obj->contentX(), 1600. + 40. - obj->width());
- QCOMPARE(obj->contentWidth(), 1600.);
-
- // position to the far bottom, including margin
- obj->setContentY(600 + 30 - obj->height());
- obj->returnToBounds();
- QTest::qWait(200);
- QCOMPARE(obj->contentY(), 600. + 30. - obj->height());
-
- // position beyond the far bottom, including margin
- obj->setContentY(600 + 30 - obj->height() + 1.);
- obj->returnToBounds();
- QTRY_COMPARE(obj->contentY(), 600. + 30. - obj->height());
-
- // Reduce bottom margin
- obj->setBottomMargin(20);
- QTRY_COMPARE(obj->contentY(), 600. + 20. - obj->height());
- QCOMPARE(obj->contentHeight(), 600.);
-
- delete root;
-}
-
-QTEST_MAIN(tst_qquickflickable)
-
-#include "tst_qquickflickable.moc"
diff --git a/tests/auto/qtquick2/qquickflipable/qquickflipable.pro b/tests/auto/qtquick2/qquickflipable/qquickflipable.pro
deleted file mode 100644
index 3afad837fe..0000000000
--- a/tests/auto/qtquick2/qquickflipable/qquickflipable.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickflipable
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickflipable.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp b/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp
deleted file mode 100644
index c2c40c9746..0000000000
--- a/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <private/qquickflipable_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include <QFontMetrics>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <math.h>
-#include <QtOpenGL/QGLShaderProgram>
-#include "../../shared/util.h"
-
-class tst_qquickflipable : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
-
-private slots:
- void create();
- void checkFrontAndBack();
- void setFrontAndBack();
-
- // below here task issues
- void QTBUG_9161_crash();
- void QTBUG_8474_qgv_abort();
-
-private:
- QDeclarativeEngine engine;
-};
-
-void tst_qquickflipable::create()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("test-flipable.qml"));
- QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
-
- QVERIFY(obj != 0);
- delete obj;
-}
-
-void tst_qquickflipable::checkFrontAndBack()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("test-flipable.qml"));
- QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->front() != 0);
- QVERIFY(obj->back() != 0);
- delete obj;
-}
-
-void tst_qquickflipable::setFrontAndBack()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("test-flipable.qml"));
- QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->front() != 0);
- QVERIFY(obj->back() != 0);
-
- QString message = c.url().toString() + ":3:1: QML Flipable: front is a write-once property";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- obj->setFront(new QQuickRectangle());
-
- message = c.url().toString() + ":3:1: QML Flipable: back is a write-once property";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
- obj->setBack(new QQuickRectangle());
- delete obj;
-}
-
-void tst_qquickflipable::QTBUG_9161_crash()
-{
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("crash.qml"));
- QQuickItem *root = canvas->rootObject();
- QVERIFY(root != 0);
- canvas->show();
- delete canvas;
-}
-
-void tst_qquickflipable::QTBUG_8474_qgv_abort()
-{
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("flipable-abort.qml"));
- QQuickItem *root = canvas->rootObject();
- QVERIFY(root != 0);
- canvas->show();
- delete canvas;
-}
-
-QTEST_MAIN(tst_qquickflipable)
-
-#include "tst_qquickflipable.moc"
diff --git a/tests/auto/qtquick2/qquickfocusscope/qquickfocusscope.pro b/tests/auto/qtquick2/qquickfocusscope/qquickfocusscope.pro
deleted file mode 100644
index d83f6ca7a3..0000000000
--- a/tests/auto/qtquick2/qquickfocusscope/qquickfocusscope.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickfocusscope
-SOURCES += tst_qquickfocusscope.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qquickfocusscope/tst_qquickfocusscope.cpp b/tests/auto/qtquick2/qquickfocusscope/tst_qquickfocusscope.cpp
deleted file mode 100644
index 4264c68d92..0000000000
--- a/tests/auto/qtquick2/qquickfocusscope/tst_qquickfocusscope.cpp
+++ /dev/null
@@ -1,636 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <private/qquicktextedit_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qquickfocusscope_p.h>
-#include "../../shared/util.h"
-#include "../shared/visualtestutil.h"
-
-using namespace QQuickVisualTestUtil;
-
-class tst_qquickfocusscope : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquickfocusscope() {}
-
-private slots:
- void basic();
- void nested();
- void noFocus();
- void textEdit();
- void forceFocus();
- void noParentFocus();
- void signalEmission();
- void qtBug13380();
- void forceActiveFocus();
- void canvasFocus();
-};
-
-void tst_qquickfocusscope::basic()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("test.qml"));
-
- QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0"));
- QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
- QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
- QQuickRectangle *item3 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item3"));
- QVERIFY(item0 != 0);
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
-
- view->show();
- view->requestActivateWindow();
-
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
-
- QVERIFY(view->isTopLevel());
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Right);
- QTest::qWait(50);
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == true);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Down);
- QTest::qWait(50);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == true);
-
- delete view;
-}
-
-void tst_qquickfocusscope::nested()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("test2.qml"));
-
- QQuickFocusScope *item1 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item1"));
- QQuickFocusScope *item2 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item2"));
- QQuickFocusScope *item3 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item3"));
- QQuickFocusScope *item4 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item4"));
- QQuickFocusScope *item5 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item5"));
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
- QVERIFY(item4 != 0);
- QVERIFY(item5 != 0);
-
- view->show();
- view->requestActivateWindow();
-
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
-
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == true);
- QVERIFY(item3->hasActiveFocus() == true);
- QVERIFY(item4->hasActiveFocus() == true);
- QVERIFY(item5->hasActiveFocus() == true);
- delete view;
-}
-
-void tst_qquickfocusscope::noFocus()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("test4.qml"));
-
- QQuickRectangle *item0 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item0"));
- QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
- QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
- QQuickRectangle *item3 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item3"));
- QVERIFY(item0 != 0);
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
-
- view->show();
- view->requestActivateWindow();
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
-
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Down);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- delete view;
-}
-
-void tst_qquickfocusscope::textEdit()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("test5.qml"));
-
- QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0"));
- QQuickTextEdit *item1 = findItem<QQuickTextEdit>(view->rootObject(), QLatin1String("item1"));
- QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
- QQuickTextEdit *item3 = findItem<QQuickTextEdit>(view->rootObject(), QLatin1String("item3"));
- QVERIFY(item0 != 0);
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
-
- view->show();
- view->requestActivateWindow();
-
- QTest::qWaitForWindowShown(view);
-
- QTRY_VERIFY(view == qGuiApp->focusWindow());
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Right);
- QTest::keyClick(view, Qt::Key_Right);
- QTest::keyClick(view, Qt::Key_Right);
- QTest::keyClick(view, Qt::Key_Right);
- QTest::keyClick(view, Qt::Key_Right);
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == true);
- QVERIFY(item3->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_Down);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == true);
-
- delete view;
-}
-
-void tst_qquickfocusscope::forceFocus()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("forcefocus.qml"));
-
- QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0"));
- QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
- QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
- QQuickFocusScope *item3 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item3"));
- QQuickRectangle *item4 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item4"));
- QQuickRectangle *item5 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item5"));
- QVERIFY(item0 != 0);
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
- QVERIFY(item4 != 0);
- QVERIFY(item5 != 0);
-
- view->show();
- view->requestActivateWindow();
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
-
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
- QVERIFY(item4->hasActiveFocus() == false);
- QVERIFY(item5->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_4);
- QVERIFY(item0->hasActiveFocus() == true);
- QVERIFY(item1->hasActiveFocus() == true);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == false);
- QVERIFY(item4->hasActiveFocus() == false);
- QVERIFY(item5->hasActiveFocus() == false);
-
- QTest::keyClick(view, Qt::Key_5);
- QVERIFY(item0->hasActiveFocus() == false);
- QVERIFY(item1->hasActiveFocus() == false);
- QVERIFY(item2->hasActiveFocus() == false);
- QVERIFY(item3->hasActiveFocus() == true);
- QVERIFY(item4->hasActiveFocus() == false);
- QVERIFY(item5->hasActiveFocus() == true);
-
- delete view;
-}
-
-void tst_qquickfocusscope::noParentFocus()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("chain.qml"));
- QVERIFY(view->rootObject());
-
- view->show();
- view->requestActivateWindow();
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
-
- QVERIFY(view->rootObject()->property("focus1") == false);
- QVERIFY(view->rootObject()->property("focus2") == false);
- QVERIFY(view->rootObject()->property("focus3") == true);
- QVERIFY(view->rootObject()->property("focus4") == true);
- QVERIFY(view->rootObject()->property("focus5") == true);
-
- delete view;
-}
-
-void tst_qquickfocusscope::signalEmission()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("signalEmission.qml"));
-
- QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
- QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
- QQuickRectangle *item3 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item3"));
- QQuickRectangle *item4 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item4"));
- QVERIFY(item1 != 0);
- QVERIFY(item2 != 0);
- QVERIFY(item3 != 0);
- QVERIFY(item4 != 0);
-
- view->show();
- view->requestActivateWindow();
-
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
-
- QVariant blue(QColor("blue"));
- QVariant red(QColor("red"));
-
- item1->setFocus(true);
- QCOMPARE(item1->property("color"), red);
- QCOMPARE(item2->property("color"), blue);
- QCOMPARE(item3->property("color"), blue);
- QCOMPARE(item4->property("color"), blue);
-
- item2->setFocus(true);
- QCOMPARE(item1->property("color"), blue);
- QCOMPARE(item2->property("color"), red);
- QCOMPARE(item3->property("color"), blue);
- QCOMPARE(item4->property("color"), blue);
-
- item3->setFocus(true);
- QCOMPARE(item1->property("color"), blue);
- QCOMPARE(item2->property("color"), red);
- QCOMPARE(item3->property("color"), red);
- QCOMPARE(item4->property("color"), blue);
-
- item4->setFocus(true);
- QCOMPARE(item1->property("color"), blue);
- QCOMPARE(item2->property("color"), red);
- QCOMPARE(item3->property("color"), blue);
- QCOMPARE(item4->property("color"), red);
-
- item4->setFocus(false);
- QCOMPARE(item1->property("color"), blue);
- QCOMPARE(item2->property("color"), red);
- QCOMPARE(item3->property("color"), blue);
- QCOMPARE(item4->property("color"), blue);
-
- delete view;
-}
-
-void tst_qquickfocusscope::qtBug13380()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("qtBug13380.qml"));
-
- view->show();
- QVERIFY(view->rootObject());
- view->requestActivateWindow();
- qApp->processEvents();
-
- QTest::qWaitForWindowShown(view);
-
- QTRY_VERIFY(view == qGuiApp->focusWindow());
- QVERIFY(view->rootObject()->property("noFocus").toBool());
-
- view->rootObject()->setProperty("showRect", true);
- QVERIFY(view->rootObject()->property("noFocus").toBool());
-
- delete view;
-}
-
-void tst_qquickfocusscope::forceActiveFocus()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("forceActiveFocus.qml"));
-
- view->show();
- view->requestActivateWindow();
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
-
- QQuickItem *rootObject = view->rootObject();
- QVERIFY(rootObject);
-
- QQuickItem *scope = findItem<QQuickItem>(rootObject, QLatin1String("scope"));
- QQuickItem *itemA1 = findItem<QQuickItem>(rootObject, QLatin1String("item-a1"));
- QQuickItem *scopeA = findItem<QQuickItem>(rootObject, QLatin1String("scope-a"));
- QQuickItem *itemA2 = findItem<QQuickItem>(rootObject, QLatin1String("item-a2"));
- QQuickItem *itemB1 = findItem<QQuickItem>(rootObject, QLatin1String("item-b1"));
- QQuickItem *scopeB = findItem<QQuickItem>(rootObject, QLatin1String("scope-b"));
- QQuickItem *itemB2 = findItem<QQuickItem>(rootObject, QLatin1String("item-b2"));
-
- QVERIFY(scope);
- QVERIFY(itemA1);
- QVERIFY(scopeA);
- QVERIFY(itemA2);
- QVERIFY(itemB1);
- QVERIFY(scopeB);
- QVERIFY(itemB2);
-
- QSignalSpy rootSpy(rootObject, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy scopeSpy(scope, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy scopeASpy(scopeA, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy scopeBSpy(scopeB, SIGNAL(activeFocusChanged(bool)));
-
- // First, walk the focus from item-a1 down to item-a2 and back again
- itemA1->forceActiveFocus();
- QVERIFY(itemA1->hasActiveFocus());
- QVERIFY(!rootObject->hasActiveFocus());
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- scopeA->forceActiveFocus();
- QVERIFY(!itemA1->hasActiveFocus());
- QVERIFY(scopeA->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 1);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- itemA2->forceActiveFocus();
- QVERIFY(!itemA1->hasActiveFocus());
- QVERIFY(itemA2->hasActiveFocus());
- QVERIFY(scopeA->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 1);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- scopeA->forceActiveFocus();
- QVERIFY(!itemA1->hasActiveFocus());
- QVERIFY(itemA2->hasActiveFocus());
- QVERIFY(scopeA->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 1);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- itemA1->forceActiveFocus();
- QVERIFY(itemA1->hasActiveFocus());
- QVERIFY(!scopeA->hasActiveFocus());
- QVERIFY(!itemA2->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 2);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- // Then jump back and forth between branch 'a' and 'b'
- itemB1->forceActiveFocus();
- QVERIFY(itemB1->hasActiveFocus());
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- scopeA->forceActiveFocus();
- QVERIFY(!itemA1->hasActiveFocus());
- QVERIFY(!itemB1->hasActiveFocus());
- QVERIFY(scopeA->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 3);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- scopeB->forceActiveFocus();
- QVERIFY(!scopeA->hasActiveFocus());
- QVERIFY(!itemB1->hasActiveFocus());
- QVERIFY(scopeB->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 4);
- QCOMPARE(scopeBSpy.count(), 1);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- itemA2->forceActiveFocus();
- QVERIFY(!scopeB->hasActiveFocus());
- QVERIFY(itemA2->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 5);
- QCOMPARE(scopeBSpy.count(), 2);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- itemB2->forceActiveFocus();
- QVERIFY(!itemA2->hasActiveFocus());
- QVERIFY(itemB2->hasActiveFocus());
- QCOMPARE(scopeASpy.count(), 6);
- QCOMPARE(scopeBSpy.count(), 3);
- QCOMPARE(rootSpy.count(), 0);
- QCOMPARE(scopeSpy.count(), 1);
-
- delete view;
-}
-
-void tst_qquickfocusscope::canvasFocus()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("canvasFocus.qml"));
-
- QQuickView alternateView;
-
- QQuickItem *rootObject = view->rootObject();
- QVERIFY(rootObject);
-
- QQuickItem *rootItem = view->rootItem();
- QQuickItem *scope1 = findItem<QQuickItem>(rootObject, QLatin1String("scope1"));
- QQuickItem *item1 = findItem<QQuickItem>(rootObject, QLatin1String("item1"));
- QQuickItem *scope2 = findItem<QQuickItem>(rootObject, QLatin1String("scope2"));
- QQuickItem *item2 = findItem<QQuickItem>(rootObject, QLatin1String("item2"));
-
- QVERIFY(scope1);
- QVERIFY(item1);
- QVERIFY(scope2);
- QVERIFY(item2);
-
- QSignalSpy rootFocusSpy(rootItem, SIGNAL(focusChanged(bool)));
- QSignalSpy scope1FocusSpy(scope1, SIGNAL(focusChanged(bool)));
- QSignalSpy item1FocusSpy(item1, SIGNAL(focusChanged(bool)));
- QSignalSpy scope2FocusSpy(scope2, SIGNAL(focusChanged(bool)));
- QSignalSpy item2FocusSpy(item2, SIGNAL(focusChanged(bool)));
- QSignalSpy rootActiveFocusSpy(rootItem, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy scope1ActiveFocusSpy(scope1, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy item1ActiveFocusSpy(item1, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy scope2ActiveFocusSpy(scope2, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy item2ActiveFocusSpy(item2, SIGNAL(activeFocusChanged(bool)));
-
- QEXPECT_FAIL("", "QTBUG-22415", Abort);
- QCOMPARE(rootItem->hasFocus(), false);
- QCOMPARE(rootItem->hasActiveFocus(), false);
- QCOMPARE(scope1->hasFocus(), true);
- QCOMPARE(scope1->hasActiveFocus(), false);
- QCOMPARE(item1->hasFocus(), true);
- QCOMPARE(item1->hasActiveFocus(), false);
- QCOMPARE(scope2->hasFocus(), false);
- QCOMPARE(scope2->hasActiveFocus(), false);
- QCOMPARE(item2->hasFocus(), false);
- QCOMPARE(item2->hasActiveFocus(), false);
-
- view->show();
- view->requestActivateWindow();
-
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(view == qGuiApp->focusWindow());
-
- // Now the canvas has focus, active focus given to item1
- QCOMPARE(rootItem->hasFocus(), true);
- QCOMPARE(rootItem->hasActiveFocus(), true);
- QCOMPARE(scope1->hasFocus(), true);
- QCOMPARE(scope1->hasActiveFocus(), true);
- QCOMPARE(item1->hasFocus(), true);
- QCOMPARE(item1->hasActiveFocus(), true);
- QCOMPARE(scope2->hasFocus(), false);
- QCOMPARE(scope2->hasActiveFocus(), false);
- QCOMPARE(item2->hasFocus(), false);
- QCOMPARE(item2->hasActiveFocus(), false);
-
- QCOMPARE(rootFocusSpy.count(), 1);
- QCOMPARE(rootActiveFocusSpy.count(), 1);
- QCOMPARE(scope1FocusSpy.count(), 0);
- QCOMPARE(scope1ActiveFocusSpy.count(), 1);
- QCOMPARE(item1FocusSpy.count(), 0);
- QCOMPARE(item1ActiveFocusSpy.count(), 1);
-
-
- // view->hide(); // seemingly doesn't remove focus, so have an another view steal it.
- alternateView.show();
- alternateView.requestActivateWindow();
- QTest::qWaitForWindowShown(&alternateView);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &alternateView);
-
- QCOMPARE(rootItem->hasFocus(), false);
- QCOMPARE(rootItem->hasActiveFocus(), false);
- QCOMPARE(scope1->hasFocus(), true);
- QCOMPARE(scope1->hasActiveFocus(), false);
- QCOMPARE(item1->hasFocus(), true);
- QCOMPARE(item1->hasActiveFocus(), false);
-
- QCOMPARE(rootFocusSpy.count(), 2);
- QCOMPARE(rootActiveFocusSpy.count(), 2);
- QCOMPARE(scope1FocusSpy.count(), 0);
- QCOMPARE(scope1ActiveFocusSpy.count(), 2);
- QCOMPARE(item1FocusSpy.count(), 0);
- QCOMPARE(item1ActiveFocusSpy.count(), 2);
-
-
- // canvas does not have focus, so item2 will not get active focus
- item2->forceActiveFocus();
-
- QCOMPARE(rootItem->hasFocus(), false);
- QCOMPARE(rootItem->hasActiveFocus(), false);
- QCOMPARE(scope1->hasFocus(), false);
- QCOMPARE(scope1->hasActiveFocus(), false);
- QCOMPARE(item1->hasFocus(), true);
- QCOMPARE(item1->hasActiveFocus(), false);
- QCOMPARE(scope2->hasFocus(), true);
- QCOMPARE(scope2->hasActiveFocus(), false);
- QCOMPARE(item2->hasFocus(), true);
- QCOMPARE(item2->hasActiveFocus(), false);
-
- QCOMPARE(rootFocusSpy.count(), 2);
- QCOMPARE(rootActiveFocusSpy.count(), 2);
- QCOMPARE(scope1FocusSpy.count(), 1);
- QCOMPARE(scope1ActiveFocusSpy.count(), 2);
- QCOMPARE(item1FocusSpy.count(), 0);
- QCOMPARE(item1ActiveFocusSpy.count(), 2);
- QCOMPARE(scope2FocusSpy.count(), 1);
- QCOMPARE(scope2ActiveFocusSpy.count(), 0);
- QCOMPARE(item2FocusSpy.count(), 1);
- QCOMPARE(item2ActiveFocusSpy.count(), 0);
-
- // give the canvas focus, and item2 will get active focus
- view->show();
- view->requestActivateWindow();
- QTest::qWaitForWindowShown(view);
- QTRY_VERIFY(QGuiApplication::focusWindow() == view);
-
- QCOMPARE(rootItem->hasFocus(), true);
- QCOMPARE(rootItem->hasActiveFocus(), true);
- QCOMPARE(scope2->hasFocus(), true);
- QCOMPARE(scope2->hasActiveFocus(), true);
- QCOMPARE(item2->hasFocus(), true);
- QCOMPARE(item2->hasActiveFocus(), true);
- QCOMPARE(rootFocusSpy.count(), 3);
- QCOMPARE(rootActiveFocusSpy.count(), 3);
- QCOMPARE(scope2FocusSpy.count(), 1);
- QCOMPARE(scope2ActiveFocusSpy.count(), 1);
- QCOMPARE(item2FocusSpy.count(), 1);
- QCOMPARE(item2ActiveFocusSpy.count(), 1);
-
- delete view;
-}
-
-QTEST_MAIN(tst_qquickfocusscope)
-
-#include "tst_qquickfocusscope.moc"
diff --git a/tests/auto/qtquick2/qquickgridview/data/addTransitions.qml b/tests/auto/qtquick2/qquickgridview/data/addTransitions.qml
deleted file mode 100644
index faea02a50d..0000000000
--- a/tests/auto/qtquick2/qquickgridview/data/addTransitions.qml
+++ /dev/null
@@ -1,129 +0,0 @@
-import QtQuick 2.0
-
-Rectangle {
- id: root
- width: 550
- height: 600
-
- property int duration: 10
- property int count: grid.count
-
- Component {
- id: myDelegate
-
- Rectangle {
- id: wrapper
-
- property string nameData: name
-
- objectName: "wrapper"
- width: 80
- height: 60
- border.width: 1
- Column {
- Text { text: index }
- Text {
- text: wrapper.x + ", " + wrapper.y
- }
- Text {
- id: textName
- objectName: "textName"
- text: name
- }
- }
- color: GridView.isCurrentItem ? "lightsteelblue" : "white"
-
- onXChanged: checkPos()
- onYChanged: checkPos()
-
- function checkPos() {
- if (Qt.point(x, y) == targetItems_transitionFrom)
- model_targetItems_transitionFrom.addItem(name, "")
- if (Qt.point(x, y) == displacedItems_transitionVia)
- model_displacedItems_transitionVia.addItem(name, "")
- }
- }
- }
-
- GridView {
- id: grid
-
- property int targetTransitionsDone
- property int displaceTransitionsDone
-
- property var targetTrans_items: new Object()
- property var targetTrans_targetIndexes: new Array()
- property var targetTrans_targetItems: new Array()
-
- property var displacedTrans_items: new Object()
- property var displacedTrans_targetIndexes: new Array()
- property var displacedTrans_targetItems: new Array()
-
- objectName: "grid"
- width: 240
- height: 320
- cellWidth: 80
- cellHeight: 60
- anchors.centerIn: parent
- model: testModel
- delegate: myDelegate
-
- // for QDeclarativeListProperty types
- function copyList(propList) {
- var temp = new Array()
- for (var i=0; i<propList.length; i++)
- temp.push(propList[i])
- return temp
- }
-
- add: Transition {
- id: targetTransition
-
- SequentialAnimation {
- ScriptAction {
- script: {
- grid.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
- grid.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
- grid.targetTrans_targetItems.push(grid.copyList(targetTransition.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; from: targetItems_transitionFrom.x; duration: root.duration }
- NumberAnimation { properties: "y"; from: targetItems_transitionFrom.y; duration: root.duration }
- }
-
- ScriptAction { script: grid.targetTransitionsDone += 1 }
- }
- }
-
- addDisplaced: Transition {
- id: displaced
-
- SequentialAnimation {
- ScriptAction {
- script: {
- grid.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
- grid.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
- grid.displacedTrans_targetItems.push(grid.copyList(displaced.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; duration: root.duration; to: displacedItems_transitionVia.x }
- NumberAnimation { properties: "y"; duration: root.duration; to: displacedItems_transitionVia.y }
- }
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: grid.displaceTransitionsDone += 1 }
- }
-
- }
- }
-
- Rectangle {
- anchors.fill: grid
- color: "lightsteelblue"
- opacity: 0.2
- }
-}
-
-
diff --git a/tests/auto/qtquick2/qquickgridview/data/moveTransitions.qml b/tests/auto/qtquick2/qquickgridview/data/moveTransitions.qml
deleted file mode 100644
index 3599dcfea0..0000000000
--- a/tests/auto/qtquick2/qquickgridview/data/moveTransitions.qml
+++ /dev/null
@@ -1,143 +0,0 @@
-import QtQuick 2.0
-
-Rectangle {
- id: root
- width: 500
- height: 600
-
- property int duration: 10
- property int count: grid.count
-
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
-
- property string nameData: name
-
- objectName: "wrapper"
- width: 80
- height: 60
- border.width: 1
- Column {
- Text { text: index }
- Text {
- text: wrapper.x + ", " + wrapper.y
- }
- Text {
- id: textName
- objectName: "textName"
- text: name
- }
- }
- color: GridView.isCurrentItem ? "lightsteelblue" : "white"
-
- onXChanged: checkPos()
- onYChanged: checkPos()
-
- function checkPos() {
- if (Qt.point(x, y) == targetItems_transitionVia)
- model_targetItems_transitionVia.addItem(name, "")
- if (Qt.point(x, y) == displacedItems_transitionVia)
- model_displacedItems_transitionVia.addItem(name, "")
- }
- }
- }
-
- GridView {
- id: grid
-
- property int targetTransitionsDone
- property int displaceTransitionsDone
-
- property var targetTrans_items: new Object()
- property var targetTrans_targetIndexes: new Array()
- property var targetTrans_targetItems: new Array()
-
- property var displacedTrans_items: new Object()
- property var displacedTrans_targetIndexes: new Array()
- property var displacedTrans_targetItems: new Array()
-
- objectName: "grid"
- width: 240
- height: 320
- cellWidth: 80
- cellHeight: 60
- anchors.centerIn: parent
- model: testModel
- delegate: myDelegate
-
- // for QDeclarativeListProperty types
- function copyList(propList) {
- var temp = new Array()
- for (var i=0; i<propList.length; i++)
- temp.push(propList[i])
- return temp
- }
-
- move: Transition {
- id: targetTransition
-
- SequentialAnimation {
- ScriptAction {
- script: {
- grid.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
- grid.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
- grid.targetTrans_targetItems.push(grid.copyList(targetTransition.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; to: targetItems_transitionVia.x; duration: root.duration }
- NumberAnimation { properties: "y"; to: targetItems_transitionVia.y; duration: root.duration }
- }
-
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: grid.targetTransitionsDone += 1 }
- }
- }
-
- moveDisplaced: Transition {
- id: displaced
-
- SequentialAnimation {
- ScriptAction {
- script: {
- grid.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
- grid.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
- grid.displacedTrans_targetItems.push(grid.copyList(displaced.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation {
- properties: "x"; duration: root.duration
- to: displacedItems_transitionVia.x
- }
- NumberAnimation {
- properties: "y"; duration: root.duration
- to: displacedItems_transitionVia.y
- }
- }
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: grid.displaceTransitionsDone += 1 }
- }
-
- }
- }
-
- Rectangle {
- anchors.fill: grid
- color: "lightsteelblue"
- opacity: 0.2
- }
-
- Rectangle {
- anchors.bottom: parent.bottom
- width: 20; height: 20
- color: "white"
- NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 10000 }
- }
-}
-
-
diff --git a/tests/auto/qtquick2/qquickgridview/data/removeTransitions.qml b/tests/auto/qtquick2/qquickgridview/data/removeTransitions.qml
deleted file mode 100644
index b07a03580a..0000000000
--- a/tests/auto/qtquick2/qquickgridview/data/removeTransitions.qml
+++ /dev/null
@@ -1,146 +0,0 @@
-import QtQuick 2.0
-
-Rectangle {
- id: root
- width: 500
- height: 600
-
- property int duration: 10
- property int count: grid.count
-
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
-
- property string nameData: name
-
- objectName: "wrapper"
- width: 80
- height: 60
- border.width: 1
- Column {
- Text { text: index }
- Text {
- text: wrapper.x + ", " + wrapper.y
- }
- Text {
- id: textName
- objectName: "textName"
- text: name
- }
- }
- color: GridView.isCurrentItem ? "lightsteelblue" : "white"
-
- onXChanged: checkPos()
- onYChanged: checkPos()
-
- function checkPos() {
- if (Qt.point(x, y) == targetItems_transitionTo) {
- model_targetItems_transitionTo.addItem(nameData, "") // name is invalid once model removes the item
- }
- if (Qt.point(x, y) == displacedItems_transitionVia) {
- model_displacedItems_transitionVia.addItem(name, "")
- }
- }
- }
- }
-
- GridView {
- id: grid
-
- property int targetTransitionsDone
- property int displaceTransitionsDone
-
- property var targetTrans_items: new Object()
- property var targetTrans_targetIndexes: new Array()
- property var targetTrans_targetItems: new Array()
-
- property var displacedTrans_items: new Object()
- property var displacedTrans_targetIndexes: new Array()
- property var displacedTrans_targetItems: new Array()
-
- objectName: "grid"
- width: 240
- height: 320
- cellWidth: 80
- cellHeight: 60
- anchors.centerIn: parent
- model: testModel
- delegate: myDelegate
-
- // for QDeclarativeListProperty types
- function copyList(propList) {
- var temp = new Array()
- for (var i=0; i<propList.length; i++)
- temp.push(propList[i])
- return temp
- }
-
- remove: Transition {
- id: targetTransition
-
- SequentialAnimation {
- ScriptAction {
- script: {
- grid.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
- grid.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
- grid.targetTrans_targetItems.push(grid.copyList(targetTransition.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; to: targetItems_transitionTo.x; duration: root.duration }
- NumberAnimation { properties: "y"; to: targetItems_transitionTo.y; duration: root.duration }
- }
- ScriptAction { script: grid.targetTransitionsDone += 1 }
-
- // delay deleting this item so that it stays valid for the tests
- // (this doesn't delay the test itself)
- PauseAnimation { duration: 10000 }
- }
- }
-
- removeDisplaced: Transition {
- id: displaced
-
- SequentialAnimation {
- ScriptAction {
- script: {
- grid.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
- grid.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
- grid.displacedTrans_targetItems.push(grid.copyList(displaced.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation {
- properties: "x"; duration: root.duration
- to: displacedItems_transitionVia.x
- }
- NumberAnimation {
- properties: "y"; duration: root.duration
- to: displacedItems_transitionVia.y
- }
- }
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: grid.displaceTransitionsDone += 1 }
- }
-
- }
- }
-
- Rectangle {
- anchors.fill: grid
- color: "lightsteelblue"
- opacity: 0.2
- }
-
- Rectangle {
- anchors.bottom: parent.bottom
- width: 20; height: 20
- color: "white"
- NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 10000 }
- }
-}
-
-
diff --git a/tests/auto/qtquick2/qquickgridview/qquickgridview.pro b/tests/auto/qtquick2/qquickgridview/qquickgridview.pro
deleted file mode 100644
index 583aedae8c..0000000000
--- a/tests/auto/qtquick2/qquickgridview/qquickgridview.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickgridview
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickgridview.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib widgets
diff --git a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp
deleted file mode 100644
index cc76b7b401..0000000000
--- a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp
+++ /dev/null
@@ -1,5075 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtCore/qstringlistmodel.h>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativeincubator.h>
-#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/private/qquickgridview_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qquickvisualitemmodel_p.h>
-#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
-#include <QtDeclarative/private/qlistmodelinterface_p.h>
-#include "../../shared/util.h"
-#include "../shared/viewtestutil.h"
-#include "../shared/visualtestutil.h"
-#include <QtGui/qguiapplication.h>
-
-Q_DECLARE_METATYPE(Qt::LayoutDirection)
-Q_DECLARE_METATYPE(QQuickGridView::Flow)
-
-using namespace QQuickViewTestUtil;
-using namespace QQuickVisualTestUtil;
-
-class tst_QQuickGridView : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickGridView();
-
-private slots:
- void items();
- void changed();
- void inserted();
- void inserted_more();
- void inserted_more_data();
- void insertBeforeVisible();
- void insertBeforeVisible_data();
- void removed();
- void removed_more();
- void removed_more_data();
- void addOrRemoveBeforeVisible();
- void addOrRemoveBeforeVisible_data();
- void clear();
- void moved();
- void moved_data();
- void multipleChanges();
- void multipleChanges_data();
- void swapWithFirstItem();
- void changeFlow();
- void currentIndex();
- void noCurrentIndex();
- void defaultValues();
- void properties();
- void propertyChanges();
- void componentChanges();
- void modelChanges();
- void positionViewAtIndex();
- void positionViewAtIndex_rightToLeft();
- void mirroring();
- void snapping();
- void resetModel();
- void enforceRange();
- void enforceRange_rightToLeft();
- void QTBUG_8456();
- void manualHighlight();
- void footer();
- void footer_data();
- void header();
- void header_data();
- void resizeViewAndRepaint();
- void changeColumnCount();
- void indexAt_itemAt_data();
- void indexAt_itemAt();
- void onAdd();
- void onAdd_data();
- void onRemove();
- void onRemove_data();
- void columnCount();
- void margins();
- void creationContext();
- void snapToRow_data();
- void snapToRow();
- void snapOneRow_data();
- void snapOneRow();
- void unaligned();
- void cacheBuffer();
- void asynchronous();
- void unrequestedVisibility();
-
- void populateTransitions();
- void populateTransitions_data();
- void addTransitions();
- void addTransitions_data();
- void moveTransitions();
- void moveTransitions_data();
- void removeTransitions();
- void removeTransitions_data();
- void multipleTransitions();
- void multipleTransitions_data();
-
-private:
- QList<int> toIntList(const QVariantList &list);
- void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes);
- void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes);
- void matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems);
-};
-
-tst_QQuickGridView::tst_QQuickGridView()
-{
-}
-
-void tst_QQuickGridView::items()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Billy", "22345");
- model.addItem("Sam", "2945");
- model.addItem("Ben", "04321");
- model.addItem("Jim", "0780");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(gridview->count(), model.count());
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- for (int i = 0; i < model.count(); ++i) {
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- // set an empty model and confirm that items are destroyed
- QaimModel model2;
- ctxt->setContextProperty("testModel", &model2);
-
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QTRY_VERIFY(itemCount == 0);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::changed()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Billy", "22345");
- model.addItem("Sam", "2945");
- model.addItem("Ben", "04321");
- model.addItem("Jim", "0780");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- qApp->processEvents();
-
- QQuickFlickable *gridview = findItem<QQuickFlickable>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- model.modifyItem(1, "Will", "9876");
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- delete canvas;
-}
-
-void tst_QQuickGridView::inserted()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- model.insertItem(1, "Will", "9876");
-
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- // Checks that onAdd is called
- int added = canvas->rootObject()->property("added").toInt();
- QTRY_COMPARE(added, 1);
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_COMPARE(item->x(), (i%3)*80.0);
- QTRY_COMPARE(item->y(), (i/3)*60.0);
- }
-
- model.insertItem(0, "Foo", "1111"); // zero index, and current item
-
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- name = findItem<QQuickText>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QQuickText>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- QTRY_COMPARE(gridview->currentIndex(), 1);
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- for (int i = model.count(); i < 30; ++i)
- model.insertItem(i, "Hello", QString::number(i));
-
- gridview->setContentY(120);
-
- // Insert item outside visible area
- model.insertItem(1, "Hello", "1324");
-
- QTRY_VERIFY(gridview->contentY() == 120);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::inserted_more()
-{
- QFETCH(qreal, contentY);
- QFETCH(int, insertIndex);
- QFETCH(int, insertCount);
- QFETCH(qreal, itemsOffsetAfterMove);
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- gridview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QList<QPair<QString, QString> > newData;
- for (int i=0; i<insertCount; i++)
- newData << qMakePair(QString("value %1").arg(i), QString::number(i));
- model.insertItems(insertIndex, newData);
- QTRY_COMPARE(gridview->property("count").toInt(), model.count());
-
- // check visibleItems.first() is in correct position
- QQuickItem *item0 = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item0);
- QCOMPARE(item0->y(), 0.0);
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QQuickText *name;
- QQuickText *number;
- for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
-
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
-
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- number = findItem<QQuickText>(contentItem, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::inserted_more_data()
-{
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<int>("insertIndex");
- QTest::addColumn<int>("insertCount");
- QTest::addColumn<qreal>("itemsOffsetAfterMove");
-
- QTest::newRow("add 1, before visible items")
- << 120.0 // show 6-23
- << 5 << 1
- << 0.0; // insert 1 above first visible, grid is rearranged; first visible moves forward within its row
- // new 1st visible item is at 0
-
- QTest::newRow("add 2, before visible items")
- << 120.0 // show 6-23
- << 5 << 2
- << 0.0; // insert 2 above first visible, grid is rearranged; first visible moves forward within its row
-
- QTest::newRow("add 3, before visible items")
- << 120.0 // show 6-23
- << 5 << 3
- << -60.0; // insert 3 (1 row) above first visible in negative pos, first visible does not move
-
- QTest::newRow("add 5, before visible items")
- << 120.0 // show 6-23
- << 5 << 5
- << -60.0; // insert 1 row + 2 items above first visible, 1 row added at negative pos,
- // grid is rearranged and first visible moves forward within its row
-
- QTest::newRow("add 6, before visible items")
- << 120.0 // show 6-23
- << 5 << 6
- << -60.0 * 2; // insert 2 rows above first visible in negative pos, first visible does not move
-
-
-
- QTest::newRow("add 1, at start of visible, content at start")
- << 0.0
- << 0 << 1
- << 0.0;
-
- QTest::newRow("add multiple, at start of visible, content at start")
- << 0.0
- << 0 << 3
- << 0.0;
-
- QTest::newRow("add 1, at start of visible, content not at start")
- << 120.0 // show 6-23
- << 6 << 1
- << 0.0;
-
- QTest::newRow("add multiple, at start of visible, content not at start")
- << 120.0 // show 6-23
- << 6 << 3
- << 0.0;
-
-
- QTest::newRow("add 1, at end of visible, content at start")
- << 0.0
- << 17 << 1
- << 0.0;
-
- QTest::newRow("add 1, at end of visible, content at start")
- << 0.0
- << 17 << 3
- << 0.0;
-
- QTest::newRow("add 1, at end of visible, content not at start")
- << 120.0 // show 6-23
- << 23 << 1
- << 0.0;
-
- QTest::newRow("add multiple, at end of visible, content not at start")
- << 120.0 // show 6-23
- << 23 << 3
- << 0.0;
-
-
- QTest::newRow("add 1, after visible, content at start")
- << 0.0
- << 20 << 1
- << 0.0;
-
- QTest::newRow("add 1, after visible, content at start")
- << 0.0
- << 20 << 3
- << 0.0;
-
- QTest::newRow("add 1, after visible, content not at start")
- << 120.0 // show 6-23
- << 24 << 1
- << 0.0;
-
- QTest::newRow("add multiple, after visible, content not at start")
- << 120.0 // show 6-23
- << 24 << 3
- << 0.0;
-}
-
-void tst_QQuickGridView::insertBeforeVisible()
-{
- QFETCH(int, insertIndex);
- QFETCH(int, insertCount);
- QFETCH(int, cacheBuffer);
-
- QQuickText *name;
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- gridview->setCacheBuffer(cacheBuffer);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- // trigger a refill (not just setting contentY) so that the visibleItems grid is updated
- int firstVisibleIndex = 12; // move to an index where the top item is not visible
- gridview->setContentY(firstVisibleIndex/3 * 60.0);
- gridview->setCurrentIndex(firstVisibleIndex);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QTRY_COMPARE(gridview->currentIndex(), firstVisibleIndex);
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", firstVisibleIndex);
- QVERIFY(item);
- QCOMPARE(item->y(), gridview->contentY());
-
- QList<QPair<QString, QString> > newData;
- for (int i=0; i<insertCount; i++)
- newData << qMakePair(QString("value %1").arg(i), QString::number(i));
- model.insertItems(insertIndex, newData);
- QTRY_COMPARE(gridview->property("count").toInt(), model.count());
-
- // now, moving to the top of the view should position the inserted items correctly
- int itemsOffsetAfterMove = (insertCount / 3) * -60.0;
- gridview->setCurrentIndex(0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- QTRY_COMPARE(gridview->currentIndex(), 0);
- QTRY_COMPARE(gridview->contentY(), 0.0 + itemsOffsetAfterMove);
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::insertBeforeVisible_data()
-{
- QTest::addColumn<int>("insertIndex");
- QTest::addColumn<int>("insertCount");
- QTest::addColumn<int>("cacheBuffer");
-
- QTest::newRow("insert 1 at 0, 0 buffer") << 0 << 1 << 0;
- QTest::newRow("insert 1 at 0, 100 buffer") << 0 << 1 << 100;
- QTest::newRow("insert 1 at 0, 500 buffer") << 0 << 1 << 500;
-
- QTest::newRow("insert 1 at 1, 0 buffer") << 1 << 1 << 0;
- QTest::newRow("insert 1 at 1, 100 buffer") << 1 << 1 << 100;
- QTest::newRow("insert 1 at 1, 500 buffer") << 1 << 1 << 500;
-
- QTest::newRow("insert multiple at 0, 0 buffer") << 0 << 6 << 0;
- QTest::newRow("insert multiple at 0, 100 buffer") << 0 << 6 << 100;
- QTest::newRow("insert multiple at 0, 500 buffer") << 0 << 6 << 500;
-
- QTest::newRow("insert multiple at 1, 0 buffer") << 1 << 6 << 0;
- QTest::newRow("insert multiple at 1, 100 buffer") << 1 << 6 << 100;
- QTest::newRow("insert multiple at 1, 500 buffer") << 1 << 6 << 500;
-}
-
-void tst_QQuickGridView::removed()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- model.removeItem(1);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
-
- // Checks that onRemove is called
- QString removed = canvas->rootObject()->property("removed").toString();
- QTRY_COMPARE(removed, QString("Item1"));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- // Remove first item (which is the current item);
- model.removeItem(0);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- name = findItem<QQuickText>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QQuickText>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- // Remove items not visible
- model.removeItem(25);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- // Remove items before visible
- gridview->setContentY(120);
- gridview->setCurrentIndex(10);
-
- // Setting currentIndex above shouldn't cause view to scroll
- QTRY_COMPARE(gridview->contentY(), 120.0);
-
- model.removeItem(1);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- // Confirm items positioned correctly
- for (int i = 6; i < 18; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- // Remove currentIndex
- QQuickItem *oldCurrent = gridview->currentItem();
- model.removeItem(9);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- QTRY_COMPARE(gridview->currentIndex(), 9);
- QTRY_VERIFY(gridview->currentItem() != oldCurrent);
-
- gridview->setContentY(0);
- // let transitions settle.
- QTest::qWait(300);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60);
- }
-
- // remove item outside current view.
- gridview->setCurrentIndex(32);
- gridview->setContentY(240);
-
- model.removeItem(30);
- QTRY_VERIFY(gridview->currentIndex() == 31);
-
- // remove current item beyond visible items.
- gridview->setCurrentIndex(20);
- gridview->setContentY(0);
- model.removeItem(20);
-
- QTRY_COMPARE(gridview->currentIndex(), 20);
- QTRY_VERIFY(gridview->currentItem() != 0);
-
- // remove item before current, but visible
- gridview->setCurrentIndex(8);
- gridview->setContentY(240);
- oldCurrent = gridview->currentItem();
- model.removeItem(6);
-
- QTRY_COMPARE(gridview->currentIndex(), 7);
- QTRY_VERIFY(gridview->currentItem() == oldCurrent);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::removed_more()
-{
- QFETCH(qreal, contentY);
- QFETCH(int, removeIndex);
- QFETCH(int, removeCount);
- QFETCH(qreal, itemsOffsetAfterMove);
- QFETCH(QString, firstVisible);
-
- QQuickText *name;
- QQuickText *number;
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- gridview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- model.removeItems(removeIndex, removeCount);
- QTRY_COMPARE(gridview->property("count").toInt(), model.count());
-
- QString firstName;
- int firstVisibleIndex = -1;
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- QDeclarativeExpression en(qmlContext(items[i]), items[i], "name");
- firstName = en.evaluate().toString();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
- QCOMPARE(firstName, firstVisible);
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
-
- QTRY_COMPARE(item->x(), (i%3)*80.0);
- QTRY_COMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
-
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QQuickText>(contentItem, "textNumber", i);
- QVERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::removed_more_data()
-{
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<int>("removeIndex");
- QTest::addColumn<int>("removeCount");
- QTest::addColumn<qreal>("itemsOffsetAfterMove");
- QTest::addColumn<QString>("firstVisible");
-
- QTest::newRow("remove 1, before visible items")
- << 120.0 // show 6-23
- << 2 << 1
- << 0.0 << "Item7";
-
- QTest::newRow("remove 1, before visible position")
- << 120.0 // show 6-23
- << 3 << 1
- << 0.0 << "Item7";
-
- QTest::newRow("remove multiple, all before visible items")
- << 120.0
- << 1 << 3
- << 60.0 << "Item6"; // removed top row, slide down by 1 row
-
- QTest::newRow("remove multiple, all before visible items, remove item 0")
- << 120.0
- << 0 << 4
- << 60.0 << "Item7"; // removed top row, slide down by 1 row
-
- QTest::newRow("remove multiple rows, all before visible items")
- << 240.0 // show 12-29
- << 1 << 7
- << 120.0 << "Item13";
-
- QTest::newRow("remove one row before visible, content y not on item border")
- << 100.0
- << 0 << 3
- << 60.0 << "Item6"; // 1 row removed
-
- QTest::newRow("remove mix of visible/non-visible")
- << 120.0 // show 6-23
- << 2 << 3
- << 60.0 << "Item6"; // 1 row removed
-
-
- // remove 3,4,5 before the visible pos, first row moves down to just before the visible pos,
- // items 6,7 are removed from view, item 8 slides up to original pos of item 6 (120px)
- QTest::newRow("remove multiple, mix of items from before and within visible items")
- << 120.0
- << 3 << 5
- << 60.0 << "Item8"; // adjust for the 1 row removed before the visible
-
- QTest::newRow("remove multiple, mix of items from before and within visible items, remove item 0")
- << 120.0
- << 0 << 8
- << 60.0 * 2 << "Item8"; // adjust for the 2 rows removed before the visible
-
-
- QTest::newRow("remove 1, from start of visible, content at start")
- << 0.0
- << 0 << 1
- << 0.0 << "Item1";
-
- QTest::newRow("remove multiple, from start of visible, content at start")
- << 0.0
- << 0 << 3
- << 0.0 << "Item3";
-
- QTest::newRow("remove 1, from start of visible, content not at start")
- << 120.0 // show 6-23
- << 4 << 1
- << 0.0 << "Item7";
-
- QTest::newRow("remove multiple, from start of visible, content not at start")
- << 120.0 // show 6-23
- << 4 << 3
- << 0.0 << "Item9";
-
-
- QTest::newRow("remove 1, from middle of visible, content at start")
- << 0.0
- << 10 << 1
- << 0.0 << "Item0";
-
- QTest::newRow("remove multiple, from middle of visible, content at start")
- << 0.0
- << 10 << 5
- << 0.0 << "Item0";
-
- QTest::newRow("remove 1, from middle of visible, content not at start")
- << 120.0 // show 6-23
- << 10 << 1
- << 0.0 << "Item6";
-
- QTest::newRow("remove multiple, from middle of visible, content not at start")
- << 120.0 // show 6-23
- << 10 << 5
- << 0.0 << "Item6";
-
-
- QTest::newRow("remove 1, after visible, content at start")
- << 0.0
- << 16 << 1
- << 0.0 << "Item0";
-
- QTest::newRow("remove multiple, after visible, content at start")
- << 0.0
- << 16 << 5
- << 0.0 << "Item0";
-
- QTest::newRow("remove 1, after visible, content not at start")
- << 120.0 // show 6-23
- << 16+4 << 1
- << 0.0 << "Item6";
-
- QTest::newRow("remove multiple, after visible, content not at start")
- << 120.0 // show 6-23
- << 16+4 << 5
- << 0.0 << "Item6";
-
- QTest::newRow("remove multiple, mix of items from within and after visible items")
- << 120.0 // show 6-23
- << 20 << 5
- << 0.0 << "Item6";
-}
-
-void tst_QQuickGridView::addOrRemoveBeforeVisible()
-{
- // QTBUG-21588: ensure re-layout is done on grid after adding or removing
- // items from before the visible area
-
- QFETCH(bool, doAdd);
- QFETCH(qreal, newTopContentY);
-
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(testFileUrl("gridview1.qml"));
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 0);
- QTRY_COMPARE(name->text(), QString("Item0"));
-
- gridview->setCurrentIndex(0);
- qApp->processEvents();
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- // scroll down until item 0 is no longer drawn
- // (bug not triggered if we just move using content y, since that doesn't
- // refill and change the visible items)
- gridview->setCurrentIndex(24);
- qApp->processEvents();
-
- QTRY_COMPARE(gridview->currentIndex(), 24);
- QTRY_COMPARE(gridview->contentY(), 220.0);
-
- QTest::qWait(100); // wait for refill to complete
- QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 0)); // 0 shouldn't be visible
-
- if (doAdd) {
- model.insertItem(0, "New Item", "New Item number");
- QTRY_COMPARE(gridview->count(), 31);
- } else {
- model.removeItem(0);
- QTRY_COMPARE(gridview->count(), 29);
- }
-
- // scroll back up and item 0 should be gone
- gridview->setCurrentIndex(0);
- qApp->processEvents();
- QTRY_COMPARE(gridview->currentIndex(), 0);
- QTRY_COMPARE(gridview->contentY(), newTopContentY);
-
- name = findItem<QQuickText>(contentItem, "textName", 0);
- if (doAdd)
- QCOMPARE(name->text(), QString("New Item"));
- else
- QCOMPARE(name->text(), QString("Item1"));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QTRY_VERIFY(findItem<QQuickItem>(contentItem, "wrapper", i));
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item->x() == (i%3)*80);
- QTRY_VERIFY(item->y() == (i/3)*60 + newTopContentY);
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::addOrRemoveBeforeVisible_data()
-{
- QTest::addColumn<bool>("doAdd");
- QTest::addColumn<qreal>("newTopContentY");
-
- QTest::newRow("add") << true << -60.0;
- QTest::newRow("remove") << false << -60.0;
-}
-
-void tst_QQuickGridView::clear()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- model.clear();
-
- QVERIFY(gridview->count() == 0);
- QVERIFY(gridview->currentItem() == 0);
- QVERIFY(gridview->contentY() == 0);
- QVERIFY(gridview->currentIndex() == -1);
-
- // confirm sanity when adding an item to cleared list
- model.addItem("New", "1");
- QTRY_COMPARE(gridview->count(), 1);
- QVERIFY(gridview->currentItem() != 0);
- QVERIFY(gridview->currentIndex() == 0);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::moved()
-{
- QFETCH(qreal, contentY);
- QFETCH(int, from);
- QFETCH(int, to);
- QFETCH(int, count);
- QFETCH(qreal, itemsOffsetAfterMove);
-
- QQuickText *name;
- QQuickText *number;
- QScopedPointer<QQuickView> canvas(createView());
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QQuickItem *currentItem = gridview->currentItem();
- QTRY_VERIFY(currentItem != 0);
-
- if (contentY != 0) {
- gridview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- }
-
- model.moveItems(from, to, count);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- // Confirm items positioned correctly and indexes correct
- int firstVisibleIndex = qCeil(contentY / 60.0) * 3;
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- if (i >= firstVisibleIndex + 18) // index has moved out of view
- continue;
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
-
- QTRY_COMPARE(item->x(), (i%3)*80.0);
- QTRY_COMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
-
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QQuickText>(contentItem, "textNumber", i);
- QVERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
-
- // current index should have been updated
- if (item == currentItem)
- QTRY_COMPARE(gridview->currentIndex(), i);
- }
-}
-
-void tst_QQuickGridView::moved_data()
-{
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<int>("from");
- QTest::addColumn<int>("to");
- QTest::addColumn<int>("count");
- QTest::addColumn<qreal>("itemsOffsetAfterMove");
-
- // model starts with 30 items, each 80x60, in area 240x320
- // 18 items should be visible at a time
-
- // The first visible item should not move upwards and out of the view
- // if items are moved/removed before it.
-
-
- QTest::newRow("move 1 forwards, within visible items")
- << 0.0
- << 1 << 8 << 1
- << 0.0;
-
- QTest::newRow("move 1 forwards, from non-visible -> visible")
- << 120.0 // show 6-23
- << 1 << 23 << 1
- << 0.0;
-
- QTest::newRow("move 1 forwards, from non-visible -> visible (move first item)")
- << 120.0 // // show 6-23
- << 0 << 6 << 1
- << 0.0;
-
- QTest::newRow("move 1 forwards, from visible -> non-visible")
- << 0.0
- << 1 << 20 << 1
- << 0.0;
-
- QTest::newRow("move 1 forwards, from visible -> non-visible (move first item)")
- << 0.0
- << 0 << 20 << 1
- << 0.0;
-
-
- QTest::newRow("move 1 backwards, within visible items")
- << 0.0
- << 10 << 5 << 1
- << 0.0;
-
- QTest::newRow("move 1 backwards, within visible items (to first index)")
- << 0.0
- << 10 << 0 << 1
- << 0.0;
-
- QTest::newRow("move 1 backwards, from non-visible -> visible")
- << 0.0
- << 28 << 8 << 1
- << 0.0;
-
- QTest::newRow("move 1 backwards, from non-visible -> visible (move last item)")
- << 0.0
- << 29 << 14 << 1
- << 0.0;
-
- QTest::newRow("move 1 backwards, from visible -> non-visible")
- << 120.0 // show 6-23
- << 7 << 1 << 1
- << 0.0; // only 1 item moved back, so items shift accordingly and first row doesn't move
-
- QTest::newRow("move 1 backwards, from visible -> non-visible (move first item)")
- << 120.0 // show 6-23
- << 7 << 0 << 1
- << 0.0; // only 1 item moved back, so items shift accordingly and first row doesn't move
-
-
- QTest::newRow("move multiple forwards, within visible items")
- << 0.0
- << 0 << 5 << 3
- << 0.0;
-
- QTest::newRow("move multiple backwards, within visible items (move first item)")
- << 0.0
- << 10 << 0 << 3
- << 0.0;
-
- QTest::newRow("move multiple forwards, before visible items")
- << 120.0 // show 6-23
- << 3 << 4 << 3 // 3, 4, 5 move to after 6
- << 60.0; // row of 3,4,5 has moved down
-
- QTest::newRow("move multiple forwards, from non-visible -> visible")
- << 120.0 // show 6-23
- << 1 << 6 << 3
- << 60.0; // 1st row (it's above visible area) disappears, 0 drops down 1 row, first visible item (6) stays where it is
-
- QTest::newRow("move multiple forwards, from non-visible -> visible (move first item)")
- << 120.0 // show 6-23
- << 0 << 6 << 3
- << 60.0; // top row moved and shifted to below 3rd row, all items should shift down by 1 row
-
- QTest::newRow("move multiple forwards, mix of non-visible/visible")
- << 120.0
- << 3 << 16 << 6
- << 60.0; // top two rows removed, third row is now the first visible
-
- QTest::newRow("move multiple forwards, to bottom of view")
- << 0.0
- << 5 << 13 << 5
- << 0.0;
-
- QTest::newRow("move multiple forwards, to bottom of view, first row -> last")
- << 0.0
- << 0 << 15 << 3
- << 0.0;
-
- QTest::newRow("move multiple forwards, to bottom of view, content y not 0")
- << 120.0
- << 5+4 << 13+4 << 5
- << 0.0;
-
- QTest::newRow("move multiple forwards, from visible -> non-visible")
- << 0.0
- << 1 << 16 << 3
- << 0.0;
-
- QTest::newRow("move multiple forwards, from visible -> non-visible (move first item)")
- << 0.0
- << 0 << 16 << 3
- << 0.0;
-
-
- QTest::newRow("move multiple backwards, within visible items")
- << 0.0
- << 4 << 1 << 3
- << 0.0;
-
- QTest::newRow("move multiple backwards, from non-visible -> visible")
- << 0.0
- << 20 << 4 << 3
- << 0.0;
-
- QTest::newRow("move multiple backwards, from non-visible -> visible (move last item)")
- << 0.0
- << 27 << 10 << 3
- << 0.0;
-
- QTest::newRow("move multiple backwards, from visible -> non-visible")
- << 120.0 // show 6-23
- << 16 << 1 << 3
- << -60.0; // to minimize movement, items are added above visible area, all items move up by 1 row
-
- QTest::newRow("move multiple backwards, from visible -> non-visible (move first item)")
- << 120.0 // show 6-23
- << 16 << 0 << 3
- << -60.0; // 16,17,18 move to above item 0, all items move up by 1 row
-}
-
-void tst_QQuickGridView::multipleChanges()
-{
- QFETCH(int, startCount);
- QFETCH(QList<ListChange>, changes);
- QFETCH(int, newCount);
- QFETCH(int, newCurrentIndex);
-
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < startCount; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- for (int i=0; i<changes.count(); i++) {
- switch (changes[i].type) {
- case ListChange::Inserted:
- {
- QList<QPair<QString, QString> > items;
- for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
- items << qMakePair(QString("new item " + j), QString::number(j));
- model.insertItems(changes[i].index, items);
- break;
- }
- case ListChange::Removed:
- model.removeItems(changes[i].index, changes[i].count);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- break;
- case ListChange::Moved:
- model.moveItems(changes[i].index, changes[i].to, changes[i].count);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- break;
- case ListChange::SetCurrent:
- gridview->setCurrentIndex(changes[i].index);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- break;
- case ListChange::SetContentY:
- gridview->setContentY(changes[i].pos);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- break;
- }
- }
-
- QTRY_COMPARE(gridview->count(), newCount);
- QCOMPARE(gridview->count(), model.count());
- QTRY_COMPARE(gridview->currentIndex(), newCurrentIndex);
-
- QQuickText *name;
- QQuickText *number;
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i=0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QQuickText>(contentItem, "textNumber", i);
- QVERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::multipleChanges_data()
-{
- QTest::addColumn<int>("startCount");
- QTest::addColumn<QList<ListChange> >("changes");
- QTest::addColumn<int>("newCount");
- QTest::addColumn<int>("newCurrentIndex");
-
- QList<ListChange> changes;
-
- for (int i=1; i<30; i++)
- changes << ListChange::remove(0);
- QTest::newRow("remove all but 1, first->last") << 30 << changes << 1 << 0;
-
- changes << ListChange::remove(0);
- QTest::newRow("remove all") << 30 << changes << 0 << -1;
-
- changes.clear();
- changes << ListChange::setCurrent(29);
- for (int i=29; i>0; i--)
- changes << ListChange::remove(i);
- QTest::newRow("remove last (current) -> first") << 30 << changes << 1 << 0;
-
- QTest::newRow("remove then insert at 0") << 10 << (QList<ListChange>()
- << ListChange::remove(0, 1)
- << ListChange::insert(0, 1)
- ) << 10 << 1;
-
- QTest::newRow("remove then insert at non-zero index") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(2)
- << ListChange::remove(2, 1)
- << ListChange::insert(2, 1)
- ) << 10 << 3;
-
- QTest::newRow("remove current then insert below it") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(1)
- << ListChange::remove(1, 3)
- << ListChange::insert(2, 2)
- ) << 9 << 1;
-
- QTest::newRow("remove current index then move it down") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(2)
- << ListChange::remove(1, 3)
- << ListChange::move(1, 5, 1)
- ) << 7 << 5;
-
- QTest::newRow("remove current index then move it up") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(5)
- << ListChange::remove(4, 3)
- << ListChange::move(4, 1, 1)
- ) << 7 << 1;
-
-
- QTest::newRow("insert multiple times") << 0 << (QList<ListChange>()
- << ListChange::insert(0, 2)
- << ListChange::insert(0, 4)
- << ListChange::insert(0, 6)
- ) << 12 << 10;
-
- QTest::newRow("insert multiple times with current index changes") << 0 << (QList<ListChange>()
- << ListChange::insert(0, 2)
- << ListChange::insert(0, 4)
- << ListChange::insert(0, 6)
- << ListChange::setCurrent(3)
- << ListChange::insert(3, 2)
- ) << 14 << 5;
-
- QTest::newRow("insert and remove all") << 0 << (QList<ListChange>()
- << ListChange::insert(0, 30)
- << ListChange::remove(0, 30)
- ) << 0 << -1;
-
- QTest::newRow("insert and remove current") << 30 << (QList<ListChange>()
- << ListChange::insert(1)
- << ListChange::setCurrent(1)
- << ListChange::remove(1)
- ) << 30 << 1;
-
- QTest::newRow("insert before 0, then remove cross section of new and old items") << 10 << (QList<ListChange>()
- << ListChange::insert(0, 10)
- << ListChange::remove(5, 10)
- ) << 10 << 5;
-
- QTest::newRow("insert multiple, then move new items to end") << 10 << (QList<ListChange>()
- << ListChange::insert(0, 3)
- << ListChange::move(0, 10, 3)
- ) << 13 << 0;
-
- QTest::newRow("insert multiple, then move new and some old items to end") << 10 << (QList<ListChange>()
- << ListChange::insert(0, 3)
- << ListChange::move(0, 8, 5)
- ) << 13 << 11;
-
- QTest::newRow("insert multiple at end, then move new and some old items to start") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(9)
- << ListChange::insert(10, 3)
- << ListChange::move(8, 0, 5)
- ) << 13 << 1;
-
-
- QTest::newRow("move back and forth to same index") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(1)
- << ListChange::move(1, 2, 2)
- << ListChange::move(2, 1, 2)
- ) << 10 << 1;
-
- QTest::newRow("move forwards then back") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(2)
- << ListChange::move(1, 2, 3)
- << ListChange::move(3, 0, 5)
- ) << 10 << 0;
-
- QTest::newRow("move current, then remove it") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(5)
- << ListChange::move(5, 0, 1)
- << ListChange::remove(0)
- ) << 9 << 0;
-
- QTest::newRow("move current, then insert before it") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(5)
- << ListChange::move(5, 0, 1)
- << ListChange::insert(0)
- ) << 11 << 1;
-
- QTest::newRow("move multiple, then remove them") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(1)
- << ListChange::move(5, 1, 3)
- << ListChange::remove(1, 3)
- ) << 7 << 1;
-
- QTest::newRow("move multiple, then insert before them") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(5)
- << ListChange::move(5, 1, 3)
- << ListChange::insert(1, 5)
- ) << 15 << 6;
-
- QTest::newRow("move multiple, then insert after them") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(3)
- << ListChange::move(0, 1, 2)
- << ListChange::insert(3, 5)
- ) << 15 << 8;
-
-
- QTest::newRow("clear current") << 0 << (QList<ListChange>()
- << ListChange::insert(0, 5)
- << ListChange::setCurrent(-1)
- << ListChange::remove(0, 5)
- << ListChange::insert(0, 5)
- ) << 5 << -1;
-}
-
-
-void tst_QQuickGridView::swapWithFirstItem()
-{
- // QTBUG_9697
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- // ensure content position is stable
- gridview->setContentY(0);
- model.moveItem(10, 0);
- QTRY_VERIFY(gridview->contentY() == 0);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::currentIndex()
-{
- QaimModel model;
- for (int i = 0; i < 60; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
- canvas->show();
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- QString filename(testFile("gridview-initCurrent.qml"));
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
- QTRY_VERIFY(!QQuickItemPrivate::get(gridview)->polishScheduled);
-
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
-
- // current item should be third item
- QCOMPARE(gridview->currentIndex(), 35);
- QCOMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 35));
- QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
- QCOMPARE(gridview->contentY(), 400.0);
-
- gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), 36);
- gridview->moveCurrentIndexDown();
- QCOMPARE(gridview->currentIndex(), 39);
- gridview->moveCurrentIndexUp();
- QCOMPARE(gridview->currentIndex(), 36);
- gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), 35);
-
- // wait until motion stops
- QTRY_VERIFY(gridview->verticalVelocity() == 0.0);
-
- // 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);
-
- gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->setCurrentIndex(model.count()-1);
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- gridview->moveCurrentIndexDown();
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- // with wrap
- gridview->setWrapEnabled(true);
-
- gridview->setCurrentIndex(0);
- QCOMPARE(gridview->currentIndex(), 0);
-
- gridview->moveCurrentIndexLeft();
- QCOMPARE(gridview->currentIndex(), model.count()-1);
-
- qApp->processEvents();
- QTRY_COMPARE(gridview->contentY(), 880.0);
-
- gridview->moveCurrentIndexRight();
- QCOMPARE(gridview->currentIndex(), 0);
-
- QTRY_COMPARE(gridview->contentY(), 0.0);
-
-
- // footer should become visible if it is out of view, and then current index moves to the first row
- canvas->rootObject()->setProperty("showFooter", true);
- QTRY_VERIFY(gridview->footerItem());
- gridview->setCurrentIndex(model.count()-3);
- QTRY_VERIFY(gridview->footerItem()->y() > gridview->contentY() + gridview->height());
- gridview->setCurrentIndex(model.count()-2);
- QTRY_COMPARE(gridview->contentY() + gridview->height(), (60.0 * model.count()/3) + gridview->footerItem()->height());
- canvas->rootObject()->setProperty("showFooter", false);
-
- // header should become visible if it is out of view, and then current index moves to the last row
- canvas->rootObject()->setProperty("showHeader", true);
- QTRY_VERIFY(gridview->headerItem());
- gridview->setCurrentIndex(3);
- QTRY_VERIFY(gridview->headerItem()->y() + gridview->headerItem()->height() < gridview->contentY());
- gridview->setCurrentIndex(1);
- QTRY_COMPARE(gridview->contentY(), -gridview->headerItem()->height());
- canvas->rootObject()->setProperty("showHeader", false);
-
-
- // Test keys
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(qGuiApp->focusWindow() == canvas);
-
- gridview->setCurrentIndex(0);
-
- QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(gridview->currentIndex(), 3);
-
- QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(gridview->currentIndex(), 0);
-
- // hold down Key_Down
- for (int i=0; i<(model.count() / 3) - 1; i++) {
- QTest::simulateEvent(canvas, true, Qt::Key_Down, Qt::NoModifier, "", true);
- QTRY_COMPARE(gridview->currentIndex(), i*3 + 3);
- }
- QTest::keyRelease(canvas, Qt::Key_Down);
- QTRY_COMPARE(gridview->currentIndex(), 57);
- QTRY_COMPARE(gridview->contentY(), 880.0);
-
- // hold down Key_Up
- for (int i=(model.count() / 3) - 1; i > 0; i--) {
- QTest::simulateEvent(canvas, true, Qt::Key_Up, Qt::NoModifier, "", true);
- QTRY_COMPARE(gridview->currentIndex(), i*3 - 3);
- }
- QTest::keyRelease(canvas, Qt::Key_Up);
- QTRY_COMPARE(gridview->currentIndex(), 0);
- QTRY_COMPARE(gridview->contentY(), 0.0);
-
-
- gridview->setFlow(QQuickGridView::TopToBottom);
-
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QVERIFY(qGuiApp->focusWindow() == canvas);
- qApp->processEvents();
-
- QTest::keyClick(canvas, Qt::Key_Right);
- QCOMPARE(gridview->currentIndex(), 5);
-
- QTest::keyClick(canvas, Qt::Key_Left);
- QCOMPARE(gridview->currentIndex(), 0);
-
- QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(gridview->currentIndex(), 1);
-
- QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(gridview->currentIndex(), 0);
-
- // hold down Key_Right
- for (int i=0; i<(model.count() / 5) - 1; i++) {
- QTest::simulateEvent(canvas, true, Qt::Key_Right, Qt::NoModifier, "", true);
- QTRY_COMPARE(gridview->currentIndex(), i*5 + 5);
- }
-
- QTest::keyRelease(canvas, Qt::Key_Right);
- QTRY_COMPARE(gridview->currentIndex(), 55);
- QTRY_COMPARE(gridview->contentX(), 720.0);
-
- // hold down Key_Left
- for (int i=(model.count() / 5) - 1; i > 0; i--) {
- QTest::simulateEvent(canvas, true, Qt::Key_Left, Qt::NoModifier, "", true);
- QTRY_COMPARE(gridview->currentIndex(), i*5 - 5);
- }
- QTest::keyRelease(canvas, Qt::Key_Left);
- QTRY_COMPARE(gridview->currentIndex(), 0);
- QTRY_COMPARE(gridview->contentX(), 0.0);
-
-
- // turn off auto highlight
- gridview->setHighlightFollowsCurrentItem(false);
- QVERIFY(gridview->highlightFollowsCurrentItem() == false);
- QVERIFY(gridview->highlightItem());
- qreal hlPosX = gridview->highlightItem()->x();
- qreal hlPosY = gridview->highlightItem()->y();
-
- gridview->setCurrentIndex(5);
- QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX);
- QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY);
-
- // insert item before currentIndex
- gridview->setCurrentIndex(28);
- model.insertItem(0, "Foo", "1111");
- QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
-
- // check removing highlight by setting currentIndex to -1;
- gridview->setCurrentIndex(-1);
-
- QCOMPARE(gridview->currentIndex(), -1);
- QVERIFY(!gridview->highlightItem());
- QVERIFY(!gridview->currentItem());
-
- gridview->setHighlightFollowsCurrentItem(true);
-
- gridview->setFlow(QQuickGridView::LeftToRight);
- gridview->setLayoutDirection(Qt::RightToLeft);
-
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(qGuiApp->focusWindow() == canvas);
- qApp->processEvents();
-
- gridview->setCurrentIndex(35);
-
- QTest::keyClick(canvas, Qt::Key_Right);
- QCOMPARE(gridview->currentIndex(), 34);
-
- QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(gridview->currentIndex(), 37);
-
- QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(gridview->currentIndex(), 34);
-
- QTest::keyClick(canvas, Qt::Key_Left);
- QCOMPARE(gridview->currentIndex(), 35);
-
-
- // turn off auto highlight
- gridview->setHighlightFollowsCurrentItem(false);
- QVERIFY(gridview->highlightFollowsCurrentItem() == false);
- QVERIFY(gridview->highlightItem());
- hlPosX = gridview->highlightItem()->x();
- hlPosY = gridview->highlightItem()->y();
-
- gridview->setCurrentIndex(5);
- QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX);
- QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY);
-
- // insert item before currentIndex
- gridview->setCurrentIndex(28);
- model.insertItem(0, "Foo", "1111");
- QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
-
- // check removing highlight by setting currentIndex to -1;
- gridview->setCurrentIndex(-1);
-
- QCOMPARE(gridview->currentIndex(), -1);
- QVERIFY(!gridview->highlightItem());
- QVERIFY(!gridview->currentItem());
-
- delete canvas;
-}
-
-void tst_QQuickGridView::noCurrentIndex()
-{
- QaimModel model;
- for (int i = 0; i < 60; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- QString filename(testFile("gridview-noCurrent.qml"));
- canvas->setSource(QUrl::fromLocalFile(filename));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- // current index should be -1
- QCOMPARE(gridview->currentIndex(), -1);
- QVERIFY(!gridview->currentItem());
- QVERIFY(!gridview->highlightItem());
- QCOMPARE(gridview->contentY(), 0.0);
-
- gridview->setCurrentIndex(5);
- QCOMPARE(gridview->currentIndex(), 5);
- QVERIFY(gridview->currentItem());
- QVERIFY(gridview->highlightItem());
-
- delete canvas;
-}
-
-void tst_QQuickGridView::changeFlow()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal((i%3)*80));
- QTRY_COMPARE(item->y(), qreal((i/3)*60));
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- ctxt->setContextProperty("testTopToBottom", QVariant(true));
-
- // Confirm items positioned correctly and indexes correct
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal((i/5)*80));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- ctxt->setContextProperty("testRightToLeft", QVariant(true));
-
- // Confirm items positioned correctly and indexes correct
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80 - item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
- gridview->setContentX(100);
- QTRY_COMPARE(gridview->contentX(), 100.);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
- QTRY_COMPARE(gridview->contentX(), 0.);
-
- // Confirm items positioned correctly and indexes correct
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(240 - (i%3+1)*80));
- QTRY_COMPARE(item->y(), qreal((i/3)*60));
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::defaultValues()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("gridview3.qml"));
- QQuickGridView *obj = qobject_cast<QQuickGridView*>(c.create());
-
- QTRY_VERIFY(obj != 0);
- QTRY_VERIFY(obj->model() == QVariant());
- QTRY_VERIFY(obj->delegate() == 0);
- QTRY_COMPARE(obj->currentIndex(), -1);
- QTRY_VERIFY(obj->currentItem() == 0);
- QTRY_COMPARE(obj->count(), 0);
- QTRY_VERIFY(obj->highlight() == 0);
- QTRY_VERIFY(obj->highlightItem() == 0);
- QTRY_COMPARE(obj->highlightFollowsCurrentItem(), true);
- QTRY_VERIFY(obj->flow() == 0);
- QTRY_COMPARE(obj->isWrapEnabled(), false);
- QTRY_COMPARE(obj->cacheBuffer(), 0);
- QTRY_COMPARE(obj->cellWidth(), qreal(100)); //### Should 100 be the default?
- QTRY_COMPARE(obj->cellHeight(), qreal(100));
- delete obj;
-}
-
-void tst_QQuickGridView::properties()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("gridview2.qml"));
- QQuickGridView *obj = qobject_cast<QQuickGridView*>(c.create());
-
- QTRY_VERIFY(obj != 0);
- QTRY_VERIFY(obj->model() != QVariant());
- QTRY_VERIFY(obj->delegate() != 0);
- QTRY_COMPARE(obj->currentIndex(), 0);
- QTRY_VERIFY(obj->currentItem() != 0);
- QTRY_COMPARE(obj->count(), 4);
- QTRY_VERIFY(obj->highlight() != 0);
- QTRY_VERIFY(obj->highlightItem() != 0);
- QTRY_COMPARE(obj->highlightFollowsCurrentItem(), false);
- QTRY_VERIFY(obj->flow() == 0);
- QTRY_COMPARE(obj->isWrapEnabled(), true);
- QTRY_COMPARE(obj->cacheBuffer(), 200);
- QTRY_COMPARE(obj->cellWidth(), qreal(100));
- QTRY_COMPARE(obj->cellHeight(), qreal(100));
- delete obj;
-}
-
-void tst_QQuickGridView::propertyChanges()
-{
- QQuickView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(testFileUrl("propertychangestest.qml"));
-
- QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView");
- QTRY_VERIFY(gridView);
-
- QSignalSpy keyNavigationWrapsSpy(gridView, SIGNAL(keyNavigationWrapsChanged()));
- QSignalSpy cacheBufferSpy(gridView, SIGNAL(cacheBufferChanged()));
- QSignalSpy layoutSpy(gridView, SIGNAL(layoutDirectionChanged()));
- QSignalSpy flowSpy(gridView, SIGNAL(flowChanged()));
-
- QTRY_COMPARE(gridView->isWrapEnabled(), true);
- QTRY_COMPARE(gridView->cacheBuffer(), 10);
- QTRY_COMPARE(gridView->flow(), QQuickGridView::LeftToRight);
-
- gridView->setWrapEnabled(false);
- gridView->setCacheBuffer(3);
- gridView->setFlow(QQuickGridView::TopToBottom);
-
- QTRY_COMPARE(gridView->isWrapEnabled(), false);
- QTRY_COMPARE(gridView->cacheBuffer(), 3);
- QTRY_COMPARE(gridView->flow(), QQuickGridView::TopToBottom);
-
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
- QTRY_COMPARE(cacheBufferSpy.count(),1);
- QTRY_COMPARE(flowSpy.count(),1);
-
- gridView->setWrapEnabled(false);
- gridView->setCacheBuffer(3);
- gridView->setFlow(QQuickGridView::TopToBottom);
-
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
- QTRY_COMPARE(cacheBufferSpy.count(),1);
- QTRY_COMPARE(flowSpy.count(),1);
-
- gridView->setFlow(QQuickGridView::LeftToRight);
- QTRY_COMPARE(gridView->flow(), QQuickGridView::LeftToRight);
-
- gridView->setWrapEnabled(true);
- gridView->setCacheBuffer(5);
- gridView->setLayoutDirection(Qt::RightToLeft);
-
- QTRY_COMPARE(gridView->isWrapEnabled(), true);
- QTRY_COMPARE(gridView->cacheBuffer(), 5);
- QTRY_COMPARE(gridView->layoutDirection(), Qt::RightToLeft);
-
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),2);
- QTRY_COMPARE(cacheBufferSpy.count(),2);
- QTRY_COMPARE(layoutSpy.count(),1);
- QTRY_COMPARE(flowSpy.count(),2);
-
- gridView->setWrapEnabled(true);
- gridView->setCacheBuffer(5);
- gridView->setLayoutDirection(Qt::RightToLeft);
-
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),2);
- QTRY_COMPARE(cacheBufferSpy.count(),2);
- QTRY_COMPARE(layoutSpy.count(),1);
- QTRY_COMPARE(flowSpy.count(),2);
-
- gridView->setFlow(QQuickGridView::TopToBottom);
- QTRY_COMPARE(gridView->flow(), QQuickGridView::TopToBottom);
- QTRY_COMPARE(flowSpy.count(),3);
-
- gridView->setFlow(QQuickGridView::TopToBottom);
- QTRY_COMPARE(flowSpy.count(),3);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::componentChanges()
-{
- QQuickView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(testFileUrl("propertychangestest.qml"));
-
- QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView");
- QTRY_VERIFY(gridView);
-
- QDeclarativeComponent component(canvas->engine());
- component.setData("import QtQuick 1.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile(""));
-
- QDeclarativeComponent delegateComponent(canvas->engine());
- delegateComponent.setData("import QtQuick 1.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
-
- QSignalSpy highlightSpy(gridView, SIGNAL(highlightChanged()));
- QSignalSpy delegateSpy(gridView, SIGNAL(delegateChanged()));
- QSignalSpy headerSpy(gridView, SIGNAL(headerChanged()));
- QSignalSpy footerSpy(gridView, SIGNAL(footerChanged()));
-
- gridView->setHighlight(&component);
- gridView->setDelegate(&delegateComponent);
- gridView->setHeader(&component);
- gridView->setFooter(&component);
-
- QTRY_COMPARE(gridView->highlight(), &component);
- QTRY_COMPARE(gridView->delegate(), &delegateComponent);
- QTRY_COMPARE(gridView->header(), &component);
- QTRY_COMPARE(gridView->footer(), &component);
-
- QTRY_COMPARE(highlightSpy.count(),1);
- QTRY_COMPARE(delegateSpy.count(),1);
- QTRY_COMPARE(headerSpy.count(),1);
- QTRY_COMPARE(footerSpy.count(),1);
-
- gridView->setHighlight(&component);
- gridView->setDelegate(&delegateComponent);
- gridView->setHeader(&component);
- gridView->setFooter(&component);
-
- QTRY_COMPARE(highlightSpy.count(),1);
- QTRY_COMPARE(delegateSpy.count(),1);
- QTRY_COMPARE(headerSpy.count(),1);
- QTRY_COMPARE(footerSpy.count(),1);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::modelChanges()
-{
- QQuickView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(testFileUrl("propertychangestest.qml"));
-
- QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView");
- QTRY_VERIFY(gridView);
-
- QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel");
- QTRY_VERIFY(alternateModel);
- QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
- QSignalSpy modelSpy(gridView, SIGNAL(modelChanged()));
-
- gridView->setModel(modelVariant);
- QTRY_COMPARE(gridView->model(), modelVariant);
- QTRY_COMPARE(modelSpy.count(),1);
-
- gridView->setModel(modelVariant);
- QTRY_COMPARE(modelSpy.count(),1);
-
- gridView->setModel(QVariant());
- QTRY_COMPARE(modelSpy.count(),2);
- delete canvas;
-}
-
-void tst_QQuickGridView::positionViewAtIndex()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.);
- QTRY_COMPARE(item->y(), (i/3)*60.);
- }
-
- // Position on a currently visible item
- gridview->positionViewAtIndex(4, QQuickGridView::Beginning);
- QTRY_COMPARE(gridview->indexAt(120, 90), 4);
- QTRY_COMPARE(gridview->contentY(), 60.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.);
- QTRY_COMPARE(item->y(), (i/3)*60.);
- }
-
- // Position on an item beyond the visible items
- gridview->positionViewAtIndex(21, QQuickGridView::Beginning);
- QTRY_COMPARE(gridview->indexAt(40, 450), 21);
- QTRY_COMPARE(gridview->contentY(), 420.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.);
- QTRY_COMPARE(item->y(), (i/3)*60.);
- }
-
- // Position on an item that would leave empty space if positioned at the top
- gridview->positionViewAtIndex(31, QQuickGridView::Beginning);
- QTRY_COMPARE(gridview->indexAt(120, 630), 31);
- QTRY_COMPARE(gridview->contentY(), 520.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.);
- QTRY_COMPARE(item->y(), (i/3)*60.);
- }
-
- // Position at the beginning again
- gridview->positionViewAtIndex(0, QQuickGridView::Beginning);
- QTRY_COMPARE(gridview->indexAt(0, 0), 0);
- QTRY_COMPARE(gridview->indexAt(40, 30), 0);
- QTRY_COMPARE(gridview->indexAt(80, 60), 4);
- QTRY_COMPARE(gridview->contentY(), 0.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.);
- QTRY_COMPARE(item->y(), (i/3)*60.);
- }
-
- // Position at End
- gridview->positionViewAtIndex(30, QQuickGridView::End);
- QTRY_COMPARE(gridview->contentY(), 340.);
-
- // Position in Center
- gridview->positionViewAtIndex(15, QQuickGridView::Center);
- QTRY_COMPARE(gridview->contentY(), 170.);
-
- // Ensure at least partially visible
- gridview->positionViewAtIndex(15, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentY(), 170.);
-
- gridview->setContentY(302);
- gridview->positionViewAtIndex(15, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentY(), 302.);
-
- gridview->setContentY(360);
- gridview->positionViewAtIndex(15, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentY(), 300.);
-
- gridview->setContentY(60);
- gridview->positionViewAtIndex(20, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentY(), 60.);
-
- gridview->setContentY(20);
- gridview->positionViewAtIndex(20, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentY(), 100.);
-
- // Ensure completely visible
- gridview->setContentY(120);
- gridview->positionViewAtIndex(20, QQuickGridView::Contain);
- QTRY_COMPARE(gridview->contentY(), 120.);
-
- gridview->setContentY(302);
- gridview->positionViewAtIndex(15, QQuickGridView::Contain);
- QTRY_COMPARE(gridview->contentY(), 300.);
-
- gridview->setContentY(60);
- gridview->positionViewAtIndex(20, QQuickGridView::Contain);
- QTRY_COMPARE(gridview->contentY(), 100.);
-
- // Test for Top To Bottom layout
- ctxt->setContextProperty("testTopToBottom", QVariant(true));
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), (i/5)*80.);
- QTRY_COMPARE(item->y(), (i%5)*60.);
- }
-
- // Position at End
- gridview->positionViewAtIndex(30, QQuickGridView::End);
- QTRY_COMPARE(gridview->contentX(), 320.);
- QTRY_COMPARE(gridview->contentY(), 0.);
-
- // Position in Center
- gridview->positionViewAtIndex(15, QQuickGridView::Center);
- QTRY_COMPARE(gridview->contentX(), 160.);
-
- // Ensure at least partially visible
- gridview->positionViewAtIndex(15, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentX(), 160.);
-
- gridview->setContentX(170);
- gridview->positionViewAtIndex(25, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentX(), 170.);
-
- gridview->positionViewAtIndex(30, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentX(), 320.);
-
- gridview->setContentX(170);
- gridview->positionViewAtIndex(25, QQuickGridView::Contain);
- QTRY_COMPARE(gridview->contentX(), 240.);
-
- // positionViewAtBeginning
- gridview->positionViewAtBeginning();
- QTRY_COMPARE(gridview->contentX(), 0.);
-
- gridview->setContentX(80);
- canvas->rootObject()->setProperty("showHeader", true);
- gridview->positionViewAtBeginning();
- QTRY_COMPARE(gridview->contentX(), -30.);
-
- // positionViewAtEnd
- gridview->positionViewAtEnd();
- QTRY_COMPARE(gridview->contentX(), 400.); // 8*80 - 240 (8 columns)
-
- gridview->setContentX(80);
- canvas->rootObject()->setProperty("showFooter", true);
- gridview->positionViewAtEnd();
- QTRY_COMPARE(gridview->contentX(), 430.);
-
- // set current item to outside visible view, position at beginning
- // and ensure highlight moves to current item
- gridview->setCurrentIndex(6);
- gridview->positionViewAtBeginning();
- QTRY_COMPARE(gridview->contentX(), -30.);
- QVERIFY(gridview->highlightItem());
- QCOMPARE(gridview->highlightItem()->x(), 80.);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::snapping()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- gridview->setHeight(220);
- QCOMPARE(gridview->height(), 220.);
-
- gridview->positionViewAtIndex(12, QQuickGridView::Visible);
- QCOMPARE(gridview->contentY(), 80.);
-
- gridview->setContentY(0);
- QCOMPARE(gridview->contentY(), 0.);
-
- gridview->setSnapMode(QQuickGridView::SnapToRow);
- QCOMPARE(gridview->snapMode(), QQuickGridView::SnapToRow);
-
- gridview->positionViewAtIndex(12, QQuickGridView::Visible);
- QCOMPARE(gridview->contentY(), 60.);
-
- gridview->positionViewAtIndex(15, QQuickGridView::End);
- QCOMPARE(gridview->contentY(), 120.);
-
- delete canvas;
-
-}
-
-void tst_QQuickGridView::mirroring()
-{
- QQuickView *canvasA = createView();
- canvasA->setSource(testFileUrl("mirroring.qml"));
- QQuickGridView *gridviewA = findItem<QQuickGridView>(canvasA->rootObject(), "view");
- QTRY_VERIFY(gridviewA != 0);
-
- QQuickView *canvasB = createView();
- canvasB->setSource(testFileUrl("mirroring.qml"));
- QQuickGridView *gridviewB = findItem<QQuickGridView>(canvasB->rootObject(), "view");
- QTRY_VERIFY(gridviewA != 0);
- qApp->processEvents();
-
- QList<QString> objectNames;
- objectNames << "item1" << "item2"; // << "item3"
-
- gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
- gridviewB->setProperty("layoutDirection", Qt::RightToLeft);
- QCOMPARE(gridviewA->layoutDirection(), gridviewA->effectiveLayoutDirection());
-
- // LTR != RTL
- foreach (const QString objectName, objectNames)
- QVERIFY(findItem<QQuickItem>(gridviewA, objectName)->x() != findItem<QQuickItem>(gridviewB, objectName)->x());
-
- gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
- gridviewB->setProperty("layoutDirection", Qt::LeftToRight);
-
- // LTR == LTR
- foreach (const QString objectName, objectNames)
- QCOMPARE(findItem<QQuickItem>(gridviewA, objectName)->x(), findItem<QQuickItem>(gridviewB, objectName)->x());
-
- QVERIFY(gridviewB->layoutDirection() == gridviewB->effectiveLayoutDirection());
- QQuickItemPrivate::get(gridviewB)->setLayoutMirror(true);
- QVERIFY(gridviewB->layoutDirection() != gridviewB->effectiveLayoutDirection());
-
- // LTR != LTR+mirror
- foreach (const QString objectName, objectNames)
- QVERIFY(findItem<QQuickItem>(gridviewA, objectName)->x() != findItem<QQuickItem>(gridviewB, objectName)->x());
-
- gridviewA->setProperty("layoutDirection", Qt::RightToLeft);
-
- // RTL == LTR+mirror
- foreach (const QString objectName, objectNames)
- QCOMPARE(findItem<QQuickItem>(gridviewA, objectName)->x(), findItem<QQuickItem>(gridviewB, objectName)->x());
-
- gridviewB->setProperty("layoutDirection", Qt::RightToLeft);
-
- // RTL != RTL+mirror
- foreach (const QString objectName, objectNames)
- QVERIFY(findItem<QQuickItem>(gridviewA, objectName)->x() != findItem<QQuickItem>(gridviewB, objectName)->x());
-
- gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
-
- // LTR == RTL+mirror
- foreach (const QString objectName, objectNames)
- QCOMPARE(findItem<QQuickItem>(gridviewA, objectName)->x(), findItem<QQuickItem>(gridviewB, objectName)->x());
-
- delete canvasA;
- delete canvasB;
-}
-
-void tst_QQuickGridView::positionViewAtIndex_rightToLeft()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testTopToBottom", QVariant(true));
- ctxt->setContextProperty("testRightToLeft", QVariant(true));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- }
-
- // Position on a currently visible item
- gridview->positionViewAtIndex(6, QQuickGridView::Beginning);
- QTRY_COMPARE(gridview->contentX(), -320.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- }
-
- // Position on an item beyond the visible items
- gridview->positionViewAtIndex(21, QQuickGridView::Beginning);
- QTRY_COMPARE(gridview->contentX(), -560.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- }
-
- // Position on an item that would leave empty space if positioned at the top
- gridview->positionViewAtIndex(31, QQuickGridView::Beginning);
- QTRY_COMPARE(gridview->contentX(), -640.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- }
-
- // Position at the beginning again
- gridview->positionViewAtIndex(0, QQuickGridView::Beginning);
- QTRY_COMPARE(gridview->contentX(), -240.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
- QTRY_COMPARE(item->y(), qreal((i%5)*60));
- }
-
- // Position at End
- gridview->positionViewAtIndex(30, QQuickGridView::End);
- QTRY_COMPARE(gridview->contentX(), -560.);
-
- // Position in Center
- gridview->positionViewAtIndex(15, QQuickGridView::Center);
- QTRY_COMPARE(gridview->contentX(), -400.);
-
- // Ensure at least partially visible
- gridview->positionViewAtIndex(15, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentX(), -400.);
-
- gridview->setContentX(-555.);
- gridview->positionViewAtIndex(15, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentX(), -555.);
-
- gridview->setContentX(-239);
- gridview->positionViewAtIndex(15, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentX(), -320.);
-
- gridview->setContentX(-239);
- gridview->positionViewAtIndex(20, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentX(), -400.);
-
- gridview->setContentX(-640);
- gridview->positionViewAtIndex(20, QQuickGridView::Visible);
- QTRY_COMPARE(gridview->contentX(), -560.);
-
- // Ensure completely visible
- gridview->setContentX(-400);
- gridview->positionViewAtIndex(20, QQuickGridView::Contain);
- QTRY_COMPARE(gridview->contentX(), -400.);
-
- gridview->setContentX(-315);
- gridview->positionViewAtIndex(15, QQuickGridView::Contain);
- QTRY_COMPARE(gridview->contentX(), -320.);
-
- gridview->setContentX(-640);
- gridview->positionViewAtIndex(20, QQuickGridView::Contain);
- QTRY_COMPARE(gridview->contentX(), -560.);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::resetModel()
-{
- QQuickView *canvas = createView();
-
- QStringList strings;
- strings << "one" << "two" << "three";
- QStringListModel model(strings);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("displaygrid.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QTRY_COMPARE(gridview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QQuickText *display = findItem<QQuickText>(contentItem, "displayText", i);
- QTRY_VERIFY(display != 0);
- QTRY_COMPARE(display->text(), strings.at(i));
- }
-
- strings.clear();
- strings << "four" << "five" << "six" << "seven";
- model.setStringList(strings);
-
- QTRY_COMPARE(gridview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QQuickText *display = findItem<QQuickText>(contentItem, "displayText", i);
- QTRY_VERIFY(display != 0);
- QTRY_COMPARE(display->text(), strings.at(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::enforceRange()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview-enforcerange.qml"));
- canvas->show();
- qApp->processEvents();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QTRY_COMPARE(gridview->preferredHighlightBegin(), 100.0);
- QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0);
- QTRY_COMPARE(gridview->highlightRangeMode(), QQuickGridView::StrictlyEnforceRange);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // view should be positioned at the top of the range.
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QTRY_VERIFY(item);
- QTRY_COMPARE(gridview->contentY(), -100.0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- // Check currentIndex is updated when contentItem moves
- gridview->setContentY(0);
- QTRY_COMPARE(gridview->currentIndex(), 2);
-
- gridview->setCurrentIndex(5);
- QTRY_COMPARE(gridview->contentY(), 100.);
-
- QaimModel model2;
- for (int i = 0; i < 5; i++)
- model2.addItem("Item" + QString::number(i), "");
-
- ctxt->setContextProperty("testModel", &model2);
- QCOMPARE(gridview->count(), 5);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::enforceRange_rightToLeft()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(true));
- ctxt->setContextProperty("testTopToBottom", QVariant(true));
-
- canvas->setSource(testFileUrl("gridview-enforcerange.qml"));
- qApp->processEvents();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QCOMPARE(gridview->preferredHighlightBegin(), 100.0);
- QCOMPARE(gridview->preferredHighlightEnd(), 100.0);
- QCOMPARE(gridview->highlightRangeMode(), QQuickGridView::StrictlyEnforceRange);
-
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
-
- // view should be positioned at the top of the range.
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QTRY_COMPARE(gridview->contentX(), -140.);
- QTRY_COMPARE(gridview->contentY(), 0.0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- // Check currentIndex is updated when contentItem moves
- gridview->setContentX(-240);
- QTRY_COMPARE(gridview->currentIndex(), 3);
-
- gridview->setCurrentIndex(7);
- QTRY_COMPARE(gridview->contentX(), -340.);
- QTRY_COMPARE(gridview->contentY(), 0.0);
-
- QaimModel model2;
- for (int i = 0; i < 5; i++)
- model2.addItem("Item" + QString::number(i), "");
-
- ctxt->setContextProperty("testModel", &model2);
- QCOMPARE(gridview->count(), 5);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::QTBUG_8456()
-{
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("setindex.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QTRY_COMPARE(gridview->currentIndex(), 0);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::manualHighlight()
-{
- QQuickView *canvas = createView();
-
- QString filename(testFile("manual-highlight.qml"));
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(gridview->currentIndex(), 0);
- QTRY_COMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
- QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
- QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
-
- gridview->setCurrentIndex(2);
-
- QTRY_COMPARE(gridview->currentIndex(), 2);
- QTRY_COMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
- QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
- QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
-
- gridview->positionViewAtIndex(8, QQuickGridView::Contain);
-
- QTRY_COMPARE(gridview->currentIndex(), 2);
- QTRY_COMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
- QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
- QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
-
- gridview->setFlow(QQuickGridView::TopToBottom);
- QTRY_COMPARE(gridview->flow(), QQuickGridView::TopToBottom);
-
- gridview->setCurrentIndex(0);
- QTRY_COMPARE(gridview->currentIndex(), 0);
- QTRY_COMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
- QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
- QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
-
- delete canvas;
-}
-
-
-void tst_QQuickGridView::footer()
-{
- QFETCH(QQuickGridView::Flow, flow);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(QPointF, initialFooterPos);
- QFETCH(QPointF, changedFooterPos);
- QFETCH(QPointF, initialContentPos);
- QFETCH(QPointF, changedContentPos);
- QFETCH(QPointF, firstDelegatePos);
- QFETCH(QPointF, resizeContentPos);
-
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- for (int i = 0; i < 7; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("footer.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- gridview->setFlow(flow);
- gridview->setLayoutDirection(layoutDirection);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickText *footer = findItem<QQuickText>(contentItem, "footer");
- QVERIFY(footer);
-
- QVERIFY(footer == gridview->footerItem());
-
- QCOMPARE(footer->pos(), initialFooterPos);
- QCOMPARE(footer->width(), 100.);
- QCOMPARE(footer->height(), 30.);
- QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos);
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->pos(), firstDelegatePos);
-
- if (flow == QQuickGridView::LeftToRight) {
- // shrink by one row
- model.removeItem(2);
- QTRY_COMPARE(footer->y(), initialFooterPos.y() - gridview->cellHeight());
- } else {
- // shrink by one column
- model.removeItem(2);
- model.removeItem(3);
- if (layoutDirection == Qt::LeftToRight)
- QTRY_COMPARE(footer->x(), initialFooterPos.x() - gridview->cellWidth());
- else
- QTRY_COMPARE(footer->x(), initialFooterPos.x() + gridview->cellWidth());
- }
-
- // remove all items
- model.clear();
-
- QPointF posWhenNoItems(0, 0);
- if (layoutDirection == Qt::RightToLeft)
- posWhenNoItems.setX(flow == QQuickGridView::LeftToRight ? gridview->width() - footer->width() : -footer->width());
- QTRY_COMPARE(footer->pos(), posWhenNoItems);
-
- // if header is present, it's at a negative pos, so the footer should not move
- canvas->rootObject()->setProperty("showHeader", true);
- QVERIFY(findItem<QQuickItem>(contentItem, "header") != 0);
- QTRY_COMPARE(footer->pos(), posWhenNoItems);
- canvas->rootObject()->setProperty("showHeader", false);
-
- // add 30 items
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QSignalSpy footerItemSpy(gridview, SIGNAL(footerItemChanged()));
- QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter");
-
- QCOMPARE(footerItemSpy.count(), 1);
-
- footer = findItem<QQuickText>(contentItem, "footer");
- QVERIFY(!footer);
- footer = findItem<QQuickText>(contentItem, "footer2");
- QVERIFY(footer);
-
- QVERIFY(footer == gridview->footerItem());
-
- QCOMPARE(footer->pos(), changedFooterPos);
- QCOMPARE(footer->width(), 50.);
- QCOMPARE(footer->height(), 20.);
- QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), changedContentPos);
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->pos(), firstDelegatePos);
-
- gridview->positionViewAtEnd();
- footer->setHeight(10);
- footer->setWidth(40);
- QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), resizeContentPos);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::footer_data()
-{
- QTest::addColumn<QQuickGridView::Flow>("flow");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<QPointF>("initialFooterPos");
- QTest::addColumn<QPointF>("changedFooterPos");
- QTest::addColumn<QPointF>("initialContentPos");
- QTest::addColumn<QPointF>("changedContentPos");
- QTest::addColumn<QPointF>("firstDelegatePos");
- QTest::addColumn<QPointF>("resizeContentPos");
-
- // footer1 = 100 x 30
- // footer2 = 50 x 20
- // cells = 80 * 60
- // view width = 240
- // view height = 320
-
- // footer below items, bottom left
- QTest::newRow("flow left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight
- << QPointF(0, 3 * 60) // 180 = height of 3 rows (cell height is 60)
- << QPointF(0, 10 * 60) // 30 items = 10 rows
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(0, 10 * 60 - 320 + 10);
-
- // footer below items, bottom right
- QTest::newRow("flow left to right, layout right to left") << QQuickGridView::LeftToRight << Qt::RightToLeft
- << QPointF(240 - 100, 3 * 60)
- << QPointF((240 - 100) + 50, 10 * 60) // 50 = width diff between old and new footers
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(240 - 80, 0)
- << QPointF(0, 10 * 60 - 320 + 10);
-
- // footer to right of items
- QTest::newRow("flow top to bottom, layout left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight
- << QPointF(2 * 80, 0) // 2 columns, cell width 80
- << QPointF(6 * 80, 0) // 30 items = 6 columns
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(6 * 80 - 240 + 40, 0);
-
- // footer to left of items
- QTest::newRow("flow top to bottom, layout right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft
- << QPointF(-(2 * 80) - 100, 0)
- << QPointF(-(6 * 80) - 50, 0) // 50 = new footer width
- << QPointF(-240, 0)
- << QPointF(-240, 0) // unchanged, footer change doesn't change content pos
- << QPointF(-80, 0)
- << QPointF(-(6 * 80) - 40, 0);
-}
-
-void tst_QQuickGridView::header()
-{
- QFETCH(QQuickGridView::Flow, flow);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(QPointF, initialHeaderPos);
- QFETCH(QPointF, changedHeaderPos);
- QFETCH(QPointF, initialContentPos);
- QFETCH(QPointF, changedContentPos);
- QFETCH(QPointF, firstDelegatePos);
- QFETCH(QPointF, resizeContentPos);
-
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QQuickView *canvas = createView();
- canvas->rootContext()->setContextProperty("testModel", &model);
- canvas->rootContext()->setContextProperty("initialViewWidth", 240);
- canvas->rootContext()->setContextProperty("initialViewHeight", 320);
- canvas->setSource(testFileUrl("header.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- gridview->setFlow(flow);
- gridview->setLayoutDirection(layoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickText *header = findItem<QQuickText>(contentItem, "header");
- QVERIFY(header);
-
- QVERIFY(header == gridview->headerItem());
-
- QCOMPARE(header->pos(), initialHeaderPos);
- QCOMPARE(header->width(), 100.);
- QCOMPARE(header->height(), 30.);
- QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos);
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->pos(), firstDelegatePos);
-
- model.clear();
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- QCOMPARE(header->pos(), initialHeaderPos); // header should stay where it is
-
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QSignalSpy headerItemSpy(gridview, SIGNAL(headerItemChanged()));
- QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader");
-
- QCOMPARE(headerItemSpy.count(), 1);
-
- header = findItem<QQuickText>(contentItem, "header");
- QVERIFY(!header);
- header = findItem<QQuickText>(contentItem, "header2");
- QVERIFY(header);
-
- QVERIFY(header == gridview->headerItem());
-
- QCOMPARE(header->pos(), changedHeaderPos);
- QCOMPARE(header->width(), 50.);
- QCOMPARE(header->height(), 20.);
- QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), changedContentPos);
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->pos(), firstDelegatePos);
-
- header->setHeight(10);
- header->setWidth(40);
- QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), resizeContentPos);
-
- delete canvas;
-
-
- // QTBUG-21207 header should become visible if view resizes from initial empty size
-
- canvas = createView();
- canvas->rootContext()->setContextProperty("testModel", &model);
- canvas->rootContext()->setContextProperty("initialViewWidth", 240);
- canvas->rootContext()->setContextProperty("initialViewHeight", 320);
- canvas->setSource(testFileUrl("header.qml"));
- canvas->show();
- qApp->processEvents();
-
- gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- gridview->setFlow(flow);
- gridview->setLayoutDirection(layoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- gridview->setWidth(240);
- gridview->setHeight(320);
- QTRY_COMPARE(gridview->headerItem()->pos(), initialHeaderPos);
- QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::header_data()
-{
- QTest::addColumn<QQuickGridView::Flow>("flow");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<QPointF>("initialHeaderPos");
- QTest::addColumn<QPointF>("changedHeaderPos");
- QTest::addColumn<QPointF>("initialContentPos");
- QTest::addColumn<QPointF>("changedContentPos");
- QTest::addColumn<QPointF>("firstDelegatePos");
- QTest::addColumn<QPointF>("resizeContentPos");
-
- // header1 = 100 x 30
- // header2 = 50 x 20
- // cells = 80 x 60
- // view width = 240
-
- // header above items, top left
- QTest::newRow("flow left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight
- << QPointF(0, -30)
- << QPointF(0, -20)
- << QPointF(0, -30)
- << QPointF(0, -20)
- << QPointF(0, 0)
- << QPointF(0, -10);
-
- // header above items, top right
- QTest::newRow("flow left to right, layout right to left") << QQuickGridView::LeftToRight << Qt::RightToLeft
- << QPointF(240 - 100, -30)
- << QPointF((240 - 100) + 50, -20) // 50 = width diff between old and new headers
- << QPointF(0, -30)
- << QPointF(0, -20)
- << QPointF(160, 0)
- << QPointF(0, -10);
-
- // header to left of items
- QTest::newRow("flow top to bottom, layout left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight
- << QPointF(-100, 0)
- << QPointF(-50, 0)
- << QPointF(-100, 0)
- << QPointF(-50, 0)
- << QPointF(0, 0)
- << QPointF(-40, 0);
-
- // header to right of items
- QTest::newRow("flow top to bottom, layout right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(-(240 - 100), 0)
- << QPointF(-(240 - 50), 0)
- << QPointF(-80, 0)
- << QPointF(-(240 - 40), 0);
-}
-
-void tst_QQuickGridView::resizeViewAndRepaint()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("initialWidth", 240);
- ctxt->setContextProperty("initialHeight", 100);
-
- canvas->setSource(testFileUrl("resizeview.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- // item at index 10 should not be currently visible
- QVERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
-
- gridview->setHeight(320);
- QTRY_VERIFY(findItem<QQuickItem>(contentItem, "wrapper", 10));
-
- gridview->setHeight(100);
- QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
-
- // Ensure we handle -ve sizes
- gridview->setHeight(-100);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 3);
-
- gridview->setCacheBuffer(120);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 9);
-
- // ensure items in cache become visible
- gridview->setHeight(120);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 15);
-
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal((i%3)*80));
- QTRY_COMPARE(item->y(), qreal((i/3)*60));
- QCOMPARE(item->isVisible(), i < 9); // inside view visible, outside not visible
- }
-
- // ensure items outside view become invisible
- gridview->setHeight(60);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 12);
-
- itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), qreal((i%3)*80));
- QTRY_COMPARE(item->y(), qreal((i/3)*60));
- QCOMPARE(item->isVisible(), i < 6); // inside view visible, outside not visible
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::changeColumnCount()
-{
- QmlListModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("initialWidth", 100);
- ctxt->setContextProperty("initialHeight", 320);
- canvas->setSource(testFileUrl("resizeview.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- // a single column of 6 items are visible
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QCOMPARE(itemCount, 6);
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), 0.0);
- QCOMPARE(item->y(), qreal(i*60));
- }
-
- // now 6x3 grid is visible, plus 1 extra below for refill
- gridview->setWidth(240);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QCOMPARE(itemCount, 6*3 + 1);
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), qreal((i%3)*80));
- QCOMPARE(item->y(), qreal((i/3)*60));
- }
-
- // back to single column
- gridview->setWidth(100);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QCOMPARE(itemCount, 6);
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), 0.0);
- QCOMPARE(item->y(), qreal(i*60));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::indexAt_itemAt_data()
-{
- QTest::addColumn<qreal>("x");
- QTest::addColumn<qreal>("y");
- QTest::addColumn<int>("index");
-
- QTest::newRow("Item 0 - 0, 0") << 0. << 0. << 0;
- QTest::newRow("Item 0 - 79, 59") << 79. << 59. << 0;
- QTest::newRow("Item 1 - 80, 0") << 80. << 0. << 1;
- QTest::newRow("Item 3 - 0, 60") << 0. << 60. << 3;
- QTest::newRow("No Item - 240, 0") << 240. << 0. << -1;
-}
-
-void tst_QQuickGridView::indexAt_itemAt()
-{
- QFETCH(qreal, x);
- QFETCH(qreal, y);
- QFETCH(int, index);
-
- QQuickView *canvas = createView();
-
- QaimModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Billy", "22345");
- model.addItem("Sam", "2945");
- model.addItem("Ben", "04321");
- model.addItem("Jim", "0780");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(gridview->count(), model.count());
-
- QQuickItem *item = 0;
- if (index >= 0) {
- item = findItem<QQuickItem>(contentItem, "wrapper", index);
- QVERIFY(item);
- }
- QCOMPARE(gridview->indexAt(x, y), index);
- QVERIFY(gridview->itemAt(x, y) == item);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::onAdd()
-{
- QFETCH(int, initialItemCount);
- QFETCH(int, itemsToAdd);
-
- const int delegateWidth = 50;
- const int delegateHeight = 100;
- QaimModel model;
- QQuickView *canvas = createView();
- canvas->setGeometry(0,0,5 * delegateWidth, 5 * delegateHeight); // just ensure all items fit
-
- // these initial items should not trigger GridView.onAdd
- for (int i=0; i<initialItemCount; i++)
- model.addItem("dummy value", "dummy value");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("delegateWidth", delegateWidth);
- ctxt->setContextProperty("delegateHeight", delegateHeight);
- canvas->setSource(testFileUrl("attachedSignals.qml"));
-
- QObject *object = canvas->rootObject();
- object->setProperty("width", canvas->width());
- object->setProperty("height", canvas->height());
- qApp->processEvents();
-
- QList<QPair<QString, QString> > items;
- for (int i=0; i<itemsToAdd; i++)
- items << qMakePair(QString("value %1").arg(i), QString::number(i));
- model.addItems(items);
-
- QTRY_COMPARE(model.count(), qobject_cast<QQuickGridView*>(canvas->rootObject())->count());
- qApp->processEvents();
-
- QVariantList result = object->property("addedDelegates").toList();
- QTRY_COMPARE(result.count(), items.count());
- for (int i=0; i<items.count(); i++)
- QCOMPARE(result[i].toString(), items[i].first);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::onAdd_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<int>("itemsToAdd");
-
- QTest::newRow("0, add 1") << 0 << 1;
- QTest::newRow("0, add 2") << 0 << 2;
- QTest::newRow("0, add 10") << 0 << 10;
-
- QTest::newRow("1, add 1") << 1 << 1;
- QTest::newRow("1, add 2") << 1 << 2;
- QTest::newRow("1, add 10") << 1 << 10;
-
- QTest::newRow("5, add 1") << 5 << 1;
- QTest::newRow("5, add 2") << 5 << 2;
- QTest::newRow("5, add 10") << 5 << 10;
-}
-
-void tst_QQuickGridView::onRemove()
-{
- QFETCH(int, initialItemCount);
- QFETCH(int, indexToRemove);
- QFETCH(int, removeCount);
-
- const int delegateWidth = 50;
- const int delegateHeight = 100;
- QaimModel model;
- for (int i=0; i<initialItemCount; i++)
- model.addItem(QString("value %1").arg(i), "dummy value");
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("delegateWidth", delegateWidth);
- ctxt->setContextProperty("delegateHeight", delegateHeight);
- canvas->setSource(testFileUrl("attachedSignals.qml"));
- QObject *object = canvas->rootObject();
-
- model.removeItems(indexToRemove, removeCount);
- QTRY_COMPARE(model.count(), qobject_cast<QQuickGridView*>(canvas->rootObject())->count());
- QCOMPARE(object->property("removedDelegateCount"), QVariant(removeCount));
-
- delete canvas;
-}
-
-void tst_QQuickGridView::onRemove_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<int>("indexToRemove");
- QTest::addColumn<int>("removeCount");
-
- QTest::newRow("remove first") << 1 << 0 << 1;
- QTest::newRow("two items, remove first") << 2 << 0 << 1;
- QTest::newRow("two items, remove last") << 2 << 1 << 1;
- QTest::newRow("two items, remove all") << 2 << 0 << 2;
-
- QTest::newRow("four items, remove first") << 4 << 0 << 1;
- QTest::newRow("four items, remove 0-2") << 4 << 0 << 2;
- QTest::newRow("four items, remove 1-3") << 4 << 1 << 2;
- QTest::newRow("four items, remove 2-4") << 4 << 2 << 2;
- QTest::newRow("four items, remove last") << 4 << 3 << 1;
- QTest::newRow("four items, remove all") << 4 << 0 << 4;
-
- QTest::newRow("ten items, remove 1-8") << 10 << 0 << 8;
- QTest::newRow("ten items, remove 2-7") << 10 << 2 << 5;
- QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6;
-}
-
-void tst_QQuickGridView::columnCount()
-{
- QQuickView canvas;
- canvas.setSource(testFileUrl("gridview4.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
-
- QQuickGridView *view = qobject_cast<QQuickGridView*>(canvas.rootObject());
-
- QCOMPARE(view->cellWidth(), qreal(405)/qreal(9));
- QCOMPARE(view->cellHeight(), qreal(100));
-
- QList<QQuickItem*> items = findItems<QQuickItem>(view, "delegate");
- QCOMPARE(items.size(), 18);
- QCOMPARE(items.at(8)->y(), qreal(0));
- QCOMPARE(items.at(9)->y(), qreal(100));
-}
-
-void tst_QQuickGridView::margins()
-{
- {
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
-
- canvas->setSource(testFileUrl("margins.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QCOMPARE(gridview->contentX(), -30.);
- QCOMPARE(gridview->xOrigin(), 0.);
-
- // check end bound
- gridview->positionViewAtEnd();
- qreal pos = gridview->contentX();
- gridview->setContentX(pos + 80);
- gridview->returnToBounds();
- QTRY_COMPARE(gridview->contentX(), pos + 50);
-
- // remove item before visible and check that left margin is maintained
- // and xOrigin is updated
- gridview->setContentX(200);
- model.removeItems(0, 4);
- QTest::qWait(100);
- gridview->setContentX(-50);
- gridview->returnToBounds();
- QCOMPARE(gridview->xOrigin(), 100.);
- QTRY_COMPARE(gridview->contentX(), 70.);
-
- // reduce left margin
- gridview->setLeftMargin(20);
- QCOMPARE(gridview->xOrigin(), 100.);
- QTRY_COMPARE(gridview->contentX(), 80.);
-
- // check end bound
- gridview->positionViewAtEnd();
- QCOMPARE(gridview->xOrigin(), 0.); // positionViewAtEnd() resets origin
- pos = gridview->contentX();
- gridview->setContentX(pos + 80);
- gridview->returnToBounds();
- QTRY_COMPARE(gridview->contentX(), pos + 50);
-
- // reduce right margin
- pos = gridview->contentX();
- gridview->setRightMargin(40);
- QCOMPARE(gridview->xOrigin(), 0.);
- QTRY_COMPARE(gridview->contentX(), pos-10);
-
- delete canvas;
- }
- {
- //RTL
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(true));
-
- canvas->setSource(testFileUrl("margins.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QCOMPARE(gridview->contentX(), -240+30.);
- QCOMPARE(gridview->xOrigin(), 0.);
-
- // check end bound
- gridview->positionViewAtEnd();
- qreal pos = gridview->contentX();
- gridview->setContentX(pos - 80);
- gridview->returnToBounds();
- QTRY_COMPARE(gridview->contentX(), pos - 50);
-
- // remove item before visible and check that left margin is maintained
- // and xOrigin is updated
- gridview->setContentX(-400);
- model.removeItems(0, 4);
- QTest::qWait(100);
- gridview->setContentX(-240+50);
- gridview->returnToBounds();
- QCOMPARE(gridview->xOrigin(), -100.);
- QTRY_COMPARE(gridview->contentX(), -240-70.);
-
- // reduce left margin (i.e. right side due to RTL)
- pos = gridview->contentX();
- gridview->setLeftMargin(20);
- QCOMPARE(gridview->xOrigin(), -100.);
- QTRY_COMPARE(gridview->contentX(), -240-80.);
-
- // check end bound
- gridview->positionViewAtEnd();
- QCOMPARE(gridview->xOrigin(), 0.); // positionViewAtEnd() resets origin
- pos = gridview->contentX();
- gridview->setContentX(pos - 80);
- gridview->returnToBounds();
- QTRY_COMPARE(gridview->contentX(), pos - 50);
-
- // reduce right margin (i.e. left side due to RTL)
- pos = gridview->contentX();
- gridview->setRightMargin(40);
- QCOMPARE(gridview->xOrigin(), 0.);
- QTRY_COMPARE(gridview->contentX(), pos+10);
-
- delete canvas;
- }
-}
-
-void tst_QQuickGridView::creationContext()
-{
- QQuickView canvas;
- canvas.setGeometry(0,0,240,320);
- canvas.setSource(testFileUrl("creationContext.qml"));
- qApp->processEvents();
-
- QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
- QVERIFY(rootItem);
- QVERIFY(rootItem->property("count").toInt() > 0);
-
- QQuickItem *item;
- QVERIFY(item = rootItem->findChild<QQuickItem *>("listItem"));
- QCOMPARE(item->property("text").toString(), QString("Hello!"));
- QVERIFY(item = rootItem->findChild<QQuickItem *>("header"));
- QCOMPARE(item->property("text").toString(), QString("Hello!"));
- QVERIFY(item = rootItem->findChild<QQuickItem *>("footer"));
- QCOMPARE(item->property("text").toString(), QString("Hello!"));
-}
-
-void tst_QQuickGridView::snapToRow_data()
-{
- QTest::addColumn<QQuickGridView::Flow>("flow");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<int>("highlightRangeMode");
- QTest::addColumn<QPoint>("flickStart");
- QTest::addColumn<QPoint>("flickEnd");
- QTest::addColumn<qreal>("snapAlignment");
- QTest::addColumn<qreal>("endExtent");
- QTest::addColumn<qreal>("startExtent");
-
- QTest::newRow("vertical, left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
-
- QTest::newRow("horizontal, left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
-
- QTest::newRow("horizontal, right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 << -240.0;
-
- QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
-
- QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
-
- QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 - 140.0 << -220.0;
-}
-
-void tst_QQuickGridView::snapToRow()
-{
- QFETCH(QQuickGridView::Flow, flow);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(int, highlightRangeMode);
- QFETCH(QPoint, flickStart);
- QFETCH(QPoint, flickEnd);
- QFETCH(qreal, snapAlignment);
- QFETCH(qreal, endExtent);
- QFETCH(qreal, startExtent);
-
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("snapToRow.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- gridview->setFlow(flow);
- gridview->setLayoutDirection(layoutDirection);
- gridview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // confirm that a flick hits an item boundary
- flick(canvas, flickStart, flickEnd, 180);
- QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
- if (flow == QQuickGridView::LeftToRight)
- QCOMPARE(qreal(fmod(gridview->contentY(),80.0)), snapAlignment);
- else
- QCOMPARE(qreal(fmod(gridview->contentX(),80.0)), snapAlignment);
-
- // flick to end
- do {
- flick(canvas, flickStart, flickEnd, 180);
- QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
- } while (flow == QQuickGridView::LeftToRight
- ? !gridview->isAtYEnd()
- : layoutDirection == Qt::LeftToRight ? !gridview->isAtXEnd() : !gridview->isAtXBeginning());
-
- if (flow == QQuickGridView::LeftToRight)
- QCOMPARE(gridview->contentY(), endExtent);
- else
- QCOMPARE(gridview->contentX(), endExtent);
-
- // flick to start
- do {
- flick(canvas, flickEnd, flickStart, 180);
- QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
- } while (flow == QQuickGridView::LeftToRight
- ? !gridview->isAtYBeginning()
- : layoutDirection == Qt::LeftToRight ? !gridview->isAtXBeginning() : !gridview->isAtXEnd());
-
- if (flow == QQuickGridView::LeftToRight)
- QCOMPARE(gridview->contentY(), startExtent);
- else
- QCOMPARE(gridview->contentX(), startExtent);
-
- delete canvas;
-}
-
-void tst_QQuickGridView::snapOneRow_data()
-{
- QTest::addColumn<QQuickGridView::Flow>("flow");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<int>("highlightRangeMode");
- QTest::addColumn<QPoint>("flickStart");
- QTest::addColumn<QPoint>("flickEnd");
- QTest::addColumn<qreal>("snapAlignment");
- QTest::addColumn<qreal>("endExtent");
- QTest::addColumn<qreal>("startExtent");
-
- QTest::newRow("vertical, left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 360.0 << 0.0;
-
- QTest::newRow("horizontal, left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 360.0 << 0.0;
-
- QTest::newRow("horizontal, right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -360.0 - 240.0 << -240.0;
-
- QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 460.0 << -20.0;
-
- QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 460.0 << -20.0;
-
- QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -360.0 - 240.0 - 100.0 << -220.0;
-}
-
-void tst_QQuickGridView::snapOneRow()
-{
- QFETCH(QQuickGridView::Flow, flow);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(int, highlightRangeMode);
- QFETCH(QPoint, flickStart);
- QFETCH(QPoint, flickEnd);
- QFETCH(qreal, snapAlignment);
- QFETCH(qreal, endExtent);
- QFETCH(qreal, startExtent);
-
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("snapOneRow.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
-
- gridview->setFlow(flow);
- gridview->setLayoutDirection(layoutDirection);
- gridview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QQuickItem *contentItem = gridview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QSignalSpy currentIndexSpy(gridview, SIGNAL(currentIndexChanged()));
-
- // confirm that a flick hits next row boundary
- flick(canvas, flickStart, flickEnd, 180);
- QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
- if (flow == QQuickGridView::LeftToRight)
- QCOMPARE(gridview->contentY(), snapAlignment);
- else
- QCOMPARE(gridview->contentX(), snapAlignment);
-
- if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
- QCOMPARE(gridview->currentIndex(), 2);
- QCOMPARE(currentIndexSpy.count(), 1);
- }
-
- // flick to end
- do {
- flick(canvas, flickStart, flickEnd, 180);
- QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
- } while (flow == QQuickGridView::LeftToRight
- ? !gridview->isAtYEnd()
- : layoutDirection == Qt::LeftToRight ? !gridview->isAtXEnd() : !gridview->isAtXBeginning());
-
- if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
- QCOMPARE(gridview->currentIndex(), 8);
- QCOMPARE(currentIndexSpy.count(), 4);
- }
-
- if (flow == QQuickGridView::LeftToRight)
- QCOMPARE(gridview->contentY(), endExtent);
- else
- QCOMPARE(gridview->contentX(), endExtent);
-
- // flick to start
- do {
- flick(canvas, flickEnd, flickStart, 180);
- QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
- } while (flow == QQuickGridView::LeftToRight
- ? !gridview->isAtYBeginning()
- : layoutDirection == Qt::LeftToRight ? !gridview->isAtXBeginning() : !gridview->isAtXEnd());
-
- if (flow == QQuickGridView::LeftToRight)
- QCOMPARE(gridview->contentY(), startExtent);
- else
- QCOMPARE(gridview->contentX(), startExtent);
-
- if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
- QCOMPARE(gridview->currentIndex(), 0);
- QCOMPARE(currentIndexSpy.count(), 8);
- }
-
- delete canvas;
-}
-
-
-void tst_QQuickGridView::unaligned()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- for (int i = 0; i < 10; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("unaligned.qml"));
- qApp->processEvents();
-
- QQuickGridView *gridview = qobject_cast<QQuickGridView*>(canvas->rootObject());
- QVERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
-
- for (int i = 0; i < 10; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth()));
- QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight()));
- }
-
- // appending
- for (int i = 10; i < 18; ++i) {
- model.addItem("Item" + QString::number(i), "");
- QQuickItem *item = 0;
- QTRY_VERIFY(item = findItem<QQuickItem>(contentItem, "wrapper", i));
- QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth()));
- QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight()));
- }
-
- // inserting
- for (int i = 0; i < 10; ++i) {
- model.insertItem(i, "Item" + QString::number(i), "");
- QQuickItem *item = 0;
- QTRY_VERIFY(item = findItem<QQuickItem>(contentItem, "wrapper", i));
- QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth()));
- QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight()));
- }
-
- // removing
- model.removeItems(7, 10);
- QTRY_COMPARE(model.count(), gridview->count());
- for (int i = 0; i < 18; ++i) {
- QQuickItem *item = 0;
- QTRY_VERIFY(item = findItem<QQuickItem>(contentItem, "wrapper", i));
- QCOMPARE(item->x(), qreal(i%9)*gridview->cellWidth());
- QCOMPARE(item->y(), qreal(i/9)*gridview->cellHeight());
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::populateTransitions()
-{
- QFETCH(bool, staticallyPopulate);
- QFETCH(bool, dynamicallyPopulate);
- QFETCH(bool, usePopulateTransition);
-
- QPointF transitionFrom(-50, -50);
- QPointF transitionVia(100, 100);
- QaimModel model_transitionFrom;
- QaimModel model_transitionVia;
-
- QaimModel model;
- if (staticallyPopulate) {
- for (int i = 0; i < 30; i++)
- model.addItem("item" + QString::number(i), "");
- }
-
- QQuickView *canvas = createView();
- canvas->rootContext()->setContextProperty("testModel", &model);
- canvas->rootContext()->setContextProperty("usePopulateTransition", usePopulateTransition);
- canvas->rootContext()->setContextProperty("dynamicallyPopulate", dynamicallyPopulate);
- canvas->rootContext()->setContextProperty("transitionFrom", transitionFrom);
- canvas->rootContext()->setContextProperty("transitionVia", transitionVia);
- canvas->rootContext()->setContextProperty("model_transitionFrom", &model_transitionFrom);
- canvas->rootContext()->setContextProperty("model_transitionVia", &model_transitionVia);
- canvas->setSource(testFileUrl("populateTransitions.qml"));
- canvas->show();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview);
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem);
-
- if (staticallyPopulate || dynamicallyPopulate) {
- // check the populate transition is run
- if (usePopulateTransition) {
- QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 19);
- } else {
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 0);
- }
- QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0);
- } else {
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- }
-
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- if (usePopulateTransition)
- QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt());
- for (int i=0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- // add an item and check this is done with add transition, not populate
- model.insertItem(0, "another item", "");
- QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 1);
- QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(),
- (usePopulateTransition && (staticallyPopulate || dynamicallyPopulate)) ? 19 : 0);
-
- // clear the model
- canvas->rootContext()->setContextProperty("testModel", QVariant());
- QTRY_COMPARE(gridview->count(), 0);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 0);
- gridview->setProperty("countPopulateTransitions", 0);
- gridview->setProperty("countAddTransitions", 0);
-
- // set to a valid model and check populate transition is run a second time
- model.clear();
- for (int i = 0; i < 30; i++)
- model.addItem("item" + QString::number(i), "");
- canvas->rootContext()->setContextProperty("testModel", &model);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 19 : 0);
- QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0);
-
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- if (usePopulateTransition)
- QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt());
- for (int i=0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- // reset model and check populate transition is run again
- gridview->setProperty("countPopulateTransitions", 0);
- gridview->setProperty("countAddTransitions", 0);
- model.reset();
- QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 19 : 0);
- QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0);
-
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- if (usePopulateTransition)
- QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt());
- for (int i=0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::populateTransitions_data()
-{
- QTest::addColumn<bool>("staticallyPopulate");
- QTest::addColumn<bool>("dynamicallyPopulate");
- QTest::addColumn<bool>("usePopulateTransition");
-
- QTest::newRow("static") << true << false << true;
- QTest::newRow("static, no populate") << true << false << false;
-
- QTest::newRow("dynamic") << false << true << true;
- QTest::newRow("dynamic, no populate") << false << true << false;
-
- QTest::newRow("empty to start with") << false << false << true;
- QTest::newRow("empty to start with, no populate") << false << false << false;
-}
-
-void tst_QQuickGridView::addTransitions()
-{
- QFETCH(int, initialItemCount);
- QFETCH(bool, shouldAnimateTargets);
- QFETCH(qreal, contentY);
- QFETCH(int, insertionIndex);
- QFETCH(int, insertionCount);
- QFETCH(ListRange, expectedDisplacedIndexes);
-
- // added items should start here
- QPointF targetItems_transitionFrom(-50, -50);
-
- // displaced items should pass through this point
- QPointF displacedItems_transitionVia(100, 100);
-
- QaimModel model;
- for (int i = 0; i < initialItemCount; i++)
- model.addItem("Original item" + QString::number(i), "");
- QaimModel model_targetItems_transitionFrom;
- QaimModel model_displacedItems_transitionVia;
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
- ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
- ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
- ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- canvas->setSource(testFileUrl("addTransitions.qml"));
- canvas->show();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- if (contentY != 0) {
- gridview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- }
-
- QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
-
- // only target items that will become visible should be animated
- QList<QPair<QString, QString> > newData;
- QList<QPair<QString, QString> > expectedTargetData;
- QList<int> targetIndexes;
- if (shouldAnimateTargets) {
- for (int i=insertionIndex; i<insertionIndex+insertionCount; i++) {
- newData << qMakePair(QString("New item %1").arg(i), QString(""));
-
- // last visible item is the first item of the row beneath the view
- if (i >= (contentY / 60)*3 && i < qCeil((contentY + gridview->height()) / 60.0)*3) {
- expectedTargetData << newData.last();
- targetIndexes << i;
- }
- }
- QVERIFY(expectedTargetData.count() > 0);
- }
-
- // start animation
- if (!newData.isEmpty()) {
- model.insertItems(insertionIndex, newData);
- QTRY_COMPARE(model.count(), gridview->count());
- }
-
- QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
-
- if (shouldAnimateTargets) {
- QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
- QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(),
- expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
-
- // check the target and displaced items were animated
- model_targetItems_transitionFrom.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
- model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
-
- // check attached properties
- matchItemsAndIndexes(gridview->property("targetTrans_items").toMap(), model, targetIndexes);
- matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems);
- if (expectedDisplacedIndexes.isValid()) {
- // adjust expectedDisplacedIndexes to their final values after the move
- QList<int> displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount);
- matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes);
- matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems);
- }
- } else {
- QTRY_COMPARE(model_targetItems_transitionFrom.count(), 0);
- QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0);
- }
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // verify all items moved to the correct final positions
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::addTransitions_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<bool>("shouldAnimateTargets");
- QTest::addColumn<int>("insertionIndex");
- QTest::addColumn<int>("insertionCount");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- // if inserting a full row before visible index, items don't appear or animate in, even if there are > 1 new items
- QTest::newRow("insert 1, just before start")
- << 30 << 20.0 << false
- << 0 << 1 << ListRange();
- QTest::newRow("insert 1, way before start")
- << 30 << 20.0 << false
- << 0 << 1 << ListRange();
- QTest::newRow("insert multiple, just before start")
- << 30 << 100.0 << false
- << 0 << 3 << ListRange();
- QTest::newRow("insert multiple (< 1 row), just before start")
- << 30 << 100.0 << false
- << 0 << 2 << ListRange();
- QTest::newRow("insert multiple, way before start")
- << 30 << 100.0 << false
- << 0 << 3 << ListRange();
-
- QTest::newRow("insert 1 at start")
- << 30 << 0.0 << true
- << 0 << 1 << ListRange(0, 17);
- QTest::newRow("insert multiple at start")
- << 30 << 0.0 << true
- << 0 << 3 << ListRange(0, 17);
- QTest::newRow("insert multiple (> 1 row) at start")
- << 30 << 0.0 << true
- << 0 << 5 << ListRange(0, 17);
- QTest::newRow("insert 1 at start, content y not 0")
- << 30 << 60.0 << true // first visible is index 3
- << 3 << 1 << ListRange(0 + 3, 17 + 3);
- QTest::newRow("insert multiple at start, content y not 0")
- << 30 << 60.0 << true // first visible is index 3
- << 3 << 3 << ListRange(0 + 3, 17 + 3);
- QTest::newRow("insert multiple (> 1 row) at start, content y not 0")
- << 30 << 60.0 << true // first visible is index 3
- << 3 << 5 << ListRange(0 + 3, 17 + 3);
-
- QTest::newRow("insert 1 at start, to empty grid")
- << 0 << 0.0 << true
- << 0 << 1 << ListRange();
- QTest::newRow("insert multiple at start, to empty grid")
- << 0 << 0.0 << true
- << 0 << 3 << ListRange();
-
- QTest::newRow("insert 1 at middle")
- << 30 << 0.0 << true
- << 7 << 1 << ListRange(7, 17);
- QTest::newRow("insert multiple at middle")
- << 30 << 0.0 << true
- << 7 << 3 << ListRange(7, 17);
- QTest::newRow("insert multiple (> 1 row) at middle")
- << 30 << 0.0 << true
- << 7 << 5 << ListRange(7, 17);
-
- QTest::newRow("insert 1 at bottom")
- << 30 << 0.0 << true
- << 17 << 1 << ListRange(17, 17);
- QTest::newRow("insert multiple at bottom")
- << 30 << 0.0 << true
- << 17 << 3 << ListRange(17, 17);
- QTest::newRow("insert 1 at bottom, content y not 0")
- << 30 << 20.0 * 3 << true
- << 17 + 3 << 1 << ListRange(17 + 3, 17 + 3);
- QTest::newRow("insert multiple at bottom, content y not 0")
- << 30 << 20.0 * 3 << true
- << 17 + 3 << 3 << ListRange(17 + 3, 17 + 3);
-
-
- // items added after the last visible will not be animated in, since they
- // do not appear in the final view
- QTest::newRow("insert 1 after end")
- << 30 << 0.0 << false
- << 18 << 1 << ListRange();
- QTest::newRow("insert multiple after end")
- << 30 << 0.0 << false
- << 18 << 3 << ListRange();
-}
-
-void tst_QQuickGridView::moveTransitions()
-{
- QFETCH(int, initialItemCount);
- QFETCH(qreal, contentY);
- QFETCH(qreal, itemsOffsetAfterMove);
- QFETCH(int, moveFrom);
- QFETCH(int, moveTo);
- QFETCH(int, moveCount);
- QFETCH(ListRange, expectedDisplacedIndexes);
-
- // target and displaced items should pass through these points
- QPointF targetItems_transitionVia(-50, 50);
- QPointF displacedItems_transitionVia(100, 100);
-
- QaimModel model;
- for (int i = 0; i < initialItemCount; i++)
- model.addItem("Original item" + QString::number(i), "");
- QaimModel model_targetItems_transitionVia;
- QaimModel model_displacedItems_transitionVia;
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("model_targetItems_transitionVia", &model_targetItems_transitionVia);
- ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
- ctxt->setContextProperty("targetItems_transitionVia", targetItems_transitionVia);
- ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- canvas->setSource(testFileUrl("moveTransitions.qml"));
- canvas->show();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
- QQuickText *name;
-
- if (contentY != 0) {
- gridview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- }
-
- QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
-
- // Items moving to *or* from visible positions should be animated.
- // Otherwise, they should not be animated.
- QList<QPair<QString, QString> > expectedTargetData;
- QList<int> targetIndexes;
- for (int i=moveFrom; i<moveFrom+moveCount; i++) {
- int toIndex = moveTo + (i - moveFrom);
- int firstVisibleIndex = (contentY / 60) * 3;
- int lastVisibleIndex = (qCeil((contentY + gridview->height()) / 60.0)*3) - 1;
- if ((i >= firstVisibleIndex && i <= lastVisibleIndex)
- || (toIndex >= firstVisibleIndex && toIndex <= lastVisibleIndex)) {
- expectedTargetData << qMakePair(model.name(i), model.number(i));
- targetIndexes << i;
- }
- }
- // ViewTransition.index provides the indices that items are moving to, not from
- targetIndexes = adjustIndexesForMove(targetIndexes, moveFrom, moveTo, moveCount);
-
- // start animation
- model.moveItems(moveFrom, moveTo, moveCount);
-
- QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
- QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(),
- expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
-
- QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
-
- // check the target and displaced items were animated
- model_targetItems_transitionVia.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
- model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
-
- // check attached properties
- matchItemsAndIndexes(gridview->property("targetTrans_items").toMap(), model, targetIndexes);
- matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems);
- if (expectedDisplacedIndexes.isValid()) {
- // adjust expectedDisplacedIndexes to their final values after the move
- QList<int> displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, moveFrom, moveTo, moveCount);
- matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes);
- matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems);
- }
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // verify all items moved to the correct final positions
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::moveTransitions_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<qreal>("itemsOffsetAfterMove");
- QTest::addColumn<int>("moveFrom");
- QTest::addColumn<int>("moveTo");
- QTest::addColumn<int>("moveCount");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- QTest::newRow("move from above view, outside visible items, move 1") << 30 << 120.0 << 0.0
- << 1 << 10 << 1 << ListRange(6, 10);
- QTest::newRow("move from above view, outside visible items, move 1 (first item)") << 30 << 120.0 << 0.0
- << 0 << 10 << 1 << ListRange(6, 10);
- QTest::newRow("move from above view, outside visible items, move multiple") << 30 << 120.0 << 60.0
- << 1 << 10 << 3 << ListRange(13, 23);
- QTest::newRow("move from above view, mix of visible/non-visible") << 30 << 120.0 << 60.0
- << 1 << 10 << 6 << (ListRange(7, 15) + ListRange(16, 23));
- QTest::newRow("move from above view, mix of visible/non-visible (move first)") << 30 << 120.0 << 120.0
- << 0 << 10 << 6 << ListRange(16, 23);
-
- QTest::newRow("move within view, move 1 down") << 30 << 0.0 << 0.0
- << 1 << 10 << 1 << ListRange(2, 10);
- QTest::newRow("move within view, move 1 down, move first item") << 30 << 0.0 << 0.0
- << 0 << 10 << 1 << ListRange(1, 10);
- QTest::newRow("move within view, move 1 down, move first item, contentY not 0") << 30 << 120.0 << 0.0
- << 0+6 << 10+6 << 1 << ListRange(1+6, 10+6);
- QTest::newRow("move within view, move 1 down, to last item") << 30 << 0.0 << 0.0
- << 10 << 17 << 1 << ListRange(11, 17);
- QTest::newRow("move within view, move first->last") << 30 << 0.0 << 0.0
- << 0 << 17 << 1 << ListRange(1, 17);
-
- QTest::newRow("move within view, move multiple down") << 30 << 0.0 << 0.0
- << 1 << 10 << 3 << ListRange(4, 12);
- QTest::newRow("move within view, move multiple down, move first item") << 30 << 0.0 << 0.0
- << 0 << 10 << 3 << ListRange(3, 12);
- QTest::newRow("move within view, move multiple down, move first item, contentY not 0") << 30 << 60.0 << 0.0
- << 0+3 << 10+3 << 3 << ListRange(3+3, 12+3);
- QTest::newRow("move within view, move multiple down, displace last item") << 30 << 0.0 << 0.0
- << 5 << 15 << 3 << ListRange(8, 17);
- QTest::newRow("move within view, move multiple down, move first->last") << 30 << 0.0 << 0.0
- << 0 << 15 << 3 << ListRange(3, 17);
-
- QTest::newRow("move within view, move 1 up") << 30 << 0.0 << 0.0
- << 10 << 1 << 1 << ListRange(1, 9);
- QTest::newRow("move within view, move 1 up, move to first index") << 30 << 0.0 << 0.0
- << 10 << 0 << 1 << ListRange(0, 9);
- QTest::newRow("move within view, move 1 up, move to first index, contentY not 0") << 30 << 120.0 << 0.0
- << 10+6 << 0+6 << 1 << ListRange(0+6, 9+6);
- QTest::newRow("move within view, move 1 up, move to first index, contentY not on item border") << 30 << 80.0 << 0.0
- << 10+3 << 0+3 << 1 << ListRange(0+3, 9+3);
- QTest::newRow("move within view, move 1 up, move last item") << 30 << 0.0 << 0.0
- << 17 << 10 << 1 << ListRange(10, 16);
- QTest::newRow("move within view, move 1 up, move last->first") << 30 << 0.0 << 0.0
- << 17 << 0 << 1 << ListRange(0, 16);
-
- QTest::newRow("move within view, move multiple up") << 30 << 0.0 << 0.0
- << 10 << 1 << 3 << ListRange(1, 9);
- QTest::newRow("move within view, move multiple (> 1 row) up") << 30 << 0.0 << 0.0
- << 10 << 1 << 5 << ListRange(1, 9);
- QTest::newRow("move within view, move multiple up, move to first index") << 30 << 0.0 << 0.0
- << 10 << 0 << 3 << ListRange(0, 9);
- QTest::newRow("move within view, move multiple up, move to first index, contentY not 0") << 30 << 60.0 << 0.0
- << 10+3 << 0+3 << 3 << ListRange(0+3, 9+3);
- QTest::newRow("move within view, move multiple up (> 1 row), move to first index, contentY not on border") << 30 << 80.0 << 0.0
- << 10+3 << 0+3 << 5 << ListRange(0+3, 9+3);
- QTest::newRow("move within view, move multiple up, move last item") << 30 << 0.0 << 0.0
- << 15 << 5 << 3 << ListRange(5, 14);
- QTest::newRow("move within view, move multiple up, move last->first") << 30 << 0.0 << 0.0
- << 15 << 0 << 3 << ListRange(0, 14);
-
- QTest::newRow("move from below view, move 1 up") << 30 << 0.0 << 0.0
- << 20 << 5 << 1 << ListRange(5, 17);
- QTest::newRow("move from below view, move 1 up, move to top") << 30 << 0.0 << 0.0
- << 20 << 0 << 1 << ListRange(0, 17);
- QTest::newRow("move from below view, move 1 up, move to top, contentY not 0") << 30 << 60.0 << 0.0
- << 25 << 3 << 1 << ListRange(0+3, 17+3);
- QTest::newRow("move from below view, move multiple (> 1 row) up") << 30 << 0.0 << 0.0
- << 20 << 5 << 5 << ListRange(5, 17);
- QTest::newRow("move from below view, move multiple up, move to top") << 30 << 0.0 << 0.0
- << 20 << 0 << 3 << ListRange(0, 17);
- QTest::newRow("move from below view, move multiple up, move to top, contentY not 0") << 30 << 60.0 << 0.0
- << 25 << 3 << 3 << ListRange(0+3, 17+3);
-
- QTest::newRow("move from below view, move 1 up, move to bottom") << 30 << 0.0 << 0.0
- << 20 << 17 << 1 << ListRange(17, 17);
- QTest::newRow("move from below view, move 1 up, move to bottom, contentY not 0") << 30 << 60.0 << 0.0
- << 25 << 17+3 << 1 << ListRange(17+3, 17+3);
- QTest::newRow("move from below view, move multiple up, move to to bottom") << 30 << 0.0 << 0.0
- << 20 << 17 << 3 << ListRange(17, 17);
- QTest::newRow("move from below view, move multiple up, move to bottom, contentY not 0") << 30 << 60.0 << 0.0
- << 25 << 17+3 << 3 << ListRange(17+3, 17+3);
-}
-
-void tst_QQuickGridView::removeTransitions()
-{
- QFETCH(int, initialItemCount);
- QFETCH(bool, shouldAnimateTargets);
- QFETCH(qreal, contentY);
- QFETCH(int, removalIndex);
- QFETCH(int, removalCount);
- QFETCH(ListRange, expectedDisplacedIndexes);
-
- // added items should end here
- QPointF targetItems_transitionTo(-50, -50);
-
- // displaced items should pass through this points
- QPointF displacedItems_transitionVia(100, 100);
-
- QaimModel model;
- for (int i = 0; i < initialItemCount; i++)
- model.addItem("Original item" + QString::number(i), "");
- QaimModel model_targetItems_transitionTo;
- QaimModel model_displacedItems_transitionVia;
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("model_targetItems_transitionTo", &model_targetItems_transitionTo);
- ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
- ctxt->setContextProperty("targetItems_transitionTo", targetItems_transitionTo);
- ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- canvas->setSource(testFileUrl("removeTransitions.qml"));
- canvas->show();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- if (contentY != 0) {
- gridview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- }
-
- QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
-
- // only target items that are visible should be animated
- QList<QPair<QString, QString> > expectedTargetData;
- QList<int> targetIndexes;
- if (shouldAnimateTargets) {
- for (int i=removalIndex; i<removalIndex+removalCount; i++) {
- int firstVisibleIndex = (contentY / 60.0)*3;
- int lastVisibleIndex = (qCeil((contentY + gridview->height()) / 60.0)*3) - 1;
- if (i >= firstVisibleIndex && i <= lastVisibleIndex) {
- expectedTargetData << qMakePair(model.name(i), model.number(i));
- targetIndexes << i;
- }
- }
- QVERIFY(expectedTargetData.count() > 0);
- }
-
- // calculate targetItems and expectedTargets before model changes
- QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
- QVariantMap expectedTargets;
- for (int i=0; i<targetIndexes.count(); i++)
- expectedTargets[model.name(targetIndexes[i])] = targetIndexes[i];
-
- // start animation
- model.removeItems(removalIndex, removalCount);
- QTRY_COMPARE(model.count(), gridview->count());
-
- if (shouldAnimateTargets || expectedDisplacedIndexes.isValid()) {
- QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
- QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(),
- expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
-
- // check the target and displaced items were animated
- model_targetItems_transitionTo.matchAgainst(expectedTargetData, "wasn't animated to target 'to' pos", "shouldn't have been animated to target 'to' pos");
- model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
-
- // check attached properties
- QCOMPARE(gridview->property("targetTrans_items").toMap(), expectedTargets);
- matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems);
- if (expectedDisplacedIndexes.isValid()) {
- // adjust expectedDisplacedIndexes to their final values after the move
- QList<int> displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, removalIndex, removalCount);
- matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes);
- matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems);
- }
- } else {
- QTRY_COMPARE(model_targetItems_transitionTo.count(), 0);
- QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0);
- }
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int itemCount = items.count();
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- int index = e.evaluate().toInt();
- if (firstVisibleIndex < 0 && items[i]->y() >= contentY)
- firstVisibleIndex = index;
- else if (index < 0)
- itemCount--; // exclude deleted items
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // verify all items moved to the correct final positions
- for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), contentY + ((i-firstVisibleIndex)/3) * 60.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::removeTransitions_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<bool>("shouldAnimateTargets");
- QTest::addColumn<int>("removalIndex");
- QTest::addColumn<int>("removalCount");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- // All items that are visible following the remove operation should be animated.
- // Remove targets that are outside of the view should not be animated.
-
- // For a GridView, removing any number of items other than a full row before the start
- // should displace all items in the view
- QTest::newRow("remove 1 before start")
- << 30 << 120.0 << false
- << 2 << 1 << ListRange(6, 24); // 6-24 are displaced
- QTest::newRow("remove 1 row, before start")
- << 30 << 120.0 << false
- << 3 << 3 << ListRange();
- QTest::newRow("remove between 1-2 rows, before start")
- << 30 << 120.0 << false
- << 0 << 5 << ListRange(6, 25);
- QTest::newRow("remove 2 rows, before start")
- << 30 << 120.0 << false
- << 0 << 6 << ListRange();
- QTest::newRow("remove mix of before and after start")
- << 30 << 60.0 << true
- << 2 << 3 << ListRange(5, 23); // 5-23 are displaced into view
-
-
- QTest::newRow("remove 1 from start")
- << 30 << 0.0 << true
- << 0 << 1 << ListRange(1, 18); // 1-18 are displaced into view
- QTest::newRow("remove multiple from start")
- << 30 << 0.0 << true
- << 0 << 3 << ListRange(3, 20); // 3-18 are displaced into view
- QTest::newRow("remove 1 from start, content y not 0")
- << 30 << 60.0 << true
- << 3 << 1 << ListRange(1 + 3, 18 + 3);
- QTest::newRow("remove multiple from start, content y not 0")
- << 30 << 60.0 << true
- << 3 << 3 << ListRange(3 + 3, 20 + 3);
-
-
- QTest::newRow("remove 1 from middle")
- << 30 << 0.0 << true
- << 5 << 1 << ListRange(6, 18);
- QTest::newRow("remove multiple from middle")
- << 30 << 0.0 << true
- << 5 << 3 << ListRange(8, 20);
-
-
- QTest::newRow("remove 1 from bottom")
- << 30 << 0.0 << true
- << 17 << 1 << ListRange(18, 18);
- QTest::newRow("remove multiple (1 row) from bottom")
- << 30 << 0.0 << true
- << 15 << 3 << ListRange(18, 20);
- QTest::newRow("remove multiple (> 1 row) from bottom")
- << 30 << 0.0 << true
- << 15 << 5 << ListRange(20, 22);
- QTest::newRow("remove 1 from bottom, content y not 0")
- << 30 << 60.0 << true
- << 17 + 3 << 1 << ListRange(18 + 3, 18 + 3);
- QTest::newRow("remove multiple (1 row) from bottom, content y not 0")
- << 30 << 60.0 << true
- << 15 + 3 << 3 << ListRange(18 + 3, 20 + 3);
-
-
- QTest::newRow("remove 1 after end")
- << 30 << 0.0 << false
- << 18 << 1 << ListRange();
- QTest::newRow("remove multiple after end")
- << 30 << 0.0 << false
- << 18 << 3 << ListRange();
-}
-
-void tst_QQuickGridView::multipleTransitions()
-{
- // Tests that if you interrupt a transition in progress with another action that
- // cancels the previous transition, the resulting items are still placed correctly.
-
- QFETCH(int, initialCount);
- QFETCH(qreal, contentY);
- QFETCH(QList<ListChange>, changes);
-
- // add transitions on the left, moves on the right
- QPointF addTargets_transitionFrom(-50, -50);
- QPointF addDisplaced_transitionFrom(-50, 50);
- QPointF moveTargets_transitionFrom(50, -50);
- QPointF moveDisplaced_transitionFrom(50, 50);
-
- QmlListModel model;
- for (int i = 0; i < initialCount; i++)
- model.addItem("Original item" + QString::number(i), "");
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("addTargets_transitionFrom", addTargets_transitionFrom);
- ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom);
- ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom);
- ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom);
- canvas->setSource(testFileUrl("multipleTransitions.qml"));
- canvas->show();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
-
- int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt();
-
- QList<QPair<QString, QString> > targetItems;
- for (int i=0; i<changes.count(); i++) {
- switch (changes[i].type) {
- case ListChange::Inserted:
- {
- for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
- targetItems << qMakePair(QString("new item %1").arg(j), QString::number(j));
- model.insertItems(changes[i].index, targetItems);
- QTRY_COMPARE(model.count(), gridview->count());
- QTRY_VERIFY(gridview->property("runningAddTargets").toBool());
- QTRY_VERIFY(gridview->property("runningAddDisplaced").toBool());
- if (i == changes.count() - 1) {
- QTRY_VERIFY(!gridview->property("runningAddTargets").toBool());
- QTRY_VERIFY(!gridview->property("runningAddDisplaced").toBool());
- } else {
- QTest::qWait(timeBetweenActions);
- }
- break;
- }
- case ListChange::Removed:
- for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
- targetItems << qMakePair(model.name(i), model.number(i));
- model.removeItems(changes[i].index, changes[i].count);
- QTRY_COMPARE(model.count(), gridview->count());
- QTRY_VERIFY(gridview->property("runningRemoveTargets").toBool());
- QTRY_VERIFY(gridview->property("runningRemoveDisplaced").toBool());
- if (i == changes.count() - 1) {
- QTRY_VERIFY(!gridview->property("runningRemoveTargets").toBool());
- QTRY_VERIFY(!gridview->property("runningRemoveDisplaced").toBool());
- } else {
- QTest::qWait(timeBetweenActions);
- }
- break;
- case ListChange::Moved:
- for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
- targetItems << qMakePair(model.name(i), model.number(i));
- model.moveItems(changes[i].index, changes[i].to, changes[i].count);
- QTRY_VERIFY(gridview->property("runningMoveTargets").toBool());
- QTRY_VERIFY(gridview->property("runningMoveDisplaced").toBool());
- if (i == changes.count() - 1) {
- QTRY_VERIFY(!gridview->property("runningMoveTargets").toBool());
- QTRY_VERIFY(!gridview->property("runningMoveDisplaced").toBool());
- } else {
- QTest::qWait(timeBetweenActions);
- }
- break;
- case ListChange::SetCurrent:
- gridview->setCurrentIndex(changes[i].index);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- break;
- case ListChange::SetContentY:
- gridview->setContentY(changes[i].pos);
- QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
- break;
- }
- }
- QCOMPARE(gridview->count(), model.count());
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // verify all items moved to the correct final positions
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), (i%3)*80.0);
- QCOMPARE(item->y(), (i/3)*60.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::multipleTransitions_data()
-{
- QTest::addColumn<int>("initialCount");
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<QList<ListChange> >("changes");
-
- // the added item and displaced items should move to final dest correctly
- QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList<ListChange>()
- << ListChange::insert(0, 1)
- << ListChange::move(0, 3, 1)
- );
-
- // items affected by the add should change from move to add transition
- QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList<ListChange>()
- << ListChange::move(1, 10, 3)
- << ListChange::insert(0, 1)
- );
-
- // items should be placed correctly if you trigger a transition then refill for that index
- QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList<ListChange>()
- << ListChange::insert(0, 1)
- << ListChange::setContentY(160.0)
- << ListChange::setContentY(0.0)
- << ListChange::insert(0, 1)
- );
-}
-
-void tst_QQuickGridView::cacheBuffer()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 90; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testRightToLeft", QVariant(false));
- ctxt->setContextProperty("testTopToBottom", QVariant(false));
-
- canvas->setSource(testFileUrl("gridview1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
- QVERIFY(gridview != 0);
-
- QQuickItem *contentItem = gridview->contentItem();
- QVERIFY(contentItem != 0);
- QVERIFY(gridview->delegate() != 0);
- QVERIFY(gridview->model() != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_COMPARE(item->x(), (i%3)*80.0);
- QTRY_COMPARE(item->y(), (i/3)*60.0);
- }
-
- QDeclarativeIncubationController controller;
- canvas->engine()->setIncubationController(&controller);
-
- canvas->rootObject()->setProperty("cacheBuffer", 200);
- QTRY_VERIFY(gridview->cacheBuffer() == 200);
-
- // items will be created one at a time
- for (int i = itemCount; i < qMin(itemCount+9,model.count()); ++i) {
- QVERIFY(findItem<QQuickItem>(gridview, "wrapper", i) == 0);
- QQuickItem *item = 0;
- while (!item) {
- bool b = false;
- controller.incubateWhile(&b);
- item = findItem<QQuickItem>(gridview, "wrapper", i);
- }
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- int newItemCount = 0;
- newItemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < newItemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.0);
- QTRY_COMPARE(item->y(), (i/3)*60.0);
- }
-
- // move view and confirm items in view are visible immediately and outside are created async
- gridview->setContentY(300);
-
- for (int i = 15; i < 34; ++i) { // 34 due to staggered item creation
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY(item);
- QTRY_COMPARE(item->x(), (i%3)*80.0);
- QTRY_COMPARE(item->y(), (i/3)*60.0);
- }
-
- QVERIFY(findItem<QQuickItem>(gridview, "wrapper", 34) == 0);
-
- // ensure buffered items are created
- for (int i = 34; i < qMin(44,model.count()); ++i) {
- QQuickItem *item = 0;
- while (!item) {
- qGuiApp->processEvents(); // allow refill to happen
- bool b = false;
- controller.incubateWhile(&b);
- item = findItem<QQuickItem>(gridview, "wrapper", i);
- }
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::asynchronous()
-{
- QQuickView *canvas = createView();
- canvas->show();
- QDeclarativeIncubationController controller;
- canvas->engine()->setIncubationController(&controller);
-
- canvas->setSource(testFile("asyncloader.qml"));
-
- QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootObject);
-
- QQuickGridView *gridview = 0;
- while (!gridview) {
- bool b = false;
- controller.incubateWhile(&b);
- gridview = rootObject->findChild<QQuickGridView*>("view");
- }
-
- // items will be created one at a time
- for (int i = 0; i < 12; ++i) {
- QVERIFY(findItem<QQuickItem>(gridview, "wrapper", i) == 0);
- QQuickItem *item = 0;
- while (!item) {
- bool b = false;
- controller.incubateWhile(&b);
- item = findItem<QQuickItem>(gridview, "wrapper", i);
- }
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- // verify positioning
- QQuickItem *contentItem = gridview->contentItem();
- for (int i = 0; i < 12; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item->x() == (i%3)*100);
- QVERIFY(item->y() == (i/3)*100);
- }
-
- delete canvas;
-}
-
-void tst_QQuickGridView::unrequestedVisibility()
-{
- QaimModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testWrap", QVariant(false));
-
- canvas->setSource(testFileUrl("unrequestedItems.qml"));
-
- canvas->show();
-
- qApp->processEvents();
-
- QQuickGridView *leftview = findItem<QQuickGridView>(canvas->rootObject(), "leftGrid");
- QTRY_VERIFY(leftview != 0);
-
- QQuickGridView *rightview = findItem<QQuickGridView>(canvas->rootObject(), "rightGrid");
- QTRY_VERIFY(rightview != 0);
-
- QQuickItem *leftContent = leftview->contentItem();
- QTRY_VERIFY(leftContent != 0);
-
- QQuickItem *rightContent = rightview->contentItem();
- QTRY_VERIFY(rightContent != 0);
-
- rightview->setCurrentIndex(12);
-
- QTRY_COMPARE(leftview->contentY(), 0.0);
- QTRY_COMPARE(rightview->contentY(), 240.0);
-
- QQuickItem *item;
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 11));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 11));
- QCOMPARE(item->isVisible(), true);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 9));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 10));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 4));
- QCOMPARE(item->isVisible(), true);
-
- rightview->setCurrentIndex(0);
-
- QTRY_COMPARE(leftview->contentY(), 0.0);
- QTRY_COMPARE(rightview->contentY(), 0.0);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
- QTRY_COMPARE(item->isVisible(), true);
-
- QVERIFY(!findItem<QQuickItem>(leftContent, "wrapper", 11));
- QVERIFY(!findItem<QQuickItem>(rightContent, "wrapper", 11));
-
- leftview->setCurrentIndex(12);
-
- QTRY_COMPARE(leftview->contentY(), 240.0);
- QTRY_COMPARE(rightview->contentY(), 0.0);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QTRY_COMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), true);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 11));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 11));
- QCOMPARE(item->isVisible(), false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
- QCOMPARE(item->isVisible(), false);
-
- // move a non-visible item into view
- model.moveItems(10, 9, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QTRY_VERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), true);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 11));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 11));
- QCOMPARE(item->isVisible(), false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
- QCOMPARE(item->isVisible(), false);
-
- // move a visible item out of view
- model.moveItems(5, 3, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
- QCOMPARE(item->isVisible(), false);
-
- // move a non-visible item into view
- model.moveItems(3, 5, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
- QCOMPARE(item->isVisible(), false);
-
- // move a visible item out of view
- model.moveItems(9, 10, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
- QCOMPARE(item->isVisible(), false);
-
- // move a non-visible item into view
- model.moveItems(10, 9, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
- QCOMPARE(item->isVisible(), false);
-
- delete canvas;
-}
-
-QList<int> tst_QQuickGridView::toIntList(const QVariantList &list)
-{
- QList<int> ret;
- bool ok = true;
- for (int i=0; i<list.count(); i++) {
- ret << list[i].toInt(&ok);
- if (!ok)
- qWarning() << "tst_QQuickGridView::toIntList(): not a number:" << list[i];
- }
-
- return ret;
-}
-
-void tst_QQuickGridView::matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes)
-{
- for (int i=0; i<indexLists.count(); i++) {
- QSet<int> current = indexLists[i].value<QList<int> >().toSet();
- if (current != expectedIndexes.toSet())
- qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes;
- QCOMPARE(current, expectedIndexes.toSet());
- }
-}
-
-void tst_QQuickGridView::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes)
-{
- for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) {
- QVERIFY(it.value().type() == QVariant::Int);
- QString name = it.key();
- int itemIndex = it.value().toInt();
- QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex)));
- if (model.name(itemIndex) != name)
- qDebug() << itemIndex;
- QCOMPARE(model.name(itemIndex), name);
- }
- QCOMPARE(items.count(), expectedIndexes.count());
-}
-
-void tst_QQuickGridView::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems)
-{
- for (int i=0; i<itemLists.count(); i++) {
- QVariantList current = itemLists[i].toList();
- for (int j=0; j<current.count(); j++) {
- QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
- QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j)));
- QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j)));
- }
- QCOMPARE(current.count(), expectedItems.count());
- }
-}
-
-QTEST_MAIN(tst_QQuickGridView)
-
-#include "tst_qquickgridview.moc"
-
diff --git a/tests/auto/qtquick2/qquickimage/qquickimage.pro b/tests/auto/qtquick2/qquickimage/qquickimage.pro
deleted file mode 100644
index 43e95a2bed..0000000000
--- a/tests/auto/qtquick2/qquickimage/qquickimage.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickimage
-macx:CONFIG -= app_bundle
-
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qquickimage.cpp \
- ../../shared/testhttpserver.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qquickimage/tst_qquickimage.cpp b/tests/auto/qtquick2/qquickimage/tst_qquickimage.cpp
deleted file mode 100644
index 7602f1b1d5..0000000000
--- a/tests/auto/qtquick2/qquickimage/tst_qquickimage.cpp
+++ /dev/null
@@ -1,749 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QTextDocument>
-#include <QTcpServer>
-#include <QTcpSocket>
-#include <QDir>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/qquickview.h>
-#include <private/qquickimage_p.h>
-#include <private/qquickimagebase_p.h>
-#include <private/qquickloader_p.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtTest/QSignalSpy>
-#include <QtGui/QPainter>
-#include <QtGui/QImageReader>
-
-#include "../../shared/util.h"
-#include "../../shared/testhttpserver.h"
-#include "../shared/visualtestutil.h"
-
-#define SERVER_PORT 14451
-#define SERVER_ADDR "http://127.0.0.1:14451"
-
-
-using namespace QQuickVisualTestUtil;
-
-Q_DECLARE_METATYPE(QQuickImageBase::Status)
-
-class tst_qquickimage : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquickimage();
-
-private slots:
- void noSource();
- void imageSource();
- void imageSource_data();
- void clearSource();
- void resized();
- void preserveAspectRatio();
- void smooth();
- void mirror();
- void svg();
- void geometry();
- void geometry_data();
- void big();
- void tiling_QTBUG_6716();
- void tiling_QTBUG_6716_data();
- void noLoading();
- void paintedWidthHeight();
- void sourceSize_QTBUG_14303();
- void sourceSize_QTBUG_16389();
- void nullPixmapPaint();
- void imageCrash_QTBUG_22125();
- void sourceSize_data();
- void sourceSize();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qquickimage::tst_qquickimage()
-{
-}
-
-void tst_qquickimage::noSource()
-{
- QString componentStr = "import QtQuick 2.0\nImage { source: \"\" }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->source(), QUrl());
- QVERIFY(obj->status() == QQuickImage::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
- QCOMPARE(obj->progress(), 0.0);
-
- delete obj;
-}
-
-void tst_qquickimage::imageSource_data()
-{
- QTest::addColumn<QString>("source");
- QTest::addColumn<double>("width");
- QTest::addColumn<double>("height");
- QTest::addColumn<bool>("remote");
- QTest::addColumn<bool>("async");
- QTest::addColumn<bool>("cache");
- QTest::addColumn<QString>("error");
-
- QTest::newRow("local") << testFileUrl("colors.png").toString() << 120.0 << 120.0 << false << false << true << "";
- QTest::newRow("local no cache") << testFileUrl("colors.png").toString() << 120.0 << 120.0 << false << false << false << "";
- QTest::newRow("local async") << testFileUrl("colors1.png").toString() << 120.0 << 120.0 << false << true << true << "";
- QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << 0.0 << 0.0 << false
- << false << true << "file::2:1: QML Image: Cannot open: " + testFileUrl("no-such-file.png").toString();
- QTest::newRow("local async not found") << testFileUrl("no-such-file-1.png").toString() << 0.0 << 0.0 << false
- << true << true << "file::2:1: QML Image: Cannot open: " + testFileUrl("no-such-file-1.png").toString();
- QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << true << "";
- QTest::newRow("remote redirected") << SERVER_ADDR "/oldcolors.png" << 120.0 << 120.0 << true << false << false << "";
- if (QImageReader::supportedImageFormats().contains("svg"))
- QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << false << "";
-
- QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true
- << false << true << "file::2:1: QML Image: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found";
-
-}
-
-void tst_qquickimage::imageSource()
-{
- QFETCH(QString, source);
- QFETCH(double, width);
- QFETCH(double, height);
- QFETCH(bool, remote);
- QFETCH(bool, async);
- QFETCH(bool, cache);
- QFETCH(QString, error);
-
- TestHTTPServer server(SERVER_PORT);
- if (remote) {
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
- server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
- }
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
-
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + source + "\"; asynchronous: "
- + (async ? QLatin1String("true") : QLatin1String("false")) + "; cache: "
- + (cache ? QLatin1String("true") : QLatin1String("false")) + " }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
-
- if (async)
- QVERIFY(obj->asynchronous() == true);
- else
- QVERIFY(obj->asynchronous() == false);
-
- if (cache)
- QVERIFY(obj->cache() == true);
- else
- QVERIFY(obj->cache() == false);
-
- if (remote || async)
- QTRY_VERIFY(obj->status() == QQuickImage::Loading);
-
- QCOMPARE(obj->source(), remote ? source : QUrl(source));
-
- if (error.isEmpty()) {
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QCOMPARE(obj->width(), qreal(width));
- QCOMPARE(obj->height(), qreal(height));
- QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
- QCOMPARE(obj->progress(), 1.0);
- } else {
- QTRY_VERIFY(obj->status() == QQuickImage::Error);
- }
-
- delete obj;
-}
-
-void tst_qquickimage::clearSource()
-{
- QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->status() == QQuickImage::Ready);
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
- QCOMPARE(obj->progress(), 1.0);
-
- ctxt->setContextProperty("srcImage", "");
- QVERIFY(obj->source().isEmpty());
- QVERIFY(obj->status() == QQuickImage::Null);
- QCOMPARE(obj->width(), 0.);
- QCOMPARE(obj->height(), 0.);
- QCOMPARE(obj->progress(), 0.0);
-
- delete obj;
-}
-
-void tst_qquickimage::resized()
-{
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + testFile("colors.png") + "\"; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
- delete obj;
-}
-
-
-void tst_qquickimage::preserveAspectRatio()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->show();
-
- canvas->setSource(testFileUrl("aspectratio.qml"));
- QQuickImage *image = qobject_cast<QQuickImage*>(canvas->rootObject());
- QVERIFY(image != 0);
- image->setWidth(80.0);
- QCOMPARE(image->width(), 80.);
- QCOMPARE(image->height(), 80.);
-
- canvas->setSource(testFileUrl("aspectratio.qml"));
- image = qobject_cast<QQuickImage*>(canvas->rootObject());
- image->setHeight(60.0);
- QVERIFY(image != 0);
- QCOMPARE(image->height(), 60.);
- QCOMPARE(image->width(), 60.);
- delete canvas;
-}
-
-void tst_qquickimage::smooth()
-{
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + testFile("colors.png") + "\"; smooth: true; width: 300; height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.);
- QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->smooth(), true);
- QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
-
- delete obj;
-}
-
-void tst_qquickimage::mirror()
-{
- QSKIP("Test is broken on multiple levels, will need incremental fixes");
-
- QMap<QQuickImage::FillMode, QImage> screenshots;
- QList<QQuickImage::FillMode> fillModes;
- fillModes << QQuickImage::Stretch << QQuickImage::PreserveAspectFit << QQuickImage::PreserveAspectCrop
- << QQuickImage::Tile << QQuickImage::TileVertically << QQuickImage::TileHorizontally;
-
- qreal width = 300;
- qreal height = 250;
-
- foreach (QQuickImage::FillMode fillMode, fillModes) {
- QQuickView *canvas = new QQuickView;
- canvas->setSource(testFileUrl("mirror.qml"));
-
- QQuickImage *obj = canvas->rootObject()->findChild<QQuickImage*>("image");
- QVERIFY(obj != 0);
-
- obj->setFillMode(fillMode);
- obj->setProperty("mirror", true);
- canvas->show();
-
- QImage screenshot = canvas->grabFrameBuffer();
- screenshots[fillMode] = screenshot;
- delete canvas;
- }
-
- foreach (QQuickImage::FillMode fillMode, fillModes) {
- QPixmap srcPixmap;
- QVERIFY(srcPixmap.load(testFile("pattern.png")));
-
- QPixmap expected(width, height);
- expected.fill();
- QPainter p_e(&expected);
- QTransform transform;
- transform.translate(width, 0).scale(-1, 1.0);
- p_e.setTransform(transform);
-
- switch (fillMode) {
- case QQuickImage::Stretch:
- p_e.drawPixmap(QRect(0, 0, width, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
- break;
- case QQuickImage::PreserveAspectFit:
- p_e.drawPixmap(QRect(25, 0, height, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
- break;
- case QQuickImage::PreserveAspectCrop:
- {
- qreal ratio = width/srcPixmap.width(); // width is the longer side
- QRect rect(0, 0, srcPixmap.width()*ratio, srcPixmap.height()*ratio);
- rect.moveCenter(QRect(0, 0, width, height).center());
- p_e.drawPixmap(rect, srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
- break;
- }
- case QQuickImage::Tile:
- p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap);
- break;
- case QQuickImage::TileVertically:
- transform.scale(width / srcPixmap.width(), 1.0);
- p_e.setTransform(transform);
- p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap);
- break;
- case QQuickImage::TileHorizontally:
- transform.scale(1.0, height / srcPixmap.height());
- p_e.setTransform(transform);
- p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap);
- break;
- case QQuickImage::Pad:
- break;
- }
-
- QImage img = expected.toImage();
- QEXPECT_FAIL("", "QTBUG-21005 fails", Continue);
- QCOMPARE(screenshots[fillMode], img);
- }
-}
-
-void tst_qquickimage::svg()
-{
- if (!QImageReader::supportedImageFormats().contains("svg"))
- QSKIP("svg support not available");
-
- QString src = testFileUrl("heart.svg").toString();
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; sourceSize.width: 300; sourceSize.height: 300 }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 300.0);
- QCOMPARE(obj->height(), 300.0);
- obj->setSourceSize(QSize(200,200));
-
- QCOMPARE(obj->width(), 200.0);
- QCOMPARE(obj->height(), 200.0);
- delete obj;
-}
-
-void tst_qquickimage::geometry_data()
-{
- QTest::addColumn<QString>("fillMode");
- QTest::addColumn<bool>("explicitWidth");
- QTest::addColumn<bool>("explicitHeight");
- QTest::addColumn<double>("itemWidth");
- QTest::addColumn<double>("paintedWidth");
- QTest::addColumn<double>("boundingWidth");
- QTest::addColumn<double>("itemHeight");
- QTest::addColumn<double>("paintedHeight");
- QTest::addColumn<double>("boundingHeight");
-
- // tested image has width 200, height 100
-
- // bounding rect and item rect are equal with fillMode PreserveAspectFit, painted rect may be smaller if the aspect ratio doesn't match
- QTest::newRow("PreserveAspectFit") << "PreserveAspectFit" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0;
- QTest::newRow("PreserveAspectFit explicit width 300") << "PreserveAspectFit" << true << false << 300.0 << 200.0 << 300.0 << 100.0 << 100.0 << 100.0;
- QTest::newRow("PreserveAspectFit explicit height 400") << "PreserveAspectFit" << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 100.0 << 400.0;
- QTest::newRow("PreserveAspectFit explicit width 300, height 400") << "PreserveAspectFit" << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 150.0 << 400.0;
-
- // bounding rect and painted rect are equal with fillMode PreserveAspectCrop, item rect may be smaller if the aspect ratio doesn't match
- QTest::newRow("PreserveAspectCrop") << "PreserveAspectCrop" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0;
- QTest::newRow("PreserveAspectCrop explicit width 300") << "PreserveAspectCrop" << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 150.0 << 150.0;
- QTest::newRow("PreserveAspectCrop explicit height 400") << "PreserveAspectCrop" << false << true << 200.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0;
- QTest::newRow("PreserveAspectCrop explicit width 300, height 400") << "PreserveAspectCrop" << true << true << 300.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0;
-
- // bounding rect, painted rect and item rect are equal in stretching and tiling images
- QStringList fillModes;
- fillModes << "Stretch" << "Tile" << "TileVertically" << "TileHorizontally";
- foreach (QString fillMode, fillModes) {
- QTest::newRow(fillMode.toLatin1()) << fillMode << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0;
- QTest::newRow(QString(fillMode + " explicit width 300").toLatin1()) << fillMode << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 100.0 << 100.0;
- QTest::newRow(QString(fillMode + " explicit height 400").toLatin1()) << fillMode << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 400.0 << 400.0;
- QTest::newRow(QString(fillMode + " explicit width 300, height 400").toLatin1()) << fillMode << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 400.0 << 400.0;
- }
-}
-
-void tst_qquickimage::geometry()
-{
- QFETCH(QString, fillMode);
- QFETCH(bool, explicitWidth);
- QFETCH(bool, explicitHeight);
- QFETCH(double, itemWidth);
- QFETCH(double, itemHeight);
- QFETCH(double, paintedWidth);
- QFETCH(double, paintedHeight);
- QFETCH(double, boundingWidth);
- QFETCH(double, boundingHeight);
-
- QString src = testFileUrl("rect.png").toString();
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; fillMode: Image." + fillMode + "; ";
-
- if (explicitWidth)
- componentStr.append("width: 300; ");
- if (explicitHeight)
- componentStr.append("height: 400; ");
- componentStr.append("}");
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->width(), itemWidth);
- QCOMPARE(obj->paintedWidth(), paintedWidth);
- QCOMPARE(obj->boundingRect().width(), boundingWidth);
-
- QCOMPARE(obj->height(), itemHeight);
- QCOMPARE(obj->paintedHeight(), paintedHeight);
- QCOMPARE(obj->boundingRect().height(), boundingHeight);
- delete obj;
-}
-
-void tst_qquickimage::big()
-{
- // If the JPEG loader does not implement scaling efficiently, it would
- // have to build a 400 MB image. That would be a bug in the JPEG loader.
-
- QString src = testFileUrl("big.jpeg").toString();
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 100; sourceSize.height: 256 }";
-
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 100.0);
- QCOMPARE(obj->height(), 256.0);
-
- delete obj;
-}
-
-// As tiling_QTBUG_6716 doesn't complete, it doesn't delete the
-// canvas which causes leak warnings. Use this delete on stack
-// destruction pattern to work around this.
-template<typename T>
-struct AutoDelete {
- AutoDelete(T *t) : t(t) {}
- ~AutoDelete() { delete t; }
-private:
- T *t;
-};
-
-void tst_qquickimage::tiling_QTBUG_6716()
-{
- QSKIP("Test is broken on multiple levels, will need incremental fixes");
-
- QFETCH(QString, source);
-
- QQuickView *canvas = new QQuickView(0);
- AutoDelete<QQuickView> del(canvas);
-
- canvas->setSource(testFileUrl(source));
- canvas->show();
- qApp->processEvents();
-
- QQuickImage *tiling = findItem<QQuickImage>(canvas->rootObject(), "tiling");
-
- QVERIFY(tiling != 0);
- QImage img = canvas->grabFrameBuffer();
- for (int x = 0; x < tiling->width(); ++x) {
- for (int y = 0; y < tiling->height(); ++y) {
- QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0));
- }
- }
-
- delete canvas;
-}
-
-void tst_qquickimage::tiling_QTBUG_6716_data()
-{
- QTest::addColumn<QString>("source");
- QTest::newRow("vertical_tiling") << "vtiling.qml";
- QTest::newRow("horizontal_tiling") << "htiling.qml";
-}
-
-void tst_qquickimage::noLoading()
-{
- qRegisterMetaType<QQuickImageBase::Status>();
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
- server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
-
- QString componentStr = "import QtQuick 2.0\nImage { source: srcImage; cache: true }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", testFileUrl("heart.png"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QVERIFY(obj->status() == QQuickImage::Ready);
-
- QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &)));
- QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal)));
- QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status)));
-
- // Loading local file
- ctxt->setContextProperty("srcImage", testFileUrl("green.png"));
- QTRY_VERIFY(obj->status() == QQuickImage::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) + "/rect.png");
- QTRY_VERIFY(obj->status() == QQuickImage::Loading);
- QTRY_VERIFY(obj->progress() == 0.0);
- QTRY_VERIFY(obj->status() == QQuickImage::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", testFileUrl("green.png"));
- ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png");
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
- QTRY_VERIFY(obj->progress() == 1.0);
- QTRY_COMPARE(sourceSpy.count(), 4);
- QTRY_COMPARE(progressSpy.count(), 2);
- QTRY_COMPARE(statusSpy.count(), 2);
-
- delete obj;
-}
-
-void tst_qquickimage::paintedWidthHeight()
-{
- {
- QString src = testFileUrl("heart.png").toString();
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 200; height: 25; fillMode: Image.PreserveAspectFit }";
-
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 200.0);
- QCOMPARE(obj->height(), 25.0);
- QCOMPARE(obj->paintedWidth(), 25.0);
- QCOMPARE(obj->paintedHeight(), 25.0);
-
- delete obj;
- }
-
- {
- QString src = testFileUrl("heart.png").toString();
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 26; height: 175; fillMode: Image.PreserveAspectFit }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
- QVERIFY(obj != 0);
- QCOMPARE(obj->width(), 26.0);
- QCOMPARE(obj->height(), 175.0);
- QCOMPARE(obj->paintedWidth(), 26.0);
- QCOMPARE(obj->paintedHeight(), 26.0);
-
- delete obj;
- }
-}
-
-void tst_qquickimage::sourceSize_QTBUG_14303()
-{
- QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }";
- QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", testFileUrl("heart200.png"));
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
-
- QSignalSpy sourceSizeSpy(obj, SIGNAL(sourceSizeChanged()));
-
- QTRY_VERIFY(obj != 0);
- QTRY_VERIFY(obj->status() == QQuickImage::Ready);
-
- QTRY_COMPARE(obj->sourceSize().width(), 200);
- QTRY_COMPARE(obj->sourceSize().height(), 200);
- QTRY_COMPARE(sourceSizeSpy.count(), 0);
-
- ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
- QTRY_COMPARE(obj->sourceSize().width(), 120);
- QTRY_COMPARE(obj->sourceSize().height(), 120);
- QTRY_COMPARE(sourceSizeSpy.count(), 1);
-
- ctxt->setContextProperty("srcImage", testFileUrl("heart200.png"));
- QTRY_COMPARE(obj->sourceSize().width(), 200);
- QTRY_COMPARE(obj->sourceSize().height(), 200);
- QTRY_COMPARE(sourceSizeSpy.count(), 2);
-
- delete obj;
-}
-
-void tst_qquickimage::sourceSize_QTBUG_16389()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(testFileUrl("qtbug_16389.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickImage *image = findItem<QQuickImage>(canvas->rootObject(), "iconImage");
- QQuickItem *handle = findItem<QQuickItem>(canvas->rootObject(), "blueHandle");
-
- QCOMPARE(image->sourceSize().width(), 200);
- QCOMPARE(image->sourceSize().height(), 200);
- QCOMPARE(image->paintedWidth(), 0.0);
- QCOMPARE(image->paintedHeight(), 0.0);
-
- handle->setY(20);
-
- QCOMPARE(image->sourceSize().width(), 200);
- QCOMPARE(image->sourceSize().height(), 200);
- QCOMPARE(image->paintedWidth(), 20.0);
- QCOMPARE(image->paintedHeight(), 20.0);
-
- delete canvas;
-}
-
-static int numberOfWarnings = 0;
-static void checkWarnings(QtMsgType, const char *msg)
-{
- if (!QString(msg).contains("QGLContext::makeCurrent(): Failed."))
- numberOfWarnings++;
-}
-
-// QTBUG-15690
-void tst_qquickimage::nullPixmapPaint()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(testFileUrl("nullpixmap.qml"));
- canvas->show();
-
- QQuickImage *image = qobject_cast<QQuickImage*>(canvas->rootObject());
- QTRY_VERIFY(image != 0);
- image->setSource(SERVER_ADDR + QString("/no-such-file.png"));
-
- QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings);
-
- // used to print "QTransform::translate with NaN called"
- QPixmap pm = QPixmap::fromImage(canvas->grabFrameBuffer());
- qInstallMsgHandler(previousMsgHandler);
- QVERIFY(numberOfWarnings == 0);
- delete image;
-
- delete canvas;
-}
-
-void tst_qquickimage::imageCrash_QTBUG_22125()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
-
- {
- QQuickView view(testFileUrl("qtbug_22125.qml"));
- view.show();
- qApp->processEvents();
- qApp->processEvents();
- // shouldn't crash when the view drops out of scope due to
- // QDeclarativePixmapData attempting to dereference a pointer to
- // the destroyed reader.
- }
-
- // shouldn't crash when deleting cancelled QDeclarativePixmapReplys.
- QTest::qWait(520); // Delay mode delays for 500 ms.
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-}
-
-void tst_qquickimage::sourceSize_data()
-{
- QTest::addColumn<int>("sourceWidth");
- QTest::addColumn<int>("sourceHeight");
- QTest::addColumn<qreal>("implicitWidth");
- QTest::addColumn<qreal>("implicitHeight");
-
- QTest::newRow("unscaled") << 0 << 0 << 300.0 << 300.0;
- QTest::newRow("scale width") << 100 << 0 << 100.0 << 100.0;
- QTest::newRow("scale height") << 0 << 150 << 150.0 << 150.0;
- QTest::newRow("larger sourceSize") << 400 << 400 << 300.0 << 300.0;
-}
-
-void tst_qquickimage::sourceSize()
-{
- QFETCH(int, sourceWidth);
- QFETCH(int, sourceHeight);
- QFETCH(qreal, implicitWidth);
- QFETCH(qreal, implicitHeight);
-
- QQuickView *canvas = new QQuickView(0);
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("srcWidth", sourceWidth);
- ctxt->setContextProperty("srcHeight", sourceHeight);
-
- canvas->setSource(testFileUrl("sourceSize.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickImage *image = qobject_cast<QQuickImage*>(canvas->rootObject());
- QVERIFY(image);
-
- QCOMPARE(image->sourceSize().width(), sourceWidth);
- QCOMPARE(image->sourceSize().height(), sourceHeight);
- QCOMPARE(image->implicitWidth(), implicitWidth);
- QCOMPARE(image->implicitHeight(), implicitHeight);
-
- delete canvas;
-}
-
-QTEST_MAIN(tst_qquickimage)
-
-#include "tst_qquickimage.moc"
diff --git a/tests/auto/qtquick2/qquickitem/qquickitem.pro b/tests/auto/qtquick2/qquickitem/qquickitem.pro
deleted file mode 100644
index 70f6b15b3d..0000000000
--- a/tests/auto/qtquick2/qquickitem/qquickitem.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickitem
-SOURCES += tst_qquickitem.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private quick-private widgets testlib
diff --git a/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp b/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp
deleted file mode 100644
index be3aef80bd..0000000000
--- a/tests/auto/qtquick2/qquickitem/tst_qquickitem.cpp
+++ /dev/null
@@ -1,1468 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickcanvas.h>
-#include <QtQuick/qquickview.h>
-#include <QtWidgets/QGraphicsSceneMouseEvent>
-#include "private/qquickfocusscope_p.h"
-#include "private/qquickitem_p.h"
-#include <QDebug>
-#include <QTimer>
-#include "../../shared/util.h"
-
-class TestItem : public QQuickItem
-{
-Q_OBJECT
-public:
- TestItem(QQuickItem *parent = 0)
- : QQuickItem(parent), focused(false), pressCount(0), releaseCount(0)
- , wheelCount(0), acceptIncomingTouchEvents(true)
- , touchEventReached(false) {}
-
- bool focused;
- int pressCount;
- int releaseCount;
- int wheelCount;
- bool acceptIncomingTouchEvents;
- bool touchEventReached;
-protected:
- virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; }
- virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; }
- virtual void mousePressEvent(QMouseEvent *event) { event->accept(); ++pressCount; }
- virtual void mouseReleaseEvent(QMouseEvent *event) { event->accept(); ++releaseCount; }
- virtual void touchEvent(QTouchEvent *event) {
- touchEventReached = true;
- event->setAccepted(acceptIncomingTouchEvents);
- }
- virtual void wheelEvent(QWheelEvent *event) { event->accept(); ++wheelCount; }
-};
-
-class TestCanvas: public QQuickCanvas
-{
-public:
- TestCanvas()
- : QQuickCanvas()
- {}
-
- virtual bool event(QEvent *event)
- {
- return QQuickCanvas::event(event);
- }
-};
-
-class TestPolishItem : public QQuickItem
-{
-Q_OBJECT
-public:
- TestPolishItem(QQuickItem *parent = 0)
- : QQuickItem(parent), wasPolished(false) {
-
- }
-
- bool wasPolished;
-
-protected:
- virtual void updatePolish() {
- wasPolished = true;
- }
-
-public slots:
- void doPolish() {
- polish();
- }
-};
-
-class TestFocusScope : public QQuickFocusScope
-{
-Q_OBJECT
-public:
- TestFocusScope(QQuickItem *parent = 0) : QQuickFocusScope(parent), focused(false) {}
-
- bool focused;
-protected:
- virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; }
- virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; }
-};
-
-class tst_qquickitem : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
-
-private slots:
- void initTestCase();
-
- void noCanvas();
- void simpleFocus();
- void scopedFocus();
- void addedToCanvas();
- void changeParent();
-
- void constructor();
- void setParentItem();
-
- void visible();
- void enabled();
- void enabledFocus();
-
- void mouseGrab();
- void touchEventAcceptIgnore_data();
- void touchEventAcceptIgnore();
- void polishOutsideAnimation();
- void polishOnCompleted();
-
- void wheelEvent_data();
- void wheelEvent();
- void hoverEvent_data();
- void hoverEvent();
- void hoverEventInParent();
-
- void paintOrder_data();
- void paintOrder();
-
-private:
-
- enum PaintOrderOp {
- NoOp, Append, Remove, StackBefore, StackAfter, SetZ
- };
-
- void ensureFocus(QWindow *w) {
- w->show();
- w->requestActivateWindow();
- qApp->processEvents();
- }
-};
-
-void tst_qquickitem::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- qmlRegisterType<TestPolishItem>("Qt.test", 1, 0, "TestPolishItem");
-}
-
-// Focus has no effect when outside a canvas
-void tst_qquickitem::noCanvas()
-{
- QQuickItem *root = new TestItem;
- QQuickItem *child = new TestItem(root);
- QQuickItem *scope = new TestItem(root);
- QQuickFocusScope *scopedChild = new TestFocusScope(scope);
- QQuickFocusScope *scopedChild2 = new TestFocusScope(scope);
-
- QCOMPARE(root->hasFocus(), false);
- QCOMPARE(child->hasFocus(), false);
- QCOMPARE(scope->hasFocus(), false);
- QCOMPARE(scopedChild->hasFocus(), false);
- QCOMPARE(scopedChild2->hasFocus(), false);
-
- root->setFocus(true);
- scope->setFocus(true);
- scopedChild2->setFocus(true);
- QCOMPARE(root->hasFocus(), true);
- QCOMPARE(child->hasFocus(), false);
- QCOMPARE(scope->hasFocus(), true);
- QCOMPARE(scopedChild->hasFocus(), false);
- QCOMPARE(scopedChild2->hasFocus(), true);
-
- root->setFocus(false);
- child->setFocus(true);
- scopedChild->setFocus(true);
- scope->setFocus(false);
- QCOMPARE(root->hasFocus(), false);
- QCOMPARE(child->hasFocus(), true);
- QCOMPARE(scope->hasFocus(), false);
- QCOMPARE(scopedChild->hasFocus(), true);
- QCOMPARE(scopedChild2->hasFocus(), true);
-
- delete root;
-}
-
-struct FocusData {
- FocusData() : focus(false), activeFocus(false) {}
-
- void set(bool f, bool af) { focus = f; activeFocus = af; }
- bool focus;
- bool activeFocus;
-};
-struct FocusState : public QHash<QQuickItem *, FocusData>
-{
- FocusState() : activeFocusItem(0) {}
- FocusState &operator<<(QQuickItem *item) {
- insert(item, FocusData());
- return *this;
- }
-
- void active(QQuickItem *i) {
- activeFocusItem = i;
- }
- QQuickItem *activeFocusItem;
-};
-
-#define FVERIFY() \
- do { \
- if (focusState.activeFocusItem) { \
- QCOMPARE(canvas.activeFocusItem(), focusState.activeFocusItem); \
- if (qobject_cast<TestItem *>(canvas.activeFocusItem())) \
- QCOMPARE(qobject_cast<TestItem *>(canvas.activeFocusItem())->focused, true); \
- else if (qobject_cast<TestFocusScope *>(canvas.activeFocusItem())) \
- QCOMPARE(qobject_cast<TestFocusScope *>(canvas.activeFocusItem())->focused, true); \
- } else { \
- QCOMPARE(canvas.activeFocusItem(), canvas.rootItem()); \
- } \
- for (QHash<QQuickItem *, FocusData>::Iterator iter = focusState.begin(); \
- iter != focusState.end(); \
- iter++) { \
- QCOMPARE(iter.key()->hasFocus(), iter.value().focus); \
- QCOMPARE(iter.key()->hasActiveFocus(), iter.value().activeFocus); \
- } \
- } while (false)
-
-// Tests a simple set of top-level scoped items
-void tst_qquickitem::simpleFocus()
-{
- QQuickCanvas canvas;
- ensureFocus(&canvas);
-
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-24094: fails on Mac OS X 10.7");
-#endif
-
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
-
- QQuickItem *l1c1 = new TestItem(canvas.rootItem());
- QQuickItem *l1c2 = new TestItem(canvas.rootItem());
- QQuickItem *l1c3 = new TestItem(canvas.rootItem());
-
- QQuickItem *l2c1 = new TestItem(l1c1);
- QQuickItem *l2c2 = new TestItem(l1c1);
- QQuickItem *l2c3 = new TestItem(l1c3);
-
- FocusState focusState;
- focusState << l1c1 << l1c2 << l1c3
- << l2c1 << l2c2 << l2c3;
- FVERIFY();
-
- l1c1->setFocus(true);
- focusState[l1c1].set(true, true);
- focusState.active(l1c1);
- FVERIFY();
-
- l2c3->setFocus(true);
- focusState[l1c1].set(false, false);
- focusState[l2c3].set(true, true);
- focusState.active(l2c3);
- FVERIFY();
-
- l1c3->setFocus(true);
- focusState[l2c3].set(false, false);
- focusState[l1c3].set(true, true);
- focusState.active(l1c3);
- FVERIFY();
-
- l1c2->setFocus(false);
- FVERIFY();
-
- l1c3->setFocus(false);
- focusState[l1c3].set(false, false);
- focusState.active(0);
- FVERIFY();
-
- l2c1->setFocus(true);
- focusState[l2c1].set(true, true);
- focusState.active(l2c1);
- FVERIFY();
-}
-
-// Items with a focus scope
-void tst_qquickitem::scopedFocus()
-{
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
-
- QQuickItem *l1c1 = new TestItem(canvas.rootItem());
- QQuickItem *l1c2 = new TestItem(canvas.rootItem());
- QQuickItem *l1c3 = new TestItem(canvas.rootItem());
-
- QQuickItem *l2c1 = new TestItem(l1c1);
- QQuickItem *l2c2 = new TestItem(l1c1);
- QQuickItem *l2c3 = new TestFocusScope(l1c3);
-
- QQuickItem *l3c1 = new TestItem(l2c3);
- QQuickItem *l3c2 = new TestFocusScope(l2c3);
-
- QQuickItem *l4c1 = new TestItem(l3c2);
- QQuickItem *l4c2 = new TestItem(l3c2);
-
- FocusState focusState;
- focusState << l1c1 << l1c2 << l1c3
- << l2c1 << l2c2 << l2c3
- << l3c1 << l3c2
- << l4c1 << l4c2;
- FVERIFY();
-
- l4c2->setFocus(true);
- focusState[l4c2].set(true, false);
- FVERIFY();
-
- l4c1->setFocus(true);
- focusState[l4c2].set(false, false);
- focusState[l4c1].set(true, false);
- FVERIFY();
-
- l1c1->setFocus(true);
- focusState[l1c1].set(true, true);
- focusState.active(l1c1);
- FVERIFY();
-
- l3c2->setFocus(true);
- focusState[l3c2].set(true, false);
- FVERIFY();
-
- l2c3->setFocus(true);
- focusState[l1c1].set(false, false);
- focusState[l2c3].set(true, true);
- focusState[l3c2].set(true, true);
- focusState[l4c1].set(true, true);
- focusState.active(l4c1);
- FVERIFY();
-
- l3c2->setFocus(false);
- focusState[l3c2].set(false, false);
- focusState[l4c1].set(true, false);
- focusState.active(l2c3);
- FVERIFY();
-
- l3c2->setFocus(true);
- focusState[l3c2].set(true, true);
- focusState[l4c1].set(true, true);
- focusState.active(l4c1);
- FVERIFY();
-
- l4c1->setFocus(false);
- focusState[l4c1].set(false, false);
- focusState.active(l3c2);
- FVERIFY();
-
- l1c3->setFocus(true);
- focusState[l1c3].set(true, true);
- focusState[l2c3].set(false, false);
- focusState[l3c2].set(true, false);
- focusState.active(l1c3);
- FVERIFY();
-}
-
-// Tests focus corrects itself when a tree is added to a canvas for the first time
-void tst_qquickitem::addedToCanvas()
-{
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
-
- QQuickItem *item = new TestItem;
-
- FocusState focusState;
- focusState << item;
-
- item->setFocus(true);
- focusState[item].set(true, false);
- FVERIFY();
-
- item->setParentItem(canvas.rootItem());
- focusState[item].set(true, true);
- focusState.active(item);
- FVERIFY();
- }
-
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
-
- QQuickItem *item = new TestItem(canvas.rootItem());
-
- QQuickItem *tree = new TestItem;
- QQuickItem *c1 = new TestItem(tree);
- QQuickItem *c2 = new TestItem(tree);
-
- FocusState focusState;
- focusState << item << tree << c1 << c2;
-
- item->setFocus(true);
- c1->setFocus(true);
- c2->setFocus(true);
- focusState[item].set(true, true);
- focusState[c1].set(true, false);
- focusState[c2].set(true, false);
- focusState.active(item);
- FVERIFY();
-
- tree->setParentItem(item);
- focusState[c1].set(false, false);
- focusState[c2].set(false, false);
- FVERIFY();
- }
-
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
-
- QQuickItem *tree = new TestItem;
- QQuickItem *c1 = new TestItem(tree);
- QQuickItem *c2 = new TestItem(tree);
-
- FocusState focusState;
- focusState << tree << c1 << c2;
- c1->setFocus(true);
- c2->setFocus(true);
- focusState[c1].set(true, false);
- focusState[c2].set(true, false);
- FVERIFY();
-
- tree->setParentItem(canvas.rootItem());
- focusState[c1].set(true, true);
- focusState[c2].set(false, false);
- focusState.active(c1);
- FVERIFY();
- }
-
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
- QQuickItem *tree = new TestFocusScope;
- QQuickItem *c1 = new TestItem(tree);
- QQuickItem *c2 = new TestItem(tree);
-
- FocusState focusState;
- focusState << tree << c1 << c2;
- c1->setFocus(true);
- c2->setFocus(true);
- focusState[c1].set(true, false);
- focusState[c2].set(true, false);
- FVERIFY();
-
- tree->setParentItem(canvas.rootItem());
- focusState[c1].set(true, false);
- focusState[c2].set(false, false);
- FVERIFY();
-
- tree->setFocus(true);
- focusState[tree].set(true, true);
- focusState[c1].set(true, true);
- focusState.active(c1);
- FVERIFY();
- }
-
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
- QQuickItem *tree = new TestFocusScope;
- QQuickItem *c1 = new TestItem(tree);
- QQuickItem *c2 = new TestItem(tree);
-
- FocusState focusState;
- focusState << tree << c1 << c2;
- tree->setFocus(true);
- c1->setFocus(true);
- c2->setFocus(true);
- focusState[tree].set(true, false);
- focusState[c1].set(true, false);
- focusState[c2].set(true, false);
- FVERIFY();
-
- tree->setParentItem(canvas.rootItem());
- focusState[tree].set(true, true);
- focusState[c1].set(true, true);
- focusState[c2].set(false, false);
- focusState.active(c1);
- FVERIFY();
- }
-
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
- QQuickItem *child = new TestItem(canvas.rootItem());
- QQuickItem *tree = new TestFocusScope;
- QQuickItem *c1 = new TestItem(tree);
- QQuickItem *c2 = new TestItem(tree);
-
- FocusState focusState;
- focusState << child << tree << c1 << c2;
- child->setFocus(true);
- tree->setFocus(true);
- c1->setFocus(true);
- c2->setFocus(true);
- focusState[child].set(true, true);
- focusState[tree].set(true, false);
- focusState[c1].set(true, false);
- focusState[c2].set(true, false);
- focusState.active(child);
- FVERIFY();
-
- tree->setParentItem(canvas.rootItem());
- focusState[tree].set(false, false);
- focusState[c1].set(true, false);
- focusState[c2].set(false, false);
- FVERIFY();
-
- tree->setFocus(true);
- focusState[child].set(false, false);
- focusState[tree].set(true, true);
- focusState[c1].set(true, true);
- focusState.active(c1);
- FVERIFY();
- }
-}
-
-void tst_qquickitem::changeParent()
-{
- // Parent to no parent
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
- QQuickItem *child = new TestItem(canvas.rootItem());
-
- FocusState focusState;
- focusState << child;
- FVERIFY();
-
- child->setFocus(true);
- focusState[child].set(true, true);
- focusState.active(child);
- FVERIFY();
-
- child->setParentItem(0);
- focusState[child].set(true, false);
- focusState.active(0);
- FVERIFY();
- }
-
- // Different parent, same focus scope
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
- QQuickItem *child = new TestItem(canvas.rootItem());
- QQuickItem *child2 = new TestItem(canvas.rootItem());
-
- FocusState focusState;
- focusState << child << child2;
- FVERIFY();
-
- child->setFocus(true);
- focusState[child].set(true, true);
- focusState.active(child);
- FVERIFY();
-
- child->setParentItem(child2);
- FVERIFY();
- }
-
- // Different parent, different focus scope
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
- QQuickItem *child = new TestItem(canvas.rootItem());
- QQuickItem *child2 = new TestFocusScope(canvas.rootItem());
- QQuickItem *item = new TestItem(child);
-
- FocusState focusState;
- focusState << child << child2 << item;
- FVERIFY();
-
- item->setFocus(true);
- focusState[item].set(true, true);
- focusState.active(item);
- FVERIFY();
-
- item->setParentItem(child2);
- focusState[item].set(true, false);
- focusState.active(0);
- FVERIFY();
- }
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
- QQuickItem *child = new TestItem(canvas.rootItem());
- QQuickItem *child2 = new TestFocusScope(canvas.rootItem());
- QQuickItem *item = new TestItem(child2);
-
- FocusState focusState;
- focusState << child << child2 << item;
- FVERIFY();
-
- item->setFocus(true);
- focusState[item].set(true, false);
- focusState.active(0);
- FVERIFY();
-
- item->setParentItem(child);
- focusState[item].set(true, true);
- focusState.active(item);
- FVERIFY();
- }
- {
- QQuickCanvas canvas;
- ensureFocus(&canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
- QQuickItem *child = new TestItem(canvas.rootItem());
- QQuickItem *child2 = new TestFocusScope(canvas.rootItem());
- QQuickItem *item = new TestItem(child2);
-
- FocusState focusState;
- focusState << child << child2 << item;
- FVERIFY();
-
- child->setFocus(true);
- item->setFocus(true);
- focusState[child].set(true, true);
- focusState[item].set(true, false);
- focusState.active(child);
- FVERIFY();
-
- item->setParentItem(child);
- focusState[item].set(false, false);
- FVERIFY();
- }
-
-}
-
-void tst_qquickitem::constructor()
-{
- QQuickItem *root = new QQuickItem;
- QVERIFY(root->parent() == 0);
- QVERIFY(root->parentItem() == 0);
-
- QQuickItem *child1 = new QQuickItem(root);
- QVERIFY(child1->parent() == root);
- QVERIFY(child1->parentItem() == root);
- QCOMPARE(root->childItems().count(), 1);
- QCOMPARE(root->childItems().at(0), child1);
-
- QQuickItem *child2 = new QQuickItem(root);
- QVERIFY(child2->parent() == root);
- QVERIFY(child2->parentItem() == root);
- QCOMPARE(root->childItems().count(), 2);
- QCOMPARE(root->childItems().at(0), child1);
- QCOMPARE(root->childItems().at(1), child2);
-
- delete root;
-}
-
-void tst_qquickitem::setParentItem()
-{
- QQuickItem *root = new QQuickItem;
- QVERIFY(root->parent() == 0);
- QVERIFY(root->parentItem() == 0);
-
- QQuickItem *child1 = new QQuickItem;
- QVERIFY(child1->parent() == 0);
- QVERIFY(child1->parentItem() == 0);
-
- child1->setParentItem(root);
- QVERIFY(child1->parent() == 0);
- QVERIFY(child1->parentItem() == root);
- QCOMPARE(root->childItems().count(), 1);
- QCOMPARE(root->childItems().at(0), child1);
-
- QQuickItem *child2 = new QQuickItem;
- QVERIFY(child2->parent() == 0);
- QVERIFY(child2->parentItem() == 0);
- child2->setParentItem(root);
- QVERIFY(child2->parent() == 0);
- QVERIFY(child2->parentItem() == root);
- QCOMPARE(root->childItems().count(), 2);
- QCOMPARE(root->childItems().at(0), child1);
- QCOMPARE(root->childItems().at(1), child2);
-
- child1->setParentItem(0);
- QVERIFY(child1->parent() == 0);
- QVERIFY(child1->parentItem() == 0);
- QCOMPARE(root->childItems().count(), 1);
- QCOMPARE(root->childItems().at(0), child2);
-
- delete root;
-
- QVERIFY(child1->parent() == 0);
- QVERIFY(child1->parentItem() == 0);
- QVERIFY(child2->parent() == 0);
- QVERIFY(child2->parentItem() == 0);
-
- delete child1;
- delete child2;
-}
-
-void tst_qquickitem::visible()
-{
- QQuickItem *root = new QQuickItem;
-
- QQuickItem *child1 = new QQuickItem;
- child1->setParentItem(root);
-
- QQuickItem *child2 = new QQuickItem;
- child2->setParentItem(root);
-
- QVERIFY(child1->isVisible());
- QVERIFY(child2->isVisible());
-
- root->setVisible(false);
- QVERIFY(!child1->isVisible());
- QVERIFY(!child2->isVisible());
-
- root->setVisible(true);
- QVERIFY(child1->isVisible());
- QVERIFY(child2->isVisible());
-
- child1->setVisible(false);
- QVERIFY(!child1->isVisible());
- QVERIFY(child2->isVisible());
-
- child2->setParentItem(child1);
- QVERIFY(!child1->isVisible());
- QVERIFY(!child2->isVisible());
-
- child2->setParentItem(root);
- QVERIFY(!child1->isVisible());
- QVERIFY(child2->isVisible());
-
- delete root;
- delete child1;
- delete child2;
-}
-
-void tst_qquickitem::enabled()
-{
- QQuickItem *root = new QQuickItem;
-
- QQuickItem *child1 = new QQuickItem;
- child1->setParentItem(root);
-
- QQuickItem *child2 = new QQuickItem;
- child2->setParentItem(root);
-
- QVERIFY(child1->isEnabled());
- QVERIFY(child2->isEnabled());
-
- root->setEnabled(false);
- QVERIFY(!child1->isEnabled());
- QVERIFY(!child2->isEnabled());
-
- root->setEnabled(true);
- QVERIFY(child1->isEnabled());
- QVERIFY(child2->isEnabled());
-
- child1->setEnabled(false);
- QVERIFY(!child1->isEnabled());
- QVERIFY(child2->isEnabled());
-
- child2->setParentItem(child1);
- QVERIFY(!child1->isEnabled());
- QVERIFY(!child2->isEnabled());
-
- child2->setParentItem(root);
- QVERIFY(!child1->isEnabled());
- QVERIFY(child2->isEnabled());
-
- delete root;
- delete child1;
- delete child2;
-}
-
-void tst_qquickitem::enabledFocus()
-{
- QQuickCanvas canvas;
- ensureFocus(&canvas);
-
- QQuickFocusScope root;
-
- root.setFocus(true);
- root.setEnabled(false);
-
- QCOMPARE(root.isEnabled(), false);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), false);
-
- root.setParentItem(canvas.rootItem());
-
- QCOMPARE(root.isEnabled(), false);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), canvas.rootItem());
-
- root.setEnabled(true);
- QCOMPARE(root.isEnabled(), true);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), true);
- QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
-
- QQuickItem child1;
- child1.setParentItem(&root);
-
- QCOMPARE(child1.isEnabled(), true);
- QCOMPARE(child1.hasFocus(), false);
- QCOMPARE(child1.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
-
- QQuickItem child2;
- child2.setFocus(true);
- child2.setParentItem(&root);
-
- QCOMPARE(root.isEnabled(), true);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), true);
- QCOMPARE(child2.isEnabled(), true);
- QCOMPARE(child2.hasFocus(), true);
- QCOMPARE(child2.hasActiveFocus(), true);
- QCOMPARE(canvas.activeFocusItem(), &child2);
-
- child2.setEnabled(false);
-
- QCOMPARE(root.isEnabled(), true);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), true);
- QCOMPARE(child1.isEnabled(), true);
- QCOMPARE(child1.hasFocus(), false);
- QCOMPARE(child1.hasActiveFocus(), false);
- QCOMPARE(child2.isEnabled(), false);
- QCOMPARE(child2.hasFocus(), true);
- QCOMPARE(child2.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
-
- child1.setEnabled(false);
- QCOMPARE(child1.isEnabled(), false);
- QCOMPARE(child1.hasFocus(), false);
- QCOMPARE(child1.hasActiveFocus(), false);
-
- child1.setFocus(true);
- QCOMPARE(child1.isEnabled(), false);
- QCOMPARE(child1.hasFocus(), true);
- QCOMPARE(child1.hasActiveFocus(), false);
- QCOMPARE(child2.isEnabled(), false);
- QCOMPARE(child2.hasFocus(), false);
- QCOMPARE(child2.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
-
- child1.setEnabled(true);
- QCOMPARE(child1.isEnabled(), true);
- QCOMPARE(child1.hasFocus(), true);
- QCOMPARE(child1.hasActiveFocus(), true);
- QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&child1));
-
- root.setFocus(false);
- QCOMPARE(root.isEnabled(), true);
- QCOMPARE(root.hasFocus(), false);
- QCOMPARE(root.hasActiveFocus(), false);
- QCOMPARE(child1.isEnabled(), true);
- QCOMPARE(child1.hasFocus(), true);
- QCOMPARE(child1.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), canvas.rootItem());
-
- child2.forceActiveFocus();
- QCOMPARE(root.isEnabled(), true);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), true);
- QCOMPARE(child1.isEnabled(), true);
- QCOMPARE(child1.hasFocus(), false);
- QCOMPARE(child1.hasActiveFocus(), false);
- QCOMPARE(child2.isEnabled(), false);
- QCOMPARE(child2.hasFocus(), true);
- QCOMPARE(child2.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
-
- root.setEnabled(false);
- QCOMPARE(root.isEnabled(), false);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), false);
- QCOMPARE(child1.isEnabled(), false);
- QCOMPARE(child1.hasFocus(), false);
- QCOMPARE(child1.hasActiveFocus(), false);
- QCOMPARE(child2.isEnabled(), false);
- QCOMPARE(child2.hasFocus(), true);
- QCOMPARE(child2.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), canvas.rootItem());
-
- child1.forceActiveFocus();
- QCOMPARE(root.isEnabled(), false);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), false);
- QCOMPARE(child1.isEnabled(), false);
- QCOMPARE(child1.hasFocus(), true);
- QCOMPARE(child1.hasActiveFocus(), false);
- QCOMPARE(child2.isEnabled(), false);
- QCOMPARE(child2.hasFocus(), false);
- QCOMPARE(child2.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), canvas.rootItem());
-
- root.setEnabled(true);
- QCOMPARE(root.isEnabled(), true);
- QCOMPARE(root.hasFocus(), true);
- QCOMPARE(root.hasActiveFocus(), true);
- QCOMPARE(child1.isEnabled(), true);
- QCOMPARE(child1.hasFocus(), true);
- QCOMPARE(child1.hasActiveFocus(), true);
- QCOMPARE(child2.isEnabled(), false);
- QCOMPARE(child2.hasFocus(), false);
- QCOMPARE(child2.hasActiveFocus(), false);
- QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&child1));
-}
-
-void tst_qquickitem::mouseGrab()
-{
- QQuickCanvas *canvas = new QQuickCanvas;
- canvas->resize(200, 200);
- canvas->show();
-
- TestItem *child1 = new TestItem;
- child1->setAcceptedMouseButtons(Qt::LeftButton);
- child1->setSize(QSizeF(200, 100));
- child1->setParentItem(canvas->rootItem());
-
- TestItem *child2 = new TestItem;
- child2->setAcceptedMouseButtons(Qt::LeftButton);
- child2->setY(51);
- child2->setSize(QSizeF(200, 100));
- child2->setParentItem(canvas->rootItem());
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(100);
- QVERIFY(canvas->mouseGrabberItem() == child1);
- QTest::qWait(100);
-
- QCOMPARE(child1->pressCount, 1);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(50);
- QVERIFY(canvas->mouseGrabberItem() == 0);
- QCOMPARE(child1->releaseCount, 1);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(50);
- QVERIFY(canvas->mouseGrabberItem() == child1);
- QCOMPARE(child1->pressCount, 2);
- child1->setEnabled(false);
- QVERIFY(canvas->mouseGrabberItem() == 0);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(50);
- QCOMPARE(child1->releaseCount, 1);
- child1->setEnabled(true);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(50);
- QVERIFY(canvas->mouseGrabberItem() == child1);
- QCOMPARE(child1->pressCount, 3);
- child1->setVisible(false);
- QVERIFY(canvas->mouseGrabberItem() == 0);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QCOMPARE(child1->releaseCount, 1);
- child1->setVisible(true);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(50);
- QVERIFY(canvas->mouseGrabberItem() == child1);
- QCOMPARE(child1->pressCount, 4);
- child2->grabMouse();
- QVERIFY(canvas->mouseGrabberItem() == child2);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(50);
- QCOMPARE(child1->releaseCount, 1);
- QCOMPARE(child2->releaseCount, 1);
-
- child2->grabMouse();
- QVERIFY(canvas->mouseGrabberItem() == child2);
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(50);
- QCOMPARE(child1->pressCount, 4);
- QCOMPARE(child2->pressCount, 1);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
- QTest::qWait(50);
- QCOMPARE(child1->releaseCount, 1);
- QCOMPARE(child2->releaseCount, 2);
-
- delete child1;
- delete child2;
- delete canvas;
-}
-
-void tst_qquickitem::touchEventAcceptIgnore_data()
-{
- QTest::addColumn<bool>("itemSupportsTouch");
-
- QTest::newRow("with touch") << true;
- QTest::newRow("without touch") << false;
-}
-
-void tst_qquickitem::touchEventAcceptIgnore()
-{
- QFETCH(bool, itemSupportsTouch);
-
- TestCanvas *canvas = new TestCanvas;
- canvas->resize(100, 100);
- canvas->show();
-
- TestItem *item = new TestItem;
- item->setSize(QSizeF(100, 100));
- item->setParentItem(canvas->rootItem());
- item->acceptIncomingTouchEvents = itemSupportsTouch;
-
- static QTouchDevice* device = 0;
- if (!device) {
- device =new QTouchDevice;
- device->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(device);
- }
-
- // Send Begin, Update & End touch sequence
- {
- QTouchEvent::TouchPoint point;
- point.setId(1);
- point.setPos(QPointF(50, 50));
- point.setScreenPos(point.pos());
- point.setState(Qt::TouchPointPressed);
-
- QTouchEvent event(QEvent::TouchBegin, device,
- Qt::NoModifier,
- Qt::TouchPointPressed,
- QList<QTouchEvent::TouchPoint>() << point);
- event.setAccepted(true);
-
- item->touchEventReached = false;
-
- bool accepted = canvas->event(&event);
-
- QVERIFY(item->touchEventReached);
- QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch);
- }
- {
- QTouchEvent::TouchPoint point;
- point.setId(1);
- point.setPos(QPointF(60, 60));
- point.setScreenPos(point.pos());
- point.setState(Qt::TouchPointMoved);
-
- QTouchEvent event(QEvent::TouchUpdate, device,
- Qt::NoModifier,
- Qt::TouchPointMoved,
- QList<QTouchEvent::TouchPoint>() << point);
- event.setAccepted(true);
-
- item->touchEventReached = false;
-
- bool accepted = canvas->event(&event);
-
- QCOMPARE(item->touchEventReached, itemSupportsTouch);
- QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch);
- }
- {
- QTouchEvent::TouchPoint point;
- point.setId(1);
- point.setPos(QPointF(60, 60));
- point.setScreenPos(point.pos());
- point.setState(Qt::TouchPointReleased);
-
- QTouchEvent event(QEvent::TouchEnd, device,
- Qt::NoModifier,
- Qt::TouchPointReleased,
- QList<QTouchEvent::TouchPoint>() << point);
- event.setAccepted(true);
-
- item->touchEventReached = false;
-
- bool accepted = canvas->event(&event);
-
- QCOMPARE(item->touchEventReached, itemSupportsTouch);
- QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch);
- }
-
- delete item;
- delete canvas;
-}
-
-void tst_qquickitem::polishOutsideAnimation()
-{
- QQuickCanvas *canvas = new QQuickCanvas;
- canvas->resize(200, 200);
- canvas->show();
-
- TestPolishItem *item = new TestPolishItem(canvas->rootItem());
- item->setSize(QSizeF(200, 100));
- QTest::qWait(50);
-
- QTimer::singleShot(10, item, SLOT(doPolish()));
- QTRY_VERIFY(item->wasPolished);
-
- delete item;
- delete canvas;
-}
-
-void tst_qquickitem::polishOnCompleted()
-{
- QQuickView *view = new QQuickView;
- view->setSource(testFileUrl("polishOnCompleted.qml"));
- view->show();
-
- TestPolishItem *item = qobject_cast<TestPolishItem*>(view->rootObject());
- QVERIFY(item);
-
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-21590 view does not reliably receive polish without a running animation");
-#endif
-
- QTRY_VERIFY(item->wasPolished);
-
- delete view;
-}
-
-void tst_qquickitem::wheelEvent_data()
-{
- QTest::addColumn<bool>("visible");
- QTest::addColumn<bool>("enabled");
-
- QTest::newRow("visible and enabled") << true << true;
- QTest::newRow("visible and disabled") << true << false;
- QTest::newRow("invisible and enabled") << false << true;
- QTest::newRow("invisible and disabled") << false << false;
-}
-
-void tst_qquickitem::wheelEvent()
-{
- QFETCH(bool, visible);
- QFETCH(bool, enabled);
-
- const bool shouldReceiveWheelEvents = visible && enabled;
-
- QQuickCanvas *canvas = new QQuickCanvas;
- canvas->resize(200, 200);
- canvas->show();
-
- TestItem *item = new TestItem;
- item->setSize(QSizeF(200, 100));
- item->setParentItem(canvas->rootItem());
-
- item->setEnabled(enabled);
- item->setVisible(visible);
-
- QWheelEvent event(QPoint(100, 50), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical);
- event.setAccepted(false);
- QGuiApplication::sendEvent(canvas, &event);
-
- if (shouldReceiveWheelEvents) {
- QVERIFY(event.isAccepted());
- QCOMPARE(item->wheelCount, 1);
- } else {
- QVERIFY(!event.isAccepted());
- QCOMPARE(item->wheelCount, 0);
- }
-
- delete canvas;
-}
-
-class HoverItem : public QQuickItem
-{
-Q_OBJECT
-public:
- HoverItem(QQuickItem *parent = 0)
- : QQuickItem(parent), hoverEnterCount(0), hoverMoveCount(0), hoverLeaveCount(0)
- { }
- void resetCounters() {
- hoverEnterCount = 0;
- hoverMoveCount = 0;
- hoverLeaveCount = 0;
- }
- int hoverEnterCount;
- int hoverMoveCount;
- int hoverLeaveCount;
-protected:
- virtual void hoverEnterEvent(QHoverEvent *event) {
- event->accept();
- ++hoverEnterCount;
- }
- virtual void hoverMoveEvent(QHoverEvent *event) {
- event->accept();
- ++hoverMoveCount;
- }
- virtual void hoverLeaveEvent(QHoverEvent *event) {
- event->accept();
- ++hoverLeaveCount;
- }
-};
-
-void tst_qquickitem::hoverEvent_data()
-{
- QTest::addColumn<bool>("visible");
- QTest::addColumn<bool>("enabled");
- QTest::addColumn<bool>("acceptHoverEvents");
-
- QTest::newRow("visible, enabled, accept hover") << true << true << true;
- QTest::newRow("visible, disabled, accept hover") << true << false << true;
- QTest::newRow("invisible, enabled, accept hover") << false << true << true;
- QTest::newRow("invisible, disabled, accept hover") << false << false << true;
-
- QTest::newRow("visible, enabled, not accept hover") << true << true << false;
- QTest::newRow("visible, disabled, not accept hover") << true << false << false;
- QTest::newRow("invisible, enabled, not accept hover") << false << true << false;
- QTest::newRow("invisible, disabled, not accept hover") << false << false << false;
-}
-
-// ### For some unknown reason QTest::mouseMove() isn't working correctly.
-static void sendMouseMove(QObject *object, const QPoint &position)
-{
- QMouseEvent moveEvent(QEvent::MouseMove, position, Qt::NoButton, Qt::NoButton, 0);
- QGuiApplication::sendEvent(object, &moveEvent);
-}
-
-void tst_qquickitem::hoverEvent()
-{
- QFETCH(bool, visible);
- QFETCH(bool, enabled);
- QFETCH(bool, acceptHoverEvents);
-
- QQuickCanvas *canvas = new QQuickCanvas();
- canvas->resize(200, 200);
- canvas->show();
-
- HoverItem *item = new HoverItem;
- item->setSize(QSizeF(100, 100));
- item->setParentItem(canvas->rootItem());
-
- item->setEnabled(enabled);
- item->setVisible(visible);
- item->setAcceptHoverEvents(acceptHoverEvents);
-
- const QPoint outside(150, 150);
- const QPoint inside(50, 50);
- const QPoint anotherInside(51, 51);
-
- sendMouseMove(canvas, outside);
- item->resetCounters();
-
- // Enter, then move twice inside, then leave.
- sendMouseMove(canvas, inside);
- sendMouseMove(canvas, anotherInside);
- sendMouseMove(canvas, inside);
- sendMouseMove(canvas, outside);
-
- const bool shouldReceiveHoverEvents = visible && enabled && acceptHoverEvents;
- if (shouldReceiveHoverEvents) {
- QCOMPARE(item->hoverEnterCount, 1);
- QCOMPARE(item->hoverMoveCount, 2);
- QCOMPARE(item->hoverLeaveCount, 1);
- } else {
- QCOMPARE(item->hoverEnterCount, 0);
- QCOMPARE(item->hoverMoveCount, 0);
- QCOMPARE(item->hoverLeaveCount, 0);
- }
-
- delete canvas;
-}
-
-void tst_qquickitem::hoverEventInParent()
-{
- QQuickCanvas *canvas = new QQuickCanvas();
- canvas->resize(200, 200);
- canvas->show();
-
- HoverItem *parentItem = new HoverItem(canvas->rootItem());
- parentItem->setSize(QSizeF(200, 200));
- parentItem->setAcceptHoverEvents(true);
-
- HoverItem *leftItem = new HoverItem(parentItem);
- leftItem->setSize(QSizeF(100, 200));
- leftItem->setAcceptHoverEvents(true);
-
- HoverItem *rightItem = new HoverItem(parentItem);
- rightItem->setSize(QSizeF(100, 200));
- rightItem->setPos(QPointF(100, 0));
- rightItem->setAcceptHoverEvents(true);
-
- const QPoint insideLeft(50, 100);
- const QPoint insideRight(150, 100);
-
- sendMouseMove(canvas, insideLeft);
- parentItem->resetCounters();
- leftItem->resetCounters();
- rightItem->resetCounters();
-
- sendMouseMove(canvas, insideRight);
- QCOMPARE(parentItem->hoverEnterCount, 0);
- QCOMPARE(parentItem->hoverLeaveCount, 0);
- QCOMPARE(leftItem->hoverEnterCount, 0);
- QCOMPARE(leftItem->hoverLeaveCount, 1);
- QCOMPARE(rightItem->hoverEnterCount, 1);
- QCOMPARE(rightItem->hoverLeaveCount, 0);
-
- sendMouseMove(canvas, insideLeft);
- QCOMPARE(parentItem->hoverEnterCount, 0);
- QCOMPARE(parentItem->hoverLeaveCount, 0);
- QCOMPARE(leftItem->hoverEnterCount, 1);
- QCOMPARE(leftItem->hoverLeaveCount, 1);
- QCOMPARE(rightItem->hoverEnterCount, 1);
- QCOMPARE(rightItem->hoverLeaveCount, 1);
-
- delete canvas;
-}
-
-void tst_qquickitem::paintOrder_data()
-{
- const QUrl order1Url = testFileUrl("order.1.qml");
- const QUrl order2Url = testFileUrl("order.2.qml");
-
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<int>("op");
- QTest::addColumn<QVariant>("param1");
- QTest::addColumn<QVariant>("param2");
- QTest::addColumn<QStringList>("expected");
-
- QTest::newRow("test 1 noop") << order1Url
- << int(NoOp) << QVariant() << QVariant()
- << (QStringList() << "1" << "2" << "3");
- QTest::newRow("test 1 add") << order1Url
- << int(Append) << QVariant("new") << QVariant()
- << (QStringList() << "1" << "2" << "3" << "new");
- QTest::newRow("test 1 remove") << order1Url
- << int(Remove) << QVariant(1) << QVariant()
- << (QStringList() << "1" << "3");
- QTest::newRow("test 1 stack before") << order1Url
- << int(StackBefore) << QVariant(2) << QVariant(1)
- << (QStringList() << "1" << "3" << "2");
- QTest::newRow("test 1 stack after") << order1Url
- << int(StackAfter) << QVariant(0) << QVariant(1)
- << (QStringList() << "2" << "1" << "3");
- QTest::newRow("test 1 set z") << order1Url
- << int(SetZ) << QVariant(1) << QVariant(qreal(1.))
- << (QStringList() << "1" << "3" << "2");
-
- QTest::newRow("test 2 noop") << order2Url
- << int(NoOp) << QVariant() << QVariant()
- << (QStringList() << "1" << "3" << "2");
- QTest::newRow("test 2 add") << order2Url
- << int(Append) << QVariant("new") << QVariant()
- << (QStringList() << "1" << "3" << "new" << "2");
- QTest::newRow("test 2 remove 1") << order2Url
- << int(Remove) << QVariant(1) << QVariant()
- << (QStringList() << "1" << "3");
- QTest::newRow("test 2 remove 2") << order2Url
- << int(Remove) << QVariant(2) << QVariant()
- << (QStringList() << "1" << "2");
- QTest::newRow("test 2 stack before 1") << order2Url
- << int(StackBefore) << QVariant(1) << QVariant(0)
- << (QStringList() << "1" << "3" << "2");
- QTest::newRow("test 2 stack before 2") << order2Url
- << int(StackBefore) << QVariant(2) << QVariant(0)
- << (QStringList() << "3" << "1" << "2");
- QTest::newRow("test 2 stack after 1") << order2Url
- << int(StackAfter) << QVariant(0) << QVariant(1)
- << (QStringList() << "1" << "3" << "2");
- QTest::newRow("test 2 stack after 2") << order2Url
- << int(StackAfter) << QVariant(0) << QVariant(2)
- << (QStringList() << "3" << "1" << "2");
- QTest::newRow("test 1 set z") << order1Url
- << int(SetZ) << QVariant(2) << QVariant(qreal(2.))
- << (QStringList() << "1" << "2" << "3");
-}
-
-void tst_qquickitem::paintOrder()
-{
- QFETCH(QUrl, source);
- QFETCH(int, op);
- QFETCH(QVariant, param1);
- QFETCH(QVariant, param2);
- QFETCH(QStringList, expected);
-
- QQuickView view;
- view.setSource(source);
-
- QQuickItem *root = qobject_cast<QQuickItem*>(view.rootObject());
- QVERIFY(root);
-
- switch (op) {
- case Append: {
- QQuickItem *item = new QQuickItem(root);
- item->setObjectName(param1.toString());
- }
- break;
- case Remove: {
- QQuickItem *item = root->childItems().at(param1.toInt());
- delete item;
- }
- break;
- case StackBefore: {
- QQuickItem *item1 = root->childItems().at(param1.toInt());
- QQuickItem *item2 = root->childItems().at(param2.toInt());
- item1->stackBefore(item2);
- }
- break;
- case StackAfter: {
- QQuickItem *item1 = root->childItems().at(param1.toInt());
- QQuickItem *item2 = root->childItems().at(param2.toInt());
- item1->stackAfter(item2);
- }
- break;
- case SetZ: {
- QQuickItem *item = root->childItems().at(param1.toInt());
- item->setZ(param2.toReal());
- }
- break;
- default:
- break;
- }
-
- QList<QQuickItem*> list = QQuickItemPrivate::get(root)->paintOrderChildItems();
-
- QStringList items;
- for (int i = 0; i < list.count(); ++i)
- items << list.at(i)->objectName();
-
- QCOMPARE(items, expected);
-}
-
-
-QTEST_MAIN(tst_qquickitem)
-
-#include "tst_qquickitem.moc"
diff --git a/tests/auto/qtquick2/qquickitem2/qquickitem2.pro b/tests/auto/qtquick2/qquickitem2/qquickitem2.pro
deleted file mode 100644
index 44d3ba37c8..0000000000
--- a/tests/auto/qtquick2/qquickitem2/qquickitem2.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickitem2
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickitem.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
diff --git a/tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp b/tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp
deleted file mode 100644
index 9891b8718a..0000000000
--- a/tests/auto/qtquick2/qquickitem2/tst_qquickitem.cpp
+++ /dev/null
@@ -1,1380 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtQuick/qquickview.h>
-#include <QtGui/private/qinputmethod_p.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtQuick/private/qquicktextinput_p.h>
-#include <private/qquickitem_p.h>
-#include "../../shared/util.h"
-#include "../shared/visualtestutil.h"
-#include "../../shared/platforminputcontext.h"
-
-using namespace QQuickVisualTestUtil;
-
-class tst_QQuickItem : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickItem();
-
-private slots:
- void initTestCase();
- void cleanup();
-
- void keys();
- void keysProcessingOrder();
- void keysim();
- void keyNavigation();
- void keyNavigation_RightToLeft();
- void keyNavigation_skipNotVisible();
- void keyNavigation_implicitSetting();
- void layoutMirroring();
- void layoutMirroringIllegalParent();
- void smooth();
- void clip();
- void mapCoordinates();
- void mapCoordinates_data();
- void propertyChanges();
- void transforms();
- void transforms_data();
- void childrenRect();
- void childrenRectBug();
- void childrenRectBug2();
- void childrenRectBug3();
-
- void childrenProperty();
- void resourcesProperty();
-
- void transformCrash();
- void implicitSize();
- void qtbug_16871();
- void visibleChildren();
- void parentLoop();
-private:
- QDeclarativeEngine engine;
-};
-
-class KeysTestObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(bool processLast READ processLast NOTIFY processLastChanged)
-
-public:
- KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0), mLast(false) {}
-
- void reset() {
- mKey = 0;
- mText = QString();
- mModifiers = 0;
- mForwardedKey = 0;
- }
-
- bool processLast() const { return mLast; }
- void setProcessLast(bool b) {
- if (b != mLast) {
- mLast = b;
- emit processLastChanged();
- }
- }
-
-public slots:
- void keyPress(int key, QString text, int modifiers) {
- mKey = key;
- mText = text;
- mModifiers = modifiers;
- }
- void keyRelease(int key, QString text, int modifiers) {
- mKey = key;
- mText = text;
- mModifiers = modifiers;
- }
- void forwardedKey(int key) {
- mForwardedKey = key;
- }
-
-signals:
- void processLastChanged();
-
-public:
- int mKey;
- QString mText;
- int mModifiers;
- int mForwardedKey;
- bool mLast;
-
-private:
-};
-
-class KeyTestItem : public QQuickItem
-{
- Q_OBJECT
-public:
- KeyTestItem(QQuickItem *parent=0) : QQuickItem(parent), mKey(0) {}
-
-protected:
- void keyPressEvent(QKeyEvent *e) {
- mKey = e->key();
-
- if (e->key() == Qt::Key_A)
- e->accept();
- else
- e->ignore();
- }
-
- void keyReleaseEvent(QKeyEvent *e) {
- if (e->key() == Qt::Key_B)
- e->accept();
- else
- e->ignore();
- }
-
-public:
- int mKey;
-};
-
-QML_DECLARE_TYPE(KeyTestItem);
-
-
-tst_QQuickItem::tst_QQuickItem()
-{
-}
-
-void tst_QQuickItem::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- qmlRegisterType<KeyTestItem>("Test",1,0,"KeyTestItem");
-}
-
-void tst_QQuickItem::cleanup()
-{
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = 0;
-}
-
-void tst_QQuickItem::keys()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(240,320));
-
- KeysTestObject *testObject = new KeysTestObject;
- canvas->rootContext()->setContextProperty("keysTestObject", testObject);
-
- canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true));
- canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(true));
-
- canvas->setSource(testFileUrl("keystest.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
-
- QVERIFY(canvas->rootObject());
- QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true);
-
- QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_A));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A));
- QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(!key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::ShiftModifier, "A", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_A));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A));
- QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::ShiftModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_Return));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Return));
- QCOMPARE(testObject->mText, QLatin1String("Return"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_0, Qt::NoModifier, "0", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_0));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_0));
- QCOMPARE(testObject->mText, QLatin1String("0"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_9, Qt::NoModifier, "9", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_9));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_9));
- QCOMPARE(testObject->mText, QLatin1String("9"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(!key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_Tab));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Tab));
- QCOMPARE(testObject->mText, QLatin1String("Tab"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_Backtab));
- QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Backtab));
- QCOMPARE(testObject->mText, QLatin1String("Backtab"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(false));
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_A));
- QCOMPARE(testObject->mForwardedKey, 0);
- QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(!key.isAccepted());
-
- testObject->reset();
-
- canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false));
- QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), false);
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, 0);
- QVERIFY(!key.isAccepted());
-
- canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true));
- QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true);
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_Return));
- QVERIFY(key.isAccepted());
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickItem::keysProcessingOrder()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(240,320));
-
- KeysTestObject *testObject = new KeysTestObject;
- canvas->rootContext()->setContextProperty("keysTestObject", testObject);
-
- canvas->setSource(testFileUrl("keyspriority.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
-
- KeyTestItem *testItem = qobject_cast<KeyTestItem*>(canvas->rootObject());
- QVERIFY(testItem);
-
- QCOMPARE(testItem->property("priorityTest").toInt(), 0);
-
- QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_A));
- QCOMPARE(testObject->mText, QLatin1String("A"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- testObject->setProcessLast(true);
-
- QCOMPARE(testItem->property("priorityTest").toInt(), 1);
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, 0);
- QVERIFY(key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_B, Qt::NoModifier, "B", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, int(Qt::Key_B));
- QCOMPARE(testObject->mText, QLatin1String("B"));
- QVERIFY(testObject->mModifiers == Qt::NoModifier);
- QVERIFY(!key.isAccepted());
-
- testObject->reset();
-
- key = QKeyEvent(QEvent::KeyRelease, Qt::Key_B, Qt::NoModifier, "B", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QCOMPARE(testObject->mKey, 0);
- QVERIFY(key.isAccepted());
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickItem::keysim()
-{
- PlatformInputContext platformInputContext;
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = &platformInputContext;
-
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(240,320));
-
- canvas->setSource(testFileUrl("keysim.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
-
- QVERIFY(canvas->rootObject());
- QVERIFY(canvas->rootObject()->hasFocus() && canvas->rootObject()->hasActiveFocus());
-
- QQuickTextInput *input = canvas->rootObject()->findChild<QQuickTextInput*>();
- QVERIFY(input);
-
- QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>());
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev);
-
- QEXPECT_FAIL("", "QTBUG-24280", Continue);
- QCOMPARE(input->text(), QLatin1String("Hello world!"));
-
- delete canvas;
-}
-
-QQuickItemPrivate *childPrivate(QQuickItem *rootItem, const char * itemString)
-{
- QQuickItem *item = findItem<QQuickItem>(rootItem, QString(QLatin1String(itemString)));
- QQuickItemPrivate* itemPrivate = QQuickItemPrivate::get(item);
- return itemPrivate;
-}
-
-QVariant childProperty(QQuickItem *rootItem, const char * itemString, const char * property)
-{
- QQuickItem *item = findItem<QQuickItem>(rootItem, QString(QLatin1String(itemString)));
- return item->property(property);
-}
-
-bool anchorsMirrored(QQuickItem *rootItem, const char * itemString)
-{
- QQuickItem *item = findItem<QQuickItem>(rootItem, QString(QLatin1String(itemString)));
- QQuickItemPrivate* itemPrivate = QQuickItemPrivate::get(item);
- return itemPrivate->anchors()->mirrored();
-}
-
-void tst_QQuickItem::layoutMirroring()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(testFileUrl("layoutmirroring.qml"));
- canvas->show();
-
- QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootItem);
- QQuickItemPrivate *rootPrivate = QQuickItemPrivate::get(rootItem);
- QVERIFY(rootPrivate);
-
- QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "mirrored2")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored2")->effectiveLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true);
-
- QCOMPARE(anchorsMirrored(rootItem, "mirrored1"), true);
- QCOMPARE(anchorsMirrored(rootItem, "mirrored2"), true);
- QCOMPARE(anchorsMirrored(rootItem, "notMirrored1"), false);
- QCOMPARE(anchorsMirrored(rootItem, "notMirrored2"), false);
- QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror1"), true);
- QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror2"), true);
-
- QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritedLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritedLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true);
-
- QCOMPARE(childPrivate(rootItem, "mirrored1")->isMirrorImplicit, false);
- QCOMPARE(childPrivate(rootItem, "mirrored2")->isMirrorImplicit, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->isMirrorImplicit, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored2")->isMirrorImplicit, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->isMirrorImplicit, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->isMirrorImplicit, true);
-
- QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromParent, true);
- QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromParent, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromParent, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromParent, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromParent, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromParent, true);
-
- QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromItem, true);
- QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromItem, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromItem, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromItem, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromItem, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromItem, false);
-
- // load dynamic content using Loader that needs to inherit mirroring
- rootItem->setProperty("state", "newContent");
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->effectiveLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->effectiveLayoutMirror, true);
-
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritedLayoutMirror, true);
-
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->isMirrorImplicit, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->isMirrorImplicit, true);
-
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromParent, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritMirrorFromParent, true);
-
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false);
-
- // disable inheritance
- rootItem->setProperty("childrenInherit", false);
-
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false);
-
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, false);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, false);
-
- // re-enable inheritance
- rootItem->setProperty("childrenInherit", true);
-
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false);
-
- QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true);
- QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true);
-
- //
- // dynamic parenting
- //
- QQuickItem *parentItem1 = new QQuickItem();
- QQuickItemPrivate::get(parentItem1)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true
- QQuickItemPrivate::get(parentItem1)->isMirrorImplicit = false;
- QQuickItemPrivate::get(parentItem1)->inheritMirrorFromItem = true; // LayoutMirroring.childrenInherit: true
- QQuickItemPrivate::get(parentItem1)->resolveLayoutMirror();
-
- // inherit in constructor
- QQuickItem *childItem1 = new QQuickItem(parentItem1);
- QCOMPARE(QQuickItemPrivate::get(childItem1)->effectiveLayoutMirror, true);
- QCOMPARE(QQuickItemPrivate::get(childItem1)->inheritMirrorFromParent, true);
-
- // inherit through a parent change
- QQuickItem *childItem2 = new QQuickItem();
- QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, false);
- QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, false);
- childItem2->setParentItem(parentItem1);
- QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, true);
- QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, true);
-
- // stop inherting through a parent change
- QQuickItem *parentItem2 = new QQuickItem();
- QQuickItemPrivate::get(parentItem2)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true
- QQuickItemPrivate::get(parentItem2)->resolveLayoutMirror();
- childItem2->setParentItem(parentItem2);
- QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, false);
- QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, false);
-
- delete parentItem1;
- delete parentItem2;
-}
-
-void tst_QQuickItem::layoutMirroringIllegalParent()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; QtObject { LayoutMirroring.enabled: true; LayoutMirroring.childrenInherit: true }", QUrl::fromLocalFile(""));
- QTest::ignoreMessage(QtWarningMsg, "file::1:21: QML QtObject: LayoutDirection attached property only works with Items");
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
-
-void tst_QQuickItem::keyNavigation()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(240,320));
-
- canvas->setSource(testFileUrl("keynavigationtest.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
-
- QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- QVariant result;
- QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify",
- Q_RETURN_ARG(QVariant, result)));
- QVERIFY(result.toBool());
-
- // right
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // down
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // left
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // up
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // tab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // backtab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- delete canvas;
-}
-
-void tst_QQuickItem::keyNavigation_RightToLeft()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(240,320));
-
- canvas->setSource(testFileUrl("keynavigationtest.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
-
- QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootItem);
- QQuickItemPrivate* rootItemPrivate = QQuickItemPrivate::get(rootItem);
-
- rootItemPrivate->effectiveLayoutMirror = true; // LayoutMirroring.mirror: true
- rootItemPrivate->isMirrorImplicit = false;
- rootItemPrivate->inheritMirrorFromItem = true; // LayoutMirroring.inherit: true
- rootItemPrivate->resolveLayoutMirror();
-
- QEvent wa(QEvent::WindowActivate);
- QGuiApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QGuiApplication::sendEvent(canvas, &fe);
-
- QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- QVariant result;
- QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify",
- Q_RETURN_ARG(QVariant, result)));
- QVERIFY(result.toBool());
-
- // right
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // left
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- delete canvas;
-}
-
-void tst_QQuickItem::keyNavigation_skipNotVisible()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(240,320));
-
- canvas->setSource(testFileUrl("keynavigationtest.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
-
- QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // Set item 2 to not visible
- item = findItem<QQuickItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- item->setVisible(false);
- QVERIFY(!item->isVisible());
-
- // right
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // tab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // backtab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- //Set item 3 to not visible
- item = findItem<QQuickItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- item->setVisible(false);
- QVERIFY(!item->isVisible());
-
- // tab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // backtab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- delete canvas;
-}
-
-void tst_QQuickItem::keyNavigation_implicitSetting()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(240,320));
-
- canvas->setSource(testFileUrl("keynavigationtest_implicit.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
-
- QEvent wa(QEvent::WindowActivate);
- QGuiApplication::sendEvent(canvas, &wa);
- QFocusEvent fe(QEvent::FocusIn);
- QGuiApplication::sendEvent(canvas, &fe);
-
- QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- QVariant result;
- QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify",
- Q_RETURN_ARG(QVariant, result)));
- QVERIFY(result.toBool());
-
- // right
- QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // back to item1
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // down
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // move to item4
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // left
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // back to item4
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // up
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item2");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // back to item4
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // tab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item1");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // back to item4
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item4");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- // backtab
- key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
- QGuiApplication::sendEvent(canvas, &key);
- QVERIFY(key.isAccepted());
-
- item = findItem<QQuickItem>(canvas->rootObject(), "item3");
- QVERIFY(item);
- QVERIFY(item->hasActiveFocus());
-
- delete canvas;
-}
-
-void tst_QQuickItem::smooth()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0; Item { smooth: false; }", QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QSignalSpy spy(item, SIGNAL(smoothChanged(bool)));
-
- QVERIFY(item);
- QVERIFY(!item->smooth());
-
- item->setSmooth(true);
- QVERIFY(item->smooth());
- QCOMPARE(spy.count(),1);
- QList<QVariant> arguments = spy.first();
- QVERIFY(arguments.count() == 1);
- QVERIFY(arguments.at(0).toBool() == true);
-
- item->setSmooth(true);
- QCOMPARE(spy.count(),1);
-
- item->setSmooth(false);
- QVERIFY(!item->smooth());
- QCOMPARE(spy.count(),2);
- item->setSmooth(false);
- QCOMPARE(spy.count(),2);
-
- delete item;
-}
-
-void tst_QQuickItem::clip()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nItem { clip: false\n }", QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QSignalSpy spy(item, SIGNAL(clipChanged(bool)));
-
- QVERIFY(item);
- QVERIFY(!item->clip());
-
- item->setClip(true);
- QVERIFY(item->clip());
-
- QList<QVariant> arguments = spy.first();
- QVERIFY(arguments.count() == 1);
- QVERIFY(arguments.at(0).toBool() == true);
-
- QCOMPARE(spy.count(),1);
- item->setClip(true);
- QCOMPARE(spy.count(),1);
-
- item->setClip(false);
- QVERIFY(!item->clip());
- QCOMPARE(spy.count(),2);
- item->setClip(false);
- QCOMPARE(spy.count(),2);
-
- delete item;
-}
-
-void tst_QQuickItem::mapCoordinates()
-{
- QFETCH(int, x);
- QFETCH(int, y);
-
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(300, 300));
- canvas->setSource(testFileUrl("mapCoordinates.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root != 0);
- QQuickItem *a = findItem<QQuickItem>(canvas->rootObject(), "itemA");
- QVERIFY(a != 0);
- QQuickItem *b = findItem<QQuickItem>(canvas->rootObject(), "itemB");
- QVERIFY(b != 0);
-
- QVariant result;
-
- QVERIFY(QMetaObject::invokeMethod(root, "mapAToB",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapToItem(b, QPointF(x, y)));
-
- QVERIFY(QMetaObject::invokeMethod(root, "mapAFromB",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapFromItem(b, QPointF(x, y)));
-
- QVERIFY(QMetaObject::invokeMethod(root, "mapAToNull",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapToScene(QPointF(x, y)));
-
- QVERIFY(QMetaObject::invokeMethod(root, "mapAFromNull",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapFromScene(QPointF(x, y)));
-
- QString warning1 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapToItem() given argument \"1122\" which is neither null nor an Item";
- QString warning2 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapFromItem() given argument \"1122\" which is neither null nor an Item";
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QVERIFY(QMetaObject::invokeMethod(root, "checkMapAToInvalid",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QVERIFY(result.toBool());
-
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QVERIFY(QMetaObject::invokeMethod(root, "checkMapAFromInvalid",
- Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
- QVERIFY(result.toBool());
-
- delete canvas;
-}
-
-void tst_QQuickItem::mapCoordinates_data()
-{
- QTest::addColumn<int>("x");
- QTest::addColumn<int>("y");
-
- for (int i=-20; i<=20; i+=10)
- QTest::newRow(QTest::toString(i)) << i << i;
-}
-
-void tst_QQuickItem::transforms_data()
-{
- QTest::addColumn<QByteArray>("qml");
- QTest::addColumn<QTransform>("transform");
- QTest::newRow("translate") << QByteArray("Translate { x: 10; y: 20 }")
- << QTransform(1,0,0,0,1,0,10,20,1);
- QTest::newRow("rotation") << QByteArray("Rotation { angle: 90 }")
- << QTransform(0,1,0,-1,0,0,0,0,1);
- QTest::newRow("scale") << QByteArray("Scale { xScale: 1.5; yScale: -2 }")
- << QTransform(1.5,0,0,0,-2,0,0,0,1);
- QTest::newRow("sequence") << QByteArray("[ Translate { x: 10; y: 20 }, Scale { xScale: 1.5; yScale: -2 } ]")
- << QTransform(1,0,0,0,1,0,10,20,1) * QTransform(1.5,0,0,0,-2,0,0,0,1);
-}
-
-void tst_QQuickItem::transforms()
-{
- QFETCH(QByteArray, qml);
- QFETCH(QTransform, transform);
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\nItem { transform: "+qml+"}", QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(item->itemTransform(0,0), transform);
-}
-
-void tst_QQuickItem::childrenProperty()
-{
- QDeclarativeComponent component(&engine, testFileUrl("childrenProperty.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test4").toBool(), true);
- QCOMPARE(o->property("test5").toBool(), true);
- delete o;
-}
-
-void tst_QQuickItem::resourcesProperty()
-{
- QDeclarativeComponent component(&engine, testFileUrl("resourcesProperty.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test1").toBool(), true);
- QCOMPARE(o->property("test2").toBool(), true);
- QCOMPARE(o->property("test3").toBool(), true);
- QCOMPARE(o->property("test4").toBool(), true);
- QCOMPARE(o->property("test5").toBool(), true);
- delete o;
-}
-
-void tst_QQuickItem::propertyChanges()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(300, 300));
- canvas->setSource(testFileUrl("propertychanges.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
-
- QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item");
- QQuickItem *parentItem = findItem<QQuickItem>(canvas->rootObject(), "parentItem");
-
- QVERIFY(item);
- QVERIFY(parentItem);
-
- QSignalSpy parentSpy(item, SIGNAL(parentChanged(QQuickItem *)));
- QSignalSpy widthSpy(item, SIGNAL(widthChanged()));
- QSignalSpy heightSpy(item, SIGNAL(heightChanged()));
- QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal)));
- QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF)));
- QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool)));
- QSignalSpy wantsFocusSpy(parentItem, SIGNAL(activeFocusChanged(bool)));
- QSignalSpy childrenChangedSpy(parentItem, SIGNAL(childrenChanged()));
- QSignalSpy xSpy(item, SIGNAL(xChanged()));
- QSignalSpy ySpy(item, SIGNAL(yChanged()));
-
- item->setParentItem(parentItem);
- item->setWidth(100.0);
- item->setHeight(200.0);
- item->setFocus(true);
- item->setBaselineOffset(10.0);
-
- QCOMPARE(item->parentItem(), parentItem);
- QCOMPARE(parentSpy.count(),1);
- QList<QVariant> parentArguments = parentSpy.first();
- QVERIFY(parentArguments.count() == 1);
- QCOMPARE(item->parentItem(), qvariant_cast<QQuickItem *>(parentArguments.at(0)));
- QCOMPARE(childrenChangedSpy.count(),1);
-
- item->setParentItem(parentItem);
- QCOMPARE(childrenChangedSpy.count(),1);
-
- QCOMPARE(item->width(), 100.0);
- QCOMPARE(widthSpy.count(),1);
-
- QCOMPARE(item->height(), 200.0);
- QCOMPARE(heightSpy.count(),1);
-
- QCOMPARE(item->baselineOffset(), 10.0);
- QCOMPARE(baselineOffsetSpy.count(),1);
- QList<QVariant> baselineOffsetArguments = baselineOffsetSpy.first();
- QVERIFY(baselineOffsetArguments.count() == 1);
- QCOMPARE(item->baselineOffset(), baselineOffsetArguments.at(0).toReal());
-
- QCOMPARE(parentItem->childrenRect(), QRectF(0.0,0.0,100.0,200.0));
- QCOMPARE(childrenRectSpy.count(),1);
- QList<QVariant> childrenRectArguments = childrenRectSpy.at(0);
- QVERIFY(childrenRectArguments.count() == 1);
- QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF());
-
- QCOMPARE(item->hasActiveFocus(), true);
- QCOMPARE(focusSpy.count(),1);
- QList<QVariant> focusArguments = focusSpy.first();
- QVERIFY(focusArguments.count() == 1);
- QCOMPARE(focusArguments.at(0).toBool(), true);
-
- QCOMPARE(parentItem->hasActiveFocus(), false);
- QCOMPARE(parentItem->hasFocus(), false);
- QCOMPARE(wantsFocusSpy.count(),0);
-
- item->setX(10.0);
- QCOMPARE(item->x(), 10.0);
- QCOMPARE(xSpy.count(), 1);
-
- item->setY(10.0);
- QCOMPARE(item->y(), 10.0);
- QCOMPARE(ySpy.count(), 1);
-
- delete canvas;
-}
-
-void tst_QQuickItem::childrenRect()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(testFileUrl("childrenRect.qml"));
- canvas->setBaseSize(QSize(240,320));
- canvas->show();
-
- QQuickItem *o = canvas->rootObject();
- QQuickItem *item = o->findChild<QQuickItem*>("testItem");
- QCOMPARE(item->width(), qreal(0));
- QCOMPARE(item->height(), qreal(0));
-
- o->setProperty("childCount", 1);
- QCOMPARE(item->width(), qreal(10));
- QCOMPARE(item->height(), qreal(20));
-
- o->setProperty("childCount", 5);
- QCOMPARE(item->width(), qreal(50));
- QCOMPARE(item->height(), qreal(100));
-
- o->setProperty("childCount", 0);
- QCOMPARE(item->width(), qreal(0));
- QCOMPARE(item->height(), qreal(0));
-
- delete o;
- delete canvas;
-}
-
-// QTBUG-11383
-void tst_QQuickItem::childrenRectBug()
-{
- QQuickView *canvas = new QQuickView(0);
-
- QString warning = testFileUrl("childrenRectBug.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\"";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- canvas->setSource(testFileUrl("childrenRectBug.qml"));
- canvas->show();
-
- QQuickItem *o = canvas->rootObject();
- QQuickItem *item = o->findChild<QQuickItem*>("theItem");
- QCOMPARE(item->width(), qreal(200));
- QCOMPARE(item->height(), qreal(100));
- QCOMPARE(item->x(), qreal(100));
-
- delete canvas;
-}
-
-// QTBUG-11465
-void tst_QQuickItem::childrenRectBug2()
-{
- QQuickView *canvas = new QQuickView(0);
-
- QString warning1 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"width\"";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
-
- QString warning2 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\"";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
-
- canvas->setSource(testFileUrl("childrenRectBug2.qml"));
- canvas->show();
-
- QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(canvas->rootObject());
- QVERIFY(rect);
- QQuickItem *item = rect->findChild<QQuickItem*>("theItem");
- QCOMPARE(item->width(), qreal(100));
- QCOMPARE(item->height(), qreal(110));
- QCOMPARE(item->x(), qreal(130));
-
- QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
- rectPrivate->setState("row");
- QCOMPARE(item->width(), qreal(210));
- QCOMPARE(item->height(), qreal(50));
- QCOMPARE(item->x(), qreal(75));
-
- delete canvas;
-}
-
-// QTBUG-12722
-void tst_QQuickItem::childrenRectBug3()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(testFileUrl("childrenRectBug3.qml"));
- canvas->show();
-
- //don't crash on delete
- delete canvas;
-}
-
-// QTBUG-13893
-void tst_QQuickItem::transformCrash()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(testFileUrl("transformCrash.qml"));
- canvas->show();
-
- delete canvas;
-}
-
-void tst_QQuickItem::implicitSize()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(testFileUrl("implicitsize.qml"));
- canvas->show();
-
- QQuickItem *item = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(item);
- QCOMPARE(item->width(), qreal(80));
- QCOMPARE(item->height(), qreal(60));
-
- QCOMPARE(item->implicitWidth(), qreal(200));
- QCOMPARE(item->implicitHeight(), qreal(100));
-
- QMetaObject::invokeMethod(item, "resetSize");
-
- QCOMPARE(item->width(), qreal(200));
- QCOMPARE(item->height(), qreal(100));
-
- QMetaObject::invokeMethod(item, "changeImplicit");
-
- QCOMPARE(item->implicitWidth(), qreal(150));
- QCOMPARE(item->implicitHeight(), qreal(80));
- QCOMPARE(item->width(), qreal(150));
- QCOMPARE(item->height(), qreal(80));
-
- delete canvas;
-}
-
-void tst_QQuickItem::qtbug_16871()
-{
- QDeclarativeComponent component(&engine, testFileUrl("qtbug_16871.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- delete o;
-}
-
-
-void tst_QQuickItem::visibleChildren()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(testFileUrl("visiblechildren.qml"));
- canvas->show();
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root);
-
- QCOMPARE(root->property("test1_1").toBool(), true);
- QCOMPARE(root->property("test1_2").toBool(), true);
- QCOMPARE(root->property("test1_3").toBool(), true);
- QCOMPARE(root->property("test1_4").toBool(), true);
-
- QMetaObject::invokeMethod(root, "hideFirstAndLastRowChild");
- QCOMPARE(root->property("test2_1").toBool(), true);
- QCOMPARE(root->property("test2_2").toBool(), true);
- QCOMPARE(root->property("test2_3").toBool(), true);
- QCOMPARE(root->property("test2_4").toBool(), true);
-
- QMetaObject::invokeMethod(root, "showLastRowChildsLastChild");
- QCOMPARE(root->property("test3_1").toBool(), true);
- QCOMPARE(root->property("test3_2").toBool(), true);
- QCOMPARE(root->property("test3_3").toBool(), true);
- QCOMPARE(root->property("test3_4").toBool(), true);
-
- QMetaObject::invokeMethod(root, "showLastRowChild");
- QCOMPARE(root->property("test4_1").toBool(), true);
- QCOMPARE(root->property("test4_2").toBool(), true);
- QCOMPARE(root->property("test4_3").toBool(), true);
- QCOMPARE(root->property("test4_4").toBool(), true);
-
- QString warning1 = testFileUrl("visiblechildren.qml").toString() + ":96:32: QML Item: QQuickItem: visibleChildren property is readonly and cannot be assigned to.";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QMetaObject::invokeMethod(root, "tryWriteToReadonlyVisibleChildren");
- QCOMPARE(root->property("test5_1").toBool(), true);
-
- QMetaObject::invokeMethod(root, "reparentVisibleItem3");
- QCOMPARE(root->property("test6_1").toBool(), true);
- QCOMPARE(root->property("test6_2").toBool(), true);
- QCOMPARE(root->property("test6_3").toBool(), true);
- QCOMPARE(root->property("test6_4").toBool(), true);
-
- QMetaObject::invokeMethod(root, "reparentImlicitlyInvisibleItem4_1");
- QCOMPARE(root->property("test7_1").toBool(), true);
- QCOMPARE(root->property("test7_2").toBool(), true);
- QCOMPARE(root->property("test7_3").toBool(), true);
- QCOMPARE(root->property("test7_4").toBool(), true);
-
- // FINALLY TEST THAT EVERYTHING IS AS EXPECTED
- QCOMPARE(root->property("test8_1").toBool(), true);
- QCOMPARE(root->property("test8_2").toBool(), true);
- QCOMPARE(root->property("test8_3").toBool(), true);
- QCOMPARE(root->property("test8_4").toBool(), true);
- QCOMPARE(root->property("test8_5").toBool(), true);
-
- delete canvas;
-}
-
-void tst_QQuickItem::parentLoop()
-{
- QQuickView *canvas = new QQuickView(0);
-
- QTest::ignoreMessage(QtWarningMsg, "QQuickItem::setParentItem: Parent is already part of this items subtree.");
- canvas->setSource(testFileUrl("parentLoop.qml"));
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root);
-
- QQuickItem *item1 = root->findChild<QQuickItem*>("item1");
- QVERIFY(item1);
- QCOMPARE(item1->parentItem(), root);
-
- QQuickItem *item2 = root->findChild<QQuickItem*>("item2");
- QVERIFY(item2);
- QCOMPARE(item2->parentItem(), item1);
-
- delete canvas;
-}
-
-QTEST_MAIN(tst_QQuickItem)
-
-#include "tst_qquickitem.moc"
diff --git a/tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro b/tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro
deleted file mode 100644
index 557e23d150..0000000000
--- a/tests/auto/qtquick2/qquickitemlayer/qquickitemlayer.pro
+++ /dev/null
@@ -1,38 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickitemlayer
-SOURCES += tst_qquickitemlayer.cpp
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-include(../../shared/util.pri)
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private quick-private testlib
-
-OTHER_FILES += \
- data/Smooth.qml \
- data/Enabled.qml \
- data/Mipmap.qml \
- data/Effect.qml \
- data/SourceRect.qml \
- data/TextureProvider.qml \
- data/Visible.qml \
- data/ZOrder.qml \
- data/ZOrderChange.qml \
- data/ToggleLayerAndEffect.qml \
- data/DisableLayer.qml \
- data/SamplerNameChange.qml \
- data/ItemEffect.qml \
- data/RectangleEffect.qml
-
-
-
-
-
-
-
-
diff --git a/tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp
deleted file mode 100644
index 2a856707ba..0000000000
--- a/tests/auto/qtquick2/qquickitemlayer/tst_qquickitemlayer.cpp
+++ /dev/null
@@ -1,436 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickview.h>
-#include <QtGui/qopenglcontext.h>
-
-#include "../../shared/util.h"
-
-class tst_QQuickItemLayer: public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickItemLayer();
-
- QImage runTest(const QString &url)
- {
- QQuickView view;
- view.setSource(QUrl(url));
-
- view.show();
- QTest::qWaitForWindowShown(&view);
-
- return view.grabFrameBuffer();
- }
-
-private slots:
- void layerEnabled();
- void layerSmooth();
- void layerMipmap();
- void layerEffect();
-
- void layerVisibility_data();
- void layerVisibility();
-
- void layerSourceRect();
-
- void layerZOrder_data();
- void layerZOrder();
-
- void layerIsTextureProvider();
-
- void changeZOrder_data();
- void changeZOrder();
-
- void toggleLayerAndEffect();
- void disableLayer();
- void changeSamplerName();
- void itemEffect();
- void rectangleEffect();
-
-private:
- bool m_isMesaSoftwareRasterizer;
- int m_mesaVersion;
-};
-
-tst_QQuickItemLayer::tst_QQuickItemLayer()
- : m_mesaVersion(0)
-{
- QWindow window;
- QOpenGLContext context;
- window.setSurfaceType(QWindow::OpenGLSurface);
- window.create();
- context.create();
- context.makeCurrent(&window);
- const char *vendor = (const char *)glGetString(GL_VENDOR);
- const char *renderer = (const char *)glGetString(GL_RENDERER);
- m_isMesaSoftwareRasterizer = strcmp(vendor, "Mesa Project") == 0
- && strcmp(renderer, "Software Rasterizer") == 0;
- if (m_isMesaSoftwareRasterizer) {
- // Expects format: <OpenGL version> Mesa <Mesa version>[-devel] [...]
- const char *version = (const char *)glGetString(GL_VERSION);
- QList<QByteArray> list = QByteArray(version).split(' ');
- if (list.size() >= 3) {
- list = list.at(2).split('-').at(0).split('.');
- int major = 0;
- int minor = 0;
- int patch = 0;
- if (list.size() >= 1)
- major = list.at(0).toInt();
- if (list.size() >= 2)
- minor = list.at(1).toInt();
- if (list.size() >= 3)
- patch = list.at(2).toInt();
- m_mesaVersion = QT_VERSION_CHECK(major, minor, patch);
- }
- }
-}
-
-// The test draws a red and a blue box next to each other and tests that the
-// output is still red and blue on the left and right and a combination of
-// the two in the middle.
-
-void tst_QQuickItemLayer::layerSmooth()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
- QImage fb = runTest(testFile("Smooth.qml"));
- QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
- QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff));
-
- uint pixel = fb.pixel(fb.width() / 2, 0);
- QVERIFY(qRed(pixel) > 0);
- QVERIFY(qBlue(pixel) > 0);
-}
-
-
-
-// The test draws a gradient at a small size into a layer and scales the
-// layer. If the layer is enabled there should be very visible bands in
-// the gradient.
-
-void tst_QQuickItemLayer::layerEnabled()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
- QImage fb = runTest(testFile("Enabled.qml"));
- // Verify the banding
- QCOMPARE(fb.pixel(0, 0), fb.pixel(0, 1));
- // Verify the gradient
- QVERIFY(fb.pixel(0, 0) != fb.pixel(0, fb.height() - 1));
-}
-
-
-
-// The test draws a one pixel wide line and scales it down by more than a a factor 2
-// If mipmpping works, the pixels should be gray, not white or black
-
-void tst_QQuickItemLayer::layerMipmap()
-{
- if (m_isMesaSoftwareRasterizer)
- QSKIP("Mipmapping does not work with the Mesa Software Rasterizer.");
- QImage fb = runTest(testFile("Mipmap.qml"));
- QVERIFY(fb.pixel(0, 0) != 0xff000000);
- QVERIFY(fb.pixel(0, 0) != 0xffffffff);
-}
-
-
-
-// The test implements an rgb swapping effect sourced from a blue rectangle. The
-// resulting pixel should be red
-
-void tst_QQuickItemLayer::layerEffect()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
- QImage fb = runTest(testFile("Effect.qml"));
- QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
- QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0));
-}
-
-
-
-// The test draws a rectangle and verifies that there is padding on each side
-// as the source rect spans outside the item. The padding is verified using
-// a shader that pads transparent to blue. Everything else is red.
-void tst_QQuickItemLayer::layerSourceRect()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
-
- QImage fb = runTest(testFile("SourceRect.qml"));
-
- // Check that the edges are converted to blue
- QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff));
- QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff));
- QCOMPARE(fb.pixel(0, fb.height() - 1), qRgb(0, 0, 0xff));
- QCOMPARE(fb.pixel(fb.width() - 1, fb.height() - 1), qRgb(0, 0, 0xff));
-
- // The center pixel should be red
- QCOMPARE(fb.pixel(fb.width() / 2, fb.height() / 2), qRgb(0xff, 0, 0));
-}
-
-
-
-// Same as the effect test up above, but this time use the item
-// directly in a stand alone ShaderEffect
-void tst_QQuickItemLayer::layerIsTextureProvider()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
- QImage fb = runTest(testFile("TextureProvider.qml"));
- QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
- QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0));
-}
-
-
-void tst_QQuickItemLayer::layerVisibility_data()
-{
- QTest::addColumn<bool>("visible");
- QTest::addColumn<bool>("effect");
- QTest::addColumn<qreal>("opacity");
-
- QTest::newRow("!effect, !visible, a=1") << false << false << 1.;
- QTest::newRow("!effect, visible, a=1") << false << true << 1.;
- QTest::newRow("effect, !visible, a=1") << true << false << 1.;
- QTest::newRow("effect, visible, a=1") << true << true << 1.;
-
- QTest::newRow("!effect, !visible, a=.5") << false << false << .5;
- QTest::newRow("!effect, visible, a=.5") << false << true << .5;
- QTest::newRow("effect, !visible, a=.5") << true << false << .5;
- QTest::newRow("effect, visible, a=.5") << true << true << .5;
-
- QTest::newRow("!effect, !visible, a=0") << false << false << 0.;
- QTest::newRow("!effect, visible, a=0") << false << true << 0.;
- QTest::newRow("effect, !visible, a=0") << true << false << 0.;
- QTest::newRow("effect, visible, a=0") << true << true << 0.;
-}
-
-void tst_QQuickItemLayer::layerVisibility()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
-
- QFETCH(bool, visible);
- QFETCH(bool, effect);
- QFETCH(qreal, opacity);
-
- QQuickView view;
- view.setSource(testFile("Visible.qml"));
-
- QQuickItem *child = view.rootItem()->childItems().at(0);
- child->setProperty("layerVisible", visible);
- child->setProperty("layerEffect", effect);
- child->setProperty("layerOpacity", opacity);
-
- view.show();
-
- QTest::qWaitForWindowShown(&view);
-
- QImage fb = view.grabFrameBuffer();
- uint pixel = fb.pixel(0, 0);
-
- if (!visible || opacity == 0) {
- QCOMPARE(pixel, qRgb(0xff, 0xff, 0xff));
- } else if (effect) {
- QCOMPARE(qRed(pixel), 0xff);
- QVERIFY(qGreen(pixel) < 0xff);
- QVERIFY(qBlue(pixel) < 0xff);
- } else { // no effect
- QCOMPARE(qBlue(pixel), 0xff);
- QVERIFY(qGreen(pixel) < 0xff);
- QVERIFY(qRed(pixel) < 0xff);
- }
-}
-
-
-
-
-void tst_QQuickItemLayer::layerZOrder_data()
-{
- QTest::addColumn<bool>("effect");
-
- QTest::newRow("!effect") << false;
- QTest::newRow("effect") << true;
-}
-
-void tst_QQuickItemLayer::layerZOrder()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
-
- QFETCH(bool, effect);
-
- QQuickView view;
- view.setSource(testFile("ZOrder.qml"));
-
- QQuickItem *child = view.rootItem()->childItems().at(0);
- child->setProperty("layerEffect", effect);
-
- view.show();
-
- QTest::qWaitForWindowShown(&view);
-
- QImage fb = view.grabFrameBuffer();
-
- QCOMPARE(fb.pixel(50, 50), qRgb(0, 0, 0xff));
- QCOMPARE(fb.pixel(150, 150), qRgb(0, 0xff, 00));
-
-}
-
-void tst_QQuickItemLayer::changeZOrder_data()
-{
- QTest::addColumn<bool>("layered");
- QTest::addColumn<bool>("effect");
-
- QTest::newRow("layered, effect") << true << true;
- QTest::newRow("layered, !effect") << true << false;
- QTest::newRow("!layered") << false << false;
-}
-
-void tst_QQuickItemLayer::changeZOrder()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
-
- QFETCH(bool, layered);
- QFETCH(bool, effect);
-
- QQuickView view;
- view.setSource(testFile("ZOrderChange.qml"));
-
- QQuickItem *child = view.rootItem()->childItems().at(0);
- child->setProperty("layerEnabled", layered);
- child->setProperty("layerEffect", effect);
- child->setProperty("layerZ", 1);
-
- view.show();
-
- QTest::qWaitForWindowShown(&view);
-
- QImage fb = view.grabFrameBuffer();
-
- QRgb topLeft = fb.pixel(50, 50);
- QRgb topRight = fb.pixel(150, 50);
- QRgb bottomLeft = fb.pixel(50, 150);
- QRgb bottomRight = fb.pixel(150, 150);
-
- QCOMPARE(bottomLeft, qRgb(0, 0, 0xff));
-
- if (layered) {
- QCOMPARE(topLeft, qRgb(0, 0xff, 0xff));
- } else {
- QCOMPARE(qGreen(topLeft), 0xff);
- QVERIFY(qAbs(qRed(topLeft) - 0x3f) < 4);
- QVERIFY(qAbs(qBlue(topLeft) - 0xbf) < 4);
- }
-
- if (layered && effect) {
- QCOMPARE(qRed(topRight), 0xff);
- QCOMPARE(qGreen(topRight), 0x00);
- QVERIFY(qAbs(qBlue(topRight) - 0x7f) < 4);
-
- QVERIFY(qAbs(qRed(bottomRight) - 0x7f) < 4);
- QCOMPARE(qBlue(bottomRight), 0xff);
- QVERIFY(qAbs(qGreen(bottomRight) - 0x7f) < 4);
- } else {
- QCOMPARE(qRed(topRight), 0xff);
- QCOMPARE(qBlue(topRight), 0x00);
- QVERIFY(qAbs(qGreen(topRight) - 0x7f) < 4);
-
- QVERIFY(qAbs(qRed(bottomRight) - 0x7f) < 4);
- QCOMPARE(qGreen(bottomRight), 0xff);
- QVERIFY(qAbs(qBlue(bottomRight) - 0x7f) < 4);
- }
-}
-
-void tst_QQuickItemLayer::toggleLayerAndEffect()
-{
- // This test passes if it doesn't crash.
- runTest(testFile("ToggleLayerAndEffect.qml"));
-}
-
-void tst_QQuickItemLayer::disableLayer()
-{
- // This test passes if it doesn't crash.
- runTest(testFile("DisableLayer.qml"));
-}
-
-void tst_QQuickItemLayer::changeSamplerName()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
- QImage fb = runTest(testFile("SamplerNameChange.qml"));
- QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff));
-}
-
-void tst_QQuickItemLayer::itemEffect()
-{
- if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
- QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
- QImage fb = runTest(testFile("ItemEffect.qml"));
- QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
- QCOMPARE(fb.pixel(199, 0), qRgb(0xff, 0, 0));
- QCOMPARE(fb.pixel(0, 199), qRgb(0, 0, 0xff));
- QCOMPARE(fb.pixel(199, 199), qRgb(0, 0, 0xff));
-}
-
-void tst_QQuickItemLayer::rectangleEffect()
-{
- QImage fb = runTest(testFile("RectangleEffect.qml"));
- QCOMPARE(fb.pixel(0, 0), qRgb(0, 0xff, 0));
- QCOMPARE(fb.pixel(199, 0), qRgb(0, 0xff, 0));
- QCOMPARE(fb.pixel(0, 199), qRgb(0, 0xff, 0));
- QCOMPARE(fb.pixel(199, 199), qRgb(0, 0xff, 0));
-
- QCOMPARE(fb.pixel(100, 0), qRgb(0, 0, 0xff));
- QCOMPARE(fb.pixel(199, 100), qRgb(0, 0, 0xff));
- QCOMPARE(fb.pixel(100, 199), qRgb(0, 0, 0xff));
- QCOMPARE(fb.pixel(0, 100), qRgb(0, 0, 0xff));
-}
-
-
-QTEST_MAIN(tst_QQuickItemLayer)
-
-#include "tst_qquickitemlayer.moc"
diff --git a/tests/auto/qtquick2/qquicklistview/data/addTransitions.qml b/tests/auto/qtquick2/qquicklistview/data/addTransitions.qml
deleted file mode 100644
index ff90ead8a6..0000000000
--- a/tests/auto/qtquick2/qquicklistview/data/addTransitions.qml
+++ /dev/null
@@ -1,134 +0,0 @@
-import QtQuick 2.0
-
-Rectangle {
- id: root
- width: 500
- height: 600
-
- property int duration: 10
- property int count: list.count
-
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
-
- property string nameData: name
-
- objectName: "wrapper"
- height: 20
- width: 240
- Text { text: index }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 200
- text: wrapper.y
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
-
- onXChanged: checkPos()
- onYChanged: checkPos()
-
- function checkPos() {
- if (Qt.point(x, y) == targetItems_transitionFrom)
- model_targetItems_transitionFrom.addItem(name, "")
- if (Qt.point(x, y) == displacedItems_transitionVia)
- model_displacedItems_transitionVia.addItem(name, "")
- }
- }
- }
-
- ListView {
- id: list
-
- property int targetTransitionsDone
- property int displaceTransitionsDone
-
- property var targetTrans_items: new Object()
- property var targetTrans_targetIndexes: new Array()
- property var targetTrans_targetItems: new Array()
-
- property var displacedTrans_items: new Object()
- property var displacedTrans_targetIndexes: new Array()
- property var displacedTrans_targetItems: new Array()
-
- objectName: "list"
- focus: true
- anchors.centerIn: parent
- width: 240
- height: 320
- model: testModel
- delegate: myDelegate
-
- // for QDeclarativeListProperty types
- function copyList(propList) {
- var temp = new Array()
- for (var i=0; i<propList.length; i++)
- temp.push(propList[i])
- return temp
- }
-
- add: Transition {
- id: targetTransition
-
- SequentialAnimation {
- ScriptAction {
- script: {
- list.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
- list.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
- list.targetTrans_targetItems.push(list.copyList(targetTransition.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; from: targetItems_transitionFrom.x; duration: root.duration }
- NumberAnimation { properties: "y"; from: targetItems_transitionFrom.y; duration: root.duration }
- }
-
- ScriptAction { script: list.targetTransitionsDone += 1 }
- }
- }
-
- addDisplaced: Transition {
- id: displaced
-
- SequentialAnimation {
- ScriptAction {
- script: {
- list.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
- list.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
- list.displacedTrans_targetItems.push(list.copyList(displaced.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; duration: root.duration; to: displacedItems_transitionVia.x }
- NumberAnimation { properties: "y"; duration: root.duration; to: displacedItems_transitionVia.y }
- }
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: list.displaceTransitionsDone += 1 }
- }
-
- }
- }
-
- Rectangle {
- anchors.fill: list
- color: "lightsteelblue"
- opacity: 0.2
- }
-
- // XXX will it pass without these if I just wait for polish?
- // check all of these tests - if not, then mark this bit with the bug number!
- Rectangle {
- anchors.bottom: parent.bottom
- width: 20; height: 20
- color: "white"
- NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 100000 }
- }
-}
-
diff --git a/tests/auto/qtquick2/qquicklistview/data/moveTransitions.qml b/tests/auto/qtquick2/qquicklistview/data/moveTransitions.qml
deleted file mode 100644
index 744db3110e..0000000000
--- a/tests/auto/qtquick2/qquicklistview/data/moveTransitions.qml
+++ /dev/null
@@ -1,141 +0,0 @@
-import QtQuick 2.0
-
-Rectangle {
- id: root
- width: 500
- height: 600
-
- property int duration: 10
- property int count: list.count
-
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
-
- property string nameData: name
-
- objectName: "wrapper"
- height: 20
- width: 240
- Text { text: index }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 200
- text: wrapper.y
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
-
- onXChanged: checkPos()
- onYChanged: checkPos()
-
- function checkPos() {
- if (Qt.point(x, y) == targetItems_transitionVia)
- model_targetItems_transitionVia.addItem(name, "")
- if (Qt.point(x, y) == displacedItems_transitionVia)
- model_displacedItems_transitionVia.addItem(name, "")
- }
- }
- }
-
- ListView {
- id: list
-
- property int targetTransitionsDone
- property int displaceTransitionsDone
-
- property var targetTrans_items: new Object()
- property var targetTrans_targetIndexes: new Array()
- property var targetTrans_targetItems: new Array()
-
- property var displacedTrans_items: new Object()
- property var displacedTrans_targetIndexes: new Array()
- property var displacedTrans_targetItems: new Array()
-
- objectName: "list"
- focus: true
- anchors.centerIn: parent
- width: 240
- height: 320
- model: testModel
- delegate: myDelegate
-
- // for QDeclarativeListProperty types
- function copyList(propList) {
- var temp = new Array()
- for (var i=0; i<propList.length; i++)
- temp.push(propList[i])
- return temp
- }
-
- move: Transition {
- id: targetTransition
-
- SequentialAnimation {
- ScriptAction {
- script: {
- list.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
- list.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
- list.targetTrans_targetItems.push(list.copyList(targetTransition.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; to: targetItems_transitionVia.x; duration: root.duration }
- NumberAnimation { properties: "y"; to: targetItems_transitionVia.y; duration: root.duration }
- }
-
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: list.targetTransitionsDone += 1 }
- }
- }
-
- moveDisplaced: Transition {
- id: displaced
-
- SequentialAnimation {
- ScriptAction {
- script: {
- list.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
- list.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
- list.displacedTrans_targetItems.push(list.copyList(displaced.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation {
- properties: "x"; duration: root.duration
- to: displacedItems_transitionVia.x
- }
- NumberAnimation {
- properties: "y"; duration: root.duration
- to: displacedItems_transitionVia.y
- }
- }
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: list.displaceTransitionsDone += 1 }
- }
-
- }
- }
-
- Rectangle {
- anchors.fill: list
- color: "lightsteelblue"
- opacity: 0.2
- }
-
- Rectangle {
- anchors.bottom: parent.bottom
- width: 20; height: 20
- color: "white"
- NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 10000 }
- }
-}
-
-
diff --git a/tests/auto/qtquick2/qquicklistview/data/removeTransitions.qml b/tests/auto/qtquick2/qquicklistview/data/removeTransitions.qml
deleted file mode 100644
index 95f76f0200..0000000000
--- a/tests/auto/qtquick2/qquicklistview/data/removeTransitions.qml
+++ /dev/null
@@ -1,144 +0,0 @@
-import QtQuick 2.0
-
-Rectangle {
- id: root
- width: 500
- height: 600
-
- property int duration: 10
- property int count: list.count
-
- Component {
- id: myDelegate
- Rectangle {
- id: wrapper
-
- property string nameData: name
-
- objectName: "wrapper"
- height: 20
- width: 240
- Text { text: index }
- Text {
- x: 30
- id: textName
- objectName: "textName"
- text: name
- }
- Text {
- x: 200
- text: wrapper.y
- }
- color: ListView.isCurrentItem ? "lightsteelblue" : "white"
-
- onXChanged: checkPos()
- onYChanged: checkPos()
-
- function checkPos() {
- if (Qt.point(x, y) == targetItems_transitionTo) {
- model_targetItems_transitionTo.addItem(nameData, "") // name is invalid once model removes the item
- }
- if (Qt.point(x, y) == displacedItems_transitionVia) {
- model_displacedItems_transitionVia.addItem(name, "")
- }
- }
- }
- }
-
- ListView {
- id: list
-
- property int targetTransitionsDone
- property int displaceTransitionsDone
-
- property var targetTrans_items: new Object()
- property var targetTrans_targetIndexes: new Array()
- property var targetTrans_targetItems: new Array()
-
- property var displacedTrans_items: new Object()
- property var displacedTrans_targetIndexes: new Array()
- property var displacedTrans_targetItems: new Array()
-
- objectName: "list"
- focus: true
- anchors.centerIn: parent
- width: 240
- height: 320
- model: testModel
- delegate: myDelegate
-
- // for QDeclarativeListProperty types
- function copyList(propList) {
- var temp = new Array()
- for (var i=0; i<propList.length; i++)
- temp.push(propList[i])
- return temp
- }
-
- remove: Transition {
- id: targetTransition
-
- SequentialAnimation {
- ScriptAction {
- script: {
- list.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
- list.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
- list.targetTrans_targetItems.push(list.copyList(targetTransition.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation { properties: "x"; to: targetItems_transitionTo.x; duration: root.duration }
- NumberAnimation { properties: "y"; to: targetItems_transitionTo.y; duration: root.duration }
- }
- ScriptAction { script: list.targetTransitionsDone += 1 }
-
- // delay deleting this item so that it stays valid for the tests
- // (this doesn't delay the test itself)
- PauseAnimation { duration: 10000 }
- }
- }
-
- removeDisplaced: Transition {
- id: displaced
-
- SequentialAnimation {
- ScriptAction {
- script: {
- list.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
- list.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
- list.displacedTrans_targetItems.push(list.copyList(displaced.ViewTransition.targetItems))
- }
- }
- ParallelAnimation {
- NumberAnimation {
- properties: "x"; duration: root.duration
- to: displacedItems_transitionVia.x
- }
- NumberAnimation {
- properties: "y"; duration: root.duration
- to: displacedItems_transitionVia.y
- }
- }
- NumberAnimation { properties: "x,y"; duration: root.duration }
-
- ScriptAction { script: list.displaceTransitionsDone += 1 }
- }
-
- }
- }
-
- Rectangle {
- anchors.fill: list
- color: "lightsteelblue"
- opacity: 0.2
- }
-
- Rectangle {
- anchors.bottom: parent.bottom
- width: 20; height: 20
- color: "white"
- NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 10000 }
- }
-}
-
-
diff --git a/tests/auto/qtquick2/qquicklistview/qquicklistview.pro b/tests/auto/qtquick2/qquicklistview/qquicklistview.pro
deleted file mode 100644
index 6828bf2f13..0000000000
--- a/tests/auto/qtquick2/qquicklistview/qquicklistview.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquicklistview
-macx:CONFIG -= app_bundle
-
-HEADERS += incrementalmodel.h
-SOURCES += tst_qquicklistview.cpp \
- incrementalmodel.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-QT += core-private gui-private declarative-private quick-private widgets widgets-private v8-private opengl-private testlib
diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp
deleted file mode 100644
index eb7efd6d33..0000000000
--- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp
+++ /dev/null
@@ -1,5715 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtCore/QStringListModel>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativeincubator.h>
-#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/private/qquicklistview_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qquickvisualitemmodel_p.h>
-#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
-#include "../../shared/util.h"
-#include "../shared/viewtestutil.h"
-#include "../shared/visualtestutil.h"
-#include "incrementalmodel.h"
-#include <math.h>
-
-Q_DECLARE_METATYPE(Qt::LayoutDirection)
-Q_DECLARE_METATYPE(QQuickListView::Orientation)
-
-using namespace QQuickViewTestUtil;
-using namespace QQuickVisualTestUtil;
-
-class tst_QQuickListView : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickListView();
-
-private slots:
- // Test both QListModelInterface and QAbstractItemModel model types
- void qListModelInterface_items();
- void qListModelInterface_package_items();
- void qAbstractItemModel_items();
-
- void qListModelInterface_changed();
- void qListModelInterface_package_changed();
- void qAbstractItemModel_changed();
-
- void qListModelInterface_inserted();
- void qListModelInterface_inserted_more();
- void qListModelInterface_inserted_more_data();
- void qListModelInterface_package_inserted();
- void qAbstractItemModel_inserted();
- void qAbstractItemModel_inserted_more();
- void qAbstractItemModel_inserted_more_data();
-
- void qListModelInterface_removed();
- void qListModelInterface_removed_more();
- void qListModelInterface_removed_more_data();
- void qListModelInterface_package_removed();
- void qAbstractItemModel_removed();
- void qAbstractItemModel_removed_more();
- void qAbstractItemModel_removed_more_data();
-
- void qListModelInterface_moved();
- void qListModelInterface_moved_data();
- void qListModelInterface_package_moved();
- void qListModelInterface_package_moved_data();
- void qAbstractItemModel_moved();
- void qAbstractItemModel_moved_data();
-
- void multipleChanges();
- void multipleChanges_data();
-
- void qListModelInterface_clear();
- void qListModelInterface_package_clear();
- void qAbstractItemModel_clear();
-
- void insertBeforeVisible();
- void insertBeforeVisible_data();
- void swapWithFirstItem();
- void itemList();
- void currentIndex_delayedItemCreation();
- void currentIndex_delayedItemCreation_data();
- void currentIndex();
- void noCurrentIndex();
- void enforceRange();
- void enforceRange_withoutHighlight();
- void spacing();
- void qListModelInterface_sections();
- void qListModelInterface_package_sections();
- void qAbstractItemModel_sections();
- void sectionsPositioning();
- void sectionsDelegate();
- void cacheBuffer();
- void positionViewAtIndex();
- void resetModel();
- void propertyChanges();
- void componentChanges();
- void modelChanges();
- void manualHighlight();
- void header();
- void header_data();
- void header_delayItemCreation();
- void footer();
- void footer_data();
- void headerFooter();
- void resizeView();
- void resizeViewAndRepaint();
- void sizeLessThan1();
- void QTBUG_14821();
- void resizeDelegate();
- void resizeFirstDelegate();
- void QTBUG_16037();
- void indexAt_itemAt_data();
- void indexAt_itemAt();
- void incrementalModel();
- void onAdd();
- void onAdd_data();
- void onRemove();
- void onRemove_data();
- void rightToLeft();
- void test_mirroring();
- void margins();
- void marginsResize();
- void marginsResize_data();
- void creationContext();
- void snapToItem_data();
- void snapToItem();
- void snapOneItem_data();
- void snapOneItem();
-
- void QTBUG_9791();
- void QTBUG_11105();
- void QTBUG_21742();
-
- void asynchronous();
- void unrequestedVisibility();
-
- void populateTransitions();
- void populateTransitions_data();
- void addTransitions();
- void addTransitions_data();
- void moveTransitions();
- void moveTransitions_data();
- void removeTransitions();
- void removeTransitions_data();
- void multipleTransitions();
- void multipleTransitions_data();
-
-private:
- template <class T> void items(const QUrl &source, bool forceLayout);
- template <class T> void changed(const QUrl &source, bool forceLayout);
- template <class T> void inserted(const QUrl &source);
- template <class T> void inserted_more();
- template <class T> void removed(const QUrl &source, bool animated);
- template <class T> void removed_more(const QUrl &source);
- template <class T> void moved(const QUrl &source);
- template <class T> void clear(const QUrl &source);
- template <class T> void sections(const QUrl &source);
-
- QList<int> toIntList(const QVariantList &list);
- void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes);
- void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes);
- void matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems);
-
- void inserted_more_data();
- void removed_more_data();
- void moved_data();
-};
-
-class TestObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(bool error READ error WRITE setError NOTIFY changedError)
- Q_PROPERTY(bool animate READ animate NOTIFY changedAnim)
- Q_PROPERTY(bool invalidHighlight READ invalidHighlight NOTIFY changedHl)
- Q_PROPERTY(int cacheBuffer READ cacheBuffer NOTIFY changedCacheBuffer)
-
-public:
- TestObject(QObject *parent = 0)
- : QObject(parent), mError(true), mAnimate(false), mInvalidHighlight(false)
- , mCacheBuffer(0) {}
-
- bool error() const { return mError; }
- void setError(bool err) { mError = err; emit changedError(); }
-
- bool animate() const { return mAnimate; }
- void setAnimate(bool anim) { mAnimate = anim; emit changedAnim(); }
-
- bool invalidHighlight() const { return mInvalidHighlight; }
- void setInvalidHighlight(bool invalid) { mInvalidHighlight = invalid; emit changedHl(); }
-
- int cacheBuffer() const { return mCacheBuffer; }
- void setCacheBuffer(int buffer) { mCacheBuffer = buffer; emit changedCacheBuffer(); }
-
-signals:
- void changedError();
- void changedAnim();
- void changedHl();
- void changedCacheBuffer();
-
-public:
- bool mError;
- bool mAnimate;
- bool mInvalidHighlight;
- int mCacheBuffer;
-};
-
-tst_QQuickListView::tst_QQuickListView()
-{
-}
-
-template <class T>
-void tst_QQuickListView::items(const QUrl &source, bool forceLayout)
-{
- QQuickView *canvas = createView();
-
- T model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(source);
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QTRY_VERIFY(testObject->error() == false);
-
- QTRY_VERIFY(listview->highlightItem() != 0);
- QTRY_COMPARE(listview->count(), model.count());
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- // current item should be first item
- QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
-
- for (int i = 0; i < model.count(); ++i) {
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- // switch to other delegate
- testObject->setAnimate(true);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QTRY_VERIFY(testObject->error() == false);
- QTRY_VERIFY(listview->currentItem());
-
- // set invalid highlight
- testObject->setInvalidHighlight(true);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QTRY_VERIFY(testObject->error() == false);
- QTRY_VERIFY(listview->currentItem());
- QTRY_VERIFY(listview->highlightItem() == 0);
-
- // back to normal highlight
- testObject->setInvalidHighlight(false);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QTRY_VERIFY(testObject->error() == false);
- QTRY_VERIFY(listview->currentItem());
- QTRY_VERIFY(listview->highlightItem() != 0);
-
- // set an empty model and confirm that items are destroyed
- T model2;
- ctxt->setContextProperty("testModel", &model2);
-
- // Force a layout, necessary if ListView is completed before VisualDataModel.
- if (forceLayout)
- QCOMPARE(listview->property("count").toInt(), 0);
-
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QTRY_VERIFY(itemCount == 0);
-
- QTRY_COMPARE(listview->highlightResizeSpeed(), 1000.0);
- QTRY_COMPARE(listview->highlightMoveSpeed(), 1000.0);
-
- delete canvas;
- delete testObject;
-}
-
-
-template <class T>
-void tst_QQuickListView::changed(const QUrl &source, bool forceLayout)
-{
- QQuickView *canvas = createView();
-
- T model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(source);
- qApp->processEvents();
-
- QQuickFlickable *listview = findItem<QQuickFlickable>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // Force a layout, necessary if ListView is completed before VisualDataModel.
- if (forceLayout)
- QCOMPARE(listview->property("count").toInt(), model.count());
-
- model.modifyItem(1, "Will", "9876");
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- delete canvas;
- delete testObject;
-}
-
-template <class T>
-void tst_QQuickListView::inserted(const QUrl &source)
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- T model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(source);
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- model.insertItem(1, "Will", "9876");
-
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_COMPARE(item->y(), i*20.0);
- }
-
- model.insertItem(0, "Foo", "1111"); // zero index, and current item
-
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
- QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
-
- name = findItem<QQuickText>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QQuickText>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- QTRY_COMPARE(listview->currentIndex(), 1);
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count(); ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_COMPARE(item->y(), i*20.0);
- }
-
- for (int i = model.count(); i < 30; ++i)
- model.insertItem(i, "Hello", QString::number(i));
-
- listview->setContentY(80);
-
- // Insert item outside visible area
- model.insertItem(1, "Hello", "1324");
-
- QTRY_VERIFY(listview->contentY() == 80);
-
- // Confirm items positioned correctly
- for (int i = 5; i < 5+15; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.0 - 20.0);
- }
-
-// QTRY_COMPARE(listview->contentItemHeight(), model.count() * 20.0);
-
- // QTBUG-19675
- model.clear();
- model.insertItem(0, "Hello", "1234");
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->y(), 0.);
- QTRY_VERIFY(listview->contentY() == 0);
-
- delete canvas;
- delete testObject;
-}
-
-template <class T>
-void tst_QQuickListView::inserted_more()
-{
- QFETCH(qreal, contentY);
- QFETCH(int, insertIndex);
- QFETCH(int, insertCount);
- QFETCH(qreal, itemsOffsetAfterMove);
-
- T model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QList<QPair<QString, QString> > newData;
- for (int i=0; i<insertCount; i++)
- newData << qMakePair(QString("value %1").arg(i), QString::number(i));
- model.insertItems(insertIndex, newData);
- QTRY_COMPARE(listview->property("count").toInt(), model.count());
-
- // check visibleItems.first() is in correct position
- QQuickItem *item0 = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item0);
- QCOMPARE(item0->y(), itemsOffsetAfterMove);
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QQuickText *name;
- QQuickText *number;
- for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QQuickText>(contentItem, "textNumber", i);
- QVERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::inserted_more_data()
-{
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<int>("insertIndex");
- QTest::addColumn<int>("insertCount");
- QTest::addColumn<qreal>("itemsOffsetAfterMove");
-
- QTest::newRow("add 1, before visible items")
- << 80.0 // show 4-19
- << 3 << 1
- << -20.0; // insert above first visible i.e. 0 is at -20, first visible should not move
-
- QTest::newRow("add multiple, before visible")
- << 80.0 // show 4-19
- << 3 << 3
- << -20.0 * 3; // again first visible should not move
-
- QTest::newRow("add 1, at start of visible, content at start")
- << 0.0
- << 0 << 1
- << 0.0;
-
- QTest::newRow("add multiple, start of visible, content at start")
- << 0.0
- << 0 << 3
- << 0.0;
-
- QTest::newRow("add 1, at start of visible, content not at start")
- << 80.0 // show 4-19
- << 4 << 1
- << 0.0;
-
- QTest::newRow("add multiple, at start of visible, content not at start")
- << 80.0 // show 4-19
- << 4 << 3
- << 0.0;
-
-
- QTest::newRow("add 1, at end of visible, content at start")
- << 0.0
- << 15 << 1
- << 0.0;
-
- QTest::newRow("add 1, at end of visible, content at start")
- << 0.0
- << 15 << 3
- << 0.0;
-
- QTest::newRow("add 1, at end of visible, content not at start")
- << 80.0 // show 4-19
- << 19 << 1
- << 0.0;
-
- QTest::newRow("add multiple, at end of visible, content not at start")
- << 80.0 // show 4-19
- << 19 << 3
- << 0.0;
-
-
- QTest::newRow("add 1, after visible, content at start")
- << 0.0
- << 16 << 1
- << 0.0;
-
- QTest::newRow("add 1, after visible, content at start")
- << 0.0
- << 16 << 3
- << 0.0;
-
- QTest::newRow("add 1, after visible, content not at start")
- << 80.0 // show 4-19
- << 20 << 1
- << 0.0;
-
- QTest::newRow("add multiple, after visible, content not at start")
- << 80.0 // show 4-19
- << 20 << 3
- << 0.0;
-}
-
-void tst_QQuickListView::insertBeforeVisible()
-{
- QFETCH(int, insertIndex);
- QFETCH(int, insertCount);
- QFETCH(int, cacheBuffer);
-
- QQuickText *name;
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; 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(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- listview->setCacheBuffer(cacheBuffer);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // trigger a refill (not just setting contentY) so that the visibleItems grid is updated
- int firstVisibleIndex = 20; // move to an index where the top item is not visible
- listview->setContentY(firstVisibleIndex * 20.0);
- listview->setCurrentIndex(firstVisibleIndex);
-
- qApp->processEvents();
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- QTRY_COMPARE(listview->currentIndex(), firstVisibleIndex);
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", firstVisibleIndex);
- QVERIFY(item);
- QCOMPARE(item->y(), listview->contentY());
-
- QList<QPair<QString, QString> > newData;
- for (int i=0; i<insertCount; i++)
- newData << qMakePair(QString("value %1").arg(i), QString::number(i));
- model.insertItems(insertIndex, newData);
- QTRY_COMPARE(listview->property("count").toInt(), model.count());
-
- // now, moving to the top of the view should position the inserted items correctly
- int itemsOffsetAfterMove = -(insertCount * 20);
- listview->setCurrentIndex(0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- QTRY_COMPARE(listview->currentIndex(), 0);
- QTRY_COMPARE(listview->contentY(), 0.0 + itemsOffsetAfterMove);
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::insertBeforeVisible_data()
-{
- QTest::addColumn<int>("insertIndex");
- QTest::addColumn<int>("insertCount");
- QTest::addColumn<int>("cacheBuffer");
-
- QTest::newRow("insert 1 at 0, 0 buffer") << 0 << 1 << 0;
- QTest::newRow("insert 1 at 0, 100 buffer") << 0 << 1 << 100;
- QTest::newRow("insert 1 at 0, 500 buffer") << 0 << 1 << 500;
-
- QTest::newRow("insert 1 at 1, 0 buffer") << 1 << 1 << 0;
- QTest::newRow("insert 1 at 1, 100 buffer") << 1 << 1 << 100;
- QTest::newRow("insert 1 at 1, 500 buffer") << 1 << 1 << 500;
-
- QTest::newRow("insert multiple at 0, 0 buffer") << 0 << 3 << 0;
- QTest::newRow("insert multiple at 0, 100 buffer") << 0 << 3 << 100;
- QTest::newRow("insert multiple at 0, 500 buffer") << 0 << 3 << 500;
-
- QTest::newRow("insert multiple at 1, 0 buffer") << 1 << 3 << 0;
- QTest::newRow("insert multiple at 1, 100 buffer") << 1 << 3 << 100;
- QTest::newRow("insert multiple at 1, 500 buffer") << 1 << 3 << 500;
-}
-
-template <class T>
-void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
-{
- QQuickView *canvas = createView();
-
- T model;
- for (int i = 0; i < 50; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(source);
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- model.removeItem(1);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(1));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(1));
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- // Remove first item (which is the current item);
- model.removeItem(0);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- name = findItem<QQuickText>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QQuickText>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(),i*20.0);
- }
-
- // Remove items not visible
- model.removeItem(18);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(),i*20.0);
- }
-
- // Remove items before visible
- listview->setContentY(80);
- listview->setCurrentIndex(10);
-
- model.removeItem(1); // post: top item will be at 20
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- // Confirm items positioned correctly
- for (int i = 2; i < 18; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(),20+i*20.0);
- }
-
- // Remove current index
- QTRY_VERIFY(listview->currentIndex() == 9);
- QQuickItem *oldCurrent = listview->currentItem();
- model.removeItem(9);
-
- QTRY_COMPARE(listview->currentIndex(), 9);
- QTRY_VERIFY(listview->currentItem() != oldCurrent);
-
- listview->setContentY(20); // That's the top now
- // let transitions settle.
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- QTest::qWait(300);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(),20+i*20.0);
- }
-
- // remove current item beyond visible items.
- listview->setCurrentIndex(20);
- listview->setContentY(40);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- model.removeItem(20);
- QTRY_COMPARE(listview->currentIndex(), 20);
- QTRY_VERIFY(listview->currentItem() != 0);
-
- // remove item before current, but visible
- listview->setCurrentIndex(8);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- oldCurrent = listview->currentItem();
- model.removeItem(6);
-
- QTRY_COMPARE(listview->currentIndex(), 7);
- QTRY_VERIFY(listview->currentItem() == oldCurrent);
-
- listview->setContentY(80);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- QTest::qWait(300);
-
- // remove all visible items
- model.removeItems(1, 18);
- QTRY_COMPARE(listview->count() , model.count());
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i+1);
- if (!item) qWarning() << "Item" << i+1 << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(),80+i*20.0);
- }
-
- model.removeItems(1, 17);
- QTRY_COMPARE(listview->count() , model.count());
-
- model.removeItems(2, 1);
- QTRY_COMPARE(listview->count() , model.count());
-
- model.addItem("New", "1");
- QTRY_COMPARE(listview->count() , model.count());
-
- QTRY_VERIFY(name = findItem<QQuickText>(contentItem, "textName", model.count()-1));
- QCOMPARE(name->text(), QString("New"));
-
- // Add some more items so that we don't run out
- model.clear();
- for (int i = 0; i < 50; i++)
- model.addItem("Item" + QString::number(i), "");
-
- // QTBUG-QTBUG-20575
- listview->setCurrentIndex(0);
- listview->setContentY(30);
- model.removeItem(0);
- QTRY_VERIFY(name = findItem<QQuickText>(contentItem, "textName", 0));
-
- // QTBUG-19198 move to end and remove all visible items one at a time.
- listview->positionViewAtEnd();
- for (int i = 0; i < 18; ++i)
- model.removeItems(model.count() - 1, 1);
- QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() > 16);
-
- delete canvas;
- delete testObject;
-}
-
-template <class T>
-void tst_QQuickListView::removed_more(const QUrl &source)
-{
- QFETCH(qreal, contentY);
- QFETCH(int, removeIndex);
- QFETCH(int, removeCount);
- QFETCH(qreal, itemsOffsetAfterMove);
-
- QQuickText *name;
- QQuickText *number;
- QQuickView *canvas = createView();
-
- T model;
- for (int i = 0; i < 30; 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(source);
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // wait for refill (after refill, items above the firstVisibleIndex-1 should not be rendered)
- int firstVisibleIndex = contentY / 20;
- if (firstVisibleIndex - 2 >= 0)
- QTRY_VERIFY(!findItem<QQuickText>(contentItem, "textName", firstVisibleIndex - 2));
-
- model.removeItems(removeIndex, removeCount);
- QTRY_COMPARE(listview->property("count").toInt(), model.count());
-
- // check visibleItems.first() is in correct position
- QQuickItem *item0 = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item0);
- QCOMPARE(item0->y(), itemsOffsetAfterMove);
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QQuickText>(contentItem, "textNumber", i);
- QVERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::removed_more_data()
-{
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<int>("removeIndex");
- QTest::addColumn<int>("removeCount");
- QTest::addColumn<qreal>("itemsOffsetAfterMove");
-
- QTest::newRow("remove 1, before visible items")
- << 80.0 // show 4-19
- << 3 << 1
- << 20.0; // visible items slide down by 1 item so that first visible does not move
-
- QTest::newRow("remove multiple, all before visible items")
- << 80.0
- << 1 << 3
- << 20.0 * 3;
-
- QTest::newRow("remove multiple, all before visible items, remove item 0")
- << 80.0
- << 0 << 4
- << 20.0 * 4;
-
- // remove 1,2,3 before the visible pos, 0 moves down to just before the visible pos,
- // items 4,5 are removed from view, item 6 slides up to original pos of item 4 (80px)
- QTest::newRow("remove multiple, mix of items from before and within visible items")
- << 80.0
- << 1 << 5
- << 20.0 * 3; // adjust for the 3 items removed before the visible
-
- QTest::newRow("remove multiple, mix of items from before and within visible items, remove item 0")
- << 80.0
- << 0 << 6
- << 20.0 * 4; // adjust for the 3 items removed before the visible
-
-
- QTest::newRow("remove 1, from start of visible, content at start")
- << 0.0
- << 0 << 1
- << 0.0;
-
- QTest::newRow("remove multiple, from start of visible, content at start")
- << 0.0
- << 0 << 3
- << 0.0;
-
- QTest::newRow("remove 1, from start of visible, content not at start")
- << 80.0 // show 4-19
- << 4 << 1
- << 0.0;
-
- QTest::newRow("remove multiple, from start of visible, content not at start")
- << 80.0 // show 4-19
- << 4 << 3
- << 0.0;
-
-
- QTest::newRow("remove 1, from middle of visible, content at start")
- << 0.0
- << 10 << 1
- << 0.0;
-
- QTest::newRow("remove multiple, from middle of visible, content at start")
- << 0.0
- << 10 << 5
- << 0.0;
-
- QTest::newRow("remove 1, from middle of visible, content not at start")
- << 80.0 // show 4-19
- << 10 << 1
- << 0.0;
-
- QTest::newRow("remove multiple, from middle of visible, content not at start")
- << 80.0 // show 4-19
- << 10 << 5
- << 0.0;
-
-
- QTest::newRow("remove 1, after visible, content at start")
- << 0.0
- << 16 << 1
- << 0.0;
-
- QTest::newRow("remove multiple, after visible, content at start")
- << 0.0
- << 16 << 5
- << 0.0;
-
- QTest::newRow("remove 1, after visible, content not at middle")
- << 80.0 // show 4-19
- << 16+4 << 1
- << 0.0;
-
- QTest::newRow("remove multiple, after visible, content not at start")
- << 80.0 // show 4-19
- << 16+4 << 5
- << 0.0;
-
- QTest::newRow("remove multiple, mix of items from within and after visible items")
- << 80.0
- << 18 << 5
- << 0.0;
-}
-
-template <class T>
-void tst_QQuickListView::clear(const QUrl &source)
-{
- QQuickView *canvas = createView();
-
- T model;
- for (int i = 0; i < 30; 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(source);
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- model.clear();
-
- QTRY_VERIFY(listview->count() == 0);
- QTRY_VERIFY(listview->currentItem() == 0);
- QTRY_VERIFY(listview->contentY() == 0);
- QVERIFY(listview->currentIndex() == -1);
-
- // confirm sanity when adding an item to cleared list
- model.addItem("New", "1");
- QTRY_VERIFY(listview->count() == 1);
- QVERIFY(listview->currentItem() != 0);
- QVERIFY(listview->currentIndex() == 0);
-
- delete canvas;
- delete testObject;
-}
-
-template <class T>
-void tst_QQuickListView::moved(const QUrl &source)
-{
- QFETCH(qreal, contentY);
- QFETCH(int, from);
- QFETCH(int, to);
- QFETCH(int, count);
- QFETCH(qreal, itemsOffsetAfterMove);
-
- QQuickText *name;
- QQuickText *number;
- QQuickView *canvas = createView();
-
- T model;
- for (int i = 0; i < 30; 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(source);
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QQuickItem *currentItem = listview->currentItem();
- QTRY_VERIFY(currentItem != 0);
-
- if (contentY != 0) {
- listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- }
-
- model.moveItems(from, to, count);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- if (i >= firstVisibleIndex + 16) // index has moved out of view
- continue;
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QQuickText>(contentItem, "textNumber", i);
- QVERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
-
- // current index should have been updated
- if (item == currentItem)
- QTRY_COMPARE(listview->currentIndex(), i);
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::moved_data()
-{
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<int>("from");
- QTest::addColumn<int>("to");
- QTest::addColumn<int>("count");
- QTest::addColumn<qreal>("itemsOffsetAfterMove");
-
- // model starts with 30 items, each 20px high, in area 320px high
- // 16 items should be visible at a time
- // itemsOffsetAfterMove should be > 0 whenever items above the visible pos have moved
-
- QTest::newRow("move 1 forwards, within visible items")
- << 0.0
- << 1 << 4 << 1
- << 0.0;
-
- QTest::newRow("move 1 forwards, from non-visible -> visible")
- << 80.0 // show 4-19
- << 1 << 18 << 1
- << 20.0; // removed 1 item above the first visible, so item 0 should drop down by 1 to minimize movement
-
- QTest::newRow("move 1 forwards, from non-visible -> visible (move first item)")
- << 80.0 // show 4-19
- << 0 << 4 << 1
- << 20.0; // first item has moved to below item4, everything drops down by size of 1 item
-
- QTest::newRow("move 1 forwards, from visible -> non-visible")
- << 0.0
- << 1 << 16 << 1
- << 0.0;
-
- QTest::newRow("move 1 forwards, from visible -> non-visible (move first item)")
- << 0.0
- << 0 << 16 << 1
- << 0.0;
-
-
- QTest::newRow("move 1 backwards, within visible items")
- << 0.0
- << 4 << 1 << 1
- << 0.0;
-
- QTest::newRow("move 1 backwards, within visible items (to first index)")
- << 0.0
- << 4 << 0 << 1
- << 0.0;
-
- QTest::newRow("move 1 backwards, from non-visible -> visible")
- << 0.0
- << 20 << 4 << 1
- << 0.0;
-
- QTest::newRow("move 1 backwards, from non-visible -> visible (move last item)")
- << 0.0
- << 29 << 15 << 1
- << 0.0;
-
- QTest::newRow("move 1 backwards, from visible -> non-visible")
- << 80.0 // show 4-19
- << 16 << 1 << 1
- << -20.0; // to minimize movement, item 0 moves to -20, and other items do not move
-
- QTest::newRow("move 1 backwards, from visible -> non-visible (move first item)")
- << 80.0 // show 4-19
- << 16 << 0 << 1
- << -20.0; // to minimize movement, item 16 (now at 0) moves to -20, and other items do not move
-
-
- QTest::newRow("move multiple forwards, within visible items")
- << 0.0
- << 0 << 5 << 3
- << 0.0;
-
- QTest::newRow("move multiple forwards, before visible items")
- << 140.0 // show 7-22
- << 4 << 5 << 3 // 4,5,6 move to below 7
- << 20.0 * 3; // 4,5,6 moved down
-
- QTest::newRow("move multiple forwards, from non-visible -> visible")
- << 80.0 // show 4-19
- << 1 << 5 << 3
- << 20.0 * 3; // moving 3 from above the content y should adjust y positions accordingly
-
- QTest::newRow("move multiple forwards, from non-visible -> visible (move first item)")
- << 80.0 // show 4-19
- << 0 << 5 << 3
- << 20.0 * 3; // moving 3 from above the content y should adjust y positions accordingly
-
- QTest::newRow("move multiple forwards, mix of non-visible/visible")
- << 40.0
- << 1 << 16 << 2
- << 20.0; // item 1,2 are removed, item 3 is now first visible
-
- QTest::newRow("move multiple forwards, to bottom of view")
- << 0.0
- << 5 << 13 << 3
- << 0.0;
-
- QTest::newRow("move multiple forwards, to bottom of view, first->last")
- << 0.0
- << 0 << 13 << 3
- << 0.0;
-
- QTest::newRow("move multiple forwards, to bottom of view, content y not 0")
- << 80.0
- << 5+4 << 13+4 << 3
- << 0.0;
-
- QTest::newRow("move multiple forwards, from visible -> non-visible")
- << 0.0
- << 1 << 16 << 3
- << 0.0;
-
- QTest::newRow("move multiple forwards, from visible -> non-visible (move first item)")
- << 0.0
- << 0 << 16 << 3
- << 0.0;
-
-
- QTest::newRow("move multiple backwards, within visible items")
- << 0.0
- << 4 << 1 << 3
- << 0.0;
-
- QTest::newRow("move multiple backwards, within visible items (move first item)")
- << 0.0
- << 10 << 0 << 3
- << 0.0;
-
- QTest::newRow("move multiple backwards, from non-visible -> visible")
- << 0.0
- << 20 << 4 << 3
- << 0.0;
-
- QTest::newRow("move multiple backwards, from non-visible -> visible (move last item)")
- << 0.0
- << 27 << 10 << 3
- << 0.0;
-
- QTest::newRow("move multiple backwards, from visible -> non-visible")
- << 80.0 // show 4-19
- << 16 << 1 << 3
- << -20.0 * 3; // to minimize movement, 0 moves by -60, and other items do not move
-
- QTest::newRow("move multiple backwards, from visible -> non-visible (move first item)")
- << 80.0 // show 4-19
- << 16 << 0 << 3
- << -20.0 * 3; // to minimize movement, 16,17,18 move to above item 0, and other items do not move
-}
-
-void tst_QQuickListView::multipleChanges()
-{
- QFETCH(int, startCount);
- QFETCH(QList<ListChange>, changes);
- QFETCH(int, newCount);
- QFETCH(int, newCurrentIndex);
-
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < startCount; 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(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- for (int i=0; i<changes.count(); i++) {
- switch (changes[i].type) {
- case ListChange::Inserted:
- {
- QList<QPair<QString, QString> > items;
- for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
- items << qMakePair(QString("new item %1").arg(j), QString::number(j));
- model.insertItems(changes[i].index, items);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- break;
- }
- case ListChange::Removed:
- model.removeItems(changes[i].index, changes[i].count);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- break;
- case ListChange::Moved:
- model.moveItems(changes[i].index, changes[i].to, changes[i].count);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- break;
- case ListChange::SetCurrent:
- listview->setCurrentIndex(changes[i].index);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- break;
- case ListChange::SetContentY:
- listview->setContentY(changes[i].pos);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- break;
- }
- }
-
- QTRY_COMPARE(listview->count(), newCount);
- QCOMPARE(listview->count(), model.count());
- QTRY_COMPARE(listview->currentIndex(), newCurrentIndex);
-
- QQuickText *name;
- QQuickText *number;
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i=0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QQuickText>(contentItem, "textNumber", i);
- QVERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(i));
- }
-
- delete testObject;
- delete canvas;
-}
-
-void tst_QQuickListView::multipleChanges_data()
-{
- QTest::addColumn<int>("startCount");
- QTest::addColumn<QList<ListChange> >("changes");
- QTest::addColumn<int>("newCount");
- QTest::addColumn<int>("newCurrentIndex");
-
- QList<ListChange> changes;
-
- for (int i=1; i<30; i++)
- changes << ListChange::remove(0);
- QTest::newRow("remove all but 1, first->last") << 30 << changes << 1 << 0;
-
- changes << ListChange::remove(0);
- QTest::newRow("remove all") << 30 << changes << 0 << -1;
-
- changes.clear();
- changes << ListChange::setCurrent(29);
- for (int i=29; i>0; i--)
- changes << ListChange::remove(i);
- QTest::newRow("remove last (current) -> first") << 30 << changes << 1 << 0;
-
- QTest::newRow("remove then insert at 0") << 10 << (QList<ListChange>()
- << ListChange::remove(0, 1)
- << ListChange::insert(0, 1)
- ) << 10 << 1;
-
- QTest::newRow("remove then insert at non-zero index") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(2)
- << ListChange::remove(2, 1)
- << ListChange::insert(2, 1)
- ) << 10 << 3;
-
- QTest::newRow("remove current then insert below it") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(1)
- << ListChange::remove(1, 3)
- << ListChange::insert(2, 2)
- ) << 9 << 1;
-
- QTest::newRow("remove current index then move it down") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(2)
- << ListChange::remove(1, 3)
- << ListChange::move(1, 5, 1)
- ) << 7 << 5;
-
- QTest::newRow("remove current index then move it up") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(5)
- << ListChange::remove(4, 3)
- << ListChange::move(4, 1, 1)
- ) << 7 << 1;
-
-
- QTest::newRow("insert multiple times") << 0 << (QList<ListChange>()
- << ListChange::insert(0, 2)
- << ListChange::insert(0, 4)
- << ListChange::insert(0, 6)
- ) << 12 << 10;
-
- QTest::newRow("insert multiple times with current index changes") << 0 << (QList<ListChange>()
- << ListChange::insert(0, 2)
- << ListChange::insert(0, 4)
- << ListChange::insert(0, 6)
- << ListChange::setCurrent(3)
- << ListChange::insert(3, 2)
- ) << 14 << 5;
-
- QTest::newRow("insert and remove all") << 0 << (QList<ListChange>()
- << ListChange::insert(0, 30)
- << ListChange::remove(0, 30)
- ) << 0 << -1;
-
- QTest::newRow("insert and remove current") << 30 << (QList<ListChange>()
- << ListChange::insert(1)
- << ListChange::setCurrent(1)
- << ListChange::remove(1)
- ) << 30 << 1;
-
- QTest::newRow("insert before 0, then remove cross section of new and old items") << 10 << (QList<ListChange>()
- << ListChange::insert(0, 10)
- << ListChange::remove(5, 10)
- ) << 10 << 5;
-
- QTest::newRow("insert multiple, then move new items to end") << 10 << (QList<ListChange>()
- << ListChange::insert(0, 3)
- << ListChange::move(0, 10, 3)
- ) << 13 << 0;
-
- QTest::newRow("insert multiple, then move new and some old items to end") << 10 << (QList<ListChange>()
- << ListChange::insert(0, 3)
- << ListChange::move(0, 8, 5)
- ) << 13 << 11;
-
- QTest::newRow("insert multiple at end, then move new and some old items to start") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(9)
- << ListChange::insert(10, 3)
- << ListChange::move(8, 0, 5)
- ) << 13 << 1;
-
-
- QTest::newRow("move back and forth to same index") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(1)
- << ListChange::move(1, 2, 2)
- << ListChange::move(2, 1, 2)
- ) << 10 << 1;
-
- QTest::newRow("move forwards then back") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(2)
- << ListChange::move(1, 2, 3)
- << ListChange::move(3, 0, 5)
- ) << 10 << 0;
-
- QTest::newRow("move current, then remove it") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(5)
- << ListChange::move(5, 0, 1)
- << ListChange::remove(0)
- ) << 9 << 0;
-
- QTest::newRow("move current, then insert before it") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(5)
- << ListChange::move(5, 0, 1)
- << ListChange::insert(0)
- ) << 11 << 1;
-
- QTest::newRow("move multiple, then remove them") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(1)
- << ListChange::move(5, 1, 3)
- << ListChange::remove(1, 3)
- ) << 7 << 1;
-
- QTest::newRow("move multiple, then insert before them") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(5)
- << ListChange::move(5, 1, 3)
- << ListChange::insert(1, 5)
- ) << 15 << 6;
-
- QTest::newRow("move multiple, then insert after them") << 10 << (QList<ListChange>()
- << ListChange::setCurrent(3)
- << ListChange::move(0, 1, 2)
- << ListChange::insert(3, 5)
- ) << 15 << 8;
-
-
- QTest::newRow("clear current") << 0 << (QList<ListChange>()
- << ListChange::insert(0, 5)
- << ListChange::setCurrent(-1)
- << ListChange::remove(0, 5)
- << ListChange::insert(0, 5)
- ) << 5 << -1;
-}
-
-void tst_QQuickListView::swapWithFirstItem()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; 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(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // ensure content position is stable
- listview->setContentY(0);
- model.moveItem(1, 0);
- QTRY_VERIFY(listview->contentY() == 0);
-
- delete testObject;
- delete canvas;
-}
-
-void tst_QQuickListView::enforceRange()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("listview-enforcerange.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QTRY_COMPARE(listview->preferredHighlightBegin(), 100.0);
- QTRY_COMPARE(listview->preferredHighlightEnd(), 100.0);
- QTRY_COMPARE(listview->highlightRangeMode(), QQuickListView::StrictlyEnforceRange);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // view should be positioned at the top of the range.
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QTRY_VERIFY(item);
- QTRY_COMPARE(listview->contentY(), -100.0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", 0);
- QTRY_VERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(0));
- QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 0);
- QTRY_VERIFY(number != 0);
- QTRY_COMPARE(number->text(), model.number(0));
-
- // Check currentIndex is updated when contentItem moves
- listview->setContentY(20);
-
- QTRY_COMPARE(listview->currentIndex(), 6);
-
- // change model
- QmlListModel model2;
- for (int i = 0; i < 5; i++)
- model2.addItem("Item" + QString::number(i), "");
-
- ctxt->setContextProperty("testModel", &model2);
- QCOMPARE(listview->count(), 5);
-
- delete canvas;
-}
-
-void tst_QQuickListView::enforceRange_withoutHighlight()
-{
- // QTBUG-20287
- // If no highlight is set but StrictlyEnforceRange is used, the content should still move
- // to the correct position (i.e. to the next/previous item, not next/previous section)
- // when moving up/down via incrementCurrentIndex() and decrementCurrentIndex()
-
- QQuickView *canvas = createView();
-
- QmlListModel model;
- model.addItem("Item 0", "a");
- model.addItem("Item 1", "b");
- model.addItem("Item 2", "b");
- model.addItem("Item 3", "c");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("listview-enforcerange-nohighlight.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- qreal expectedPos = -100.0;
-
- expectedPos += 10.0; // scroll past 1st section's delegate (10px height)
- QTRY_COMPARE(listview->contentY(), expectedPos);
-
- expectedPos += 20 + 10; // scroll past 1st section and section delegate of 2nd section
- QTest::keyClick(canvas, Qt::Key_Down);
-
- QTRY_COMPARE(listview->contentY(), expectedPos);
-
- expectedPos += 20; // scroll past 1st item of 2nd section
- QTest::keyClick(canvas, Qt::Key_Down);
- QTRY_COMPARE(listview->contentY(), expectedPos);
-
- expectedPos += 20 + 10; // scroll past 2nd item of 2nd section and section delegate of 3rd section
- QTest::keyClick(canvas, Qt::Key_Down);
- QTRY_COMPARE(listview->contentY(), expectedPos);
-
- delete canvas;
-}
-
-void tst_QQuickListView::spacing()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; 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(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- listview->setSpacing(10);
- QTRY_VERIFY(listview->spacing() == 10);
-
- // Confirm items positioned correctly
- QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() == 11);
- for (int i = 0; i < 11; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*30);
- }
-
- listview->setSpacing(0);
-
- // Confirm items positioned correctly
- QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() >= 16);
- for (int i = 0; i < 16; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.0);
- }
-
- delete canvas;
- delete testObject;
-}
-
-template <typename T>
-void tst_QQuickListView::sections(const QUrl &source)
-{
- QQuickView *canvas = createView();
-
- T model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i/5));
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(source);
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20));
- QQuickText *next = findItem<QQuickText>(item, "nextSection");
- QCOMPARE(next->text().toInt(), (i+1)/5);
- }
-
- QSignalSpy currentSectionChangedSpy(listview, SIGNAL(currentSectionChanged()));
-
- // Remove section boundary
- model.removeItem(5);
- QTRY_COMPARE(listview->count(), model.count());
-
- // New section header created
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 5);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 40.0);
-
- model.insertItem(3, "New Item", "0");
- QTRY_COMPARE(listview->count(), model.count());
-
- // Section header moved
- item = findItem<QQuickItem>(contentItem, "wrapper", 5);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 20.0);
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 6);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 40.0);
-
- // insert item which will become a section header
- model.insertItem(6, "Replace header", "1");
- QTRY_COMPARE(listview->count(), model.count());
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 6);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 40.0);
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 7);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 20.0);
-
- QTRY_COMPARE(listview->currentSection(), QString("0"));
-
- listview->setContentY(140);
- QTRY_COMPARE(listview->currentSection(), QString("1"));
-
- QTRY_COMPARE(currentSectionChangedSpy.count(), 1);
-
- listview->setContentY(20);
- QTRY_COMPARE(listview->currentSection(), QString("0"));
-
- QTRY_COMPARE(currentSectionChangedSpy.count(), 2);
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 1);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 20.0);
-
- // check that headers change when item changes
- listview->setContentY(0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- model.modifyItem(0, "changed", "2");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 1);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->height(), 40.0);
-
- delete canvas;
-}
-
-void tst_QQuickListView::sectionsDelegate()
-{
- QSKIP("QTBUG-24395");
-
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i/5));
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("listview-sections_delegate.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20 + ((i+5)/5) * 20));
- QQuickText *next = findItem<QQuickText>(item, "nextSection");
- QCOMPARE(next->text().toInt(), (i+1)/5);
- }
-
- for (int i = 0; i < 3; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "sect_" + QString::number(i));
- QVERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20*6));
- }
-
- // ensure section header is maintained in view
- listview->setCurrentIndex(20);
- QTRY_VERIFY(listview->contentY() >= 200.0);
- listview->setCurrentIndex(0);
- QTRY_COMPARE(listview->contentY(), 0.0);
-
- // change section
- model.modifyItem(0, "One", "aaa");
- model.modifyItem(1, "Two", "aaa");
- model.modifyItem(2, "Three", "aaa");
- model.modifyItem(3, "Four", "aaa");
- model.modifyItem(4, "Five", "aaa");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- for (int i = 0; i < 3; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem,
- "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
- QVERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20*6));
- }
-
- // remove section boundary
- model.removeItem(5);
- QTRY_COMPARE(listview->count(), model.count());
- for (int i = 0; i < 3; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem,
- "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
- QVERIFY(item);
- }
-
- // QTBUG-17606
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "sect_1");
- QCOMPARE(items.count(), 1);
-
- // QTBUG-17759
- model.modifyItem(0, "One", "aaa");
- model.modifyItem(1, "One", "aaa");
- model.modifyItem(2, "One", "aaa");
- model.modifyItem(3, "Four", "aaa");
- model.modifyItem(4, "Four", "aaa");
- model.modifyItem(5, "Four", "aaa");
- model.modifyItem(6, "Five", "aaa");
- model.modifyItem(7, "Five", "aaa");
- model.modifyItem(8, "Five", "aaa");
- model.modifyItem(9, "Two", "aaa");
- model.modifyItem(10, "Two", "aaa");
- model.modifyItem(11, "Two", "aaa");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_aaa").count(), 1);
- canvas->rootObject()->setProperty("sectionProperty", "name");
- // ensure view has settled.
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_Four").count(), 1);
- for (int i = 0; i < 4; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem,
- "sect_" + model.name(i*3));
- QVERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20*4));
- }
-
- // QTBUG-17769
- model.removeItems(10, 20);
- // ensure view has settled.
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 10);
- // Drag view up beyond bounds
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(20,20));
- {
- QMouseEvent mv(QEvent::MouseMove, QPoint(20,0), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(canvas, &mv);
- }
- {
- QMouseEvent mv(QEvent::MouseMove, QPoint(20,-50), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(canvas, &mv);
- }
- {
- QMouseEvent mv(QEvent::MouseMove, QPoint(20,-200), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(canvas, &mv);
- }
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(20,-200));
- // view should settle back at 0
- QTRY_COMPARE(listview->contentY(), 0.0);
-
- delete canvas;
-}
-
-void tst_QQuickListView::sectionsPositioning()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i/5));
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("listview-sections_delegate.qml"));
- canvas->show();
- qApp->processEvents();
- canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart | QQuickViewSection::NextLabelAtEnd)));
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- for (int i = 0; i < 3; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "sect_" + QString::number(i));
- QVERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20*6));
- }
-
- QQuickItem *topItem = findVisibleChild(contentItem, "sect_0"); // section header
- QVERIFY(topItem);
- QCOMPARE(topItem->y(), 0.);
-
- QQuickItem *bottomItem = findVisibleChild(contentItem, "sect_3"); // section footer
- QVERIFY(bottomItem);
- QCOMPARE(bottomItem->y(), 300.);
-
- // move down a little and check that section header is at top
- listview->setContentY(10);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- QCOMPARE(topItem->y(), 0.);
-
- // push the top header up
- listview->setContentY(110);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- topItem = findVisibleChild(contentItem, "sect_0"); // section header
- QVERIFY(topItem);
- QCOMPARE(topItem->y(), 100.);
-
- QQuickItem *item = findVisibleChild(contentItem, "sect_1");
- QVERIFY(item);
- QCOMPARE(item->y(), 120.);
-
- bottomItem = findVisibleChild(contentItem, "sect_4"); // section footer
- QVERIFY(bottomItem);
- QCOMPARE(bottomItem->y(), 410.);
-
- // Move past section 0
- listview->setContentY(120);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- topItem = findVisibleChild(contentItem, "sect_0"); // section header
- QVERIFY(!topItem);
-
- // Push section footer down
- listview->setContentY(70);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- bottomItem = findVisibleChild(contentItem, "sect_4"); // section footer
- QVERIFY(bottomItem);
- QCOMPARE(bottomItem->y(), 380.);
-
- // Change current section
- listview->setContentY(10);
- model.modifyItem(0, "One", "aaa");
- model.modifyItem(1, "Two", "aaa");
- model.modifyItem(2, "Three", "aaa");
- model.modifyItem(3, "Four", "aaa");
- model.modifyItem(4, "Five", "aaa");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QTRY_COMPARE(listview->currentSection(), QString("aaa"));
-
- for (int i = 0; i < 3; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem,
- "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
- QVERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20*6));
- }
-
- QTRY_VERIFY(topItem = findVisibleChild(contentItem, "sect_aaa")); // section header
- QCOMPARE(topItem->y(), 10.);
-
- // remove section boundary
- listview->setContentY(120);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- model.removeItem(5);
- QTRY_COMPARE(listview->count(), model.count());
- for (int i = 0; i < 3; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem,
- "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
- QVERIFY(item);
- QTRY_COMPARE(item->y(), qreal(i*20*6));
- }
-
- QVERIFY(topItem = findVisibleChild(contentItem, "sect_1"));
- QTRY_COMPARE(topItem->y(), 120.);
-
- // Change the next section
- listview->setContentY(0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- bottomItem = findVisibleChild(contentItem, "sect_3"); // section footer
- QVERIFY(bottomItem);
- QTRY_COMPARE(bottomItem->y(), 300.);
-
- model.modifyItem(14, "New", "new");
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QTRY_VERIFY(bottomItem = findVisibleChild(contentItem, "sect_new")); // section footer
- QTRY_COMPARE(bottomItem->y(), 300.);
-
- // Turn sticky footer off
- listview->setContentY(20);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart)));
- QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_new")); // inline label restored
- QCOMPARE(item->y(), 340.);
-
- // Turn sticky header off
- listview->setContentY(30);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels)));
- QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_aaa")); // inline label restored
- QCOMPARE(item->y(), 0.);
-
- delete canvas;
-}
-
-void tst_QQuickListView::currentIndex_delayedItemCreation()
-{
- QFETCH(bool, setCurrentToZero);
-
- QQuickView *canvas = createView();
-
- // test currentIndexChanged() is emitted even if currentIndex = 0 on start up
- // (since the currentItem will have changed and that shares the same index)
- canvas->rootContext()->setContextProperty("setCurrentToZero", setCurrentToZero);
-
- canvas->setSource(testFileUrl("fillModelOnComponentCompleted.qml"));
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QSignalSpy spy(listview, SIGNAL(currentItemChanged()));
- QCOMPARE(listview->currentIndex(), 0);
- QTRY_COMPARE(spy.count(), 1);
-
- delete canvas;
-}
-
-void tst_QQuickListView::currentIndex_delayedItemCreation_data()
-{
- QTest::addColumn<bool>("setCurrentToZero");
-
- QTest::newRow("set to 0") << true;
- QTest::newRow("don't set to 0") << false;
-}
-
-void tst_QQuickListView::currentIndex()
-{
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testWrap", QVariant(false));
-
- QString filename(testFile("listview-initCurrent.qml"));
- canvas->setSource(QUrl::fromLocalFile(filename));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // current item should be 20th item at startup
- // and current item should be in view
- QCOMPARE(listview->currentIndex(), 20);
- QCOMPARE(listview->contentY(), 100.0);
- QCOMPARE(listview->currentItem(), findItem<QQuickItem>(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);
- listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
-
- listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
-
- // with wrap
- ctxt->setContextProperty("testWrap", QVariant(true));
- QVERIFY(listview->isWrapEnabled());
-
- listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), model.count()-1);
-
- QTRY_COMPARE(listview->contentY(), 280.0);
-
- listview->incrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
-
- QTRY_COMPARE(listview->contentY(), 0.0);
-
-
- // footer should become visible if it is out of view, and then current index is set to count-1
- canvas->rootObject()->setProperty("showFooter", true);
- QTRY_VERIFY(listview->footerItem());
- listview->setCurrentIndex(model.count()-2);
- QTRY_VERIFY(listview->footerItem()->y() > listview->contentY() + listview->height());
- listview->setCurrentIndex(model.count()-1);
- QTRY_COMPARE(listview->contentY() + listview->height(), (20.0 * model.count()) + listview->footerItem()->height());
- canvas->rootObject()->setProperty("showFooter", false);
-
- // header should become visible if it is out of view, and then current index is set to 0
- canvas->rootObject()->setProperty("showHeader", true);
- QTRY_VERIFY(listview->headerItem());
- listview->setCurrentIndex(1);
- QTRY_VERIFY(listview->headerItem()->y() + listview->headerItem()->height() < listview->contentY());
- listview->setCurrentIndex(0);
- QTRY_COMPARE(listview->contentY(), -listview->headerItem()->height());
- canvas->rootObject()->setProperty("showHeader", false);
-
-
- // Test keys
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(qGuiApp->focusWindow() == canvas);
-
- listview->setCurrentIndex(0);
-
- QTest::keyClick(canvas, Qt::Key_Down);
- QCOMPARE(listview->currentIndex(), 1);
-
- QTest::keyClick(canvas, Qt::Key_Up);
- QCOMPARE(listview->currentIndex(), 0);
-
- // hold down Key_Down
- for (int i=0; i<model.count()-1; i++) {
- QTest::simulateEvent(canvas, true, Qt::Key_Down, Qt::NoModifier, "", true);
- QTRY_COMPARE(listview->currentIndex(), i+1);
- }
- QTest::keyRelease(canvas, Qt::Key_Down);
- QTRY_COMPARE(listview->currentIndex(), model.count()-1);
- QTRY_COMPARE(listview->contentY(), 280.0);
-
- // hold down Key_Up
- for (int i=model.count()-1; i > 0; i--) {
- QTest::simulateEvent(canvas, true, Qt::Key_Up, Qt::NoModifier, "", true);
- QTRY_COMPARE(listview->currentIndex(), i-1);
- }
- QTest::keyRelease(canvas, Qt::Key_Up);
- QTRY_COMPARE(listview->currentIndex(), 0);
- QTRY_COMPARE(listview->contentY(), 0.0);
-
-
- // turn off auto highlight
- listview->setHighlightFollowsCurrentItem(false);
- QVERIFY(listview->highlightFollowsCurrentItem() == false);
-
- QVERIFY(listview->highlightItem());
- qreal hlPos = listview->highlightItem()->y();
-
- listview->setCurrentIndex(4);
- QTRY_COMPARE(listview->highlightItem()->y(), hlPos);
-
- // insert item before currentIndex
- listview->setCurrentIndex(28);
- model.insertItem(0, "Foo", "1111");
- QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
-
- // check removing highlight by setting currentIndex to -1;
- listview->setCurrentIndex(-1);
-
- QCOMPARE(listview->currentIndex(), -1);
- QVERIFY(!listview->highlightItem());
- QVERIFY(!listview->currentItem());
-
- delete canvas;
-}
-
-void tst_QQuickListView::noCurrentIndex()
-{
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- QString filename(testFile("listview-noCurrent.qml"));
- canvas->setSource(QUrl::fromLocalFile(filename));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // current index should be -1 at startup
- // and we should not have a currentItem or highlightItem
- QCOMPARE(listview->currentIndex(), -1);
- QCOMPARE(listview->contentY(), 0.0);
- QVERIFY(!listview->highlightItem());
- QVERIFY(!listview->currentItem());
-
- listview->setCurrentIndex(2);
- QCOMPARE(listview->currentIndex(), 2);
- QVERIFY(listview->highlightItem());
- QVERIFY(listview->currentItem());
-
- delete canvas;
-}
-
-void tst_QQuickListView::itemList()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("itemlist.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "view");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickVisualItemModel *model = canvas->rootObject()->findChild<QQuickVisualItemModel*>("itemModel");
- QTRY_VERIFY(model != 0);
-
- QTRY_VERIFY(model->count() == 3);
- QTRY_COMPARE(listview->currentIndex(), 0);
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "item1");
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), 0.0);
- QCOMPARE(item->height(), listview->height());
-
- QQuickText *text = findItem<QQuickText>(contentItem, "text1");
- QTRY_VERIFY(text);
- QTRY_COMPARE(text->text(), QLatin1String("index: 0"));
-
- listview->setCurrentIndex(2);
-
- item = findItem<QQuickItem>(contentItem, "item3");
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), 480.0);
-
- text = findItem<QQuickText>(contentItem, "text3");
- QTRY_VERIFY(text);
- QTRY_COMPARE(text->text(), QLatin1String("index: 2"));
-
- delete canvas;
-}
-
-void tst_QQuickListView::cacheBuffer()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 90; 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(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_VERIFY(listview->delegate() != 0);
- QTRY_VERIFY(listview->model() != 0);
- QTRY_VERIFY(listview->highlight() != 0);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- QDeclarativeIncubationController controller;
- canvas->engine()->setIncubationController(&controller);
-
- testObject->setCacheBuffer(200);
- QTRY_VERIFY(listview->cacheBuffer() == 200);
-
- // items will be created one at a time
- for (int i = itemCount; i < qMin(itemCount+10,model.count()); ++i) {
- QVERIFY(findItem<QQuickItem>(listview, "wrapper", i) == 0);
- QQuickItem *item = 0;
- while (!item) {
- bool b = false;
- controller.incubateWhile(&b);
- item = findItem<QQuickItem>(listview, "wrapper", i);
- }
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- int newItemCount = 0;
- newItemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
-
- // Confirm items positioned correctly
- for (int i = 0; i < model.count() && i < newItemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- // move view and confirm items in view are visible immediately and outside are created async
- listview->setContentY(300);
-
- for (int i = 15; i < 32; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QVERIFY(item);
- QVERIFY(item->y() == i*20);
- }
-
- QVERIFY(findItem<QQuickItem>(listview, "wrapper", 32) == 0);
-
- // ensure buffered items are created
- for (int i = 32; i < qMin(41,model.count()); ++i) {
- QQuickItem *item = 0;
- while (!item) {
- qGuiApp->processEvents(); // allow refill to happen
- bool b = false;
- controller.incubateWhile(&b);
- item = findItem<QQuickItem>(listview, "wrapper", i);
- }
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::positionViewAtIndex()
-{
- QQuickView *canvas = createView();
-
- QmlListModel 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->show();
- canvas->setSource(testFileUrl("listviewtest.qml"));
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position on a currently visible item
- listview->positionViewAtIndex(3, QQuickListView::Beginning);
- QTRY_COMPARE(listview->contentY(), 60.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position on an item beyond the visible items
- listview->positionViewAtIndex(22, QQuickListView::Beginning);
- QTRY_COMPARE(listview->contentY(), 440.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position on an item that would leave empty space if positioned at the top
- listview->positionViewAtIndex(28, QQuickListView::Beginning);
- QTRY_COMPARE(listview->contentY(), 480.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position at the beginning again
- listview->positionViewAtIndex(0, QQuickListView::Beginning);
- QTRY_COMPARE(listview->contentY(), 0.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position at End using last index
- listview->positionViewAtIndex(model.count()-1, QQuickListView::End);
- QTRY_COMPARE(listview->contentY(), 480.);
-
- // Confirm items positioned correctly
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 24; i < model.count(); ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- }
-
- // Position at End
- listview->positionViewAtIndex(20, QQuickListView::End);
- QTRY_COMPARE(listview->contentY(), 100.);
-
- // Position in Center
- listview->positionViewAtIndex(15, QQuickListView::Center);
- QTRY_COMPARE(listview->contentY(), 150.);
-
- // Ensure at least partially visible
- listview->positionViewAtIndex(15, QQuickListView::Visible);
- QTRY_COMPARE(listview->contentY(), 150.);
-
- listview->setContentY(302);
- listview->positionViewAtIndex(15, QQuickListView::Visible);
- QTRY_COMPARE(listview->contentY(), 302.);
-
- listview->setContentY(320);
- listview->positionViewAtIndex(15, QQuickListView::Visible);
- QTRY_COMPARE(listview->contentY(), 300.);
-
- listview->setContentY(85);
- listview->positionViewAtIndex(20, QQuickListView::Visible);
- QTRY_COMPARE(listview->contentY(), 85.);
-
- listview->setContentY(75);
- listview->positionViewAtIndex(20, QQuickListView::Visible);
- QTRY_COMPARE(listview->contentY(), 100.);
-
- // Ensure completely visible
- listview->setContentY(120);
- listview->positionViewAtIndex(20, QQuickListView::Contain);
- QTRY_COMPARE(listview->contentY(), 120.);
-
- listview->setContentY(302);
- listview->positionViewAtIndex(15, QQuickListView::Contain);
- QTRY_COMPARE(listview->contentY(), 300.);
-
- listview->setContentY(85);
- listview->positionViewAtIndex(20, QQuickListView::Contain);
- QTRY_COMPARE(listview->contentY(), 100.);
-
- // positionAtBeginnging
- listview->positionViewAtBeginning();
- QTRY_COMPARE(listview->contentY(), 0.);
-
- listview->setContentY(80);
- canvas->rootObject()->setProperty("showHeader", true);
- listview->positionViewAtBeginning();
- QTRY_COMPARE(listview->contentY(), -30.);
-
- // positionAtEnd
- listview->positionViewAtEnd();
- QTRY_COMPARE(listview->contentY(), 480.); // 40*20 - 320
-
- listview->setContentY(80);
- canvas->rootObject()->setProperty("showFooter", true);
- listview->positionViewAtEnd();
- QTRY_COMPARE(listview->contentY(), 510.);
-
- // set current item to outside visible view, position at beginning
- // and ensure highlight moves to current item
- listview->setCurrentIndex(1);
- listview->positionViewAtBeginning();
- QTRY_COMPARE(listview->contentY(), -30.);
- QVERIFY(listview->highlightItem());
- QCOMPARE(listview->highlightItem()->y(), 20.);
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::resetModel()
-{
- QQuickView *canvas = createView();
-
- QStringList strings;
- strings << "one" << "two" << "three";
- QStringListModel model(strings);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("displaylist.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QTRY_COMPARE(listview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QQuickText *display = findItem<QQuickText>(contentItem, "displayText", i);
- QTRY_VERIFY(display != 0);
- QTRY_COMPARE(display->text(), strings.at(i));
- }
-
- strings.clear();
- strings << "four" << "five" << "six" << "seven";
- model.setStringList(strings);
-
- QTRY_COMPARE(listview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QQuickText *display = findItem<QQuickText>(contentItem, "displayText", i);
- QTRY_VERIFY(display != 0);
- QTRY_COMPARE(display->text(), strings.at(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickListView::propertyChanges()
-{
- QQuickView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(testFileUrl("propertychangestest.qml"));
-
- QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView");
- QTRY_VERIFY(listView);
-
- QSignalSpy highlightFollowsCurrentItemSpy(listView, SIGNAL(highlightFollowsCurrentItemChanged()));
- QSignalSpy preferredHighlightBeginSpy(listView, SIGNAL(preferredHighlightBeginChanged()));
- QSignalSpy preferredHighlightEndSpy(listView, SIGNAL(preferredHighlightEndChanged()));
- QSignalSpy highlightRangeModeSpy(listView, SIGNAL(highlightRangeModeChanged()));
- QSignalSpy keyNavigationWrapsSpy(listView, SIGNAL(keyNavigationWrapsChanged()));
- QSignalSpy cacheBufferSpy(listView, SIGNAL(cacheBufferChanged()));
- QSignalSpy snapModeSpy(listView, SIGNAL(snapModeChanged()));
-
- QTRY_COMPARE(listView->highlightFollowsCurrentItem(), true);
- QTRY_COMPARE(listView->preferredHighlightBegin(), 0.0);
- QTRY_COMPARE(listView->preferredHighlightEnd(), 0.0);
- QTRY_COMPARE(listView->highlightRangeMode(), QQuickListView::ApplyRange);
- QTRY_COMPARE(listView->isWrapEnabled(), true);
- QTRY_COMPARE(listView->cacheBuffer(), 10);
- QTRY_COMPARE(listView->snapMode(), QQuickListView::SnapToItem);
-
- listView->setHighlightFollowsCurrentItem(false);
- listView->setPreferredHighlightBegin(1.0);
- listView->setPreferredHighlightEnd(1.0);
- listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange);
- listView->setWrapEnabled(false);
- listView->setCacheBuffer(3);
- listView->setSnapMode(QQuickListView::SnapOneItem);
-
- QTRY_COMPARE(listView->highlightFollowsCurrentItem(), false);
- QTRY_COMPARE(listView->preferredHighlightBegin(), 1.0);
- QTRY_COMPARE(listView->preferredHighlightEnd(), 1.0);
- QTRY_COMPARE(listView->highlightRangeMode(), QQuickListView::StrictlyEnforceRange);
- QTRY_COMPARE(listView->isWrapEnabled(), false);
- QTRY_COMPARE(listView->cacheBuffer(), 3);
- QTRY_COMPARE(listView->snapMode(), QQuickListView::SnapOneItem);
-
- QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1);
- QTRY_COMPARE(preferredHighlightBeginSpy.count(),1);
- QTRY_COMPARE(preferredHighlightEndSpy.count(),1);
- QTRY_COMPARE(highlightRangeModeSpy.count(),1);
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
- QTRY_COMPARE(cacheBufferSpy.count(),1);
- QTRY_COMPARE(snapModeSpy.count(),1);
-
- listView->setHighlightFollowsCurrentItem(false);
- listView->setPreferredHighlightBegin(1.0);
- listView->setPreferredHighlightEnd(1.0);
- listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange);
- listView->setWrapEnabled(false);
- listView->setCacheBuffer(3);
- listView->setSnapMode(QQuickListView::SnapOneItem);
-
- QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1);
- QTRY_COMPARE(preferredHighlightBeginSpy.count(),1);
- QTRY_COMPARE(preferredHighlightEndSpy.count(),1);
- QTRY_COMPARE(highlightRangeModeSpy.count(),1);
- QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
- QTRY_COMPARE(cacheBufferSpy.count(),1);
- QTRY_COMPARE(snapModeSpy.count(),1);
-
- delete canvas;
-}
-
-void tst_QQuickListView::componentChanges()
-{
- QQuickView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(testFileUrl("propertychangestest.qml"));
-
- QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView");
- QTRY_VERIFY(listView);
-
- QDeclarativeComponent component(canvas->engine());
- component.setData("import QtQuick 2.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile(""));
-
- QDeclarativeComponent delegateComponent(canvas->engine());
- delegateComponent.setData("import QtQuick 2.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
-
- QSignalSpy highlightSpy(listView, SIGNAL(highlightChanged()));
- QSignalSpy delegateSpy(listView, SIGNAL(delegateChanged()));
- QSignalSpy headerSpy(listView, SIGNAL(headerChanged()));
- QSignalSpy footerSpy(listView, SIGNAL(footerChanged()));
-
- listView->setHighlight(&component);
- listView->setHeader(&component);
- listView->setFooter(&component);
- listView->setDelegate(&delegateComponent);
-
- QTRY_COMPARE(listView->highlight(), &component);
- QTRY_COMPARE(listView->header(), &component);
- QTRY_COMPARE(listView->footer(), &component);
- QTRY_COMPARE(listView->delegate(), &delegateComponent);
-
- QTRY_COMPARE(highlightSpy.count(),1);
- QTRY_COMPARE(delegateSpy.count(),1);
- QTRY_COMPARE(headerSpy.count(),1);
- QTRY_COMPARE(footerSpy.count(),1);
-
- listView->setHighlight(&component);
- listView->setHeader(&component);
- listView->setFooter(&component);
- listView->setDelegate(&delegateComponent);
-
- QTRY_COMPARE(highlightSpy.count(),1);
- QTRY_COMPARE(delegateSpy.count(),1);
- QTRY_COMPARE(headerSpy.count(),1);
- QTRY_COMPARE(footerSpy.count(),1);
-
- delete canvas;
-}
-
-void tst_QQuickListView::modelChanges()
-{
- QQuickView *canvas = createView();
- QTRY_VERIFY(canvas);
- canvas->setSource(testFileUrl("propertychangestest.qml"));
-
- QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView");
- QTRY_VERIFY(listView);
-
- QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel");
- QTRY_VERIFY(alternateModel);
- QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
- QSignalSpy modelSpy(listView, SIGNAL(modelChanged()));
-
- listView->setModel(modelVariant);
- QTRY_COMPARE(listView->model(), modelVariant);
- QTRY_COMPARE(modelSpy.count(),1);
-
- listView->setModel(modelVariant);
- QTRY_COMPARE(modelSpy.count(),1);
-
- listView->setModel(QVariant());
- QTRY_COMPARE(modelSpy.count(),2);
-
- delete canvas;
-}
-
-void tst_QQuickListView::QTBUG_9791()
-{
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("strictlyenforcerange.qml"));
- qApp->processEvents();
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_VERIFY(listview->delegate() != 0);
- QTRY_VERIFY(listview->model() != 0);
-
- QMetaObject::invokeMethod(listview, "fillModel");
- qApp->processEvents();
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
- QCOMPARE(itemCount, 3);
-
- for (int i = 0; i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), i*300.0);
- }
-
- // check that view is positioned correctly
- QTRY_COMPARE(listview->contentX(), 590.0);
-
- delete canvas;
-}
-
-void tst_QQuickListView::manualHighlight()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
-
- QString filename(testFile("manual-highlight.qml"));
- canvas->setSource(QUrl::fromLocalFile(filename));
-
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(listview->currentIndex(), 0);
- QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
- QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
-
- listview->setCurrentIndex(2);
-
- QTRY_COMPARE(listview->currentIndex(), 2);
- QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
- QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
-
- // QTBUG-15972
- listview->positionViewAtIndex(3, QQuickListView::Contain);
-
- QTRY_COMPARE(listview->currentIndex(), 2);
- QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
- QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
-
- delete canvas;
-}
-
-void tst_QQuickListView::QTBUG_11105()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; 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(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_VERIFY(item->y() == i*20);
- }
-
- listview->positionViewAtIndex(20, QQuickListView::Beginning);
- QCOMPARE(listview->contentY(), 280.);
-
- QmlListModel model2;
- for (int i = 0; i < 5; i++)
- model2.addItem("Item" + QString::number(i), "");
-
- ctxt->setContextProperty("testModel", &model2);
-
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- QCOMPARE(itemCount, 5);
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::header()
-{
- QFETCH(QQuickListView::Orientation, orientation);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(QPointF, initialHeaderPos);
- QFETCH(QPointF, firstDelegatePos);
- QFETCH(QPointF, initialContentPos);
- QFETCH(QPointF, changedHeaderPos);
- QFETCH(QPointF, changedContentPos);
- QFETCH(QPointF, resizeContentPos);
-
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QQuickView *canvas = createView();
- canvas->rootContext()->setContextProperty("testModel", &model);
- canvas->rootContext()->setContextProperty("initialViewWidth", 240);
- canvas->rootContext()->setContextProperty("initialViewHeight", 320);
- canvas->setSource(testFileUrl("header.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- listview->setOrientation(orientation);
- listview->setLayoutDirection(layoutDirection);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickText *header = 0;
- QTRY_VERIFY(header = findItem<QQuickText>(contentItem, "header"));
- QVERIFY(header == listview->headerItem());
-
- QCOMPARE(header->width(), 100.);
- QCOMPARE(header->height(), 30.);
- QCOMPARE(header->pos(), initialHeaderPos);
- QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos);
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->pos(), firstDelegatePos);
-
- model.clear();
- QTRY_COMPARE(listview->count(), model.count());
- QCOMPARE(header->pos(), initialHeaderPos); // header should stay where it is
-
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QSignalSpy headerItemSpy(listview, SIGNAL(headerItemChanged()));
- QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader");
-
- QCOMPARE(headerItemSpy.count(), 1);
-
- header = findItem<QQuickText>(contentItem, "header");
- QVERIFY(!header);
- header = findItem<QQuickText>(contentItem, "header2");
- QVERIFY(header);
-
- QVERIFY(header == listview->headerItem());
-
- QCOMPARE(header->pos(), changedHeaderPos);
- QCOMPARE(header->width(), 50.);
- QCOMPARE(header->height(), 20.);
- QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), changedContentPos);
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->pos(), firstDelegatePos);
-
- delete canvas;
-
-
- // QTBUG-21207 header should become visible if view resizes from initial empty size
-
- canvas = createView();
- canvas->rootContext()->setContextProperty("testModel", &model);
- canvas->rootContext()->setContextProperty("initialViewWidth", 0.0);
- canvas->rootContext()->setContextProperty("initialViewHeight", 0.0);
- canvas->setSource(testFileUrl("header.qml"));
- canvas->show();
- qApp->processEvents();
-
- listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- listview->setOrientation(orientation);
- listview->setLayoutDirection(layoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- listview->setWidth(240);
- listview->setHeight(320);
- QTRY_COMPARE(listview->headerItem()->pos(), initialHeaderPos);
- QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos);
-
-
- delete canvas;
-}
-
-void tst_QQuickListView::header_data()
-{
- QTest::addColumn<QQuickListView::Orientation>("orientation");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<QPointF>("initialHeaderPos");
- QTest::addColumn<QPointF>("changedHeaderPos");
- QTest::addColumn<QPointF>("initialContentPos");
- QTest::addColumn<QPointF>("changedContentPos");
- QTest::addColumn<QPointF>("firstDelegatePos");
- QTest::addColumn<QPointF>("resizeContentPos");
-
- // header1 = 100 x 30
- // header2 = 50 x 20
- // delegates = 240 x 20
- // view width = 240
-
- // header above items, top left
- QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight
- << QPointF(0, -30)
- << QPointF(0, -20)
- << QPointF(0, -30)
- << QPointF(0, -20)
- << QPointF(0, 0)
- << QPointF(0, -10);
-
- // header above items, top right
- QTest::newRow("vertical, layout right to left") << QQuickListView::Vertical << Qt::RightToLeft
- << QPointF(0, -30)
- << QPointF(0, -20)
- << QPointF(0, -30)
- << QPointF(0, -20)
- << QPointF(0, 0)
- << QPointF(0, -10);
-
- // header to left of items
- QTest::newRow("horizontal, layout left to right") << QQuickListView::Horizontal << Qt::LeftToRight
- << QPointF(-100, 0)
- << QPointF(-50, 0)
- << QPointF(-100, 0)
- << QPointF(-50, 0)
- << QPointF(0, 0)
- << QPointF(-40, 0);
-
- // header to right of items
- QTest::newRow("horizontal, layout right to left") << QQuickListView::Horizontal << Qt::RightToLeft
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(-240 + 100, 0)
- << QPointF(-240 + 50, 0)
- << QPointF(-240, 0)
- << QPointF(-240 + 40, 0);
-}
-
-void tst_QQuickListView::header_delayItemCreation()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
-
- canvas->rootContext()->setContextProperty("setCurrentToZero", QVariant(false));
- canvas->setSource(testFileUrl("fillModelOnComponentCompleted.qml"));
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickText *header = findItem<QQuickText>(contentItem, "header");
- QVERIFY(header);
- QCOMPARE(header->y(), -header->height());
-
- QCOMPARE(listview->contentY(), -header->height());
-
- model.clear();
- QTRY_COMPARE(header->y(), -header->height());
-
- delete canvas;
-}
-
-void tst_QQuickListView::footer()
-{
- QFETCH(QQuickListView::Orientation, orientation);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(QPointF, initialFooterPos);
- QFETCH(QPointF, firstDelegatePos);
- QFETCH(QPointF, initialContentPos);
- QFETCH(QPointF, changedFooterPos);
- QFETCH(QPointF, changedContentPos);
- QFETCH(QPointF, resizeContentPos);
-
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 3; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("footer.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- listview->setOrientation(orientation);
- listview->setLayoutDirection(layoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickText *footer = findItem<QQuickText>(contentItem, "footer");
- QVERIFY(footer);
-
- QVERIFY(footer == listview->footerItem());
-
- QCOMPARE(footer->pos(), initialFooterPos);
- QCOMPARE(footer->width(), 100.);
- QCOMPARE(footer->height(), 30.);
- QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos);
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->pos(), firstDelegatePos);
-
- // remove one item
- model.removeItem(1);
-
- if (orientation == QQuickListView::Vertical) {
- QTRY_COMPARE(footer->y(), initialFooterPos.y() - 20); // delegate height = 20
- } else {
- QTRY_COMPARE(footer->x(), layoutDirection == Qt::LeftToRight ?
- initialFooterPos.x() - 40 : initialFooterPos.x() + 40); // delegate width = 40
- }
-
- // remove all items
- model.clear();
-
- QPointF posWhenNoItems(0, 0);
- if (orientation == QQuickListView::Horizontal && layoutDirection == Qt::RightToLeft)
- posWhenNoItems.setX(-100);
- QTRY_COMPARE(footer->pos(), posWhenNoItems);
-
- // if header is present, it's at a negative pos, so the footer should not move
- canvas->rootObject()->setProperty("showHeader", true);
- QTRY_COMPARE(footer->pos(), posWhenNoItems);
- canvas->rootObject()->setProperty("showHeader", false);
-
- // add 30 items
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QSignalSpy footerItemSpy(listview, SIGNAL(footerItemChanged()));
- QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter");
-
- QCOMPARE(footerItemSpy.count(), 1);
-
- footer = findItem<QQuickText>(contentItem, "footer");
- QVERIFY(!footer);
- footer = findItem<QQuickText>(contentItem, "footer2");
- QVERIFY(footer);
-
- QVERIFY(footer == listview->footerItem());
-
- QCOMPARE(footer->pos(), changedFooterPos);
- QCOMPARE(footer->width(), 50.);
- QCOMPARE(footer->height(), 20.);
- QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), changedContentPos);
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->pos(), firstDelegatePos);
-
- listview->positionViewAtEnd();
- footer->setHeight(10);
- footer->setWidth(40);
- QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), resizeContentPos);
-
- delete canvas;
-}
-
-void tst_QQuickListView::footer_data()
-{
- QTest::addColumn<QQuickListView::Orientation>("orientation");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<QPointF>("initialFooterPos");
- QTest::addColumn<QPointF>("changedFooterPos");
- QTest::addColumn<QPointF>("initialContentPos");
- QTest::addColumn<QPointF>("changedContentPos");
- QTest::addColumn<QPointF>("firstDelegatePos");
- QTest::addColumn<QPointF>("resizeContentPos");
-
- // footer1 = 100 x 30
- // footer2 = 50 x 20
- // delegates = 40 x 20
- // view width = 240
- // view height = 320
-
- // footer below items, bottom left
- QTest::newRow("vertical, layout left to right") << QQuickListView::Vertical << Qt::LeftToRight
- << QPointF(0, 3 * 20)
- << QPointF(0, 30 * 20) // added 30 items
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(0, 30 * 20 - 320 + 10);
-
- // footer below items, bottom right
- QTest::newRow("vertical, layout right to left") << QQuickListView::Vertical << Qt::RightToLeft
- << QPointF(0, 3 * 20)
- << QPointF(0, 30 * 20)
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(0, 30 * 20 - 320 + 10);
-
- // footer to right of items
- QTest::newRow("horizontal, layout left to right") << QQuickListView::Horizontal << Qt::LeftToRight
- << QPointF(40 * 3, 0)
- << QPointF(40 * 30, 0)
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(0, 0)
- << QPointF(40 * 30 - 240 + 40, 0);
-
- // footer to left of items
- QTest::newRow("horizontal, layout right to left") << QQuickListView::Horizontal << Qt::RightToLeft
- << QPointF(-(40 * 3) - 100, 0)
- << QPointF(-(40 * 30) - 50, 0) // 50 = new footer width
- << QPointF(-240, 0)
- << QPointF(-240, 0)
- << QPointF(-40, 0)
- << QPointF(-(40 * 30) - 40, 0);
-}
-
-class LVAccessor : public QQuickListView
-{
-public:
- qreal minY() const { return minYExtent(); }
- qreal maxY() const { return maxYExtent(); }
- qreal minX() const { return minXExtent(); }
- qreal maxX() const { return maxXExtent(); }
-};
-
-void tst_QQuickListView::headerFooter()
-{
- {
- // Vertical
- QQuickView *canvas = createView();
-
- QmlListModel model;
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("headerfooter.qml"));
- qApp->processEvents();
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickItem *header = findItem<QQuickItem>(contentItem, "header");
- QVERIFY(header);
- QCOMPARE(header->y(), -header->height());
-
- QQuickItem *footer = findItem<QQuickItem>(contentItem, "footer");
- QVERIFY(footer);
- QCOMPARE(footer->y(), 0.);
-
- QCOMPARE(static_cast<LVAccessor*>(listview)->minY(), header->height());
- QCOMPARE(static_cast<LVAccessor*>(listview)->maxY(), header->height());
-
- delete canvas;
- }
- {
- // Horizontal
- QQuickView *canvas = createView();
-
- QmlListModel model;
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("headerfooter.qml"));
- canvas->rootObject()->setProperty("horizontal", true);
- qApp->processEvents();
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickItem *header = findItem<QQuickItem>(contentItem, "header");
- QVERIFY(header);
- QCOMPARE(header->x(), -header->width());
-
- QQuickItem *footer = findItem<QQuickItem>(contentItem, "footer");
- QVERIFY(footer);
- QCOMPARE(footer->x(), 0.);
-
- QCOMPARE(static_cast<LVAccessor*>(listview)->minX(), header->width());
- QCOMPARE(static_cast<LVAccessor*>(listview)->maxX(), header->width());
-
- delete canvas;
- }
- {
- // Horizontal RTL
- QQuickView *canvas = createView();
-
- QmlListModel model;
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("headerfooter.qml"));
- canvas->rootObject()->setProperty("horizontal", true);
- canvas->rootObject()->setProperty("rtl", true);
- qApp->processEvents();
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QQuickItem *header = findItem<QQuickItem>(contentItem, "header");
- QVERIFY(header);
- QCOMPARE(header->x(), 0.);
-
- QQuickItem *footer = findItem<QQuickItem>(contentItem, "footer");
- QVERIFY(footer);
- QCOMPARE(footer->x(), -footer->width());
-
- QCOMPARE(static_cast<LVAccessor*>(listview)->minX(), 240. - header->width());
- QCOMPARE(static_cast<LVAccessor*>(listview)->maxX(), 240. - header->width());
-
- delete canvas;
- }
-}
-
-void tst_QQuickListView::resizeView()
-{
- QQuickView *canvas = createView();
-
- QmlListModel 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(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(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);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
- QCOMPARE(heightRatio.toReal(), 0.25);
-
- // Ensure we handle -ve sizes
- listview->setHeight(-100);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 1);
-
- listview->setCacheBuffer(200);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 11);
-
- // ensure items in cache become visible
- listview->setHeight(200);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 21);
-
- itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- QCOMPARE(item->isVisible(), i < 11); // inside view visible, outside not visible
- }
-
- // ensure items outside view become invisible
- listview->setHeight(100);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 16);
-
- itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*20.);
- QCOMPARE(item->isVisible(), i < 6); // inside view visible, outside not visible
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::resizeViewAndRepaint()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 40; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("initialHeight", 100);
-
- canvas->setSource(testFileUrl("resizeview.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // item at index 10 should not be currently visible
- QVERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
-
- listview->setHeight(320);
-
- QTRY_VERIFY(findItem<QQuickItem>(contentItem, "wrapper", 10));
-
- listview->setHeight(100);
- QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
-
- delete canvas;
-}
-
-void tst_QQuickListView::sizeLessThan1()
-{
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; 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(testFileUrl("sizelessthan1.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // Confirm items positioned correctly
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- if (!item) qWarning() << "Item" << i << "not found";
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->y(), i*0.5);
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::QTBUG_14821()
-{
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("qtbug14821.qml"));
- qApp->processEvents();
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- listview->decrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 99);
-
- listview->incrementCurrentIndex();
- QCOMPARE(listview->currentIndex(), 0);
-
- delete canvas;
-}
-
-void tst_QQuickListView::resizeDelegate()
-{
- QQuickView *canvas = createView();
-
- QStringList strings;
- for (int i = 0; i < 30; ++i)
- strings << QString::number(i);
- QStringListModel model(strings);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("displaylist.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QCOMPARE(listview->count(), model.rowCount());
-
- listview->setCurrentIndex(25);
- listview->setContentY(0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- for (int i = 0; i < 16; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY(item != 0);
- QCOMPARE(item->y(), i*20.0);
- }
-
- QCOMPARE(listview->currentItem()->y(), 500.0);
- QTRY_COMPARE(listview->highlightItem()->y(), 500.0);
-
- canvas->rootObject()->setProperty("delegateHeight", 30);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- for (int i = 0; i < 11; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY(item != 0);
- QTRY_COMPARE(item->y(), i*30.0);
- }
-
- QTRY_COMPARE(listview->currentItem()->y(), 750.0);
- QTRY_COMPARE(listview->highlightItem()->y(), 750.0);
-
- listview->setCurrentIndex(1);
- listview->positionViewAtIndex(25, QQuickListView::Beginning);
- listview->positionViewAtIndex(5, QQuickListView::Beginning);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- for (int i = 5; i < 16; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY(item != 0);
- QCOMPARE(item->y(), i*30.0);
- }
-
- QTRY_COMPARE(listview->currentItem()->y(), 30.0);
- QTRY_COMPARE(listview->highlightItem()->y(), 30.0);
-
- canvas->rootObject()->setProperty("delegateHeight", 20);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- for (int i = 5; i < 11; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY(item != 0);
- QTRY_COMPARE(item->y(), 150 + (i-5)*20.0);
- }
-
- QTRY_COMPARE(listview->currentItem()->y(), 70.0);
- QTRY_COMPARE(listview->highlightItem()->y(), 70.0);
-
- delete canvas;
-}
-
-void tst_QQuickListView::resizeFirstDelegate()
-{
- // QTBUG-20712: Content Y jumps constantly if first delegate height == 0
- // and other delegates have height > 0
-
- QQuickView *canvas = createView();
-
- // bug only occurs when all items in the model are visible
- QmlListModel model;
- for (int i = 0; i < 10; 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(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QVERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QQuickItem *item = 0;
- for (int i = 0; i < model.count(); ++i) {
- item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY(item != 0);
- QCOMPARE(item->y(), i*20.0);
- }
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 0);
- item->setHeight(0);
-
- // check the content y has not jumped up and down
- QCOMPARE(listview->contentY(), 0.0);
- QSignalSpy spy(listview, SIGNAL(contentYChanged()));
- QTest::qWait(100);
- QCOMPARE(spy.count(), 0);
-
- for (int i = 1; i < model.count(); ++i) {
- item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY(item != 0);
- QTRY_COMPARE(item->y(), (i-1)*20.0);
- }
-
-
- // QTBUG-22014: refill doesn't clear items scrolling off the top of the
- // list if they follow a zero-sized delegate
-
- for (int i = 0; i < 10; i++)
- model.addItem("Item" + QString::number(i), "");
- QTRY_COMPARE(listview->count(), model.count());
-
- item = findItem<QQuickItem>(contentItem, "wrapper", 1);
- QVERIFY(item);
- item->setHeight(0);
-
- listview->setCurrentIndex(19);
- qApp->processEvents();
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // items 0-2 should have been deleted
- for (int i=0; i<3; i++) {
- QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", i));
- }
-
- delete testObject;
- delete canvas;
-}
-
-void tst_QQuickListView::QTBUG_16037()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- canvas->setSource(testFileUrl("qtbug16037.qml"));
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "listview");
- QTRY_VERIFY(listview != 0);
-
- QVERIFY(listview->contentHeight() <= 0.0);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "setModel");
-
- QTRY_COMPARE(listview->contentHeight(), 80.0);
-
- delete canvas;
-}
-
-void tst_QQuickListView::indexAt_itemAt_data()
-{
- QTest::addColumn<qreal>("x");
- QTest::addColumn<qreal>("y");
- QTest::addColumn<int>("index");
-
- QTest::newRow("Item 0 - 0, 0") << 0. << 0. << 0;
- QTest::newRow("Item 0 - 0, 19") << 0. << 19. << 0;
- QTest::newRow("Item 0 - 239, 19") << 239. << 19. << 0;
- QTest::newRow("Item 1 - 0, 20") << 0. << 20. << 1;
- QTest::newRow("No Item - 240, 20") << 240. << 20. << -1;
-}
-
-void tst_QQuickListView::indexAt_itemAt()
-{
- QFETCH(qreal, x);
- QFETCH(qreal, y);
- QFETCH(int, index);
-
- QQuickView *canvas = createView();
-
- QmlListModel model;
- for (int i = 0; i < 30; 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(testFileUrl("listviewtest.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QQuickItem *item = 0;
- if (index >= 0) {
- item = findItem<QQuickItem>(contentItem, "wrapper", index);
- QVERIFY(item);
- }
- QCOMPARE(listview->indexAt(x,y), index);
- QVERIFY(listview->itemAt(x,y) == item);
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::incrementalModel()
-{
- QQuickView *canvas = createView();
-
- IncrementalModel model;
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("displaylist.qml"));
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(listview->count(), 20);
-
- listview->positionViewAtIndex(10, QQuickListView::Beginning);
-
- QTRY_COMPARE(listview->count(), 25);
-
- delete canvas;
-}
-
-void tst_QQuickListView::onAdd()
-{
- QFETCH(int, initialItemCount);
- QFETCH(int, itemsToAdd);
-
- const int delegateHeight = 10;
- QaimModel model;
-
- // these initial items should not trigger ListView.onAdd
- for (int i=0; i<initialItemCount; i++)
- model.addItem("dummy value", "dummy value");
-
- QQuickView *canvas = createView();
- canvas->setGeometry(0,0,200, delegateHeight * (initialItemCount + itemsToAdd));
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("delegateHeight", delegateHeight);
- canvas->setSource(testFileUrl("attachedSignals.qml"));
-
- QObject *object = canvas->rootObject();
- object->setProperty("width", canvas->width());
- object->setProperty("height", canvas->height());
- qApp->processEvents();
-
- QList<QPair<QString, QString> > items;
- for (int i=0; i<itemsToAdd; i++)
- items << qMakePair(QString("value %1").arg(i), QString::number(i));
- model.addItems(items);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- QVariantList result = object->property("addedDelegates").toList();
- QCOMPARE(result.count(), items.count());
- for (int i=0; i<items.count(); i++)
- QCOMPARE(result[i].toString(), items[i].first);
-
- delete canvas;
-}
-
-void tst_QQuickListView::onAdd_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<int>("itemsToAdd");
-
- QTest::newRow("0, add 1") << 0 << 1;
- QTest::newRow("0, add 2") << 0 << 2;
- QTest::newRow("0, add 10") << 0 << 10;
-
- QTest::newRow("1, add 1") << 1 << 1;
- QTest::newRow("1, add 2") << 1 << 2;
- QTest::newRow("1, add 10") << 1 << 10;
-
- QTest::newRow("5, add 1") << 5 << 1;
- QTest::newRow("5, add 2") << 5 << 2;
- QTest::newRow("5, add 10") << 5 << 10;
-}
-
-void tst_QQuickListView::onRemove()
-{
- QFETCH(int, initialItemCount);
- QFETCH(int, indexToRemove);
- QFETCH(int, removeCount);
-
- const int delegateHeight = 10;
- QaimModel model;
- for (int i=0; i<initialItemCount; i++)
- model.addItem(QString("value %1").arg(i), "dummy value");
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("delegateHeight", delegateHeight);
- canvas->setSource(testFileUrl("attachedSignals.qml"));
-
- QObject *object = canvas->rootObject();
-
- model.removeItems(indexToRemove, removeCount);
- QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
-
- QCOMPARE(object->property("removedDelegateCount"), QVariant(removeCount));
-
- delete canvas;
-}
-
-void tst_QQuickListView::onRemove_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<int>("indexToRemove");
- QTest::addColumn<int>("removeCount");
-
- QTest::newRow("remove first") << 1 << 0 << 1;
- QTest::newRow("two items, remove first") << 2 << 0 << 1;
- QTest::newRow("two items, remove last") << 2 << 1 << 1;
- QTest::newRow("two items, remove all") << 2 << 0 << 2;
-
- QTest::newRow("four items, remove first") << 4 << 0 << 1;
- QTest::newRow("four items, remove 0-2") << 4 << 0 << 2;
- QTest::newRow("four items, remove 1-3") << 4 << 1 << 2;
- QTest::newRow("four items, remove 2-4") << 4 << 2 << 2;
- QTest::newRow("four items, remove last") << 4 << 3 << 1;
- QTest::newRow("four items, remove all") << 4 << 0 << 4;
-
- QTest::newRow("ten items, remove 1-8") << 10 << 0 << 8;
- QTest::newRow("ten items, remove 2-7") << 10 << 2 << 5;
- QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6;
-}
-
-void tst_QQuickListView::rightToLeft()
-{
- QQuickView *canvas = createView();
- canvas->setGeometry(0,0,640,320);
- canvas->setSource(testFileUrl("rightToLeft.qml"));
- canvas->show();
- qApp->processEvents();
-
- QVERIFY(canvas->rootObject() != 0);
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "view");
- QTRY_VERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QQuickVisualItemModel *model = canvas->rootObject()->findChild<QQuickVisualItemModel*>("itemModel");
- QTRY_VERIFY(model != 0);
-
- QTRY_VERIFY(model->count() == 3);
- QTRY_COMPARE(listview->currentIndex(), 0);
-
- // initial position at first item, right edge aligned
- QCOMPARE(listview->contentX(), -640.);
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "item1");
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), -100.0);
- QCOMPARE(item->height(), listview->height());
-
- QQuickText *text = findItem<QQuickText>(contentItem, "text1");
- QTRY_VERIFY(text);
- QTRY_COMPARE(text->text(), QLatin1String("index: 0"));
-
- listview->setCurrentIndex(2);
-
- item = findItem<QQuickItem>(contentItem, "item3");
- QTRY_VERIFY(item);
- QTRY_COMPARE(item->x(), -540.0);
-
- text = findItem<QQuickText>(contentItem, "text3");
- QTRY_VERIFY(text);
- QTRY_COMPARE(text->text(), QLatin1String("index: 2"));
-
- QCOMPARE(listview->contentX(), -640.);
-
- // Ensure resizing maintains position relative to right edge
- qobject_cast<QQuickItem*>(canvas->rootObject())->setWidth(600);
- QTRY_COMPARE(listview->contentX(), -600.);
-
- delete canvas;
-}
-
-void tst_QQuickListView::test_mirroring()
-{
- QQuickView *canvasA = createView();
- canvasA->setSource(testFileUrl("rightToLeft.qml"));
- QQuickListView *listviewA = findItem<QQuickListView>(canvasA->rootObject(), "view");
- QTRY_VERIFY(listviewA != 0);
-
- QQuickView *canvasB = createView();
- canvasB->setSource(testFileUrl("rightToLeft.qml"));
- QQuickListView *listviewB = findItem<QQuickListView>(canvasB->rootObject(), "view");
- QTRY_VERIFY(listviewA != 0);
- qApp->processEvents();
-
- QList<QString> objectNames;
- objectNames << "item1" << "item2"; // << "item3"
-
- listviewA->setProperty("layoutDirection", Qt::LeftToRight);
- listviewB->setProperty("layoutDirection", Qt::RightToLeft);
- QCOMPARE(listviewA->layoutDirection(), listviewA->effectiveLayoutDirection());
-
- // LTR != RTL
- foreach (const QString objectName, objectNames)
- QVERIFY(findItem<QQuickItem>(listviewA, objectName)->x() != findItem<QQuickItem>(listviewB, objectName)->x());
-
- listviewA->setProperty("layoutDirection", Qt::LeftToRight);
- listviewB->setProperty("layoutDirection", Qt::LeftToRight);
-
- // LTR == LTR
- foreach (const QString objectName, objectNames)
- QCOMPARE(findItem<QQuickItem>(listviewA, objectName)->x(), findItem<QQuickItem>(listviewB, objectName)->x());
-
- QVERIFY(listviewB->layoutDirection() == listviewB->effectiveLayoutDirection());
- QQuickItemPrivate::get(listviewB)->setLayoutMirror(true);
- QVERIFY(listviewB->layoutDirection() != listviewB->effectiveLayoutDirection());
-
- // LTR != LTR+mirror
- foreach (const QString objectName, objectNames)
- QVERIFY(findItem<QQuickItem>(listviewA, objectName)->x() != findItem<QQuickItem>(listviewB, objectName)->x());
-
- listviewA->setProperty("layoutDirection", Qt::RightToLeft);
-
- // RTL == LTR+mirror
- foreach (const QString objectName, objectNames)
- QCOMPARE(findItem<QQuickItem>(listviewA, objectName)->x(), findItem<QQuickItem>(listviewB, objectName)->x());
-
- listviewB->setProperty("layoutDirection", Qt::RightToLeft);
-
- // RTL != RTL+mirror
- foreach (const QString objectName, objectNames)
- QVERIFY(findItem<QQuickItem>(listviewA, objectName)->x() != findItem<QQuickItem>(listviewB, objectName)->x());
-
- listviewA->setProperty("layoutDirection", Qt::LeftToRight);
-
- // LTR == RTL+mirror
- foreach (const QString objectName, objectNames)
- QCOMPARE(findItem<QQuickItem>(listviewA, objectName)->x(), findItem<QQuickItem>(listviewB, objectName)->x());
-
- delete canvasA;
- delete canvasB;
-}
-
-void tst_QQuickListView::margins()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- for (int i = 0; i < 50; i++)
- model.addItem("Item" + QString::number(i), "");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("margins.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QCOMPARE(listview->contentY(), -30.);
- QCOMPARE(listview->yOrigin(), 0.);
-
- // check end bound
- listview->positionViewAtEnd();
- qreal pos = listview->contentY();
- listview->setContentY(pos + 80);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- listview->returnToBounds();
- QTRY_COMPARE(listview->contentY(), pos + 50);
-
- // remove item before visible and check that top margin is maintained
- // and yOrigin is updated
- listview->setContentY(100);
- model.removeItem(1);
- QTRY_COMPARE(listview->count(), model.count());
- listview->setContentY(-50);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- listview->returnToBounds();
- QCOMPARE(listview->yOrigin(), 20.);
- QTRY_COMPARE(listview->contentY(), -10.);
-
- // reduce top margin
- listview->setTopMargin(20);
- QCOMPARE(listview->yOrigin(), 20.);
- QTRY_COMPARE(listview->contentY(), 0.);
-
- // check end bound
- listview->positionViewAtEnd();
- pos = listview->contentY();
- listview->setContentY(pos + 80);
- listview->returnToBounds();
- QTRY_COMPARE(listview->contentY(), pos + 50);
-
- // reduce bottom margin
- pos = listview->contentY();
- listview->setBottomMargin(40);
- QCOMPARE(listview->yOrigin(), 20.);
- QTRY_COMPARE(listview->contentY(), pos-10);
-
- delete canvas;
-}
-
-// QTBUG-24028
-void tst_QQuickListView::marginsResize()
-{
- QFETCH(QQuickListView::Orientation, orientation);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(qreal, start);
- QFETCH(qreal, end);
-
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("margins2.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "listview");
- QTRY_VERIFY(listview != 0);
-
- listview->setOrientation(orientation);
- listview->setLayoutDirection(layoutDirection);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- // view is resized after componentCompleted - top margin should still be visible
- if (orientation == QQuickListView::Vertical)
- QCOMPARE(listview->contentY(), start);
- else
- QCOMPARE(listview->contentX(), start);
-
- // move to last index and ensure bottom margin is visible.
- listview->setCurrentIndex(19);
- if (orientation == QQuickListView::Vertical)
- QTRY_COMPARE(listview->contentY(), end);
- else
- QTRY_COMPARE(listview->contentX(), end);
-
- // back to top - top margin should be visible.
- listview->setCurrentIndex(0);
- if (orientation == QQuickListView::Vertical)
- QTRY_COMPARE(listview->contentY(), start);
- else
- QTRY_COMPARE(listview->contentX(), start);
-
- delete canvas;
-}
-
-void tst_QQuickListView::marginsResize_data()
-{
- QTest::addColumn<QQuickListView::Orientation>("orientation");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<qreal>("start");
- QTest::addColumn<qreal>("end");
-
- QTest::newRow("vertical") << QQuickListView::Vertical << Qt::LeftToRight << -20.0 << 1020.0;
- QTest::newRow("horizontal") << QQuickListView::Horizontal << Qt::LeftToRight << -20.0 << 1020.0;
- QTest::newRow("horizontal, rtl") << QQuickListView::Horizontal << Qt::RightToLeft << -180.0 << -1220.0;
-}
-
-void tst_QQuickListView::snapToItem_data()
-{
- QTest::addColumn<QQuickListView::Orientation>("orientation");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<int>("highlightRangeMode");
- QTest::addColumn<QPoint>("flickStart");
- QTest::addColumn<QPoint>("flickEnd");
- QTest::addColumn<qreal>("snapAlignment");
- QTest::addColumn<qreal>("endExtent");
- QTest::addColumn<qreal>("startExtent");
-
- QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
-
- QTest::newRow("horizontal, left to right") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
-
- QTest::newRow("horizontal, right to left") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 << -240.0;
-
- QTest::newRow("vertical, left to right, enforce range") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
-
- QTest::newRow("horizontal, left to right, enforce range") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
-
- QTest::newRow("horizontal, right to left, enforce range") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 - 140.0 << -220.0;
-}
-
-void tst_QQuickListView::snapToItem()
-{
- QFETCH(QQuickListView::Orientation, orientation);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(int, highlightRangeMode);
- QFETCH(QPoint, flickStart);
- QFETCH(QPoint, flickEnd);
- QFETCH(qreal, snapAlignment);
- QFETCH(qreal, endExtent);
- QFETCH(qreal, startExtent);
-
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("snapToItem.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- listview->setOrientation(orientation);
- listview->setLayoutDirection(layoutDirection);
- listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- // confirm that a flick hits an item boundary
- flick(canvas, flickStart, flickEnd, 180);
- QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
- if (orientation == QQuickListView::Vertical)
- QCOMPARE(qreal(fmod(listview->contentY(),80.0)), snapAlignment);
- else
- QCOMPARE(qreal(fmod(listview->contentX(),80.0)), snapAlignment);
-
- // flick to end
- do {
- flick(canvas, flickStart, flickEnd, 180);
- QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
- } while (orientation == QQuickListView::Vertical
- ? !listview->isAtYEnd()
- : layoutDirection == Qt::LeftToRight ? !listview->isAtXEnd() : !listview->isAtXBeginning());
-
- if (orientation == QQuickListView::Vertical)
- QCOMPARE(listview->contentY(), endExtent);
- else
- QCOMPARE(listview->contentX(), endExtent);
-
- // flick to start
- do {
- flick(canvas, flickEnd, flickStart, 180);
- QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
- } while (orientation == QQuickListView::Vertical
- ? !listview->isAtYBeginning()
- : layoutDirection == Qt::LeftToRight ? !listview->isAtXBeginning() : !listview->isAtXEnd());
-
- if (orientation == QQuickListView::Vertical)
- QCOMPARE(listview->contentY(), startExtent);
- else
- QCOMPARE(listview->contentX(), startExtent);
-
- delete canvas;
-}
-
-void tst_QQuickListView::qListModelInterface_items()
-{
- items<QmlListModel>(testFileUrl("listviewtest.qml"), false);
-}
-
-void tst_QQuickListView::qListModelInterface_package_items()
-{
- items<QmlListModel>(testFileUrl("listviewtest-package.qml"), true);
-}
-
-void tst_QQuickListView::qAbstractItemModel_items()
-{
- items<QaimModel>(testFileUrl("listviewtest.qml"), false);
-}
-
-void tst_QQuickListView::qListModelInterface_changed()
-{
- changed<QmlListModel>(testFileUrl("listviewtest.qml"), false);
-}
-
-void tst_QQuickListView::qListModelInterface_package_changed()
-{
- changed<QmlListModel>(testFileUrl("listviewtest-package.qml"), true);
-}
-
-void tst_QQuickListView::qAbstractItemModel_changed()
-{
- changed<QaimModel>(testFileUrl("listviewtest.qml"), false);
-}
-
-void tst_QQuickListView::qListModelInterface_inserted()
-{
- inserted<QmlListModel>(testFileUrl("listviewtest.qml"));
-}
-
-void tst_QQuickListView::qListModelInterface_package_inserted()
-{
- inserted<QmlListModel>(testFileUrl("listviewtest-package.qml"));
-}
-
-void tst_QQuickListView::qListModelInterface_inserted_more()
-{
- inserted_more<QmlListModel>();
-}
-
-void tst_QQuickListView::qListModelInterface_inserted_more_data()
-{
- inserted_more_data();
-}
-
-void tst_QQuickListView::qAbstractItemModel_inserted()
-{
- inserted<QaimModel>(testFileUrl("listviewtest.qml"));
-}
-
-void tst_QQuickListView::qAbstractItemModel_inserted_more()
-{
- inserted_more<QaimModel>();
-}
-
-void tst_QQuickListView::qAbstractItemModel_inserted_more_data()
-{
- inserted_more_data();
-}
-
-void tst_QQuickListView::qListModelInterface_removed()
-{
- removed<QmlListModel>(testFileUrl("listviewtest.qml"), false);
- removed<QmlListModel>(testFileUrl("listviewtest.qml"), true);
-}
-
-void tst_QQuickListView::qListModelInterface_removed_more()
-{
- removed_more<QmlListModel>(testFileUrl("listviewtest.qml"));
-}
-
-void tst_QQuickListView::qListModelInterface_removed_more_data()
-{
- removed_more_data();
-}
-
-void tst_QQuickListView::qListModelInterface_package_removed()
-{
- removed<QmlListModel>(testFileUrl("listviewtest-package.qml"), false);
- removed<QmlListModel>(testFileUrl("listviewtest-package.qml"), true);
-}
-
-void tst_QQuickListView::qAbstractItemModel_removed()
-{
- removed<QaimModel>(testFileUrl("listviewtest.qml"), false);
- removed<QaimModel>(testFileUrl("listviewtest.qml"), true);
-}
-
-void tst_QQuickListView::qAbstractItemModel_removed_more()
-{
- removed_more<QaimModel>(testFileUrl("listviewtest.qml"));
-}
-
-void tst_QQuickListView::qAbstractItemModel_removed_more_data()
-{
- removed_more_data();
-}
-
-void tst_QQuickListView::qListModelInterface_moved()
-{
- moved<QmlListModel>(testFileUrl("listviewtest.qml"));
-}
-
-void tst_QQuickListView::qListModelInterface_moved_data()
-{
- moved_data();
-}
-
-void tst_QQuickListView::qListModelInterface_package_moved()
-{
- moved<QmlListModel>(testFileUrl("listviewtest-package.qml"));
-}
-
-void tst_QQuickListView::qListModelInterface_package_moved_data()
-{
- moved_data();
-}
-
-void tst_QQuickListView::qAbstractItemModel_moved()
-{
- moved<QaimModel>(testFileUrl("listviewtest.qml"));
-}
-
-void tst_QQuickListView::qAbstractItemModel_moved_data()
-{
- moved_data();
-}
-
-void tst_QQuickListView::qListModelInterface_clear()
-{
- clear<QmlListModel>(testFileUrl("listviewtest.qml"));
-}
-
-void tst_QQuickListView::qListModelInterface_package_clear()
-{
- clear<QmlListModel>(testFileUrl("listviewtest-package.qml"));
-}
-
-void tst_QQuickListView::qAbstractItemModel_clear()
-{
- clear<QaimModel>(testFileUrl("listviewtest.qml"));
-}
-
-void tst_QQuickListView::qListModelInterface_sections()
-{
- sections<QmlListModel>(testFileUrl("listview-sections.qml"));
-}
-
-void tst_QQuickListView::qListModelInterface_package_sections()
-{
- sections<QmlListModel>(testFileUrl("listview-sections-package.qml"));
-}
-
-void tst_QQuickListView::qAbstractItemModel_sections()
-{
- sections<QaimModel>(testFileUrl("listview-sections.qml"));
-}
-
-void tst_QQuickListView::creationContext()
-{
- QQuickView canvas;
- canvas.setGeometry(0,0,240,320);
- canvas.setSource(testFileUrl("creationContext.qml"));
- qApp->processEvents();
-
- QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
- QVERIFY(rootItem);
- QVERIFY(rootItem->property("count").toInt() > 0);
-
- QQuickItem *item;
- QVERIFY(item = rootItem->findChild<QQuickItem *>("listItem"));
- QCOMPARE(item->property("text").toString(), QString("Hello!"));
- QVERIFY(item = rootItem->findChild<QQuickItem *>("header"));
- QCOMPARE(item->property("text").toString(), QString("Hello!"));
- QVERIFY(item = rootItem->findChild<QQuickItem *>("footer"));
- QCOMPARE(item->property("text").toString(), QString("Hello!"));
- QVERIFY(item = rootItem->findChild<QQuickItem *>("section"));
- QCOMPARE(item->property("text").toString(), QString("Hello!"));
-}
-
-void tst_QQuickListView::QTBUG_21742()
-{
- QQuickView canvas;
- canvas.setGeometry(0,0,200,200);
- canvas.setSource(testFileUrl("qtbug-21742.qml"));
- qApp->processEvents();
-
- QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
- QVERIFY(rootItem);
- QCOMPARE(rootItem->property("count").toInt(), 1);
-}
-
-void tst_QQuickListView::asynchronous()
-{
- QQuickView *canvas = createView();
- canvas->show();
- QDeclarativeIncubationController controller;
- canvas->engine()->setIncubationController(&controller);
-
- canvas->setSource(testFileUrl("asyncloader.qml"));
-
- QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootObject);
-
- QQuickListView *listview = 0;
- while (!listview) {
- bool b = false;
- controller.incubateWhile(&b);
- listview = rootObject->findChild<QQuickListView*>("view");
- }
-
- // items will be created one at a time
- for (int i = 0; i < 8; ++i) {
- QVERIFY(findItem<QQuickItem>(listview, "wrapper", i) == 0);
- QQuickItem *item = 0;
- while (!item) {
- bool b = false;
- controller.incubateWhile(&b);
- item = findItem<QQuickItem>(listview, "wrapper", i);
- }
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- // verify positioning
- QQuickItem *contentItem = listview->contentItem();
- for (int i = 0; i < 8; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QTRY_COMPARE(item->y(), i*50.0);
- }
-
- delete canvas;
-}
-
-void tst_QQuickListView::snapOneItem_data()
-{
- QTest::addColumn<QQuickListView::Orientation>("orientation");
- QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
- QTest::addColumn<int>("highlightRangeMode");
- QTest::addColumn<QPoint>("flickStart");
- QTest::addColumn<QPoint>("flickEnd");
- QTest::addColumn<qreal>("snapAlignment");
- QTest::addColumn<qreal>("endExtent");
- QTest::addColumn<qreal>("startExtent");
-
- QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 560.0 << 0.0;
-
- QTest::newRow("horizontal, left to right") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
- << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 560.0 << 0.0;
-
- QTest::newRow("horizontal, right to left") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
- << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -560.0 - 240.0 << -240.0;
-
- QTest::newRow("vertical, left to right, enforce range") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 580.0 << -20.0;
-
- QTest::newRow("horizontal, left to right, enforce range") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 580.0 << -20.0;
-
- QTest::newRow("horizontal, right to left, enforce range") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
- << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -580.0 - 240.0 << -220.0;
-}
-
-void tst_QQuickListView::snapOneItem()
-{
- QFETCH(QQuickListView::Orientation, orientation);
- QFETCH(Qt::LayoutDirection, layoutDirection);
- QFETCH(int, highlightRangeMode);
- QFETCH(QPoint, flickStart);
- QFETCH(QPoint, flickEnd);
- QFETCH(qreal, snapAlignment);
- QFETCH(qreal, endExtent);
- QFETCH(qreal, startExtent);
-
-#ifdef Q_OS_MAC
- // This test seems to be unreliable - different test data fails on different runs
- QSKIP("QTBUG-24338");
-#endif
-
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("snapOneItem.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
-
- listview->setOrientation(orientation);
- listview->setLayoutDirection(layoutDirection);
- listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- QQuickItem *contentItem = listview->contentItem();
- QTRY_VERIFY(contentItem != 0);
-
- QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged()));
-
- // confirm that a flick hits the next item boundary
- flick(canvas, flickStart, flickEnd, 180);
- QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
- if (orientation == QQuickListView::Vertical)
- QCOMPARE(listview->contentY(), snapAlignment);
- else
- QCOMPARE(listview->contentX(), snapAlignment);
-
- if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
- QCOMPARE(listview->currentIndex(), 1);
- QCOMPARE(currentIndexSpy.count(), 1);
- }
-
- // flick to end
- do {
- flick(canvas, flickStart, flickEnd, 180);
- QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
- } while (orientation == QQuickListView::Vertical
- ? !listview->isAtYEnd()
- : layoutDirection == Qt::LeftToRight ? !listview->isAtXEnd() : !listview->isAtXBeginning());
-
- if (orientation == QQuickListView::Vertical)
- QCOMPARE(listview->contentY(), endExtent);
- else
- QCOMPARE(listview->contentX(), endExtent);
-
- if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
- QCOMPARE(listview->currentIndex(), 3);
- QCOMPARE(currentIndexSpy.count(), 3);
- }
-
- // flick to start
- do {
- flick(canvas, flickEnd, flickStart, 180);
- QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
- } while (orientation == QQuickListView::Vertical
- ? !listview->isAtYBeginning()
- : layoutDirection == Qt::LeftToRight ? !listview->isAtXBeginning() : !listview->isAtXEnd());
-
- if (orientation == QQuickListView::Vertical)
- QCOMPARE(listview->contentY(), startExtent);
- else
- QCOMPARE(listview->contentX(), startExtent);
-
- if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
- QCOMPARE(listview->currentIndex(), 0);
- QCOMPARE(currentIndexSpy.count(), 6);
- }
-
- delete canvas;
-}
-
-void tst_QQuickListView::unrequestedVisibility()
-{
- QmlListModel model;
- for (int i = 0; i < 30; i++)
- model.addItem("Item" + QString::number(i), QString::number(i));
-
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testWrap", QVariant(false));
-
- canvas->setSource(testFileUrl("unrequestedItems.qml"));
- canvas->show();
- qApp->processEvents();
-
- QQuickListView *leftview = findItem<QQuickListView>(canvas->rootObject(), "leftList");
- QTRY_VERIFY(leftview != 0);
-
- QQuickListView *rightview = findItem<QQuickListView>(canvas->rootObject(), "rightList");
- QTRY_VERIFY(rightview != 0);
-
- QQuickItem *leftContent = leftview->contentItem();
- QTRY_VERIFY(leftContent != 0);
-
- QQuickItem *rightContent = rightview->contentItem();
- QTRY_VERIFY(rightContent != 0);
-
- rightview->setCurrentIndex(20);
-
- QTRY_COMPARE(leftview->contentY(), 0.0);
- QTRY_COMPARE(rightview->contentY(), 100.0);
-
- QQuickItem *item;
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19));
- QCOMPARE(item->isVisible(), true);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 16));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 17));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 4));
- QCOMPARE(item->isVisible(), true);
-
- rightview->setCurrentIndex(0);
-
- QTRY_COMPARE(leftview->contentY(), 0.0);
- QTRY_COMPARE(rightview->contentY(), 0.0);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
- QTRY_COMPARE(item->isVisible(), true);
-
- QVERIFY(!findItem<QQuickItem>(leftContent, "wrapper", 19));
- QVERIFY(!findItem<QQuickItem>(rightContent, "wrapper", 19));
-
- leftview->setCurrentIndex(20);
-
- QTRY_COMPARE(leftview->contentY(), 100.0);
- QTRY_COMPARE(rightview->contentY(), 0.0);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QTRY_COMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), true);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19));
- QCOMPARE(item->isVisible(), false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
- QCOMPARE(item->isVisible(), false);
-
- model.moveItems(19, 1, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QTRY_VERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
- QCOMPARE(item->isVisible(), true);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19));
- QCOMPARE(item->isVisible(), false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
- QCOMPARE(item->isVisible(), false);
-
- model.moveItems(3, 4, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
- QCOMPARE(item->isVisible(), false);
-
- model.moveItems(4, 3, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
- QCOMPARE(item->isVisible(), false);
-
- model.moveItems(16, 17, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
- QCOMPARE(item->isVisible(), false);
-
- model.moveItems(17, 16, 1);
- QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
-
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
- QCOMPARE(item->isVisible(), false);
- QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
- QCOMPARE(item->isVisible(), true);
- QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
- QCOMPARE(item->isVisible(), false);
-
- delete canvas;
-}
-
-void tst_QQuickListView::populateTransitions()
-{
- QFETCH(bool, staticallyPopulate);
- QFETCH(bool, dynamicallyPopulate);
- QFETCH(bool, usePopulateTransition);
-
- QPointF transitionFrom(-50, -50);
- QPointF transitionVia(100, 100);
- QaimModel model_transitionFrom;
- QaimModel model_transitionVia;
-
- QaimModel model;
- if (staticallyPopulate) {
- for (int i = 0; i < 30; i++)
- model.addItem("item" + QString::number(i), "");
- }
-
- QQuickView *canvas = createView();
- canvas->rootContext()->setContextProperty("testModel", &model);
- canvas->rootContext()->setContextProperty("testObject", new TestObject(canvas->rootContext()));
- canvas->rootContext()->setContextProperty("usePopulateTransition", usePopulateTransition);
- canvas->rootContext()->setContextProperty("dynamicallyPopulate", dynamicallyPopulate);
- canvas->rootContext()->setContextProperty("transitionFrom", transitionFrom);
- canvas->rootContext()->setContextProperty("transitionVia", transitionVia);
- canvas->rootContext()->setContextProperty("model_transitionFrom", &model_transitionFrom);
- canvas->rootContext()->setContextProperty("model_transitionVia", &model_transitionVia);
- canvas->setSource(testFileUrl("populateTransitions.qml"));
- canvas->show();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QVERIFY(listview);
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem);
-
- if (staticallyPopulate || dynamicallyPopulate) {
- // check the populate transition is run
- if (usePopulateTransition) {
- QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), 17);
- } else {
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), 0);
- }
- QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0);
- } else {
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- }
-
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- if (usePopulateTransition)
- QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt());
- for (int i=0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->x(), 0.0);
- QTRY_COMPARE(item->y(), i*20.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- // add an item and check this is done with add trantion, not populate
- model.insertItem(0, "another item", "");
- QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 1);
- QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(),
- (usePopulateTransition && (staticallyPopulate || dynamicallyPopulate)) ? 17 : 0);
-
- // clear the model
- canvas->rootContext()->setContextProperty("testModel", QVariant());
- QTRY_COMPARE(listview->count(), 0);
- QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 0);
- listview->setProperty("countPopulateTransitions", 0);
- listview->setProperty("countAddTransitions", 0);
-
- // set to a valid model and check populate transition is run a second time
- model.clear();
- for (int i = 0; i < 30; i++)
- model.addItem("item" + QString::number(i), "");
- canvas->rootContext()->setContextProperty("testModel", &model);
- QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 17 : 0);
- QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0);
-
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- if (usePopulateTransition)
- QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt());
- for (int i=0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->x(), 0.0);
- QTRY_COMPARE(item->y(), i*20.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- // reset model and check populate transition is run again
- listview->setProperty("countPopulateTransitions", 0);
- listview->setProperty("countAddTransitions", 0);
- model.reset();
- QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 17 : 0);
- QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0);
-
- itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- if (usePopulateTransition)
- QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt());
- for (int i=0; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->x(), 0.0);
- QTRY_COMPARE(item->y(), i*20.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickListView::populateTransitions_data()
-{
- QTest::addColumn<bool>("staticallyPopulate");
- QTest::addColumn<bool>("dynamicallyPopulate");
- QTest::addColumn<bool>("usePopulateTransition");
-
- QTest::newRow("static") << true << false << true;
- QTest::newRow("static, no populate") << true << false << false;
-
- QTest::newRow("dynamic") << false << true << true;
- QTest::newRow("dynamic, no populate") << false << true << false;
-
- QTest::newRow("empty to start with") << false << false << true;
- QTest::newRow("empty to start with, no populate") << false << false << false;
-}
-
-void tst_QQuickListView::addTransitions()
-{
- QFETCH(int, initialItemCount);
- QFETCH(bool, shouldAnimateTargets);
- QFETCH(qreal, contentY);
- QFETCH(int, insertionIndex);
- QFETCH(int, insertionCount);
- QFETCH(ListRange, expectedDisplacedIndexes);
-
- // added items should start here
- QPointF targetItems_transitionFrom(-50, -50);
-
- // displaced items should pass through this point
- QPointF displacedItems_transitionVia(100, 100);
-
- QaimModel model;
- for (int i = 0; i < initialItemCount; i++)
- model.addItem("Original item" + QString::number(i), "");
- QaimModel model_targetItems_transitionFrom;
- QaimModel model_displacedItems_transitionVia;
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
- ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
- ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
- ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(testFileUrl("addTransitions.qml"));
- canvas->show();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- if (contentY != 0) {
- listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- }
-
- QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
-
- // only target items that will become visible should be animated
- QList<QPair<QString, QString> > newData;
- QList<QPair<QString, QString> > expectedTargetData;
- QList<int> targetIndexes;
- if (shouldAnimateTargets) {
- for (int i=insertionIndex; i<insertionIndex+insertionCount; i++) {
- newData << qMakePair(QString("New item %1").arg(i), QString(""));
-
- if (i >= contentY / 20 && i < (contentY + listview->height()) / 20) { // only grab visible items
- expectedTargetData << newData.last();
- targetIndexes << i;
- }
- }
- QVERIFY(expectedTargetData.count() > 0);
- }
-
- // start animation
- if (!newData.isEmpty()) {
- model.insertItems(insertionIndex, newData);
- QTRY_COMPARE(model.count(), listview->count());
- }
-
- QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
-
- if (shouldAnimateTargets) {
- QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
- QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(),
- expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
-
- // check the target and displaced items were animated
- model_targetItems_transitionFrom.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
- model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
-
- // check attached properties
- matchItemsAndIndexes(listview->property("targetTrans_items").toMap(), model, targetIndexes);
- matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems);
- if (expectedDisplacedIndexes.isValid()) {
- // adjust expectedDisplacedIndexes to their final values after the move
- QList<int> displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount);
- matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes);
- matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems);
- }
-
- } else {
- QTRY_COMPARE(model_targetItems_transitionFrom.count(), 0);
- QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0);
- }
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- int itemCount = items.count();
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // verify all items moved to the correct final positions
- for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->y(), i*20.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::addTransitions_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<bool>("shouldAnimateTargets");
- QTest::addColumn<int>("insertionIndex");
- QTest::addColumn<int>("insertionCount");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- // if inserting before visible index, items should not appear or animate in, even if there are > 1 new items
- QTest::newRow("insert 1, just before start")
- << 30 << 20.0 << false
- << 0 << 1 << ListRange();
- QTest::newRow("insert 1, way before start")
- << 30 << 20.0 << false
- << 0 << 1 << ListRange();
- QTest::newRow("insert multiple, just before start")
- << 30 << 100.0 << false
- << 0 << 3 << ListRange();
- QTest::newRow("insert multiple, way before start")
- << 30 << 100.0 << false
- << 0 << 3 << ListRange();
-
- QTest::newRow("insert 1 at start")
- << 30 << 0.0 << true
- << 0 << 1 << ListRange(0, 15);
- QTest::newRow("insert multiple at start")
- << 30 << 0.0 << true
- << 0 << 3 << ListRange(0, 15);
- QTest::newRow("insert 1 at start, content y not 0")
- << 30 << 40.0 << true // first visible is index 2, so translate the displaced indexes by 2
- << 2 << 1 << ListRange(0 + 2, 15 + 2);
- QTest::newRow("insert multiple at start, content y not 0")
- << 30 << 40.0 << true // first visible is index 2
- << 2 << 3 << ListRange(0 + 2, 15 + 2);
-
- QTest::newRow("insert 1 at start, to empty list")
- << 0 << 0.0 << true
- << 0 << 1 << ListRange();
- QTest::newRow("insert multiple at start, to empty list")
- << 0 << 0.0 << true
- << 0 << 3 << ListRange();
-
- QTest::newRow("insert 1 at middle")
- << 30 << 0.0 << true
- << 5 << 1 << ListRange(5, 15);
- QTest::newRow("insert multiple at middle")
- << 30 << 0.0 << true
- << 5 << 3 << ListRange(5, 15);
-
- QTest::newRow("insert 1 at bottom")
- << 30 << 0.0 << true
- << 15 << 1 << ListRange(15, 15);
- QTest::newRow("insert multiple at bottom")
- << 30 << 0.0 << true
- << 15 << 3 << ListRange(15, 15);
- QTest::newRow("insert 1 at bottom, content y not 0")
- << 30 << 20.0 * 3 << true
- << 15 + 3 << 1 << ListRange(15 + 3, 15 + 3);
- QTest::newRow("insert multiple at bottom, content y not 0")
- << 30 << 20.0 * 3 << true
- << 15 + 3 << 3 << ListRange(15 + 3, 15 + 3);
-
- // items added after the last visible will not be animated in, since they
- // do not appear in the final view
- QTest::newRow("insert 1 after end")
- << 30 << 0.0 << false
- << 17 << 1 << ListRange();
- QTest::newRow("insert multiple after end")
- << 30 << 0.0 << false
- << 17 << 3 << ListRange();
-}
-
-void tst_QQuickListView::moveTransitions()
-{
- QFETCH(int, initialItemCount);
- QFETCH(qreal, contentY);
- QFETCH(qreal, itemsOffsetAfterMove);
- QFETCH(int, moveFrom);
- QFETCH(int, moveTo);
- QFETCH(int, moveCount);
- QFETCH(ListRange, expectedDisplacedIndexes);
-
- // target and displaced items should pass through these points
- QPointF targetItems_transitionVia(-50, 50);
- QPointF displacedItems_transitionVia(100, 100);
-
- QaimModel model;
- for (int i = 0; i < initialItemCount; i++)
- model.addItem("Original item" + QString::number(i), "");
- QaimModel model_targetItems_transitionVia;
- QaimModel model_displacedItems_transitionVia;
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("model_targetItems_transitionVia", &model_targetItems_transitionVia);
- ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
- ctxt->setContextProperty("targetItems_transitionVia", targetItems_transitionVia);
- ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(testFileUrl("moveTransitions.qml"));
- canvas->show();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
- QQuickText *name;
-
- if (contentY != 0) {
- listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- }
-
- QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
-
- // Items moving to *or* from visible positions should be animated.
- // Otherwise, they should not be animated.
- QList<QPair<QString, QString> > expectedTargetData;
- QList<int> targetIndexes;
- for (int i=moveFrom; i<moveFrom+moveCount; i++) {
- int toIndex = moveTo + (i - moveFrom);
- if (i <= (contentY + listview->height()) / 20
- || toIndex < (contentY + listview->height()) / 20) {
- expectedTargetData << qMakePair(model.name(i), model.number(i));
- targetIndexes << i;
- }
- }
- // ViewTransition.index provides the indices that items are moving to, not from
- targetIndexes = adjustIndexesForMove(targetIndexes, moveFrom, moveTo, moveCount);
-
- // start animation
- model.moveItems(moveFrom, moveTo, moveCount);
-
- QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
- QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(),
- expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
-
- QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
-
- // check the target and displaced items were animated
- model_targetItems_transitionVia.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
- model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
-
- // check attached properties
- matchItemsAndIndexes(listview->property("targetTrans_items").toMap(), model, targetIndexes);
- matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems);
- if (expectedDisplacedIndexes.isValid()) {
- // adjust expectedDisplacedIndexes to their final values after the move
- QList<int> displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, moveFrom, moveTo, moveCount);
- matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes);
- matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems);
- }
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // verify all items moved to the correct final positions
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
- name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::moveTransitions_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<qreal>("itemsOffsetAfterMove");
- QTest::addColumn<int>("moveFrom");
- QTest::addColumn<int>("moveTo");
- QTest::addColumn<int>("moveCount");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- // when removing from above the visible, all items shift down depending on how many
- // items have been removed from above the visible
- QTest::newRow("move from above view, outside visible items, move 1") << 30 << 4*20.0 << 20.0
- << 1 << 10 << 1 << ListRange(11, 15+4);
- QTest::newRow("move from above view, outside visible items, move 1 (first item)") << 30 << 4*20.0 << 20.0
- << 0 << 10 << 1 << ListRange(11, 15+4);
- QTest::newRow("move from above view, outside visible items, move multiple") << 30 << 4*20.0 << 2*20.0
- << 1 << 10 << 2 << ListRange(12, 15+4);
- QTest::newRow("move from above view, outside visible items, move multiple (first item)") << 30 << 4*20.0 << 3*20.0
- << 0 << 10 << 3 << ListRange(13, 15+4);
- QTest::newRow("move from above view, mix of visible/non-visible") << 30 << 4*20.0 << 3*20.0
- << 1 << 10 << 5 << ListRange(6, 14) + ListRange(15, 15+4);
- QTest::newRow("move from above view, mix of visible/non-visible (move first)") << 30 << 4*20.0 << 4*20.0
- << 0 << 10 << 5 << ListRange(5, 14) + ListRange(15, 15+4);
-
- QTest::newRow("move within view, move 1 down") << 30 << 0.0 << 0.0
- << 1 << 10 << 1 << ListRange(2, 10);
- QTest::newRow("move within view, move 1 down, move first item") << 30 << 0.0 << 0.0
- << 0 << 10 << 1 << ListRange(1, 10);
- QTest::newRow("move within view, move 1 down, move first item, contentY not 0") << 30 << 4*20.0 << 0.0
- << 0+4 << 10+4 << 1 << ListRange(1+4, 10+4);
- QTest::newRow("move within view, move 1 down, to last item") << 30 << 0.0 << 0.0
- << 10 << 15 << 1 << ListRange(11, 15);
- QTest::newRow("move within view, move first->last") << 30 << 0.0 << 0.0
- << 0 << 15 << 1 << ListRange(1, 15);
-
- QTest::newRow("move within view, move multiple down") << 30 << 0.0 << 0.0
- << 1 << 10 << 3 << ListRange(4, 12);
- QTest::newRow("move within view, move multiple down, move first item") << 30 << 0.0 << 0.0
- << 0 << 10 << 3 << ListRange(3, 12);
- QTest::newRow("move within view, move multiple down, move first item, contentY not 0") << 30 << 4*20.0 << 0.0
- << 0+4 << 10+4 << 3 << ListRange(3+4, 12+4);
- QTest::newRow("move within view, move multiple down, displace last item") << 30 << 0.0 << 0.0
- << 5 << 13 << 3 << ListRange(8, 15);
- QTest::newRow("move within view, move multiple down, move first->last") << 30 << 0.0 << 0.0
- << 0 << 13 << 3 << ListRange(3, 15);
-
- QTest::newRow("move within view, move 1 up") << 30 << 0.0 << 0.0
- << 10 << 1 << 1 << ListRange(1, 9);
- QTest::newRow("move within view, move 1 up, move to first index") << 30 << 0.0 << 0.0
- << 10 << 0 << 1 << ListRange(0, 9);
- QTest::newRow("move within view, move 1 up, move to first index, contentY not 0") << 30 << 4*20.0 << 0.0
- << 10+4 << 0+4 << 1 << ListRange(0+4, 9+4);
- QTest::newRow("move within view, move 1 up, move to first index, contentY not on item border") << 30 << 4*20.0 - 10 << 0.0
- << 10+4 << 0+4 << 1 << ListRange(0+4, 9+4);
- QTest::newRow("move within view, move 1 up, move last item") << 30 << 0.0 << 0.0
- << 15 << 10 << 1 << ListRange(10, 14);
- QTest::newRow("move within view, move 1 up, move last->first") << 30 << 0.0 << 0.0
- << 15 << 0 << 1 << ListRange(0, 14);
-
- QTest::newRow("move within view, move multiple up") << 30 << 0.0 << 0.0
- << 10 << 1 << 3 << ListRange(1, 9);
- QTest::newRow("move within view, move multiple up, move to first index") << 30 << 0.0 << 0.0
- << 10 << 0 << 3 << ListRange(0, 9);
- QTest::newRow("move within view, move multiple up, move to first index, contentY not 0") << 30 << 4*20.0 << 0.0
- << 10+4 << 0+4 << 3 << ListRange(0+4, 9+4);
- QTest::newRow("move within view, move multiple up, move last item") << 30 << 0.0 << 0.0
- << 13 << 5 << 3 << ListRange(5, 12);
- QTest::newRow("move within view, move multiple up, move last->first") << 30 << 0.0 << 0.0
- << 13 << 0 << 3 << ListRange(0, 12);
-
- QTest::newRow("move from below view, move 1 up, move to top") << 30 << 0.0 << 0.0
- << 20 << 0 << 1 << ListRange(0, 15);
- QTest::newRow("move from below view, move 1 up, move to top, contentY not 0") << 30 << 4*20.0 << 0.0
- << 25 << 4 << 1 << ListRange(0+4, 15+4);
- QTest::newRow("move from below view, move multiple up, move to top") << 30 << 0.0 << 0.0
- << 20 << 0 << 3 << ListRange(0, 15);
- QTest::newRow("move from below view, move multiple up, move to top, contentY not 0") << 30 << 4*20.0 << 0.0
- << 25 << 4 << 3 << ListRange(0+4, 15+4);
-
- QTest::newRow("move from below view, move 1 up, move to bottom") << 30 << 0.0 << 0.0
- << 20 << 15 << 1 << ListRange(15, 15);
- QTest::newRow("move from below view, move 1 up, move to bottom, contentY not 0") << 30 << 4*20.0 << 0.0
- << 25 << 15+4 << 1 << ListRange(15+4, 15+4);
- QTest::newRow("move from below view, move multiple up, move to to bottom") << 30 << 0.0 << 0.0
- << 20 << 15 << 3 << ListRange(15, 15);
- QTest::newRow("move from below view, move multiple up, move to bottom, contentY not 0") << 30 << 4*20.0 << 0.0
- << 25 << 15+4 << 3 << ListRange(15+4, 15+4);
-}
-
-void tst_QQuickListView::removeTransitions()
-{
- QFETCH(int, initialItemCount);
- QFETCH(bool, shouldAnimateTargets);
- QFETCH(qreal, contentY);
- QFETCH(int, removalIndex);
- QFETCH(int, removalCount);
- QFETCH(ListRange, expectedDisplacedIndexes);
-
- // added items should end here
- QPointF targetItems_transitionTo(-50, -50);
-
- // displaced items should pass through this points
- QPointF displacedItems_transitionVia(100, 100);
-
- QaimModel model;
- for (int i = 0; i < initialItemCount; i++)
- model.addItem("Original item" + QString::number(i), "");
- QaimModel model_targetItems_transitionTo;
- QaimModel model_displacedItems_transitionVia;
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("model_targetItems_transitionTo", &model_targetItems_transitionTo);
- ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
- ctxt->setContextProperty("targetItems_transitionTo", targetItems_transitionTo);
- ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
- ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(testFileUrl("removeTransitions.qml"));
- canvas->show();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- if (contentY != 0) {
- listview->setContentY(contentY);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- }
-
- QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
-
- // only target items that are visible should be animated
- QList<QPair<QString, QString> > expectedTargetData;
- QList<int> targetIndexes;
- if (shouldAnimateTargets) {
- for (int i=removalIndex; i<removalIndex+removalCount; i++) {
- if (i >= contentY / 20 && i < (contentY + listview->height()) / 20) {
- expectedTargetData << qMakePair(model.name(i), model.number(i));
- targetIndexes << i;
- }
- }
- QVERIFY(expectedTargetData.count() > 0);
- }
-
- // calculate targetItems and expectedTargets before model changes
- QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
- QVariantMap expectedTargets;
- for (int i=0; i<targetIndexes.count(); i++)
- expectedTargets[model.name(targetIndexes[i])] = targetIndexes[i];
-
- // start animation
- model.removeItems(removalIndex, removalCount);
- QTRY_COMPARE(model.count(), listview->count());
-
- if (shouldAnimateTargets) {
- QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
- QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(),
- expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
-
- // check the target and displaced items were animated
- model_targetItems_transitionTo.matchAgainst(expectedTargetData, "wasn't animated to target 'to' pos", "shouldn't have been animated to target 'to' pos");
- model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
-
- // check attached properties
- QCOMPARE(listview->property("targetTrans_items").toMap(), expectedTargets);
- matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems);
- if (expectedDisplacedIndexes.isValid()) {
- // adjust expectedDisplacedIndexes to their final values after the move
- QList<int> displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, removalIndex, removalCount);
- matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes);
- matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
- matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems);
- }
- } else {
- QTRY_COMPARE(model_targetItems_transitionTo.count(), 0);
- QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0);
- }
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- int itemCount = items.count();
-
- for (int i=0; i<items.count(); i++) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- int index = e.evaluate().toInt();
- if (firstVisibleIndex < 0 && items[i]->y() >= contentY)
- firstVisibleIndex = index;
- if (index < 0)
- itemCount--; // exclude deleted items
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // verify all items moved to the correct final positions
- for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QCOMPARE(item->x(), 0.0);
- QCOMPARE(item->y(), contentY + (i-firstVisibleIndex) * 20.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::removeTransitions_data()
-{
- QTest::addColumn<int>("initialItemCount");
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<bool>("shouldAnimateTargets");
- QTest::addColumn<int>("removalIndex");
- QTest::addColumn<int>("removalCount");
- QTest::addColumn<ListRange>("expectedDisplacedIndexes");
-
- // All items that are visible following the remove operation should be animated.
- // Remove targets that are outside of the view should not be animated.
-
- QTest::newRow("remove 1 before start")
- << 30 << 20.0 * 3 << false
- << 2 << 1 << ListRange();
- QTest::newRow("remove multiple, all before start")
- << 30 << 20.0 * 3 << false
- << 0 << 3 << ListRange();
- QTest::newRow("remove mix of before and after start")
- << 30 << 20.0 * 3 << true
- << 2 << 3 << ListRange(5, 20); // 5-20 are visible after the remove
-
- QTest::newRow("remove 1 from start")
- << 30 << 0.0 << true
- << 0 << 1 << ListRange(1, 16); // 1-16 are visible after the remove
- QTest::newRow("remove multiple from start")
- << 30 << 0.0 << true
- << 0 << 3 << ListRange(3, 18); // 3-18 are visible after the remove
- QTest::newRow("remove 1 from start, content y not 0")
- << 30 << 20.0 * 2 << true // first visible is index 2, so translate the displaced indexes by 2
- << 2 << 1 << ListRange(1 + 2, 16 + 2);
- QTest::newRow("remove multiple from start, content y not 0")
- << 30 << 20.0 * 2 << true // first visible is index 2
- << 2 << 3 << ListRange(3 + 2, 18 + 2);
-
- QTest::newRow("remove 1 from middle")
- << 30 << 0.0 << true
- << 5 << 1 << ListRange(6, 16);
- QTest::newRow("remove multiple from middle")
- << 30 << 0.0 << true
- << 5 << 3 << ListRange(8, 18);
-
-
- QTest::newRow("remove 1 from bottom")
- << 30 << 0.0 << true
- << 15 << 1 << ListRange(16, 16);
-
- // remove 15, 16, 17
- // 15 will animate as the target item, 16 & 17 won't be animated since they are outside
- // the view, and 18 will be animated as the displaced item to replace the last item
- QTest::newRow("remove multiple from bottom")
- << 30 << 0.0 << true
- << 15 << 3 << ListRange(18, 18);
-
- QTest::newRow("remove 1 from bottom, content y not 0")
- << 30 << 20.0 * 2 << true
- << 15 + 2 << 1 << ListRange(16 + 2, 16 + 2);
- QTest::newRow("remove multiple from bottom, content y not 0")
- << 30 << 20.0 * 2 << true
- << 15 + 2 << 3 << ListRange(18 + 2, 18 + 2);
-
-
- QTest::newRow("remove 1 after end")
- << 30 << 0.0 << false
- << 17 << 1 << ListRange();
- QTest::newRow("remove multiple after end")
- << 30 << 0.0 << false
- << 17 << 3 << ListRange();
-}
-
-void tst_QQuickListView::multipleTransitions()
-{
- // Tests that if you interrupt a transition in progress with another action that
- // cancels the previous transition, the resulting items are still placed correctly.
-
- QFETCH(int, initialCount);
- QFETCH(qreal, contentY);
- QFETCH(QList<ListChange>, changes);
-
- // add transitions on the left, moves on the right
- QPointF addTargets_transitionFrom(-50, -50);
- QPointF addDisplaced_transitionFrom(-50, 50);
- QPointF moveTargets_transitionFrom(50, -50);
- QPointF moveDisplaced_transitionFrom(50, 50);
-
- QmlListModel model;
- for (int i = 0; i < initialCount; i++)
- model.addItem("Original item" + QString::number(i), "");
-
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testModel", &model);
- ctxt->setContextProperty("testObject", testObject);
- ctxt->setContextProperty("addTargets_transitionFrom", addTargets_transitionFrom);
- ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom);
- ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom);
- ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom);
- canvas->setSource(testFileUrl("multipleTransitions.qml"));
- canvas->show();
-
- QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
- QTRY_VERIFY(listview != 0);
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
-
- int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt();
-
- QList<QPair<QString, QString> > targetItems;
- for (int i=0; i<changes.count(); i++) {
- switch (changes[i].type) {
- case ListChange::Inserted:
- {
- for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
- targetItems << qMakePair(QString("new item %1").arg(j), QString::number(j));
- model.insertItems(changes[i].index, targetItems);
- QTRY_COMPARE(model.count(), listview->count());
- QTRY_VERIFY(listview->property("runningAddTargets").toBool());
- QTRY_VERIFY(listview->property("runningAddDisplaced").toBool());
- if (i == changes.count() - 1) {
- QTRY_VERIFY(!listview->property("runningAddTargets").toBool());
- QTRY_VERIFY(!listview->property("runningAddDisplaced").toBool());
- } else {
- QTest::qWait(timeBetweenActions);
- }
- break;
- }
- case ListChange::Removed:
- for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
- targetItems << qMakePair(model.name(i), model.number(i));
- model.removeItems(changes[i].index, changes[i].count);
- QTRY_COMPARE(model.count(), listview->count());
- QTRY_VERIFY(listview->property("runningRemoveTargets").toBool());
- QTRY_VERIFY(listview->property("runningRemoveDisplaced").toBool());
- if (i == changes.count() - 1) {
- QTRY_VERIFY(!listview->property("runningRemoveTargets").toBool());
- QTRY_VERIFY(!listview->property("runningRemoveDisplaced").toBool());
- } else {
- QTest::qWait(timeBetweenActions);
- }
- break;
- case ListChange::Moved:
- for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
- targetItems << qMakePair(model.name(i), model.number(i));
- model.moveItems(changes[i].index, changes[i].to, changes[i].count);
- QTRY_VERIFY(listview->property("runningMoveTargets").toBool());
- QTRY_VERIFY(listview->property("runningMoveDisplaced").toBool());
- if (i == changes.count() - 1) {
- QTRY_VERIFY(!listview->property("runningMoveTargets").toBool());
- QTRY_VERIFY(!listview->property("runningMoveDisplaced").toBool());
- } else {
- QTest::qWait(timeBetweenActions);
- }
- break;
- case ListChange::SetCurrent:
- listview->setCurrentIndex(changes[i].index);
- break;
- case ListChange::SetContentY:
- listview->setContentY(changes[i].pos);
- QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
- break;
- }
- }
- QCOMPARE(listview->count(), model.count());
-
- QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
- int firstVisibleIndex = -1;
- for (int i=0; i<items.count(); i++) {
- if (items[i]->y() >= contentY) {
- QDeclarativeExpression e(qmlContext(items[i]), items[i], "index");
- firstVisibleIndex = e.evaluate().toInt();
- break;
- }
- }
- QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
-
- // verify all items moved to the correct final positions
- int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
- for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
- QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
- QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
- QTRY_COMPARE(item->x(), 0.0);
- QTRY_COMPARE(item->y(), i*20.0);
- QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
- QVERIFY(name != 0);
- QTRY_COMPARE(name->text(), model.name(i));
- }
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickListView::multipleTransitions_data()
-{
- QTest::addColumn<int>("initialCount");
- QTest::addColumn<qreal>("contentY");
- QTest::addColumn<QList<ListChange> >("changes");
-
- // the added item and displaced items should move to final dest correctly
- QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList<ListChange>()
- << ListChange::insert(0, 1)
- << ListChange::move(0, 3, 1)
- );
-
- // items affected by the add should change from move to add transition
- QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList<ListChange>()
- << ListChange::move(1, 10, 3)
- << ListChange::insert(0, 1)
- );
-
- // items should be placed correctly if you trigger a transition then refill for that index
- QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList<ListChange>()
- << ListChange::insert(0, 1)
- << ListChange::setContentY(80.0)
- << ListChange::setContentY(0.0)
- << ListChange::insert(0, 1)
- );
-}
-
-QList<int> tst_QQuickListView::toIntList(const QVariantList &list)
-{
- QList<int> ret;
- bool ok = true;
- for (int i=0; i<list.count(); i++) {
- ret << list[i].toInt(&ok);
- if (!ok)
- qWarning() << "tst_QQuickListView::toIntList(): not a number:" << list[i];
- }
-
- return ret;
-}
-
-void tst_QQuickListView::matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes)
-{
- for (int i=0; i<indexLists.count(); i++) {
- QSet<int> current = indexLists[i].value<QList<int> >().toSet();
- if (current != expectedIndexes.toSet())
- qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes;
- QCOMPARE(current, expectedIndexes.toSet());
- }
-}
-
-void tst_QQuickListView::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes)
-{
- for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) {
- QVERIFY(it.value().type() == QVariant::Int);
- QString name = it.key();
- int itemIndex = it.value().toInt();
- QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex)));
- if (model.name(itemIndex) != name)
- qDebug() << itemIndex;
- QCOMPARE(model.name(itemIndex), name);
- }
- QCOMPARE(items.count(), expectedIndexes.count());
-}
-
-void tst_QQuickListView::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems)
-{
- for (int i=0; i<itemLists.count(); i++) {
- QVERIFY(itemLists[i].type() == QVariant::List);
- QVariantList current = itemLists[i].toList();
- for (int j=0; j<current.count(); j++) {
- QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
- QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j)));
- QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j)));
- }
- QCOMPARE(current.count(), expectedItems.count());
- }
-}
-
-
-QTEST_MAIN(tst_QQuickListView)
-
-#include "tst_qquicklistview.moc"
-
diff --git a/tests/auto/qtquick2/qquickloader/qquickloader.pro b/tests/auto/qtquick2/qquickloader/qquickloader.pro
deleted file mode 100644
index 33c8c207af..0000000000
--- a/tests/auto/qtquick2/qquickloader/qquickloader.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickloader
-macx:CONFIG -= app_bundle
-
-INCLUDEPATH += ../../shared/
-HEADERS += ../../shared/testhttpserver.h
-
-SOURCES += tst_qquickloader.cpp \
- ../../shared/testhttpserver.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qquickloader/tst_qquickloader.cpp b/tests/auto/qtquick2/qquickloader/tst_qquickloader.cpp
deleted file mode 100644
index 33148db7b1..0000000000
--- a/tests/auto/qtquick2/qquickloader/tst_qquickloader.cpp
+++ /dev/null
@@ -1,987 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-
-#include <QSignalSpy>
-
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeincubator.h>
-#include <private/qquickloader_p.h>
-#include "testhttpserver.h"
-#include "../../shared/util.h"
-
-#define SERVER_PORT 14450
-
-class PeriodicIncubationController : public QObject,
- public QDeclarativeIncubationController
-{
-public:
- PeriodicIncubationController() {
- startTimer(16);
- }
-
-protected:
- virtual void timerEvent(QTimerEvent *) {
- incubateFor(15);
- }
-};
-
-class tst_QQuickLoader : public QDeclarativeDataTest
-
-{
- Q_OBJECT
-public:
- tst_QQuickLoader();
-
-private slots:
- void sourceOrComponent();
- void sourceOrComponent_data();
- void clear();
- void urlToComponent();
- void componentToUrl();
- void anchoredLoader();
- void sizeLoaderToItem();
- void sizeItemToLoader();
- void noResize();
- void networkRequestUrl();
- void failNetworkRequest();
-// void networkComponent();
- void active();
- void initialPropertyValues_data();
- void initialPropertyValues();
- void initialPropertyValuesBinding();
- void initialPropertyValuesError_data();
- void initialPropertyValuesError();
-
- void deleteComponentCrash();
- void nonItem();
- void vmeErrors();
- void creationContext();
- void QTBUG_16928();
- void implicitSize();
- void QTBUG_17114();
- void asynchronous_data();
- void asynchronous();
- void asynchronous_clear();
-
- void parented();
- void sizeBound();
-
-private:
- QDeclarativeEngine engine;
-};
-
-
-tst_QQuickLoader::tst_QQuickLoader()
-{
-}
-
-void tst_QQuickLoader::sourceOrComponent()
-{
- QFETCH(QString, sourceOrComponent);
- QFETCH(QString, sourceDefinition);
- QFETCH(QUrl, sourceUrl);
- QFETCH(QString, errorString);
-
- bool error = !errorString.isEmpty();
- if (error)
- QTest::ignoreMessage(QtWarningMsg, errorString.toUtf8().constData());
-
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray(
- "import QtQuick 2.0\n"
- "Loader {\n"
- " property int onItemChangedCount: 0\n"
- " property int onSourceChangedCount: 0\n"
- " property int onSourceComponentChangedCount: 0\n"
- " property int onStatusChangedCount: 0\n"
- " property int onProgressChangedCount: 0\n"
- " property int onLoadedCount: 0\n")
- + sourceDefinition.toUtf8()
- + QByteArray(
- " onItemChanged: onItemChangedCount += 1\n"
- " onSourceChanged: onSourceChangedCount += 1\n"
- " onSourceComponentChanged: onSourceComponentChangedCount += 1\n"
- " onStatusChanged: onStatusChangedCount += 1\n"
- " onProgressChanged: onProgressChangedCount += 1\n"
- " onLoaded: onLoadedCount += 1\n"
- "}")
- , dataDirectoryUrl());
-
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QVERIFY(loader != 0);
- QCOMPARE(loader->item() == 0, error);
- QCOMPARE(loader->source(), sourceUrl);
- QCOMPARE(loader->progress(), 1.0);
-
- QCOMPARE(loader->status(), error ? QQuickLoader::Error : QQuickLoader::Ready);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), error ? 0: 1);
-
- if (!error) {
- bool sourceComponentIsChildOfLoader = false;
- for (int ii = 0; ii < loader->children().size(); ++ii) {
- QDeclarativeComponent *c = qobject_cast<QDeclarativeComponent*>(loader->children().at(ii));
- if (c && c == loader->sourceComponent()) {
- sourceComponentIsChildOfLoader = true;
- }
- }
- QVERIFY(sourceComponentIsChildOfLoader);
- }
-
- if (sourceOrComponent == "component") {
- QCOMPARE(loader->property("onSourceComponentChangedCount").toInt(), 1);
- QCOMPARE(loader->property("onSourceChangedCount").toInt(), 0);
- } else {
- QCOMPARE(loader->property("onSourceComponentChangedCount").toInt(), 0);
- QCOMPARE(loader->property("onSourceChangedCount").toInt(), 1);
- }
- QCOMPARE(loader->property("onStatusChangedCount").toInt(), 1);
- QCOMPARE(loader->property("onProgressChangedCount").toInt(), 1);
-
- QCOMPARE(loader->property("onItemChangedCount").toInt(), error ? 0 : 1);
- QCOMPARE(loader->property("onLoadedCount").toInt(), error ? 0 : 1);
-
- delete loader;
-}
-
-void tst_QQuickLoader::sourceOrComponent_data()
-{
- QTest::addColumn<QString>("sourceOrComponent");
- QTest::addColumn<QString>("sourceDefinition");
- QTest::addColumn<QUrl>("sourceUrl");
- QTest::addColumn<QString>("errorString");
-
- QTest::newRow("source") << "source" << "source: 'Rect120x60.qml'\n" << testFileUrl("Rect120x60.qml") << "";
- QTest::newRow("sourceComponent") << "component" << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << "";
- QTest::newRow("invalid source") << "source" << "source: 'IDontExist.qml'\n" << testFileUrl("IDontExist.qml")
- << QString(testFileUrl("IDontExist.qml").toString() + ": File not found");
-}
-
-void tst_QQuickLoader::clear()
-{
- {
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray(
- "import QtQuick 2.0\n"
- " Loader { id: loader\n"
- " source: 'Rect120x60.qml'\n"
- " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n"
- " }")
- , dataDirectoryUrl());
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QVERIFY(loader != 0);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
-
- QTRY_VERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->status(), QQuickLoader::Null);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
-
- delete loader;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
-
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::childItems().at(0));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
-
- loader->setSourceComponent(0);
-
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->status(), QQuickLoader::Null);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
-
- delete item;
- }
- {
- QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
-
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::childItems().at(0));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
-
- QMetaObject::invokeMethod(item, "clear");
-
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->status(), QQuickLoader::Null);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
-
- delete item;
- }
-}
-
-void tst_QQuickLoader::urlToComponent()
-{
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\n"
- "Loader {\n"
- " id: loader\n"
- " Component { id: myComp; Rectangle { width: 10; height: 10 } }\n"
- " source: \"Rect120x60.qml\"\n"
- " Timer { interval: 100; running: true; onTriggered: loader.sourceComponent = myComp }\n"
- "}" )
- , dataDirectoryUrl());
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QTest::qWait(200);
- QTRY_VERIFY(loader != 0);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
- QCOMPARE(loader->width(), 10.0);
- QCOMPARE(loader->height(), 10.0);
-
- delete loader;
-}
-
-void tst_QQuickLoader::componentToUrl()
-{
- QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
-
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::childItems().at(0));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
-
- loader->setSource(testFileUrl("/Rect120x60.qml"));
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
- QCOMPARE(loader->width(), 120.0);
- QCOMPARE(loader->height(), 60.0);
-
- delete item;
-}
-
-void tst_QQuickLoader::anchoredLoader()
-{
- QDeclarativeComponent component(&engine, testFileUrl("/AnchoredLoader.qml"));
- QQuickItem *rootItem = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(rootItem != 0);
- QQuickItem *loader = rootItem->findChild<QQuickItem*>("loader");
- QQuickItem *sourceElement = rootItem->findChild<QQuickItem*>("sourceElement");
-
- QVERIFY(loader != 0);
- QVERIFY(sourceElement != 0);
-
- QCOMPARE(rootItem->width(), 300.0);
- QCOMPARE(rootItem->height(), 200.0);
-
- QCOMPARE(loader->width(), 300.0);
- QCOMPARE(loader->height(), 200.0);
-
- QCOMPARE(sourceElement->width(), 300.0);
- QCOMPARE(sourceElement->height(), 200.0);
-}
-
-void tst_QQuickLoader::sizeLoaderToItem()
-{
- QDeclarativeComponent component(&engine, testFileUrl("/SizeToItem.qml"));
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QVERIFY(loader != 0);
- QCOMPARE(loader->width(), 120.0);
- QCOMPARE(loader->height(), 60.0);
-
- // Check resize
- QQuickItem *rect = qobject_cast<QQuickItem*>(loader->item());
- QVERIFY(rect);
- rect->setWidth(150);
- rect->setHeight(45);
- QCOMPARE(loader->width(), 150.0);
- QCOMPARE(loader->height(), 45.0);
-
- // Check explicit width
- loader->setWidth(200.0);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(rect->width(), 200.0);
- rect->setWidth(100.0); // when rect changes ...
- QCOMPARE(rect->width(), 100.0); // ... it changes
- QCOMPARE(loader->width(), 200.0); // ... but loader stays the same
-
- // Check explicit height
- loader->setHeight(200.0);
- QCOMPARE(loader->height(), 200.0);
- QCOMPARE(rect->height(), 200.0);
- rect->setHeight(100.0); // when rect changes ...
- QCOMPARE(rect->height(), 100.0); // ... it changes
- QCOMPARE(loader->height(), 200.0); // ... but loader stays the same
-
- // Switch mode
- loader->setWidth(180);
- loader->setHeight(30);
- QCOMPARE(rect->width(), 180.0);
- QCOMPARE(rect->height(), 30.0);
-
- delete loader;
-}
-
-void tst_QQuickLoader::sizeItemToLoader()
-{
- QDeclarativeComponent component(&engine, testFileUrl("/SizeToLoader.qml"));
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QVERIFY(loader != 0);
- QCOMPARE(loader->width(), 200.0);
- QCOMPARE(loader->height(), 80.0);
-
- QQuickItem *rect = qobject_cast<QQuickItem*>(loader->item());
- QVERIFY(rect);
- QCOMPARE(rect->width(), 200.0);
- QCOMPARE(rect->height(), 80.0);
-
- // Check resize
- loader->setWidth(180);
- loader->setHeight(30);
- QCOMPARE(rect->width(), 180.0);
- QCOMPARE(rect->height(), 30.0);
-
- // Switch mode
- loader->resetWidth(); // reset explicit size
- loader->resetHeight();
- rect->setWidth(160);
- rect->setHeight(45);
- QCOMPARE(loader->width(), 160.0);
- QCOMPARE(loader->height(), 45.0);
-
- delete loader;
-}
-
-void tst_QQuickLoader::noResize()
-{
- QDeclarativeComponent component(&engine, testFileUrl("/NoResize.qml"));
- QQuickItem* item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item != 0);
- QCOMPARE(item->width(), 200.0);
- QCOMPARE(item->height(), 80.0);
-
- delete item;
-}
-
-void tst_QQuickLoader::networkRequestUrl()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
-
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), testFileUrl("../dummy.qml"));
- if (component.isError())
- qDebug() << component.errors();
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QVERIFY(loader != 0);
-
- QTRY_VERIFY(loader->status() == QQuickLoader::Ready);
-
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->property("signalCount").toInt(), 1);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
-
- delete loader;
-}
-
-/* XXX Component waits until all dependencies are loaded. Is this actually possible?
-void tst_QQuickLoader::networkComponent()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory("slowdata", TestHTTPServer::Delay);
-
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray(
- "import QtQuick 2.0\n"
- "import \"http://127.0.0.1:14450/\" as NW\n"
- "Item {\n"
- " Component { id: comp; NW.SlowRect {} }\n"
- " Loader { sourceComponent: comp } }")
- , dataDirectoryUrl());
-
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
-
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::children().at(1));
- QVERIFY(loader);
- QTRY_VERIFY(loader->status() == QQuickLoader::Ready);
-
- QVERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QQuickLoader::Ready);
- QCOMPARE(static_cast<QQuickItem*>(loader)->children().count(), 1);
-
- delete loader;
-}
-*/
-
-void tst_QQuickLoader::failNetworkRequest()
-{
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
-
- QTest::ignoreMessage(QtWarningMsg, "http://127.0.0.1:14450/IDontExist.qml: File not found");
-
- QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\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"));
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QVERIFY(loader != 0);
-
- QTRY_VERIFY(loader->status() == QQuickLoader::Error);
-
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->property("did_load").toInt(), 123);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
-
- delete loader;
-}
-
-void tst_QQuickLoader::active()
-{
- // check that the item isn't instantiated until active is set to true
- {
- QDeclarativeComponent component(&engine, testFileUrl("active.1.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
-
- QVERIFY(loader->active() == false); // set manually to false
- QVERIFY(loader->item() == 0);
- QMetaObject::invokeMethod(object, "doSetSourceComponent");
- QVERIFY(loader->item() == 0);
- QMetaObject::invokeMethod(object, "doSetSource");
- QVERIFY(loader->item() == 0);
- QMetaObject::invokeMethod(object, "doSetActive");
- QVERIFY(loader->item() != 0);
-
- delete object;
- }
-
- // check that the status is Null if active is set to false
- {
- QDeclarativeComponent component(&engine, testFileUrl("active.2.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
-
- QVERIFY(loader->active() == true); // active is true by default
- QCOMPARE(loader->status(), QQuickLoader::Ready);
- int currStatusChangedCount = loader->property("statusChangedCount").toInt();
- QMetaObject::invokeMethod(object, "doSetInactive");
- QCOMPARE(loader->status(), QQuickLoader::Null);
- QCOMPARE(loader->property("statusChangedCount").toInt(), (currStatusChangedCount+1));
-
- delete object;
- }
-
- // check that the source is not cleared if active is set to false
- {
- QDeclarativeComponent component(&engine, testFileUrl("active.3.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
-
- QVERIFY(loader->active() == true); // active is true by default
- QVERIFY(!loader->source().isEmpty());
- int currSourceChangedCount = loader->property("sourceChangedCount").toInt();
- QMetaObject::invokeMethod(object, "doSetInactive");
- QVERIFY(!loader->source().isEmpty());
- QCOMPARE(loader->property("sourceChangedCount").toInt(), currSourceChangedCount);
-
- delete object;
- }
-
- // check that the sourceComponent is not cleared if active is set to false
- {
- QDeclarativeComponent component(&engine, testFileUrl("active.4.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
-
- QVERIFY(loader->active() == true); // active is true by default
- QVERIFY(loader->sourceComponent() != 0);
- int currSourceComponentChangedCount = loader->property("sourceComponentChangedCount").toInt();
- QMetaObject::invokeMethod(object, "doSetInactive");
- QVERIFY(loader->sourceComponent() != 0);
- QCOMPARE(loader->property("sourceComponentChangedCount").toInt(), currSourceComponentChangedCount);
-
- delete object;
- }
-
- // check that the item is released if active is set to false
- {
- QDeclarativeComponent component(&engine, testFileUrl("active.5.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
-
- QVERIFY(loader->active() == true); // active is true by default
- QVERIFY(loader->item() != 0);
- int currItemChangedCount = loader->property("itemChangedCount").toInt();
- QMetaObject::invokeMethod(object, "doSetInactive");
- QVERIFY(loader->item() == 0);
- QCOMPARE(loader->property("itemChangedCount").toInt(), (currItemChangedCount+1));
-
- delete object;
- }
-
- // check that the activeChanged signal is emitted correctly
- {
- QDeclarativeComponent component(&engine, testFileUrl("active.6.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
-
- QVERIFY(loader->active() == true); // active is true by default
- loader->setActive(true); // no effect
- QCOMPARE(loader->property("activeChangedCount").toInt(), 0);
- loader->setActive(false); // change signal should be emitted
- QCOMPARE(loader->property("activeChangedCount").toInt(), 1);
- loader->setActive(false); // no effect
- QCOMPARE(loader->property("activeChangedCount").toInt(), 1);
- loader->setActive(true); // change signal should be emitted
- QCOMPARE(loader->property("activeChangedCount").toInt(), 2);
- loader->setActive(false); // change signal should be emitted
- QCOMPARE(loader->property("activeChangedCount").toInt(), 3);
- QMetaObject::invokeMethod(object, "doSetActive");
- QCOMPARE(loader->property("activeChangedCount").toInt(), 4);
- QMetaObject::invokeMethod(object, "doSetActive");
- QCOMPARE(loader->property("activeChangedCount").toInt(), 4);
- QMetaObject::invokeMethod(object, "doSetInactive");
- QCOMPARE(loader->property("activeChangedCount").toInt(), 5);
- loader->setActive(true); // change signal should be emitted
- QCOMPARE(loader->property("activeChangedCount").toInt(), 6);
-
- delete object;
- }
-
- // check that the component isn't loaded until active is set to true
- {
- QDeclarativeComponent component(&engine, testFileUrl("active.7.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("success").toBool(), true);
- delete object;
- }
-
- // check that the component is loaded if active is not set (true by default)
- {
- QDeclarativeComponent component(&engine, testFileUrl("active.8.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
- QCOMPARE(object->property("success").toBool(), true);
- delete object;
- }
-}
-
-void tst_QQuickLoader::initialPropertyValues_data()
-{
- QTest::addColumn<QUrl>("qmlFile");
- QTest::addColumn<QStringList>("expectedWarnings");
- QTest::addColumn<QStringList>("propertyNames");
- QTest::addColumn<QVariantList>("propertyValues");
-
- QTest::newRow("source url with value set in onLoaded, initially active = true") << testFileUrl("initialPropertyValues.1.qml")
- << QStringList()
- << (QStringList() << "initialValue" << "behaviorCount")
- << (QVariantList() << 1 << 1);
-
- QTest::newRow("set source with initial property values specified, active = true") << testFileUrl("initialPropertyValues.2.qml")
- << QStringList()
- << (QStringList() << "initialValue" << "behaviorCount")
- << (QVariantList() << 2 << 0);
-
- QTest::newRow("set source with initial property values specified, active = false") << testFileUrl("initialPropertyValues.3.qml")
- << (QStringList() << QString(QLatin1String("file://") + testFileUrl("initialPropertyValues.3.qml").toLocalFile() + QLatin1String(":16: TypeError: Cannot read property 'canary' of null")))
- << (QStringList())
- << (QVariantList());
-
- QTest::newRow("set source with initial property values specified, active = false, with active set true later") << testFileUrl("initialPropertyValues.4.qml")
- << QStringList()
- << (QStringList() << "initialValue" << "behaviorCount")
- << (QVariantList() << 4 << 0);
-
- QTest::newRow("set source without initial property values specified, active = true") << testFileUrl("initialPropertyValues.5.qml")
- << QStringList()
- << (QStringList() << "initialValue" << "behaviorCount")
- << (QVariantList() << 0 << 0);
-
- QTest::newRow("set source with initial property values specified with binding, active = true") << testFileUrl("initialPropertyValues.6.qml")
- << QStringList()
- << (QStringList() << "initialValue" << "behaviorCount")
- << (QVariantList() << 6 << 0);
-
- QTest::newRow("ensure initial property value semantics mimic createObject") << testFileUrl("initialPropertyValues.7.qml")
- << QStringList()
- << (QStringList() << "loaderValue" << "createObjectValue")
- << (QVariantList() << 1 << 1);
-
- QTest::newRow("ensure initial property values aren't disposed prior to component completion") << testFileUrl("initialPropertyValues.8.qml")
- << QStringList()
- << (QStringList() << "initialValue")
- << (QVariantList() << 6);
-}
-
-void tst_QQuickLoader::initialPropertyValues()
-{
- QFETCH(QUrl, qmlFile);
- QFETCH(QStringList, expectedWarnings);
- QFETCH(QStringList, propertyNames);
- QFETCH(QVariantList, propertyValues);
-
- TestHTTPServer server(SERVER_PORT);
- QVERIFY(server.isValid());
- server.serveDirectory(dataDirectory());
-
- foreach (const QString &warning, expectedWarnings)
- QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
-
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- qApp->processEvents();
- QTest::qWait(50);
-
- for (int i = 0; i < propertyNames.size(); ++i)
- QCOMPARE(object->property(propertyNames.at(i).toAscii().constData()), propertyValues.at(i));
-
- delete object;
-}
-
-void tst_QQuickLoader::initialPropertyValuesBinding()
-{
- QDeclarativeComponent component(&engine, testFileUrl("initialPropertyValues.binding.qml"));
- QObject *object = component.create();
- QVERIFY(object != 0);
-
- QVERIFY(object->setProperty("bindable", QVariant(8)));
- QCOMPARE(object->property("canaryValue").toInt(), 8);
-
- delete object;
-}
-
-void tst_QQuickLoader::initialPropertyValuesError_data()
-{
- QTest::addColumn<QUrl>("qmlFile");
- QTest::addColumn<QStringList>("expectedWarnings");
-
- QTest::newRow("invalid initial property values object") << testFileUrl("initialPropertyValues.error.1.qml")
- << (QStringList() << QString(testFileUrl("initialPropertyValues.error.1.qml").toString() + ":6:5: QML Loader: setSource: value is not an object"));
-
- QTest::newRow("nonexistent source url") << testFileUrl("initialPropertyValues.error.2.qml")
- << (QStringList() << QString(testFileUrl("NonexistentSourceComponent.qml").toString() + ": File not found"));
-
- QTest::newRow("invalid source url") << testFileUrl("initialPropertyValues.error.3.qml")
- << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error"));
-
- QTest::newRow("invalid initial property values object with invalid property access") << testFileUrl("initialPropertyValues.error.4.qml")
- << (QStringList() << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":7:5: QML Loader: setSource: value is not an object")
- << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":5: TypeError: Cannot read property 'canary' of null"));
-}
-
-void tst_QQuickLoader::initialPropertyValuesError()
-{
- QFETCH(QUrl, qmlFile);
- QFETCH(QStringList, expectedWarnings);
-
- foreach (const QString &warning, expectedWarnings)
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8().constData());
-
- QDeclarativeComponent component(&engine, qmlFile);
- QObject *object = component.create();
- QVERIFY(object != 0);
- QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
- QVERIFY(loader != 0);
- QVERIFY(loader->item() == 0);
- delete object;
-}
-
-// QTBUG-9241
-void tst_QQuickLoader::deleteComponentCrash()
-{
- QDeclarativeComponent component(&engine, testFileUrl("crash.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
-
- item->metaObject()->invokeMethod(item, "setLoaderSource");
-
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::childItems().at(0));
- QVERIFY(loader);
- QVERIFY(loader->item());
- QCOMPARE(loader->item()->objectName(), QLatin1String("blue"));
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QQuickLoader::Ready);
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
- QTRY_COMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
- QVERIFY(loader->source() == testFileUrl("BlueRect.qml"));
-
- delete item;
-}
-
-void tst_QQuickLoader::nonItem()
-{
- QDeclarativeComponent component(&engine, testFileUrl("nonItem.qml"));
- QString err = testFileUrl("nonItem.qml").toString() + ":3:1: QML Loader: Loader does not support loading non-visual elements.";
-
- QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData());
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QVERIFY(loader);
- QVERIFY(loader->item() == 0);
-
- delete loader;
-}
-
-void tst_QQuickLoader::vmeErrors()
-{
- QDeclarativeComponent component(&engine, testFileUrl("vmeErrors.qml"));
- QString err = testFileUrl("VmeError.qml").toString() + ":6: Cannot assign object type QObject with no default method";
- QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData());
- QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
- QVERIFY(loader);
- QVERIFY(loader->item() == 0);
-
- delete loader;
-}
-
-// QTBUG-13481
-void tst_QQuickLoader::creationContext()
-{
- QDeclarativeComponent component(&engine, testFileUrl("creationContext.qml"));
-
- QObject *o = component.create();
- QVERIFY(o != 0);
-
- QCOMPARE(o->property("test").toBool(), true);
-
- delete o;
-}
-
-void tst_QQuickLoader::QTBUG_16928()
-{
- QDeclarativeComponent component(&engine, testFileUrl("QTBUG_16928.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
-
- QCOMPARE(item->width(), 250.);
- QCOMPARE(item->height(), 250.);
-
- delete item;
-}
-
-void tst_QQuickLoader::implicitSize()
-{
- QDeclarativeComponent component(&engine, testFileUrl("implicitSize.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
-
- QCOMPARE(item->width(), 150.);
- QCOMPARE(item->height(), 150.);
-
- QCOMPARE(item->property("implHeight").toReal(), 100.);
- QCOMPARE(item->property("implWidth").toReal(), 100.);
-
- delete item;
-}
-
-void tst_QQuickLoader::QTBUG_17114()
-{
- QDeclarativeComponent component(&engine, testFileUrl("QTBUG_17114.qml"));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
-
- QCOMPARE(item->property("loaderWidth").toReal(), 32.);
- QCOMPARE(item->property("loaderHeight").toReal(), 32.);
-
- delete item;
-}
-
-void tst_QQuickLoader::asynchronous_data()
-{
- QTest::addColumn<QUrl>("qmlFile");
- QTest::addColumn<QStringList>("expectedWarnings");
-
- QTest::newRow("Valid component") << testFileUrl("BigComponent.qml")
- << QStringList();
-
- QTest::newRow("Non-existant component") << testFileUrl("IDoNotExist.qml")
- << (QStringList() << QString(testFileUrl("IDoNotExist.qml").toString() + ": File not found"));
-
- QTest::newRow("Invalid component") << testFileUrl("InvalidSourceComponent.qml")
- << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error"));
-}
-
-void tst_QQuickLoader::asynchronous()
-{
- QFETCH(QUrl, qmlFile);
- QFETCH(QStringList, expectedWarnings);
-
- if (!engine.incubationController())
- engine.setIncubationController(new PeriodicIncubationController);
- QDeclarativeComponent component(&engine, testFileUrl("asynchronous.qml"));
- QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(root);
-
- QQuickLoader *loader = root->findChild<QQuickLoader*>("loader");
- QVERIFY(loader);
-
- foreach (const QString &warning, expectedWarnings)
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8().constData());
-
- QVERIFY(!loader->item());
- root->setProperty("comp", qmlFile.toString());
- QMetaObject::invokeMethod(root, "loadComponent");
- QVERIFY(!loader->item());
-
- if (expectedWarnings.isEmpty()) {
- QCOMPARE(loader->status(), QQuickLoader::Loading);
- QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1);
-
- QTRY_VERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QQuickLoader::Ready);
- } else {
- QCOMPARE(loader->progress(), 1.0);
- QTRY_COMPARE(loader->status(), QQuickLoader::Error);
- }
-
- delete root;
-}
-
-void tst_QQuickLoader::asynchronous_clear()
-{
- if (!engine.incubationController())
- engine.setIncubationController(new PeriodicIncubationController);
- QDeclarativeComponent component(&engine, testFileUrl("asynchronous.qml"));
- QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(root);
-
- QQuickLoader *loader = root->findChild<QQuickLoader*>("loader");
- QVERIFY(loader);
-
- QVERIFY(!loader->item());
- root->setProperty("comp", "BigComponent.qml");
- QMetaObject::invokeMethod(root, "loadComponent");
- QVERIFY(!loader->item());
-
- QCOMPARE(loader->status(), QQuickLoader::Loading);
- QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1);
-
- // clear before component created
- root->setProperty("comp", "");
- QMetaObject::invokeMethod(root, "loadComponent");
- QVERIFY(!loader->item());
- QCOMPARE(engine.incubationController()->incubatingObjectCount(), 0);
-
- QCOMPARE(loader->progress(), 0.0);
- QCOMPARE(loader->status(), QQuickLoader::Null);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
-
- // check loading component
- root->setProperty("comp", "Rect120x60.qml");
- QMetaObject::invokeMethod(root, "loadComponent");
- QVERIFY(!loader->item());
-
- QCOMPARE(loader->status(), QQuickLoader::Loading);
- QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1);
-
- QTRY_VERIFY(loader->item());
- QCOMPARE(loader->progress(), 1.0);
- QCOMPARE(loader->status(), QQuickLoader::Ready);
- QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
-}
-
-void tst_QQuickLoader::parented()
-{
- QDeclarativeComponent component(&engine, testFileUrl("parented.qml"));
- QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(root);
-
- QQuickItem *item = root->findChild<QQuickItem*>("comp");
- QVERIFY(item);
-
- QVERIFY(item->parentItem() == root);
-
- QCOMPARE(item->width(), 300.);
- QCOMPARE(item->height(), 300.);
-
- delete root;
-}
-
-void tst_QQuickLoader::sizeBound()
-{
- QDeclarativeComponent component(&engine, testFileUrl("sizebound.qml"));
- QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(root);
- QQuickLoader *loader = root->findChild<QQuickLoader*>("loader");
- QVERIFY(loader != 0);
-
- QVERIFY(loader->item());
-
- QCOMPARE(loader->width(), 50.0);
- QCOMPARE(loader->height(), 60.0);
-
- QMetaObject::invokeMethod(root, "switchComponent");
-
- QCOMPARE(loader->width(), 80.0);
- QCOMPARE(loader->height(), 90.0);
-
- delete root;
-}
-
-
-QTEST_MAIN(tst_QQuickLoader)
-
-#include "tst_qquickloader.moc"
diff --git a/tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro b/tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro
deleted file mode 100644
index 67d77dc05a..0000000000
--- a/tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickmousearea
-macx:CONFIG -= app_bundle
-
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qquickmousearea.cpp \
- ../../shared/testhttpserver.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp
deleted file mode 100644
index 66f651329a..0000000000
--- a/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp
+++ /dev/null
@@ -1,806 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <QtQuick/private/qquickmousearea_p.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <private/qquickflickable_p.h>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtOpenGL/QGLShaderProgram>
-#include "../../shared/util.h"
-
-//#define OLDWAY
-
-class tst_QQuickMouseArea: public QDeclarativeDataTest
-{
- Q_OBJECT
-private slots:
- void dragProperties();
- void resetDrag();
- void dragging();
- void updateMouseAreaPosOnClick();
- void updateMouseAreaPosOnResize();
- void noOnClickedWithPressAndHold();
- void onMousePressRejected();
- void pressedCanceledOnWindowDeactivate();
- void doubleClick();
- void clickTwice();
- void pressedOrdering();
- void preventStealing();
- void clickThrough();
- void hoverPosition();
- void hoverPropagation();
- void hoverVisible();
-
-private:
- QQuickView *createView();
-};
-
-void tst_QQuickMouseArea::dragProperties()
-{
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("dragproperties.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
- QQuickDrag *drag = mouseRegion->drag();
- QVERIFY(mouseRegion != 0);
- QVERIFY(drag != 0);
-
- // target
- QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
- QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
- QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootItem != 0);
- QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
- drag->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
- drag->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
-
- // axis
- QCOMPARE(drag->axis(), QQuickDrag::XandYAxis);
- QSignalSpy axisSpy(drag, SIGNAL(axisChanged()));
- drag->setAxis(QQuickDrag::XAxis);
- QCOMPARE(drag->axis(), QQuickDrag::XAxis);
- QCOMPARE(axisSpy.count(),1);
- drag->setAxis(QQuickDrag::XAxis);
- QCOMPARE(axisSpy.count(),1);
-
- // minimum and maximum properties
- QSignalSpy xminSpy(drag, SIGNAL(minimumXChanged()));
- QSignalSpy xmaxSpy(drag, SIGNAL(maximumXChanged()));
- QSignalSpy yminSpy(drag, SIGNAL(minimumYChanged()));
- QSignalSpy ymaxSpy(drag, SIGNAL(maximumYChanged()));
-
- QCOMPARE(drag->xmin(), 0.0);
- QCOMPARE(drag->xmax(), rootItem->width()-blackRect->width());
- QCOMPARE(drag->ymin(), 0.0);
- QCOMPARE(drag->ymax(), rootItem->height()-blackRect->height());
-
- drag->setXmin(10);
- drag->setXmax(10);
- drag->setYmin(10);
- drag->setYmax(10);
-
- QCOMPARE(drag->xmin(), 10.0);
- QCOMPARE(drag->xmax(), 10.0);
- QCOMPARE(drag->ymin(), 10.0);
- QCOMPARE(drag->ymax(), 10.0);
-
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
-
- drag->setXmin(10);
- drag->setXmax(10);
- drag->setYmin(10);
- drag->setYmax(10);
-
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
-
- // filterChildren
- QSignalSpy filterChildrenSpy(drag, SIGNAL(filterChildrenChanged()));
-
- drag->setFilterChildren(true);
-
- QVERIFY(drag->filterChildren());
- QCOMPARE(filterChildrenSpy.count(), 1);
-
- drag->setFilterChildren(true);
- QCOMPARE(filterChildrenSpy.count(), 1);
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::resetDrag()
-{
- QQuickView *canvas = createView();
-
- canvas->rootContext()->setContextProperty("haveTarget", QVariant(true));
- canvas->setSource(testFileUrl("dragreset.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
- QQuickDrag *drag = mouseRegion->drag();
- QVERIFY(mouseRegion != 0);
- QVERIFY(drag != 0);
-
- // target
- QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
- QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
- QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootItem != 0);
- QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
- QVERIFY(drag->target() != 0);
- canvas->rootContext()->setContextProperty("haveTarget", QVariant(false));
- QCOMPARE(targetSpy.count(),1);
- QVERIFY(drag->target() == 0);
-
- delete canvas;
-}
-
-
-void tst_QQuickMouseArea::dragging()
-{
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("dragging.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWait(20);
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
- QQuickDrag *drag = mouseRegion->drag();
- QVERIFY(mouseRegion != 0);
- QVERIFY(drag != 0);
-
- // target
- QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
- QVERIFY(blackRect != 0);
- QVERIFY(blackRect == drag->target());
-
- QVERIFY(!drag->active());
-
-#ifdef OLDWAY
- QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-#else
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
-#endif
-
- QVERIFY(!drag->active());
- QCOMPARE(blackRect->x(), 50.0);
- QCOMPARE(blackRect->y(), 50.0);
-
- // First move event triggers drag, second is acted upon.
- // This is due to possibility of higher stacked area taking precedence.
-
- QTest::mouseMove(canvas, QPoint(111,111));
- QTest::qWait(50);
- QTest::mouseMove(canvas, QPoint(122,122));
- QTest::qWait(50);
-
- QVERIFY(drag->active());
- QCOMPARE(blackRect->x(), 72.0);
- QCOMPARE(blackRect->y(), 72.0);
-
-#ifdef OLDWAY
- QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-#else
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(122,122));
- QTest::qWait(50);
-#endif
-
- QVERIFY(!drag->active());
- QCOMPARE(blackRect->x(), 72.0);
- QCOMPARE(blackRect->y(), 72.0);
-
- delete canvas;
-}
-
-QQuickView *tst_QQuickMouseArea::createView()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setBaseSize(QSize(240,320));
-
- return canvas;
-}
-
-void tst_QQuickMouseArea::updateMouseAreaPosOnClick()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("updateMousePosOnClick.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
- QVERIFY(mouseRegion != 0);
-
- QQuickRectangle *rect = canvas->rootObject()->findChild<QQuickRectangle*>("ball");
- QVERIFY(rect != 0);
-
- QCOMPARE(mouseRegion->mouseX(), rect->x());
- QCOMPARE(mouseRegion->mouseY(), rect->y());
-
- QMouseEvent event(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &event);
-
- QCOMPARE(mouseRegion->mouseX(), 100.0);
- QCOMPARE(mouseRegion->mouseY(), 100.0);
-
- QCOMPARE(mouseRegion->mouseX(), rect->x());
- QCOMPARE(mouseRegion->mouseY(), rect->y());
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::updateMouseAreaPosOnResize()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("updateMousePosOnResize.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
- QVERIFY(mouseRegion != 0);
-
- QQuickRectangle *rect = canvas->rootObject()->findChild<QQuickRectangle*>("brother");
- QVERIFY(rect != 0);
-
- QCOMPARE(mouseRegion->mouseX(), 0.0);
- QCOMPARE(mouseRegion->mouseY(), 0.0);
-
- QMouseEvent event(QEvent::MouseButtonPress, rect->pos().toPoint(), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &event);
-
- QVERIFY(!mouseRegion->property("emitPositionChanged").toBool());
- QVERIFY(mouseRegion->property("mouseMatchesPos").toBool());
-
- QCOMPARE(mouseRegion->property("x1").toReal(), 0.0);
- QCOMPARE(mouseRegion->property("y1").toReal(), 0.0);
-
- QCOMPARE(mouseRegion->property("x2").toReal(), rect->x());
- QCOMPARE(mouseRegion->property("y2").toReal(), rect->y());
-
- QCOMPARE(mouseRegion->mouseX(), rect->x());
- QCOMPARE(mouseRegion->mouseY(), rect->y());
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::noOnClickedWithPressAndHold()
-{
- {
- // We handle onPressAndHold, therefore no onClicked
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("clickandhold.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QVERIFY(!canvas->rootObject()->property("clicked").toBool());
- QVERIFY(!canvas->rootObject()->property("held").toBool());
-
- QTest::qWait(1000);
-
- QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-
- QVERIFY(!canvas->rootObject()->property("clicked").toBool());
- QVERIFY(canvas->rootObject()->property("held").toBool());
-
- delete canvas;
- }
-
- {
- // We do not handle onPressAndHold, therefore we get onClicked
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("noclickandhold.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QVERIFY(!canvas->rootObject()->property("clicked").toBool());
-
- QTest::qWait(1000);
-
- QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-
- QVERIFY(canvas->rootObject()->property("clicked").toBool());
-
- delete canvas;
- }
-}
-
-void tst_QQuickMouseArea::onMousePressRejected()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("rejectEvent.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
- QVERIFY(canvas->rootObject()->property("enabled").toBool());
-
- QVERIFY(!canvas->rootObject()->property("mr1_pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("mr1_released").toBool());
- QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
- QVERIFY(!canvas->rootObject()->property("mr2_pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
- QVERIFY(!canvas->rootObject()->property("mr2_canceled").toBool());
-
- QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QVERIFY(canvas->rootObject()->property("mr1_pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("mr1_released").toBool());
- QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
- QVERIFY(canvas->rootObject()->property("mr2_pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
- QVERIFY(canvas->rootObject()->property("mr2_canceled").toBool());
-
- QTest::qWait(200);
-
- QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-
- QVERIFY(canvas->rootObject()->property("mr1_released").toBool());
- QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
- QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
-
- delete canvas;
-}
-void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("pressedCanceled.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
- QVERIFY(!canvas->rootObject()->property("pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("canceled").toBool());
- QVERIFY(!canvas->rootObject()->property("released").toBool());
-
- QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QVERIFY(canvas->rootObject()->property("pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("canceled").toBool());
- QVERIFY(!canvas->rootObject()->property("released").toBool());
-
- QTest::qWait(200);
-
- QEvent windowDeactivateEvent(QEvent::WindowDeactivate);
- QGuiApplication::sendEvent(canvas, &windowDeactivateEvent);
- QVERIFY(!canvas->rootObject()->property("pressed").toBool());
- QVERIFY(canvas->rootObject()->property("canceled").toBool());
- QVERIFY(!canvas->rootObject()->property("released").toBool());
-
- QTest::qWait(200);
-
- //press again
- QGuiApplication::sendEvent(canvas, &pressEvent);
- QVERIFY(canvas->rootObject()->property("pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("canceled").toBool());
- QVERIFY(!canvas->rootObject()->property("released").toBool());
-
- QTest::qWait(200);
-
- //release
- QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
- QVERIFY(!canvas->rootObject()->property("pressed").toBool());
- QVERIFY(!canvas->rootObject()->property("canceled").toBool());
- QVERIFY(canvas->rootObject()->property("released").toBool());
-
- delete canvas;
-}
-void tst_QQuickMouseArea::doubleClick()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("doubleclick.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-
- QCOMPARE(canvas->rootObject()->property("released").toInt(), 1);
-
- pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-
- QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("doubleClicked").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("released").toInt(), 2);
-
- delete canvas;
-}
-
-// QTBUG-14832
-void tst_QQuickMouseArea::clickTwice()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("clicktwice.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-
- QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("released").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1);
-
- pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QGuiApplication::sendEvent(canvas, &pressEvent);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-
- QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 2);
- QCOMPARE(canvas->rootObject()->property("released").toInt(), 2);
- QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 2);
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::pressedOrdering()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("pressedOrdering.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("base"));
-
- QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed"));
-
- QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
- QGuiApplication::sendEvent(canvas, &releaseEvent);
-
- QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("toggled"));
-
- QGuiApplication::sendEvent(canvas, &pressEvent);
-
- QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed"));
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::preventStealing()
-{
- QQuickView *canvas = createView();
-
- canvas->setSource(testFileUrl("preventstealing.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(canvas->rootObject());
- QVERIFY(flickable != 0);
-
- QQuickMouseArea *mouseArea = canvas->rootObject()->findChild<QQuickMouseArea*>("mousearea");
- QVERIFY(mouseArea != 0);
-
- QSignalSpy mousePositionSpy(mouseArea, SIGNAL(positionChanged(QQuickMouseEvent*)));
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(80, 80));
-
- // Without preventStealing, mouse movement over MouseArea would
- // cause the Flickable to steal mouse and trigger content movement.
-
- QTest::mouseMove(canvas,QPoint(69,69));
- QTest::mouseMove(canvas,QPoint(58,58));
- QTest::mouseMove(canvas,QPoint(47,47));
-
- // We should have received all three move events
- QCOMPARE(mousePositionSpy.count(), 3);
- QVERIFY(mouseArea->pressed());
-
- // Flickable content should not have moved.
- QCOMPARE(flickable->contentX(), 0.);
- QCOMPARE(flickable->contentY(), 0.);
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(47, 47));
-
- // Now allow stealing and confirm Flickable does its thing.
- canvas->rootObject()->setProperty("stealing", false);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(80, 80));
-
- // Without preventStealing, mouse movement over MouseArea would
- // cause the Flickable to steal mouse and trigger content movement.
-
- QTest::mouseMove(canvas,QPoint(69,69));
- QTest::mouseMove(canvas,QPoint(58,58));
- QTest::mouseMove(canvas,QPoint(47,47));
-
- // We should only have received the first move event
- QCOMPARE(mousePositionSpy.count(), 4);
- // Our press should be taken away
- QVERIFY(!mouseArea->pressed());
-
- // Flickable content should have moved.
-
- QCOMPARE(flickable->contentX(), 11.);
- QCOMPARE(flickable->contentY(), 11.);
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 50));
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::clickThrough()
-{
- QSKIP("QTBUG-23976 Unstable");
- //With no handlers defined click, doubleClick and PressAndHold should propagate to those with handlers
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("clickThrough.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
-
- QTRY_COMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1);
-
- QTest::qWait(800); // to avoid generating a double click.
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(1000);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
-
- QTRY_COMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1);
- QTRY_COMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
-
- QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(100);
-
- QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2);
- QTRY_COMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
-
- delete canvas;
-
- //With handlers defined click, doubleClick and PressAndHold should propagate only when explicitly ignored
- canvas = createView();
- canvas->setSource(testFileUrl("clickThrough2.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
-
- QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0);
-
- QTest::qWait(800); // to avoid generating a double click.
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(1000);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(100);
-
- QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 0);
-
- QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(100);
-
- QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 0);
-
- canvas->rootObject()->setProperty("letThrough", QVariant(true));
-
- QTest::qWait(800); // to avoid generating a double click.
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
-
- QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1);
-
- QTest::qWait(800); // to avoid generating a double click.
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(1000);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(100);
-
- QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
-
- QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(100);
-
- QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2);
- QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
-
- canvas->rootObject()->setProperty("noPropagation", QVariant(true));
-
- QTest::qWait(800); // to avoid generating a double click.
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
-
- QTest::qWait(800); // to avoid generating a double click.
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(1000);
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(100);
-
- QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(100);
-
- QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
- QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2);
- QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1);
- QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::hoverPosition()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("hoverPosition.qml"));
-
- QQuickItem *root = canvas->rootObject();
- QVERIFY(root != 0);
-
- QCOMPARE(root->property("mouseX").toReal(), qreal(0));
- QCOMPARE(root->property("mouseY").toReal(), qreal(0));
-
- QTest::mouseMove(canvas,QPoint(10,32));
-
-
- QCOMPARE(root->property("mouseX").toReal(), qreal(10));
- QCOMPARE(root->property("mouseY").toReal(), qreal(32));
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::hoverPropagation()
-{
- //QTBUG-18175, to behave like GV did.
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("hoverPropagation.qml"));
-
- QQuickItem *root = canvas->rootObject();
- QVERIFY(root != 0);
-
- QCOMPARE(root->property("point1").toBool(), false);
- QCOMPARE(root->property("point2").toBool(), false);
-
- QMouseEvent moveEvent(QEvent::MouseMove, QPoint(32, 32), Qt::NoButton, Qt::NoButton, 0);
- QGuiApplication::sendEvent(canvas, &moveEvent);
-
- QCOMPARE(root->property("point1").toBool(), true);
- QCOMPARE(root->property("point2").toBool(), false);
-
- QMouseEvent moveEvent2(QEvent::MouseMove, QPoint(232, 32), Qt::NoButton, Qt::NoButton, 0);
- QGuiApplication::sendEvent(canvas, &moveEvent2);
- QCOMPARE(root->property("point1").toBool(), false);
- QCOMPARE(root->property("point2").toBool(), true);
-
- delete canvas;
-}
-
-void tst_QQuickMouseArea::hoverVisible()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("hoverVisible.qml"));
-
- QQuickItem *root = canvas->rootObject();
- QVERIFY(root != 0);
-
- QQuickMouseArea *mouseTracker = canvas->rootObject()->findChild<QQuickMouseArea*>("mousetracker");
- QVERIFY(mouseTracker != 0);
-
- QSignalSpy enteredSpy(mouseTracker, SIGNAL(entered()));
-
- QTest::mouseMove(canvas,QPoint(10,32));
-
- QCOMPARE(mouseTracker->hovered(), false);
- QCOMPARE(enteredSpy.count(), 0);
-
- mouseTracker->setVisible(true);
-
- QCOMPARE(mouseTracker->hovered(), true);
- QCOMPARE(enteredSpy.count(), 1);
-
- QEXPECT_FAIL("", "QTBUG-24282", Continue);
- QCOMPARE(QPointF(mouseTracker->mouseX(), mouseTracker->mouseY()), QPointF(10,32));
-
- delete canvas;
-}
-
-QTEST_MAIN(tst_QQuickMouseArea)
-
-#include "tst_qquickmousearea.moc"
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/qquickmultipointtoucharea.pro b/tests/auto/qtquick2/qquickmultipointtoucharea/qquickmultipointtoucharea.pro
deleted file mode 100644
index 38c32099b0..0000000000
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/qquickmultipointtoucharea.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-TARGET = tst_qquickmultipointtoucharea
-CONFIG += testcase
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickmultipointtoucharea.cpp
-
-importFiles.files = data
-importFiles.path = .
-DEPLOYMENT += importFiles
-
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
deleted file mode 100644
index 0a154d0a7b..0000000000
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
+++ /dev/null
@@ -1,727 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <private/qquickmultipointtoucharea_p.h>
-#include <private/qquickflickable_p.h>
-#include <QtQuick/qquickview.h>
-
-class tst_QQuickMultiPointTouchArea: public QObject
-{
- Q_OBJECT
-public:
- tst_QQuickMultiPointTouchArea() : device(0) { }
-private slots:
- void initTestCase() {
- if (!device) {
- device = new QTouchDevice;
- device->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(device);
- }
- }
- void cleanupTestCase() {}
-
- void properties();
- void signalTest();
- void release();
- void reuse();
- void nonOverlapping();
- void nested();
- void inFlickable();
- void invisible();
-
-private:
- QQuickView *createAndShowView(const QString &file);
- QTouchDevice *device;
-};
-
-void tst_QQuickMultiPointTouchArea::properties()
-{
- QQuickView *canvas = createAndShowView("properties.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickMultiPointTouchArea *area = qobject_cast<QQuickMultiPointTouchArea *>(canvas->rootObject());
- QVERIFY(area != 0);
-
- QCOMPARE(area->minimumTouchPoints(), 2);
- QCOMPARE(area->maximumTouchPoints(), 4);
-
- QDeclarativeListReference ref(area, "touchPoints");
- QCOMPARE(ref.count(), 4);
-
- delete canvas;
-}
-
-void tst_QQuickMultiPointTouchArea::signalTest()
-{
- QQuickView *canvas = createAndShowView("signalTest.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickMultiPointTouchArea *area = qobject_cast<QQuickMultiPointTouchArea *>(canvas->rootObject());
- QVERIFY(area != 0);
-
- QPoint p1(20,100);
- QPoint p2(40,100);
- QPoint p3(60,100);
- QPoint p4(80,100);
- QPoint p5(100,100);
-
- QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
-
- sequence.press(0, p1).press(1, p2).commit();
-
- QCOMPARE(area->property("touchPointPressCount").toInt(), 2);
- QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
- QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
- QCOMPARE(area->property("touchCount").toInt(), 2);
- QMetaObject::invokeMethod(area, "clearCounts");
-
- sequence.stationary(0).stationary(1).press(2, p3).commit();
-
- QCOMPARE(area->property("touchPointPressCount").toInt(), 1);
- QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
- QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
- QCOMPARE(area->property("touchCount").toInt(), 3);
- QMetaObject::invokeMethod(area, "clearCounts");
-
- p1 -= QPoint(10,10);
- p2 += QPoint(10,10);
- sequence.move(0, p1).move(1, p2).stationary(2).commit();
-
- QCOMPARE(area->property("touchPointPressCount").toInt(), 0);
- QCOMPARE(area->property("touchPointUpdateCount").toInt(), 2);
- QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
- QCOMPARE(area->property("touchCount").toInt(), 3);
- QMetaObject::invokeMethod(area, "clearCounts");
-
- p3 += QPoint(10,10);
- sequence.release(0, p1).release(1, p2)
- .move(2, p3).press(3, p4).press(4, p5).commit();
-
- QCOMPARE(area->property("touchPointPressCount").toInt(), 2);
- QCOMPARE(area->property("touchPointUpdateCount").toInt(), 1);
- QCOMPARE(area->property("touchPointReleaseCount").toInt(), 2);
- QCOMPARE(area->property("touchCount").toInt(), 3);
- QMetaObject::invokeMethod(area, "clearCounts");
-
- sequence.release(2, p3).release(3, p4).release(4, p5).commit();
-
- QCOMPARE(area->property("touchPointPressCount").toInt(), 0);
- QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
- QCOMPARE(area->property("touchPointReleaseCount").toInt(), 3);
- QCOMPARE(area->property("touchCount").toInt(), 0);
- QCOMPARE(area->property("touchUpdatedHandled").toBool(), true);
- QMetaObject::invokeMethod(area, "clearCounts");
-
- delete canvas;
-}
-
-void tst_QQuickMultiPointTouchArea::release()
-{
- QQuickView *canvas = createAndShowView("basic.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickTouchPoint *point1 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point1");
-
- QCOMPARE(point1->pressed(), false);
-
- QPoint p1(20,100);
-
- QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
-
- sequence.press(0, p1).commit();
-
- QCOMPARE(point1->pressed(), true);
-
- p1 += QPoint(0,10);
-
- sequence.move(0, p1).commit();
-
- QCOMPARE(point1->pressed(), true);
- QCOMPARE(point1->x(), qreal(20)); QCOMPARE(point1->y(), qreal(110));
-
- p1 += QPoint(4,10);
-
- sequence.release(0, p1).commit();
-
- //test that a release without a prior move to the release position successfully updates the point's position
- QCOMPARE(point1->pressed(), false);
- QCOMPARE(point1->x(), qreal(24)); QCOMPARE(point1->y(), qreal(120));
-
- delete canvas;
-}
-
-void tst_QQuickMultiPointTouchArea::reuse()
-{
- QQuickView *canvas = createAndShowView("basic.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickTouchPoint *point1 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point1");
- QQuickTouchPoint *point2 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point2");
- QQuickTouchPoint *point3 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point3");
-
- QCOMPARE(point1->pressed(), false);
- QCOMPARE(point2->pressed(), false);
-
- QPoint p1(20,100);
- QPoint p2(40,100);
- QPoint p3(60,100);
- QPoint p4(80,100);
-
- QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
-
- sequence.press(0, p1).press(1, p2).commit();
-
- QCOMPARE(point1->pressed(), true);
- QCOMPARE(point2->pressed(), true);
- QCOMPARE(point3->pressed(), false);
-
- sequence.release(0, p1).stationary(1).press(2, p3).commit();
-
- //we shouldn't reuse point 1 yet
- QCOMPARE(point1->pressed(), false);
- QCOMPARE(point2->pressed(), true);
- QCOMPARE(point3->pressed(), true);
-
- //back to base state (no touches)
- sequence.release(1, p2).release(2, p3).commit();
-
- QCOMPARE(point1->pressed(), false);
- QCOMPARE(point2->pressed(), false);
- QCOMPARE(point3->pressed(), false);
-
- sequence.press(0, p1).press(1, p2).commit();
-
- QCOMPARE(point1->pressed(), true);
- QCOMPARE(point2->pressed(), true);
- QCOMPARE(point3->pressed(), false);
-
- sequence.release(0, p1).stationary(1).commit();
-
- QCOMPARE(point1->pressed(), false);
- QCOMPARE(point2->pressed(), true);
- QCOMPARE(point3->pressed(), false);
-
- sequence.press(4, p4).stationary(1).commit();
-
- //the new touch point should reuse point 1
- QCOMPARE(point1->pressed(), true);
- QCOMPARE(point2->pressed(), true);
- QCOMPARE(point3->pressed(), false);
-
- QCOMPARE(point1->x(), qreal(80)); QCOMPARE(point1->y(), qreal(100));
-
- delete canvas;
-}
-
-void tst_QQuickMultiPointTouchArea::nonOverlapping()
-{
- QQuickView *canvas = createAndShowView("nonOverlapping.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickTouchPoint *point11 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point11");
- QQuickTouchPoint *point12 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point12");
- QQuickTouchPoint *point21 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point21");
- QQuickTouchPoint *point22 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point22");
- QQuickTouchPoint *point23 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point23");
-
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- QPoint p1(20,100);
- QPoint p2(40,100);
- QPoint p3(60,180);
- QPoint p4(80,180);
- QPoint p5(100,180);
-
- QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
-
- sequence.press(0, p1).commit();
-
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- sequence.stationary(0).press(1, p2).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(100));
- QCOMPARE(point12->x(), qreal(40)); QCOMPARE(point12->y(), qreal(100));
-
- p1 += QPoint(0,10);
- p2 += QPoint(5,0);
- sequence.move(0, p1).move(1, p2).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
- QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
-
- sequence.stationary(0).stationary(1).press(2, p3).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- sequence.stationary(0).stationary(1).stationary(2).press(3, p4).press(4, p5).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
- QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
- QCOMPARE(point21->x(), qreal(60)); QCOMPARE(point21->y(), qreal(20));
- QCOMPARE(point22->x(), qreal(80)); QCOMPARE(point22->y(), qreal(20));
- QCOMPARE(point23->x(), qreal(100)); QCOMPARE(point23->y(), qreal(20));
-
- p1 += QPoint(4,10);
- p2 += QPoint(17,17);
- p3 += QPoint(3,0);
- p4 += QPoint(1,-1);
- p5 += QPoint(-7,10);
- sequence.move(0, p1).move(1, p2).move(2, p3).move(3, p4).move(4, p5).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- QCOMPARE(point11->x(), qreal(24)); QCOMPARE(point11->y(), qreal(120));
- QCOMPARE(point12->x(), qreal(62)); QCOMPARE(point12->y(), qreal(117));
- QCOMPARE(point21->x(), qreal(63)); QCOMPARE(point21->y(), qreal(20));
- QCOMPARE(point22->x(), qreal(81)); QCOMPARE(point22->y(), qreal(19));
- QCOMPARE(point23->x(), qreal(93)); QCOMPARE(point23->y(), qreal(30));
-
- sequence.release(0, p1).release(1, p2).release(2, p3).release(3, p4).release(4, p5).commit();
-
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- delete canvas;
-}
-
-void tst_QQuickMultiPointTouchArea::nested()
-{
- QQuickView *canvas = createAndShowView("nested.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickTouchPoint *point11 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point11");
- QQuickTouchPoint *point12 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point12");
- QQuickTouchPoint *point21 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point21");
- QQuickTouchPoint *point22 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point22");
- QQuickTouchPoint *point23 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point23");
-
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- QPoint p1(20,100);
- QPoint p2(40,100);
- QPoint p3(60,180);
-
- QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
-
- sequence.press(0, p1).commit();
-
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- sequence.stationary(0).press(1, p2).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(100));
- QCOMPARE(point12->x(), qreal(40)); QCOMPARE(point12->y(), qreal(100));
-
- p1 += QPoint(0,10);
- p2 += QPoint(5,0);
- sequence.move(0, p1).move(1, p2).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
- QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
-
- sequence.stationary(0).stationary(1).press(2, p3).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- //point11 should be same as point21, point12 same as point22
- QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
- QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
- QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110));
- QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100));
- QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180));
-
- sequence.stationary(0).stationary(1).stationary(2).press(3, QPoint(80,180)).press(4, QPoint(100,180)).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- //new touch points should be ignored (have no impact on our existing touch points)
- QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
- QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
- QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110));
- QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100));
- QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180));
-
- sequence.stationary(0).stationary(1).stationary(2).release(3, QPoint(80,180)).release(4, QPoint(100,180)).commit();
-
- p1 += QPoint(4,10);
- p2 += QPoint(17,17);
- p3 += QPoint(3,0);
- sequence.move(0, p1).move(1, p2).move(2, p3).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120));
- QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117));
- QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120));
- QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117));
- QCOMPARE(point23->x(), qreal(63)); QCOMPARE(point23->y(), qreal(180));
-
- p1 += QPoint(4,10);
- p2 += QPoint(17,17);
- p3 += QPoint(3,0);
- sequence.move(0, p1).move(1, p2).move(2, p3).commit();
-
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- //first two remain the same (touches now grabbed by inner touch area)
- QCOMPARE(point11->x(), qreal(24)); QCOMPARE(point11->y(), qreal(120));
- QCOMPARE(point12->x(), qreal(62)); QCOMPARE(point12->y(), qreal(117));
- QCOMPARE(point21->x(), qreal(28)); QCOMPARE(point21->y(), qreal(130));
- QCOMPARE(point22->x(), qreal(79)); QCOMPARE(point22->y(), qreal(134));
- QCOMPARE(point23->x(), qreal(66)); QCOMPARE(point23->y(), qreal(180));
-
- sequence.release(0, p1).release(1, p2).release(2, p3).commit();
-
- sequence.press(0, p1).commit();
-
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
- QCOMPARE(point21->pressed(), false);
- QCOMPARE(point22->pressed(), false);
- QCOMPARE(point23->pressed(), false);
-
- sequence.release(0, p1).commit();
-
- //test with grabbing turned off
- canvas->rootObject()->setProperty("grabInnerArea", false);
-
- sequence.press(0, p1).press(1, p2).press(2, p3).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- p1 -= QPoint(4,10);
- p2 -= QPoint(17,17);
- p3 -= QPoint(3,0);
- sequence.move(0, p1).move(1, p2).move(2, p3).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120));
- QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117));
- QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120));
- QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117));
- QCOMPARE(point23->x(), qreal(63)); QCOMPARE(point23->y(), qreal(180));
-
- p1 -= QPoint(4,10);
- p2 -= QPoint(17,17);
- p3 -= QPoint(3,0);
- sequence.move(0, p1).move(1, p2).move(2, p3).commit();
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(point21->pressed(), true);
- QCOMPARE(point22->pressed(), true);
- QCOMPARE(point23->pressed(), true);
-
- //all change (touches not grabbed by inner touch area)
- QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
- QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
- QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110));
- QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100));
- QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180));
-
- sequence.release(0, p1).release(1, p2).release(2, p3).commit();
-
- delete canvas;
-}
-
-void tst_QQuickMultiPointTouchArea::inFlickable()
-{
- QQuickView *canvas = createAndShowView("inFlickable.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickFlickable *flickable = qobject_cast<QQuickFlickable *>(canvas->rootObject());
- QVERIFY(flickable != 0);
-
- QQuickTouchPoint *point11 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point1");
- QQuickTouchPoint *point12 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point2");
-
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
-
- QPoint p1(20,100);
- QPoint p2(40,100);
-
- //moving one point vertically
- QTest::touchEvent(canvas, device).press(0, p1);
- QTest::mousePress(canvas, Qt::LeftButton, 0, p1);
-
- p1 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1);
- QTest::mouseMove(canvas, p1);
-
- QVERIFY(flickable->contentY() < 0);
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
-
- QTest::touchEvent(canvas, device).release(0, p1);
- QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1);
- QTest::qWait(50);
-
- QTRY_VERIFY(!flickable->isMoving());
-
- //moving two points vertically
- p1 = QPoint(20,100);
- QTest::touchEvent(canvas, device).press(0, p1).press(1, p2);
- QTest::mousePress(canvas, Qt::LeftButton, 0, p1);
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
- QCOMPARE(flickable->property("cancelCount").toInt(), 0);
- QCOMPARE(flickable->property("touchCount").toInt(), 2);
-
- p1 += QPoint(0,15); p2 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15); p2 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15); p2 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15); p2 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- QVERIFY(flickable->contentY() < 0);
- QCOMPARE(point11->pressed(), false);
- QCOMPARE(point12->pressed(), false);
- QCOMPARE(flickable->property("cancelCount").toInt(), 2);
- QCOMPARE(flickable->property("touchCount").toInt(), 0);
-
- QTest::touchEvent(canvas, device).release(0, p1).release(1, p2);
- QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1);
- QTest::qWait(50);
-
- QTRY_VERIFY(!flickable->isMoving());
-
- //moving two points horizontally, then one point vertically
- p1 = QPoint(20,100);
- p2 = QPoint(40,100);
- QTest::touchEvent(canvas, device).press(0, p1).press(1, p2);
- QTest::mousePress(canvas, Qt::LeftButton, 0, p1);
-
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
-
- p1 += QPoint(15,0); p2 += QPoint(15,0);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(15,0); p2 += QPoint(15,0);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(15,0); p2 += QPoint(15,0);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(15,0); p2 += QPoint(15,0);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15); p2 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15); p2 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15); p2 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- p1 += QPoint(0,15); p2 += QPoint(0,15);
- QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
- QTest::mouseMove(canvas, p1);
-
- QVERIFY(flickable->contentY() == 0);
- QCOMPARE(point11->pressed(), true);
- QCOMPARE(point12->pressed(), true);
-
- QTest::touchEvent(canvas, device).release(0, p1).release(1, p2);
- QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1);
- QTest::qWait(50);
-
- delete canvas;
-}
-
-// QTBUG-23327
-void tst_QQuickMultiPointTouchArea::invisible()
-{
- QQuickView *canvas = createAndShowView("signalTest.qml");
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickMultiPointTouchArea *area = qobject_cast<QQuickMultiPointTouchArea *>(canvas->rootObject());
- QVERIFY(area != 0);
-
- area->setVisible(false);
-
- QPoint p1(20,100);
- QPoint p2(40,100);
-
- QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
-
- sequence.press(0, p1).press(1, p2).commit();
-
- QCOMPARE(area->property("touchPointPressCount").toInt(), 0);
- QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
- QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
- QCOMPARE(area->property("touchCount").toInt(), 0);
-
- delete canvas;
-}
-
-
-QQuickView *tst_QQuickMultiPointTouchArea::createAndShowView(const QString &file)
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setSource(QUrl::fromLocalFile(QCoreApplication::applicationDirPath() + QLatin1String("/data/") + file));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
-
- return canvas;
-}
-
-QTEST_MAIN(tst_QQuickMultiPointTouchArea)
-
-#include "tst_qquickmultipointtoucharea.moc"
diff --git a/tests/auto/qtquick2/qquickpathview/qquickpathview.pro b/tests/auto/qtquick2/qquickpathview/qquickpathview.pro
deleted file mode 100644
index 027abb60e6..0000000000
--- a/tests/auto/qtquick2/qquickpathview/qquickpathview.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickpathview
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickpathview.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private quick-private widgets testlib
diff --git a/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp b/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp
deleted file mode 100644
index 8ed2ee75a6..0000000000
--- a/tests/auto/qtquick2/qquickpathview/tst_qquickpathview.cpp
+++ /dev/null
@@ -1,1458 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativeincubator.h>
-#include <QtQuick/private/qquickpathview_p.h>
-#include <QtQuick/private/qdeclarativepath_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtDeclarative/private/qdeclarativelistmodel_p.h>
-#include <QtDeclarative/private/qdeclarativevaluetype_p.h>
-#include <QStringListModel>
-#include <QStandardItemModel>
-#include <QFile>
-
-#include "../../shared/util.h"
-#include "../shared/viewtestutil.h"
-#include "../shared/visualtestutil.h"
-
-using namespace QQuickViewTestUtil;
-using namespace QQuickVisualTestUtil;
-
-
-static void initStandardTreeModel(QStandardItemModel *model)
-{
- QStandardItem *item;
- item = new QStandardItem(QLatin1String("Row 1 Item"));
- model->insertRow(0, item);
-
- item = new QStandardItem(QLatin1String("Row 2 Item"));
- item->setCheckable(true);
- model->insertRow(1, item);
-
- QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item"));
- item->setChild(0, childItem);
-
- item = new QStandardItem(QLatin1String("Row 3 Item"));
- item->setIcon(QIcon());
- model->insertRow(2, item);
-}
-
-
-class tst_QQuickPathView : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickPathView();
-
-private slots:
- void initValues();
- void items();
- void dataModel();
- void pathview2();
- void pathview3();
- void insertModel_data();
- void insertModel();
- void removeModel_data();
- void removeModel();
- void moveModel_data();
- void moveModel();
- void path();
- void pathMoved();
- void setCurrentIndex();
- void resetModel();
- void propertyChanges();
- void pathChanges();
- void componentChanges();
- void modelChanges();
- void pathUpdateOnStartChanged();
- void package();
- void emptyModel();
- void closed();
- void pathUpdate();
- void visualDataModel();
- void undefinedPath();
- void mouseDrag();
- void treeModel();
- void changePreferredHighlight();
- void missingPercent();
- void creationContext();
- void currentOffsetOnInsertion();
- void asynchronous();
-};
-
-class TestObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(bool error READ error WRITE setError)
- Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged)
- Q_PROPERTY(int pathItemCount READ pathItemCount NOTIFY pathItemCountChanged)
-
-public:
- TestObject() : QObject(), mError(true), mUseModel(true), mPathItemCount(-1) {}
-
- bool error() const { return mError; }
- void setError(bool err) { mError = err; }
-
- bool useModel() const { return mUseModel; }
- void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); }
-
- int pathItemCount() const { return mPathItemCount; }
- void setPathItemCount(int count) { mPathItemCount = count; emit pathItemCountChanged(); }
-
-signals:
- void useModelChanged();
- void pathItemCountChanged();
-
-private:
- bool mError;
- bool mUseModel;
- int mPathItemCount;
-};
-
-tst_QQuickPathView::tst_QQuickPathView()
-{
-}
-
-void tst_QQuickPathView::initValues()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathview1.qml"));
- QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->path() == 0);
- QVERIFY(obj->delegate() == 0);
- QCOMPARE(obj->model(), QVariant());
- QCOMPARE(obj->currentIndex(), 0);
- QCOMPARE(obj->offset(), 0.);
- QCOMPARE(obj->preferredHighlightBegin(), 0.);
- QCOMPARE(obj->dragMargin(), 0.);
- QCOMPARE(obj->count(), 0);
- QCOMPARE(obj->pathItemCount(), -1);
-
- delete obj;
-}
-
-void tst_QQuickPathView::items()
-{
- QQuickView *canvas = createView();
-
- QaimModel model;
- model.addItem("Fred", "12345");
- model.addItem("John", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("pathview0.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- QCOMPARE(pathview->count(), model.count());
- QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count());
- QCOMPARE(pathview->childItems().count(), model.count()+1); // assumes all are visible, including highlight
-
- for (int i = 0; i < model.count(); ++i) {
- QQuickText *name = findItem<QQuickText>(pathview, "textName", i);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), model.name(i));
- QQuickText *number = findItem<QQuickText>(pathview, "textNumber", i);
- QVERIFY(number != 0);
- QCOMPARE(number->text(), model.number(i));
- }
-
- QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
- QVERIFY(path);
-
- QVERIFY(pathview->highlightItem());
- QPointF start = path->pointAt(0.0);
- QPointF offset;
- offset.setX(pathview->highlightItem()->width()/2);
- offset.setY(pathview->highlightItem()->height()/2);
- QCOMPARE(pathview->highlightItem()->pos() + offset, start);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::pathview2()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathview2.qml"));
- QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->path() != 0);
- QVERIFY(obj->delegate() != 0);
- QVERIFY(obj->model() != QVariant());
- QCOMPARE(obj->currentIndex(), 0);
- QCOMPARE(obj->offset(), 0.);
- QCOMPARE(obj->preferredHighlightBegin(), 0.);
- QCOMPARE(obj->dragMargin(), 0.);
- QCOMPARE(obj->count(), 8);
- QCOMPARE(obj->pathItemCount(), 10);
-
- delete obj;
-}
-
-void tst_QQuickPathView::pathview3()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathview3.qml"));
- QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
-
- QVERIFY(obj != 0);
- QVERIFY(obj->path() != 0);
- QVERIFY(obj->delegate() != 0);
- QVERIFY(obj->model() != QVariant());
- QCOMPARE(obj->currentIndex(), 0);
- QCOMPARE(obj->offset(), 1.0);
- QCOMPARE(obj->preferredHighlightBegin(), 0.5);
- QCOMPARE(obj->dragMargin(), 24.);
- QCOMPARE(obj->count(), 8);
- QCOMPARE(obj->pathItemCount(), 4);
-
- delete obj;
-}
-
-void tst_QQuickPathView::insertModel_data()
-{
- QTest::addColumn<int>("mode");
- QTest::addColumn<int>("idx");
- QTest::addColumn<int>("count");
- QTest::addColumn<qreal>("offset");
-
- // We have 8 items, with currentIndex == 4
- QTest::newRow("insert after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << 5.;
- QTest::newRow("insert before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << 4.;
- QTest::newRow("insert multiple after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << 6.;
- QTest::newRow("insert multiple before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << 4.;
- QTest::newRow("insert at end")
- << int(QQuickPathView::StrictlyEnforceRange) << 8 << 1 << 5.;
- QTest::newRow("insert at beginning")
- << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 4.;
- QTest::newRow("insert at current")
- << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << 4.;
-
- QTest::newRow("no range - insert after current")
- << int(QQuickPathView::NoHighlightRange) << 6 << 1 << 5.;
- QTest::newRow("no range - insert before current")
- << int(QQuickPathView::NoHighlightRange) << 2 << 1 << 4.;
- QTest::newRow("no range - insert multiple after current")
- << int(QQuickPathView::NoHighlightRange) << 5 << 2 << 6.;
- QTest::newRow("no range - insert multiple before current")
- << int(QQuickPathView::NoHighlightRange) << 1 << 2 << 4.;
- QTest::newRow("no range - insert at end")
- << int(QQuickPathView::NoHighlightRange) << 8 << 1 << 5.;
- QTest::newRow("no range - insert at beginning")
- << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 4.;
- QTest::newRow("no range - insert at current")
- << int(QQuickPathView::NoHighlightRange) << 4 << 1 << 4.;
-}
-
-void tst_QQuickPathView::insertModel()
-{
- QFETCH(int, mode);
- QFETCH(int, idx);
- QFETCH(int, count);
- QFETCH(qreal, offset);
-
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- model.addItem("Ben", "12345");
- model.addItem("Bohn", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
- model.addItem("Jinny", "679");
- model.addItem("Milly", "73378");
- model.addItem("Jimmy", "3535");
- model.addItem("Barb", "9039");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("pathview0.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode);
-
- pathview->setCurrentIndex(4);
- if (mode == QQuickPathView::StrictlyEnforceRange)
- QTRY_COMPARE(pathview->offset(), 4.0);
- else
- pathview->setOffset(4);
-
- QList<QPair<QString, QString> > items;
- for (int i = 0; i < count; ++i)
- items.append(qMakePair(QString("New"), QString::number(i)));
-
- model.insertItems(idx, items);
- QTRY_COMPARE(pathview->offset(), offset);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::removeModel_data()
-{
- QTest::addColumn<int>("mode");
- QTest::addColumn<int>("idx");
- QTest::addColumn<int>("count");
- QTest::addColumn<qreal>("offset");
-
- // We have 8 items, with currentIndex == 4
- QTest::newRow("remove after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << 3.;
- QTest::newRow("remove before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << 4.;
- QTest::newRow("remove multiple after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << 2.;
- QTest::newRow("remove multiple before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << 4.;
- QTest::newRow("remove last")
- << int(QQuickPathView::StrictlyEnforceRange) << 7 << 1 << 3.;
- QTest::newRow("remove first")
- << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 4.;
- QTest::newRow("remove current")
- << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << 3.;
-
- QTest::newRow("no range - remove after current")
- << int(QQuickPathView::NoHighlightRange) << 6 << 1 << 3.;
- QTest::newRow("no range - remove before current")
- << int(QQuickPathView::NoHighlightRange) << 2 << 1 << 4.;
- QTest::newRow("no range - remove multiple after current")
- << int(QQuickPathView::NoHighlightRange) << 5 << 2 << 2.;
- QTest::newRow("no range - remove multiple before current")
- << int(QQuickPathView::NoHighlightRange) << 1 << 2 << 4.;
- QTest::newRow("no range - remove last")
- << int(QQuickPathView::NoHighlightRange) << 7 << 1 << 3.;
- QTest::newRow("no range - remove first")
- << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 4.;
- QTest::newRow("no range - remove current offset")
- << int(QQuickPathView::NoHighlightRange) << 4 << 1 << 4.;
-}
-
-void tst_QQuickPathView::removeModel()
-{
- QFETCH(int, mode);
- QFETCH(int, idx);
- QFETCH(int, count);
- QFETCH(qreal, offset);
-
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- model.addItem("Ben", "12345");
- model.addItem("Bohn", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
- model.addItem("Jinny", "679");
- model.addItem("Milly", "73378");
- model.addItem("Jimmy", "3535");
- model.addItem("Barb", "9039");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("pathview0.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode);
-
- pathview->setCurrentIndex(4);
- if (mode == QQuickPathView::StrictlyEnforceRange)
- QTRY_COMPARE(pathview->offset(), 4.0);
- else
- pathview->setOffset(4);
-
- model.removeItems(idx, count);
- QTRY_COMPARE(pathview->offset(), offset);
-
- delete canvas;
-}
-
-
-void tst_QQuickPathView::moveModel_data()
-{
- QTest::addColumn<int>("mode");
- QTest::addColumn<int>("from");
- QTest::addColumn<int>("to");
- QTest::addColumn<int>("count");
- QTest::addColumn<qreal>("offset");
-
- // We have 8 items, with currentIndex == 4
- QTest::newRow("move after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 1 << 4.;
- QTest::newRow("move before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 2 << 3 << 1 << 4.;
- QTest::newRow("move before current to after")
- << int(QQuickPathView::StrictlyEnforceRange) << 2 << 6 << 1 << 5.;
- QTest::newRow("move multiple after current")
- << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 2 << 4.;
- QTest::newRow("move multiple before current")
- << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 2 << 4.;
- QTest::newRow("move before current to end")
- << int(QQuickPathView::StrictlyEnforceRange) << 2 << 7 << 1 << 5.;
- QTest::newRow("move last to beginning")
- << int(QQuickPathView::StrictlyEnforceRange) << 7 << 0 << 1 << 3.;
- QTest::newRow("move current")
- << int(QQuickPathView::StrictlyEnforceRange) << 4 << 6 << 1 << 2.;
-
- QTest::newRow("no range - move after current")
- << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 1 << 4.;
- QTest::newRow("no range - move before current")
- << int(QQuickPathView::NoHighlightRange) << 2 << 3 << 1 << 4.;
- QTest::newRow("no range - move before current to after")
- << int(QQuickPathView::NoHighlightRange) << 2 << 6 << 1 << 5.;
- QTest::newRow("no range - move multiple after current")
- << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 2 << 4.;
- QTest::newRow("no range - move multiple before current")
- << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 2 << 4.;
- QTest::newRow("no range - move before current to end")
- << int(QQuickPathView::NoHighlightRange) << 2 << 7 << 1 << 5.;
- QTest::newRow("no range - move last to beginning")
- << int(QQuickPathView::NoHighlightRange) << 7 << 0 << 1 << 3.;
- QTest::newRow("no range - move current")
- << int(QQuickPathView::NoHighlightRange) << 4 << 6 << 1 << 4.;
- QTest::newRow("no range - move multiple incl. current")
- << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 5 << 4.;
-}
-
-void tst_QQuickPathView::moveModel()
-{
- QFETCH(int, mode);
- QFETCH(int, from);
- QFETCH(int, to);
- QFETCH(int, count);
- QFETCH(qreal, offset);
-
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- model.addItem("Ben", "12345");
- model.addItem("Bohn", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
- model.addItem("Jinny", "679");
- model.addItem("Milly", "73378");
- model.addItem("Jimmy", "3535");
- model.addItem("Barb", "9039");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("pathview0.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode);
-
- pathview->setCurrentIndex(4);
- if (mode == QQuickPathView::StrictlyEnforceRange)
- QTRY_COMPARE(pathview->offset(), 4.0);
- else
- pathview->setOffset(4);
-
- model.moveItems(from, to, count);
- QTRY_COMPARE(pathview->offset(), offset);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::path()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("pathtest.qml"));
- QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
-
- QVERIFY(obj != 0);
- QCOMPARE(obj->startX(), 120.);
- QCOMPARE(obj->startY(), 100.);
- QVERIFY(obj->path() != QPainterPath());
-
- QDeclarativeListReference list(obj, "pathElements");
- QCOMPARE(list.count(), 5);
-
- QDeclarativePathAttribute* attr = qobject_cast<QDeclarativePathAttribute*>(list.at(0));
- QVERIFY(attr != 0);
- QCOMPARE(attr->name(), QString("scale"));
- QCOMPARE(attr->value(), 1.0);
-
- QDeclarativePathQuad* quad = qobject_cast<QDeclarativePathQuad*>(list.at(1));
- QVERIFY(quad != 0);
- QCOMPARE(quad->x(), 120.);
- QCOMPARE(quad->y(), 25.);
- QCOMPARE(quad->controlX(), 260.);
- QCOMPARE(quad->controlY(), 75.);
-
- QDeclarativePathPercent* perc = qobject_cast<QDeclarativePathPercent*>(list.at(2));
- QVERIFY(perc != 0);
- QCOMPARE(perc->value(), 0.3);
-
- QDeclarativePathLine* line = qobject_cast<QDeclarativePathLine*>(list.at(3));
- QVERIFY(line != 0);
- QCOMPARE(line->x(), 120.);
- QCOMPARE(line->y(), 100.);
-
- QDeclarativePathCubic* cubic = qobject_cast<QDeclarativePathCubic*>(list.at(4));
- QVERIFY(cubic != 0);
- QCOMPARE(cubic->x(), 180.);
- QCOMPARE(cubic->y(), 0.);
- QCOMPARE(cubic->control1X(), -10.);
- QCOMPARE(cubic->control1Y(), 90.);
- QCOMPARE(cubic->control2X(), 210.);
- QCOMPARE(cubic->control2Y(), 90.);
-
- delete obj;
-}
-
-void tst_QQuickPathView::dataModel()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- QaimModel model;
- model.addItem("red", "1");
- model.addItem("green", "2");
- model.addItem("blue", "3");
- model.addItem("purple", "4");
- model.addItem("gray", "5");
- model.addItem("brown", "6");
- model.addItem("yellow", "7");
- model.addItem("thistle", "8");
- model.addItem("cyan", "9");
- model.addItem("peachpuff", "10");
- model.addItem("powderblue", "11");
- model.addItem("gold", "12");
- model.addItem("sandybrown", "13");
-
- ctxt->setContextProperty("testData", &model);
-
- canvas->setSource(testFileUrl("datamodel.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- QQuickItem *item = findItem<QQuickItem>(pathview, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->x(), 110.0);
- QCOMPARE(item->y(), 10.0);
-
- model.insertItem(4, "orange", "10");
- QTest::qWait(100);
-
- QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count());
- QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 14);
-
- QVERIFY(pathview->currentIndex() == 0);
- QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 0));
-
- QQuickText *text = findItem<QQuickText>(pathview, "myText", 4);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(4));
-
- model.removeItem(2);
- QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count());
- text = findItem<QQuickText>(pathview, "myText", 2);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(2));
- QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 0));
-
- testObject->setPathItemCount(5);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
-
- QQuickRectangle *testItem = findItem<QQuickRectangle>(pathview, "wrapper", 4);
- QVERIFY(testItem != 0);
- testItem = findItem<QQuickRectangle>(pathview, "wrapper", 5);
- QVERIFY(testItem == 0);
-
- pathview->setCurrentIndex(1);
- QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
- QTest::qWait(100);
-
- model.insertItem(2, "pink", "2");
- QTest::qWait(100);
-
- QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
- QVERIFY(pathview->currentIndex() == 1);
- QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
-
- text = findItem<QQuickText>(pathview, "myText", 2);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(2));
-
- model.removeItem(3);
- QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
- text = findItem<QQuickText>(pathview, "myText", 3);
- QVERIFY(text);
- QCOMPARE(text->text(), model.name(3));
- QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
-
- model.moveItem(3, 5);
- QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
- QList<QQuickItem*> items = findItems<QQuickItem>(pathview, "wrapper");
- foreach (QQuickItem *item, items) {
- QVERIFY(item->property("onPath").toBool());
- }
- QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
-
- // QTBUG-14199
- pathview->setOffset(7);
- pathview->setOffset(0);
- QCOMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
-
- pathview->setCurrentIndex(model.count()-1);
- model.removeItem(model.count()-1);
- QCOMPARE(pathview->currentIndex(), model.count()-1);
-
- delete canvas;
- delete testObject;
-}
-
-void tst_QQuickPathView::pathMoved()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- model.addItem("Ben", "12345");
- model.addItem("Bohn", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("pathview0.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- QQuickRectangle *firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
- QVERIFY(path);
- QPointF start = path->pointAt(0.0);
- QPointF offset;//Center of item is at point, but pos is from corner
- offset.setX(firstItem->width()/2);
- offset.setY(firstItem->height()/2);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- pathview->setOffset(1.0);
-
- for (int i=0; i<model.count(); i++) {
- QQuickRectangle *curItem = findItem<QQuickRectangle>(pathview, "wrapper", i);
- QPointF itemPos(path->pointAt(0.25 + i*0.25));
- QCOMPARE(curItem->pos() + offset, QPointF(itemPos.x(), itemPos.y()));
- }
-
- pathview->setOffset(0.0);
- QCOMPARE(firstItem->pos() + offset, start);
-
- // Change delegate size
- pathview->setOffset(0.1);
- pathview->setOffset(0.0);
- canvas->rootObject()->setProperty("delegateWidth", 30);
- QCOMPARE(firstItem->width(), 30.0);
- offset.setX(firstItem->width()/2);
- QTRY_COMPARE(firstItem->pos() + offset, start);
-
- // Change delegate scale
- pathview->setOffset(0.1);
- pathview->setOffset(0.0);
- canvas->rootObject()->setProperty("delegateScale", 1.2);
- QTRY_COMPARE(firstItem->pos() + offset, start);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::setCurrentIndex()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
- model.addItem("Ben", "12345");
- model.addItem("Bohn", "2345");
- model.addItem("Bob", "54321");
- model.addItem("Bill", "4321");
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("pathview0.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- QQuickRectangle *firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
- QVERIFY(path);
- QPointF start = path->pointAt(0.0);
- QPointF offset;//Center of item is at point, but pos is from corner
- offset.setX(firstItem->width()/2);
- offset.setY(firstItem->height()/2);
- QCOMPARE(firstItem->pos() + offset, start);
- QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 0);
- QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 0);
-
- pathview->setCurrentIndex(2);
-
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 2);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 2);
- QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 2);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(true));
-
- pathview->decrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 1);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 1);
- QVERIFY(firstItem);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(true));
-
- pathview->decrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 0);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(true));
-
- pathview->decrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 3);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 3);
- QVERIFY(firstItem);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(true));
-
- pathview->incrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 0);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(true));
-
- // move an item, set move duration to 0, and change currentIndex to moved item. QTBUG-22786
- model.moveItem(0, 3);
- pathview->setHighlightMoveDuration(0);
- pathview->setCurrentIndex(3);
- QCOMPARE(pathview->currentIndex(), 3);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 3);
- QVERIFY(firstItem);
- QCOMPARE(pathview->currentItem(), firstItem);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- model.moveItem(3, 0);
- pathview->setCurrentIndex(0);
- pathview->setHighlightMoveDuration(300);
-
- // Check the current item is still created when outside the bounds of pathItemCount.
- pathview->setPathItemCount(2);
- pathview->setHighlightRangeMode(QQuickPathView::NoHighlightRange);
- QVERIFY(findItem<QQuickRectangle>(pathview, "wrapper", 0));
- QVERIFY(findItem<QQuickRectangle>(pathview, "wrapper", 1));
- QVERIFY(!findItem<QQuickRectangle>(pathview, "wrapper", 2));
- QVERIFY(!findItem<QQuickRectangle>(pathview, "wrapper", 3));
-
- pathview->setCurrentIndex(2);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 2);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(false));
-
- pathview->decrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 1);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 1);
- QVERIFY(firstItem);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(true));
-
- pathview->decrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 0);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(true));
-
- pathview->decrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 3);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 3);
- QVERIFY(firstItem);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(false));
-
- pathview->incrementCurrentIndex();
- QTRY_COMPARE(pathview->currentIndex(), 0);
- firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QCOMPARE(pathview->currentItem(), firstItem);
- QCOMPARE(firstItem->property("onPath"), QVariant(true));
-
- delete canvas;
-}
-
-void tst_QQuickPathView::resetModel()
-{
- QQuickView *canvas = createView();
-
- QStringList strings;
- strings << "one" << "two" << "three";
- QStringListModel model(strings);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("displaypath.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- QCOMPARE(pathview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QQuickText *display = findItem<QQuickText>(pathview, "displayText", i);
- QVERIFY(display != 0);
- QCOMPARE(display->text(), strings.at(i));
- }
-
- strings.clear();
- strings << "four" << "five" << "six" << "seven";
- model.setStringList(strings);
-
- QCOMPARE(pathview->count(), model.rowCount());
-
- for (int i = 0; i < model.rowCount(); ++i) {
- QQuickText *display = findItem<QQuickText>(pathview, "displayText", i);
- QVERIFY(display != 0);
- QCOMPARE(display->text(), strings.at(i));
- }
-
- delete canvas;
-}
-
-void tst_QQuickPathView::propertyChanges()
-{
- QQuickView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(testFileUrl("propertychanges.qml"));
-
- QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
- QVERIFY(pathView);
-
- QSignalSpy snapPositionSpy(pathView, SIGNAL(preferredHighlightBeginChanged()));
- QSignalSpy dragMarginSpy(pathView, SIGNAL(dragMarginChanged()));
-
- QCOMPARE(pathView->preferredHighlightBegin(), 0.1);
- QCOMPARE(pathView->dragMargin(), 5.0);
-
- pathView->setPreferredHighlightBegin(0.4);
- pathView->setPreferredHighlightEnd(0.4);
- pathView->setDragMargin(20.0);
-
- QCOMPARE(pathView->preferredHighlightBegin(), 0.4);
- QCOMPARE(pathView->preferredHighlightEnd(), 0.4);
- QCOMPARE(pathView->dragMargin(), 20.0);
-
- QCOMPARE(snapPositionSpy.count(), 1);
- QCOMPARE(dragMarginSpy.count(), 1);
-
- pathView->setPreferredHighlightBegin(0.4);
- pathView->setPreferredHighlightEnd(0.4);
- pathView->setDragMargin(20.0);
-
- QCOMPARE(snapPositionSpy.count(), 1);
- QCOMPARE(dragMarginSpy.count(), 1);
- delete canvas;
-}
-
-void tst_QQuickPathView::pathChanges()
-{
- QQuickView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(testFileUrl("propertychanges.qml"));
-
- QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
- QVERIFY(pathView);
-
- QDeclarativePath *path = canvas->rootObject()->findChild<QDeclarativePath*>("path");
- QVERIFY(path);
-
- QSignalSpy startXSpy(path, SIGNAL(startXChanged()));
- QSignalSpy startYSpy(path, SIGNAL(startYChanged()));
-
- QCOMPARE(path->startX(), 220.0);
- QCOMPARE(path->startY(), 200.0);
-
- path->setStartX(240.0);
- path->setStartY(220.0);
-
- QCOMPARE(path->startX(), 240.0);
- QCOMPARE(path->startY(), 220.0);
-
- QCOMPARE(startXSpy.count(),1);
- QCOMPARE(startYSpy.count(),1);
-
- path->setStartX(240);
- path->setStartY(220);
-
- QCOMPARE(startXSpy.count(),1);
- QCOMPARE(startYSpy.count(),1);
-
- QDeclarativePath *alternatePath = canvas->rootObject()->findChild<QDeclarativePath*>("alternatePath");
- QVERIFY(alternatePath);
-
- QSignalSpy pathSpy(pathView, SIGNAL(pathChanged()));
-
- QCOMPARE(pathView->path(), path);
-
- pathView->setPath(alternatePath);
- QCOMPARE(pathView->path(), alternatePath);
- QCOMPARE(pathSpy.count(),1);
-
- pathView->setPath(alternatePath);
- QCOMPARE(pathSpy.count(),1);
-
- QDeclarativePathAttribute *pathAttribute = canvas->rootObject()->findChild<QDeclarativePathAttribute*>("pathAttribute");
- QVERIFY(pathAttribute);
-
- QSignalSpy nameSpy(pathAttribute, SIGNAL(nameChanged()));
- QCOMPARE(pathAttribute->name(), QString("opacity"));
-
- pathAttribute->setName("scale");
- QCOMPARE(pathAttribute->name(), QString("scale"));
- QCOMPARE(nameSpy.count(),1);
-
- pathAttribute->setName("scale");
- QCOMPARE(nameSpy.count(),1);
- delete canvas;
-}
-
-void tst_QQuickPathView::componentChanges()
-{
- QQuickView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(testFileUrl("propertychanges.qml"));
-
- QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
- QVERIFY(pathView);
-
- QDeclarativeComponent delegateComponent(canvas->engine());
- delegateComponent.setData("import QtQuick 2.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
-
- QSignalSpy delegateSpy(pathView, SIGNAL(delegateChanged()));
-
- pathView->setDelegate(&delegateComponent);
- QCOMPARE(pathView->delegate(), &delegateComponent);
- QCOMPARE(delegateSpy.count(),1);
-
- pathView->setDelegate(&delegateComponent);
- QCOMPARE(delegateSpy.count(),1);
- delete canvas;
-}
-
-void tst_QQuickPathView::modelChanges()
-{
- QQuickView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(testFileUrl("propertychanges.qml"));
-
- QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
- QVERIFY(pathView);
-
- QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel");
- QVERIFY(alternateModel);
- QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
- QSignalSpy modelSpy(pathView, SIGNAL(modelChanged()));
-
- pathView->setModel(modelVariant);
- QCOMPARE(pathView->model(), modelVariant);
- QCOMPARE(modelSpy.count(),1);
-
- pathView->setModel(modelVariant);
- QCOMPARE(modelSpy.count(),1);
-
- pathView->setModel(QVariant());
- QCOMPARE(modelSpy.count(),2);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::pathUpdateOnStartChanged()
-{
- QQuickView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(testFileUrl("pathUpdateOnStartChanged.qml"));
-
- QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
- QVERIFY(pathView);
-
- QDeclarativePath *path = canvas->rootObject()->findChild<QDeclarativePath*>("path");
- QVERIFY(path);
- QCOMPARE(path->startX(), 400.0);
- QCOMPARE(path->startY(), 300.0);
-
- QQuickItem *item = findItem<QQuickItem>(pathView, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->x(), path->startX() - item->width() / 2.0);
- QCOMPARE(item->y(), path->startY() - item->height() / 2.0);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::package()
-{
- QQuickView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(testFileUrl("pathview_package.qml"));
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
-
- QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("photoPathView");
- QVERIFY(pathView);
-
-#ifdef Q_OS_MAC
- QSKIP("QTBUG-21590 view does not reliably receive polish without a running animation");
-#endif
-
- QQuickItem *item = findItem<QQuickItem>(pathView, "pathItem");
- QVERIFY(item);
- QVERIFY(item->scale() != 1.0);
-
- delete canvas;
-}
-
-//QTBUG-13017
-void tst_QQuickPathView::emptyModel()
-{
- QQuickView *canvas = createView();
-
- QStringListModel model;
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("emptyModel", &model);
-
- canvas->setSource(testFileUrl("emptymodel.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
-
- QCOMPARE(pathview->offset(), qreal(0.0));
-
- delete canvas;
-}
-
-void tst_QQuickPathView::closed()
-{
- QDeclarativeEngine engine;
-
- {
- QDeclarativeComponent c(&engine, testFileUrl("openPath.qml"));
- QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
- QVERIFY(obj);
- QCOMPARE(obj->isClosed(), false);
- delete obj;
- }
-
- {
- QDeclarativeComponent c(&engine, testFileUrl("closedPath.qml"));
- QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
- QVERIFY(obj);
- QCOMPARE(obj->isClosed(), true);
- delete obj;
- }
-}
-
-// QTBUG-14239
-void tst_QQuickPathView::pathUpdate()
-{
- QQuickView *canvas = createView();
- QVERIFY(canvas);
- canvas->setSource(testFileUrl("pathUpdate.qml"));
-
- QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
- QVERIFY(pathView);
-
- QQuickItem *item = findItem<QQuickItem>(pathView, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->x(), 150.0);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::visualDataModel()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("vdm.qml"));
-
- QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->count(), 3);
-
- delete obj;
-}
-
-void tst_QQuickPathView::undefinedPath()
-{
- QDeclarativeEngine engine;
-
- // QPainterPath warnings are only received if QT_NO_DEBUG is not defined
- if (QLibraryInfo::isDebugBuild()) {
- QString warning1("QPainterPath::moveTo: Adding point where x or y is NaN or Inf, ignoring call");
- QTest::ignoreMessage(QtWarningMsg,qPrintable(warning1));
-
- QString warning2("QPainterPath::lineTo: Adding point where x or y is NaN or Inf, ignoring call");
- QTest::ignoreMessage(QtWarningMsg,qPrintable(warning2));
- }
-
- QDeclarativeComponent c(&engine, testFileUrl("undefinedpath.qml"));
-
- QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->count(), 3);
-
- delete obj;
-}
-
-void tst_QQuickPathView::mouseDrag()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("dragpath.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(canvas, qGuiApp->focusWindow());
-
- QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
-
- int current = pathview->currentIndex();
-
- QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(10,100));
- QTest::qWait(100);
-
- {
- QMouseEvent mv(QEvent::MouseMove, QPoint(30,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(canvas, &mv);
- }
- {
- QMouseEvent mv(QEvent::MouseMove, QPoint(90,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(canvas, &mv);
- }
-
- QVERIFY(pathview->currentIndex() != current);
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(40,100));
-
- delete canvas;
-}
-
-void tst_QQuickPathView::treeModel()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
- canvas->engine()->rootContext()->setContextProperty("myModel", &model);
-
- canvas->setSource(testFileUrl("treemodel.qml"));
-
- QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
- QCOMPARE(pathview->count(), 3);
-
- QQuickText *item = findItem<QQuickText>(pathview, "wrapper", 0);
- QVERIFY(item);
- QCOMPARE(item->text(), QLatin1String("Row 1 Item"));
-
- QVERIFY(QMetaObject::invokeMethod(pathview, "setRoot", Q_ARG(QVariant, 1)));
- QCOMPARE(pathview->count(), 1);
-
- QTRY_VERIFY(item = findItem<QQuickText>(pathview, "wrapper", 0));
- QTRY_COMPARE(item->text(), QLatin1String("Row 2 Child Item"));
-
- delete canvas;
-}
-
-void tst_QQuickPathView::changePreferredHighlight()
-{
- QQuickView *canvas = createView();
- canvas->setGeometry(0,0,400,200);
- canvas->setSource(testFileUrl("dragpath.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_COMPARE(canvas, qGuiApp->focusWindow());
-
- QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
- QVERIFY(pathview != 0);
-
- int current = pathview->currentIndex();
- QCOMPARE(current, 0);
-
- QQuickRectangle *firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
- QVERIFY(path);
- QPointF start = path->pointAt(0.5);
- QPointF offset;//Center of item is at point, but pos is from corner
- offset.setX(firstItem->width()/2);
- offset.setY(firstItem->height()/2);
- QTRY_COMPARE(firstItem->pos() + offset, start);
-
- pathview->setPreferredHighlightBegin(0.8);
- pathview->setPreferredHighlightEnd(0.8);
- start = path->pointAt(0.8);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- QCOMPARE(pathview->currentIndex(), 0);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::creationContext()
-{
- QQuickView canvas;
- canvas.setGeometry(0,0,240,320);
- canvas.setSource(testFileUrl("creationContext.qml"));
-
- QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
- QVERIFY(rootItem);
- QVERIFY(rootItem->property("count").toInt() > 0);
-
- QQuickItem *item;
- QVERIFY(item = findItem<QQuickItem>(rootItem, "listItem", 0));
- QCOMPARE(item->property("text").toString(), QString("Hello!"));
-}
-
-// QTBUG-21320
-void tst_QQuickPathView::currentOffsetOnInsertion()
-{
- QQuickView *canvas = createView();
- canvas->show();
-
- QaimModel model;
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testModel", &model);
-
- canvas->setSource(testFileUrl("pathline.qml"));
- qApp->processEvents();
-
- QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
- QVERIFY(pathview != 0);
-
- pathview->setPreferredHighlightBegin(0.5);
- pathview->setPreferredHighlightEnd(0.5);
-
- QCOMPARE(pathview->count(), model.count());
-
- model.addItem("item0", "0");
-
- QCOMPARE(pathview->count(), model.count());
-
- QQuickRectangle *item = 0;
- QTRY_VERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 0));
-
- QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
- QVERIFY(path);
-
- QPointF start = path->pointAt(0.5);
- QPointF offset;//Center of item is at point, but pos is from corner
- offset.setX(item->width()/2);
- offset.setY(item->height()/2);
- QCOMPARE(item->pos() + offset, start);
-
- QSignalSpy currentIndexSpy(pathview, SIGNAL(currentIndexChanged()));
-
- // insert an item at the beginning
- model.insertItem(0, "item1", "1");
- qApp->processEvents();
-
- QCOMPARE(currentIndexSpy.count(), 1);
-
- // currentIndex is now 1
- QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 1));
-
- // verify that current item (item 1) is still at offset 0.5
- QCOMPARE(item->pos() + offset, start);
-
- // insert another item at the beginning
- model.insertItem(0, "item2", "2");
- qApp->processEvents();
-
- QCOMPARE(currentIndexSpy.count(), 2);
-
- // currentIndex is now 2
- QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 2));
-
- // verify that current item (item 2) is still at offset 0.5
- QCOMPARE(item->pos() + offset, start);
-
- // verify that remove before current maintains current item
- model.removeItem(0);
- qApp->processEvents();
-
- QCOMPARE(currentIndexSpy.count(), 3);
-
- // currentIndex is now 1
- QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 1));
-
- // verify that current item (item 1) is still at offset 0.5
- QCOMPARE(item->pos() + offset, start);
-
- delete canvas;
-}
-
-void tst_QQuickPathView::asynchronous()
-{
- QQuickView *canvas = createView();
- canvas->show();
- QDeclarativeIncubationController controller;
- canvas->engine()->setIncubationController(&controller);
-
- canvas->setSource(testFileUrl("asyncloader.qml"));
-
- QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootObject);
-
- QQuickPathView *pathview = 0;
- while (!pathview) {
- bool b = false;
- controller.incubateWhile(&b);
- pathview = rootObject->findChild<QQuickPathView*>("view");
- }
-
- // items will be created one at a time
- for (int i = 0; i < 5; ++i) {
- QVERIFY(findItem<QQuickItem>(pathview, "wrapper", i) == 0);
- QQuickItem *item = 0;
- while (!item) {
- bool b = false;
- controller.incubateWhile(&b);
- item = findItem<QQuickItem>(pathview, "wrapper", i);
- }
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- // verify positioning
- QQuickRectangle *firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
- QVERIFY(firstItem);
- QDeclarativePath *path = qobject_cast<QDeclarativePath*>(pathview->path());
- QVERIFY(path);
- QPointF start = path->pointAt(0.0);
- QPointF offset;//Center of item is at point, but pos is from corner
- offset.setX(firstItem->width()/2);
- offset.setY(firstItem->height()/2);
- QTRY_COMPARE(firstItem->pos() + offset, start);
- pathview->setOffset(1.0);
-
- for (int i=0; i<5; i++) {
- QQuickItem *curItem = findItem<QQuickItem>(pathview, "wrapper", i);
- QPointF itemPos(path->pointAt(0.2 + i*0.2));
- QCOMPARE(curItem->pos() + offset, itemPos);
- }
-
- delete canvas;
-}
-
-void tst_QQuickPathView::missingPercent()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("missingPercent.qml"));
- QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
- QVERIFY(obj);
- QCOMPARE(obj->attributeAt("_qfx_percent", 1.0), qreal(1.0));
- delete obj;
-}
-
-QTEST_MAIN(tst_QQuickPathView)
-
-#include "tst_qquickpathview.moc"
diff --git a/tests/auto/qtquick2/qquickpincharea/qquickpincharea.pro b/tests/auto/qtquick2/qquickpincharea/qquickpincharea.pro
deleted file mode 100644
index 3c75079ca5..0000000000
--- a/tests/auto/qtquick2/qquickpincharea/qquickpincharea.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickpincharea
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickpincharea.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp b/tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp
deleted file mode 100644
index e1eaa7879e..0000000000
--- a/tests/auto/qtquick2/qquickpincharea/tst_qquickpincharea.cpp
+++ /dev/null
@@ -1,404 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <private/qquickpincharea_p.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include "../../shared/util.h"
-
-class tst_QQuickPinchArea: public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickPinchArea() : device(0) { }
-private slots:
- void initTestCase();
- void cleanupTestCase();
- void pinchProperties();
- void scale();
- void pan();
- void retouch();
-
-private:
- QQuickView *createView();
- QTouchDevice *device;
-};
-void tst_QQuickPinchArea::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- if (!device) {
- device = new QTouchDevice;
- device->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(device);
- }
-}
-
-void tst_QQuickPinchArea::cleanupTestCase()
-{
-
-}
-void tst_QQuickPinchArea::pinchProperties()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("pinchproperties.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pincharea");
- QQuickPinch *pinch = pinchArea->pinch();
- QVERIFY(pinchArea != 0);
- QVERIFY(pinch != 0);
-
- // target
- QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
- QVERIFY(blackRect != 0);
- QVERIFY(blackRect == pinch->target());
- QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootItem != 0);
- QSignalSpy targetSpy(pinch, SIGNAL(targetChanged()));
- pinch->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
- pinch->setTarget(rootItem);
- QCOMPARE(targetSpy.count(),1);
-
- // axis
- QCOMPARE(pinch->axis(), QQuickPinch::XandYAxis);
- QSignalSpy axisSpy(pinch, SIGNAL(dragAxisChanged()));
- pinch->setAxis(QQuickPinch::XAxis);
- QCOMPARE(pinch->axis(), QQuickPinch::XAxis);
- QCOMPARE(axisSpy.count(),1);
- pinch->setAxis(QQuickPinch::XAxis);
- QCOMPARE(axisSpy.count(),1);
-
- // minimum and maximum drag properties
- QSignalSpy xminSpy(pinch, SIGNAL(minimumXChanged()));
- QSignalSpy xmaxSpy(pinch, SIGNAL(maximumXChanged()));
- QSignalSpy yminSpy(pinch, SIGNAL(minimumYChanged()));
- QSignalSpy ymaxSpy(pinch, SIGNAL(maximumYChanged()));
-
- QCOMPARE(pinch->xmin(), 0.0);
- QCOMPARE(pinch->xmax(), rootItem->width()-blackRect->width());
- QCOMPARE(pinch->ymin(), 0.0);
- QCOMPARE(pinch->ymax(), rootItem->height()-blackRect->height());
-
- pinch->setXmin(10);
- pinch->setXmax(10);
- pinch->setYmin(10);
- pinch->setYmax(10);
-
- QCOMPARE(pinch->xmin(), 10.0);
- QCOMPARE(pinch->xmax(), 10.0);
- QCOMPARE(pinch->ymin(), 10.0);
- QCOMPARE(pinch->ymax(), 10.0);
-
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
-
- pinch->setXmin(10);
- pinch->setXmax(10);
- pinch->setYmin(10);
- pinch->setYmax(10);
-
- QCOMPARE(xminSpy.count(),1);
- QCOMPARE(xmaxSpy.count(),1);
- QCOMPARE(yminSpy.count(),1);
- QCOMPARE(ymaxSpy.count(),1);
-
- // minimum and maximum scale properties
- QSignalSpy scaleMinSpy(pinch, SIGNAL(minimumScaleChanged()));
- QSignalSpy scaleMaxSpy(pinch, SIGNAL(maximumScaleChanged()));
-
- QCOMPARE(pinch->minimumScale(), 1.0);
- QCOMPARE(pinch->maximumScale(), 2.0);
-
- pinch->setMinimumScale(0.5);
- pinch->setMaximumScale(1.5);
-
- QCOMPARE(pinch->minimumScale(), 0.5);
- QCOMPARE(pinch->maximumScale(), 1.5);
-
- QCOMPARE(scaleMinSpy.count(),1);
- QCOMPARE(scaleMaxSpy.count(),1);
-
- pinch->setMinimumScale(0.5);
- pinch->setMaximumScale(1.5);
-
- QCOMPARE(scaleMinSpy.count(),1);
- QCOMPARE(scaleMaxSpy.count(),1);
-
- // minimum and maximum rotation properties
- QSignalSpy rotMinSpy(pinch, SIGNAL(minimumRotationChanged()));
- QSignalSpy rotMaxSpy(pinch, SIGNAL(maximumRotationChanged()));
-
- QCOMPARE(pinch->minimumRotation(), 0.0);
- QCOMPARE(pinch->maximumRotation(), 90.0);
-
- pinch->setMinimumRotation(-90.0);
- pinch->setMaximumRotation(45.0);
-
- QCOMPARE(pinch->minimumRotation(), -90.0);
- QCOMPARE(pinch->maximumRotation(), 45.0);
-
- QCOMPARE(rotMinSpy.count(),1);
- QCOMPARE(rotMaxSpy.count(),1);
-
- pinch->setMinimumRotation(-90.0);
- pinch->setMaximumRotation(45.0);
-
- QCOMPARE(rotMinSpy.count(),1);
- QCOMPARE(rotMaxSpy.count(),1);
-
- delete canvas;
-}
-
-QTouchEvent::TouchPoint makeTouchPoint(int id, QPoint p, QQuickView *v, QQuickItem *i)
-{
- QTouchEvent::TouchPoint touchPoint(id);
- touchPoint.setPos(i->mapFromScene(p));
- touchPoint.setScreenPos(v->mapToGlobal(p));
- touchPoint.setScenePos(p);
- return touchPoint;
-}
-
-void tst_QQuickPinchArea::scale()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("pinchproperties.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QVERIFY(canvas->rootObject() != 0);
- qApp->processEvents();
-
- QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pincharea");
- QQuickPinch *pinch = pinchArea->pinch();
- QVERIFY(pinchArea != 0);
- QVERIFY(pinch != 0);
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root != 0);
-
- // target
- QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
- QVERIFY(blackRect != 0);
-
- QPoint p1(80, 80);
- QPoint p2(100, 100);
-
- QTest::touchEvent(canvas, device).press(0, p1, canvas);
- QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
- p1 -= QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(canvas, device).move(0, p1,canvas).move(1, p2,canvas);
-
- QCOMPARE(root->property("scale").toReal(), 1.0);
-
- p1 -= QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(canvas, device).move(0, p1,canvas).move(1, p2,canvas);
-
- QCOMPARE(root->property("scale").toReal(), 1.5);
- QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50
- QCOMPARE(blackRect->scale(), 1.5);
-
- // scale beyond bound
- p1 -= QPoint(50,50);
- p2 += QPoint(50,50);
- QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(blackRect->scale(), 2.0);
-
- QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas);
-
- delete canvas;
-}
-
-void tst_QQuickPinchArea::pan()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("pinchproperties.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QVERIFY(canvas->rootObject() != 0);
- qApp->processEvents();
-
- QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pincharea");
- QQuickPinch *pinch = pinchArea->pinch();
- QVERIFY(pinchArea != 0);
- QVERIFY(pinch != 0);
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root != 0);
-
- // target
- QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
- QVERIFY(blackRect != 0);
-
- QPoint p1(80, 80);
- QPoint p2(100, 100);
-
- QTest::touchEvent(canvas, device).press(0, p1, canvas);
- QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
- p1 += QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(root->property("scale").toReal(), 1.0);
-
- p1 += QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(root->property("center").toPointF(), QPointF(60, 60)); // blackrect is at 50,50
-
- QCOMPARE(blackRect->x(), 60.0);
- QCOMPARE(blackRect->y(), 60.0);
-
- // pan x beyond bound
- p1 += QPoint(100,100);
- p2 += QPoint(100,100);
- QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(blackRect->x(), 140.0);
- QCOMPARE(blackRect->y(), 160.0);
-
- QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas);
-
- delete canvas;
-}
-
-// test pinch, release one point, touch again to continue pinch
-void tst_QQuickPinchArea::retouch()
-{
- QQuickView *canvas = createView();
- canvas->setSource(testFileUrl("pinchproperties.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QVERIFY(canvas->rootObject() != 0);
- qApp->processEvents();
-
- QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pincharea");
- QQuickPinch *pinch = pinchArea->pinch();
- QVERIFY(pinchArea != 0);
- QVERIFY(pinch != 0);
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root != 0);
-
- QSignalSpy startedSpy(pinchArea, SIGNAL(pinchStarted(QQuickPinchEvent *)));
- QSignalSpy finishedSpy(pinchArea, SIGNAL(pinchFinished(QQuickPinchEvent *)));
-
- // target
- QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
- QVERIFY(blackRect != 0);
-
- QPoint p1(80, 80);
- QPoint p2(100, 100);
-
- QTest::touchEvent(canvas, device).press(0, p1, canvas);
- QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
- p1 -= QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(root->property("scale").toReal(), 1.0);
-
- p1 -= QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
-
- QCOMPARE(startedSpy.count(), 1);
-
- QCOMPARE(root->property("scale").toReal(), 1.5);
- QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50
- QCOMPARE(blackRect->scale(), 1.5);
-
- QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 2);
-
- QCOMPARE(startedSpy.count(), 1);
- QCOMPARE(finishedSpy.count(), 0);
-
- QTest::touchEvent(canvas, device).stationary(0).release(1, p2, canvas);
-
- QCOMPARE(startedSpy.count(), 1);
- QCOMPARE(finishedSpy.count(), 0);
-
- QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 1);
-
- QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
- p1 -= QPoint(10,10);
- p2 += QPoint(10,10);
- QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
-
- // Lifting and retouching results in onPinchStarted being called again
- QCOMPARE(startedSpy.count(), 2);
- QCOMPARE(finishedSpy.count(), 0);
-
- QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 2);
-
- QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas);
-
- QCOMPARE(startedSpy.count(), 2);
- QCOMPARE(finishedSpy.count(), 1);
-
- delete canvas;
-}
-
-
-QQuickView *tst_QQuickPinchArea::createView()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
-
- return canvas;
-}
-
-QTEST_MAIN(tst_QQuickPinchArea)
-
-#include "tst_qquickpincharea.moc"
diff --git a/tests/auto/qtquick2/qquickpositioners/qquickpositioners.pro b/tests/auto/qtquick2/qquickpositioners/qquickpositioners.pro
deleted file mode 100644
index ec0056f8e9..0000000000
--- a/tests/auto/qtquick2/qquickpositioners/qquickpositioners.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickpositioners
-SOURCES += tst_qquickpositioners.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
diff --git a/tests/auto/qtquick2/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/qtquick2/qquickpositioners/tst_qquickpositioners.cpp
deleted file mode 100644
index 4c903ab704..0000000000
--- a/tests/auto/qtquick2/qquickpositioners/tst_qquickpositioners.cpp
+++ /dev/null
@@ -1,1472 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include <private/qlistmodelinterface_p.h>
-#include <QtQuick/qquickview.h>
-#include <qdeclarativeengine.h>
-#include <QtQuick/private/qquickrectangle_p.h>
-#include <QtQuick/private/qquickpositioners_p.h>
-#include <QtQuick/private/qdeclarativetransition_p.h>
-#include <private/qquickitem_p.h>
-#include <qdeclarativeexpression.h>
-#include "../../shared/util.h"
-
-class tst_qquickpositioners : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquickpositioners();
-
-private slots:
- void test_horizontal();
- void test_horizontal_rtl();
- void test_horizontal_spacing();
- void test_horizontal_spacing_rightToLeft();
- void test_horizontal_animated();
- void test_horizontal_animated_rightToLeft();
- void test_horizontal_animated_disabled();
- void test_vertical();
- void test_vertical_spacing();
- void test_vertical_animated();
- void test_grid();
- void test_grid_topToBottom();
- void test_grid_rightToLeft();
- void test_grid_spacing();
- void test_grid_row_column_spacing();
- void test_grid_animated();
- void test_grid_animated_rightToLeft();
- void test_grid_zero_columns();
- void test_propertychanges();
- void test_repeater();
- void test_flow();
- void test_flow_rightToLeft();
- void test_flow_topToBottom();
- void test_flow_resize();
- void test_flow_resize_rightToLeft();
- void test_flow_implicit_resize();
- void test_conflictinganchors();
- void test_mirroring();
- void test_allInvisible();
- void test_attachedproperties();
- void test_attachedproperties_data();
- void test_attachedproperties_dynamic();
-
-private:
- QQuickView *createView(const QString &filename, bool wait=true);
-};
-
-tst_qquickpositioners::tst_qquickpositioners()
-{
-}
-
-void tst_qquickpositioners::test_horizontal()
-{
- QQuickView *canvas = createView(testFile("horizontal.qml"));
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 70.0);
- QCOMPARE(three->y(), 0.0);
-
- QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
- QCOMPARE(row->width(), 110.0);
- QCOMPARE(row->height(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_horizontal_rtl()
-{
- QQuickView *canvas = createView(testFile("horizontal.qml"));
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 60.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 40.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 0.0);
-
- QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
- QCOMPARE(row->width(), 110.0);
- QCOMPARE(row->height(), 50.0);
-
- // Change the width of the row and check that items stay to the right
- row->setWidth(200);
- QTRY_COMPARE(one->x(), 150.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 130.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 90.0);
- QCOMPARE(three->y(), 0.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_horizontal_spacing()
-{
- QQuickView *canvas = createView(testFile("horizontal-spacing.qml"));
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 60.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 90.0);
- QCOMPARE(three->y(), 0.0);
-
- QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
- QCOMPARE(row->width(), 130.0);
- QCOMPARE(row->height(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_horizontal_spacing_rightToLeft()
-{
- QQuickView *canvas = createView(testFile("horizontal-spacing.qml"));
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 80.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 00.0);
- QCOMPARE(three->y(), 0.0);
-
- QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
- QCOMPARE(row->width(), 130.0);
- QCOMPARE(row->height(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_horizontal_animated()
-{
- QQuickView *canvas = createView(testFile("horizontal-animated.qml"), false);
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- //Note that they animate in
- QCOMPARE(one->x(), -100.0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(three->x(), -100.0);
-
- QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
-
- QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
- QVERIFY(row);
- QCOMPARE(row->width(), 100.0);
- QCOMPARE(row->height(), 50.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(two->isVisible(), false);
- QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
- QTRY_COMPARE(two->y(), 0.0);
- QTRY_COMPARE(three->x(), 50.0);
- QTRY_COMPARE(three->y(), 0.0);
-
- //Add 'two'
- two->setVisible(true);
- QTRY_COMPARE(two->isVisible(), true);
- QTRY_COMPARE(row->width(), 150.0);
- QTRY_COMPARE(row->height(), 50.0);
-
- QTest::qWait(0);//Let the animation start
- QVERIFY(two->x() >= -100.0 && two->x() < 50.0);
- QVERIFY(three->x() >= 50.0 && three->x() < 100.0);
-
- QTRY_COMPARE(two->x(), 50.0);
- QTRY_COMPARE(three->x(), 100.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_horizontal_animated_rightToLeft()
-{
- QQuickView *canvas = createView(testFile("horizontal-animated.qml"), false);
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- //Note that they animate in
- QCOMPARE(one->x(), -100.0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(three->x(), -100.0);
-
- QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
-
- QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
- QVERIFY(row);
- QCOMPARE(row->width(), 100.0);
- QCOMPARE(row->height(), 50.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->x(), 50.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(two->isVisible(), false);
- QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
- QTRY_COMPARE(two->y(), 0.0);
- QTRY_COMPARE(three->x(), 0.0);
- QTRY_COMPARE(three->y(), 0.0);
-
- //Add 'two'
- two->setVisible(true);
- QTRY_COMPARE(two->isVisible(), true);
-
- // New size should propagate after visible change
- QTRY_COMPARE(row->width(), 150.0);
- QTRY_COMPARE(row->height(), 50.0);
-
- QTest::qWait(0);//Let the animation start
- QVERIFY(one->x() >= 50.0 && one->x() < 100);
- QVERIFY(two->x() >= -100.0 && two->x() < 50.0);
-
- QTRY_COMPARE(one->x(), 100.0);
- QTRY_COMPARE(two->x(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_horizontal_animated_disabled()
-{
- QQuickView *canvas = createView(testFile("horizontal-animated-disabled.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
- QVERIFY(row);
-
- qApp->processEvents();
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->isVisible(), false);
- QCOMPARE(two->x(), -100.0);//Not 'in' yet
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 0.0);
-
- //Add 'two'
- two->setVisible(true);
- QCOMPARE(two->isVisible(), true);
- QTRY_COMPARE(row->width(), 150.0);
- QTRY_COMPARE(row->height(), 50.0);
-
- QTRY_COMPARE(two->x(), 50.0);
- QTRY_COMPARE(three->x(), 100.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_vertical()
-{
- QQuickView *canvas = createView(testFile("vertical.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("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);
-
- QQuickItem *column = canvas->rootObject()->findChild<QQuickItem*>("column");
- QVERIFY(column);
- QCOMPARE(column->height(), 80.0);
- QCOMPARE(column->width(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_vertical_spacing()
-{
- QQuickView *canvas = createView(testFile("vertical-spacing.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 0.0);
- QCOMPARE(two->y(), 60.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 80.0);
-
- QQuickItem *column = canvas->rootObject()->findChild<QQuickItem*>("column");
- QCOMPARE(column->height(), 100.0);
- QCOMPARE(column->width(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_vertical_animated()
-{
- QQuickView *canvas = createView(testFile("vertical-animated.qml"), false);
-
- //Note that they animate in
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QCOMPARE(one->y(), -100.0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QCOMPARE(two->y(), -100.0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QCOMPARE(three->y(), -100.0);
-
- QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
-
- QQuickItem *column = canvas->rootObject()->findChild<QQuickItem*>("column");
- QVERIFY(column);
- QCOMPARE(column->height(), 100.0);
- QCOMPARE(column->width(), 50.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(two->isVisible(), false);
- QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet
- QTRY_COMPARE(two->x(), 0.0);
- QTRY_COMPARE(three->y(), 50.0);
- QTRY_COMPARE(three->x(), 0.0);
-
- //Add 'two'
- two->setVisible(true);
- QTRY_COMPARE(two->isVisible(), true);
- QTRY_COMPARE(column->height(), 150.0);
- QTRY_COMPARE(column->width(), 50.0);
- QTest::qWait(0);//Let the animation start
- QVERIFY(two->y() >= -100.0 && two->y() < 50.0);
- QVERIFY(three->y() >= 50.0 && three->y() < 100.0);
-
- QTRY_COMPARE(two->y(), 50.0);
- QTRY_COMPARE(three->y(), 100.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_grid()
-{
- QQuickView *canvas = createView(testFile("gridtest.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 70.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 50.0);
- QCOMPARE(five->y(), 50.0);
-
- QQuickGrid *grid = canvas->rootObject()->findChild<QQuickGrid*>("grid");
- QCOMPARE(grid->flow(), QQuickGrid::LeftToRight);
- QCOMPARE(grid->width(), 100.0);
- QCOMPARE(grid->height(), 100.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_grid_topToBottom()
-{
- QQuickView *canvas = createView(testFile("grid-toptobottom.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 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(), 100.0);
- QCOMPARE(four->x(), 50.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 50.0);
- QCOMPARE(five->y(), 50.0);
-
- QQuickGrid *grid = canvas->rootObject()->findChild<QQuickGrid*>("grid");
- QCOMPARE(grid->flow(), QQuickGrid::TopToBottom);
- QCOMPARE(grid->width(), 100.0);
- QCOMPARE(grid->height(), 120.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_grid_rightToLeft()
-{
- QQuickView *canvas = createView(testFile("gridtest.qml"));
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 50.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 30.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 50.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 40.0);
- QCOMPARE(five->y(), 50.0);
-
- QQuickGrid *grid = canvas->rootObject()->findChild<QQuickGrid*>("grid");
- QCOMPARE(grid->layoutDirection(), Qt::RightToLeft);
- QCOMPARE(grid->width(), 100.0);
- QCOMPARE(grid->height(), 100.0);
-
- // Change the width of the grid and check that items stay to the right
- grid->setWidth(200);
- QTRY_COMPARE(one->x(), 150.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 130.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 100.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 150.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 140.0);
- QCOMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_grid_spacing()
-{
- QQuickView *canvas = createView(testFile("grid-spacing.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 54.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 78.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 54.0);
- QCOMPARE(five->x(), 54.0);
- QCOMPARE(five->y(), 54.0);
-
- QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
- QCOMPARE(grid->width(), 128.0);
- QCOMPARE(grid->height(), 104.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_grid_row_column_spacing()
-{
- QQuickView *canvas = createView(testFile("grid-row-column-spacing.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 61.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 92.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 57.0);
- QCOMPARE(five->x(), 61.0);
- QCOMPARE(five->y(), 57.0);
-
- QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
- QCOMPARE(grid->width(), 142.0);
- QCOMPARE(grid->height(), 107.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_grid_animated()
-{
- QQuickView *canvas = createView(testFile("grid-animated.qml"), false);
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- //Note that all animate in
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QCOMPARE(one->x(), -100.0);
- QCOMPARE(one->y(), -100.0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(two->y(), -100.0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QCOMPARE(three->x(), -100.0);
- QCOMPARE(three->y(), -100.0);
-
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QCOMPARE(four->x(), -100.0);
- QCOMPARE(four->y(), -100.0);
-
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
- QCOMPARE(five->x(), -100.0);
- QCOMPARE(five->y(), -100.0);
-
- QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
-
- QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
- QVERIFY(grid);
- QCOMPARE(grid->width(), 150.0);
- QCOMPARE(grid->height(), 100.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(two->isVisible(), false);
- QTRY_COMPARE(two->y(), -100.0);
- QTRY_COMPARE(two->x(), -100.0);
- QTRY_COMPARE(three->y(), 0.0);
- QTRY_COMPARE(three->x(), 50.0);
- QTRY_COMPARE(four->y(), 0.0);
- QTRY_COMPARE(four->x(), 100.0);
- QTRY_COMPARE(five->y(), 50.0);
- QTRY_COMPARE(five->x(), 0.0);
-
- //Add 'two'
- two->setVisible(true);
- QCOMPARE(two->isVisible(), true);
- QCOMPARE(grid->width(), 150.0);
- QCOMPARE(grid->height(), 100.0);
- QTest::qWait(0);//Let the animation start
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(two->y(), -100.0);
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 100.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 0.0);
- QCOMPARE(five->y(), 50.0);
- //Let the animation complete
- QTRY_COMPARE(two->x(), 50.0);
- QTRY_COMPARE(two->y(), 0.0);
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(three->x(), 100.0);
- QTRY_COMPARE(three->y(), 0.0);
- QTRY_COMPARE(four->x(), 0.0);
- QTRY_COMPARE(four->y(), 50.0);
- QTRY_COMPARE(five->x(), 50.0);
- QTRY_COMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_grid_animated_rightToLeft()
-{
- QQuickView *canvas = createView(testFile("grid-animated.qml"), false);
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- //Note that all animate in
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QCOMPARE(one->x(), -100.0);
- QCOMPARE(one->y(), -100.0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(two->y(), -100.0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QCOMPARE(three->x(), -100.0);
- QCOMPARE(three->y(), -100.0);
-
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QCOMPARE(four->x(), -100.0);
- QCOMPARE(four->y(), -100.0);
-
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
- QCOMPARE(five->x(), -100.0);
- QCOMPARE(five->y(), -100.0);
-
- QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
-
- QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
- QVERIFY(grid);
- QCOMPARE(grid->width(), 150.0);
- QCOMPARE(grid->height(), 100.0);
-
- //QTRY_COMPARE used instead of waiting for the expected time of animation completion
- //Note that this means the duration of the animation is NOT tested
-
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(one->x(), 100.0);
- QTRY_COMPARE(two->isVisible(), false);
- QTRY_COMPARE(two->y(), -100.0);
- QTRY_COMPARE(two->x(), -100.0);
- QTRY_COMPARE(three->y(), 0.0);
- QTRY_COMPARE(three->x(), 50.0);
- QTRY_COMPARE(four->y(), 0.0);
- QTRY_COMPARE(four->x(), 0.0);
- QTRY_COMPARE(five->y(), 50.0);
- QTRY_COMPARE(five->x(), 100.0);
-
- //Add 'two'
- two->setVisible(true);
- QCOMPARE(two->isVisible(), true);
- QCOMPARE(grid->width(), 150.0);
- QCOMPARE(grid->height(), 100.0);
- QTest::qWait(0);//Let the animation start
- QCOMPARE(two->x(), -100.0);
- QCOMPARE(two->y(), -100.0);
- QCOMPARE(one->x(), 100.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 100.0);
- QCOMPARE(five->y(), 50.0);
- //Let the animation complete
- QTRY_COMPARE(two->x(), 50.0);
- QTRY_COMPARE(two->y(), 0.0);
- QTRY_COMPARE(one->x(), 100.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(three->x(), 0.0);
- QTRY_COMPARE(three->y(), 0.0);
- QTRY_COMPARE(four->x(), 100.0);
- QTRY_COMPARE(four->y(), 50.0);
- QTRY_COMPARE(five->x(), 50.0);
- QTRY_COMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_grid_zero_columns()
-{
- QQuickView *canvas = createView(testFile("gridzerocolumns.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 70.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 120.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 0.0);
- QCOMPARE(five->y(), 50.0);
-
- QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
- QCOMPARE(grid->width(), 170.0);
- QCOMPARE(grid->height(), 60.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_propertychanges()
-{
- QQuickView *canvas = createView(testFile("propertychangestest.qml"));
-
- QQuickGrid *grid = qobject_cast<QQuickGrid*>(canvas->rootObject());
- QVERIFY(grid != 0);
- QDeclarativeTransition *rowTransition = canvas->rootObject()->findChild<QDeclarativeTransition*>("rowTransition");
- QDeclarativeTransition *columnTransition = canvas->rootObject()->findChild<QDeclarativeTransition*>("columnTransition");
-
- QSignalSpy addSpy(grid, SIGNAL(addChanged()));
- QSignalSpy moveSpy(grid, SIGNAL(moveChanged()));
- QSignalSpy columnsSpy(grid, SIGNAL(columnsChanged()));
- QSignalSpy rowsSpy(grid, SIGNAL(rowsChanged()));
-
- QVERIFY(grid);
- QVERIFY(rowTransition);
- QVERIFY(columnTransition);
- QCOMPARE(grid->add(), columnTransition);
- QCOMPARE(grid->move(), columnTransition);
- QCOMPARE(grid->columns(), 4);
- QCOMPARE(grid->rows(), -1);
-
- grid->setAdd(rowTransition);
- grid->setMove(rowTransition);
- QCOMPARE(grid->add(), rowTransition);
- QCOMPARE(grid->move(), rowTransition);
- QCOMPARE(addSpy.count(),1);
- QCOMPARE(moveSpy.count(),1);
-
- grid->setAdd(rowTransition);
- grid->setMove(rowTransition);
- QCOMPARE(addSpy.count(),1);
- QCOMPARE(moveSpy.count(),1);
-
- grid->setAdd(0);
- grid->setMove(0);
- QCOMPARE(addSpy.count(),2);
- QCOMPARE(moveSpy.count(),2);
-
- grid->setColumns(-1);
- grid->setRows(3);
- QCOMPARE(grid->columns(), -1);
- QCOMPARE(grid->rows(), 3);
- QCOMPARE(columnsSpy.count(),1);
- QCOMPARE(rowsSpy.count(),1);
-
- grid->setColumns(-1);
- grid->setRows(3);
- QCOMPARE(columnsSpy.count(),1);
- QCOMPARE(rowsSpy.count(),1);
-
- grid->setColumns(2);
- grid->setRows(2);
- QCOMPARE(columnsSpy.count(),2);
- QCOMPARE(rowsSpy.count(),2);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_repeater()
-{
- QQuickView *canvas = createView(testFile("repeatertest.qml"));
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
-
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
-
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 100.0);
- QCOMPARE(three->y(), 0.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_flow()
-{
- QQuickView *canvas = createView(testFile("flowtest.qml"));
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 0.0);
- QCOMPARE(three->y(), 50.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 70.0);
- QCOMPARE(five->x(), 50.0);
- QCOMPARE(five->y(), 70.0);
-
- QQuickItem *flow = canvas->rootObject()->findChild<QQuickItem*>("flow");
- QVERIFY(flow);
- QCOMPARE(flow->width(), 90.0);
- QCOMPARE(flow->height(), 120.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_flow_rightToLeft()
-{
- QQuickView *canvas = createView(testFile("flowtest.qml"));
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 40.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 20.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 40.0);
- QCOMPARE(three->y(), 50.0);
- QCOMPARE(four->x(), 40.0);
- QCOMPARE(four->y(), 70.0);
- QCOMPARE(five->x(), 30.0);
- QCOMPARE(five->y(), 70.0);
-
- QQuickItem *flow = canvas->rootObject()->findChild<QQuickItem*>("flow");
- QVERIFY(flow);
- QCOMPARE(flow->width(), 90.0);
- QCOMPARE(flow->height(), 120.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_flow_topToBottom()
-{
- QQuickView *canvas = createView(testFile("flowtest-toptobottom.qml"));
-
- canvas->rootObject()->setProperty("testRightToLeft", false);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 0.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 50.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 50.0);
- QCOMPARE(four->x(), 100.0);
- QCOMPARE(four->y(), 00.0);
- QCOMPARE(five->x(), 100.0);
- QCOMPARE(five->y(), 50.0);
-
- QQuickItem *flow = canvas->rootObject()->findChild<QQuickItem*>("flow");
- QVERIFY(flow);
- QCOMPARE(flow->height(), 90.0);
- QCOMPARE(flow->width(), 150.0);
-
- canvas->rootObject()->setProperty("testRightToLeft", true);
-
- QVERIFY(flow);
- QCOMPARE(flow->height(), 90.0);
- QCOMPARE(flow->width(), 150.0);
-
- QCOMPARE(one->x(), 100.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 80.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 50.0);
- QCOMPARE(three->y(), 50.0);
- QCOMPARE(four->x(), 0.0);
- QCOMPARE(four->y(), 0.0);
- QCOMPARE(five->x(), 40.0);
- QCOMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_flow_resize()
-{
- QQuickView *canvas = createView(testFile("flowtest.qml"));
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root);
- root->setWidth(125);
- root->setProperty("testRightToLeft", false);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QVERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QTRY_COMPARE(one->x(), 0.0);
- QTRY_COMPARE(one->y(), 0.0);
- QTRY_COMPARE(two->x(), 50.0);
- QTRY_COMPARE(two->y(), 0.0);
- QTRY_COMPARE(three->x(), 70.0);
- QTRY_COMPARE(three->y(), 0.0);
- QTRY_COMPARE(four->x(), 0.0);
- QTRY_COMPARE(four->y(), 50.0);
- QTRY_COMPARE(five->x(), 50.0);
- QTRY_COMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_flow_resize_rightToLeft()
-{
- QQuickView *canvas = createView(testFile("flowtest.qml"));
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root);
- root->setWidth(125);
- root->setProperty("testRightToLeft", true);
-
- QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
- QTRY_VERIFY(one != 0);
- QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
- QVERIFY(two != 0);
- QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
- QVERIFY(three != 0);
- QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
- QVERIFY(four != 0);
- QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
- QVERIFY(five != 0);
-
- QCOMPARE(one->x(), 75.0);
- QCOMPARE(one->y(), 0.0);
- QCOMPARE(two->x(), 55.0);
- QCOMPARE(two->y(), 0.0);
- QCOMPARE(three->x(), 5.0);
- QCOMPARE(three->y(), 0.0);
- QCOMPARE(four->x(), 75.0);
- QCOMPARE(four->y(), 50.0);
- QCOMPARE(five->x(), 65.0);
- QCOMPARE(five->y(), 50.0);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_flow_implicit_resize()
-{
- QQuickView *canvas = createView(testFile("flow-testimplicitsize.qml"));
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickFlow *flow = canvas->rootObject()->findChild<QQuickFlow*>("flow");
- QVERIFY(flow != 0);
-
- QCOMPARE(flow->width(), 100.0);
- QCOMPARE(flow->height(), 120.0);
-
- canvas->rootObject()->setProperty("flowLayout", 0);
- QCOMPARE(flow->flow(), QQuickFlow::LeftToRight);
- QCOMPARE(flow->width(), 220.0);
- QCOMPARE(flow->height(), 50.0);
-
- canvas->rootObject()->setProperty("flowLayout", 1);
- QCOMPARE(flow->flow(), QQuickFlow::TopToBottom);
- QCOMPARE(flow->width(), 100.0);
- QCOMPARE(flow->height(), 120.0);
-
- canvas->rootObject()->setProperty("flowLayout", 2);
- QCOMPARE(flow->layoutDirection(), Qt::RightToLeft);
- QCOMPARE(flow->width(), 220.0);
- QCOMPARE(flow->height(), 50.0);
-
- delete canvas;
-}
-
-QString warningMessage;
-
-void interceptWarnings(QtMsgType type, const char *msg)
-{
- Q_UNUSED( type );
- warningMessage = msg;
-}
-
-void tst_qquickpositioners::test_conflictinganchors()
-{
- QtMsgHandler oldMsgHandler = qInstallMsgHandler(interceptWarnings);
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine);
-
- component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; } }", QUrl::fromLocalFile(""));
- QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- delete item;
-
- component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- delete item;
-
- component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- delete item;
-
- component.setData("import QtQuick 2.0\nFlow { Item { width: 100; height: 100; } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- delete item;
-
- component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.top: parent.top } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function."));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.centerIn: parent } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function."));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.left: parent.left } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; anchors.left: parent.left } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function."));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 2.0\nRow { width: 100; height: 100; Item { anchors.fill: parent } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function."));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; anchors.top: parent.top } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QVERIFY(warningMessage.isEmpty());
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; anchors.horizontalCenter: parent.horizontalCenter } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function."));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; anchors.centerIn: parent } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function."));
- warningMessage.clear();
- delete item;
-
- component.setData("import QtQuick 2.0\nFlow { Item { width: 100; height: 100; anchors.verticalCenter: parent.verticalCenter } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function."));
- delete item;
-
- component.setData("import QtQuick 2.0\nFlow { width: 100; height: 100; Item { anchors.fill: parent } }", QUrl::fromLocalFile(""));
- item = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(item);
- QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function."));
- qInstallMsgHandler(oldMsgHandler);
- delete item;
-}
-
-void tst_qquickpositioners::test_mirroring()
-{
- QList<QString> qmlFiles;
- qmlFiles << "horizontal.qml" << "gridtest.qml" << "flowtest.qml";
- QList<QString> objectNames;
- objectNames << "one" << "two" << "three" << "four" << "five";
-
- foreach (const QString qmlFile, qmlFiles) {
- QQuickView *canvasA = createView(testFile(qmlFile));
- QQuickItem *rootA = qobject_cast<QQuickItem*>(canvasA->rootObject());
-
- QQuickView *canvasB = createView(testFile(qmlFile));
- QQuickItem *rootB = qobject_cast<QQuickItem*>(canvasB->rootObject());
-
- rootA->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft
-
- // LTR != RTL
- foreach (const QString objectName, objectNames) {
- // horizontal.qml only has three items
- if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
- break;
- QQuickItem *itemA = rootA->findChild<QQuickItem*>(objectName);
- QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName);
- QTRY_VERIFY(itemA->x() != itemB->x());
- }
-
- QDeclarativeProperty enabledProp(rootB, "LayoutMirroring.enabled", qmlContext(rootB));
- enabledProp.write(true);
- QDeclarativeProperty inheritProp(rootB, "LayoutMirroring.childrenInherit", qmlContext(rootB));
- inheritProp.write(true);
-
- // RTL == mirror
- foreach (const QString objectName, objectNames) {
- // horizontal.qml only has three items
- if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
- break;
- QQuickItem *itemA = rootA->findChild<QQuickItem*>(objectName);
- QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName);
- QTRY_COMPARE(itemA->x(), itemB->x());
- }
-
- rootA->setProperty("testRightToLeft", false); // layoutDirection: Qt.LeftToRight
- rootB->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft
-
- // LTR == RTL + mirror
- foreach (const QString objectName, objectNames) {
- // horizontal.qml only has three items
- if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
- break;
- QQuickItem *itemA = rootA->findChild<QQuickItem*>(objectName);
- QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName);
- QTRY_COMPARE(itemA->x(), itemB->x());
- }
- delete canvasA;
- delete canvasB;
- }
-}
-
-void tst_qquickpositioners::test_allInvisible()
-{
- //QTBUG-19361
- QQuickView *canvas = createView(testFile("allInvisible.qml"));
-
- QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(root);
-
- QQuickRow *row = canvas->rootObject()->findChild<QQuickRow*>("row");
- QVERIFY(row != 0);
- QVERIFY(row->width() == 0);
- QVERIFY(row->height() == 0);
- QQuickColumn *column = canvas->rootObject()->findChild<QQuickColumn*>("column");
- QVERIFY(column != 0);
- QVERIFY(column->width() == 0);
- QVERIFY(column->height() == 0);
-}
-
-void tst_qquickpositioners::test_attachedproperties()
-{
- QFETCH(QString, filename);
-
- QQuickView *canvas = createView(filename);
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickRectangle *greenRect = canvas->rootObject()->findChild<QQuickRectangle *>("greenRect");
- QVERIFY(greenRect != 0);
-
- int posIndex = greenRect->property("posIndex").toInt();
- QVERIFY(posIndex == 0);
- bool isFirst = greenRect->property("isFirstItem").toBool();
- QVERIFY(isFirst == true);
- bool isLast = greenRect->property("isLastItem").toBool();
- QVERIFY(isLast == false);
-
- QQuickRectangle *yellowRect = canvas->rootObject()->findChild<QQuickRectangle *>("yellowRect");
- QVERIFY(yellowRect != 0);
-
- posIndex = yellowRect->property("posIndex").toInt();
- QVERIFY(posIndex == -1);
- isFirst = yellowRect->property("isFirstItem").toBool();
- QVERIFY(isFirst == false);
- isLast = yellowRect->property("isLastItem").toBool();
- QVERIFY(isLast == false);
-
- yellowRect->metaObject()->invokeMethod(yellowRect, "onDemandPositioner");
-
- posIndex = yellowRect->property("posIndex").toInt();
- QVERIFY(posIndex == 1);
- isFirst = yellowRect->property("isFirstItem").toBool();
- QVERIFY(isFirst == false);
- isLast = yellowRect->property("isLastItem").toBool();
- QVERIFY(isLast == true);
-
- delete canvas;
-}
-
-void tst_qquickpositioners::test_attachedproperties_data()
-{
- QTest::addColumn<QString>("filename");
-
- QTest::newRow("column") << testFile("attachedproperties-column.qml");
- QTest::newRow("row") << testFile("attachedproperties-row.qml");
- QTest::newRow("grid") << testFile("attachedproperties-grid.qml");
- QTest::newRow("flow") << testFile("attachedproperties-flow.qml");
-}
-
-void tst_qquickpositioners::test_attachedproperties_dynamic()
-{
- QQuickView *canvas = createView(testFile("attachedproperties-dynamic.qml"));
- QVERIFY(canvas->rootObject() != 0);
-
- QQuickRow *row = canvas->rootObject()->findChild<QQuickRow *>("pos");
- QVERIFY(row != 0);
-
- QQuickRectangle *rect0 = canvas->rootObject()->findChild<QQuickRectangle *>("rect0");
- QVERIFY(rect0 != 0);
-
- int posIndex = rect0->property("index").toInt();
- QVERIFY(posIndex == 0);
- bool isFirst = rect0->property("firstItem").toBool();
- QVERIFY(isFirst == true);
- bool isLast = rect0->property("lastItem").toBool();
- QVERIFY(isLast == false);
-
- QQuickRectangle *rect1 = canvas->rootObject()->findChild<QQuickRectangle *>("rect1");
- QVERIFY(rect1 != 0);
-
- posIndex = rect1->property("index").toInt();
- QVERIFY(posIndex == 1);
- isFirst = rect1->property("firstItem").toBool();
- QVERIFY(isFirst == false);
- isLast = rect1->property("lastItem").toBool();
- QVERIFY(isLast == true);
-
- row->metaObject()->invokeMethod(row, "createSubRect");
-
- QTRY_VERIFY(rect1->property("index").toInt() == 1);
- QTRY_VERIFY(rect1->property("firstItem").toBool() == false);
- QTRY_VERIFY(rect1->property("lastItem").toBool() == false);
-
- QQuickRectangle *rect2 = canvas->rootObject()->findChild<QQuickRectangle *>("rect2");
- QVERIFY(rect2 != 0);
-
- posIndex = rect2->property("index").toInt();
- QVERIFY(posIndex == 2);
- isFirst = rect2->property("firstItem").toBool();
- QVERIFY(isFirst == false);
- isLast = rect2->property("lastItem").toBool();
- QVERIFY(isLast == true);
-
- row->metaObject()->invokeMethod(row, "destroySubRect");
-
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QCoreApplication::processEvents();
-
- QTRY_VERIFY(rect1->property("index").toInt() == 1);
- QTRY_VERIFY(rect1->property("firstItem").toBool() == false);
- QTRY_VERIFY(rect1->property("lastItem").toBool() == true);
-
- delete canvas;
-}
-
-QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait)
-{
- QQuickView *canvas = new QQuickView(0);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
- canvas->show();
- if (wait)
- QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
-
- return canvas;
-}
-
-
-QTEST_MAIN(tst_qquickpositioners)
-
-#include "tst_qquickpositioners.moc"
diff --git a/tests/auto/qtquick2/qquickrepeater/qquickrepeater.pro b/tests/auto/qtquick2/qquickrepeater/qquickrepeater.pro
deleted file mode 100644
index b791faf78a..0000000000
--- a/tests/auto/qtquick2/qquickrepeater/qquickrepeater.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickrepeater
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickrepeater.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-testFiles.files = data
-testFiles.path = .
-DEPLOYMENT += testFiles
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/qtquick2/qquickrepeater/tst_qquickrepeater.cpp
deleted file mode 100644
index 59322704f5..0000000000
--- a/tests/auto/qtquick2/qquickrepeater/tst_qquickrepeater.cpp
+++ /dev/null
@@ -1,644 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
-#include <QtTest/QSignalSpy>
-#include <private/qlistmodelinterface_p.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtQuick/qquickview.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativeincubator.h>
-#include <private/qquickrepeater_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-
-#include "../../shared/util.h"
-#include "../shared/viewtestutil.h"
-#include "../shared/visualtestutil.h"
-
-using namespace QQuickViewTestUtil;
-using namespace QQuickVisualTestUtil;
-
-
-class tst_QQuickRepeater : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickRepeater();
-
-private slots:
- void numberModel();
- void objectList();
- void stringList();
- void dataModel_adding();
- void dataModel_removing();
- void dataModel_changes();
- void itemModel();
- void resetModel();
- void modelChanged();
- void properties();
- void asynchronous();
- void initParent();
-};
-
-class TestObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(bool error READ error WRITE setError)
- Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged)
-
-public:
- TestObject() : QObject(), mError(true), mUseModel(false) {}
-
- bool error() const { return mError; }
- void setError(bool err) { mError = err; }
-
- bool useModel() const { return mUseModel; }
- void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); }
-
-signals:
- void useModelChanged();
-
-private:
- bool mError;
- bool mUseModel;
-};
-
-tst_QQuickRepeater::tst_QQuickRepeater()
-{
-}
-
-void tst_QQuickRepeater::numberModel()
-{
- QQuickView *canvas = createView();
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", 5);
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(testFileUrl("intmodel.qml"));
- qApp->processEvents();
-
- QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QCOMPARE(repeater->parentItem()->childItems().count(), 5+1);
-
- QVERIFY(!repeater->itemAt(-1));
- for (int i=0; i<repeater->count(); i++)
- QCOMPARE(repeater->itemAt(i), repeater->parentItem()->childItems().at(i));
- QVERIFY(!repeater->itemAt(repeater->count()));
-
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- delete testObject;
- delete canvas;
-}
-
-class MyObject : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int idx READ idx CONSTANT)
-public:
- MyObject(int i) : QObject(), m_idx(i) {}
-
- int idx() const { return m_idx; }
-
- int m_idx;
-};
-
-void tst_QQuickRepeater::objectList()
-{
- QQuickView *canvas = createView();
- QObjectList data;
- for (int i=0; i<100; i++)
- data << new MyObject(i);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", QVariant::fromValue(data));
-
- canvas->setSource(testFileUrl("objlist.qml"));
- qApp->processEvents();
-
- QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data
- QCOMPARE(repeater->property("instantiated").toInt(), 100);
-
- QVERIFY(!repeater->itemAt(-1));
- for (int i=0; i<data.count(); i++)
- QCOMPARE(repeater->itemAt(i), repeater->parentItem()->childItems().at(i));
- QVERIFY(!repeater->itemAt(data.count()));
-
- QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*)));
- QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*)));
- ctxt->setContextProperty("testData", QVariant::fromValue(data));
- QCOMPARE(addedSpy.count(), data.count());
- QCOMPARE(removedSpy.count(), data.count());
-
- qDeleteAll(data);
- delete canvas;
-}
-
-/*
-The Repeater element creates children at its own position in its parent's
-stacking order. In this test we insert a repeater between two other Text
-elements to test this.
-*/
-void tst_QQuickRepeater::stringList()
-{
- QQuickView *canvas = createView();
-
- QStringList data;
- data << "One";
- data << "Two";
- data << "Three";
- data << "Four";
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", data);
-
- canvas->setSource(testFileUrl("repeater1.qml"));
- qApp->processEvents();
-
- QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
-
- QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
-
- QCOMPARE(container->childItems().count(), data.count() + 3);
-
- bool saw_repeater = false;
- for (int i = 0; i < container->childItems().count(); ++i) {
-
- if (i == 0) {
- QQuickText *name = qobject_cast<QQuickText*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), QLatin1String("Zero"));
- } else if (i == container->childItems().count() - 2) {
- // The repeater itself
- QQuickRepeater *rep = qobject_cast<QQuickRepeater*>(container->childItems().at(i));
- QCOMPARE(rep, repeater);
- saw_repeater = true;
- continue;
- } else if (i == container->childItems().count() - 1) {
- QQuickText *name = qobject_cast<QQuickText*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), QLatin1String("Last"));
- } else {
- QQuickText *name = qobject_cast<QQuickText*>(container->childItems().at(i));
- QVERIFY(name != 0);
- QCOMPARE(name->text(), data.at(i-1));
- }
- }
- QVERIFY(saw_repeater);
-
- delete canvas;
-}
-
-void tst_QQuickRepeater::dataModel_adding()
-{
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- QaimModel testModel;
- ctxt->setContextProperty("testData", &testModel);
- canvas->setSource(testFileUrl("repeater2.qml"));
- qApp->processEvents();
-
- QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
-
- QVERIFY(!repeater->itemAt(0));
-
- QSignalSpy countSpy(repeater, SIGNAL(countChanged()));
- QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*)));
-
- // add to empty model
- testModel.addItem("two", "2");
- QCOMPARE(repeater->itemAt(0), container->childItems().at(0));
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(addedSpy.count(), 1);
- QCOMPARE(addedSpy.at(0).at(0).toInt(), 0);
- QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(0));
- addedSpy.clear();
-
- // insert at start
- testModel.insertItem(0, "one", "1");
- QCOMPARE(repeater->itemAt(0), container->childItems().at(0));
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(addedSpy.count(), 1);
- QCOMPARE(addedSpy.at(0).at(0).toInt(), 0);
- QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(0));
- addedSpy.clear();
-
- // insert at end
- testModel.insertItem(2, "four", "4");
- QCOMPARE(repeater->itemAt(2), container->childItems().at(2));
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(addedSpy.count(), 1);
- QCOMPARE(addedSpy.at(0).at(0).toInt(), 2);
- QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(2));
- addedSpy.clear();
-
- // insert in middle
- testModel.insertItem(2, "three", "3");
- QCOMPARE(repeater->itemAt(2), container->childItems().at(2));
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(addedSpy.count(), 1);
- QCOMPARE(addedSpy.at(0).at(0).toInt(), 2);
- QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(2));
- addedSpy.clear();
-
- delete testObject;
- addedSpy.clear();
- countSpy.clear();
- delete canvas;
-}
-
-void tst_QQuickRepeater::dataModel_removing()
-{
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- QaimModel testModel;
- testModel.addItem("one", "1");
- testModel.addItem("two", "2");
- testModel.addItem("three", "3");
- testModel.addItem("four", "4");
- testModel.addItem("five", "5");
-
- ctxt->setContextProperty("testData", &testModel);
- canvas->setSource(testFileUrl("repeater2.qml"));
- qApp->processEvents();
-
- QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
- QCOMPARE(container->childItems().count(), repeater->count()+1);
-
- QSignalSpy countSpy(repeater, SIGNAL(countChanged()));
- QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*)));
-
- // remove at start
- QQuickItem *item = repeater->itemAt(0);
- QCOMPARE(item, container->childItems().at(0));
-
- testModel.removeItem(0);
- QVERIFY(repeater->itemAt(0) != item);
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(removedSpy.count(), 1);
- QCOMPARE(removedSpy.at(0).at(0).toInt(), 0);
- QCOMPARE(removedSpy.at(0).at(1).value<QQuickItem*>(), item);
- removedSpy.clear();
-
- // remove at end
- int lastIndex = testModel.count()-1;
- item = repeater->itemAt(lastIndex);
- QCOMPARE(item, container->childItems().at(lastIndex));
-
- testModel.removeItem(lastIndex);
- QVERIFY(repeater->itemAt(lastIndex) != item);
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(removedSpy.count(), 1);
- QCOMPARE(removedSpy.at(0).at(0).toInt(), lastIndex);
- QCOMPARE(removedSpy.at(0).at(1).value<QQuickItem*>(), item);
- removedSpy.clear();
-
- // remove from middle
- item = repeater->itemAt(1);
- QCOMPARE(item, container->childItems().at(1));
-
- testModel.removeItem(1);
- QVERIFY(repeater->itemAt(lastIndex) != item);
- QCOMPARE(countSpy.count(), 1); countSpy.clear();
- QCOMPARE(removedSpy.count(), 1);
- QCOMPARE(removedSpy.at(0).at(0).toInt(), 1);
- QCOMPARE(removedSpy.at(0).at(1).value<QQuickItem*>(), item);
- removedSpy.clear();
-
- delete testObject;
- delete canvas;
-}
-
-void tst_QQuickRepeater::dataModel_changes()
-{
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- QaimModel testModel;
- testModel.addItem("one", "1");
- testModel.addItem("two", "2");
- testModel.addItem("three", "3");
-
- ctxt->setContextProperty("testData", &testModel);
- canvas->setSource(testFileUrl("repeater2.qml"));
- qApp->processEvents();
-
- QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
- QCOMPARE(container->childItems().count(), repeater->count()+1);
-
- // Check that model changes are propagated
- QQuickText *text = findItem<QQuickText>(canvas->rootObject(), "myName", 1);
- QVERIFY(text);
- QCOMPARE(text->text(), QString("two"));
-
- testModel.modifyItem(1, "Item two", "_2");
- text = findItem<QQuickText>(canvas->rootObject(), "myName", 1);
- QVERIFY(text);
- QCOMPARE(text->text(), QString("Item two"));
-
- text = findItem<QQuickText>(canvas->rootObject(), "myNumber", 1);
- QVERIFY(text);
- QCOMPARE(text->text(), QString("_2"));
-
- delete testObject;
- delete canvas;
-}
-
-void tst_QQuickRepeater::itemModel()
-{
- QQuickView *canvas = createView();
- QDeclarativeContext *ctxt = canvas->rootContext();
- TestObject *testObject = new TestObject;
- ctxt->setContextProperty("testObject", testObject);
-
- canvas->setSource(testFileUrl("itemlist.qml"));
- qApp->processEvents();
-
- QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
-
- QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
-
- QCOMPARE(container->childItems().count(), 1);
-
- testObject->setUseModel(true);
- QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
- QVERIFY(testObject->error() == false);
-
- QCOMPARE(container->childItems().count(), 4);
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(0))->objectName() == "item1");
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(1))->objectName() == "item2");
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(2))->objectName() == "item3");
- QVERIFY(container->childItems().at(3) == repeater);
-
- QMetaObject::invokeMethod(canvas->rootObject(), "switchModel");
- QCOMPARE(container->childItems().count(), 3);
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(0))->objectName() == "item4");
- QVERIFY(qobject_cast<QObject*>(container->childItems().at(1))->objectName() == "item5");
- QVERIFY(container->childItems().at(2) == repeater);
-
- testObject->setUseModel(false);
- QCOMPARE(container->childItems().count(), 1);
-
- delete testObject;
- delete canvas;
-}
-
-void tst_QQuickRepeater::resetModel()
-{
- QQuickView *canvas = createView();
-
- QStringList dataA;
- for (int i=0; i<10; i++)
- dataA << QString::number(i);
-
- QDeclarativeContext *ctxt = canvas->rootContext();
- ctxt->setContextProperty("testData", dataA);
- canvas->setSource(testFileUrl("repeater1.qml"));
- qApp->processEvents();
- QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
- QVERIFY(repeater != 0);
- QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
- QVERIFY(container != 0);
-
- QCOMPARE(repeater->count(), dataA.count());
- for (int i=0; i<repeater->count(); i++)
- QCOMPARE(repeater->itemAt(i), container->childItems().at(i+1)); // +1 to skip first Text object
-
- QSignalSpy modelChangedSpy(repeater, SIGNAL(modelChanged()));
- QSignalSpy countSpy(repeater, SIGNAL(countChanged()));
- QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*)));
- QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*)));
-
- QStringList dataB;
- for (int i=0; i<20; i++)
- dataB << QString::number(i);
-
- // reset context property
- ctxt->setContextProperty("testData", dataB);
- QCOMPARE(repeater->count(), dataB.count());
-
- QCOMPARE(modelChangedSpy.count(), 1);
- QCOMPARE(countSpy.count(), 1);
- QCOMPARE(removedSpy.count(), dataA.count());
- QCOMPARE(addedSpy.count(), dataB.count());
- for (int i=0; i<dataB.count(); i++) {
- QCOMPARE(addedSpy.at(i).at(0).toInt(), i);
- QCOMPARE(addedSpy.at(i).at(1).value<QQuickItem*>(), repeater->itemAt(i));
- }
- modelChangedSpy.clear();
- countSpy.clear();
- removedSpy.clear();
- addedSpy.clear();
-
- // reset via setModel()
- repeater->setModel(dataA);
- QCOMPARE(repeater->count(), dataA.count());
-
- QCOMPARE(modelChangedSpy.count(), 1);
- QCOMPARE(countSpy.count(), 1);
- QCOMPARE(removedSpy.count(), dataB.count());
- QCOMPARE(addedSpy.count(), dataA.count());
- for (int i=0; i<dataA.count(); i++) {
- QCOMPARE(addedSpy.at(i).at(0).toInt(), i);
- QCOMPARE(addedSpy.at(i).at(1).value<QQuickItem*>(), repeater->itemAt(i));
- }
-
- modelChangedSpy.clear();
- countSpy.clear();
- removedSpy.clear();
- addedSpy.clear();
-
- delete canvas;
-}
-
-// QTBUG-17156
-void tst_QQuickRepeater::modelChanged()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("modelChanged.qml"));
-
- QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(rootObject);
- QQuickRepeater *repeater = findItem<QQuickRepeater>(rootObject, "repeater");
- QVERIFY(repeater);
-
- repeater->setModel(4);
- QCOMPARE(repeater->count(), 4);
- QCOMPARE(repeater->property("itemsCount").toInt(), 4);
- QCOMPARE(repeater->property("itemsFound").toList().count(), 4);
-
- repeater->setModel(10);
- QCOMPARE(repeater->count(), 10);
- QCOMPARE(repeater->property("itemsCount").toInt(), 10);
- QCOMPARE(repeater->property("itemsFound").toList().count(), 10);
-
- delete rootObject;
-}
-
-void tst_QQuickRepeater::properties()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("properties.qml"));
-
- QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(rootObject);
-
- QQuickRepeater *repeater = findItem<QQuickRepeater>(rootObject, "repeater");
- QVERIFY(repeater);
-
- QSignalSpy modelSpy(repeater, SIGNAL(modelChanged()));
- repeater->setModel(3);
- QCOMPARE(modelSpy.count(),1);
- repeater->setModel(3);
- QCOMPARE(modelSpy.count(),1);
-
- QSignalSpy delegateSpy(repeater, SIGNAL(delegateChanged()));
-
- QDeclarativeComponent rectComponent(&engine);
- rectComponent.setData("import QtQuick 2.0; Rectangle {}", QUrl::fromLocalFile(""));
-
- repeater->setDelegate(&rectComponent);
- QCOMPARE(delegateSpy.count(),1);
- repeater->setDelegate(&rectComponent);
- QCOMPARE(delegateSpy.count(),1);
-
- delete rootObject;
-}
-
-void tst_QQuickRepeater::asynchronous()
-{
- QQuickView *canvas = createView();
- canvas->show();
- QDeclarativeIncubationController controller;
- canvas->engine()->setIncubationController(&controller);
-
- canvas->setSource(testFileUrl("asyncloader.qml"));
-
- QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(rootObject);
-
- QQuickItem *container = findItem<QQuickItem>(rootObject, "container");
- QVERIFY(!container);
- while (!container) {
- bool b = false;
- controller.incubateWhile(&b);
- container = findItem<QQuickItem>(rootObject, "container");
- }
-
- QQuickRepeater *repeater = 0;
- while (!repeater) {
- bool b = false;
- controller.incubateWhile(&b);
- repeater = findItem<QQuickRepeater>(rootObject, "repeater");
- }
-
- // items will be created one at a time
- for (int i = 0; i < 10; ++i) {
- QString name("delegate");
- name += QString::number(i);
- QVERIFY(findItem<QQuickItem>(container, name) == 0);
- QQuickItem *item = 0;
- while (!item) {
- bool b = false;
- controller.incubateWhile(&b);
- item = findItem<QQuickItem>(container, name);
- }
- }
-
- {
- bool b = true;
- controller.incubateWhile(&b);
- }
-
- // verify positioning
- for (int i = 0; i < 10; ++i) {
- QString name("delegate");
- name += QString::number(i);
- QQuickItem *item = findItem<QQuickItem>(container, name);
- QTRY_COMPARE(item->y(), i * 50.0);
- }
-
- delete canvas;
-}
-
-void tst_QQuickRepeater::initParent()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, testFileUrl("initparent.qml"));
-
- QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
- QVERIFY(rootObject);
-
- QCOMPARE(qvariant_cast<QQuickItem*>(rootObject->property("parentItem")), rootObject);
-}
-
-QTEST_MAIN(tst_QQuickRepeater)
-
-#include "tst_qquickrepeater.moc"
diff --git a/tests/auto/qtquick2/qquickscreen/qquickscreen.pro b/tests/auto/qtquick2/qquickscreen/qquickscreen.pro
deleted file mode 100644
index 6d0a5e1650..0000000000
--- a/tests/auto/qtquick2/qquickscreen/qquickscreen.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickscreen
-SOURCES += tst_qquickscreen.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private testlib quick-private
diff --git a/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp b/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp
deleted file mode 100644
index bb687f7596..0000000000
--- a/tests/auto/qtquick2/qquickscreen/tst_qquickscreen.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QDebug>
-#include <QtQuick/QQuickItem>
-#include <QtQuick/QQuickView>
-#include <QtGui/QScreen>
-#include "../../shared/util.h"
-
-class tst_qquickscreen : public QDeclarativeDataTest
-{
- Q_OBJECT
-private slots:
- void basicProperties();
-};
-
-void tst_qquickscreen::basicProperties()
-{
- QQuickView view;
- view.setSource(testFileUrl("screen.qml"));
- view.show();
- QTest::qWaitForWindowShown(&view);
-
- QQuickItem* root = view.rootObject();
- QVERIFY(root);
-
- QScreen* screen = view.screen();
- QVERIFY(screen);
-
- QCOMPARE(screen->size().width(), root->property("w").toInt());
- QCOMPARE(screen->size().height(), root->property("h").toInt());
- QCOMPARE(int(screen->orientation()), root->property("curOrientation").toInt());
- QCOMPARE(int(screen->primaryOrientation()), root->property("priOrientation").toInt());
-}
-
-QTEST_MAIN(tst_qquickscreen)
-
-#include "tst_qquickscreen.moc"
diff --git a/tests/auto/qtquick2/qquickshadereffect/qquickshadereffect.pro b/tests/auto/qtquick2/qquickshadereffect/qquickshadereffect.pro
deleted file mode 100644
index de8b247340..0000000000
--- a/tests/auto/qtquick2/qquickshadereffect/qquickshadereffect.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickshadereffect
-SOURCES += tst_qquickshadereffect.cpp
-
-macx:CONFIG -= app_bundle
-
-CONFIG += parallel_test
-QT += core-private gui-private declarative-private quick-private widgets testlib
diff --git a/tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro b/tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro
deleted file mode 100644
index 0d63007c65..0000000000
--- a/tests/auto/qtquick2/qquickspriteimage/qquickspriteimage.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickspriteimage
-SOURCES += tst_qquickspriteimage.cpp
-
-include (../../shared/util.pri)
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private declarative-private quick-private network testlib
diff --git a/tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp b/tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp
deleted file mode 100644
index 37453521fa..0000000000
--- a/tests/auto/qtquick2/qquickspriteimage/tst_qquickspriteimage.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QtTest/QtTest>
-#include "../../shared/util.h"
-#include <QtQuick/qquickview.h>
-#include <private/qquickspriteimage_p.h>
-
-class tst_qquickspriteimage : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquickspriteimage(){}
-
-private slots:
- void test_properties();
- void test_framerateAdvance();//Separate codepath for QQuickSpriteEngine
-};
-
-void tst_qquickspriteimage::test_properties()
-{
- QQuickView *canvas = new QQuickView(0);
-
- canvas->setSource(testFileUrl("basic.qml"));
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
-
- QVERIFY(canvas->rootObject());
- QQuickSpriteImage* sprite = canvas->rootObject()->findChild<QQuickSpriteImage*>("sprite");
- QVERIFY(sprite);
-
- QVERIFY(sprite->running());
- QVERIFY(sprite->interpolate());
-
- sprite->setRunning(false);
- QVERIFY(!sprite->running());
- sprite->setInterpolate(false);
- QVERIFY(!sprite->interpolate());
-
- delete canvas;
-}
-
-void tst_qquickspriteimage::test_framerateAdvance()
-{
- QQuickView *canvas = new QQuickView(0);
-
- canvas->setSource(testFileUrl("advance.qml"));
- canvas->show();
- QTest::qWaitForWindowShown(canvas);
-
- QVERIFY(canvas->rootObject());
- QQuickSpriteImage* sprite = canvas->rootObject()->findChild<QQuickSpriteImage*>("sprite");
- QVERIFY(sprite);
-
- QTRY_COMPARE(sprite->currentSprite(), QLatin1String("secondState"));
- delete canvas;
-}
-
-QTEST_MAIN(tst_qquickspriteimage)
-
-#include "tst_qquickspriteimage.moc"
diff --git a/tests/auto/qtquick2/qquicktext/qquicktext.pro b/tests/auto/qtquick2/qquicktext/qquicktext.pro
deleted file mode 100644
index b483bebc61..0000000000
--- a/tests/auto/qtquick2/qquicktext/qquicktext.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquicktext
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquicktext.cpp
-
-INCLUDEPATH += ../../shared/
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += ../../shared/testhttpserver.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private widgets-private opengl-private network testlib
diff --git a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp b/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp
deleted file mode 100644
index d1c0f765d0..0000000000
--- a/tests/auto/qtquick2/qquicktext/tst_qquicktext.cpp
+++ /dev/null
@@ -1,2432 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QTextDocument>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <private/qquicktext_p_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include <QFontMetrics>
-#include <QGraphicsSceneMouseEvent>
-#include <qmath.h>
-#include <QtQuick/QQuickView>
-#include <private/qapplication_p.h>
-#include <limits.h>
-#include <QtGui/QMouseEvent>
-#include "../../shared/util.h"
-#include "testhttpserver.h"
-
-DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
-
-class tst_qquicktext : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquicktext();
-
-private slots:
- void text();
- void width();
- void wrap();
- void elide();
- void multilineElide();
- void textFormat();
-
- void alignments_data();
- void alignments();
-
- void baseUrl();
- void embeddedImages_data();
- void embeddedImages();
-
- void lineCount();
- void lineHeight();
-
- // ### these tests may be trivial
- void horizontalAlignment();
- void horizontalAlignment_RightToLeft();
- void verticalAlignment();
- void font();
- void style();
- void color();
- void smooth();
-
- // QDeclarativeFontValueType
- void weight();
- void underline();
- void overline();
- void strikeout();
- void capitalization();
- void letterSpacing();
- void wordSpacing();
-
- void clickLink();
-
- void implicitSize_data();
- void implicitSize();
- void contentSize();
-
- void lineLaidOut();
-
- void imgTagsBaseUrl_data();
- void imgTagsBaseUrl();
- void imgTagsAlign_data();
- void imgTagsAlign();
- void imgTagsMultipleImages();
- void imgTagsElide();
- void imgTagsUpdates();
- void imgTagsError();
- void fontSizeMode_data();
- void fontSizeMode();
- void fontSizeModeMultiline_data();
- void fontSizeModeMultiline();
- void multilengthStrings_data();
- void multilengthStrings();
-
-private:
- QStringList standard;
- QStringList richText;
-
- QStringList horizontalAlignmentmentStrings;
- QStringList verticalAlignmentmentStrings;
-
- QList<Qt::Alignment> verticalAlignmentments;
- QList<Qt::Alignment> horizontalAlignmentments;
-
- QStringList styleStrings;
- QList<QQuickText::TextStyle> styles;
-
- QStringList colorStrings;
-
- QDeclarativeEngine engine;
-
- QQuickView *createView(const QString &filename);
-};
-
-tst_qquicktext::tst_qquicktext()
-{
- standard << "the quick brown fox jumped over the lazy dog"
- << "the quick brown fox\n jumped over the lazy dog";
-
- richText << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a> jumped over the <b>lazy</b> dog</i>"
- << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
-
- horizontalAlignmentmentStrings << "AlignLeft"
- << "AlignRight"
- << "AlignHCenter";
-
- verticalAlignmentmentStrings << "AlignTop"
- << "AlignBottom"
- << "AlignVCenter";
-
- horizontalAlignmentments << Qt::AlignLeft
- << Qt::AlignRight
- << Qt::AlignHCenter;
-
- verticalAlignmentments << Qt::AlignTop
- << Qt::AlignBottom
- << Qt::AlignVCenter;
-
- styleStrings << "Normal"
- << "Outline"
- << "Raised"
- << "Sunken";
-
- styles << QQuickText::Normal
- << QQuickText::Outline
- << QQuickText::Raised
- << QQuickText::Sunken;
-
- colorStrings << "aliceblue"
- << "antiquewhite"
- << "aqua"
- << "darkkhaki"
- << "darkolivegreen"
- << "dimgray"
- << "palevioletred"
- << "lightsteelblue"
- << "#000000"
- << "#AAAAAA"
- << "#FFFFFF"
- << "#2AC05F";
- //
- // need a different test to do alpha channel test
- // << "#AA0011DD"
- // << "#00F16B11";
- //
-}
-
-QQuickView *tst_qquicktext::createView(const QString &filename)
-{
- QQuickView *canvas = new QQuickView(0);
-
- canvas->setSource(QUrl::fromLocalFile(filename));
- return canvas;
-}
-
-void tst_qquicktext::text()
-{
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nText { text: \"\" }", QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->text(), QString(""));
- QVERIFY(textObject->width() == 0);
-
- delete textObject;
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
-
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->text(), standard.at(i));
- QVERIFY(textObject->width() > 0);
-
- delete textObject;
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QString expected = richText.at(i);
- QCOMPARE(textObject->text(), expected.replace("\\\"", "\""));
- QVERIFY(textObject->width() > 0);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::width()
-{
- // uses Font metrics to find the width for standard and document to find the width for rich
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nText { text: \"\" }", QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 0.);
-
- delete textObject;
- }
-
- bool requiresUnhintedMetrics = !qmlDisableDistanceField();
-
- for (int i = 0; i < standard.size(); i++)
- {
- QVERIFY(!Qt::mightBeRichText(standard.at(i))); // self-test
-
- QFont f;
- qreal metricWidth = 0.0;
-
- if (requiresUnhintedMetrics) {
- QString s = standard.at(i);
- s.replace(QLatin1Char('\n'), QChar::LineSeparator);
-
- QTextLayout layout(s);
- layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic);
- {
- QTextOption option;
- option.setUseDesignMetrics(true);
- layout.setTextOption(option);
- }
-
- layout.beginLayout();
- forever {
- QTextLine line = layout.createLine();
- if (!line.isValid())
- break;
- }
-
- layout.endLayout();
-
- metricWidth = qCeil(layout.boundingRect().width());
- } else {
- QFontMetricsF fm(f);
- qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
- metricWidth = qCeil(metricWidth);
- }
-
- QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->boundingRect().width() > 0);
- QCOMPARE(textObject->width(), qreal(metricWidth));
- QVERIFY(textObject->textFormat() == QQuickText::AutoText); // setting text doesn't change format
-
- delete textObject;
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QVERIFY(Qt::mightBeRichText(richText.at(i))); // self-test
-
- QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\"; textFormat: Text.RichText }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
- QVERIFY(textObject != 0);
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
- QVERIFY(textPrivate != 0);
-
- QTextDocument *doc = textPrivate->textDocument();
- QVERIFY(doc != 0);
-
- QCOMPARE(int(textObject->width()), int(doc->idealWidth()));
- QVERIFY(textObject->textFormat() == QQuickText::RichText);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::wrap()
-{
- int textHeight = 0;
- // for specified width and wrap set true
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nText { text: \"Hello\"; wrapMode: Text.WordWrap; width: 300 }", QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
- textHeight = textObject->height();
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->wrapMode() == QQuickText::WordWrap);
- QCOMPARE(textObject->width(), 300.);
-
- delete textObject;
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 30.);
- QVERIFY(textObject->height() > textHeight);
-
- int oldHeight = textObject->height();
- textObject->setWidth(100);
- QVERIFY(textObject->height() < oldHeight);
-
- delete textObject;
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 30.);
- QVERIFY(textObject->height() > textHeight);
-
- qreal oldHeight = textObject->height();
- textObject->setWidth(100);
- QVERIFY(textObject->height() < oldHeight);
-
- delete textObject;
- }
-
- // richtext again with a fixed height
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; height: 50; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 30.);
- QVERIFY(textObject->implicitHeight() > textHeight);
-
- qreal oldHeight = textObject->implicitHeight();
- textObject->setWidth(100);
- QVERIFY(textObject->implicitHeight() < oldHeight);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::elide()
-{
- for (QQuickText::TextElideMode m = QQuickText::ElideLeft; m<=QQuickText::ElideNone; m=QQuickText::TextElideMode(int(m)+1)) {
- const char* elidename[]={"ElideLeft", "ElideRight", "ElideMiddle", "ElideNone"};
- QString elide = "elide: Text." + QString(elidename[int(m)]) + ";";
-
- // XXX Poor coverage.
-
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(("import QtQuick 2.0\nText { text: \"\"; "+elide+" width: 100 }").toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->elideMode(), m);
- QCOMPARE(textObject->width(), 100.);
-
- delete textObject;
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { "+elide+" width: 100; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->elideMode(), m);
- QCOMPARE(textObject->width(), 100.);
-
- delete textObject;
- }
-
- // richtext - does nothing
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->elideMode(), m);
- QCOMPARE(textObject->width(), 100.);
-
- delete textObject;
- }
- }
-}
-
-void tst_qquicktext::multilineElide()
-{
- QQuickView *canvas = createView(testFile("multilineelide.qml"));
-
- QQuickText *myText = qobject_cast<QQuickText*>(canvas->rootObject());
- QVERIFY(myText != 0);
-
- QCOMPARE(myText->lineCount(), 3);
- QCOMPARE(myText->truncated(), true);
-
- qreal lineHeight = myText->contentHeight() / 3.;
-
- // reduce size and ensure fewer lines are drawn
- myText->setHeight(lineHeight * 2);
- QCOMPARE(myText->lineCount(), 2);
-
- myText->setHeight(lineHeight);
- QCOMPARE(myText->lineCount(), 1);
-
- myText->setHeight(5);
- QCOMPARE(myText->lineCount(), 1);
-
- myText->setHeight(lineHeight * 3);
- QCOMPARE(myText->lineCount(), 3);
-
- // remove max count and show all lines.
- myText->setHeight(1000);
- myText->resetMaximumLineCount();
-
- QCOMPARE(myText->truncated(), false);
-
- // reduce size again
- myText->setHeight(lineHeight * 2);
- QCOMPARE(myText->lineCount(), 2);
- QCOMPARE(myText->truncated(), true);
-
- // change line height
- myText->setLineHeight(1.1);
- QCOMPARE(myText->lineCount(), 1);
-
- delete canvas;
-}
-
-void tst_qquicktext::textFormat()
-{
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nText { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QQuickText::RichText);
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
- QVERIFY(textPrivate != 0);
- QVERIFY(textPrivate->richText == true);
-
- delete textObject;
- }
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nText { text: \"<b>Hello</b>\" }", QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QQuickText::AutoText);
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
- QVERIFY(textPrivate != 0);
- QVERIFY(textPrivate->styledText == true);
-
- delete textObject;
- }
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nText { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QQuickText::PlainText);
-
- delete textObject;
- }
-}
-
-
-void tst_qquicktext::alignments_data()
-{
- QTest::addColumn<int>("hAlign");
- QTest::addColumn<int>("vAlign");
- QTest::addColumn<QString>("expectfile");
-
- QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << testFile("alignments_lt.png");
- QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << testFile("alignments_rt.png");
- QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << testFile("alignments_ct.png");
-
- QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << testFile("alignments_lb.png");
- QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << testFile("alignments_rb.png");
- QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << testFile("alignments_cb.png");
-
- QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << testFile("alignments_lc.png");
- QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << testFile("alignments_rc.png");
- QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << testFile("alignments_cc.png");
-}
-
-
-void tst_qquicktext::alignments()
-{
- QSKIP("Text alignment pixmap comparison tests will not work with scenegraph");
-#if (0)// No widgets in scenegraph
- QFETCH(int, hAlign);
- QFETCH(int, vAlign);
- QFETCH(QString, expectfile);
-
- QQuickView *canvas = createView(testFile("alignments.qml"));
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWait(50);
- QTRY_COMPARE(QGuiApplication::activeWindow(), static_cast<QWidget *>(canvas));
-
- QObject *ob = canvas->rootObject();
- QVERIFY(ob != 0);
- ob->setProperty("horizontalAlignment",hAlign);
- ob->setProperty("verticalAlignment",vAlign);
- QTRY_COMPARE(ob->property("running").toBool(),false);
- QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32);
- actual.fill(qRgb(255,255,255));
- QPainter p(&actual);
- canvas->render(&p);
-
- QImage expect(expectfile);
- if (QGuiApplicationPrivate::graphics_system_name == "raster" || QGuiApplicationPrivate::graphics_system_name == "") {
- QCOMPARE(actual,expect);
- }
- delete canvas;
-#endif
-}
-
-//the alignment tests may be trivial o.oa
-void tst_qquicktext::horizontalAlignment()
-{
- //test one align each, and then test if two align fails.
-
- for (int i = 0; i < standard.size(); i++)
- {
- for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
-
- delete textObject;
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
-
- delete textObject;
- }
- }
-
-}
-
-void tst_qquicktext::horizontalAlignment_RightToLeft()
-{
- QQuickView *canvas = createView(testFile("horizontalAlignment_RightToLeft.qml"));
- QQuickText *text = canvas->rootObject()->findChild<QQuickText*>("text");
- QVERIFY(text != 0);
- canvas->show();
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(text);
- QVERIFY(textPrivate != 0);
-
- QTRY_VERIFY(textPrivate->layout.lineCount());
-
- // implicit alignment should follow the reading direction of RTL text
- QCOMPARE(text->hAlign(), QQuickText::AlignRight);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
-
- // explicitly left aligned text
- text->setHAlign(QQuickText::AlignLeft);
- QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
-
- // explicitly right aligned text
- text->setHAlign(QQuickText::AlignRight);
- QCOMPARE(text->hAlign(), QQuickText::AlignRight);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
-
- // change to rich text
- QString textString = text->text();
- text->setText(QString("<i>") + textString + QString("</i>"));
- text->setTextFormat(QQuickText::RichText);
- text->resetHAlign();
-
- // implicitly aligned rich text should follow the reading direction of text
- QCOMPARE(text->hAlign(), QQuickText::AlignRight);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft);
-
- // explicitly left aligned rich text
- text->setHAlign(QQuickText::AlignLeft);
- QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignRight);
-
- // explicitly right aligned rich text
- text->setHAlign(QQuickText::AlignRight);
- QCOMPARE(text->hAlign(), QQuickText::AlignRight);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft);
-
- text->setText(textString);
- text->setTextFormat(QQuickText::PlainText);
-
- // explicitly center aligned
- text->setHAlign(QQuickText::AlignHCenter);
- QCOMPARE(text->hAlign(), QQuickText::AlignHCenter);
- QCOMPARE(text->effectiveHAlign(), text->hAlign());
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().right() > canvas->width()/2);
-
- // reseted alignment should go back to following the text reading direction
- text->resetHAlign();
- QCOMPARE(text->hAlign(), QQuickText::AlignRight);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
-
- // mirror the text item
- QQuickItemPrivate::get(text)->setLayoutMirror(true);
-
- // mirrored implicit alignment should continue to follow the reading direction of the text
- QCOMPARE(text->hAlign(), QQuickText::AlignRight);
- QCOMPARE(text->effectiveHAlign(), QQuickText::AlignRight);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
-
- // mirrored explicitly right aligned behaves as left aligned
- text->setHAlign(QQuickText::AlignRight);
- QCOMPARE(text->hAlign(), QQuickText::AlignRight);
- QCOMPARE(text->effectiveHAlign(), QQuickText::AlignLeft);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
-
- // mirrored explicitly left aligned behaves as right aligned
- text->setHAlign(QQuickText::AlignLeft);
- QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
- QCOMPARE(text->effectiveHAlign(), QQuickText::AlignRight);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
-
- // disable mirroring
- QQuickItemPrivate::get(text)->setLayoutMirror(false);
- text->resetHAlign();
-
- // English text should be implicitly left aligned
- text->setText("Hello world!");
- QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
- QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
-
- // empty text with implicit alignment follows the system locale-based
- // keyboard input direction from QInputMethod::inputDirection()
- text->setText("");
- QCOMPARE(text->hAlign(), qApp->inputMethod()->inputDirection() == Qt::LeftToRight ?
- QQuickText::AlignLeft : QQuickText::AlignRight);
- text->setHAlign(QQuickText::AlignRight);
- QCOMPARE(text->hAlign(), QQuickText::AlignRight);
-
- delete canvas;
-
- // alignment of Text with no text set to it
- QString componentStr = "import QtQuick 2.0\nText {}";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
- QCOMPARE(textObject->hAlign(), qApp->inputMethod()->inputDirection() == Qt::LeftToRight ?
- QQuickText::AlignLeft : QQuickText::AlignRight);
- delete textObject;
-}
-
-void tst_qquicktext::verticalAlignment()
-{
- //test one align each, and then test if two align fails.
-
- for (int i = 0; i < standard.size(); i++)
- {
- for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
-
- delete textObject;
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
-
- delete textObject;
- }
- }
-
-}
-
-void tst_qquicktext::font()
-{
- //test size, then bold, then italic, then family
- {
- QString componentStr = "import QtQuick 2.0\nText { font.pointSize: 40; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->font().pointSize(), 40);
- QCOMPARE(textObject->font().bold(), false);
- QCOMPARE(textObject->font().italic(), false);
-
- delete textObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nText { font.pixelSize: 40; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->font().pixelSize(), 40);
- QCOMPARE(textObject->font().bold(), false);
- QCOMPARE(textObject->font().italic(), false);
-
- delete textObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nText { font.bold: true; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->font().bold(), true);
- QCOMPARE(textObject->font().italic(), false);
-
- delete textObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nText { font.italic: true; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->font().italic(), true);
- QCOMPARE(textObject->font().bold(), false);
-
- delete textObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nText { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->font().family(), QString("Helvetica"));
- QCOMPARE(textObject->font().bold(), false);
- QCOMPARE(textObject->font().italic(), false);
-
- delete textObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nText { font.family: \"\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->font().family(), QString(""));
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::style()
-{
- //test style
- for (int i = 0; i < styles.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { style: \"" + styleStrings.at(i) + "\"; styleColor: \"white\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE((int)textObject->style(), (int)styles.at(i));
- QCOMPARE(textObject->styleColor(), QColor("white"));
-
- delete textObject;
- }
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QRectF brPre = textObject->boundingRect();
- textObject->setStyle(QQuickText::Outline);
- QRectF brPost = textObject->boundingRect();
-
- QVERIFY(brPre.width() < brPost.width());
- QVERIFY(brPre.height() < brPost.height());
-
- delete textObject;
-}
-
-void tst_qquicktext::color()
-{
- //test style
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
- QCOMPARE(textObject->styleColor(), QColor("black"));
- QCOMPARE(textObject->linkColor(), QColor("blue"));
-
- delete textObject;
- }
-
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i)));
- // default color to black?
- QCOMPARE(textObject->color(), QColor("black"));
- QCOMPARE(textObject->linkColor(), QColor("blue"));
-
- delete textObject;
- }
-
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nText { linkColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->styleColor(), QColor("black"));
- QCOMPARE(textObject->color(), QColor("black"));
- QCOMPARE(textObject->linkColor(), QColor(colorStrings.at(i)));
-
- delete textObject;
- }
-
- for (int i = 0; i < colorStrings.size(); i++)
- {
- for (int j = 0; j < colorStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nText { "
- "color: \"" + colorStrings.at(i) + "\"; "
- "styleColor: \"" + colorStrings.at(j) + "\"; "
- "linkColor: \"" + colorStrings.at(j) + "\"; "
- "text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
- QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(j)));
- QCOMPARE(textObject->linkColor(), QColor(colorStrings.at(j)));
-
- delete textObject;
- }
- }
- {
- QString colorStr = "#AA001234";
- QColor testColor("#001234");
- testColor.setAlpha(170);
-
- QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QCOMPARE(textObject->color(), testColor);
-
- delete textObject;
- } {
- QString colorStr = "#001234";
- QColor testColor(colorStr);
-
- QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QScopedPointer<QObject> object(textComponent.create());
- QQuickText *textObject = qobject_cast<QQuickText*>(object.data());
-
- QSignalSpy spy(textObject, SIGNAL(colorChanged()));
-
- QCOMPARE(textObject->color(), testColor);
- textObject->setColor(testColor);
- QCOMPARE(textObject->color(), testColor);
- QCOMPARE(spy.count(), 0);
-
- testColor = QColor("black");
- textObject->setColor(testColor);
- QCOMPARE(textObject->color(), testColor);
- QCOMPARE(spy.count(), 1);
- } {
- QString colorStr = "#001234";
- QColor testColor(colorStr);
-
- QString componentStr = "import QtQuick 2.0\nText { styleColor: \"" + colorStr + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QScopedPointer<QObject> object(textComponent.create());
- QQuickText *textObject = qobject_cast<QQuickText*>(object.data());
-
- QSignalSpy spy(textObject, SIGNAL(styleColorChanged()));
-
- QCOMPARE(textObject->styleColor(), testColor);
- textObject->setStyleColor(testColor);
- QCOMPARE(textObject->styleColor(), testColor);
- QCOMPARE(spy.count(), 0);
-
- testColor = QColor("black");
- textObject->setStyleColor(testColor);
- QCOMPARE(textObject->styleColor(), testColor);
- QCOMPARE(spy.count(), 1);
- } {
- QString colorStr = "#001234";
- QColor testColor(colorStr);
-
- QString componentStr = "import QtQuick 2.0\nText { linkColor: \"" + colorStr + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QScopedPointer<QObject> object(textComponent.create());
- QQuickText *textObject = qobject_cast<QQuickText*>(object.data());
-
- QSignalSpy spy(textObject, SIGNAL(linkColorChanged()));
-
- QCOMPARE(textObject->linkColor(), testColor);
- textObject->setLinkColor(testColor);
- QCOMPARE(textObject->linkColor(), testColor);
- QCOMPARE(spy.count(), 0);
-
- testColor = QColor("black");
- textObject->setLinkColor(testColor);
- QCOMPARE(textObject->linkColor(), testColor);
- QCOMPARE(spy.count(), 1);
- }
-}
-
-void tst_qquicktext::smooth()
-{
- for (int i = 0; i < standard.size(); i++)
- {
- {
- QString componentStr = "import QtQuick 2.0\nText { smooth: true; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
- QCOMPARE(textObject->smooth(), true);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
- QCOMPARE(textObject->smooth(), false);
-
- delete textObject;
- }
- }
- for (int i = 0; i < richText.size(); i++)
- {
- {
- QString componentStr = "import QtQuick 2.0\nText { smooth: true; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
- QCOMPARE(textObject->smooth(), true);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
- QCOMPARE(textObject->smooth(), false);
-
- delete textObject;
- }
- }
-}
-
-void tst_qquicktext::weight()
-{
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().weight(), (int)QDeclarativeFontValueType::Normal);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { font.weight: \"Bold\"; text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().weight(), (int)QDeclarativeFontValueType::Bold);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::underline()
-{
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().underline(), false);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { font.underline: true; text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().underline(), true);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::overline()
-{
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().overline(), false);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { font.overline: true; text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().overline(), true);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::strikeout()
-{
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().strikeOut(), false);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { font.strikeout: true; text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().strikeOut(), true);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::capitalization()
-{
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::MixedCase);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"AllUppercase\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::AllUppercase);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"AllLowercase\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::AllLowercase);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"SmallCaps\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::SmallCaps);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"Capitalize\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::Capitalize);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::letterSpacing()
-{
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().letterSpacing(), 0.0);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.letterSpacing: -2 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().letterSpacing(), -2.);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.letterSpacing: 3 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().letterSpacing(), 3.);
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::wordSpacing()
-{
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().wordSpacing(), 0.0);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.wordSpacing: -50 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().wordSpacing(), -50.);
-
- delete textObject;
- }
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.wordSpacing: 200 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->font().wordSpacing(), 200.);
-
- delete textObject;
- }
-}
-
-
-
-
-class EventSender : public QQuickItem
-{
-public:
- void sendEvent(QMouseEvent *event) {
- if (event->type() == QEvent::MouseButtonPress)
- mousePressEvent(event);
- else if (event->type() == QEvent::MouseButtonRelease)
- mouseReleaseEvent(event);
- else
- qWarning() << "Trying to send unsupported event type";
- }
-};
-
-class LinkTest : public QObject
-{
- Q_OBJECT
-public:
- LinkTest() {}
-
- QString link;
-
-public slots:
- void linkClicked(QString l) { link = l; }
-};
-
-void tst_qquicktext::clickLink()
-{
- {
- QString componentStr = "import QtQuick 2.0\nText { text: \"<a href=\\\"http://qt.nokia.com\\\">Hello world!</a>\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
-
- LinkTest test;
- QObject::connect(textObject, SIGNAL(linkActivated(QString)), &test, SLOT(linkClicked(QString)));
-
- {
- QMouseEvent me(QEvent::MouseButtonPress,QPointF(textObject->x()/2, textObject->y()/2), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
- static_cast<EventSender*>(static_cast<QQuickItem*>(textObject))->sendEvent(&me);
-
- }
-
- {
- QMouseEvent me(QEvent::MouseButtonRelease,QPointF(textObject->x()/2, textObject->y()/2), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
- static_cast<EventSender*>(static_cast<QQuickItem*>(textObject))->sendEvent(&me);
-
- }
-
-
- QCOMPARE(test.link, QLatin1String("http://qt.nokia.com"));
-
- delete textObject;
- }
-}
-
-void tst_qquicktext::baseUrl()
-{
- QUrl localUrl("file:///tests/text.qml");
- QUrl remoteUrl("http://qt.nokia.com/test.qml");
-
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\n Text {}", localUrl);
- QQuickText *textObject = qobject_cast<QQuickText *>(textComponent.create());
-
- QCOMPARE(textObject->baseUrl(), localUrl);
-
- QSignalSpy spy(textObject, SIGNAL(baseUrlChanged()));
-
- textObject->setBaseUrl(localUrl);
- QCOMPARE(textObject->baseUrl(), localUrl);
- QCOMPARE(spy.count(), 0);
-
- textObject->setBaseUrl(remoteUrl);
- QCOMPARE(textObject->baseUrl(), remoteUrl);
- QCOMPARE(spy.count(), 1);
-
- textObject->resetBaseUrl();
- QCOMPARE(textObject->baseUrl(), localUrl);
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktext::embeddedImages_data()
-{
- QTest::addColumn<QUrl>("qmlfile");
- QTest::addColumn<QString>("error");
- QTest::newRow("local") << testFileUrl("embeddedImagesLocal.qml") << "";
- QTest::newRow("local-error") << testFileUrl("embeddedImagesLocalError.qml")
- << testFileUrl("embeddedImagesLocalError.qml").toString()+":3:1: QML Text: Cannot open: " + testFileUrl("http/notexists.png").toString();
- QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << "";
- QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << "";
- QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml")
- << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found";
- QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << "";
-}
-
-void tst_qquicktext::embeddedImages()
-{
- // Tests QTBUG-9900
-
- QFETCH(QUrl, qmlfile);
- QFETCH(QString, error);
-
- TestHTTPServer server(14453);
- server.serveDirectory(testFile("http"));
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
-
- QDeclarativeComponent textComponent(&engine, qmlfile);
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
-
- QTRY_COMPARE(textObject->resourcesLoading(), 0);
-
- QPixmap pm(testFile("http/exists.png"));
- if (error.isEmpty()) {
- QCOMPARE(textObject->width(), double(pm.width()));
- QCOMPARE(textObject->height(), double(pm.height()));
- } else {
- QVERIFY(16 != pm.width()); // check test is effective
- QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon
- QCOMPARE(textObject->height(), 16.0);
- }
-
- delete textObject;
-}
-
-void tst_qquicktext::lineCount()
-{
- QQuickView *canvas = createView(testFile("lineCount.qml"));
-
- QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
- QVERIFY(myText != 0);
-
- QVERIFY(myText->lineCount() > 1);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->maximumLineCount(), INT_MAX);
-
- myText->setMaximumLineCount(2);
- QCOMPARE(myText->lineCount(), 2);
- QCOMPARE(myText->truncated(), true);
- QCOMPARE(myText->maximumLineCount(), 2);
-
- myText->resetMaximumLineCount();
- QCOMPARE(myText->maximumLineCount(), INT_MAX);
- QCOMPARE(myText->truncated(), false);
-
- myText->setElideMode(QQuickText::ElideRight);
- myText->setMaximumLineCount(2);
- QCOMPARE(myText->lineCount(), 2);
- QCOMPARE(myText->truncated(), true);
- QCOMPARE(myText->maximumLineCount(), 2);
-
- delete canvas;
-}
-
-void tst_qquicktext::lineHeight()
-{
- QQuickView *canvas = createView(testFile("lineHeight.qml"));
-
- QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
- QVERIFY(myText != 0);
-
- QVERIFY(myText->lineHeight() == 1);
- QVERIFY(myText->lineHeightMode() == QQuickText::ProportionalHeight);
-
- qreal h = myText->height();
- myText->setLineHeight(1.5);
- QCOMPARE(myText->height(), qreal(qCeil(h * 1.5)));
-
- myText->setLineHeightMode(QQuickText::FixedHeight);
- myText->setLineHeight(20);
- QCOMPARE(myText->height(), myText->lineCount() * 20.0);
-
- myText->setText("Lorem ipsum sit <b>amet</b>, consectetur adipiscing elit. Integer felis nisl, varius in pretium nec, venenatis non erat. Proin lobortis interdum dictum.");
- myText->setLineHeightMode(QQuickText::ProportionalHeight);
- myText->setLineHeight(1.0);
-
- qreal h2 = myText->height();
- myText->setLineHeight(2.0);
- QVERIFY(myText->height() == h2 * 2.0);
-
- myText->setLineHeightMode(QQuickText::FixedHeight);
- myText->setLineHeight(10);
- QCOMPARE(myText->height(), myText->lineCount() * 10.0);
-
- delete canvas;
-}
-
-void tst_qquicktext::implicitSize_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QString>("width");
- QTest::addColumn<QString>("wrap");
- QTest::addColumn<QString>("elide");
- QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.NoWrap" << "Text.ElideNone";
- QTest::newRow("richtext") << "<b>The quick red fox jumped over the lazy brown dog</b>" <<" 50" << "Text.NoWrap" << "Text.ElideNone";
- QTest::newRow("plain, 0 width") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.NoWrap" << "Text.ElideNone";
- QTest::newRow("plain, elide") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.NoWrap" << "Text.ElideRight";
- QTest::newRow("plain, 0 width, elide") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.NoWrap" << "Text.ElideRight";
- QTest::newRow("richtext, 0 width") << "<b>The quick red fox jumped over the lazy brown dog</b>" <<" 0" << "Text.NoWrap" << "Text.ElideNone";
- QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.Wrap" << "Text.ElideNone";
- QTest::newRow("richtext_wrap") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "50" << "Text.Wrap" << "Text.ElideNone";
- QTest::newRow("plain_wrap, 0 width") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.Wrap" << "Text.ElideNone";
- QTest::newRow("plain_wrap, elide") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.Wrap" << "Text.ElideRight";
- QTest::newRow("plain_wrap, 0 width, elide") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.Wrap" << "Text.ElideRight";
- QTest::newRow("richtext_wrap, 0 width") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "0" << "Text.Wrap" << "Text.ElideNone";
-}
-
-void tst_qquicktext::implicitSize()
-{
- QFETCH(QString, text);
- QFETCH(QString, width);
- QFETCH(QString, wrap);
- QFETCH(QString, elide);
- QString componentStr = "import QtQuick 2.0\nText { "
- "text: \"" + text + "\"; "
- "width: " + width + "; "
- "wrapMode: " + wrap + "; "
- "elide: " + elide + "; "
- "maximumLineCount: 1 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject->width() < textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
-
- textObject->resetWidth();
- QVERIFY(textObject->width() == textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
-
- delete textObject;
-}
-
-void tst_qquicktext::contentSize()
-{
- QString componentStr = "import QtQuick 2.0\nText { width: 75; height: 16; font.pixelSize: 10 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QScopedPointer<QObject> object(textComponent.create());
- QQuickText *textObject = qobject_cast<QQuickText *>(object.data());
-
- QSignalSpy spy(textObject, SIGNAL(contentSizeChanged()));
-
- textObject->setText("The quick red fox jumped over the lazy brown dog");
-
- QVERIFY(textObject->contentWidth() > textObject->width());
- QVERIFY(textObject->contentHeight() < textObject->height());
- QCOMPARE(spy.count(), 1);
-
- textObject->setWrapMode(QQuickText::WordWrap);
- QVERIFY(textObject->contentWidth() <= textObject->width());
- QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), 2);
-
- textObject->setElideMode(QQuickText::ElideRight);
- QVERIFY(textObject->contentWidth() <= textObject->width());
- QVERIFY(textObject->contentHeight() < textObject->height());
- QCOMPARE(spy.count(), 3);
- int spyCount = 3;
- qreal elidedWidth = textObject->contentWidth();
-
- textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
- QVERIFY(textObject->contentWidth() <= textObject->width());
- QVERIFY(textObject->contentHeight() < textObject->height());
- // this text probably won't have the same elided width, but it's not guaranteed.
- if (textObject->contentWidth() != elidedWidth)
- QCOMPARE(spy.count(), ++spyCount);
- else
- QCOMPARE(spy.count(), spyCount);
-
- textObject->setElideMode(QQuickText::ElideNone);
- QVERIFY(textObject->contentWidth() > textObject->width());
- QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), ++spyCount);
-}
-
-void tst_qquicktext::lineLaidOut()
-{
- QQuickView *canvas = createView(testFile("lineLayout.qml"));
-
- QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
- QVERIFY(myText != 0);
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
- QVERIFY(textPrivate != 0);
-
- QTextDocument *doc = textPrivate->textDocument();
- QVERIFY(doc == 0);
-
-#if defined(Q_OS_MAC)
- QVERIFY(myText->lineCount() == textPrivate->linesRects.count());
-#endif
-
- for (int i = 0; i < textPrivate->layout.lineCount(); ++i) {
- QRectF r = textPrivate->layout.lineAt(i).rect();
- QVERIFY(r.width() == i * 15);
- if (i >= 30)
- QVERIFY(r.x() == r.width() + 30);
- if (i >= 60) {
- QVERIFY(r.x() == r.width() * 2 + 60);
- QVERIFY(r.height() == 20);
- }
- }
-
- delete canvas;
-}
-
-void tst_qquicktext::imgTagsBaseUrl_data()
-{
- QTest::addColumn<QUrl>("src");
- QTest::addColumn<QUrl>("baseUrl");
- QTest::addColumn<QUrl>("contextUrl");
- QTest::addColumn<qreal>("imgHeight");
-
- QTest::newRow("absolute local")
- << testFileUrl("images/heart200.png")
- << QUrl()
- << QUrl()
- << 181.;
- QTest::newRow("relative local context 1")
- << QUrl("images/heart200.png")
- << QUrl()
- << testFileUrl("/app.qml")
- << 181.;
- QTest::newRow("relative local context 2")
- << QUrl("heart200.png")
- << QUrl()
- << testFileUrl("images/app.qml")
- << 181.;
- QTest::newRow("relative local base 1")
- << QUrl("images/heart200.png")
- << testFileUrl("")
- << testFileUrl("nonexistant/app.qml")
- << 181.;
- QTest::newRow("relative local base 2")
- << QUrl("heart200.png")
- << testFileUrl("images/")
- << testFileUrl("nonexistant/app.qml")
- << 181.;
- QTest::newRow("base relative to local context")
- << QUrl("heart200.png")
- << testFileUrl("images/")
- << testFileUrl("/app.qml")
- << 181.;
-
- QTest::newRow("absolute remote")
- << QUrl("http://127.0.0.1:14453/images/heart200.png")
- << QUrl()
- << QUrl()
- << 181.;
- QTest::newRow("relative remote base 1")
- << QUrl("images/heart200.png")
- << QUrl("http://127.0.0.1:14453/")
- << testFileUrl("nonexistant/app.qml")
- << 181.;
- QTest::newRow("relative remote base 2")
- << QUrl("heart200.png")
- << QUrl("http://127.0.0.1:14453/images/")
- << testFileUrl("nonexistant/app.qml")
- << 181.;
-}
-
-void tst_qquicktext::imgTagsBaseUrl()
-{
- QFETCH(QUrl, src);
- QFETCH(QUrl, baseUrl);
- QFETCH(QUrl, contextUrl);
- QFETCH(qreal, imgHeight);
-
- TestHTTPServer server(14453);
- server.serveDirectory(testFile(""));
-
- QByteArray baseUrlFragment;
- if (!baseUrl.isEmpty())
- baseUrlFragment = "; baseUrl: \"" + baseUrl.toEncoded() + "\"";
- QByteArray componentStr = "import QtQuick 2.0\nText { text: \"This is a test <img src=\\\"" + src.toEncoded() + "\\\">\"" + baseUrlFragment + " }";
-
- QDeclarativeComponent component(&engine);
- component.setData(componentStr, contextUrl);
- QScopedPointer<QObject> object(component.create());
- QQuickText *textObject = qobject_cast<QQuickText *>(object.data());
- QVERIFY(textObject);
-
- QCoreApplication::processEvents();
-
- QTRY_COMPARE(textObject->height(), imgHeight);
-}
-
-void tst_qquicktext::imgTagsAlign_data()
-{
- QTest::addColumn<QString>("src");
- QTest::addColumn<int>("imgHeight");
- QTest::addColumn<QString>("align");
- QTest::newRow("heart-bottom") << "data/images/heart200.png" << 181 << "bottom";
- QTest::newRow("heart-middle") << "data/images/heart200.png" << 181 << "middle";
- QTest::newRow("heart-top") << "data/images/heart200.png" << 181 << "top";
- QTest::newRow("starfish-bottom") << "data/images/starfish_2.png" << 217 << "bottom";
- QTest::newRow("starfish-middle") << "data/images/starfish_2.png" << 217 << "middle";
- QTest::newRow("starfish-top") << "data/images/starfish_2.png" << 217 << "top";
-}
-
-void tst_qquicktext::imgTagsAlign()
-{
- QFETCH(QString, src);
- QFETCH(int, imgHeight);
- QFETCH(QString, align);
- QString componentStr = "import QtQuick 2.0\nText { text: \"This is a test <img src=\\\"" + src + "\\\" align=\\\"" + align + "\\\"> of image.\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->height() == imgHeight);
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
- QVERIFY(textPrivate != 0);
-
- QRectF br = textPrivate->layout.boundingRect();
- if (align == "bottom")
- QVERIFY(br.y() == imgHeight - br.height());
- else if (align == "middle")
- QVERIFY(br.y() == imgHeight / 2.0 - br.height() / 2.0);
- else if (align == "top")
- QVERIFY(br.y() == 0);
-
- delete textObject;
-}
-
-void tst_qquicktext::imgTagsMultipleImages()
-{
- QString componentStr = "import QtQuick 2.0\nText { text: \"This is a starfish<img src=\\\"data/images/starfish_2.png\\\" width=\\\"60\\\" height=\\\"60\\\" > and another one<img src=\\\"data/images/heart200.png\\\" width=\\\"85\\\" height=\\\"85\\\">.\" }";
-
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->height() == 85);
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
- QVERIFY(textPrivate != 0);
- QVERIFY(textPrivate->visibleImgTags.count() == 2);
-
- delete textObject;
-}
-
-void tst_qquicktext::imgTagsElide()
-{
- QQuickView *canvas = createView(testFile("imgTagsElide.qml"));
- QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
- QVERIFY(myText != 0);
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
- QVERIFY(textPrivate != 0);
- QVERIFY(textPrivate->visibleImgTags.count() == 0);
- myText->setMaximumLineCount(20);
- QTRY_VERIFY(textPrivate->visibleImgTags.count() == 1);
-
- delete myText;
- delete canvas;
-}
-
-void tst_qquicktext::imgTagsUpdates()
-{
- QQuickView *canvas = createView(testFile("imgTagsUpdates.qml"));
- QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
- QVERIFY(myText != 0);
-
- QSignalSpy spy(myText, SIGNAL(contentSizeChanged()));
-
- QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
- QVERIFY(textPrivate != 0);
-
- myText->setText("This is a heart<img src=\"images/heart200.png\">.");
- QVERIFY(textPrivate->visibleImgTags.count() == 1);
- QVERIFY(spy.count() == 1);
-
- myText->setMaximumLineCount(2);
- myText->setText("This is another heart<img src=\"images/heart200.png\">.");
- QTRY_VERIFY(textPrivate->visibleImgTags.count() == 1);
-
- // if maximumLineCount is set and the img tag doesn't have an explicit size
- // we relayout twice.
- QVERIFY(spy.count() == 3);
-
- delete myText;
- delete canvas;
-}
-
-void tst_qquicktext::imgTagsError()
-{
- QString componentStr = "import QtQuick 2.0\nText { text: \"This is a starfish<img src=\\\"data/images/starfish_2.pn\\\" width=\\\"60\\\" height=\\\"60\\\">.\" }";
-
- QDeclarativeComponent textComponent(&engine);
- QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML Text: Cannot open: file:data/images/starfish_2.pn");
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- delete textObject;
-}
-
-void tst_qquicktext::fontSizeMode_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<bool>("canElide");
- QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << true;
- QTest::newRow("richtext") << "<b>The quick red fox jumped over the lazy brown dog</b>" << false;
-}
-
-void tst_qquicktext::fontSizeMode()
-{
- QFETCH(QString, text);
- QFETCH(bool, canElide);
-
- QQuickView *canvas = createView(testFile("fontSizeMode.qml"));
- canvas->show();
-
- QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
- QVERIFY(myText != 0);
-
- myText->setText(text);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- qreal originalWidth = myText->contentWidth();
- qreal originalHeight = myText->contentHeight();
-
- // The original text unwrapped should exceed the width of the item.
- QVERIFY(originalWidth > myText->width());
- QVERIFY(originalHeight < myText->height());
-
- QFont font = myText->font();
- font.setPixelSize(64);
-
- myText->setFont(font);
- myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Font size reduced to fit within the width of the item.
- qreal horizontalFitWidth = myText->contentWidth();
- qreal horizontalFitHeight = myText->contentHeight();
- QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding
- QVERIFY(horizontalFitHeight <= myText->height() + 2);
-
- if (canElide) {
- // Elide won't affect the size with HorizontalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-
- myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Font size increased to fill the height of the item.
- qreal verticalFitHeight = myText->contentHeight();
- QVERIFY(myText->contentWidth() > myText->width());
- QVERIFY(verticalFitHeight <= myText->height() + 2);
- QVERIFY(verticalFitHeight > originalHeight);
-
- if (canElide) {
- // Elide won't affect the height of a single line with VerticalFit but will crop the width.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-
- myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Should be the same as HorizontalFit with no wrapping.
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- if (canElide) {
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-
- myText->setFontSizeMode(QQuickText::FixedSize);
- myText->setWrapMode(QQuickText::Wrap);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- originalWidth = myText->contentWidth();
- originalHeight = myText->contentHeight();
-
- // The original text wrapped should exceed the height of the item.
- QVERIFY(originalWidth <= myText->width() + 2);
- QVERIFY(originalHeight > myText->height());
-
- myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
- // same size as without text wrapping.
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- if (canElide) {
- // Elide won't affect the size with HorizontalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-
- myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // VerticalFit should reduce the size to the wrapped text within the vertical height.
- verticalFitHeight = myText->contentHeight();
- qreal verticalFitWidth = myText->contentWidth();
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(verticalFitHeight <= myText->height() + 2);
- QVERIFY(verticalFitHeight < originalHeight);
-
- if (canElide) {
- // Elide won't affect the height or width of a wrapped text with VerticalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-
- myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Should be the same as VerticalFit with wrapping.
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- if (canElide) {
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-
- myText->setFontSizeMode(QQuickText::FixedSize);
- myText->setMaximumLineCount(2);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- // The original text wrapped should exceed the height of the item.
- QVERIFY(originalWidth <= myText->width() + 2);
- QVERIFY(originalHeight > myText->height());
-
- myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
- // same size as without text wrapping.
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- if (canElide) {
- // Elide won't affect the size with HorizontalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-
- myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // VerticalFit should reduce the size to the wrapped text within the vertical height.
- verticalFitHeight = myText->contentHeight();
- verticalFitWidth = myText->contentWidth();
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(verticalFitHeight <= myText->height() + 2);
- QVERIFY(verticalFitHeight < originalHeight);
-
- if (canElide) {
- // Elide won't affect the height or width of a wrapped text with VerticalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-
- myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Should be the same as VerticalFit with wrapping.
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- if (canElide) {
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-}
-
-void tst_qquicktext::fontSizeModeMultiline_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<bool>("canElide");
- QTest::newRow("plain") << "The quick red fox jumped\n over the lazy brown dog" << true;
- QTest::newRow("richtext") << "<b>The quick red fox jumped<br/> over the lazy brown dog</b>" << false;
-}
-
-void tst_qquicktext::fontSizeModeMultiline()
-{
- QFETCH(QString, text);
- QFETCH(bool, canElide);
-
- QQuickView *canvas = createView(testFile("fontSizeMode.qml"));
- canvas->show();
-
- QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
- QVERIFY(myText != 0);
-
- myText->setText(text);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- qreal originalWidth = myText->contentWidth();
- qreal originalHeight = myText->contentHeight();
- QCOMPARE(myText->lineCount(), 2);
-
- // The original text unwrapped should exceed the width and height of the item.
- QVERIFY(originalWidth > myText->width());
- QVERIFY(originalHeight > myText->height());
-
- QFont font = myText->font();
- font.setPixelSize(64);
-
- myText->setFont(font);
- myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Font size reduced to fit within the width of the item.
- QCOMPARE(myText->lineCount(), 2);
- qreal horizontalFitWidth = myText->contentWidth();
- qreal horizontalFitHeight = myText->contentHeight();
- QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding
- QVERIFY(horizontalFitHeight > myText->height());
-
- if (canElide) {
- // Right eliding will remove the last line
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QCOMPARE(myText->lineCount(), 1);
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(myText->contentHeight() <= myText->height() + 2);
-
- // Left or middle eliding wont have any effect.
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-
- myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Font size reduced to fit within the height of the item.
- qreal verticalFitWidth = myText->contentWidth();
- qreal verticalFitHeight = myText->contentHeight();
- QVERIFY(verticalFitWidth <= myText->width() + 2);
- QVERIFY(verticalFitHeight <= myText->height() + 2);
-
- if (canElide) {
- // Elide will have no effect.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-
- myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Should be the same as VerticalFit with no wrapping.
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- if (canElide) {
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideLeft);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideMiddle);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-
- myText->setFontSizeMode(QQuickText::FixedSize);
- myText->setWrapMode(QQuickText::Wrap);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- originalWidth = myText->contentWidth();
- originalHeight = myText->contentHeight();
-
- // The original text wrapped should exceed the height of the item.
- QVERIFY(originalWidth <= myText->width() + 2);
- QVERIFY(originalHeight > myText->height());
-
- myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
- // same size as without text wrapping.
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- if (canElide) {
- // Text will be elided vertically with HorizontalFit
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(myText->contentHeight() <= myText->height() + 2);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-
- myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // VerticalFit should reduce the size to the wrapped text within the vertical height.
- verticalFitHeight = myText->contentHeight();
- verticalFitWidth = myText->contentWidth();
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(verticalFitHeight <= myText->height() + 2);
- QVERIFY(verticalFitHeight < originalHeight);
-
- if (canElide) {
- // Elide won't affect the height or width of a wrapped text with VerticalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-
- myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Should be the same as VerticalFit with wrapping.
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- if (canElide) {
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-
- myText->setFontSizeMode(QQuickText::FixedSize);
- myText->setMaximumLineCount(2);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- // The original text wrapped should exceed the height of the item.
- QVERIFY(originalWidth <= myText->width() + 2);
- QVERIFY(originalHeight > myText->height());
-
- myText->setFontSizeMode(QQuickText::HorizontalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
- // same size as without text wrapping.
- QCOMPARE(myText->contentWidth(), horizontalFitWidth);
- QCOMPARE(myText->contentHeight(), horizontalFitHeight);
-
- if (canElide) {
- // Elide won't affect the size with HorizontalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(myText->truncated());
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(myText->contentHeight() <= myText->height() + 2);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-
- myText->setFontSizeMode(QQuickText::VerticalFit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // VerticalFit should reduce the size to the wrapped text within the vertical height.
- verticalFitHeight = myText->contentHeight();
- verticalFitWidth = myText->contentWidth();
- QVERIFY(myText->contentWidth() <= myText->width() + 2);
- QVERIFY(verticalFitHeight <= myText->height() + 2);
- QVERIFY(verticalFitHeight < originalHeight);
-
- if (canElide) {
- // Elide won't affect the height or width of a wrapped text with VerticalFit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-
- myText->setFontSizeMode(QQuickText::Fit);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- // Should be the same as VerticalFit with wrapping.
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- if (canElide) {
- // Elide won't affect the size with Fit.
- myText->setElideMode(QQuickText::ElideRight);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- QVERIFY(!myText->truncated());
- QCOMPARE(myText->contentWidth(), verticalFitWidth);
- QCOMPARE(myText->contentHeight(), verticalFitHeight);
-
- myText->setElideMode(QQuickText::ElideNone);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- }
-}
-
-void tst_qquicktext::multilengthStrings_data()
-{
- QTest::addColumn<QString>("source");
- QTest::newRow("No Wrap") << testFile("multilengthStrings.qml");
- QTest::newRow("Wrap") << testFile("multilengthStringsWrapped.qml");
-}
-
-void tst_qquicktext::multilengthStrings()
-{
- QFETCH(QString, source);
-
- QScopedPointer<QQuickView> canvas(createView(source));
- canvas->show();
-
- QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
- QVERIFY(myText != 0);
-
- const QString longText = "the quick brown fox jumped over the lazy dog";
- const QString mediumText = "the brown fox jumped over the dog";
- const QString shortText = "fox jumped dog";
-
- myText->setText(longText);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- const qreal longWidth = myText->contentWidth();
- const qreal longHeight = myText->contentHeight();
-
- myText->setText(mediumText);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- const qreal mediumWidth = myText->contentWidth();
- const qreal mediumHeight = myText->contentHeight();
-
- myText->setText(shortText);
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
- const qreal shortWidth = myText->contentWidth();
- const qreal shortHeight = myText->contentHeight();
-
- myText->setElideMode(QQuickText::ElideRight);
- myText->setText(longText + QLatin1Char('\x9c') + mediumText + QLatin1Char('\x9c') + shortText);
-
- myText->setSize(QSizeF(longWidth, longHeight));
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- QCOMPARE(myText->contentWidth(), longWidth);
- QCOMPARE(myText->contentHeight(), longHeight);
- QCOMPARE(myText->truncated(), false);
-
- myText->setSize(QSizeF(mediumWidth, mediumHeight));
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- QCOMPARE(myText->contentWidth(), mediumWidth);
- QCOMPARE(myText->contentHeight(), mediumHeight);
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("Wrap", "QTBUG-24310", Continue);
-#endif
- QCOMPARE(myText->truncated(), true);
-
- myText->setSize(QSizeF(shortWidth, shortHeight));
- QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
-
- QCOMPARE(myText->contentWidth(), shortWidth);
- QCOMPARE(myText->contentHeight(), shortHeight);
- QCOMPARE(myText->truncated(), true);
-}
-
-QTEST_MAIN(tst_qquicktext)
-
-#include "tst_qquicktext.moc"
diff --git a/tests/auto/qtquick2/qquicktextedit/qquicktextedit.pro b/tests/auto/qtquick2/qquicktextedit/qquicktextedit.pro
deleted file mode 100644
index 6f74761b7b..0000000000
--- a/tests/auto/qtquick2/qquicktextedit/qquicktextedit.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquicktextedit
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquicktextedit.cpp \
- ../../shared/testhttpserver.cpp
-
-HEADERS += ../../shared/testhttpserver.h
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private network widgets-private testlib
diff --git a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp
deleted file mode 100644
index 41c8546688..0000000000
--- a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp
+++ /dev/null
@@ -1,3884 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include "../../shared/testhttpserver.h"
-#include <math.h>
-#include <QFile>
-#include <QTextDocument>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtGui/qguiapplication.h>
-#include <private/qquicktextedit_p.h>
-#include <private/qquicktextedit_p_p.h>
-#include <private/qquicktext_p_p.h>
-#include <QFontMetrics>
-#include <QtQuick/QQuickView>
-#include <QDir>
-#include <QStyle>
-#include <QInputMethod>
-#include <QClipboard>
-#include <QMimeData>
-#include <private/qquicktextcontrol_p.h>
-#include "../../shared/util.h"
-#include "../../shared/platforminputcontext.h"
-#include <private/qinputmethod_p.h>
-
-#ifdef Q_OS_MAC
-#include <Carbon/Carbon.h>
-#endif
-
-
-Q_DECLARE_METATYPE(QQuickTextEdit::SelectionMode)
-DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
-
-QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual)
-{
- // XXX This will be replaced by some clever persistent platform image store.
- QString persistent_dir = QDeclarativeDataTest::instance()->dataDirectory();
- QString arch = "unknown-architecture"; // QTest needs to help with this.
-
- QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png";
-
- if (!QFile::exists(expectfile)) {
- actual.save(expectfile);
- qWarning() << "created" << expectfile;
- }
-
- return expectfile;
-}
-
-typedef QPair<int, QChar> Key;
-
-class tst_qquicktextedit : public QDeclarativeDataTest
-
-{
- Q_OBJECT
-public:
- tst_qquicktextedit();
-
-private slots:
- void cleanup();
- void text();
- void width();
- void wrap();
- void textFormat();
- void alignments();
- void alignments_data();
-
- // ### these tests may be trivial
- void hAlign();
- void hAlign_RightToLeft();
- void vAlign();
- void font();
- void color();
- void textMargin();
- void persistentSelection();
- void focusOnPress();
- void selection();
- void isRightToLeft_data();
- void isRightToLeft();
- void keySelection();
- void moveCursorSelection_data();
- void moveCursorSelection();
- void moveCursorSelectionSequence_data();
- void moveCursorSelectionSequence();
- void mouseSelection_data();
- void mouseSelection();
- void mouseSelectionMode_data();
- void mouseSelectionMode();
- void dragMouseSelection();
- void inputMethodHints();
-
- void positionAt();
-
- void linkActivated();
-
- void cursorDelegate_data();
- void cursorDelegate();
- void cursorVisible();
- void delegateLoading_data();
- void delegateLoading();
- void navigation();
- void readOnly();
- void copyAndPaste();
- void canPaste();
- void canPasteEmpty();
- void textInput();
- void inputMethodUpdate();
- void openInputPanel();
- void geometrySignals();
- void pastingRichText_QTBUG_14003();
- void implicitSize_data();
- void implicitSize();
- void contentSize();
-
- void preeditCursorRectangle();
- void inputMethodComposing();
- void cursorRectangleSize();
-
- void getText_data();
- void getText();
- void getFormattedText_data();
- void getFormattedText();
- void insert_data();
- void insert();
- void remove_data();
- void remove();
-
- void keySequence_data();
- void keySequence();
-
- void undo_data();
- void undo();
- void redo_data();
- void redo();
- void undo_keypressevents_data();
- void undo_keypressevents();
-
- void baseUrl();
- void embeddedImages();
- void embeddedImages_data();
-
- void emptytags_QTBUG_22058();
-
-private:
- void simulateKeys(QWindow *window, const QList<Key> &keys);
- void simulateKeys(QWindow *window, const QKeySequence &sequence);
-
- void simulateKey(QQuickView *, int key, Qt::KeyboardModifiers modifiers = 0);
-
- QStringList standard;
- QStringList richText;
-
- QStringList hAlignmentStrings;
- QStringList vAlignmentStrings;
-
- QList<Qt::Alignment> vAlignments;
- QList<Qt::Alignment> hAlignments;
-
- QStringList colorStrings;
-
- QDeclarativeEngine engine;
-};
-
-typedef QList<int> IntList;
-Q_DECLARE_METATYPE(IntList)
-
-typedef QList<Key> KeyList;
-Q_DECLARE_METATYPE(KeyList)
-
-Q_DECLARE_METATYPE(QQuickTextEdit::TextFormat)
-
-void tst_qquicktextedit::simulateKeys(QWindow *window, const QList<Key> &keys)
-{
- for (int i = 0; i < keys.count(); ++i) {
- const int key = keys.at(i).first;
- const int modifiers = key & Qt::KeyboardModifierMask;
- const QString text = !keys.at(i).second.isNull() ? QString(keys.at(i).second) : QString();
-
- QKeyEvent press(QEvent::KeyPress, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text);
- QKeyEvent release(QEvent::KeyRelease, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text);
-
- QGuiApplication::sendEvent(window, &press);
- QGuiApplication::sendEvent(window, &release);
- }
-}
-
-void tst_qquicktextedit::simulateKeys(QWindow *window, const QKeySequence &sequence)
-{
- for (int i = 0; i < sequence.count(); ++i) {
- const int key = sequence[i];
- const int modifiers = key & Qt::KeyboardModifierMask;
-
- QTest::keyClick(window, Qt::Key(key & ~modifiers), Qt::KeyboardModifiers(modifiers));
- }
-}
-
-QList<Key> &operator <<(QList<Key> &keys, const QKeySequence &sequence)
-{
- for (int i = 0; i < sequence.count(); ++i)
- keys << Key(sequence[i], QChar());
- return keys;
-}
-
-template <int N> QList<Key> &operator <<(QList<Key> &keys, const char (&characters)[N])
-{
- for (int i = 0; i < N - 1; ++i) {
- int key = QTest::asciiToKey(characters[i]);
- QChar character = QLatin1Char(characters[i]);
- keys << Key(key, character);
- }
- return keys;
-}
-
-QList<Key> &operator <<(QList<Key> &keys, Qt::Key key)
-{
- keys << Key(key, QChar());
- return keys;
-}
-
-tst_qquicktextedit::tst_qquicktextedit()
-{
- standard << "the quick brown fox jumped over the lazy dog"
- << "the quick brown fox\n jumped over the lazy dog"
- << "Hello, world!"
- << "!dlrow ,olleH";
-
- richText << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a> jumped over the <b>lazy</b> dog</i>"
- << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
-
- hAlignmentStrings << "AlignLeft"
- << "AlignRight"
- << "AlignHCenter";
-
- vAlignmentStrings << "AlignTop"
- << "AlignBottom"
- << "AlignVCenter";
-
- hAlignments << Qt::AlignLeft
- << Qt::AlignRight
- << Qt::AlignHCenter;
-
- vAlignments << Qt::AlignTop
- << Qt::AlignBottom
- << Qt::AlignVCenter;
-
- colorStrings << "aliceblue"
- << "antiquewhite"
- << "aqua"
- << "darkkhaki"
- << "darkolivegreen"
- << "dimgray"
- << "palevioletred"
- << "lightsteelblue"
- << "#000000"
- << "#AAAAAA"
- << "#FFFFFF"
- << "#2AC05F";
- //
- // need a different test to do alpha channel test
- // << "#AA0011DD"
- // << "#00F16B11";
- //
-}
-
-void tst_qquicktextedit::cleanup()
-{
- // ensure not even skipped tests with custom input context leave it dangling
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = 0;
-}
-
-void tst_qquicktextedit::text()
-{
- {
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\" }", QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->text(), QString(""));
- QCOMPARE(textEditObject->length(), 0);
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->text(), standard.at(i));
- QCOMPARE(textEditObject->length(), standard.at(i).length());
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
-
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
-
- QString expected = richText.at(i);
- expected.replace(QRegExp("\\\\(.)"),"\\1");
- QCOMPARE(textEditObject->text(), expected);
- QCOMPARE(textEditObject->length(), expected.length());
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
-
- QString actual = textEditObject->text();
- QString expected = standard.at(i);
- actual.remove(QRegExp(".*<body[^>]*>"));
- actual.remove(QRegExp("(<[^>]*>)+"));
- expected.remove("\n");
- QCOMPARE(actual.simplified(), expected);
- QCOMPARE(textEditObject->length(), expected.length());
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QString actual = textEditObject->text();
- QString expected = richText.at(i);
- actual.replace(QRegExp(".*<body[^>]*>"),"");
- actual.replace(QRegExp("(<[^>]*>)+"),"<>");
- expected.replace(QRegExp("(<[^>]*>)+"),"<>");
- QCOMPARE(actual.simplified(),expected.simplified());
-
- expected.replace("<>", " ");
- QCOMPARE(textEditObject->length(), expected.simplified().length());
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->text(), standard.at(i));
- QCOMPARE(textEditObject->length(), standard.at(i).length());
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QString actual = textEditObject->text();
- QString expected = richText.at(i);
- actual.replace(QRegExp(".*<body[^>]*>"),"");
- actual.replace(QRegExp("(<[^>]*>)+"),"<>");
- expected.replace(QRegExp("(<[^>]*>)+"),"<>");
- QCOMPARE(actual.simplified(),expected.simplified());
-
- expected.replace("<>", " ");
- QCOMPARE(textEditObject->length(), expected.simplified().length());
- }
-}
-
-void tst_qquicktextedit::width()
-{
- // uses Font metrics to find the width for standard and document to find the width for rich
- {
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\" }", QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 0.0);
- }
-
- bool requiresUnhintedMetrics = !qmlDisableDistanceField();
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QString s = standard.at(i);
- s.replace(QLatin1Char('\n'), QChar::LineSeparator);
-
- QTextLayout layout(s);
- layout.setFont(textEditObject->font());
- layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic);
- if (requiresUnhintedMetrics) {
- QTextOption option;
- option.setUseDesignMetrics(true);
- layout.setTextOption(option);
- }
-
- layout.beginLayout();
- forever {
- QTextLine line = layout.createLine();
- if (!line.isValid())
- break;
- }
-
- layout.endLayout();
-
- qreal metricWidth = ceil(layout.boundingRect().width());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), qreal(metricWidth));
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QTextDocument document;
- document.setHtml(richText.at(i));
- document.setDocumentMargin(0);
- if (requiresUnhintedMetrics)
- document.setUseDesignMetrics(true);
-
- int documentWidth = ceil(document.idealWidth());
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), qreal(documentWidth));
- }
-}
-
-void tst_qquicktextedit::wrap()
-{
- // for specified width and wrap set true
- {
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\"; wrapMode: TextEdit.WordWrap; width: 300 }", QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 300.);
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 300.);
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->width(), 300.);
- }
-
-}
-
-void tst_qquicktextedit::textFormat()
-{
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nTextEdit { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
- QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QQuickTextEdit::RichText);
- }
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nTextEdit { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
- QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->textFormat() == QQuickTextEdit::PlainText);
- }
-}
-
-void tst_qquicktextedit::alignments_data()
-{
- QTest::addColumn<int>("hAlign");
- QTest::addColumn<int>("vAlign");
- QTest::addColumn<QString>("expectfile");
-
- QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << "alignments_lt";
- QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << "alignments_rt";
- QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << "alignments_ct";
-
- QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << "alignments_lb";
- QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << "alignments_rb";
- QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << "alignments_cb";
-
- QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << "alignments_lc";
- QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << "alignments_rc";
- QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << "alignments_cc";
-}
-
-
-void tst_qquicktextedit::alignments()
-{
- QSKIP("Image comparison of text is almost guaranteed to fail during development");
-
- QFETCH(int, hAlign);
- QFETCH(int, vAlign);
- QFETCH(QString, expectfile);
-
- QQuickView canvas(testFileUrl("alignments.qml"));
-
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QObject *ob = canvas.rootObject();
- QVERIFY(ob != 0);
- ob->setProperty("horizontalAlignment",hAlign);
- ob->setProperty("verticalAlignment",vAlign);
- QTRY_COMPARE(ob->property("running").toBool(),false);
- QImage actual = canvas.grabFrameBuffer();
-
- expectfile = createExpectedFileIfNotFound(expectfile, actual);
-
- QImage expect(expectfile);
-
- QCOMPARE(actual,expect);
-}
-
-
-//the alignment tests may be trivial o.oa
-void tst_qquicktextedit::hAlign()
-{
- //test one align each, and then test if two align fails.
-
- for (int i = 0; i < standard.size(); i++)
- {
- for (int j=0; j < hAlignmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < hAlignmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
- }
- }
-
-}
-
-void tst_qquicktextedit::hAlign_RightToLeft()
-{
- PlatformInputContext platformInputContext;
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = &platformInputContext;
-
- QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml"));
- QQuickTextEdit *textEdit = canvas.rootObject()->findChild<QQuickTextEdit*>("text");
- QVERIFY(textEdit != 0);
- canvas.show();
-
- const QString rtlText = textEdit->text();
-
- // implicit alignment should follow the reading direction of text
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- // explicitly left aligned
- textEdit->setHAlign(QQuickTextEdit::AlignLeft);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
- QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
-
- // explicitly right aligned
- textEdit->setHAlign(QQuickTextEdit::AlignRight);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- QString textString = textEdit->text();
- textEdit->setText(QString("<i>") + textString + QString("</i>"));
- textEdit->resetHAlign();
-
- // implicitly aligned rich text should follow the reading direction of RTL text
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign());
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- // explicitly left aligned rich text
- textEdit->setHAlign(QQuickTextEdit::AlignLeft);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
- QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign());
- QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
-
- // explicitly right aligned rich text
- textEdit->setHAlign(QQuickTextEdit::AlignRight);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign());
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- textEdit->setText(textString);
-
- // explicitly center aligned
- textEdit->setHAlign(QQuickTextEdit::AlignHCenter);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignHCenter);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- // reseted alignment should go back to following the text reading direction
- textEdit->resetHAlign();
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- // mirror the text item
- QQuickItemPrivate::get(textEdit)->setLayoutMirror(true);
-
- // mirrored implicit alignment should continue to follow the reading direction of the text
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- // mirrored explicitly right aligned behaves as left aligned
- textEdit->setHAlign(QQuickTextEdit::AlignRight);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignLeft);
- QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
-
- // mirrored explicitly left aligned behaves as right aligned
- textEdit->setHAlign(QQuickTextEdit::AlignLeft);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
- QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- // disable mirroring
- QQuickItemPrivate::get(textEdit)->setLayoutMirror(false);
- textEdit->resetHAlign();
-
- // English text should be implicitly left aligned
- textEdit->setText("Hello world!");
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
- QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
-
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- textEdit->setText(QString());
- { QInputMethodEvent ev(rtlText, QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- { QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
-
- // Clear pre-edit text. TextEdit should maybe do this itself on setText, but that may be
- // redundant as an actual input method may take care of it.
- { QInputMethodEvent ev; QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
-
- // empty text with implicit alignment follows the system locale-based
- // keyboard input direction from qApp->inputMethod()->inputDirection
- textEdit->setText("");
- platformInputContext.setInputDirection(Qt::LeftToRight);
- QVERIFY(qApp->inputMethod()->inputDirection() == Qt::LeftToRight);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
- QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
-
- QSignalSpy cursorRectangleSpy(textEdit, SIGNAL(cursorRectangleChanged()));
-
- platformInputContext.setInputDirection(Qt::RightToLeft);
- QCOMPARE(cursorRectangleSpy.count(), 1);
- QVERIFY(qApp->inputMethod()->inputDirection() == Qt::RightToLeft);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-
- // set input direction while having content
- platformInputContext.setInputDirection(Qt::LeftToRight);
- textEdit->setText("a");
- textEdit->setCursorPosition(1);
- platformInputContext.setInputDirection(Qt::RightToLeft);
- QTest::keyClick(&canvas, Qt::Key_Backspace);
- QVERIFY(textEdit->text().isEmpty());
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->cursorRectangle().left() > canvas.width()/2);
-
- // input direction changed while not having focus
- platformInputContext.setInputDirection(Qt::LeftToRight);
- textEdit->setFocus(false);
- platformInputContext.setInputDirection(Qt::RightToLeft);
- textEdit->setFocus(true);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->cursorRectangle().left() > canvas.width()/2);
-
- textEdit->setHAlign(QQuickTextEdit::AlignRight);
- QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
- QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
-}
-
-void tst_qquicktextedit::vAlign()
-{
- //test one align each, and then test if two align fails.
-
- for (int i = 0; i < standard.size(); i++)
- {
- for (int j=0; j < vAlignmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
- }
- }
-
- for (int i = 0; i < richText.size(); i++)
- {
- for (int j=0; j < vAlignmentStrings.size(); j++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
- }
- }
-
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(
- "import QtQuick 2.0\n"
- "TextEdit { width: 100; height: 100; text: \"Hello World\" }", QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
-
- QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignTop);
- QVERIFY(textEditObject->cursorRectangle().bottom() < 50);
- QVERIFY(textEditObject->positionToRectangle(0).bottom() < 50);
-
- // bottom aligned
- textEditObject->setVAlign(QQuickTextEdit::AlignBottom);
- QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignBottom);
- QVERIFY(textEditObject->cursorRectangle().top() > 50);
- QVERIFY(textEditObject->positionToRectangle(0).top() > 50);
-
- // explicitly center aligned
- textEditObject->setVAlign(QQuickTextEdit::AlignVCenter);
- QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignVCenter);
- QVERIFY(textEditObject->cursorRectangle().top() < 50);
- QVERIFY(textEditObject->cursorRectangle().bottom() > 50);
- QVERIFY(textEditObject->positionToRectangle(0).top() < 50);
- QVERIFY(textEditObject->positionToRectangle(0).bottom() > 50);
-}
-
-void tst_qquicktextedit::font()
-{
- //test size, then bold, then italic, then family
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { font.pointSize: 40; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().pointSize(), 40);
- QCOMPARE(textEditObject->font().bold(), false);
- QCOMPARE(textEditObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { font.bold: true; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().bold(), true);
- QCOMPARE(textEditObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { font.italic: true; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().italic(), true);
- QCOMPARE(textEditObject->font().bold(), false);
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().family(), QString("Helvetica"));
- QCOMPARE(textEditObject->font().bold(), false);
- QCOMPARE(textEditObject->font().italic(), false);
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { font.family: \"\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->font().family(), QString(""));
- }
-}
-
-void tst_qquicktextedit::color()
-{
- //test initial color
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QQuickTextEditPrivate *textEditPrivate = static_cast<QQuickTextEditPrivate*>(QQuickItemPrivate::get(textEditObject));
-
- QVERIFY(textEditObject);
- QVERIFY(textEditPrivate);
- QVERIFY(textEditPrivate->control);
-
- QPalette pal = textEditPrivate->control->palette();
- QCOMPARE(textEditPrivate->color, QColor("black"));
- QCOMPARE(textEditPrivate->color, pal.color(QPalette::Text));
- }
- //test normal
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
- //qDebug() << "textEditObject: " << textEditObject->color() << "vs. " << QColor(colorStrings.at(i));
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->color(), QColor(colorStrings.at(i)));
- }
-
- //test selection
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->selectionColor(), QColor(colorStrings.at(i)));
- }
-
- //test selected text
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->selectedTextColor(), QColor(colorStrings.at(i)));
- }
-
- {
- QString colorStr = "#AA001234";
- QColor testColor("#001234");
- testColor.setAlpha(170);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
-
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->color(), testColor);
- }
-}
-
-void tst_qquicktextedit::textMargin()
-{
- for (qreal i=0; i<=10; i+=0.3) {
- QString componentStr = "import QtQuick 2.0\nTextEdit { textMargin: " + QString::number(i) + "; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->textMargin(), i);
- }
-}
-
-void tst_qquicktextedit::persistentSelection()
-{
- QQuickView canvas(testFileUrl("persistentSelection.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
- canvas.requestActivateWindow();
-
- QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
- QVERIFY(edit);
- QVERIFY(edit->hasActiveFocus());
-
- QSignalSpy spy(edit, SIGNAL(persistentSelectionChanged(bool)));
-
- QCOMPARE(edit->persistentSelection(), false);
-
- edit->setPersistentSelection(false);
- QCOMPARE(edit->persistentSelection(), false);
- QCOMPARE(spy.count(), 0);
-
- edit->select(1, 4);
- QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
-
- edit->setFocus(false);
- QCOMPARE(edit->property("selected").toString(), QString());
-
- edit->setFocus(true);
- QCOMPARE(edit->property("selected").toString(), QString());
-
- edit->setPersistentSelection(true);
- QCOMPARE(edit->persistentSelection(), true);
- QCOMPARE(spy.count(), 1);
-
- edit->select(1, 4);
- QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
-
- edit->setFocus(false);
- QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
-
- edit->setFocus(true);
- QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
-
-}
-
-void tst_qquicktextedit::focusOnPress()
-{
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { activeFocusOnPress: true; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->focusOnPress(), true);
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextEdit { activeFocusOnPress: false; text: \"Hello World\" }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
- QCOMPARE(textEditObject->focusOnPress(), false);
- }
-}
-
-void tst_qquicktextedit::selection()
-{
- QString testStr = standard[0];//TODO: What should happen for multiline/rich text?
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
- QVERIFY(textEditObject != 0);
-
-
- //Test selection follows cursor
- for (int i=0; i<= testStr.size(); i++) {
- textEditObject->setCursorPosition(i);
- QCOMPARE(textEditObject->cursorPosition(), i);
- QCOMPARE(textEditObject->selectionStart(), i);
- QCOMPARE(textEditObject->selectionEnd(), i);
- QVERIFY(textEditObject->selectedText().isNull());
- }
-
- textEditObject->setCursorPosition(0);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
- QVERIFY(textEditObject->selectedText().isNull());
-
- // Verify invalid positions are ignored.
- textEditObject->setCursorPosition(-1);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
- QVERIFY(textEditObject->selectedText().isNull());
-
- textEditObject->setCursorPosition(textEditObject->text().count()+1);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
- QVERIFY(textEditObject->selectedText().isNull());
-
- //Test selection
- for (int i=0; i<= testStr.size(); i++) {
- textEditObject->select(0,i);
- QCOMPARE(testStr.mid(0,i), textEditObject->selectedText());
- }
- for (int i=0; i<= testStr.size(); i++) {
- textEditObject->select(i,testStr.size());
- QCOMPARE(testStr.mid(i,testStr.size()-i), textEditObject->selectedText());
- }
-
- textEditObject->setCursorPosition(0);
- QVERIFY(textEditObject->cursorPosition() == 0);
- QVERIFY(textEditObject->selectionStart() == 0);
- QVERIFY(textEditObject->selectionEnd() == 0);
- QVERIFY(textEditObject->selectedText().isNull());
-
- //Test Error Ignoring behaviour
- textEditObject->setCursorPosition(0);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(-10,0);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(100,101);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(0,-10);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(0,100);
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(0,10);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->select(-10,0);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->select(100,101);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->select(0,-10);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->select(0,100);
- QVERIFY(textEditObject->selectedText().size() == 10);
-
- textEditObject->deselect();
- QVERIFY(textEditObject->selectedText().isNull());
- textEditObject->select(0,10);
- QVERIFY(textEditObject->selectedText().size() == 10);
- textEditObject->deselect();
- QVERIFY(textEditObject->selectedText().isNull());
-}
-
-void tst_qquicktextedit::isRightToLeft_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<bool>("emptyString");
- QTest::addColumn<bool>("firstCharacter");
- QTest::addColumn<bool>("lastCharacter");
- QTest::addColumn<bool>("middleCharacter");
- QTest::addColumn<bool>("startString");
- QTest::addColumn<bool>("midString");
- QTest::addColumn<bool>("endString");
-
- const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647};
- QTest::newRow("Empty") << "" << false << false << false << false << false << false << false;
- QTest::newRow("Neutral") << "23244242" << false << false << false << false << false << false << false;
- QTest::newRow("LTR") << "Hello world" << false << false << false << false << false << false << false;
- QTest::newRow("RTL") << QString::fromUtf16(arabic_str, 11) << false << true << true << true << true << true << true;
- QTest::newRow("Bidi RTL + LTR + RTL") << QString::fromUtf16(arabic_str, 11) + QString("Hello world") + QString::fromUtf16(arabic_str, 11) << false << true << true << false << true << true << true;
- QTest::newRow("Bidi LTR + RTL + LTR") << QString("Hello world") + QString::fromUtf16(arabic_str, 11) + QString("Hello world") << false << false << false << true << false << false << false;
-}
-
-void tst_qquicktextedit::isRightToLeft()
-{
- QFETCH(QString, text);
- QFETCH(bool, emptyString);
- QFETCH(bool, firstCharacter);
- QFETCH(bool, lastCharacter);
- QFETCH(bool, middleCharacter);
- QFETCH(bool, startString);
- QFETCH(bool, midString);
- QFETCH(bool, endString);
-
- QQuickTextEdit textEdit;
- textEdit.setText(text);
-
- // first test that the right string is delivered to the QString::isRightToLeft()
- QCOMPARE(textEdit.isRightToLeft(0,0), text.mid(0,0).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(0,1), text.mid(0,1).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(text.count()-2, text.count()-1), text.mid(text.count()-2, text.count()-1).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(text.count()/2, text.count()/2 + 1), text.mid(text.count()/2, text.count()/2 + 1).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(0,text.count()/4), text.mid(0,text.count()/4).isRightToLeft());
- QCOMPARE(textEdit.isRightToLeft(text.count()/4,3*text.count()/4), text.mid(text.count()/4,3*text.count()/4).isRightToLeft());
- if (text.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start.");
- QCOMPARE(textEdit.isRightToLeft(3*text.count()/4,text.count()-1), text.mid(3*text.count()/4,text.count()-1).isRightToLeft());
-
- // then test that the feature actually works
- QCOMPARE(textEdit.isRightToLeft(0,0), emptyString);
- QCOMPARE(textEdit.isRightToLeft(0,1), firstCharacter);
- QCOMPARE(textEdit.isRightToLeft(text.count()-2, text.count()-1), lastCharacter);
- QCOMPARE(textEdit.isRightToLeft(text.count()/2, text.count()/2 + 1), middleCharacter);
- QCOMPARE(textEdit.isRightToLeft(0,text.count()/4), startString);
- QCOMPARE(textEdit.isRightToLeft(text.count()/4,3*text.count()/4), midString);
- if (text.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start.");
- QCOMPARE(textEdit.isRightToLeft(3*text.count()/4,text.count()-1), endString);
-}
-
-void tst_qquicktextedit::keySelection()
-{
- QQuickView canvas(testFileUrl("navigation.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
- canvas.requestActivateWindow();
-
- QVERIFY(canvas.rootObject() != 0);
-
- QQuickTextEdit *input = qobject_cast<QQuickTextEdit *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
-
- QSignalSpy spy(input, SIGNAL(selectionChanged()));
-
- simulateKey(&canvas, Qt::Key_Right, Qt::ShiftModifier);
- QVERIFY(input->hasActiveFocus() == true);
- QCOMPARE(input->selectedText(), QString("a"));
- QCOMPARE(spy.count(), 1);
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
- QCOMPARE(input->selectedText(), QString());
- QCOMPARE(spy.count(), 2);
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == false);
- QCOMPARE(input->selectedText(), QString());
- QCOMPARE(spy.count(), 2);
-
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
- QCOMPARE(spy.count(), 2);
- simulateKey(&canvas, Qt::Key_Left, Qt::ShiftModifier);
- QVERIFY(input->hasActiveFocus() == true);
- QCOMPARE(input->selectedText(), QString("a"));
- QCOMPARE(spy.count(), 3);
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
- QCOMPARE(input->selectedText(), QString());
- QCOMPARE(spy.count(), 4);
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == false);
- QCOMPARE(input->selectedText(), QString());
- QCOMPARE(spy.count(), 4);
-}
-
-void tst_qquicktextedit::moveCursorSelection_data()
-{
- QTest::addColumn<QString>("testStr");
- QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<int>("movePosition");
- QTest::addColumn<QQuickTextEdit::SelectionMode>("mode");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<bool>("reversible");
-
- QTest::newRow("(t)he|characters")
- << standard[0] << 0 << 1 << QQuickTextEdit::SelectCharacters << 0 << 1 << true;
- QTest::newRow("do(g)|characters")
- << standard[0] << 43 << 44 << QQuickTextEdit::SelectCharacters << 43 << 44 << true;
- QTest::newRow("jum(p)ed|characters")
- << standard[0] << 23 << 24 << QQuickTextEdit::SelectCharacters << 23 << 24 << true;
- QTest::newRow("jumped( )over|characters")
- << standard[0] << 26 << 27 << QQuickTextEdit::SelectCharacters << 26 << 27 << true;
- QTest::newRow("(the )|characters")
- << standard[0] << 0 << 4 << QQuickTextEdit::SelectCharacters << 0 << 4 << true;
- QTest::newRow("( dog)|characters")
- << standard[0] << 40 << 44 << QQuickTextEdit::SelectCharacters << 40 << 44 << true;
- QTest::newRow("( jumped )|characters")
- << standard[0] << 19 << 27 << QQuickTextEdit::SelectCharacters << 19 << 27 << true;
- QTest::newRow("th(e qu)ick|characters")
- << standard[0] << 2 << 6 << QQuickTextEdit::SelectCharacters << 2 << 6 << true;
- QTest::newRow("la(zy d)og|characters")
- << standard[0] << 38 << 42 << QQuickTextEdit::SelectCharacters << 38 << 42 << true;
- QTest::newRow("jum(ped ov)er|characters")
- << standard[0] << 23 << 29 << QQuickTextEdit::SelectCharacters << 23 << 29 << true;
- QTest::newRow("()the|characters")
- << standard[0] << 0 << 0 << QQuickTextEdit::SelectCharacters << 0 << 0 << true;
- QTest::newRow("dog()|characters")
- << standard[0] << 44 << 44 << QQuickTextEdit::SelectCharacters << 44 << 44 << true;
- QTest::newRow("jum()ped|characters")
- << standard[0] << 23 << 23 << QQuickTextEdit::SelectCharacters << 23 << 23 << true;
-
- QTest::newRow("<(t)he>|words")
- << standard[0] << 0 << 1 << QQuickTextEdit::SelectWords << 0 << 3 << true;
- QTest::newRow("<do(g)>|words")
- << standard[0] << 43 << 44 << QQuickTextEdit::SelectWords << 41 << 44 << true;
- QTest::newRow("<jum(p)ed>|words")
- << standard[0] << 23 << 24 << QQuickTextEdit::SelectWords << 20 << 26 << true;
- QTest::newRow("<jumped( )>over|words")
- << standard[0] << 26 << 27 << QQuickTextEdit::SelectWords << 20 << 27 << false;
- QTest::newRow("jumped<( )over>|words,reversed")
- << standard[0] << 27 << 26 << QQuickTextEdit::SelectWords << 26 << 31 << false;
- QTest::newRow("<(the )>quick|words")
- << standard[0] << 0 << 4 << QQuickTextEdit::SelectWords << 0 << 4 << false;
- QTest::newRow("<(the )quick>|words,reversed")
- << standard[0] << 4 << 0 << QQuickTextEdit::SelectWords << 0 << 9 << false;
- QTest::newRow("<lazy( dog)>|words")
- << standard[0] << 40 << 44 << QQuickTextEdit::SelectWords << 36 << 44 << false;
- QTest::newRow("lazy<( dog)>|words,reversed")
- << standard[0] << 44 << 40 << QQuickTextEdit::SelectWords << 40 << 44 << false;
- QTest::newRow("<fox( jumped )>over|words")
- << standard[0] << 19 << 27 << QQuickTextEdit::SelectWords << 16 << 27 << false;
- QTest::newRow("fox<( jumped )over>|words,reversed")
- << standard[0] << 27 << 19 << QQuickTextEdit::SelectWords << 19 << 31 << false;
- QTest::newRow("<th(e qu)ick>|words")
- << standard[0] << 2 << 6 << QQuickTextEdit::SelectWords << 0 << 9 << true;
- QTest::newRow("<la(zy d)og|words>")
- << standard[0] << 38 << 42 << QQuickTextEdit::SelectWords << 36 << 44 << true;
- QTest::newRow("<jum(ped ov)er>|words")
- << standard[0] << 23 << 29 << QQuickTextEdit::SelectWords << 20 << 31 << true;
- QTest::newRow("<()>the|words")
- << standard[0] << 0 << 0 << QQuickTextEdit::SelectWords << 0 << 0 << true;
- QTest::newRow("dog<()>|words")
- << standard[0] << 44 << 44 << QQuickTextEdit::SelectWords << 44 << 44 << true;
- QTest::newRow("jum<()>ped|words")
- << standard[0] << 23 << 23 << QQuickTextEdit::SelectWords << 23 << 23 << true;
-
- QTest::newRow("Hello<(,)> |words")
- << standard[2] << 5 << 6 << QQuickTextEdit::SelectWords << 5 << 6 << true;
- QTest::newRow("Hello<(, )>world|words")
- << standard[2] << 5 << 7 << QQuickTextEdit::SelectWords << 5 << 7 << false;
- QTest::newRow("Hello<(, )world>|words,reversed")
- << standard[2] << 7 << 5 << QQuickTextEdit::SelectWords << 5 << 12 << false;
- QTest::newRow("<Hel(lo, )>world|words")
- << standard[2] << 3 << 7 << QQuickTextEdit::SelectWords << 0 << 7 << false;
- QTest::newRow("<Hel(lo, )world>|words,reversed")
- << standard[2] << 7 << 3 << QQuickTextEdit::SelectWords << 0 << 12 << false;
- QTest::newRow("<Hel(lo)>,|words")
- << standard[2] << 3 << 5 << QQuickTextEdit::SelectWords << 0 << 5 << true;
- QTest::newRow("Hello<()>,|words")
- << standard[2] << 5 << 5 << QQuickTextEdit::SelectWords << 5 << 5 << true;
- QTest::newRow("Hello,<()>|words")
- << standard[2] << 6 << 6 << QQuickTextEdit::SelectWords << 6 << 6 << true;
- QTest::newRow("Hello<,( )>world|words")
- << standard[2] << 6 << 7 << QQuickTextEdit::SelectWords << 5 << 7 << false;
- QTest::newRow("Hello,<( )world>|words,reversed")
- << standard[2] << 7 << 6 << QQuickTextEdit::SelectWords << 6 << 12 << false;
- QTest::newRow("Hello<,( world)>|words")
- << standard[2] << 6 << 12 << QQuickTextEdit::SelectWords << 5 << 12 << false;
- QTest::newRow("Hello,<( world)>|words,reversed")
- << standard[2] << 12 << 6 << QQuickTextEdit::SelectWords << 6 << 12 << false;
- QTest::newRow("Hello<,( world!)>|words")
- << standard[2] << 6 << 13 << QQuickTextEdit::SelectWords << 5 << 13 << false;
- QTest::newRow("Hello,<( world!)>|words,reversed")
- << standard[2] << 13 << 6 << QQuickTextEdit::SelectWords << 6 << 13 << false;
- QTest::newRow("Hello<(, world!)>|words")
- << standard[2] << 5 << 13 << QQuickTextEdit::SelectWords << 5 << 13 << true;
- QTest::newRow("world<(!)>|words")
- << standard[2] << 12 << 13 << QQuickTextEdit::SelectWords << 12 << 13 << true;
- QTest::newRow("world!<()>)|words")
- << standard[2] << 13 << 13 << QQuickTextEdit::SelectWords << 13 << 13 << true;
- QTest::newRow("world<()>!)|words")
- << standard[2] << 12 << 12 << QQuickTextEdit::SelectWords << 12 << 12 << true;
-
- QTest::newRow("<(,)>olleH |words")
- << standard[3] << 7 << 8 << QQuickTextEdit::SelectWords << 7 << 8 << true;
- QTest::newRow("<dlrow( ,)>olleH|words")
- << standard[3] << 6 << 8 << QQuickTextEdit::SelectWords << 1 << 8 << false;
- QTest::newRow("dlrow<( ,)>olleH|words,reversed")
- << standard[3] << 8 << 6 << QQuickTextEdit::SelectWords << 6 << 8 << false;
- QTest::newRow("<dlrow( ,ol)leH>|words")
- << standard[3] << 6 << 10 << QQuickTextEdit::SelectWords << 1 << 13 << false;
- QTest::newRow("dlrow<( ,ol)leH>|words,reversed")
- << standard[3] << 10 << 6 << QQuickTextEdit::SelectWords << 6 << 13 << false;
- QTest::newRow(",<(ol)leH>,|words")
- << standard[3] << 8 << 10 << QQuickTextEdit::SelectWords << 8 << 13 << true;
- QTest::newRow(",<()>olleH|words")
- << standard[3] << 8 << 8 << QQuickTextEdit::SelectWords << 8 << 8 << true;
- QTest::newRow("<()>,olleH|words")
- << standard[3] << 7 << 7 << QQuickTextEdit::SelectWords << 7 << 7 << true;
- QTest::newRow("<dlrow( )>,olleH|words")
- << standard[3] << 6 << 7 << QQuickTextEdit::SelectWords << 1 << 7 << false;
- QTest::newRow("dlrow<( ),>olleH|words,reversed")
- << standard[3] << 7 << 6 << QQuickTextEdit::SelectWords << 6 << 8 << false;
- QTest::newRow("<(dlrow )>,olleH|words")
- << standard[3] << 1 << 7 << QQuickTextEdit::SelectWords << 1 << 7 << false;
- QTest::newRow("<(dlrow ),>olleH|words,reversed")
- << standard[3] << 7 << 1 << QQuickTextEdit::SelectWords << 1 << 8 << false;
- QTest::newRow("<(!dlrow )>,olleH|words")
- << standard[3] << 0 << 7 << QQuickTextEdit::SelectWords << 0 << 7 << false;
- QTest::newRow("<(!dlrow ),>olleH|words,reversed")
- << standard[3] << 7 << 0 << QQuickTextEdit::SelectWords << 0 << 8 << false;
- QTest::newRow("(!dlrow ,)olleH|words")
- << standard[3] << 0 << 8 << QQuickTextEdit::SelectWords << 0 << 8 << true;
- QTest::newRow("<(!)>dlrow|words")
- << standard[3] << 0 << 1 << QQuickTextEdit::SelectWords << 0 << 1 << true;
- QTest::newRow("<()>!dlrow|words")
- << standard[3] << 0 << 0 << QQuickTextEdit::SelectWords << 0 << 0 << true;
- QTest::newRow("!<()>dlrow|words")
- << standard[3] << 1 << 1 << QQuickTextEdit::SelectWords << 1 << 1 << true;
-}
-
-void tst_qquicktextedit::moveCursorSelection()
-{
- QFETCH(QString, testStr);
- QFETCH(int, cursorPosition);
- QFETCH(int, movePosition);
- QFETCH(QQuickTextEdit::SelectionMode, mode);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(bool, reversible);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit*>(textinputComponent.create());
- QVERIFY(texteditObject != 0);
-
- texteditObject->setCursorPosition(cursorPosition);
- texteditObject->moveCursorSelection(movePosition, mode);
-
- QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
- QCOMPARE(texteditObject->selectionStart(), selectionStart);
- QCOMPARE(texteditObject->selectionEnd(), selectionEnd);
-
- if (reversible) {
- texteditObject->setCursorPosition(movePosition);
- texteditObject->moveCursorSelection(cursorPosition, mode);
-
- QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
- QCOMPARE(texteditObject->selectionStart(), selectionStart);
- QCOMPARE(texteditObject->selectionEnd(), selectionEnd);
- }
-}
-
-void tst_qquicktextedit::moveCursorSelectionSequence_data()
-{
- QTest::addColumn<QString>("testStr");
- QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<int>("movePosition1");
- QTest::addColumn<int>("movePosition2");
- QTest::addColumn<int>("selection1Start");
- QTest::addColumn<int>("selection1End");
- QTest::addColumn<int>("selection2Start");
- QTest::addColumn<int>("selection2End");
-
- QTest::newRow("the {<quick( bro)wn> f^ox} jumped|ltr")
- << standard[0]
- << 9 << 13 << 17
- << 4 << 15
- << 4 << 19;
- QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl")
- << standard[0]
- << 13 << 9 << 17
- << 9 << 15
- << 10 << 19;
- QTest::newRow("the {<quick( bro)wn> ^}fox jumped|ltr")
- << standard[0]
- << 9 << 13 << 16
- << 4 << 15
- << 4 << 16;
- QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl")
- << standard[0]
- << 13 << 9 << 16
- << 9 << 15
- << 10 << 16;
- QTest::newRow("the {<quick( bro)wn^>} fox jumped|ltr")
- << standard[0]
- << 9 << 13 << 15
- << 4 << 15
- << 4 << 15;
- QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl")
- << standard[0]
- << 13 << 9 << 15
- << 9 << 15
- << 10 << 15;
- QTest::newRow("the {<quick() ^}bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 10
- << 4 << 15
- << 4 << 10;
- QTest::newRow("the quick<(^ {^bro)wn>} fox|rtl")
- << standard[0]
- << 13 << 9 << 10
- << 9 << 15
- << 10 << 15;
- QTest::newRow("the {<quick^}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 9
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the quick{<(^ bro)wn>} fox|rtl")
- << standard[0]
- << 13 << 9 << 9
- << 9 << 15
- << 9 << 15;
- QTest::newRow("the {<qui^ck}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 7
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the {<qui^ck}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 7
- << 9 << 15
- << 4 << 15;
- QTest::newRow("the {<^quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 4
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the {<^quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 4
- << 9 << 15
- << 4 << 15;
- QTest::newRow("the{^ <quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 3
- << 4 << 15
- << 3 << 9;
- QTest::newRow("the{^ <quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 3
- << 9 << 15
- << 3 << 15;
- QTest::newRow("{t^he <quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 1
- << 4 << 15
- << 0 << 9;
- QTest::newRow("{t^he <quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 1
- << 9 << 15
- << 0 << 15;
-
- QTest::newRow("{<He(ll)o>, w^orld}!|ltr")
- << standard[2]
- << 2 << 4 << 8
- << 0 << 5
- << 0 << 12;
- QTest::newRow("{<He(ll)o>, w^orld}!|rtl")
- << standard[2]
- << 4 << 2 << 8
- << 0 << 5
- << 0 << 12;
-
- QTest::newRow("!{dlro^w ,<o(ll)eH>}|ltr")
- << standard[3]
- << 9 << 11 << 5
- << 8 << 13
- << 1 << 13;
- QTest::newRow("!{dlro^w ,<o(ll)eH>}|rtl")
- << standard[3]
- << 11 << 9 << 5
- << 8 << 13
- << 1 << 13;
-}
-
-void tst_qquicktextedit::moveCursorSelectionSequence()
-{
- QFETCH(QString, testStr);
- QFETCH(int, cursorPosition);
- QFETCH(int, movePosition1);
- QFETCH(int, movePosition2);
- QFETCH(int, selection1Start);
- QFETCH(int, selection1End);
- QFETCH(int, selection2Start);
- QFETCH(int, selection2End);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }";
- QDeclarativeComponent texteditComponent(&engine);
- texteditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
- QVERIFY(texteditObject != 0);
-
- texteditObject->setCursorPosition(cursorPosition);
-
- texteditObject->moveCursorSelection(movePosition1, QQuickTextEdit::SelectWords);
- QCOMPARE(texteditObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start));
- QCOMPARE(texteditObject->selectionStart(), selection1Start);
- QCOMPARE(texteditObject->selectionEnd(), selection1End);
-
- texteditObject->moveCursorSelection(movePosition2, QQuickTextEdit::SelectWords);
- QCOMPARE(texteditObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start));
- QCOMPARE(texteditObject->selectionStart(), selection2Start);
- QCOMPARE(texteditObject->selectionEnd(), selection2End);
-}
-
-
-void tst_qquicktextedit::mouseSelection_data()
-{
- QTest::addColumn<QString>("qmlfile");
- QTest::addColumn<int>("from");
- QTest::addColumn<int>("to");
- QTest::addColumn<QString>("selectedText");
-
- // import installed
- QTest::newRow("on") << testFile("mouseselection_true.qml") << 4 << 9 << "45678";
- QTest::newRow("off") << testFile("mouseselection_false.qml") << 4 << 9 << QString();
- QTest::newRow("default") << testFile("mouseselection_default.qml") << 4 << 9 << QString();
- QTest::newRow("off word selection") << testFile("mouseselection_false_words.qml") << 4 << 9 << QString();
- QTest::newRow("on word selection (4,9)") << testFile("mouseselection_true_words.qml") << 4 << 9 << "0123456789";
- QTest::newRow("on word selection (2,13)") << testFile("mouseselection_true_words.qml") << 2 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (2,30)") << testFile("mouseselection_true_words.qml") << 2 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (9,13)") << testFile("mouseselection_true_words.qml") << 9 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (9,30)") << testFile("mouseselection_true_words.qml") << 9 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (13,2)") << testFile("mouseselection_true_words.qml") << 13 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (20,2)") << testFile("mouseselection_true_words.qml") << 20 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (12,9)") << testFile("mouseselection_true_words.qml") << 12 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (30,9)") << testFile("mouseselection_true_words.qml") << 30 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-}
-
-void tst_qquicktextedit::mouseSelection()
-{
- QFETCH(QString, qmlfile);
- QFETCH(int, from);
- QFETCH(int, to);
- QFETCH(QString, selectedText);
-
- QQuickView canvas(QUrl::fromLocalFile(qmlfile));
-
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
- QVERIFY(textEditObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- QPoint p1 = textEditObject->positionToRectangle(from).center().toPoint();
- QPoint p2 = textEditObject->positionToRectangle(to).center().toPoint();
- QTest::mousePress(&canvas, Qt::LeftButton, 0, p1);
- QTest::mouseMove(&canvas, p2);
- QTest::mouseRelease(&canvas, Qt::LeftButton, 0, p2);
- QTest::qWait(50);
- QTRY_COMPARE(textEditObject->selectedText(), selectedText);
-
- // Clicking and shift to clicking between the same points should select the same text.
- textEditObject->setCursorPosition(0);
- QTest::mouseClick(&canvas, Qt::LeftButton, Qt::NoModifier, p1);
- QTest::mouseClick(&canvas, Qt::LeftButton, Qt::ShiftModifier, p2);
- QTest::qWait(50);
- QTRY_COMPARE(textEditObject->selectedText(), selectedText);
-}
-
-void tst_qquicktextedit::dragMouseSelection()
-{
- QString qmlfile = testFile("mouseselection_true.qml");
-
- QQuickView canvas(QUrl::fromLocalFile(qmlfile));
-
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
- QVERIFY(textEditObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textEditObject->height()/2;
- QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
- QTest::mouseMove(&canvas, QPoint(x2, y));
- QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
- QTest::qWait(300);
- QString str1;
- QTRY_VERIFY((str1 = textEditObject->selectedText()).length() > 3);
-
- // press and drag the current selection.
- x1 = 40;
- x2 = 100;
- QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
- QTest::mouseMove(&canvas, QPoint(x2, y));
- QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
- QTest::qWait(300);
- QString str2;
- QTRY_VERIFY((str2 = textEditObject->selectedText()).length() > 3);
-
- QVERIFY(str1 != str2); // Verify the second press and drag is a new selection and not the first moved.
-}
-
-void tst_qquicktextedit::mouseSelectionMode_data()
-{
- QTest::addColumn<QString>("qmlfile");
- QTest::addColumn<bool>("selectWords");
-
- // import installed
- QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true;
- QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false;
- QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false;
-}
-
-void tst_qquicktextedit::mouseSelectionMode()
-{
- QFETCH(QString, qmlfile);
- QFETCH(bool, selectWords);
-
- QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-
- QQuickView canvas(QUrl::fromLocalFile(qmlfile));
-
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
- QVERIFY(textEditObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textEditObject->height()/2;
- QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
- QTest::mouseMove(&canvas, QPoint(x2, y));
- //QTest::mouseMove(canvas, QPoint(x2,y)); // doesn't work
-// QMouseEvent mv(QEvent::MouseMove, QPoint(x2,y), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
-// QGuiApplication::sendEvent(&canvas, &mv);
- QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
- QString str = textEditObject->selectedText();
- if (selectWords) {
- QTRY_COMPARE(textEditObject->selectedText(), text);
- } else {
- QTRY_VERIFY(textEditObject->selectedText().length() > 3);
- QVERIFY(str != text);
- }
-}
-
-void tst_qquicktextedit::inputMethodHints()
-{
- QQuickView canvas(testFileUrl("inputmethodhints.qml"));
- canvas.show();
- canvas.requestActivateWindow();
-
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
- QVERIFY(textEditObject != 0);
- QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText);
- QSignalSpy inputMethodHintSpy(textEditObject, SIGNAL(inputMethodHintsChanged()));
- textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
- QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly);
- QCOMPARE(inputMethodHintSpy.count(), 1);
- textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
- QCOMPARE(inputMethodHintSpy.count(), 1);
-
- QQuickTextEdit plainTextEdit;
- QCOMPARE(plainTextEdit.inputMethodHints(), Qt::ImhNone);
-}
-
-void tst_qquicktextedit::positionAt()
-{
- QQuickView canvas(testFileUrl("positionAt.qml"));
- QVERIFY(canvas.rootObject() != 0);
- canvas.show();
- canvas.requestActivateWindow();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
-
- QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
- QVERIFY(texteditObject != 0);
-
- QTextLayout layout(texteditObject->text());
- layout.setFont(texteditObject->font());
-
- if (!qmlDisableDistanceField()) {
- QTextOption option;
- option.setUseDesignMetrics(true);
- layout.setTextOption(option);
- }
-
- layout.beginLayout();
- QTextLine line = layout.createLine();
- layout.endLayout();
-
- const int y0 = line.height() / 2;
- const int y1 = line.height() * 3 / 2;
-
- int pos = texteditObject->positionAt(texteditObject->width()/2, y0);
-
- int widthBegin = floor(line.cursorToX(pos - 1));
- int widthEnd = ceil(line.cursorToX(pos + 1));
-
- QVERIFY(widthBegin <= texteditObject->width() / 2);
- QVERIFY(widthEnd >= texteditObject->width() / 2);
-
- const qreal x0 = texteditObject->positionToRectangle(pos).x();
- const qreal x1 = texteditObject->positionToRectangle(pos + 1).x();
-
- QString preeditText = texteditObject->text().mid(0, pos);
- texteditObject->setText(texteditObject->text().mid(pos));
- texteditObject->setCursorPosition(0);
-
- QInputMethodEvent inputEvent(preeditText, QList<QInputMethodEvent::Attribute>());
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent);
-
- // Check all points within the preedit text return the same position.
- QCOMPARE(texteditObject->positionAt(0, y0), 0);
- QCOMPARE(texteditObject->positionAt(x0 / 2, y0), 0);
- QCOMPARE(texteditObject->positionAt(x0, y0), 0);
-
- // Verify positioning returns to normal after the preedit text.
- QCOMPARE(texteditObject->positionAt(x1, y0), 1);
- QCOMPARE(texteditObject->positionToRectangle(1).x(), x1);
-
- QVERIFY(texteditObject->positionAt(x0 / 2, y1) > 0);
-}
-
-void tst_qquicktextedit::linkActivated()
-{
- QQuickView canvas(testFileUrl("linkActivated.qml"));
- QVERIFY(canvas.rootObject() != 0);
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
-
- QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
- QVERIFY(texteditObject != 0);
-
- QSignalSpy spy(texteditObject, SIGNAL(linkActivated(QString)));
-
- const QString link("http://example.com/");
-
- const QPointF linkPos = texteditObject->positionToRectangle(7).center();
- const QPointF textPos = texteditObject->positionToRectangle(2).center();
-
- QTest::mouseClick(&canvas, Qt::LeftButton, 0, linkPos.toPoint());
- QTRY_COMPARE(spy.count(), 1);
- QCOMPARE(spy.last()[0].toString(), link);
-
- QTest::mouseClick(&canvas, Qt::LeftButton, 0, textPos.toPoint());
- QTest::qWait(50);
- QCOMPARE(spy.count(), 1);
-
- texteditObject->setReadOnly(true);
-
- QTest::mouseClick(&canvas, Qt::LeftButton, 0, linkPos.toPoint());
- QTRY_COMPARE(spy.count(), 2);
- QCOMPARE(spy.last()[0].toString(), link);
-
- QTest::mouseClick(&canvas, Qt::LeftButton, 0, textPos.toPoint());
- QTest::qWait(50);
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktextedit::cursorDelegate_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::newRow("out of line") << testFileUrl("cursorTest.qml");
- QTest::newRow("in line") << testFileUrl("cursorTestInline.qml");
- QTest::newRow("external") << testFileUrl("cursorTestExternal.qml");
-}
-
-void tst_qquicktextedit::cursorDelegate()
-{
- QFETCH(QUrl, source);
- QQuickView view(source);
- view.show();
- view.requestActivateWindow();
- QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject");
- QVERIFY(textEditObject != 0);
- QVERIFY(textEditObject->findChild<QQuickItem*>("cursorInstance"));
- //Test Delegate gets created
- textEditObject->setFocus(true);
- QQuickItem* delegateObject = textEditObject->findChild<QQuickItem*>("cursorInstance");
- QVERIFY(delegateObject);
- QCOMPARE(delegateObject->property("localProperty").toString(), QString("Hello"));
- //Test Delegate gets moved
- for (int i=0; i<= textEditObject->text().length(); i++) {
- textEditObject->setCursorPosition(i);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
- }
- // Clear preedit text;
- QInputMethodEvent event;
- QGuiApplication::sendEvent(&view, &event);
-
-
- // Test delegate gets moved on mouse press.
- textEditObject->setSelectByMouse(true);
- textEditObject->setCursorPosition(0);
- const QPoint point1 = textEditObject->positionToRectangle(5).center().toPoint();
- QTest::mouseClick(&view, Qt::LeftButton, 0, point1);
- QTest::qWait(50);
- QTRY_VERIFY(textEditObject->cursorPosition() != 0);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
-
- // Test delegate gets moved on mouse drag
- textEditObject->setCursorPosition(0);
- const QPoint point2 = textEditObject->positionToRectangle(10).center().toPoint();
- QTest::mousePress(&view, Qt::LeftButton, 0, point1);
- QMouseEvent mv(QEvent::MouseMove, point2, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(&view, &mv);
- QTest::mouseRelease(&view, Qt::LeftButton, 0, point2);
- QTest::qWait(50);
- QTRY_COMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
-
- textEditObject->setReadOnly(true);
- textEditObject->setCursorPosition(0);
- QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint());
- QTest::qWait(50);
- QTRY_VERIFY(textEditObject->cursorPosition() != 0);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
-
- textEditObject->setCursorPosition(0);
- QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint());
- QTest::qWait(50);
- QTRY_VERIFY(textEditObject->cursorPosition() != 0);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
-
- textEditObject->setCursorPosition(0);
- QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
- //Test Delegate gets deleted
- textEditObject->setCursorDelegate(0);
- QVERIFY(!textEditObject->findChild<QQuickItem*>("cursorInstance"));
-}
-
-void tst_qquicktextedit::cursorVisible()
-{
- QQuickView view(testFileUrl("cursorVisible.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
-
- QQuickTextEdit edit;
- QSignalSpy spy(&edit, SIGNAL(cursorVisibleChanged(bool)));
-
- QCOMPARE(edit.isCursorVisible(), false);
-
- edit.setCursorVisible(true);
- QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 1);
-
- edit.setCursorVisible(false);
- QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 2);
-
- edit.setFocus(true);
- QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 2);
-
- edit.setParentItem(view.rootObject());
- QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 3);
-
- edit.setFocus(false);
- QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 4);
-
- edit.setFocus(true);
- QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 5);
-
- QQuickView alternateView;
- alternateView.show();
- alternateView.requestActivateWindow();
- QTest::qWaitForWindowShown(&alternateView);
-
- QCOMPARE(edit.isCursorVisible(), false);
- QCOMPARE(spy.count(), 6);
-
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QCOMPARE(edit.isCursorVisible(), true);
- QCOMPARE(spy.count(), 7);
-}
-
-void tst_qquicktextedit::delegateLoading_data()
-{
- QTest::addColumn<QString>("qmlfile");
- QTest::addColumn<QString>("error");
-
- // import installed
- QTest::newRow("pass") << "cursorHttpTestPass.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 ";
-}
-
-void tst_qquicktextedit::delegateLoading()
-{
-#ifdef Q_OS_MAC
- QSKIP("Test crashes during canvas tear down. QTBUG-23010");
-#endif
- QFETCH(QString, qmlfile);
- QFETCH(QString, error);
-
- TestHTTPServer server(42332);
- server.serveDirectory(testFile("httpfail"), TestHTTPServer::Disconnect);
- server.serveDirectory(testFile("httpslow"), TestHTTPServer::Delay);
- server.serveDirectory(testFile("http"));
-
- QQuickView view(QUrl(QLatin1String("http://localhost:42332/") + qmlfile));
- view.show();
- view.requestActivateWindow();
-
- if (!error.isEmpty()) {
- QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
- QTRY_VERIFY(view.status()==QQuickView::Error);
- QTRY_VERIFY(!view.rootObject()); // there is fail item inside this test
- } else {
- QTRY_VERIFY(view.rootObject());//Wait for loading to finish.
- QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject");
- // view.rootObject()->dumpObjectTree();
- QVERIFY(textEditObject != 0);
- textEditObject->setFocus(true);
- QQuickItem *delegate;
- delegate = view.rootObject()->findChild<QQuickItem*>("delegateOkay");
- QVERIFY(delegate);
- delegate = view.rootObject()->findChild<QQuickItem*>("delegateSlow");
- QVERIFY(delegate);
-
- delete delegate;
- }
-
-
- //A test should be added here with a component which is ready but component.create() returns null
- //Not sure how to accomplish this with QQuickTextEdits cursor delegate
- //###This was only needed for code coverage, and could be a case of overzealous defensive programming
- //delegate = view.rootObject()->findChild<QQuickItem*>("delegateErrorB");
- //QVERIFY(!delegate);
-}
-
-/*
-TextEdit element should only handle left/right keys until the cursor reaches
-the extent of the text, then they should ignore the keys.
-*/
-void tst_qquicktextedit::navigation()
-{
- QQuickView canvas(testFileUrl("navigation.qml"));
- canvas.show();
- canvas.requestActivateWindow();
-
- QVERIFY(canvas.rootObject() != 0);
-
- QQuickItem *input = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == false);
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == false);
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
-}
-
-void tst_qquicktextedit::copyAndPaste() {
-#ifndef QT_NO_CLIPBOARD
-
-#ifdef Q_OS_MAC
- {
- PasteboardRef pasteboard;
- OSStatus status = PasteboardCreate(0, &pasteboard);
- if (status == noErr)
- CFRelease(pasteboard);
- else
- QSKIP("This machine doesn't support the clipboard");
- }
-#endif
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- // copy and paste
- QCOMPARE(textEdit->text().length(), 12);
- textEdit->select(0, textEdit->text().length());;
- textEdit->copy();
- QCOMPARE(textEdit->selectedText(), QString("Hello world!"));
- QCOMPARE(textEdit->selectedText().length(), 12);
- textEdit->setCursorPosition(0);
- QVERIFY(textEdit->canPaste());
- textEdit->paste();
- QCOMPARE(textEdit->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textEdit->text().length(), 24);
-
- // canPaste
- QVERIFY(textEdit->canPaste());
- textEdit->setReadOnly(true);
- QVERIFY(!textEdit->canPaste());
- textEdit->setReadOnly(false);
- QVERIFY(textEdit->canPaste());
-
- // QTBUG-12339
- // test that document and internal text attribute are in sync
- QQuickItemPrivate* pri = QQuickItemPrivate::get(textEdit);
- QQuickTextEditPrivate *editPrivate = static_cast<QQuickTextEditPrivate*>(pri);
- QCOMPARE(textEdit->text(), editPrivate->text);
-
- // select word
- textEdit->setCursorPosition(0);
- textEdit->selectWord();
- QCOMPARE(textEdit->selectedText(), QString("Hello"));
-
- // select all and cut
- textEdit->selectAll();
- textEdit->cut();
- QCOMPARE(textEdit->text().length(), 0);
- textEdit->paste();
- QCOMPARE(textEdit->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textEdit->text().length(), 24);
-#endif
-}
-
-void tst_qquicktextedit::canPaste() {
-#ifndef QT_NO_CLIPBOARD
-
- QGuiApplication::clipboard()->setText("Some text");
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- // check initial value - QTBUG-17765
- QQuickTextControl tc(0);
- QCOMPARE(textEdit->canPaste(), tc.canPaste());
-
-#endif
-}
-
-void tst_qquicktextedit::canPasteEmpty() {
-#ifndef QT_NO_CLIPBOARD
-
- QGuiApplication::clipboard()->clear();
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- // check initial value - QTBUG-17765
- QQuickTextControl tc(0);
- QCOMPARE(textEdit->canPaste(), tc.canPaste());
-
-#endif
-}
-
-void tst_qquicktextedit::readOnly()
-{
- QQuickView canvas(testFileUrl("readOnly.qml"));
- canvas.show();
- canvas.requestActivateWindow();
-
- QVERIFY(canvas.rootObject() != 0);
-
- QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
-
- QVERIFY(edit != 0);
- QTRY_VERIFY(edit->hasActiveFocus() == true);
- QVERIFY(edit->isReadOnly() == true);
- QString initial = edit->text();
- for (int k=Qt::Key_0; k<=Qt::Key_Z; k++)
- simulateKey(&canvas, k);
- simulateKey(&canvas, Qt::Key_Return);
- simulateKey(&canvas, Qt::Key_Space);
- simulateKey(&canvas, Qt::Key_Escape);
- QCOMPARE(edit->text(), initial);
-
- edit->setCursorPosition(3);
- edit->setReadOnly(false);
- QCOMPARE(edit->isReadOnly(), false);
- QCOMPARE(edit->cursorPosition(), edit->text().length());
-}
-
-void tst_qquicktextedit::simulateKey(QQuickView *view, int key, Qt::KeyboardModifiers modifiers)
-{
- QKeyEvent press(QKeyEvent::KeyPress, key, modifiers);
- QKeyEvent release(QKeyEvent::KeyRelease, key, modifiers);
-
- QGuiApplication::sendEvent(view, &press);
- QGuiApplication::sendEvent(view, &release);
-}
-
-void tst_qquicktextedit::textInput()
-{
- QQuickView view(testFileUrl("inputMethodEvent.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
- QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
- QVERIFY(edit);
- QVERIFY(edit->hasActiveFocus() == true);
-
- // test that input method event is committed and change signal is emitted
- QSignalSpy spy(edit, SIGNAL(textChanged()));
- QInputMethodEvent event;
- event.setCommitString( "Hello world!", 0, 0);
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
- QCOMPARE(edit->text(), QString("Hello world!"));
- QCOMPARE(spy.count(), 1);
-
- // QTBUG-12339
- // test that document and internal text attribute are in sync
- QQuickTextEditPrivate *editPrivate = static_cast<QQuickTextEditPrivate*>(QQuickItemPrivate::get(edit));
- QCOMPARE(editPrivate->text, QString("Hello world!"));
-
- // test that tentative commit is included in text property
- edit->setText("");
- spy.clear();
- QList<QInputMethodEvent::Attribute> attributes;
- QInputMethodEvent event2("preedit", attributes);
- event2.setTentativeCommitString("string");
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &event2);
- QCOMPARE(spy.count(), 1);
- QCOMPARE(edit->text(), QString("string"));
-
- QInputMethodQueryEvent queryEvent(Qt::ImEnabled);
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &queryEvent);
- QCOMPARE(queryEvent.value(Qt::ImEnabled).toBool(), true);
-
- edit->setReadOnly(true);
- QGuiApplication::sendEvent(edit, &queryEvent);
- QCOMPARE(queryEvent.value(Qt::ImEnabled).toBool(), false);
-}
-
-void tst_qquicktextedit::inputMethodUpdate()
-{
- PlatformInputContext platformInputContext;
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = &platformInputContext;
-
- QQuickView view(testFileUrl("inputMethodEvent.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
- QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
- QVERIFY(edit);
- QVERIFY(edit->hasActiveFocus() == true);
-
- // text change even without cursor position change needs to trigger update
- edit->setText("test");
- platformInputContext.clear();
- edit->setText("xxxx");
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // input method event replacing text
- platformInputContext.clear();
- {
- QInputMethodEvent inputMethodEvent;
- inputMethodEvent.setCommitString("y", -1, 1);
- QGuiApplication::sendEvent(edit, &inputMethodEvent);
- }
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // input method changing selection
- platformInputContext.clear();
- {
- QList<QInputMethodEvent::Attribute> attributes;
- attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 2, QVariant());
- QInputMethodEvent inputMethodEvent("", attributes);
- QGuiApplication::sendEvent(edit, &inputMethodEvent);
- }
- QVERIFY(edit->selectionStart() != edit->selectionEnd());
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // font changes
- platformInputContext.clear();
- QFont font = edit->font();
- font.setBold(!font.bold());
- edit->setFont(font);
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // normal input
- platformInputContext.clear();
- {
- QInputMethodEvent inputMethodEvent;
- inputMethodEvent.setCommitString("y");
- QGuiApplication::sendEvent(edit, &inputMethodEvent);
- }
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // changing cursor position
- platformInputContext.clear();
- edit->setCursorPosition(0);
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // continuing with selection
- platformInputContext.clear();
- edit->moveCursorSelection(1);
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // read only disabled input method
- platformInputContext.clear();
- edit->setReadOnly(true);
- QVERIFY(platformInputContext.m_updateCallCount > 0);
- edit->setReadOnly(false);
-
- // no updates while no focus
- edit->setFocus(false);
- platformInputContext.clear();
- edit->setText("Foo");
- QCOMPARE(platformInputContext.m_updateCallCount, 0);
- edit->setCursorPosition(1);
- QCOMPARE(platformInputContext.m_updateCallCount, 0);
- edit->selectAll();
- QCOMPARE(platformInputContext.m_updateCallCount, 0);
- edit->setReadOnly(true);
- QCOMPARE(platformInputContext.m_updateCallCount, 0);
-}
-
-void tst_qquicktextedit::openInputPanel()
-{
- PlatformInputContext platformInputContext;
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = &platformInputContext;
-
- QQuickView view(testFileUrl("openInputPanel.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
-
- QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
- QVERIFY(edit);
-
- // check default values
- QVERIFY(edit->focusOnPress());
- QVERIFY(!edit->hasActiveFocus());
- qDebug() << &edit << qApp->focusObject();
- QVERIFY(qApp->focusObject() != edit);
-
- QCOMPARE(qApp->inputMethod()->visible(), false);
-
- // input panel should open on focus
- QPoint centerPoint(view.width()/2, view.height()/2);
- Qt::KeyboardModifiers noModifiers = 0;
- QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
- QGuiApplication::processEvents();
- QVERIFY(edit->hasActiveFocus());
- QCOMPARE(qApp->focusObject(), edit);
- QCOMPARE(qApp->inputMethod()->visible(), true);
- QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
-
- // input panel should be re-opened when pressing already focused TextEdit
- qApp->inputMethod()->hide();
- QCOMPARE(qApp->inputMethod()->visible(), false);
- QVERIFY(edit->hasActiveFocus());
- QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
- QGuiApplication::processEvents();
- QCOMPARE(qApp->inputMethod()->visible(), true);
- QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
-
- // input panel should stay visible if focus is lost to another text editor
- QSignalSpy inputPanelVisibilitySpy(qApp->inputMethod(), SIGNAL(visibleChanged()));
- QQuickTextEdit anotherEdit;
- anotherEdit.setParentItem(view.rootObject());
- anotherEdit.setFocus(true);
- QCOMPARE(qApp->inputMethod()->visible(), true);
- QCOMPARE(qApp->focusObject(), qobject_cast<QObject*>(&anotherEdit));
- QCOMPARE(inputPanelVisibilitySpy.count(), 0);
-
- anotherEdit.setFocus(false);
- QVERIFY(qApp->focusObject() != &anotherEdit);
- QCOMPARE(view.activeFocusItem(), view.rootItem());
- anotherEdit.setFocus(true);
-
- qApp->inputMethod()->hide();
-
- // input panel should not be opened if TextEdit is read only
- edit->setReadOnly(true);
- edit->setFocus(true);
- QCOMPARE(qApp->inputMethod()->visible(), false);
- QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
- QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
- QGuiApplication::processEvents();
- QCOMPARE(qApp->inputMethod()->visible(), false);
-
- // input panel should not be opened if focusOnPress is set to false
- edit->setFocusOnPress(false);
- edit->setFocus(false);
- edit->setFocus(true);
- QCOMPARE(qApp->inputMethod()->visible(), false);
- QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
- QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
- QCOMPARE(qApp->inputMethod()->visible(), false);
-
- // input panel should open when openSoftwareInputPanel is called
- edit->openSoftwareInputPanel();
- QCOMPARE(qApp->inputMethod()->visible(), true);
-
- // input panel should close when closeSoftwareInputPanel is called
- edit->closeSoftwareInputPanel();
- QCOMPARE(qApp->inputMethod()->visible(), false);
-
- inputMethodPrivate->testContext = 0;
-}
-
-void tst_qquicktextedit::geometrySignals()
-{
- QDeclarativeComponent component(&engine, testFileUrl("geometrySignals.qml"));
- QObject *o = component.create();
- QVERIFY(o);
- QCOMPARE(o->property("bindingWidth").toInt(), 400);
- QCOMPARE(o->property("bindingHeight").toInt(), 500);
- delete o;
-}
-
-void tst_qquicktextedit::pastingRichText_QTBUG_14003()
-{
-#ifndef QT_NO_CLIPBOARD
- QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.PlainText }";
- QDeclarativeComponent component(&engine);
- component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickTextEdit *obj = qobject_cast<QQuickTextEdit*>(component.create());
-
- QTRY_VERIFY(obj != 0);
- QTRY_VERIFY(obj->textFormat() == QQuickTextEdit::PlainText);
-
- QMimeData *mData = new QMimeData;
- mData->setHtml("<font color=\"red\">Hello</font>");
- QGuiApplication::clipboard()->setMimeData(mData);
-
- obj->paste();
- QTRY_VERIFY(obj->text() == "");
- QTRY_VERIFY(obj->textFormat() == QQuickTextEdit::PlainText);
-#endif
-}
-
-void tst_qquicktextedit::implicitSize_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QString>("wrap");
- QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.NoWrap";
- QTest::newRow("richtext") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "TextEdit.NoWrap";
- QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.Wrap";
- QTest::newRow("richtext_wrap") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "TextEdit.Wrap";
-}
-
-void tst_qquicktextedit::implicitSize()
-{
- QFETCH(QString, text);
- QFETCH(QString, wrap);
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\"; width: 50; wrapMode: " + wrap + " }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
-
- QVERIFY(textObject->width() < textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
-
- textObject->resetWidth();
- QVERIFY(textObject->width() == textObject->implicitWidth());
- QVERIFY(textObject->height() == textObject->implicitHeight());
-}
-
-void tst_qquicktextedit::contentSize()
-{
- QString componentStr = "import QtQuick 2.0\nTextEdit { width: 75; height: 16; font.pixelSize: 10 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QScopedPointer<QObject> object(textComponent.create());
- QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit *>(object.data());
-
- QSignalSpy spy(textObject, SIGNAL(contentSizeChanged()));
-
- textObject->setText("The quick red fox jumped over the lazy brown dog");
-
- QVERIFY(textObject->contentWidth() > textObject->width());
- QVERIFY(textObject->contentHeight() < textObject->height());
- QCOMPARE(spy.count(), 1);
-
- textObject->setWrapMode(QQuickTextEdit::WordWrap);
- QVERIFY(textObject->contentWidth() <= textObject->width());
- QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), 2);
-
- textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
-
- QVERIFY(textObject->contentWidth() > textObject->width());
- QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), 3);
-}
-
-void tst_qquicktextedit::preeditCursorRectangle()
-{
- QString preeditText = "super";
-
- QQuickView view(testFileUrl("inputMethodEvent.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
-
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
- QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
- QVERIFY(edit);
-
- QSignalSpy editSpy(edit, SIGNAL(cursorRectangleChanged()));
- QSignalSpy panelSpy(qGuiApp->inputMethod(), SIGNAL(cursorRectangleChanged()));
-
- QRect currentRect;
-
- QInputMethodQueryEvent query(Qt::ImCursorRectangle);
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
- QRect previousRect = query.value(Qt::ImCursorRectangle).toRect();
-
- // Verify that the micro focus rect is positioned the same for position 0 as
- // it would be if there was no preedit text.
- QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>()
- << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, preeditText.length(), QVariant()));
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
- currentRect = query.value(Qt::ImCursorRectangle).toRect();
- QCOMPARE(currentRect, previousRect);
- QCOMPARE(editSpy.count(), 0);
- QCOMPARE(panelSpy.count(), 0);
-
- // Verify that the micro focus rect moves to the left as the cursor position
- // is incremented.
- for (int i = 1; i <= 5; ++i) {
- QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>()
- << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, preeditText.length(), QVariant()));
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
- currentRect = query.value(Qt::ImCursorRectangle).toRect();
- QVERIFY(previousRect.left() < currentRect.left());
- QVERIFY(editSpy.count() > 0); editSpy.clear();
- QVERIFY(panelSpy.count() > 0); panelSpy.clear();
- previousRect = currentRect;
- }
-
- // Verify that if there is no preedit cursor then the micro focus rect is the
- // same as it would be if it were positioned at the end of the preedit text.
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
- editSpy.clear();
- panelSpy.clear();
- { QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>());
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); }
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
- currentRect = query.value(Qt::ImCursorRectangle).toRect();
- QCOMPARE(currentRect, previousRect);
- QVERIFY(editSpy.count() > 0);
- QVERIFY(panelSpy.count() > 0);
-}
-
-void tst_qquicktextedit::inputMethodComposing()
-{
- QString text = "supercalifragisiticexpialidocious!";
-
- QQuickView view(testFileUrl("inputContext.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
- QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
- QVERIFY(edit);
- QSignalSpy spy(edit, SIGNAL(inputMethodComposingChanged()));
- edit->setCursorPosition(12);
-
- QCOMPARE(edit->isInputMethodComposing(), false);
-
- {
- QInputMethodEvent event(text.mid(3), QList<QInputMethodEvent::Attribute>());
- QGuiApplication::sendEvent(edit, &event);
- }
-
- QCOMPARE(edit->isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 1);
-
- {
- QInputMethodEvent event(text.mid(12), QList<QInputMethodEvent::Attribute>());
- QGuiApplication::sendEvent(edit, &event);
- }
- QCOMPARE(spy.count(), 1);
-
- {
- QInputMethodEvent event;
- QGuiApplication::sendEvent(edit, &event);
- }
- QCOMPARE(edit->isInputMethodComposing(), false);
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktextedit::cursorRectangleSize()
-{
- QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml"));
- QVERIFY(canvas->rootObject() != 0);
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit *>(canvas->rootObject());
-
- // make sure cursor rectangle is not at (0,0)
- textEdit->setX(10);
- textEdit->setY(10);
- textEdit->setCursorPosition(3);
- QVERIFY(textEdit != 0);
- textEdit->setFocus(true);
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
-
- QInputMethodQueryEvent event(Qt::ImCursorRectangle);
- qApp->sendEvent(qApp->focusObject(), &event);
- QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF();
-
- QRect cursorRectFromItem = textEdit->cursorRectangle();
- QRectF cursorRectFromPositionToRectangle = textEdit->positionToRectangle(textEdit->cursorPosition());
-
- // item and input query cursor rectangles match
- QCOMPARE(cursorRectFromItem, cursorRectFromQuery.toRect());
-
- // item cursor rectangle and positionToRectangle calculations match
- QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle.toRect());
-
- // item-canvas transform and input item transform match
- QCOMPARE(QQuickItemPrivate::get(textEdit)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform());
-
- // input panel cursorRectangle property and tranformed item cursor rectangle match
- QRectF sceneCursorRect = QQuickItemPrivate::get(textEdit)->itemToCanvasTransform().mapRect(cursorRectFromItem);
- QCOMPARE(sceneCursorRect, qApp->inputMethod()->cursorRectangle());
-
- delete canvas;
-}
-
-void tst_qquicktextedit::getText_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<int>("start");
- QTest::addColumn<int>("end");
- QTest::addColumn<QString>("expectedText");
-
- const QString richBoldText = QStringLiteral("This is some <b>bold</b> text");
- const QString plainBoldText = QStringLiteral("This is some bold text");
-
- QTest::newRow("all plain text")
- << standard.at(0)
- << 0 << standard.at(0).length()
- << standard.at(0);
-
- QTest::newRow("plain text sub string")
- << standard.at(0)
- << 0 << 12
- << standard.at(0).mid(0, 12);
-
- QTest::newRow("plain text sub string reversed")
- << standard.at(0)
- << 12 << 0
- << standard.at(0).mid(0, 12);
-
- QTest::newRow("plain text cropped beginning")
- << standard.at(0)
- << -3 << 4
- << standard.at(0).mid(0, 4);
-
- QTest::newRow("plain text cropped end")
- << standard.at(0)
- << 23 << standard.at(0).length() + 8
- << standard.at(0).mid(23);
-
- QTest::newRow("plain text cropped beginning and end")
- << standard.at(0)
- << -9 << standard.at(0).length() + 4
- << standard.at(0);
-
- QTest::newRow("all rich text")
- << richBoldText
- << 0 << plainBoldText.length()
- << plainBoldText;
-
- QTest::newRow("rich text sub string")
- << richBoldText
- << 14 << 21
- << plainBoldText.mid(14, 7);
-}
-
-void tst_qquicktextedit::getText()
-{
- QFETCH(QString, text);
- QFETCH(int, start);
- QFETCH(int, end);
- QFETCH(QString, expectedText);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + text + "\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- QCOMPARE(textEdit->getText(start, end), expectedText);
-}
-
-void tst_qquicktextedit::getFormattedText_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QQuickTextEdit::TextFormat>("textFormat");
- QTest::addColumn<int>("start");
- QTest::addColumn<int>("end");
- QTest::addColumn<QString>("expectedText");
-
- const QString richBoldText = QStringLiteral("This is some <b>bold</b> text");
- const QString plainBoldText = QStringLiteral("This is some bold text");
-
- QTest::newRow("all plain text")
- << standard.at(0)
- << QQuickTextEdit::PlainText
- << 0 << standard.at(0).length()
- << standard.at(0);
-
- QTest::newRow("plain text sub string")
- << standard.at(0)
- << QQuickTextEdit::PlainText
- << 0 << 12
- << standard.at(0).mid(0, 12);
-
- QTest::newRow("plain text sub string reversed")
- << standard.at(0)
- << QQuickTextEdit::PlainText
- << 12 << 0
- << standard.at(0).mid(0, 12);
-
- QTest::newRow("plain text cropped beginning")
- << standard.at(0)
- << QQuickTextEdit::PlainText
- << -3 << 4
- << standard.at(0).mid(0, 4);
-
- QTest::newRow("plain text cropped end")
- << standard.at(0)
- << QQuickTextEdit::PlainText
- << 23 << standard.at(0).length() + 8
- << standard.at(0).mid(23);
-
- QTest::newRow("plain text cropped beginning and end")
- << standard.at(0)
- << QQuickTextEdit::PlainText
- << -9 << standard.at(0).length() + 4
- << standard.at(0);
-
- QTest::newRow("all rich (Auto) text")
- << richBoldText
- << QQuickTextEdit::AutoText
- << 0 << plainBoldText.length()
- << QString("This is some \\<.*\\>bold\\</.*\\> text");
-
- QTest::newRow("all rich (Rich) text")
- << richBoldText
- << QQuickTextEdit::RichText
- << 0 << plainBoldText.length()
- << QString("This is some \\<.*\\>bold\\</.*\\> text");
-
- QTest::newRow("all rich (Plain) text")
- << richBoldText
- << QQuickTextEdit::PlainText
- << 0 << richBoldText.length()
- << richBoldText;
-
- QTest::newRow("rich (Auto) text sub string")
- << richBoldText
- << QQuickTextEdit::AutoText
- << 14 << 21
- << QString("\\<.*\\>old\\</.*\\> tex");
-
- QTest::newRow("rich (Rich) text sub string")
- << richBoldText
- << QQuickTextEdit::RichText
- << 14 << 21
- << QString("\\<.*\\>old\\</.*\\> tex");
-
- QTest::newRow("rich (Plain) text sub string")
- << richBoldText
- << QQuickTextEdit::PlainText
- << 17 << 27
- << richBoldText.mid(17, 10);
-}
-
-void tst_qquicktextedit::getFormattedText()
-{
- QFETCH(QString, text);
- QFETCH(QQuickTextEdit::TextFormat, textFormat);
- QFETCH(int, start);
- QFETCH(int, end);
- QFETCH(QString, expectedText);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit {}";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- textEdit->setTextFormat(textFormat);
- textEdit->setText(text);
-
- if (textFormat == QQuickTextEdit::RichText
- || (textFormat == QQuickTextEdit::AutoText && Qt::mightBeRichText(text))) {
- QVERIFY(textEdit->getFormattedText(start, end).contains(QRegExp(expectedText)));
- } else {
- QCOMPARE(textEdit->getFormattedText(start, end), expectedText);
- }
-}
-
-void tst_qquicktextedit::insert_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QQuickTextEdit::TextFormat>("textFormat");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<int>("insertPosition");
- QTest::addColumn<QString>("insertText");
- QTest::addColumn<QString>("expectedText");
- QTest::addColumn<int>("expectedSelectionStart");
- QTest::addColumn<int>("expectedSelectionEnd");
- QTest::addColumn<int>("expectedCursorPosition");
- QTest::addColumn<bool>("selectionChanged");
- QTest::addColumn<bool>("cursorPositionChanged");
-
- QTest::newRow("at cursor position (beginning)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0 << 0
- << QString("Hello")
- << QString("Hello") + standard.at(0)
- << 5 << 5 << 5
- << false << true;
-
- QTest::newRow("at cursor position (end)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << standard.at(0).length() << standard.at(0).length() << standard.at(0).length()
- << QString("Hello")
- << standard.at(0) + QString("Hello")
- << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
- << false << true;
-
- QTest::newRow("at cursor position (middle)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 18 << 18 << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << 23 << 23 << 23
- << false << true;
-
- QTest::newRow("after cursor position (beginning)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0 << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("before cursor position (end)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << standard.at(0).length() << standard.at(0).length() << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
- << false << true;
-
- QTest::newRow("before cursor position (middle)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 18 << 18 << 0
- << QString("Hello")
- << QString("Hello") + standard.at(0)
- << 23 << 23 << 23
- << false << true;
-
- QTest::newRow("after cursor position (middle)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 18 << 18 << standard.at(0).length()
- << QString("Hello")
- << standard.at(0) + QString("Hello")
- << 18 << 18 << 18
- << false << false;
-
- QTest::newRow("before selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 14 << 19 << 0
- << QString("Hello")
- << QString("Hello") + standard.at(0)
- << 19 << 24 << 24
- << false << true;
-
- QTest::newRow("before reversed selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 19 << 14 << 0
- << QString("Hello")
- << QString("Hello") + standard.at(0)
- << 19 << 24 << 19
- << false << true;
-
- QTest::newRow("after selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 14 << 19 << standard.at(0).length()
- << QString("Hello")
- << standard.at(0) + QString("Hello")
- << 14 << 19 << 19
- << false << false;
-
- QTest::newRow("after reversed selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 19 << 14 << standard.at(0).length()
- << QString("Hello")
- << standard.at(0) + QString("Hello")
- << 14 << 19 << 14
- << false << false;
-
- QTest::newRow("into selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 14 << 19 << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << 14 << 24 << 24
- << true << true;
-
- QTest::newRow("into reversed selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 19 << 14 << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << 14 << 24 << 14
- << true << false;
-
- QTest::newRow("rich text into plain text")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0 << 0
- << QString("<b>Hello</b>")
- << QString("<b>Hello</b>") + standard.at(0)
- << 12 << 12 << 12
- << false << true;
-
- QTest::newRow("rich text into rich text")
- << standard.at(0) << QQuickTextEdit::RichText
- << 0 << 0 << 0
- << QString("<b>Hello</b>")
- << QString("Hello") + standard.at(0)
- << 5 << 5 << 5
- << false << true;
-
- QTest::newRow("rich text into auto text")
- << standard.at(0) << QQuickTextEdit::AutoText
- << 0 << 0 << 0
- << QString("<b>Hello</b>")
- << QString("Hello") + standard.at(0)
- << 5 << 5 << 5
- << false << true;
-
- QTest::newRow("before start")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0 << -3
- << QString("Hello")
- << standard.at(0)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("past end")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0 << standard.at(0).length() + 3
- << QString("Hello")
- << standard.at(0)
- << 0 << 0 << 0
- << false << false;
-}
-
-void tst_qquicktextedit::insert()
-{
- QFETCH(QString, text);
- QFETCH(QQuickTextEdit::TextFormat, textFormat);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(int, insertPosition);
- QFETCH(QString, insertText);
- QFETCH(QString, expectedText);
- QFETCH(int, expectedSelectionStart);
- QFETCH(int, expectedSelectionEnd);
- QFETCH(int, expectedCursorPosition);
- QFETCH(bool, selectionChanged);
- QFETCH(bool, cursorPositionChanged);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- textEdit->setTextFormat(textFormat);
- textEdit->select(selectionStart, selectionEnd);
-
- QSignalSpy selectionSpy(textEdit, SIGNAL(selectionChanged()));
- QSignalSpy selectionStartSpy(textEdit, SIGNAL(selectionStartChanged()));
- QSignalSpy selectionEndSpy(textEdit, SIGNAL(selectionEndChanged()));
- QSignalSpy textSpy(textEdit, SIGNAL(textChanged()));
- QSignalSpy cursorPositionSpy(textEdit, SIGNAL(cursorPositionChanged()));
-
- textEdit->insert(insertPosition, insertText);
-
- if (textFormat == QQuickTextEdit::RichText || (textFormat == QQuickTextEdit::AutoText && (
- Qt::mightBeRichText(text) || Qt::mightBeRichText(insertText)))) {
- QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText);
- } else {
- QCOMPARE(textEdit->text(), expectedText);
-
- }
- QCOMPARE(textEdit->length(), expectedText.length());
-
- QCOMPARE(textEdit->selectionStart(), expectedSelectionStart);
- QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd);
- QCOMPARE(textEdit->cursorPosition(), expectedCursorPosition);
-
- if (selectionStart > selectionEnd)
- qSwap(selectionStart, selectionEnd);
-
- QEXPECT_FAIL("into selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
- QEXPECT_FAIL("into reversed selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
- QCOMPARE(selectionSpy.count() > 0, selectionChanged);
- QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QEXPECT_FAIL("into reversed selection", "selectionEndChanged signal not emitted", Continue);
- QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
- QCOMPARE(textSpy.count() > 0, text != expectedText);
- QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
-}
-
-void tst_qquicktextedit::remove_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QQuickTextEdit::TextFormat>("textFormat");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<int>("removeStart");
- QTest::addColumn<int>("removeEnd");
- QTest::addColumn<QString>("expectedText");
- QTest::addColumn<int>("expectedSelectionStart");
- QTest::addColumn<int>("expectedSelectionEnd");
- QTest::addColumn<int>("expectedCursorPosition");
- QTest::addColumn<bool>("selectionChanged");
- QTest::addColumn<bool>("cursorPositionChanged");
-
- const QString richBoldText = QStringLiteral("This is some <b>bold</b> text");
- const QString plainBoldText = QStringLiteral("This is some bold text");
-
- QTest::newRow("from cursor position (beginning)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0
- << 0 << 5
- << standard.at(0).mid(5)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("to cursor position (beginning)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0
- << 5 << 0
- << standard.at(0).mid(5)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("to cursor position (end)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << standard.at(0).length() << standard.at(0).length()
- << standard.at(0).length() << standard.at(0).length() - 5
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
- << false << true;
-
- QTest::newRow("to cursor position (end)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << standard.at(0).length() << standard.at(0).length()
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
- << false << true;
-
- QTest::newRow("from cursor position (middle)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 18 << 18
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 18 << 18 << 18
- << false << false;
-
- QTest::newRow("to cursor position (middle)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 23 << 23
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 18 << 18 << 18
- << false << true;
-
- QTest::newRow("after cursor position (beginning)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("before cursor position (end)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << standard.at(0).length() << standard.at(0).length()
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
- << false << true;
-
- QTest::newRow("before cursor position (middle)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 23 << 23
- << 0 << 5
- << standard.at(0).mid(5)
- << 18 << 18 << 18
- << false << true;
-
- QTest::newRow("after cursor position (middle)")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 18 << 18
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 18 << 18 << 18
- << false << false;
-
- QTest::newRow("before selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 14 << 19
- << 0 << 5
- << standard.at(0).mid(5)
- << 9 << 14 << 14
- << false << true;
-
- QTest::newRow("before reversed selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 19 << 14
- << 0 << 5
- << standard.at(0).mid(5)
- << 9 << 14 << 9
- << false << true;
-
- QTest::newRow("after selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 14 << 19
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << 14 << 19 << 19
- << false << false;
-
- QTest::newRow("after reversed selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 19 << 14
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << 14 << 19 << 14
- << false << false;
-
- QTest::newRow("from selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 14 << 24
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 14 << 19 << 19
- << true << true;
-
- QTest::newRow("from reversed selection")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 24 << 14
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 14 << 19 << 14
- << true << false;
-
- QTest::newRow("plain text cropped beginning")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0
- << -3 << 4
- << standard.at(0).mid(4)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("plain text cropped end")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0
- << 23 << standard.at(0).length() + 8
- << standard.at(0).mid(0, 23)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("plain text cropped beginning and end")
- << standard.at(0) << QQuickTextEdit::PlainText
- << 0 << 0
- << -9 << standard.at(0).length() + 4
- << QString()
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("all rich text")
- << richBoldText << QQuickTextEdit::RichText
- << 0 << 0
- << 0 << plainBoldText.length()
- << QString()
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("rick text sub string")
- << richBoldText << QQuickTextEdit::RichText
- << 0 << 0
- << 14 << 21
- << plainBoldText.mid(0, 14) + plainBoldText.mid(21)
- << 0 << 0 << 0
- << false << false;
-}
-
-void tst_qquicktextedit::remove()
-{
- QFETCH(QString, text);
- QFETCH(QQuickTextEdit::TextFormat, textFormat);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(int, removeStart);
- QFETCH(int, removeEnd);
- QFETCH(QString, expectedText);
- QFETCH(int, expectedSelectionStart);
- QFETCH(int, expectedSelectionEnd);
- QFETCH(int, expectedCursorPosition);
- QFETCH(bool, selectionChanged);
- QFETCH(bool, cursorPositionChanged);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- textEdit->setTextFormat(textFormat);
- textEdit->select(selectionStart, selectionEnd);
-
- QSignalSpy selectionSpy(textEdit, SIGNAL(selectionChanged()));
- QSignalSpy selectionStartSpy(textEdit, SIGNAL(selectionStartChanged()));
- QSignalSpy selectionEndSpy(textEdit, SIGNAL(selectionEndChanged()));
- QSignalSpy textSpy(textEdit, SIGNAL(textChanged()));
- QSignalSpy cursorPositionSpy(textEdit, SIGNAL(cursorPositionChanged()));
-
- textEdit->remove(removeStart, removeEnd);
-
- if (textFormat == QQuickTextEdit::RichText
- || (textFormat == QQuickTextEdit::AutoText && Qt::mightBeRichText(text))) {
- QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText);
- } else {
- QCOMPARE(textEdit->text(), expectedText);
- }
- QCOMPARE(textEdit->length(), expectedText.length());
-
- if (selectionStart > selectionEnd) //
- qSwap(selectionStart, selectionEnd);
-
- QCOMPARE(textEdit->selectionStart(), expectedSelectionStart);
- QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd);
- QCOMPARE(textEdit->cursorPosition(), expectedCursorPosition);
-
- QEXPECT_FAIL("from selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
- QEXPECT_FAIL("from reversed selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
- QCOMPARE(selectionSpy.count() > 0, selectionChanged);
- QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QEXPECT_FAIL("from reversed selection", "selectionEndChanged signal not emitted", Continue);
- QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
- QCOMPARE(textSpy.count() > 0, text != expectedText);
-
-
- if (cursorPositionChanged) //
- QVERIFY(cursorPositionSpy.count() > 0);
-}
-
-
-void tst_qquicktextedit::keySequence_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QKeySequence>("sequence");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<QString>("expectedText");
- QTest::addColumn<QString>("selectedText");
-
- // standard[0] == "the [4]quick [10]brown [16]fox [20]jumped [27]over [32]the [36]lazy [41]dog"
-
- QTest::newRow("select all")
- << standard.at(0) << QKeySequence(QKeySequence::SelectAll) << 0 << 0
- << 44 << standard.at(0) << standard.at(0);
- QTest::newRow("select end of line")
- << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfLine) << 5 << 5
- << 44 << standard.at(0) << standard.at(0).mid(5);
- QTest::newRow("select end of document")
- << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfDocument) << 3 << 3
- << 44 << standard.at(0) << standard.at(0).mid(3);
- QTest::newRow("select end of block")
- << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfBlock) << 18 << 18
- << 44 << standard.at(0) << standard.at(0).mid(18);
- QTest::newRow("delete end of line")
- << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfLine) << 24 << 24
- << 24 << standard.at(0).mid(0, 24) << QString();
- QTest::newRow("move to start of line")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfLine) << 31 << 31
- << 0 << standard.at(0) << QString();
- QTest::newRow("move to start of block")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfBlock) << 25 << 25
- << 0 << standard.at(0) << QString();
- QTest::newRow("move to next char")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToNextChar) << 12 << 12
- << 13 << standard.at(0) << QString();
- QTest::newRow("move to previous char")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 3
- << 2 << standard.at(0) << QString();
- QTest::newRow("select next char")
- << standard.at(0) << QKeySequence(QKeySequence::SelectNextChar) << 23 << 23
- << 24 << standard.at(0) << standard.at(0).mid(23, 1);
- QTest::newRow("select previous char")
- << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousChar) << 19 << 19
- << 18 << standard.at(0) << standard.at(0).mid(18, 1);
- QTest::newRow("move to next word")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7
- << 10 << standard.at(0) << QString();
- QTest::newRow("move to previous word")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7
- << 4 << standard.at(0) << QString();
- QTest::newRow("select previous word")
- << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousWord) << 11 << 11
- << 10 << standard.at(0) << standard.at(0).mid(10, 1);
- QTest::newRow("delete (selection)")
- << standard.at(0) << QKeySequence(QKeySequence::Delete) << 12 << 15
- << 12 << (standard.at(0).mid(0, 12) + standard.at(0).mid(15)) << QString();
- QTest::newRow("delete (no selection)")
- << standard.at(0) << QKeySequence(QKeySequence::Delete) << 15 << 15
- << 15 << (standard.at(0).mid(0, 15) + standard.at(0).mid(16)) << QString();
- QTest::newRow("delete end of word")
- << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfWord) << 24 << 24
- << 24 << (standard.at(0).mid(0, 24) + standard.at(0).mid(27)) << QString();
- QTest::newRow("delete start of word")
- << standard.at(0) << QKeySequence(QKeySequence::DeleteStartOfWord) << 7 << 7
- << 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString();
-}
-
-void tst_qquicktextedit::keySequence()
-{
- QFETCH(QString, text);
- QFETCH(QKeySequence, sequence);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(int, cursorPosition);
- QFETCH(QString, expectedText);
- QFETCH(QString, selectedText);
-
- if (sequence.isEmpty()) {
- QSKIP("Key sequence is undefined");
- }
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true; text: \"" + text + "\" }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- QQuickCanvas canvas;
- textEdit->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- textEdit->select(selectionStart, selectionEnd);
-
- simulateKeys(&canvas, sequence);
-
- QCOMPARE(textEdit->cursorPosition(), cursorPosition);
- QCOMPARE(textEdit->text(), expectedText);
- QCOMPARE(textEdit->selectedText(), selectedText);
-}
-
-#define NORMAL 0
-#define REPLACE_UNTIL_END 1
-
-void tst_qquicktextedit::undo_data()
-{
- QTest::addColumn<QStringList>("insertString");
- QTest::addColumn<IntList>("insertIndex");
- QTest::addColumn<IntList>("insertMode");
- QTest::addColumn<QStringList>("expectedString");
- QTest::addColumn<bool>("use_keys");
-
- for (int i=0; i<2; i++) {
- QString keys_str = "keyboard";
- bool use_keys = true;
- if (i==0) {
- keys_str = "insert";
- use_keys = false;
- }
-
- {
- IntList insertIndex;
- IntList insertMode;
- QStringList insertString;
- QStringList expectedString;
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << "1";
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << "5";
-
- insertIndex << 1;
- insertMode << NORMAL;
- insertString << "3";
-
- insertIndex << 1;
- insertMode << NORMAL;
- insertString << "2";
-
- insertIndex << 3;
- insertMode << NORMAL;
- insertString << "4";
-
- expectedString << "12345";
- expectedString << "1235";
- expectedString << "135";
- expectedString << "15";
- expectedString << "";
-
- QTest::newRow(QString(keys_str + "_numbers").toLatin1()) <<
- insertString <<
- insertIndex <<
- insertMode <<
- expectedString <<
- bool(use_keys);
- }
- {
- IntList insertIndex;
- IntList insertMode;
- QStringList insertString;
- QStringList expectedString;
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << "World"; // World
-
- insertIndex << 0;
- insertMode << NORMAL;
- insertString << "Hello"; // HelloWorld
-
- insertIndex << 0;
- insertMode << NORMAL;
- insertString << "Well"; // WellHelloWorld
-
- insertIndex << 9;
- insertMode << NORMAL;
- insertString << "There"; // WellHelloThereWorld;
-
- expectedString << "WellHelloThereWorld";
- expectedString << "WellHelloWorld";
- expectedString << "HelloWorld";
- expectedString << "World";
- expectedString << "";
-
- QTest::newRow(QString(keys_str + "_helloworld").toLatin1()) <<
- insertString <<
- insertIndex <<
- insertMode <<
- expectedString <<
- bool(use_keys);
- }
- {
- IntList insertIndex;
- IntList insertMode;
- QStringList insertString;
- QStringList expectedString;
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << "Ensuring";
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << " instan";
-
- insertIndex << 9;
- insertMode << NORMAL;
- insertString << "an ";
-
- insertIndex << 10;
- insertMode << REPLACE_UNTIL_END;
- insertString << " unique instance.";
-
- expectedString << "Ensuring a unique instance.";
- expectedString << "Ensuring a "; // ### Not present in TextInput.
- expectedString << "Ensuring an instan";
- expectedString << "Ensuring instan";
- expectedString << "";
-
- QTest::newRow(QString(keys_str + "_patterns").toLatin1()) <<
- insertString <<
- insertIndex <<
- insertMode <<
- expectedString <<
- bool(use_keys);
- }
- }
-}
-
-void tst_qquicktextedit::undo()
-{
- QFETCH(QStringList, insertString);
- QFETCH(IntList, insertIndex);
- QFETCH(IntList, insertMode);
- QFETCH(QStringList, expectedString);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- QQuickCanvas canvas;
- textEdit->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- QVERIFY(!textEdit->canUndo());
-
- QSignalSpy spy(textEdit, SIGNAL(canUndoChanged()));
-
- int i;
-
-// STEP 1: First build up an undo history by inserting or typing some strings...
- for (i = 0; i < insertString.size(); ++i) {
- if (insertIndex[i] > -1)
- textEdit->setCursorPosition(insertIndex[i]);
-
- // experimental stuff
- if (insertMode[i] == REPLACE_UNTIL_END) {
- textEdit->select(insertIndex[i], insertIndex[i] + 8);
-
- // This is what I actually want...
- // QTest::keyClick(testWidget, Qt::Key_End, Qt::ShiftModifier);
- }
-
- for (int j = 0; j < insertString.at(i).length(); j++)
- QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1());
- }
-
- QCOMPARE(spy.count(), 1);
-
-// STEP 2: Next call undo several times and see if we can restore to the previous state
- for (i = 0; i < expectedString.size() - 1; ++i) {
- QCOMPARE(textEdit->text(), expectedString[i]);
- QVERIFY(textEdit->canUndo());
- textEdit->undo();
- }
-
-// STEP 3: Verify that we have undone everything
- QVERIFY(textEdit->text().isEmpty());
- QVERIFY(!textEdit->canUndo());
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktextedit::redo_data()
-{
- QTest::addColumn<QStringList>("insertString");
- QTest::addColumn<IntList>("insertIndex");
- QTest::addColumn<QStringList>("expectedString");
-
- {
- IntList insertIndex;
- QStringList insertString;
- QStringList expectedString;
-
- insertIndex << -1;
- insertString << "World"; // World
- insertIndex << 0;
- insertString << "Hello"; // HelloWorld
- insertIndex << 0;
- insertString << "Well"; // WellHelloWorld
- insertIndex << 9;
- insertString << "There"; // WellHelloThereWorld;
-
- expectedString << "World";
- expectedString << "HelloWorld";
- expectedString << "WellHelloWorld";
- expectedString << "WellHelloThereWorld";
-
- QTest::newRow("Inserts and setting cursor") << insertString << insertIndex << expectedString;
- }
-}
-
-void tst_qquicktextedit::redo()
-{
- QFETCH(QStringList, insertString);
- QFETCH(IntList, insertIndex);
- QFETCH(QStringList, expectedString);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- QQuickCanvas canvas;
- textEdit->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- QVERIFY(!textEdit->canUndo());
- QVERIFY(!textEdit->canRedo());
-
- QSignalSpy spy(textEdit, SIGNAL(canRedoChanged()));
-
- int i;
- // inserts the diff strings at diff positions
- for (i = 0; i < insertString.size(); ++i) {
- if (insertIndex[i] > -1)
- textEdit->setCursorPosition(insertIndex[i]);
- for (int j = 0; j < insertString.at(i).length(); j++)
- QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1());
- QVERIFY(textEdit->canUndo());
- QVERIFY(!textEdit->canRedo());
- }
-
- QCOMPARE(spy.count(), 0);
-
- // undo everything
- while (!textEdit->text().isEmpty()) {
- QVERIFY(textEdit->canUndo());
- textEdit->undo();
- QVERIFY(textEdit->canRedo());
- }
-
- QCOMPARE(spy.count(), 1);
-
- for (i = 0; i < expectedString.size(); ++i) {
- QVERIFY(textEdit->canRedo());
- textEdit->redo();
- QCOMPARE(textEdit->text() , expectedString[i]);
- QVERIFY(textEdit->canUndo());
- }
- QVERIFY(!textEdit->canRedo());
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktextedit::undo_keypressevents_data()
-{
- QTest::addColumn<KeyList>("keys");
- QTest::addColumn<QStringList>("expectedString");
-
- {
- KeyList keys;
- QStringList expectedString;
-
- keys << "AFRAID"
- << Qt::Key_Home
- << "VERY"
- << Qt::Key_Left
- << Qt::Key_Left
- << Qt::Key_Left
- << Qt::Key_Left
- << "BE"
- << Qt::Key_End
- << "!";
-
- expectedString << "BEVERYAFRAID!";
- expectedString << "BEVERYAFRAID";
- expectedString << "VERYAFRAID";
- expectedString << "AFRAID";
-
- QTest::newRow("Inserts and moving cursor") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting '1234'
- keys << "1234" << Qt::Key_Home
- // skipping '12'
- << Qt::Key_Right << Qt::Key_Right
- // selecting '34'
- << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
- // deleting '34'
- << Qt::Key_Delete;
-
- expectedString << "12";
- expectedString << "1234";
-
- QTest::newRow("Inserts,moving,selection and delete") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting 'AB12'
- keys << "AB12"
- << Qt::Key_Home
- // selecting 'AB'
- << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
- << Qt::Key_Delete
- << QKeySequence::Undo
- // ### Text is selected in text input
-// << Qt::Key_Right
- << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
- << Qt::Key_Delete;
-
- expectedString << "AB";
- expectedString << "AB12";
-
- QTest::newRow("Inserts,moving,selection, delete and undo") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting 'ABCD'
- keys << "abcd"
- //move left two
- << Qt::Key_Left << Qt::Key_Left
- // inserting '1234'
- << "1234"
- // selecting '1234'
- << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier)
- // overwriting '1234' with '5'
- << "5"
- // undoing deletion of 'AB'
- << QKeySequence::Undo
- // ### Text is selected in text input
- << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier)
- // overwriting '1234' with '6'
- << "6";
-
- expectedString << "ab6cd";
- // for versions previous to 3.2 we overwrite needed two undo operations
- expectedString << "ab1234cd";
- expectedString << "abcd";
-
- QTest::newRow("Inserts,moving,selection and undo, removing selection") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting 'ABC'
- keys << "ABC"
- // removes 'C'
- << Qt::Key_Backspace;
-
- expectedString << "AB";
- expectedString << "ABC";
-
- QTest::newRow("Inserts,backspace") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- keys << "ABC"
- // removes 'C'
- << Qt::Key_Backspace
- // inserting 'Z'
- << "Z";
-
- expectedString << "ABZ";
- expectedString << "AB";
- expectedString << "ABC";
-
- QTest::newRow("Inserts,backspace,inserts") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting '123'
- keys << "123" << Qt::Key_Home
- // selecting '123'
- << (Qt::Key_End | Qt::ShiftModifier)
- // overwriting '123' with 'ABC'
- << "ABC";
-
- expectedString << "ABC";
- // ### One operation in TextInput.
- expectedString << "A";
- expectedString << "123";
-
- QTest::newRow("Inserts,moving,selection and overwriting") << keys << expectedString;
- }
-}
-
-void tst_qquicktextedit::undo_keypressevents()
-{
- QFETCH(KeyList, keys);
- QFETCH(QStringList, expectedString);
-
- QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }";
- QDeclarativeComponent textEditComponent(&engine);
- textEditComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
- QVERIFY(textEdit != 0);
-
- QQuickCanvas canvas;
- textEdit->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- simulateKeys(&canvas, keys);
-
- for (int i = 0; i < expectedString.size(); ++i) {
- QCOMPARE(textEdit->text() , expectedString[i]);
- textEdit->undo();
- }
- QVERIFY(textEdit->text().isEmpty());
-}
-
-void tst_qquicktextedit::baseUrl()
-{
- QUrl localUrl("file:///tests/text.qml");
- QUrl remoteUrl("http://qt.nokia.com/test.qml");
-
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\n TextEdit {}", localUrl);
- QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit *>(textComponent.create());
-
- QCOMPARE(textObject->baseUrl(), localUrl);
-
- QSignalSpy spy(textObject, SIGNAL(baseUrlChanged()));
-
- textObject->setBaseUrl(localUrl);
- QCOMPARE(textObject->baseUrl(), localUrl);
- QCOMPARE(spy.count(), 0);
-
- textObject->setBaseUrl(remoteUrl);
- QCOMPARE(textObject->baseUrl(), remoteUrl);
- QCOMPARE(spy.count(), 1);
-
- textObject->resetBaseUrl();
- QCOMPARE(textObject->baseUrl(), localUrl);
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktextedit::embeddedImages_data()
-{
- QTest::addColumn<QUrl>("qmlfile");
- QTest::addColumn<QString>("error");
- QTest::newRow("local") << testFileUrl("embeddedImagesLocal.qml") << "";
- QTest::newRow("local-error") << testFileUrl("embeddedImagesLocalError.qml")
- << testFileUrl("embeddedImagesLocalError.qml").toString()+":3:1: QML TextEdit: Cannot open: " + testFileUrl("http/notexists.png").toString();
- QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << "";
- QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << "";
- QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml")
- << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML TextEdit: Error downloading http://127.0.0.1:42332/notexists.png - server replied: Not found";
- QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << "";
-}
-
-void tst_qquicktextedit::embeddedImages()
-{
- QFETCH(QUrl, qmlfile);
- QFETCH(QString, error);
-
- TestHTTPServer server(42332);
- server.serveDirectory(testFile("http"));
-
- if (!error.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
-
- QDeclarativeComponent textComponent(&engine, qmlfile);
- QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QTRY_COMPARE(QQuickTextEditPrivate::get(textObject)->document->resourcesLoading(), 0);
-
- QPixmap pm(testFile("http/exists.png"));
- if (error.isEmpty()) {
- QCOMPARE(textObject->width(), double(pm.width()));
- QCOMPARE(textObject->height(), double(pm.height()));
- } else {
- QVERIFY(16 != pm.width()); // check test is effective
- QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon
- QCOMPARE(textObject->height(), 16.0);
- }
-
- delete textObject;
-}
-
-void tst_qquicktextedit::emptytags_QTBUG_22058()
-{
- QQuickView canvas(testFileUrl("qtbug-22058.qml"));
- QVERIFY(canvas.rootObject() != 0);
-
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QQuickTextEdit *input = qobject_cast<QQuickTextEdit *>(qvariant_cast<QObject *>(canvas.rootObject()->property("inputField")));
- QVERIFY(input->hasActiveFocus());
-
- QInputMethodEvent event("", QList<QInputMethodEvent::Attribute>());
- event.setCommitString("<b>Bold<");
- QGuiApplication::sendEvent(input, &event);
- QCOMPARE(input->text(), QString("<b>Bold<"));
- event.setCommitString(">");
- QGuiApplication::sendEvent(input, &event);
- QCOMPARE(input->text(), QString("<b>Bold<>"));
-}
-
-QTEST_MAIN(tst_qquicktextedit)
-
-#include "tst_qquicktextedit.moc"
diff --git a/tests/auto/qtquick2/qquicktextinput/qquicktextinput.pro b/tests/auto/qtquick2/qquicktextinput/qquicktextinput.pro
deleted file mode 100644
index 08ce675a03..0000000000
--- a/tests/auto/qtquick2/qquicktextinput/qquicktextinput.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquicktextinput
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquicktextinput.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-QT += core-private gui-private v8-private declarative-private quick-private opengl-private testlib
diff --git a/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp
deleted file mode 100644
index c1768bd98a..0000000000
--- a/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp
+++ /dev/null
@@ -1,4706 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include "../../shared/util.h"
-#include <private/qinputmethod_p.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QFile>
-#include <QtQuick/qquickview.h>
-#include <QtGui/qguiapplication.h>
-#include <QtGui/qstylehints.h>
-#include <QInputMethod>
-#include <private/qquicktextinput_p.h>
-#include <private/qquicktextinput_p_p.h>
-#include <QDebug>
-#include <QDir>
-#include <QStyle>
-#include <QtOpenGL/QGLShaderProgram>
-#include <math.h>
-
-#ifdef Q_OS_MAC
-#include <Carbon/Carbon.h>
-#endif
-
-#include "qplatformdefs.h"
-#include "../../shared/platforminputcontext.h"
-
-Q_DECLARE_METATYPE(QQuickTextInput::SelectionMode)
-DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
-
-QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual)
-{
- // XXX This will be replaced by some clever persistent platform image store.
- QString persistent_dir = QDeclarativeDataTest::instance()->dataDirectory();
- QString arch = "unknown-architecture"; // QTest needs to help with this.
-
- QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png";
-
- if (!QFile::exists(expectfile)) {
- actual.save(expectfile);
- qWarning() << "created" << expectfile;
- }
-
- return expectfile;
-}
-
-template <typename T> static T evaluate(QObject *scope, const QString &expression)
-{
- QDeclarativeExpression expr(qmlContext(scope), scope, expression);
- T result = expr.evaluate().value<T>();
- if (expr.hasError())
- qWarning() << expr.error().toString();
- return result;
-}
-
-typedef QPair<int, QChar> Key;
-
-class tst_qquicktextinput : public QDeclarativeDataTest
-
-{
- Q_OBJECT
-public:
- tst_qquicktextinput();
-
-private slots:
- void cleanup();
- void text();
- void width();
- void font();
- void color();
- void wrap();
- void selection();
- void persistentSelection();
- void isRightToLeft_data();
- void isRightToLeft();
- void moveCursorSelection_data();
- void moveCursorSelection();
- void moveCursorSelectionSequence_data();
- void moveCursorSelectionSequence();
- void dragMouseSelection();
- void mouseSelectionMode_data();
- void mouseSelectionMode();
- void tripleClickSelectsAll();
-
- void horizontalAlignment_data();
- void horizontalAlignment();
- void horizontalAlignment_RightToLeft();
- void verticalAlignment();
-
- void boundingRect();
-
- void positionAt();
-
- void maxLength();
- void masks();
- void validators();
- void inputMethods();
-
- void passwordCharacter();
- void cursorDelegate_data();
- void cursorDelegate();
- void cursorVisible();
- void cursorRectangle();
- void navigation();
- void navigation_RTL();
- void copyAndPaste();
- void copyAndPasteKeySequence();
- void canPasteEmpty();
- void canPaste();
- void readOnly();
-
- void openInputPanel();
- void setHAlignClearCache();
- void focusOutClearSelection();
-
- void echoMode();
-#ifdef QT_GUI_PASSWORD_ECHO_DELAY
- void passwordEchoDelay();
-#endif
- void geometrySignals();
- void contentSize();
-
- void preeditAutoScroll();
- void preeditCursorRectangle();
- void inputContextMouseHandler();
- void inputMethodComposing();
- void inputMethodUpdate();
- void cursorRectangleSize();
-
- void getText_data();
- void getText();
- void insert_data();
- void insert();
- void remove_data();
- void remove();
-
- void keySequence_data();
- void keySequence();
-
- void undo_data();
- void undo();
- void redo_data();
- void redo();
- void undo_keypressevents_data();
- void undo_keypressevents();
-
- void QTBUG_19956();
- void QTBUG_19956_data();
- void QTBUG_19956_regexp();
-
- void negativeDimensions();
-
-private:
- void simulateKey(QQuickView *, int key);
-
- void simulateKeys(QWindow *window, const QList<Key> &keys);
- void simulateKeys(QWindow *window, const QKeySequence &sequence);
-
- QDeclarativeEngine engine;
- QStringList standard;
- QStringList colorStrings;
-};
-
-typedef QList<int> IntList;
-Q_DECLARE_METATYPE(IntList)
-
-typedef QList<Key> KeyList;
-Q_DECLARE_METATYPE(KeyList)
-
-void tst_qquicktextinput::simulateKeys(QWindow *window, const QList<Key> &keys)
-{
- for (int i = 0; i < keys.count(); ++i) {
- const int key = keys.at(i).first;
- const int modifiers = key & Qt::KeyboardModifierMask;
- const QString text = !keys.at(i).second.isNull() ? QString(keys.at(i).second) : QString();
-
- QKeyEvent press(QEvent::KeyPress, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text);
- QKeyEvent release(QEvent::KeyRelease, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text);
-
- QGuiApplication::sendEvent(window, &press);
- QGuiApplication::sendEvent(window, &release);
- }
-}
-
-void tst_qquicktextinput::simulateKeys(QWindow *window, const QKeySequence &sequence)
-{
- for (int i = 0; i < sequence.count(); ++i) {
- const int key = sequence[i];
- const int modifiers = key & Qt::KeyboardModifierMask;
-
- QTest::keyClick(window, Qt::Key(key & ~modifiers), Qt::KeyboardModifiers(modifiers));
- }
-}
-
-QList<Key> &operator <<(QList<Key> &keys, const QKeySequence &sequence)
-{
- for (int i = 0; i < sequence.count(); ++i)
- keys << Key(sequence[i], QChar());
- return keys;
-}
-
-template <int N> QList<Key> &operator <<(QList<Key> &keys, const char (&characters)[N])
-{
- for (int i = 0; i < N - 1; ++i) {
- int key = QTest::asciiToKey(characters[i]);
- QChar character = QLatin1Char(characters[i]);
- keys << Key(key, character);
- }
- return keys;
-}
-
-QList<Key> &operator <<(QList<Key> &keys, Qt::Key key)
-{
- keys << Key(key, QChar());
- return keys;
-}
-
-void tst_qquicktextinput::cleanup()
-{
- // ensure not even skipped tests with custom input context leave it dangling
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = 0;
-}
-
-tst_qquicktextinput::tst_qquicktextinput()
-{
- standard << "the quick brown fox jumped over the lazy dog"
- << "It's supercalifragisiticexpialidocious!"
- << "Hello, world!"
- << "!dlrow ,olleH"
- << " spacey text ";
-
- colorStrings << "aliceblue"
- << "antiquewhite"
- << "aqua"
- << "darkkhaki"
- << "darkolivegreen"
- << "dimgray"
- << "palevioletred"
- << "lightsteelblue"
- << "#000000"
- << "#AAAAAA"
- << "#FFFFFF"
- << "#2AC05F";
-}
-
-void tst_qquicktextinput::text()
-{
- {
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData("import QtQuick 2.0\nTextInput { text: \"\" }", QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->text(), QString(""));
- QCOMPARE(textinputObject->length(), 0);
-
- delete textinputObject;
- }
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->text(), standard.at(i));
- QCOMPARE(textinputObject->length(), standard.at(i).length());
-
- delete textinputObject;
- }
-
-}
-
-void tst_qquicktextinput::width()
-{
- // uses Font metrics to find the width for standard
- {
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData("import QtQuick 2.0\nTextInput { text: \"\" }", QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->width(), 0.0);
-
- delete textinputObject;
- }
-
- bool requiresUnhintedMetrics = !qmlDisableDistanceField();
-
- for (int i = 0; i < standard.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QString s = standard.at(i);
- s.replace(QLatin1Char('\n'), QChar::LineSeparator);
-
- QTextLayout layout(s);
- layout.setFont(textinputObject->font());
- layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic);
- if (requiresUnhintedMetrics) {
- QTextOption option;
- option.setUseDesignMetrics(true);
- layout.setTextOption(option);
- }
-
- layout.beginLayout();
- forever {
- QTextLine line = layout.createLine();
- if (!line.isValid())
- break;
- }
-
- layout.endLayout();
-
- qreal metricWidth = ceil(layout.boundingRect().width());
-
- QVERIFY(textinputObject != 0);
- int delta = abs(int(int(textinputObject->width()) - metricWidth));
- QVERIFY(delta <= 3.0); // As best as we can hope for cross-platform.
-
- delete textinputObject;
- }
-}
-
-void tst_qquicktextinput::font()
-{
- //test size, then bold, then italic, then family
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { font.pointSize: 40; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().pointSize(), 40);
- QCOMPARE(textinputObject->font().bold(), false);
- QCOMPARE(textinputObject->font().italic(), false);
-
- delete textinputObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { font.bold: true; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().bold(), true);
- QCOMPARE(textinputObject->font().italic(), false);
-
- delete textinputObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { font.italic: true; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().italic(), true);
- QCOMPARE(textinputObject->font().bold(), false);
-
- delete textinputObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().family(), QString("Helvetica"));
- QCOMPARE(textinputObject->font().bold(), false);
- QCOMPARE(textinputObject->font().italic(), false);
-
- delete textinputObject;
- }
-
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { font.family: \"\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->font().family(), QString(""));
-
- delete textinputObject;
- }
-}
-
-void tst_qquicktextinput::color()
-{
- //test color
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i)));
-
- delete textinputObject;
- }
-
- //test selection color
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i)));
-
- delete textinputObject;
- }
-
- //test selected text color
- for (int i = 0; i < colorStrings.size(); i++)
- {
- QString componentStr = "import QtQuick 2.0\nTextInput { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i)));
-
- delete textinputObject;
- }
-
- {
- QString colorStr = "#AA001234";
- QColor testColor("#001234");
- testColor.setAlpha(170);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { color: \"" + colorStr + "\"; text: \"Hello World\" }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
-
- QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->color(), testColor);
-
- delete textinputObject;
- }
-}
-
-void tst_qquicktextinput::wrap()
-{
- int textHeight = 0;
- // for specified width and wrap set true
- {
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData("import QtQuick 2.0\nTextInput { text: \"Hello\"; wrapMode: Text.WrapAnywhere; width: 300 }", QUrl::fromLocalFile(""));
- QQuickTextInput *textObject = qobject_cast<QQuickTextInput*>(textComponent.create());
- textHeight = textObject->height();
-
- QVERIFY(textObject != 0);
- QVERIFY(textObject->wrapMode() == QQuickTextInput::WrapAnywhere);
- QCOMPARE(textObject->width(), 300.);
-
- delete textObject;
- }
-
- for (int i = 0; i < standard.count(); i++) {
- QString componentStr = "import QtQuick 2.0\nTextInput { wrapMode: Text.WrapAnywhere; width: 30; text: \"" + standard.at(i) + "\" }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QQuickTextInput *textObject = qobject_cast<QQuickTextInput*>(textComponent.create());
-
- QVERIFY(textObject != 0);
- QCOMPARE(textObject->width(), 30.);
- QVERIFY(textObject->height() > textHeight);
-
- int oldHeight = textObject->height();
- textObject->setWidth(100);
- QVERIFY(textObject->height() < oldHeight);
-
- delete textObject;
- }
-}
-
-void tst_qquicktextinput::selection()
-{
- QString testStr = standard[0];
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
-
-
- //Test selection follows cursor
- for (int i=0; i<= testStr.size(); i++) {
- textinputObject->setCursorPosition(i);
- QCOMPARE(textinputObject->cursorPosition(), i);
- QCOMPARE(textinputObject->selectionStart(), i);
- QCOMPARE(textinputObject->selectionEnd(), i);
- QVERIFY(textinputObject->selectedText().isNull());
- }
-
- textinputObject->setCursorPosition(0);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
- QVERIFY(textinputObject->selectedText().isNull());
-
- // Verify invalid positions are ignored.
- textinputObject->setCursorPosition(-1);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
- QVERIFY(textinputObject->selectedText().isNull());
-
- textinputObject->setCursorPosition(textinputObject->text().count()+1);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
- QVERIFY(textinputObject->selectedText().isNull());
-
- //Test selection
- for (int i=0; i<= testStr.size(); i++) {
- textinputObject->select(0,i);
- QCOMPARE(testStr.mid(0,i), textinputObject->selectedText());
- }
- for (int i=0; i<= testStr.size(); i++) {
- textinputObject->select(i,testStr.size());
- QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText());
- }
-
- textinputObject->setCursorPosition(0);
- QVERIFY(textinputObject->cursorPosition() == 0);
- QVERIFY(textinputObject->selectionStart() == 0);
- QVERIFY(textinputObject->selectionEnd() == 0);
- QVERIFY(textinputObject->selectedText().isNull());
-
- //Test Error Ignoring behaviour
- textinputObject->setCursorPosition(0);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(-10,0);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(100,110);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(0,-10);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(0,100);
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(0,10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->select(-10,10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->select(100,101);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->select(0,-10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->select(0,100);
- QVERIFY(textinputObject->selectedText().size() == 10);
-
- textinputObject->deselect();
- QVERIFY(textinputObject->selectedText().isNull());
- textinputObject->select(0,10);
- QVERIFY(textinputObject->selectedText().size() == 10);
- textinputObject->deselect();
- QVERIFY(textinputObject->selectedText().isNull());
-
- // test input method selection
- QSignalSpy selectionSpy(textinputObject, SIGNAL(selectedTextChanged()));
- textinputObject->setFocus(true);
- {
- QList<QInputMethodEvent::Attribute> attributes;
- attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 12, 5, QVariant());
- QInputMethodEvent event("", attributes);
- QGuiApplication::sendEvent(textinputObject, &event);
- }
- QCOMPARE(selectionSpy.count(), 1);
- QCOMPARE(textinputObject->selectionStart(), 12);
- QCOMPARE(textinputObject->selectionEnd(), 17);
-
- delete textinputObject;
-}
-
-void tst_qquicktextinput::persistentSelection()
-{
- QQuickView canvas(testFileUrl("persistentSelection.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
- canvas.requestActivateWindow();
-
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(canvas.rootObject());
- QVERIFY(input);
- QVERIFY(input->hasActiveFocus());
-
- QSignalSpy spy(input, SIGNAL(persistentSelectionChanged()));
-
- QCOMPARE(input->persistentSelection(), false);
-
- input->setPersistentSelection(false);
- QCOMPARE(input->persistentSelection(), false);
- QCOMPARE(spy.count(), 0);
-
- input->select(1, 4);
- QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
-
- input->setFocus(false);
- QCOMPARE(input->property("selected").toString(), QString());
-
- input->setFocus(true);
- QCOMPARE(input->property("selected").toString(), QString());
-
- input->setPersistentSelection(true);
- QCOMPARE(input->persistentSelection(), true);
- QCOMPARE(spy.count(), 1);
-
- input->select(1, 4);
- QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
-
- input->setFocus(false);
- QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
-
- input->setFocus(true);
- QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
-}
-
-void tst_qquicktextinput::isRightToLeft_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<bool>("emptyString");
- QTest::addColumn<bool>("firstCharacter");
- QTest::addColumn<bool>("lastCharacter");
- QTest::addColumn<bool>("middleCharacter");
- QTest::addColumn<bool>("startString");
- QTest::addColumn<bool>("midString");
- QTest::addColumn<bool>("endString");
-
- const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647};
- QTest::newRow("Empty") << "" << false << false << false << false << false << false << false;
- QTest::newRow("Neutral") << "23244242" << false << false << false << false << false << false << false;
- QTest::newRow("LTR") << "Hello world" << false << false << false << false << false << false << false;
- QTest::newRow("RTL") << QString::fromUtf16(arabic_str, 11) << false << true << true << true << true << true << true;
- QTest::newRow("Bidi RTL + LTR + RTL") << QString::fromUtf16(arabic_str, 11) + QString("Hello world") + QString::fromUtf16(arabic_str, 11) << false << true << true << false << true << true << true;
- QTest::newRow("Bidi LTR + RTL + LTR") << QString("Hello world") + QString::fromUtf16(arabic_str, 11) + QString("Hello world") << false << false << false << true << false << false << false;
-}
-
-void tst_qquicktextinput::isRightToLeft()
-{
- QFETCH(QString, text);
- QFETCH(bool, emptyString);
- QFETCH(bool, firstCharacter);
- QFETCH(bool, lastCharacter);
- QFETCH(bool, middleCharacter);
- QFETCH(bool, startString);
- QFETCH(bool, midString);
- QFETCH(bool, endString);
-
- QQuickTextInput textInput;
- textInput.setText(text);
-
- // first test that the right string is delivered to the QString::isRightToLeft()
- QCOMPARE(textInput.isRightToLeft(0,0), text.mid(0,0).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(0,1), text.mid(0,1).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(text.count()-2, text.count()-1), text.mid(text.count()-2, text.count()-1).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(text.count()/2, text.count()/2 + 1), text.mid(text.count()/2, text.count()/2 + 1).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(0,text.count()/4), text.mid(0,text.count()/4).isRightToLeft());
- QCOMPARE(textInput.isRightToLeft(text.count()/4,3*text.count()/4), text.mid(text.count()/4,3*text.count()/4).isRightToLeft());
- if (text.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start.");
- QCOMPARE(textInput.isRightToLeft(3*text.count()/4,text.count()-1), text.mid(3*text.count()/4,text.count()-1).isRightToLeft());
-
- // then test that the feature actually works
- QCOMPARE(textInput.isRightToLeft(0,0), emptyString);
- QCOMPARE(textInput.isRightToLeft(0,1), firstCharacter);
- QCOMPARE(textInput.isRightToLeft(text.count()-2, text.count()-1), lastCharacter);
- QCOMPARE(textInput.isRightToLeft(text.count()/2, text.count()/2 + 1), middleCharacter);
- QCOMPARE(textInput.isRightToLeft(0,text.count()/4), startString);
- QCOMPARE(textInput.isRightToLeft(text.count()/4,3*text.count()/4), midString);
- if (text.isEmpty())
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start.");
- QCOMPARE(textInput.isRightToLeft(3*text.count()/4,text.count()-1), endString);
-}
-
-void tst_qquicktextinput::moveCursorSelection_data()
-{
- QTest::addColumn<QString>("testStr");
- QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<int>("movePosition");
- QTest::addColumn<QQuickTextInput::SelectionMode>("mode");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<bool>("reversible");
-
- // () contains the text selected by the cursor.
- // <> contains the actual selection.
-
- QTest::newRow("(t)he|characters")
- << standard[0] << 0 << 1 << QQuickTextInput::SelectCharacters << 0 << 1 << true;
- QTest::newRow("do(g)|characters")
- << standard[0] << 43 << 44 << QQuickTextInput::SelectCharacters << 43 << 44 << true;
- QTest::newRow("jum(p)ed|characters")
- << standard[0] << 23 << 24 << QQuickTextInput::SelectCharacters << 23 << 24 << true;
- QTest::newRow("jumped( )over|characters")
- << standard[0] << 26 << 27 << QQuickTextInput::SelectCharacters << 26 << 27 << true;
- QTest::newRow("(the )|characters")
- << standard[0] << 0 << 4 << QQuickTextInput::SelectCharacters << 0 << 4 << true;
- QTest::newRow("( dog)|characters")
- << standard[0] << 40 << 44 << QQuickTextInput::SelectCharacters << 40 << 44 << true;
- QTest::newRow("( jumped )|characters")
- << standard[0] << 19 << 27 << QQuickTextInput::SelectCharacters << 19 << 27 << true;
- QTest::newRow("th(e qu)ick|characters")
- << standard[0] << 2 << 6 << QQuickTextInput::SelectCharacters << 2 << 6 << true;
- QTest::newRow("la(zy d)og|characters")
- << standard[0] << 38 << 42 << QQuickTextInput::SelectCharacters << 38 << 42 << true;
- QTest::newRow("jum(ped ov)er|characters")
- << standard[0] << 23 << 29 << QQuickTextInput::SelectCharacters << 23 << 29 << true;
- QTest::newRow("()the|characters")
- << standard[0] << 0 << 0 << QQuickTextInput::SelectCharacters << 0 << 0 << true;
- QTest::newRow("dog()|characters")
- << standard[0] << 44 << 44 << QQuickTextInput::SelectCharacters << 44 << 44 << true;
- QTest::newRow("jum()ped|characters")
- << standard[0] << 23 << 23 << QQuickTextInput::SelectCharacters << 23 << 23 << true;
-
- QTest::newRow("<(t)he>|words")
- << standard[0] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 3 << true;
- QTest::newRow("<do(g)>|words")
- << standard[0] << 43 << 44 << QQuickTextInput::SelectWords << 41 << 44 << true;
- QTest::newRow("<jum(p)ed>|words")
- << standard[0] << 23 << 24 << QQuickTextInput::SelectWords << 20 << 26 << true;
- QTest::newRow("<jumped( )>over|words,ltr")
- << standard[0] << 26 << 27 << QQuickTextInput::SelectWords << 20 << 27 << false;
- QTest::newRow("jumped<( )over>|words,rtl")
- << standard[0] << 27 << 26 << QQuickTextInput::SelectWords << 26 << 31 << false;
- QTest::newRow("<(the )>quick|words,ltr")
- << standard[0] << 0 << 4 << QQuickTextInput::SelectWords << 0 << 4 << false;
- QTest::newRow("<(the )quick>|words,rtl")
- << standard[0] << 4 << 0 << QQuickTextInput::SelectWords << 0 << 9 << false;
- QTest::newRow("<lazy( dog)>|words,ltr")
- << standard[0] << 40 << 44 << QQuickTextInput::SelectWords << 36 << 44 << false;
- QTest::newRow("lazy<( dog)>|words,rtl")
- << standard[0] << 44 << 40 << QQuickTextInput::SelectWords << 40 << 44 << false;
- QTest::newRow("<fox( jumped )>over|words,ltr")
- << standard[0] << 19 << 27 << QQuickTextInput::SelectWords << 16 << 27 << false;
- QTest::newRow("fox<( jumped )over>|words,rtl")
- << standard[0] << 27 << 19 << QQuickTextInput::SelectWords << 19 << 31 << false;
- QTest::newRow("<th(e qu)ick>|words")
- << standard[0] << 2 << 6 << QQuickTextInput::SelectWords << 0 << 9 << true;
- QTest::newRow("<la(zy d)og|words>")
- << standard[0] << 38 << 42 << QQuickTextInput::SelectWords << 36 << 44 << true;
- QTest::newRow("<jum(ped ov)er>|words")
- << standard[0] << 23 << 29 << QQuickTextInput::SelectWords << 20 << 31 << true;
- QTest::newRow("<()>the|words")
- << standard[0] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << true;
- QTest::newRow("dog<()>|words")
- << standard[0] << 44 << 44 << QQuickTextInput::SelectWords << 44 << 44 << true;
- QTest::newRow("jum<()>ped|words")
- << standard[0] << 23 << 23 << QQuickTextInput::SelectWords << 23 << 23 << true;
-
- QTest::newRow("Hello<(,)> |words")
- << standard[2] << 5 << 6 << QQuickTextInput::SelectWords << 5 << 6 << true;
- QTest::newRow("Hello<(, )>world|words,ltr")
- << standard[2] << 5 << 7 << QQuickTextInput::SelectWords << 5 << 7 << false;
- QTest::newRow("Hello<(, )world>|words,rtl")
- << standard[2] << 7 << 5 << QQuickTextInput::SelectWords << 5 << 12 << false;
- QTest::newRow("<Hel(lo, )>world|words,ltr")
- << standard[2] << 3 << 7 << QQuickTextInput::SelectWords << 0 << 7 << false;
- QTest::newRow("<Hel(lo, )world>|words,rtl")
- << standard[2] << 7 << 3 << QQuickTextInput::SelectWords << 0 << 12 << false;
- QTest::newRow("<Hel(lo)>,|words")
- << standard[2] << 3 << 5 << QQuickTextInput::SelectWords << 0 << 5 << true;
- QTest::newRow("Hello<()>,|words")
- << standard[2] << 5 << 5 << QQuickTextInput::SelectWords << 5 << 5 << true;
- QTest::newRow("Hello,<()>|words")
- << standard[2] << 6 << 6 << QQuickTextInput::SelectWords << 6 << 6 << true;
- QTest::newRow("Hello<,( )>world|words,ltr")
- << standard[2] << 6 << 7 << QQuickTextInput::SelectWords << 5 << 7 << false;
- QTest::newRow("Hello,<( )world>|words,rtl")
- << standard[2] << 7 << 6 << QQuickTextInput::SelectWords << 6 << 12 << false;
- QTest::newRow("Hello<,( world)>|words,ltr")
- << standard[2] << 6 << 12 << QQuickTextInput::SelectWords << 5 << 12 << false;
- QTest::newRow("Hello,<( world)>|words,rtl")
- << standard[2] << 12 << 6 << QQuickTextInput::SelectWords << 6 << 12 << false;
- QTest::newRow("Hello<,( world!)>|words,ltr")
- << standard[2] << 6 << 13 << QQuickTextInput::SelectWords << 5 << 13 << false;
- QTest::newRow("Hello,<( world!)>|words,rtl")
- << standard[2] << 13 << 6 << QQuickTextInput::SelectWords << 6 << 13 << false;
- QTest::newRow("Hello<(, world!)>|words")
- << standard[2] << 5 << 13 << QQuickTextInput::SelectWords << 5 << 13 << true;
- // Fails due to an issue with QTextBoundaryFinder and punctuation at the end of strings.
- // QTBUG-11365
- // QTest::newRow("world<(!)>|words")
- // << standard[2] << 12 << 13 << QQuickTextInput::SelectWords << 12 << 13 << true;
- QTest::newRow("world!<()>)|words")
- << standard[2] << 13 << 13 << QQuickTextInput::SelectWords << 13 << 13 << true;
- QTest::newRow("world<()>!)|words")
- << standard[2] << 12 << 12 << QQuickTextInput::SelectWords << 12 << 12 << true;
-
- QTest::newRow("<(,)>olleH |words")
- << standard[3] << 7 << 8 << QQuickTextInput::SelectWords << 7 << 8 << true;
- QTest::newRow("<dlrow( ,)>olleH|words,ltr")
- << standard[3] << 6 << 8 << QQuickTextInput::SelectWords << 1 << 8 << false;
- QTest::newRow("dlrow<( ,)>olleH|words,rtl")
- << standard[3] << 8 << 6 << QQuickTextInput::SelectWords << 6 << 8 << false;
- QTest::newRow("<dlrow( ,ol)leH>|words,ltr")
- << standard[3] << 6 << 10 << QQuickTextInput::SelectWords << 1 << 13 << false;
- QTest::newRow("dlrow<( ,ol)leH>|words,rtl")
- << standard[3] << 10 << 6 << QQuickTextInput::SelectWords << 6 << 13 << false;
- QTest::newRow(",<(ol)leH>,|words")
- << standard[3] << 8 << 10 << QQuickTextInput::SelectWords << 8 << 13 << true;
- QTest::newRow(",<()>olleH|words")
- << standard[3] << 8 << 8 << QQuickTextInput::SelectWords << 8 << 8 << true;
- QTest::newRow("<()>,olleH|words")
- << standard[3] << 7 << 7 << QQuickTextInput::SelectWords << 7 << 7 << true;
- QTest::newRow("<dlrow( )>,olleH|words,ltr")
- << standard[3] << 6 << 7 << QQuickTextInput::SelectWords << 1 << 7 << false;
- QTest::newRow("dlrow<( ),>olleH|words,rtl")
- << standard[3] << 7 << 6 << QQuickTextInput::SelectWords << 6 << 8 << false;
- QTest::newRow("<(dlrow )>,olleH|words,ltr")
- << standard[3] << 1 << 7 << QQuickTextInput::SelectWords << 1 << 7 << false;
- QTest::newRow("<(dlrow ),>olleH|words,rtl")
- << standard[3] << 7 << 1 << QQuickTextInput::SelectWords << 1 << 8 << false;
- QTest::newRow("<(!dlrow )>,olleH|words,ltr")
- << standard[3] << 0 << 7 << QQuickTextInput::SelectWords << 0 << 7 << false;
- QTest::newRow("<(!dlrow ),>olleH|words,rtl")
- << standard[3] << 7 << 0 << QQuickTextInput::SelectWords << 0 << 8 << false;
- QTest::newRow("(!dlrow ,)olleH|words")
- << standard[3] << 0 << 8 << QQuickTextInput::SelectWords << 0 << 8 << true;
- QTest::newRow("<(!)>dlrow|words")
- << standard[3] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 1 << true;
- QTest::newRow("<()>!dlrow|words")
- << standard[3] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << true;
- QTest::newRow("!<()>dlrow|words")
- << standard[3] << 1 << 1 << QQuickTextInput::SelectWords << 1 << 1 << true;
-
- QTest::newRow(" <s(pac)ey> text |words")
- << standard[4] << 1 << 4 << QQuickTextInput::SelectWords << 1 << 7 << true;
- QTest::newRow(" spacey <t(ex)t> |words")
- << standard[4] << 11 << 13 << QQuickTextInput::SelectWords << 10 << 14 << false; // Should be reversible. QTBUG-11365
- QTest::newRow("<( )>spacey text |words|ltr")
- << standard[4] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 1 << false;
- QTest::newRow("<( )spacey> text |words|rtl")
- << standard[4] << 1 << 0 << QQuickTextInput::SelectWords << 0 << 7 << false;
- QTest::newRow("spacey <text( )>|words|ltr")
- << standard[4] << 14 << 15 << QQuickTextInput::SelectWords << 10 << 15 << false;
-// QTBUG-11365
-// QTest::newRow("spacey text<( )>|words|rtl")
-// << standard[4] << 15 << 14 << QQuickTextInput::SelectWords << 14 << 15 << false;
- QTest::newRow("<()> spacey text |words")
- << standard[4] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << false;
- QTest::newRow(" spacey text <()>|words")
- << standard[4] << 15 << 15 << QQuickTextInput::SelectWords << 15 << 15 << false;
-}
-
-void tst_qquicktextinput::moveCursorSelection()
-{
- QFETCH(QString, testStr);
- QFETCH(int, cursorPosition);
- QFETCH(int, movePosition);
- QFETCH(QQuickTextInput::SelectionMode, mode);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(bool, reversible);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
-
- textinputObject->setCursorPosition(cursorPosition);
- textinputObject->moveCursorSelection(movePosition, mode);
-
- QCOMPARE(textinputObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
- QCOMPARE(textinputObject->selectionStart(), selectionStart);
- QCOMPARE(textinputObject->selectionEnd(), selectionEnd);
-
- if (reversible) {
- textinputObject->setCursorPosition(movePosition);
- textinputObject->moveCursorSelection(cursorPosition, mode);
-
- QCOMPARE(textinputObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
- QCOMPARE(textinputObject->selectionStart(), selectionStart);
- QCOMPARE(textinputObject->selectionEnd(), selectionEnd);
- }
-
- delete textinputObject;
-}
-
-void tst_qquicktextinput::moveCursorSelectionSequence_data()
-{
- QTest::addColumn<QString>("testStr");
- QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<int>("movePosition1");
- QTest::addColumn<int>("movePosition2");
- QTest::addColumn<int>("selection1Start");
- QTest::addColumn<int>("selection1End");
- QTest::addColumn<int>("selection2Start");
- QTest::addColumn<int>("selection2End");
-
- // () contains the text selected by the cursor.
- // <> contains the actual selection.
- // ^ is the revised cursor position.
- // {} contains the revised selection.
-
- QTest::newRow("the {<quick( bro)wn> f^ox} jumped|ltr")
- << standard[0]
- << 9 << 13 << 17
- << 4 << 15
- << 4 << 19;
- QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl")
- << standard[0]
- << 13 << 9 << 17
- << 9 << 15
- << 10 << 19;
- QTest::newRow("the {<quick( bro)wn> ^}fox jumped|ltr")
- << standard[0]
- << 9 << 13 << 16
- << 4 << 15
- << 4 << 16;
- QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl")
- << standard[0]
- << 13 << 9 << 16
- << 9 << 15
- << 10 << 16;
- QTest::newRow("the {<quick( bro)wn^>} fox jumped|ltr")
- << standard[0]
- << 9 << 13 << 15
- << 4 << 15
- << 4 << 15;
- QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl")
- << standard[0]
- << 13 << 9 << 15
- << 9 << 15
- << 10 << 15;
- QTest::newRow("the {<quick() ^}bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 10
- << 4 << 15
- << 4 << 10;
- QTest::newRow("the quick<( {^bro)wn>} fox|rtl")
- << standard[0]
- << 13 << 9 << 10
- << 9 << 15
- << 10 << 15;
- QTest::newRow("the {<quick^}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 9
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the quick{<(^ bro)wn>} fox|rtl")
- << standard[0]
- << 13 << 9 << 9
- << 9 << 15
- << 9 << 15;
- QTest::newRow("the {<qui^ck}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 7
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the {<qui^ck}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 7
- << 9 << 15
- << 4 << 15;
- QTest::newRow("the {<^quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 4
- << 4 << 15
- << 4 << 9;
- QTest::newRow("the {<^quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 4
- << 9 << 15
- << 4 << 15;
- QTest::newRow("the{^ <quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 3
- << 4 << 15
- << 3 << 9;
- QTest::newRow("the{^ <quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 3
- << 9 << 15
- << 3 << 15;
- QTest::newRow("{t^he <quick}( bro)wn> fox|ltr")
- << standard[0]
- << 9 << 13 << 1
- << 4 << 15
- << 0 << 9;
- QTest::newRow("{t^he <quick}( bro)wn> fox|rtl")
- << standard[0]
- << 13 << 9 << 1
- << 9 << 15
- << 0 << 15;
-
- QTest::newRow("{<He(ll)o>, w^orld}!|ltr")
- << standard[2]
- << 2 << 4 << 8
- << 0 << 5
- << 0 << 12;
- QTest::newRow("{<He(ll)o>, w^orld}!|rtl")
- << standard[2]
- << 4 << 2 << 8
- << 0 << 5
- << 0 << 12;
-
- QTest::newRow("!{dlro^w ,<o(ll)eH>}|ltr")
- << standard[3]
- << 9 << 11 << 5
- << 8 << 13
- << 1 << 13;
- QTest::newRow("!{dlro^w ,<o(ll)eH>}|rtl")
- << standard[3]
- << 11 << 9 << 5
- << 8 << 13
- << 1 << 13;
-
- QTest::newRow("{<(^} sp)acey> text |ltr")
- << standard[4]
- << 0 << 3 << 0
- << 0 << 7
- << 0 << 0;
- QTest::newRow("{<( ^}sp)acey> text |ltr")
- << standard[4]
- << 0 << 3 << 1
- << 0 << 7
- << 0 << 1;
- QTest::newRow("<( {s^p)acey>} text |rtl")
- << standard[4]
- << 3 << 0 << 2
- << 0 << 7
- << 1 << 7;
- QTest::newRow("<( {^sp)acey>} text |rtl")
- << standard[4]
- << 3 << 0 << 1
- << 0 << 7
- << 1 << 7;
-
- QTest::newRow(" spacey <te(xt {^)>}|rtl")
- << standard[4]
- << 15 << 12 << 15
- << 10 << 15
- << 15 << 15;
-// QTBUG-11365
-// QTest::newRow(" spacey <te(xt{^ )>}|rtl")
-// << standard[4]
-// << 15 << 12 << 14
-// << 10 << 15
-// << 14 << 15;
- QTest::newRow(" spacey {<te(x^t} )>|ltr")
- << standard[4]
- << 12 << 15 << 13
- << 10 << 15
- << 10 << 14;
-// QTBUG-11365
-// QTest::newRow(" spacey {<te(xt^} )>|ltr")
-// << standard[4]
-// << 12 << 15 << 14
-// << 10 << 15
-// << 10 << 14;
-}
-
-void tst_qquicktextinput::moveCursorSelectionSequence()
-{
- QFETCH(QString, testStr);
- QFETCH(int, cursorPosition);
- QFETCH(int, movePosition1);
- QFETCH(int, movePosition2);
- QFETCH(int, selection1Start);
- QFETCH(int, selection1End);
- QFETCH(int, selection2Start);
- QFETCH(int, selection2End);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }";
- QDeclarativeComponent textinputComponent(&engine);
- textinputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
- QVERIFY(textinputObject != 0);
-
- textinputObject->setCursorPosition(cursorPosition);
-
- textinputObject->moveCursorSelection(movePosition1, QQuickTextInput::SelectWords);
- QCOMPARE(textinputObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start));
- QCOMPARE(textinputObject->selectionStart(), selection1Start);
- QCOMPARE(textinputObject->selectionEnd(), selection1End);
-
- textinputObject->moveCursorSelection(movePosition2, QQuickTextInput::SelectWords);
- QCOMPARE(textinputObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start));
- QCOMPARE(textinputObject->selectionStart(), selection2Start);
- QCOMPARE(textinputObject->selectionEnd(), selection2End);
-
- delete textinputObject;
-}
-
-void tst_qquicktextinput::dragMouseSelection()
-{
- QString qmlfile = testFile("mouseselection_true.qml");
-
- QQuickView canvas(QUrl::fromLocalFile(qmlfile));
-
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
-
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextInput *textInputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
- QVERIFY(textInputObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textInputObject->height()/2;
- QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
- QTest::mouseMove(&canvas, QPoint(x2, y));
- QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
- QTest::qWait(100);
- QString str1;
- QVERIFY((str1 = textInputObject->selectedText()).length() > 3);
- QVERIFY(str1.length() > 3);
-
- // press and drag the current selection.
- x1 = 40;
- x2 = 100;
- QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
- QTest::mouseMove(&canvas, QPoint(x2, y));
- QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
- QTest::qWait(300);
- QString str2 = textInputObject->selectedText();
- QVERIFY(str2.length() > 3);
-
- QVERIFY(str1 != str2);
-}
-
-void tst_qquicktextinput::mouseSelectionMode_data()
-{
- QTest::addColumn<QString>("qmlfile");
- QTest::addColumn<bool>("selectWords");
-
- // import installed
- QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true;
- QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false;
- QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false;
-}
-
-void tst_qquicktextinput::mouseSelectionMode()
-{
- QFETCH(QString, qmlfile);
- QFETCH(bool, selectWords);
-
- QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-
- QQuickView canvas(QUrl::fromLocalFile(qmlfile));
-
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextInput *textInputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
- QVERIFY(textInputObject != 0);
-
- // press-and-drag-and-release from x1 to x2
- int x1 = 10;
- int x2 = 70;
- int y = textInputObject->height()/2;
- QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
- QTest::mouseMove(&canvas, QPoint(x2,y)); // doesn't work
- QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
- QTest::qWait(300);
- if (selectWords) {
- QTRY_COMPARE(textInputObject->selectedText(), text);
- } else {
- QTRY_VERIFY(textInputObject->selectedText().length() > 3);
- QVERIFY(textInputObject->selectedText() != text);
- }
-}
-
-void tst_qquicktextinput::horizontalAlignment_data()
-{
- QTest::addColumn<int>("hAlign");
- QTest::addColumn<QString>("expectfile");
-
- QTest::newRow("L") << int(Qt::AlignLeft) << "halign_left";
- QTest::newRow("R") << int(Qt::AlignRight) << "halign_right";
- QTest::newRow("C") << int(Qt::AlignHCenter) << "halign_center";
-}
-
-void tst_qquicktextinput::horizontalAlignment()
-{
- QSKIP("Image comparison of text is almost guaranteed to fail during development");
-
- QFETCH(int, hAlign);
- QFETCH(QString, expectfile);
-
- QQuickView canvas(testFileUrl("horizontalAlignment.qml"));
-
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
- QObject *ob = canvas.rootObject();
- QVERIFY(ob != 0);
- ob->setProperty("horizontalAlignment",hAlign);
- QImage actual = canvas.grabFrameBuffer();
-
- expectfile = createExpectedFileIfNotFound(expectfile, actual);
-
- QImage expect(expectfile);
-
- QCOMPARE(actual,expect);
-}
-
-void tst_qquicktextinput::horizontalAlignment_RightToLeft()
-{
- PlatformInputContext platformInputContext;
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = &platformInputContext;
-
- QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml"));
- QQuickTextInput *textInput = canvas.rootObject()->findChild<QQuickTextInput*>("text");
- QVERIFY(textInput != 0);
- canvas.show();
-
- const QString rtlText = textInput->text();
-
- QQuickTextInputPrivate *textInputPrivate = QQuickTextInputPrivate::get(textInput);
- QVERIFY(textInputPrivate != 0);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- // implicit alignment should follow the reading direction of RTL text
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- // explicitly left aligned
- textInput->setHAlign(QQuickTextInput::AlignLeft);
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
-
- // explicitly right aligned
- textInput->setHAlign(QQuickTextInput::AlignRight);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- // explicitly center aligned
- textInput->setHAlign(QQuickTextInput::AlignHCenter);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignHCenter);
- QVERIFY(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll > 0);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll < textInput->width());
-
- // reseted alignment should go back to following the text reading direction
- textInput->resetHAlign();
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- // mirror the text item
- QQuickItemPrivate::get(textInput)->setLayoutMirror(true);
-
- // mirrored implicit alignment should continue to follow the reading direction of the text
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- // explicitly right aligned behaves as left aligned
- textInput->setHAlign(QQuickTextInput::AlignRight);
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QCOMPARE(textInput->effectiveHAlign(), QQuickTextInput::AlignLeft);
- QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
-
- // mirrored explicitly left aligned behaves as right aligned
- textInput->setHAlign(QQuickTextInput::AlignLeft);
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
- QCOMPARE(textInput->effectiveHAlign(), QQuickTextInput::AlignRight);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- // disable mirroring
- QQuickItemPrivate::get(textInput)->setLayoutMirror(false);
- QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
- textInput->resetHAlign();
-
- // English text should be implicitly left aligned
- textInput->setText("Hello world!");
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
- QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
-
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- // If there is no commited text, the preedit text should determine the alignment.
- textInput->setText(QString());
- { QInputMethodEvent ev(rtlText, QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- { QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
-
- // Clear pre-edit text. TextInput should maybe do this itself on setText, but that may be
- // redundant as an actual input method may take care of it.
- { QInputMethodEvent ev; QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
-
- // empty text with implicit alignment follows the system locale-based
- // keyboard input direction from QInputMethod::inputDirection()
- textInput->setText("");
- platformInputContext.setInputDirection(Qt::LeftToRight);
- QVERIFY(qApp->inputMethod()->inputDirection() == Qt::LeftToRight);
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
- QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
-
- QSignalSpy cursorRectangleSpy(textInput, SIGNAL(cursorRectangleChanged()));
- platformInputContext.setInputDirection(Qt::RightToLeft);
- QVERIFY(qApp->inputMethod()->inputDirection() == Qt::RightToLeft);
- QCOMPARE(cursorRectangleSpy.count(), 1);
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- // set input direction while having content
- platformInputContext.setInputDirection(Qt::LeftToRight);
- textInput->setText("a");
- platformInputContext.setInputDirection(Qt::RightToLeft);
- QTest::keyClick(&canvas, Qt::Key_Backspace);
- QVERIFY(textInput->text().isEmpty());
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- // input direction changed while not having focus
- platformInputContext.setInputDirection(Qt::LeftToRight);
- textInput->setFocus(false);
- platformInputContext.setInputDirection(Qt::RightToLeft);
- textInput->setFocus(true);
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-
- textInput->setHAlign(QQuickTextInput::AlignRight);
- QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
- QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
-}
-
-void tst_qquicktextinput::verticalAlignment()
-{
- QQuickView canvas(testFileUrl("horizontalAlignment.qml"));
- QQuickTextInput *textInput = canvas.rootObject()->findChild<QQuickTextInput*>("text");
- QVERIFY(textInput != 0);
- canvas.show();
-
- QQuickTextInputPrivate *textInputPrivate = QQuickTextInputPrivate::get(textInput);
- QVERIFY(textInputPrivate != 0);
-
- QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignTop);
- QVERIFY(textInputPrivate->boundingRect.bottom() - textInputPrivate->vscroll < canvas.height() / 2);
- QVERIFY(textInput->cursorRectangle().bottom() < canvas.height() / 2);
- QVERIFY(textInput->positionToRectangle(0).bottom() < canvas.height() / 2);
-
- // bottom aligned
- textInput->setVAlign(QQuickTextInput::AlignBottom);
- QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignBottom);
- QVERIFY(textInputPrivate->boundingRect.top() - textInputPrivate->vscroll > canvas.height() / 2);
- QVERIFY(textInput->cursorRectangle().top() > canvas.height() / 2);
- QVERIFY(textInput->positionToRectangle(0).top() > canvas.height() / 2);
-
- // explicitly center aligned
- textInput->setVAlign(QQuickTextInput::AlignVCenter);
- QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignVCenter);
- QVERIFY(textInputPrivate->boundingRect.top() - textInputPrivate->vscroll < canvas.height() / 2);
- QVERIFY(textInputPrivate->boundingRect.bottom() - textInputPrivate->vscroll > canvas.height() / 2);
- QVERIFY(textInput->cursorRectangle().top() < canvas.height() / 2);
- QVERIFY(textInput->cursorRectangle().bottom() > canvas.height() / 2);
- QVERIFY(textInput->positionToRectangle(0).top() < canvas.height() / 2);
- QVERIFY(textInput->positionToRectangle(0).bottom() > canvas.height() / 2);
-}
-
-void tst_qquicktextinput::boundingRect()
-{
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\n TextInput {}", QUrl());
- QScopedPointer<QObject> object(component.create());
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(object.data());
- QVERIFY(input);
-
- QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width());
- QCOMPARE(input->height(), input->boundingRect().height());
-
- input->setText("Hello World");
- QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width());
- QCOMPARE(input->height(), input->boundingRect().height());
-
- // bounding rect shouldn't exceed the size of the item, expect for the cursor width;
- input->setWidth(input->width() / 2);
- QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width());
- QCOMPARE(input->height(), input->boundingRect().height());
-
- input->setHeight(input->height() * 2);
- QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width());
- QCOMPARE(input->height(), input->boundingRect().height());
-
- QDeclarativeComponent cursorComponent(&engine);
- cursorComponent.setData("import QtQuick 2.0\nRectangle { height: 20; width: 8 }", QUrl());
-
- input->setCursorDelegate(&cursorComponent);
-
- // If a cursor delegate is used it's size should determine the excess width.
- QCOMPARE(input->width() + 8, input->boundingRect().width());
- QCOMPARE(input->height(), input->boundingRect().height());
-}
-
-void tst_qquicktextinput::positionAt()
-{
- QQuickView canvas(testFileUrl("positionAt.qml"));
- QVERIFY(canvas.rootObject() != 0);
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
-
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
- QVERIFY(textinputObject != 0);
-
- // Check autoscrolled...
-
- int pos = evaluate<int>(textinputObject, QString("positionAt(%1)").arg(textinputObject->width()/2));
-
- QTextLayout layout(textinputObject->text());
- layout.setFont(textinputObject->font());
-
- if (!qmlDisableDistanceField()) {
- QTextOption option;
- option.setUseDesignMetrics(true);
- layout.setTextOption(option);
- }
- layout.beginLayout();
- QTextLine line = layout.createLine();
- layout.endLayout();
-
- int textLeftWidthBegin = floor(line.cursorToX(pos - 1));
- int textLeftWidthEnd = ceil(line.cursorToX(pos + 1));
- int textWidth = floor(line.horizontalAdvance());
-
- QVERIFY(textLeftWidthBegin <= textWidth - textinputObject->width() / 2);
- QVERIFY(textLeftWidthEnd >= textWidth - textinputObject->width() / 2);
-
- int x = textinputObject->positionToRectangle(pos + 1).x() - 1;
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, 0, TextInput.CursorBetweenCharacters)").arg(x)), pos + 1);
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, 0, TextInput.CursorOnCharacter)").arg(x)), pos);
-
- // Check without autoscroll...
- textinputObject->setAutoScroll(false);
- pos = evaluate<int>(textinputObject, QString("positionAt(%1)").arg(textinputObject->width() / 2));
-
- textLeftWidthBegin = floor(line.cursorToX(pos - 1));
- textLeftWidthEnd = ceil(line.cursorToX(pos + 1));
-
- QVERIFY(textLeftWidthBegin <= textinputObject->width() / 2);
- QVERIFY(textLeftWidthEnd >= textinputObject->width() / 2);
-
- x = textinputObject->positionToRectangle(pos + 1).x() - 1;
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, 0, TextInput.CursorBetweenCharacters)").arg(x)), pos + 1);
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, 0, TextInput.CursorOnCharacter)").arg(x)), pos);
-
- const qreal x0 = textinputObject->positionToRectangle(pos).x();
- const qreal x1 = textinputObject->positionToRectangle(pos + 1).x();
-
- QString preeditText = textinputObject->text().mid(0, pos);
- textinputObject->setText(textinputObject->text().mid(pos));
- textinputObject->setCursorPosition(0);
-
- { QInputMethodEvent inputEvent(preeditText, QList<QInputMethodEvent::Attribute>());
- QVERIFY(qGuiApp->focusObject());
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent); }
-
- // Check all points within the preedit text return the same position.
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1)").arg(0)), 0);
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1)").arg(x0 / 2)), 0);
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1)").arg(x0)), 0);
-
- // Verify positioning returns to normal after the preedit text.
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1)").arg(x1)), 1);
- QCOMPARE(textinputObject->positionToRectangle(1).x(), x1);
-
- { QInputMethodEvent inputEvent;
- QVERIFY(qGuiApp->focusObject());
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent); }
-
- // With wrapping.
- textinputObject->setWrapMode(QQuickTextInput::WrapAnywhere);
-
- const qreal y0 = line.height() / 2;
- const qreal y1 = line.height() * 3 / 2;
-
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, %2)").arg(x0).arg(y0)), pos);
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, %2)").arg(x1).arg(y0)), pos + 1);
-
- int newLinePos = evaluate<int>(textinputObject, QString("positionAt(%1, %2)").arg(x0).arg(y1));
- QVERIFY(newLinePos > pos);
- QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, %2)").arg(x1).arg(y1)), newLinePos + 1);
-}
-
-void tst_qquicktextinput::maxLength()
-{
- QQuickView canvas(testFileUrl("maxLength.qml"));
- QVERIFY(canvas.rootObject() != 0);
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
-
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
- QVERIFY(textinputObject != 0);
- QVERIFY(textinputObject->text().isEmpty());
- QVERIFY(textinputObject->maxLength() == 10);
- foreach (const QString &str, standard) {
- QVERIFY(textinputObject->text().length() <= 10);
- textinputObject->setText(str);
- QVERIFY(textinputObject->text().length() <= 10);
- }
-
- textinputObject->setText("");
- QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
- for (int i=0; i<20; i++) {
- QTRY_COMPARE(textinputObject->text().length(), qMin(i,10));
- //simulateKey(&canvas, Qt::Key_A);
- QTest::keyPress(&canvas, Qt::Key_A);
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QTest::qWait(50);
- }
-}
-
-void tst_qquicktextinput::masks()
-{
- //Not a comprehensive test of the possible masks, that's done elsewhere (QLineEdit)
- //QString componentStr = "import QtQuick 2.0\nTextInput { inputMask: 'HHHHhhhh'; }";
- QQuickView canvas(testFileUrl("masks.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
- QVERIFY(textinputObject != 0);
- QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
- QVERIFY(textinputObject->text().length() == 0);
- QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; "));
- QCOMPARE(textinputObject->length(), 8);
- for (int i=0; i<10; i++) {
- QTRY_COMPARE(qMin(i,8), textinputObject->text().length());
- QCOMPARE(textinputObject->length(), 8);
- QCOMPARE(textinputObject->getText(0, qMin(i, 8)), QString(qMin(i, 8), 'a'));
- QCOMPARE(textinputObject->getText(qMin(i, 8), 8), QString(8 - qMin(i, 8), ' '));
- QCOMPARE(i>=4, textinputObject->hasAcceptableInput());
- //simulateKey(&canvas, Qt::Key_A);
- QTest::keyPress(&canvas, Qt::Key_A);
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QTest::qWait(50);
- }
-}
-
-void tst_qquicktextinput::validators()
-{
- // Note that this test assumes that the validators are working properly
- // so you may need to run their tests first. All validators are checked
- // here to ensure that their exposure to QML is working.
-
- QLocale::setDefault(QLocale(QStringLiteral("C")));
-
- QQuickView canvas(testFileUrl("validators.qml"));
- canvas.show();
- canvas.requestActivateWindow();
-
- QVERIFY(canvas.rootObject() != 0);
-
- QLocale defaultLocale;
- QLocale enLocale("en");
- QLocale deLocale("de_DE");
-
- QQuickTextInput *intInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("intInput")));
- QVERIFY(intInput);
- QSignalSpy intSpy(intInput, SIGNAL(acceptableInputChanged()));
-
- QQuickIntValidator *intValidator = qobject_cast<QQuickIntValidator *>(intInput->validator());
- QVERIFY(intValidator);
- QCOMPARE(intValidator->localeName(), defaultLocale.name());
- QCOMPARE(intInput->validator()->locale(), defaultLocale);
- intValidator->setLocaleName(enLocale.name());
- QCOMPARE(intValidator->localeName(), enLocale.name());
- QCOMPARE(intInput->validator()->locale(), enLocale);
- intValidator->resetLocaleName();
- QCOMPARE(intValidator->localeName(), defaultLocale.name());
- QCOMPARE(intInput->validator()->locale(), defaultLocale);
-
- intInput->setFocus(true);
- QTRY_VERIFY(intInput->hasActiveFocus());
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QCOMPARE(intInput->property("acceptable").toBool(), false);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(intInput->text(), QLatin1String("1"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QCOMPARE(intInput->property("acceptable").toBool(), false);
- QCOMPARE(intSpy.count(), 0);
- QTest::keyPress(&canvas, Qt::Key_2);
- QTest::keyRelease(&canvas, Qt::Key_2, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(intInput->text(), QLatin1String("1"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QCOMPARE(intInput->property("acceptable").toBool(), false);
- QCOMPARE(intSpy.count(), 0);
- QTest::keyPress(&canvas, Qt::Key_Period);
- QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(intInput->text(), QLatin1String("1"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QTest::keyPress(&canvas, Qt::Key_Comma);
- QTest::keyRelease(&canvas, Qt::Key_Comma, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(intInput->text(), QLatin1String("1,"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(intInput->text(), QLatin1String("1"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- intValidator->setLocaleName(deLocale.name());
- QTest::keyPress(&canvas, Qt::Key_Period);
- QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(intInput->text(), QLatin1String("1."));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(intInput->text(), QLatin1String("1"));
- QCOMPARE(intInput->hasAcceptableInput(), false);
- intValidator->resetLocaleName();
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QCOMPARE(intInput->text(), QLatin1String("11"));
- QCOMPARE(intInput->hasAcceptableInput(), true);
- QCOMPARE(intInput->property("acceptable").toBool(), true);
- QCOMPARE(intSpy.count(), 1);
- QTest::keyPress(&canvas, Qt::Key_0);
- QTest::keyRelease(&canvas, Qt::Key_0, Qt::NoModifier ,10);
- QTest::qWait(50);
- QCOMPARE(intInput->text(), QLatin1String("11"));
- QCOMPARE(intInput->hasAcceptableInput(), true);
- QCOMPARE(intInput->property("acceptable").toBool(), true);
- QCOMPARE(intSpy.count(), 1);
-
- QQuickTextInput *dblInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("dblInput")));
- QVERIFY(dblInput);
- QSignalSpy dblSpy(dblInput, SIGNAL(acceptableInputChanged()));
-
- QQuickDoubleValidator *dblValidator = qobject_cast<QQuickDoubleValidator *>(dblInput->validator());
- QVERIFY(dblValidator);
- QCOMPARE(dblValidator->localeName(), defaultLocale.name());
- QCOMPARE(dblInput->validator()->locale(), defaultLocale);
- dblValidator->setLocaleName(enLocale.name());
- QCOMPARE(dblValidator->localeName(), enLocale.name());
- QCOMPARE(dblInput->validator()->locale(), enLocale);
- dblValidator->resetLocaleName();
- QCOMPARE(dblValidator->localeName(), defaultLocale.name());
- QCOMPARE(dblInput->validator()->locale(), defaultLocale);
-
- dblInput->setFocus(true);
- QVERIFY(dblInput->hasActiveFocus() == true);
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("1"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 0);
- QTest::keyPress(&canvas, Qt::Key_2);
- QTest::keyRelease(&canvas, Qt::Key_2, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblSpy.count(), 1);
- QTest::keyPress(&canvas, Qt::Key_Comma);
- QTest::keyRelease(&canvas, Qt::Key_Comma, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12,"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12,"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- dblValidator->setLocaleName(deLocale.name());
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12,1"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12,11"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12,1"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12,"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- dblValidator->resetLocaleName();
- QTest::keyPress(&canvas, Qt::Key_Period);
- QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12."));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblSpy.count(), 1);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12.1"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblSpy.count(), 1);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblSpy.count(), 1);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblSpy.count(), 1);
-
- // Ensure the validator doesn't prevent characters being removed.
- dblInput->setValidator(intInput->validator());
- QCOMPARE(dblInput->text(), QLatin1String("12.11"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12.1"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2);
- // Once unacceptable input is in anything goes until it reaches an acceptable state again.
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblSpy.count(), 2);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12.1"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12."));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("12"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2);
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(dblInput->text(), QLatin1String("1"));
- QCOMPARE(dblInput->hasAcceptableInput(), false);
- QCOMPARE(dblInput->property("acceptable").toBool(), false);
- QCOMPARE(dblSpy.count(), 2);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QCOMPARE(dblInput->text(), QLatin1String("11"));
- QCOMPARE(dblInput->property("acceptable").toBool(), true);
- QCOMPARE(dblInput->hasAcceptableInput(), true);
- QCOMPARE(dblSpy.count(), 3);
-
- QQuickTextInput *strInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("strInput")));
- QVERIFY(strInput);
- QSignalSpy strSpy(strInput, SIGNAL(acceptableInputChanged()));
- strInput->setFocus(true);
- QVERIFY(strInput->hasActiveFocus() == true);
- QCOMPARE(strInput->hasAcceptableInput(), false);
- QCOMPARE(strInput->property("acceptable").toBool(), false);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(strInput->text(), QLatin1String(""));
- QCOMPARE(strInput->hasAcceptableInput(), false);
- QCOMPARE(strInput->property("acceptable").toBool(), false);
- QCOMPARE(strSpy.count(), 0);
- QTest::keyPress(&canvas, Qt::Key_A);
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(strInput->text(), QLatin1String("a"));
- QCOMPARE(strInput->hasAcceptableInput(), false);
- QCOMPARE(strInput->property("acceptable").toBool(), false);
- QCOMPARE(strSpy.count(), 0);
- QTest::keyPress(&canvas, Qt::Key_A);
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(strInput->text(), QLatin1String("aa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QCOMPARE(strInput->property("acceptable").toBool(), true);
- QCOMPARE(strSpy.count(), 1);
- QTest::keyPress(&canvas, Qt::Key_A);
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(strInput->text(), QLatin1String("aaa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QCOMPARE(strInput->property("acceptable").toBool(), true);
- QCOMPARE(strSpy.count(), 1);
- QTest::keyPress(&canvas, Qt::Key_A);
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(strInput->text(), QLatin1String("aaaa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QCOMPARE(strInput->property("acceptable").toBool(), true);
- QCOMPARE(strSpy.count(), 1);
- QTest::keyPress(&canvas, Qt::Key_A);
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(strInput->text(), QLatin1String("aaaa"));
- QCOMPARE(strInput->hasAcceptableInput(), true);
- QCOMPARE(strInput->property("acceptable").toBool(), true);
- QCOMPARE(strSpy.count(), 1);
-
- QQuickTextInput *unvalidatedInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("unvalidatedInput")));
- QVERIFY(unvalidatedInput);
- QSignalSpy unvalidatedSpy(unvalidatedInput, SIGNAL(acceptableInputChanged()));
- unvalidatedInput->setFocus(true);
- QVERIFY(unvalidatedInput->hasActiveFocus() == true);
- QCOMPARE(unvalidatedInput->hasAcceptableInput(), true);
- QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true);
- QTest::keyPress(&canvas, Qt::Key_1);
- QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(unvalidatedInput->text(), QLatin1String("1"));
- QCOMPARE(unvalidatedInput->hasAcceptableInput(), true);
- QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true);
- QCOMPARE(unvalidatedSpy.count(), 0);
- QTest::keyPress(&canvas, Qt::Key_A);
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QTest::qWait(50);
- QTRY_COMPARE(unvalidatedInput->text(), QLatin1String("1a"));
- QCOMPARE(unvalidatedInput->hasAcceptableInput(), true);
- QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true);
- QCOMPARE(unvalidatedSpy.count(), 0);
-}
-
-void tst_qquicktextinput::inputMethods()
-{
- QQuickView canvas(testFileUrl("inputmethods.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
-
- // test input method hints
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(canvas.rootObject());
- QVERIFY(input != 0);
- QVERIFY(input->inputMethodHints() & Qt::ImhNoPredictiveText);
- QSignalSpy inputMethodHintSpy(input, SIGNAL(inputMethodHintsChanged()));
- input->setInputMethodHints(Qt::ImhUppercaseOnly);
- QVERIFY(input->inputMethodHints() & Qt::ImhUppercaseOnly);
- QCOMPARE(inputMethodHintSpy.count(), 1);
- input->setInputMethodHints(Qt::ImhUppercaseOnly);
- QCOMPARE(inputMethodHintSpy.count(), 1);
-
- // default value
- QQuickTextInput plainInput;
- QCOMPARE(plainInput.inputMethodHints(), Qt::ImhNone);
-
- input->setFocus(true);
- QVERIFY(input->hasActiveFocus() == true);
- // test that input method event is committed
- QInputMethodEvent event;
- event.setCommitString( "My ", -12, 0);
- QTRY_COMPARE(qGuiApp->focusObject(), input);
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
- QCOMPARE(input->text(), QString("My Hello world!"));
-
- input->setCursorPosition(2);
- event.setCommitString("Your", -2, 2);
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
- QCOMPARE(input->text(), QString("Your Hello world!"));
- QCOMPARE(input->cursorPosition(), 4);
-
- input->setCursorPosition(7);
- event.setCommitString("Goodbye", -2, 5);
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
- QCOMPARE(input->text(), QString("Your Goodbye world!"));
- QCOMPARE(input->cursorPosition(), 12);
-
- input->setCursorPosition(8);
- event.setCommitString("Our", -8, 4);
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
- QCOMPARE(input->text(), QString("Our Goodbye world!"));
- QCOMPARE(input->cursorPosition(), 7);
-
- // test that basic tentative commit gets to text property on preedit state
- input->setText("");
- QList<QInputMethodEvent::Attribute> attributes;
- QInputMethodEvent preeditEvent("test", attributes);
- preeditEvent.setTentativeCommitString("test");
- QGuiApplication::sendEvent(input, &preeditEvent);
- QCOMPARE(input->text(), QString("test"));
-
- // tentative commit not allowed present in surrounding text
- QInputMethodQueryEvent queryEvent(Qt::ImSurroundingText);
- QGuiApplication::sendEvent(input, &queryEvent);
- QCOMPARE(queryEvent.value(Qt::ImSurroundingText).toString(), QString(""));
-
- // if text with tentative commit does not validate, not allowed to be part of text property
- input->setText(""); // ensure input state is reset
- QValidator *validator = new QIntValidator(0, 100);
- input->setValidator(validator);
- QGuiApplication::sendEvent(input, &preeditEvent);
- QCOMPARE(input->text(), QString(""));
- input->setValidator(0);
- delete validator;
-
- // input should reset selection even if replacement parameters are out of bounds
- input->setText("text");
- input->setCursorPosition(0);
- input->moveCursorSelection(input->text().length());
- event.setCommitString("replacement", -input->text().length(), input->text().length());
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
- QCOMPARE(input->selectionStart(), input->selectionEnd());
-
- QInputMethodQueryEvent enabledQueryEvent(Qt::ImEnabled);
- QGuiApplication::sendEvent(input, &enabledQueryEvent);
- QCOMPARE(enabledQueryEvent.value(Qt::ImEnabled).toBool(), true);
-
- input->setReadOnly(true);
- QGuiApplication::sendEvent(input, &enabledQueryEvent);
- QCOMPARE(enabledQueryEvent.value(Qt::ImEnabled).toBool(), false);
-}
-
-/*
-TextInput element should only handle left/right keys until the cursor reaches
-the extent of the text, then they should ignore the keys.
-
-*/
-void tst_qquicktextinput::navigation()
-{
- QQuickView canvas(testFileUrl("navigation.qml"));
- canvas.show();
- canvas.requestActivateWindow();
-
- QVERIFY(canvas.rootObject() != 0);
-
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- input->setCursorPosition(0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == false);
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
- //QT-2944: If text is selected, ensure we deselect upon cursor motion
- input->setCursorPosition(input->text().length());
- input->select(0,input->text().length());
- QVERIFY(input->selectionStart() != input->selectionEnd());
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->selectionStart() == input->selectionEnd());
- QVERIFY(input->selectionStart() == input->text().length());
- QVERIFY(input->hasActiveFocus() == true);
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == false);
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
-
- // Up and Down should NOT do Home/End, even on Mac OS X (QTBUG-10438).
- input->setCursorPosition(2);
- QCOMPARE(input->cursorPosition(),2);
- simulateKey(&canvas, Qt::Key_Up);
- QCOMPARE(input->cursorPosition(),2);
- simulateKey(&canvas, Qt::Key_Down);
- QCOMPARE(input->cursorPosition(),2);
-}
-
-void tst_qquicktextinput::navigation_RTL()
-{
- QQuickView canvas(testFileUrl("navigation.qml"));
- canvas.show();
- canvas.requestActivateWindow();
-
- QVERIFY(canvas.rootObject() != 0);
-
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647};
- input->setText(QString::fromUtf16(arabic_str, 11));
-
- input->setCursorPosition(0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
-
- // move off
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == false);
-
- // move back
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == true);
-
- input->setCursorPosition(input->text().length());
- QVERIFY(input->hasActiveFocus() == true);
-
- // move off
- simulateKey(&canvas, Qt::Key_Left);
- QVERIFY(input->hasActiveFocus() == false);
-
- // move back
- simulateKey(&canvas, Qt::Key_Right);
- QVERIFY(input->hasActiveFocus() == true);
-}
-
-void tst_qquicktextinput::copyAndPaste() {
-#ifndef QT_NO_CLIPBOARD
-
-#ifdef Q_OS_MAC
- {
- PasteboardRef pasteboard;
- OSStatus status = PasteboardCreate(0, &pasteboard);
- if (status == noErr)
- CFRelease(pasteboard);
- else
- QSKIP("This machine doesn't support the clipboard");
- }
-#endif
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- // copy and paste
- QCOMPARE(textInput->text().length(), 12);
- textInput->select(0, textInput->text().length());;
- textInput->copy();
- QCOMPARE(textInput->selectedText(), QString("Hello world!"));
- QCOMPARE(textInput->selectedText().length(), 12);
- textInput->setCursorPosition(0);
- QVERIFY(textInput->canPaste());
- textInput->paste();
- QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textInput->text().length(), 24);
-
- // can paste
- QVERIFY(textInput->canPaste());
- textInput->setReadOnly(true);
- QVERIFY(!textInput->canPaste());
- textInput->setReadOnly(false);
- QVERIFY(textInput->canPaste());
-
- // select word
- textInput->setCursorPosition(0);
- textInput->selectWord();
- QCOMPARE(textInput->selectedText(), QString("Hello"));
-
- // select all and cut
- textInput->selectAll();
- textInput->cut();
- QCOMPARE(textInput->text().length(), 0);
- textInput->paste();
- QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textInput->text().length(), 24);
-
- // clear copy buffer
- QClipboard *clipboard = QGuiApplication::clipboard();
- QVERIFY(clipboard);
- clipboard->clear();
- QVERIFY(!textInput->canPaste());
-
- // test that copy functionality is disabled
- // when echo mode is set to hide text/password mode
- int index = 0;
- while (index < 4) {
- QQuickTextInput::EchoMode echoMode = QQuickTextInput::EchoMode(index);
- textInput->setEchoMode(echoMode);
- textInput->setText("My password");
- textInput->select(0, textInput->text().length());;
- textInput->copy();
- if (echoMode == QQuickTextInput::Normal) {
- QVERIFY(!clipboard->text().isEmpty());
- QCOMPARE(clipboard->text(), QString("My password"));
- clipboard->clear();
- } else {
- QVERIFY(clipboard->text().isEmpty());
- }
- index++;
- }
-
- delete textInput;
-#endif
-}
-
-void tst_qquicktextinput::copyAndPasteKeySequence() {
-#ifndef QT_NO_CLIPBOARD
-
-#ifdef Q_OS_MAC
- {
- PasteboardRef pasteboard;
- OSStatus status = PasteboardCreate(0, &pasteboard);
- if (status == noErr)
- CFRelease(pasteboard);
- else
- QSKIP("This machine doesn't support the clipboard");
- }
-#endif
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\"; focus: true }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- QQuickCanvas canvas;
- textInput->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- // copy and paste
- QVERIFY(textInput->hasActiveFocus());
- QCOMPARE(textInput->text().length(), 12);
- textInput->select(0, textInput->text().length());
- simulateKeys(&canvas, QKeySequence::Copy);
- QCOMPARE(textInput->selectedText(), QString("Hello world!"));
- QCOMPARE(textInput->selectedText().length(), 12);
- textInput->setCursorPosition(0);
- QVERIFY(textInput->canPaste());
- simulateKeys(&canvas, QKeySequence::Paste);
- QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textInput->text().length(), 24);
-
- // select all and cut
- simulateKeys(&canvas, QKeySequence::SelectAll);
- simulateKeys(&canvas, QKeySequence::Cut);
- QCOMPARE(textInput->text().length(), 0);
- simulateKeys(&canvas, QKeySequence::Paste);
- QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
- QCOMPARE(textInput->text().length(), 24);
-
- // clear copy buffer
- QClipboard *clipboard = QGuiApplication::clipboard();
- QVERIFY(clipboard);
- clipboard->clear();
- QVERIFY(!textInput->canPaste());
-
- // test that copy functionality is disabled
- // when echo mode is set to hide text/password mode
- int index = 0;
- while (index < 4) {
- QQuickTextInput::EchoMode echoMode = QQuickTextInput::EchoMode(index);
- textInput->setEchoMode(echoMode);
- textInput->setText("My password");
- textInput->select(0, textInput->text().length());;
- simulateKeys(&canvas, QKeySequence::Copy);
- if (echoMode == QQuickTextInput::Normal) {
- QVERIFY(!clipboard->text().isEmpty());
- QCOMPARE(clipboard->text(), QString("My password"));
- clipboard->clear();
- } else {
- QVERIFY(clipboard->text().isEmpty());
- }
- index++;
- }
-
- delete textInput;
-#endif
-}
-
-void tst_qquicktextinput::canPasteEmpty() {
-#ifndef QT_NO_CLIPBOARD
-
- QGuiApplication::clipboard()->clear();
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- bool cp = !textInput->isReadOnly() && QGuiApplication::clipboard()->text().length() != 0;
- QCOMPARE(textInput->canPaste(), cp);
-
-#endif
-}
-
-void tst_qquicktextinput::canPaste() {
-#ifndef QT_NO_CLIPBOARD
-
- QGuiApplication::clipboard()->setText("Some text");
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- bool cp = !textInput->isReadOnly() && QGuiApplication::clipboard()->text().length() != 0;
- QCOMPARE(textInput->canPaste(), cp);
-
-#endif
-}
-
-void tst_qquicktextinput::passwordCharacter()
-{
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\"; font.family: \"Helvetica\"; echoMode: TextInput.Password }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- textInput->setPasswordCharacter("X");
- qreal implicitWidth = textInput->implicitWidth();
- textInput->setPasswordCharacter(".");
-
- // QTBUG-12383 content is updated and redrawn
- QVERIFY(textInput->implicitWidth() < implicitWidth);
-
- delete textInput;
-}
-
-void tst_qquicktextinput::cursorDelegate_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::newRow("out of line") << testFileUrl("cursorTest.qml");
- QTest::newRow("in line") << testFileUrl("cursorTestInline.qml");
- QTest::newRow("external") << testFileUrl("cursorTestExternal.qml");
-}
-
-void tst_qquicktextinput::cursorDelegate()
-{
- QFETCH(QUrl, source);
- QQuickView view(source);
- view.show();
- view.requestActivateWindow();
- QQuickTextInput *textInputObject = view.rootObject()->findChild<QQuickTextInput*>("textInputObject");
- QVERIFY(textInputObject != 0);
- QVERIFY(textInputObject->findChild<QQuickItem*>("cursorInstance"));
- //Test Delegate gets created
- textInputObject->setFocus(true);
- QQuickItem* delegateObject = textInputObject->findChild<QQuickItem*>("cursorInstance");
- QVERIFY(delegateObject);
- QCOMPARE(delegateObject->property("localProperty").toString(), QString("Hello"));
- //Test Delegate gets moved
- for (int i=0; i<= textInputObject->text().length(); i++) {
- textInputObject->setCursorPosition(i);
- QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y()));
- }
- textInputObject->setCursorPosition(0);
- QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x()));
- QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y()));
- //Test Delegate gets deleted
- textInputObject->setCursorDelegate(0);
- QVERIFY(!textInputObject->findChild<QQuickItem*>("cursorInstance"));
-}
-
-void tst_qquicktextinput::cursorVisible()
-{
- QQuickView view(testFileUrl("cursorVisible.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
-
- QQuickTextInput input;
- input.componentComplete();
- QSignalSpy spy(&input, SIGNAL(cursorVisibleChanged(bool)));
-
- QCOMPARE(input.isCursorVisible(), false);
-
- input.setCursorVisible(true);
- QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 1);
-
- input.setCursorVisible(false);
- QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 2);
-
- input.setFocus(true);
- QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 2);
-
- input.setParentItem(view.rootObject());
- QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 3);
-
- input.setFocus(false);
- QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 4);
-
- input.setFocus(true);
- QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 5);
-
- QQuickView alternateView;
- alternateView.show();
- alternateView.requestActivateWindow();
- QTest::qWaitForWindowShown(&alternateView);
-
- QCOMPARE(input.isCursorVisible(), false);
- QCOMPARE(spy.count(), 6);
-
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QCOMPARE(input.isCursorVisible(), true);
- QCOMPARE(spy.count(), 7);
-}
-
-static QRect round(const QRectF &r) {
- return QRect(qRound(r.left()), qRound(r.top()), qCeil(r.width()), qCeil(r.height())); }
-
-void tst_qquicktextinput::cursorRectangle()
-{
-
- QString text = "Hello World!";
-
- QQuickTextInput input;
- input.setText(text);
- input.componentComplete();
-
- QTextLayout layout(text);
- layout.setFont(input.font());
- if (!qmlDisableDistanceField()) {
- QTextOption option;
- option.setUseDesignMetrics(true);
- layout.setTextOption(option);
- }
- layout.beginLayout();
- QTextLine line = layout.createLine();
- layout.endLayout();
-
- input.setWidth(line.cursorToX(5, QTextLine::Leading));
- input.setHeight(qCeil(line.height() * 3 / 2));
-
- QRect r;
-
- // some tolerance for different fonts.
-#ifdef Q_OS_LINUX
- const int error = 2;
-#else
- const int error = 5;
-#endif
-
- for (int i = 0; i <= 5; ++i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
-
- QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing)));
- QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading)));
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(i)), r);
- }
-
- // Check the cursor rectangle remains within the input bounding rect when auto scrolling.
- QVERIFY(r.left() < input.width());
- QVERIFY(r.right() >= input.width() - error);
-
- for (int i = 6; i < text.length(); ++i) {
- input.setCursorPosition(i);
- QCOMPARE(r, input.cursorRectangle());
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(i)), r);
- }
-
- for (int i = text.length() - 2; i >= 0; --i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
- QCOMPARE(r.top(), 0);
- QVERIFY(r.right() >= 0);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(i)), r);
- }
-
- // Check position with word wrap.
- input.setWrapMode(QQuickTextInput::WordWrap);
- input.setAutoScroll(false);
- for (int i = 0; i <= 5; ++i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
-
- QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing)));
- QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading)));
- QCOMPARE(r.top(), 0);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(i)), r);
- }
-
- input.setCursorPosition(6);
- r = input.cursorRectangle();
- QCOMPARE(r.left(), 0);
- QVERIFY(r.top() > line.height() - error);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(6)), r);
-
- for (int i = 7; i < text.length(); ++i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
- QVERIFY(r.top() > line.height() - error);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(i)), r);
- }
-
- // Check vertical scrolling with word wrap.
- input.setAutoScroll(true);
- for (int i = 0; i <= 5; ++i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
-
- QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing)));
- QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading)));
- QCOMPARE(r.top(), 0);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(round(input.positionToRectangle(i))), r);
- }
-
- input.setCursorPosition(6);
- r = input.cursorRectangle();
- QCOMPARE(r.left(), 0);
- QVERIFY(r.bottom() >= input.height() - error);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(6)), r);
-
- for (int i = 7; i < text.length(); ++i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
- QVERIFY(r.bottom() >= input.height() - error);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(i)), r);
- }
-
- for (int i = text.length() - 2; i >= 6; --i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
- QVERIFY(r.bottom() >= input.height() - error);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(i)), r);
- }
-
- for (int i = 5; i >= 0; --i) {
- input.setCursorPosition(i);
- r = input.cursorRectangle();
- QCOMPARE(r.top(), 0);
- QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
- QCOMPARE(round(input.positionToRectangle(i)), r);
- }
-
- input.setText("Hi!");
- input.setHAlign(QQuickTextInput::AlignRight);
- r = input.cursorRectangle();
- QVERIFY(r.left() < input.width() + error);
- QVERIFY(r.right() >= input.width() - error);
-}
-
-void tst_qquicktextinput::readOnly()
-{
- QQuickView canvas(testFileUrl("readOnly.qml"));
- canvas.show();
- canvas.requestActivateWindow();
-
- QVERIFY(canvas.rootObject() != 0);
-
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
- QVERIFY(input->isReadOnly() == true);
- QString initial = input->text();
- for (int k=Qt::Key_0; k<=Qt::Key_Z; k++)
- simulateKey(&canvas, k);
- simulateKey(&canvas, Qt::Key_Return);
- simulateKey(&canvas, Qt::Key_Space);
- simulateKey(&canvas, Qt::Key_Escape);
- QCOMPARE(input->text(), initial);
-
- input->setCursorPosition(3);
- input->setReadOnly(false);
- QCOMPARE(input->isReadOnly(), false);
- QCOMPARE(input->cursorPosition(), input->text().length());
-}
-
-void tst_qquicktextinput::echoMode()
-{
- QQuickView canvas(testFileUrl("echoMode.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QVERIFY(canvas.rootObject() != 0);
-
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
-
- QVERIFY(input != 0);
- QTRY_VERIFY(input->hasActiveFocus() == true);
- QString initial = input->text();
- Qt::InputMethodHints ref;
- QCOMPARE(initial, QLatin1String("ABCDefgh"));
- QCOMPARE(input->echoMode(), QQuickTextInput::Normal);
- QCOMPARE(input->displayText(), input->text());
- //Normal
- ref &= ~Qt::ImhHiddenText;
- ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
- QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
- input->setEchoMode(QQuickTextInput::NoEcho);
- QCOMPARE(input->text(), initial);
- QCOMPARE(input->displayText(), QLatin1String(""));
- QCOMPARE(input->passwordCharacter(), QLatin1String("*"));
- //NoEcho
- ref |= Qt::ImhHiddenText;
- ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
- QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
- input->setEchoMode(QQuickTextInput::Password);
- //Password
- ref |= Qt::ImhHiddenText;
- ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
- QCOMPARE(input->text(), initial);
- QCOMPARE(input->displayText(), QLatin1String("********"));
- QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
- // clearing input hints do not clear bits set by echo mode
- input->setInputMethodHints(Qt::ImhNone);
- QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
- input->setPasswordCharacter(QChar('Q'));
- QCOMPARE(input->passwordCharacter(), QLatin1String("Q"));
- QCOMPARE(input->text(), initial);
- QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
- input->setEchoMode(QQuickTextInput::PasswordEchoOnEdit);
- //PasswordEchoOnEdit
- ref &= ~Qt::ImhHiddenText;
- ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
- QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
- QCOMPARE(input->text(), initial);
- QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
- QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("QQQQQQQQ"));
- QTest::keyPress(&canvas, Qt::Key_A);//Clearing previous entry is part of PasswordEchoOnEdit
- QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
- QCOMPARE(input->text(), QLatin1String("a"));
- QCOMPARE(input->displayText(), QLatin1String("a"));
- QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("a"));
- input->setFocus(false);
- QVERIFY(input->hasActiveFocus() == false);
- QCOMPARE(input->displayText(), QLatin1String("Q"));
- QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("Q"));
- input->setFocus(true);
- QVERIFY(input->hasActiveFocus());
- QInputMethodEvent inputEvent;
- inputEvent.setCommitString(initial);
- QGuiApplication::sendEvent(input, &inputEvent);
- QCOMPARE(input->text(), initial);
- QCOMPARE(input->displayText(), initial);
- QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), initial);
-}
-
-#ifdef QT_GUI_PASSWORD_ECHO_DELAY
-void tst_qquicktextinput::passwordEchoDelay()
-{
- QQuickView canvas(testFileUrl("echoMode.qml"));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
-
- QVERIFY(canvas.rootObject() != 0);
-
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
-
- QChar fillChar = QLatin1Char('*');
-
- input->setEchoMode(QQuickTextInput::Password);
- QCOMPARE(input->displayText(), QString(8, fillChar));
- input->setText(QString());
- QCOMPARE(input->displayText(), QString());
-
- QTest::keyPress(&canvas, '0');
- QTest::keyPress(&canvas, '1');
- QTest::keyPress(&canvas, '2');
- QCOMPARE(input->displayText(), QString(2, fillChar) + QLatin1Char('2'));
- QTest::keyPress(&canvas, '3');
- QTest::keyPress(&canvas, '4');
- QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4'));
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QCOMPARE(input->displayText(), QString(4, fillChar));
- QTest::keyPress(&canvas, '4');
- QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4'));
- QTest::qWait(QT_GUI_PASSWORD_ECHO_DELAY);
- QTRY_COMPARE(input->displayText(), QString(5, fillChar));
- QTest::keyPress(&canvas, '5');
- QCOMPARE(input->displayText(), QString(5, fillChar) + QLatin1Char('5'));
- input->setFocus(false);
- QVERIFY(!input->hasFocus());
- QCOMPARE(input->displayText(), QString(6, fillChar));
- input->setFocus(true);
- QTRY_VERIFY(input->hasFocus());
- QCOMPARE(input->displayText(), QString(6, fillChar));
- QTest::keyPress(&canvas, '6');
- QCOMPARE(input->displayText(), QString(6, fillChar) + QLatin1Char('6'));
-
- QInputMethodEvent ev;
- ev.setCommitString(QLatin1String("7"));
- QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev);
- QCOMPARE(input->displayText(), QString(7, fillChar) + QLatin1Char('7'));
-
- input->setCursorPosition(3);
- QCOMPARE(input->displayText(), QString(7, fillChar) + QLatin1Char('7'));
- QTest::keyPress(&canvas, 'a');
- QCOMPARE(input->displayText(), QString(3, fillChar) + QLatin1Char('a') + QString(5, fillChar));
- QTest::keyPress(&canvas, Qt::Key_Backspace);
- QCOMPARE(input->displayText(), QString(8, fillChar));
-}
-#endif
-
-
-void tst_qquicktextinput::simulateKey(QQuickView *view, int key)
-{
- QKeyEvent press(QKeyEvent::KeyPress, key, 0);
- QKeyEvent release(QKeyEvent::KeyRelease, key, 0);
-
- QGuiApplication::sendEvent(view, &press);
- QGuiApplication::sendEvent(view, &release);
-}
-
-
-void tst_qquicktextinput::openInputPanel()
-{
- PlatformInputContext platformInputContext;
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = &platformInputContext;
-
- QQuickView view(testFileUrl("openInputPanel.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
-
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
- QVERIFY(input);
-
- // check default values
- QVERIFY(input->focusOnPress());
- QVERIFY(!input->hasActiveFocus());
- QVERIFY(qApp->focusObject() != input);
- QCOMPARE(qApp->inputMethod()->visible(), false);
-
- // input panel should open on focus
- QPoint centerPoint(view.width()/2, view.height()/2);
- Qt::KeyboardModifiers noModifiers = 0;
- QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
- QGuiApplication::processEvents();
- QVERIFY(input->hasActiveFocus());
- QCOMPARE(qApp->focusObject(), input);
- QCOMPARE(qApp->inputMethod()->visible(), true);
- QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
-
- // input panel should be re-opened when pressing already focused TextInput
- qApp->inputMethod()->hide();
- QCOMPARE(qApp->inputMethod()->visible(), false);
- QVERIFY(input->hasActiveFocus());
- QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
- QGuiApplication::processEvents();
- QCOMPARE(qApp->inputMethod()->visible(), true);
- QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
-
- // input panel should stay visible if focus is lost to another text inputor
- QSignalSpy inputPanelVisibilitySpy(qApp->inputMethod(), SIGNAL(visibleChanged()));
- QQuickTextInput anotherInput;
- anotherInput.componentComplete();
- anotherInput.setParentItem(view.rootObject());
- anotherInput.setFocus(true);
- QCOMPARE(qApp->inputMethod()->visible(), true);
- QCOMPARE(qApp->focusObject(), qobject_cast<QObject*>(&anotherInput));
- QCOMPARE(inputPanelVisibilitySpy.count(), 0);
-
- anotherInput.setFocus(false);
- QVERIFY(qApp->focusObject() != &anotherInput);
- QCOMPARE(view.activeFocusItem(), view.rootItem());
- anotherInput.setFocus(true);
-
- qApp->inputMethod()->hide();
-
- // input panel should not be opened if TextInput is read only
- input->setReadOnly(true);
- input->setFocus(true);
- QCOMPARE(qApp->inputMethod()->visible(), false);
- QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
- QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
- QGuiApplication::processEvents();
- QCOMPARE(qApp->inputMethod()->visible(), false);
-
- // input panel should not be opened if focusOnPress is set to false
- input->setFocusOnPress(false);
- input->setFocus(false);
- input->setFocus(true);
- QCOMPARE(qApp->inputMethod()->visible(), false);
- QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
- QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
- QCOMPARE(qApp->inputMethod()->visible(), false);
-
- // input panel should open when openSoftwareInputPanel is called
- input->openSoftwareInputPanel();
- QCOMPARE(qApp->inputMethod()->visible(), true);
-
- // input panel should close when closeSoftwareInputPanel is called
- input->closeSoftwareInputPanel();
- QCOMPARE(qApp->inputMethod()->visible(), false);
-}
-
-class MyTextInput : public QQuickTextInput
-{
-public:
- MyTextInput(QQuickItem *parent = 0) : QQuickTextInput(parent)
- {
- nbPaint = 0;
- }
- virtual QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *data)
- {
- nbPaint++;
- return QQuickTextInput::updatePaintNode(node, data);
- }
- int nbPaint;
-};
-
-void tst_qquicktextinput::setHAlignClearCache()
-{
- QQuickView view;
- MyTextInput input;
- input.setText("Hello world");
- input.setParentItem(view.rootItem());
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
-#ifdef Q_OS_MAC
- QEXPECT_FAIL("", "QTBUG-23485", Abort);
-#endif
- QTRY_COMPARE(input.nbPaint, 1);
- input.setHAlign(QQuickTextInput::AlignRight);
- //Changing the alignment should trigger a repaint
- QTRY_COMPARE(input.nbPaint, 2);
-}
-
-void tst_qquicktextinput::focusOutClearSelection()
-{
- QQuickView view;
- QQuickTextInput input;
- QQuickTextInput input2;
- input.setText(QLatin1String("Hello world"));
- input.setFocus(true);
- input2.setParentItem(view.rootItem());
- input.setParentItem(view.rootItem());
- input.componentComplete();
- input2.componentComplete();
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- input.select(2,5);
- //The selection should work
- QTRY_COMPARE(input.selectedText(), QLatin1String("llo"));
- input2.setFocus(true);
- QGuiApplication::processEvents();
- //The input lost the focus selection should be cleared
- QTRY_COMPARE(input.selectedText(), QLatin1String(""));
-}
-
-void tst_qquicktextinput::geometrySignals()
-{
- QDeclarativeComponent component(&engine, testFileUrl("geometrySignals.qml"));
- QObject *o = component.create();
- QVERIFY(o);
- QCOMPARE(o->property("bindingWidth").toInt(), 400);
- QCOMPARE(o->property("bindingHeight").toInt(), 500);
- delete o;
-}
-
-void tst_qquicktextinput::contentSize()
-{
- QString componentStr = "import QtQuick 2.0\nTextInput { width: 75; height: 16; font.pixelSize: 10 }";
- QDeclarativeComponent textComponent(&engine);
- textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
- QScopedPointer<QObject> object(textComponent.create());
- QQuickTextInput *textObject = qobject_cast<QQuickTextInput *>(object.data());
-
- QSignalSpy spy(textObject, SIGNAL(contentSizeChanged()));
-
- textObject->setText("The quick red fox jumped over the lazy brown dog");
-
- QVERIFY(textObject->contentWidth() > textObject->width());
- QVERIFY(textObject->contentHeight() < textObject->height());
- QCOMPARE(spy.count(), 1);
-
- textObject->setWrapMode(QQuickTextInput::WordWrap);
- QVERIFY(textObject->contentWidth() <= textObject->width());
- QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), 2);
-
- textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
-
- QVERIFY(textObject->contentWidth() > textObject->width());
- QVERIFY(textObject->contentHeight() > textObject->height());
- QCOMPARE(spy.count(), 3);
-}
-
-static void sendPreeditText(const QString &text, int cursor)
-{
- QInputMethodEvent event(text, QList<QInputMethodEvent::Attribute>()
- << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor, text.length(), QVariant()));
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &event);
-}
-
-void tst_qquicktextinput::preeditAutoScroll()
-{
- QString preeditText = "califragisiticexpialidocious!";
-
- QQuickView view(testFileUrl("preeditAutoScroll.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
- QVERIFY(input);
- QVERIFY(input->hasActiveFocus());
-
- input->setWidth(input->implicitWidth());
-
- QSignalSpy cursorRectangleSpy(input, SIGNAL(cursorRectangleChanged()));
- int cursorRectangleChanges = 0;
-
- // test the text is scrolled so the preedit is visible.
- sendPreeditText(preeditText.mid(0, 3), 1);
- QVERIFY(evaluate<int>(input, QString("positionAt(0)")) != 0);
- QVERIFY(input->cursorRectangle().left() < input->boundingRect().width());
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
-
- // test the text is scrolled back when the preedit is removed.
- QInputMethodEvent imEvent;
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
- QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(0)), 0);
- QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(input->width())), 5);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
-
- QTextLayout layout(preeditText);
- layout.setFont(input->font());
- if (!qmlDisableDistanceField()) {
- QTextOption option;
- option.setUseDesignMetrics(true);
- layout.setTextOption(option);
- }
- layout.beginLayout();
- QTextLine line = layout.createLine();
- layout.endLayout();
-
- // test if the preedit is larger than the text input that the
- // character preceding the cursor is still visible.
- qreal x = input->positionToRectangle(0).x();
- for (int i = 0; i < 3; ++i) {
- sendPreeditText(preeditText, i + 1);
- int width = ceil(line.cursorToX(i, QTextLine::Trailing)) - floor(line.cursorToX(i));
- QVERIFY(input->cursorRectangle().right() >= width - 3);
- QVERIFY(input->positionToRectangle(0).x() < x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
- x = input->positionToRectangle(0).x();
- }
- for (int i = 1; i >= 0; --i) {
- sendPreeditText(preeditText, i + 1);
- int width = ceil(line.cursorToX(i, QTextLine::Trailing)) - floor(line.cursorToX(i));
- QVERIFY(input->cursorRectangle().right() >= width - 3);
- QVERIFY(input->positionToRectangle(0).x() > x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
- x = input->positionToRectangle(0).x();
- }
-
- // Test incrementing the preedit cursor doesn't cause further
- // scrolling when right most text is visible.
- sendPreeditText(preeditText, preeditText.length() - 3);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
- x = input->positionToRectangle(0).x();
- for (int i = 2; i >= 0; --i) {
- sendPreeditText(preeditText, preeditText.length() - i);
- QCOMPARE(input->positionToRectangle(0).x(), x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
- }
- for (int i = 1; i < 3; ++i) {
- sendPreeditText(preeditText, preeditText.length() - i);
- QCOMPARE(input->positionToRectangle(0).x(), x);
- QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
- }
-
- // Test disabling auto scroll.
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
-
- input->setAutoScroll(false);
- sendPreeditText(preeditText.mid(0, 3), 1);
- QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(0)), 0);
- QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(input->width())), 5);
-}
-
-void tst_qquicktextinput::preeditCursorRectangle()
-{
- QString preeditText = "super";
-
- QQuickView view(testFileUrl("inputMethodEvent.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
- QVERIFY(input);
-
- QRect currentRect;
-
- QInputMethodQueryEvent query(Qt::ImCursorRectangle);
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
- QRect previousRect = query.value(Qt::ImCursorRectangle).toRect();
-
- // Verify that the micro focus rect is positioned the same for position 0 as
- // it would be if there was no preedit text.
- sendPreeditText(preeditText, 0);
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
- currentRect = query.value(Qt::ImCursorRectangle).toRect();
- QCOMPARE(currentRect, previousRect);
-
- QSignalSpy inputSpy(input, SIGNAL(cursorRectangleChanged()));
- QSignalSpy panelSpy(qGuiApp->inputMethod(), SIGNAL(cursorRectangleChanged()));
-
- // Verify that the micro focus rect moves to the left as the cursor position
- // is incremented.
- for (int i = 1; i <= 5; ++i) {
- sendPreeditText(preeditText, i);
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
- currentRect = query.value(Qt::ImCursorRectangle).toRect();
- QVERIFY(previousRect.left() < currentRect.left());
- QVERIFY(inputSpy.count() > 0); inputSpy.clear();
- QVERIFY(panelSpy.count() > 0); panelSpy.clear();
- previousRect = currentRect;
- }
-
- // Verify that if there is no preedit cursor then the micro focus rect is the
- // same as it would be if it were positioned at the end of the preedit text.
- sendPreeditText(preeditText, 0);
- QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>());
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
- QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
- currentRect = query.value(Qt::ImCursorRectangle).toRect();
- QCOMPARE(currentRect, previousRect);
- QVERIFY(inputSpy.count() > 0);
- QVERIFY(panelSpy.count() > 0);
-}
-
-void tst_qquicktextinput::inputContextMouseHandler()
-{
- PlatformInputContext platformInputContext;
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = &platformInputContext;
-
- QString text = "supercalifragisiticexpialidocious!";
- QQuickView view(testFileUrl("inputContext.qml"));
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
- QVERIFY(input);
-
- input->setFocus(true);
- input->setText("");
-
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
-
- QTextLayout layout(text);
- layout.setFont(input->font());
- if (!qmlDisableDistanceField()) {
- QTextOption option;
- option.setUseDesignMetrics(true);
- layout.setTextOption(option);
- }
- layout.beginLayout();
- QTextLine line = layout.createLine();
- layout.endLayout();
-
- const qreal x = line.cursorToX(2, QTextLine::Leading);
- const qreal y = line.height() / 2;
- QPoint position = QPointF(x, y).toPoint();
-
- QInputMethodEvent inputEvent(text.mid(0, 5), QList<QInputMethodEvent::Attribute>());
- QGuiApplication::sendEvent(input, &inputEvent);
-
- QTest::mousePress(&view, Qt::LeftButton, Qt::NoModifier, position);
- QTest::mouseRelease(&view, Qt::LeftButton, Qt::NoModifier, position);
- QGuiApplication::processEvents();
-
- QCOMPARE(platformInputContext.m_action, QInputMethod::Click);
- QCOMPARE(platformInputContext.m_invokeActionCallCount, 1);
- QCOMPARE(platformInputContext.m_cursorPosition, 2);
-}
-
-void tst_qquicktextinput::inputMethodComposing()
-{
- QString text = "supercalifragisiticexpialidocious!";
-
- QQuickView view(testFileUrl("inputContext.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
- QVERIFY(input);
- QSignalSpy spy(input, SIGNAL(inputMethodComposingChanged()));
-
- QCOMPARE(input->isInputMethodComposing(), false);
- {
- QInputMethodEvent event(text.mid(3), QList<QInputMethodEvent::Attribute>());
- QGuiApplication::sendEvent(input, &event);
- }
- QCOMPARE(input->isInputMethodComposing(), true);
- QCOMPARE(spy.count(), 1);
-
- {
- QInputMethodEvent event(text.mid(12), QList<QInputMethodEvent::Attribute>());
- QGuiApplication::sendEvent(input, &event);
- }
- QCOMPARE(spy.count(), 1);
-
- {
- QInputMethodEvent event;
- QGuiApplication::sendEvent(input, &event);
- }
- QCOMPARE(input->isInputMethodComposing(), false);
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktextinput::inputMethodUpdate()
-{
- PlatformInputContext platformInputContext;
- QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
- inputMethodPrivate->testContext = &platformInputContext;
-
- QQuickView view(testFileUrl("inputContext.qml"));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
- QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
- QVERIFY(input);
-
- // text change even without cursor position change needs to trigger update
- input->setText("test");
- platformInputContext.clear();
- input->setText("xxxx");
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // input method event replacing text
- platformInputContext.clear();
- {
- QInputMethodEvent inputMethodEvent;
- inputMethodEvent.setCommitString("y", -1, 1);
- QGuiApplication::sendEvent(input, &inputMethodEvent);
- }
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // input method changing selection
- platformInputContext.clear();
- {
- QList<QInputMethodEvent::Attribute> attributes;
- attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 2, QVariant());
- QInputMethodEvent inputMethodEvent("", attributes);
- QGuiApplication::sendEvent(input, &inputMethodEvent);
- }
- QVERIFY(input->selectionStart() != input->selectionEnd());
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // programmatical selections trigger update
- platformInputContext.clear();
- input->selectAll();
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // font changes
- platformInputContext.clear();
- QFont font = input->font();
- font.setBold(!font.bold());
- input->setFont(font);
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // normal input
- platformInputContext.clear();
- {
- QInputMethodEvent inputMethodEvent;
- inputMethodEvent.setCommitString("y");
- QGuiApplication::sendEvent(input, &inputMethodEvent);
- }
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // changing cursor position
- platformInputContext.clear();
- input->setCursorPosition(0);
- QVERIFY(platformInputContext.m_updateCallCount > 0);
-
- // read only disabled input method
- platformInputContext.clear();
- input->setReadOnly(true);
- QVERIFY(platformInputContext.m_updateCallCount > 0);
- input->setReadOnly(false);
-
- // no updates while no focus
- input->setFocus(false);
- platformInputContext.clear();
- input->setText("Foo");
- QCOMPARE(platformInputContext.m_updateCallCount, 0);
- input->setCursorPosition(1);
- QCOMPARE(platformInputContext.m_updateCallCount, 0);
- input->selectAll();
- QCOMPARE(platformInputContext.m_updateCallCount, 0);
- input->setReadOnly(true);
- QCOMPARE(platformInputContext.m_updateCallCount, 0);
-}
-
-void tst_qquicktextinput::cursorRectangleSize()
-{
- QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml"));
- QVERIFY(canvas->rootObject() != 0);
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput *>(canvas->rootObject());
-
- // make sure cursor rectangle is not at (0,0)
- textInput->setX(10);
- textInput->setY(10);
- textInput->setCursorPosition(3);
- QVERIFY(textInput != 0);
- textInput->setFocus(true);
- canvas->show();
- canvas->requestActivateWindow();
- QTest::qWaitForWindowShown(canvas);
- QTRY_VERIFY(qApp->focusObject());
-
- QInputMethodQueryEvent event(Qt::ImCursorRectangle);
- qApp->sendEvent(qApp->focusObject(), &event);
- QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF();
-
- QRect cursorRectFromItem = textInput->cursorRectangle();
- QRectF cursorRectFromPositionToRectangle = textInput->positionToRectangle(textInput->cursorPosition());
-
- // item and input query cursor rectangles match
- QCOMPARE(cursorRectFromItem, cursorRectFromQuery.toRect());
-
- // item cursor rectangle and positionToRectangle calculations match
- QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle.toRect());
-
- // item-canvas transform and input item transform match
- QCOMPARE(QQuickItemPrivate::get(textInput)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform());
-
- // input panel cursorRectangle property and tranformed item cursor rectangle match
- QRectF sceneCursorRect = QQuickItemPrivate::get(textInput)->itemToCanvasTransform().mapRect(cursorRectFromItem);
- QCOMPARE(sceneCursorRect, qApp->inputMethod()->cursorRectangle());
-
- delete canvas;
-}
-
-void tst_qquicktextinput::tripleClickSelectsAll()
-{
- QString qmlfile = testFile("positionAt.qml");
- QQuickView view(QUrl::fromLocalFile(qmlfile));
- view.show();
- view.requestActivateWindow();
- QTest::qWaitForWindowShown(&view);
-
- QTRY_COMPARE(&view, qGuiApp->focusWindow());
-
- QQuickTextInput* input = qobject_cast<QQuickTextInput*>(view.rootObject());
- QVERIFY(input);
-
- QLatin1String hello("Hello world!");
- input->setSelectByMouse(true);
- input->setText(hello);
-
- // Clicking on the same point inside TextInput three times in a row
- // should trigger a triple click, thus selecting all the text.
- QPoint pointInside = input->pos().toPoint() + QPoint(2,2);
- QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside);
- QTest::mouseClick(&view, Qt::LeftButton, 0, pointInside);
- QGuiApplication::processEvents();
- QCOMPARE(input->selectedText(), hello);
-
- // Now it simulates user moving the mouse between the second and the third click.
- // In this situation, we don't expect a triple click.
- QPoint pointInsideButFar = QPoint(input->width(),input->height()) - QPoint(2,2);
- QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside);
- QTest::mouseClick(&view, Qt::LeftButton, 0, pointInsideButFar);
- QGuiApplication::processEvents();
- QVERIFY(input->selectedText().isEmpty());
-
- // And now we press the third click too late, so no triple click event is triggered.
- QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside);
- QGuiApplication::processEvents();
- QTest::qWait(qApp->styleHints()->mouseDoubleClickInterval() + 1);
- QTest::mouseClick(&view, Qt::LeftButton, 0, pointInside);
- QGuiApplication::processEvents();
- QVERIFY(input->selectedText().isEmpty());
-}
-
-void tst_qquicktextinput::QTBUG_19956_data()
-{
- QTest::addColumn<QString>("url");
- QTest::newRow("intvalidator") << "qtbug-19956int.qml";
- QTest::newRow("doublevalidator") << "qtbug-19956double.qml";
-}
-
-
-void tst_qquicktextinput::getText_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QString>("inputMask");
- QTest::addColumn<int>("start");
- QTest::addColumn<int>("end");
- QTest::addColumn<QString>("expectedText");
-
- QTest::newRow("all plain text")
- << standard.at(0)
- << QString()
- << 0 << standard.at(0).length()
- << standard.at(0);
-
- QTest::newRow("plain text sub string")
- << standard.at(0)
- << QString()
- << 0 << 12
- << standard.at(0).mid(0, 12);
-
- QTest::newRow("plain text sub string reversed")
- << standard.at(0)
- << QString()
- << 12 << 0
- << standard.at(0).mid(0, 12);
-
- QTest::newRow("plain text cropped beginning")
- << standard.at(0)
- << QString()
- << -3 << 4
- << standard.at(0).mid(0, 4);
-
- QTest::newRow("plain text cropped end")
- << standard.at(0)
- << QString()
- << 23 << standard.at(0).length() + 8
- << standard.at(0).mid(23);
-
- QTest::newRow("plain text cropped beginning and end")
- << standard.at(0)
- << QString()
- << -9 << standard.at(0).length() + 4
- << standard.at(0);
-}
-
-void tst_qquicktextinput::getText()
-{
- QFETCH(QString, text);
- QFETCH(QString, inputMask);
- QFETCH(int, start);
- QFETCH(int, end);
- QFETCH(QString, expectedText);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- QCOMPARE(textInput->getText(start, end), expectedText);
-}
-
-void tst_qquicktextinput::insert_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QString>("inputMask");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<int>("insertPosition");
- QTest::addColumn<QString>("insertText");
- QTest::addColumn<QString>("expectedText");
- QTest::addColumn<int>("expectedSelectionStart");
- QTest::addColumn<int>("expectedSelectionEnd");
- QTest::addColumn<int>("expectedCursorPosition");
- QTest::addColumn<bool>("selectionChanged");
- QTest::addColumn<bool>("cursorPositionChanged");
-
- QTest::newRow("at cursor position (beginning)")
- << standard.at(0)
- << QString()
- << 0 << 0 << 0
- << QString("Hello")
- << QString("Hello") + standard.at(0)
- << 5 << 5 << 5
- << false << true;
-
- QTest::newRow("at cursor position (end)")
- << standard.at(0)
- << QString()
- << standard.at(0).length() << standard.at(0).length() << standard.at(0).length()
- << QString("Hello")
- << standard.at(0) + QString("Hello")
- << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
- << false << true;
-
- QTest::newRow("at cursor position (middle)")
- << standard.at(0)
- << QString()
- << 18 << 18 << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << 23 << 23 << 23
- << false << true;
-
- QTest::newRow("after cursor position (beginning)")
- << standard.at(0)
- << QString()
- << 0 << 0 << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("before cursor position (end)")
- << standard.at(0)
- << QString()
- << standard.at(0).length() << standard.at(0).length() << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
- << false << true;
-
- QTest::newRow("before cursor position (middle)")
- << standard.at(0)
- << QString()
- << 18 << 18 << 0
- << QString("Hello")
- << QString("Hello") + standard.at(0)
- << 23 << 23 << 23
- << false << true;
-
- QTest::newRow("after cursor position (middle)")
- << standard.at(0)
- << QString()
- << 18 << 18 << standard.at(0).length()
- << QString("Hello")
- << standard.at(0) + QString("Hello")
- << 18 << 18 << 18
- << false << false;
-
- QTest::newRow("before selection")
- << standard.at(0)
- << QString()
- << 14 << 19 << 0
- << QString("Hello")
- << QString("Hello") + standard.at(0)
- << 19 << 24 << 24
- << false << true;
-
- QTest::newRow("before reversed selection")
- << standard.at(0)
- << QString()
- << 19 << 14 << 0
- << QString("Hello")
- << QString("Hello") + standard.at(0)
- << 19 << 24 << 19
- << false << true;
-
- QTest::newRow("after selection")
- << standard.at(0)
- << QString()
- << 14 << 19 << standard.at(0).length()
- << QString("Hello")
- << standard.at(0) + QString("Hello")
- << 14 << 19 << 19
- << false << false;
-
- QTest::newRow("after reversed selection")
- << standard.at(0)
- << QString()
- << 19 << 14 << standard.at(0).length()
- << QString("Hello")
- << standard.at(0) + QString("Hello")
- << 14 << 19 << 14
- << false << false;
-
- QTest::newRow("into selection")
- << standard.at(0)
- << QString()
- << 14 << 19 << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << 14 << 24 << 24
- << true << true;
-
- QTest::newRow("into reversed selection")
- << standard.at(0)
- << QString()
- << 19 << 14 << 18
- << QString("Hello")
- << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
- << 14 << 24 << 14
- << true << false;
-
- QTest::newRow("rich text into plain text")
- << standard.at(0)
- << QString()
- << 0 << 0 << 0
- << QString("<b>Hello</b>")
- << QString("<b>Hello</b>") + standard.at(0)
- << 12 << 12 << 12
- << false << true;
-
- QTest::newRow("before start")
- << standard.at(0)
- << QString()
- << 0 << 0 << -3
- << QString("Hello")
- << standard.at(0)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("past end")
- << standard.at(0)
- << QString()
- << 0 << 0 << standard.at(0).length() + 3
- << QString("Hello")
- << standard.at(0)
- << 0 << 0 << 0
- << false << false;
-
- const QString inputMask = "009.009.009.009";
- const QString ip = "192.168.2.14";
-
- QTest::newRow("mask: at cursor position (beginning)")
- << ip
- << inputMask
- << 0 << 0 << 0
- << QString("125")
- << QString("125.168.2.14")
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("mask: at cursor position (end)")
- << ip
- << inputMask
- << inputMask.length() << inputMask.length() << inputMask.length()
- << QString("8")
- << ip
- << inputMask.length() << inputMask.length() << inputMask.length()
- << false << false;
-
- QTest::newRow("mask: at cursor position (middle)")
- << ip
- << inputMask
- << 6 << 6 << 6
- << QString("75.2")
- << QString("192.167.5.24")
- << 6 << 6 << 6
- << false << false;
-
- QTest::newRow("mask: after cursor position (beginning)")
- << ip
- << inputMask
- << 0 << 0 << 6
- << QString("75.2")
- << QString("192.167.5.24")
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("mask: before cursor position (end)")
- << ip
- << inputMask
- << inputMask.length() << inputMask.length() << 6
- << QString("75.2")
- << QString("192.167.5.24")
- << inputMask.length() << inputMask.length() << inputMask.length()
- << false << false;
-
- QTest::newRow("mask: before cursor position (middle)")
- << ip
- << inputMask
- << 6 << 6 << 0
- << QString("125")
- << QString("125.168.2.14")
- << 6 << 6 << 6
- << false << false;
-
- QTest::newRow("mask: after cursor position (middle)")
- << ip
- << inputMask
- << 6 << 6 << 13
- << QString("8")
- << "192.168.2.18"
- << 6 << 6 << 6
- << false << false;
-
- QTest::newRow("mask: before selection")
- << ip
- << inputMask
- << 6 << 8 << 0
- << QString("125")
- << QString("125.168.2.14")
- << 6 << 8 << 8
- << false << false;
-
- QTest::newRow("mask: before reversed selection")
- << ip
- << inputMask
- << 8 << 6 << 0
- << QString("125")
- << QString("125.168.2.14")
- << 6 << 8 << 6
- << false << false;
-
- QTest::newRow("mask: after selection")
- << ip
- << inputMask
- << 6 << 8 << 13
- << QString("8")
- << "192.168.2.18"
- << 6 << 8 << 8
- << false << false;
-
- QTest::newRow("mask: after reversed selection")
- << ip
- << inputMask
- << 8 << 6 << 13
- << QString("8")
- << "192.168.2.18"
- << 6 << 8 << 6
- << false << false;
-
- QTest::newRow("mask: into selection")
- << ip
- << inputMask
- << 5 << 8 << 6
- << QString("75.2")
- << QString("192.167.5.24")
- << 5 << 8 << 8
- << true << false;
-
- QTest::newRow("mask: into reversed selection")
- << ip
- << inputMask
- << 8 << 5 << 6
- << QString("75.2")
- << QString("192.167.5.24")
- << 5 << 8 << 5
- << true << false;
-
- QTest::newRow("mask: before start")
- << ip
- << inputMask
- << 0 << 0 << -3
- << QString("4")
- << ip
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("mask: past end")
- << ip
- << inputMask
- << 0 << 0 << ip.length() + 3
- << QString("4")
- << ip
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("mask: invalid characters")
- << ip
- << inputMask
- << 0 << 0 << 0
- << QString("abc")
- << QString("192.168.2.14")
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("mask: mixed validity")
- << ip
- << inputMask
- << 0 << 0 << 0
- << QString("a1b2c5")
- << QString("125.168.2.14")
- << 0 << 0 << 0
- << false << false;
-}
-
-void tst_qquicktextinput::insert()
-{
- QFETCH(QString, text);
- QFETCH(QString, inputMask);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(int, insertPosition);
- QFETCH(QString, insertText);
- QFETCH(QString, expectedText);
- QFETCH(int, expectedSelectionStart);
- QFETCH(int, expectedSelectionEnd);
- QFETCH(int, expectedCursorPosition);
- QFETCH(bool, selectionChanged);
- QFETCH(bool, cursorPositionChanged);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- textInput->select(selectionStart, selectionEnd);
-
- QSignalSpy selectionSpy(textInput, SIGNAL(selectedTextChanged()));
- QSignalSpy selectionStartSpy(textInput, SIGNAL(selectionStartChanged()));
- QSignalSpy selectionEndSpy(textInput, SIGNAL(selectionEndChanged()));
- QSignalSpy textSpy(textInput, SIGNAL(textChanged()));
- QSignalSpy cursorPositionSpy(textInput, SIGNAL(cursorPositionChanged()));
-
- textInput->insert(insertPosition, insertText);
-
- QCOMPARE(textInput->text(), expectedText);
- QCOMPARE(textInput->length(), inputMask.isEmpty() ? expectedText.length() : inputMask.length());
-
- QCOMPARE(textInput->selectionStart(), expectedSelectionStart);
- QCOMPARE(textInput->selectionEnd(), expectedSelectionEnd);
- QCOMPARE(textInput->cursorPosition(), expectedCursorPosition);
-
- if (selectionStart > selectionEnd)
- qSwap(selectionStart, selectionEnd);
-
- QCOMPARE(selectionSpy.count() > 0, selectionChanged);
- QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
- QCOMPARE(textSpy.count() > 0, text != expectedText);
- QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
-}
-
-void tst_qquicktextinput::remove_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QString>("inputMask");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<int>("removeStart");
- QTest::addColumn<int>("removeEnd");
- QTest::addColumn<QString>("expectedText");
- QTest::addColumn<int>("expectedSelectionStart");
- QTest::addColumn<int>("expectedSelectionEnd");
- QTest::addColumn<int>("expectedCursorPosition");
- QTest::addColumn<bool>("selectionChanged");
- QTest::addColumn<bool>("cursorPositionChanged");
-
- QTest::newRow("from cursor position (beginning)")
- << standard.at(0)
- << QString()
- << 0 << 0
- << 0 << 5
- << standard.at(0).mid(5)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("to cursor position (beginning)")
- << standard.at(0)
- << QString()
- << 0 << 0
- << 5 << 0
- << standard.at(0).mid(5)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("to cursor position (end)")
- << standard.at(0)
- << QString()
- << standard.at(0).length() << standard.at(0).length()
- << standard.at(0).length() << standard.at(0).length() - 5
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
- << false << true;
-
- QTest::newRow("to cursor position (end)")
- << standard.at(0)
- << QString()
- << standard.at(0).length() << standard.at(0).length()
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
- << false << true;
-
- QTest::newRow("from cursor position (middle)")
- << standard.at(0)
- << QString()
- << 18 << 18
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 18 << 18 << 18
- << false << false;
-
- QTest::newRow("to cursor position (middle)")
- << standard.at(0)
- << QString()
- << 23 << 23
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 18 << 18 << 18
- << false << true;
-
- QTest::newRow("after cursor position (beginning)")
- << standard.at(0)
- << QString()
- << 0 << 0
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("before cursor position (end)")
- << standard.at(0)
- << QString()
- << standard.at(0).length() << standard.at(0).length()
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
- << false << true;
-
- QTest::newRow("before cursor position (middle)")
- << standard.at(0)
- << QString()
- << 23 << 23
- << 0 << 5
- << standard.at(0).mid(5)
- << 18 << 18 << 18
- << false << true;
-
- QTest::newRow("after cursor position (middle)")
- << standard.at(0)
- << QString()
- << 18 << 18
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 18 << 18 << 18
- << false << false;
-
- QTest::newRow("before selection")
- << standard.at(0)
- << QString()
- << 14 << 19
- << 0 << 5
- << standard.at(0).mid(5)
- << 9 << 14 << 14
- << false << true;
-
- QTest::newRow("before reversed selection")
- << standard.at(0)
- << QString()
- << 19 << 14
- << 0 << 5
- << standard.at(0).mid(5)
- << 9 << 14 << 9
- << false << true;
-
- QTest::newRow("after selection")
- << standard.at(0)
- << QString()
- << 14 << 19
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << 14 << 19 << 19
- << false << false;
-
- QTest::newRow("after reversed selection")
- << standard.at(0)
- << QString()
- << 19 << 14
- << standard.at(0).length() - 5 << standard.at(0).length()
- << standard.at(0).mid(0, standard.at(0).length() - 5)
- << 14 << 19 << 14
- << false << false;
-
- QTest::newRow("from selection")
- << standard.at(0)
- << QString()
- << 14 << 24
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 14 << 19 << 19
- << true << true;
-
- QTest::newRow("from reversed selection")
- << standard.at(0)
- << QString()
- << 24 << 14
- << 18 << 23
- << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
- << 14 << 19 << 14
- << true << false;
-
- QTest::newRow("cropped beginning")
- << standard.at(0)
- << QString()
- << 0 << 0
- << -3 << 4
- << standard.at(0).mid(4)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("cropped end")
- << standard.at(0)
- << QString()
- << 0 << 0
- << 23 << standard.at(0).length() + 8
- << standard.at(0).mid(0, 23)
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("cropped beginning and end")
- << standard.at(0)
- << QString()
- << 0 << 0
- << -9 << standard.at(0).length() + 4
- << QString()
- << 0 << 0 << 0
- << false << false;
-
- const QString inputMask = "009.009.009.009";
- const QString ip = "192.168.2.14";
-
- QTest::newRow("mask: from cursor position")
- << ip
- << inputMask
- << 6 << 6
- << 6 << 9
- << QString("192.16..14")
- << 6 << 6 << 6
- << false << false;
-
- QTest::newRow("mask: to cursor position")
- << ip
- << inputMask
- << 6 << 6
- << 2 << 6
- << QString("19.8.2.14")
- << 6 << 6 << 6
- << false << false;
-
- QTest::newRow("mask: before cursor position")
- << ip
- << inputMask
- << 6 << 6
- << 0 << 2
- << QString("2.168.2.14")
- << 6 << 6 << 6
- << false << false;
-
- QTest::newRow("mask: after cursor position")
- << ip
- << inputMask
- << 6 << 6
- << 12 << 16
- << QString("192.168.2.")
- << 6 << 6 << 6
- << false << false;
-
- QTest::newRow("mask: before selection")
- << ip
- << inputMask
- << 6 << 8
- << 0 << 2
- << QString("2.168.2.14")
- << 6 << 8 << 8
- << false << false;
-
- QTest::newRow("mask: before reversed selection")
- << ip
- << inputMask
- << 8 << 6
- << 0 << 2
- << QString("2.168.2.14")
- << 6 << 8 << 6
- << false << false;
-
- QTest::newRow("mask: after selection")
- << ip
- << inputMask
- << 6 << 8
- << 12 << 16
- << QString("192.168.2.")
- << 6 << 8 << 8
- << false << false;
-
- QTest::newRow("mask: after reversed selection")
- << ip
- << inputMask
- << 8 << 6
- << 12 << 16
- << QString("192.168.2.")
- << 6 << 8 << 6
- << false << false;
-
- QTest::newRow("mask: from selection")
- << ip
- << inputMask
- << 6 << 13
- << 8 << 10
- << QString("192.168..14")
- << 6 << 13 << 13
- << true << false;
-
- QTest::newRow("mask: from reversed selection")
- << ip
- << inputMask
- << 13 << 6
- << 8 << 10
- << QString("192.168..14")
- << 6 << 13 << 6
- << true << false;
-
- QTest::newRow("mask: cropped beginning")
- << ip
- << inputMask
- << 0 << 0
- << -3 << 4
- << QString(".168.2.14")
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("mask: cropped end")
- << ip
- << inputMask
- << 0 << 0
- << 13 << 28
- << QString("192.168.2.1")
- << 0 << 0 << 0
- << false << false;
-
- QTest::newRow("mask: cropped beginning and end")
- << ip
- << inputMask
- << 0 << 0
- << -9 << 28
- << QString("...")
- << 0 << 0 << 0
- << false << false;
-}
-
-void tst_qquicktextinput::remove()
-{
- QFETCH(QString, text);
- QFETCH(QString, inputMask);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(int, removeStart);
- QFETCH(int, removeEnd);
- QFETCH(QString, expectedText);
- QFETCH(int, expectedSelectionStart);
- QFETCH(int, expectedSelectionEnd);
- QFETCH(int, expectedCursorPosition);
- QFETCH(bool, selectionChanged);
- QFETCH(bool, cursorPositionChanged);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- textInput->select(selectionStart, selectionEnd);
-
- QSignalSpy selectionSpy(textInput, SIGNAL(selectedTextChanged()));
- QSignalSpy selectionStartSpy(textInput, SIGNAL(selectionStartChanged()));
- QSignalSpy selectionEndSpy(textInput, SIGNAL(selectionEndChanged()));
- QSignalSpy textSpy(textInput, SIGNAL(textChanged()));
- QSignalSpy cursorPositionSpy(textInput, SIGNAL(cursorPositionChanged()));
-
- textInput->remove(removeStart, removeEnd);
-
- QCOMPARE(textInput->text(), expectedText);
- QCOMPARE(textInput->length(), inputMask.isEmpty() ? expectedText.length() : inputMask.length());
-
- if (selectionStart > selectionEnd) //
- qSwap(selectionStart, selectionEnd);
-
- QCOMPARE(textInput->selectionStart(), expectedSelectionStart);
- QCOMPARE(textInput->selectionEnd(), expectedSelectionEnd);
- QCOMPARE(textInput->cursorPosition(), expectedCursorPosition);
-
- QCOMPARE(selectionSpy.count() > 0, selectionChanged);
- QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
- QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
- QCOMPARE(textSpy.count() > 0, text != expectedText);
-
- if (cursorPositionChanged) //
- QVERIFY(cursorPositionSpy.count() > 0);
-}
-
-void tst_qquicktextinput::keySequence_data()
-{
- QTest::addColumn<QString>("text");
- QTest::addColumn<QKeySequence>("sequence");
- QTest::addColumn<int>("selectionStart");
- QTest::addColumn<int>("selectionEnd");
- QTest::addColumn<int>("cursorPosition");
- QTest::addColumn<QString>("expectedText");
- QTest::addColumn<QString>("selectedText");
-
- // standard[0] == "the [4]quick [10]brown [16]fox [20]jumped [27]over [32]the [36]lazy [41]dog"
-
- QTest::newRow("select all")
- << standard.at(0) << QKeySequence(QKeySequence::SelectAll) << 0 << 0
- << 44 << standard.at(0) << standard.at(0);
- QTest::newRow("select end of line")
- << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfLine) << 5 << 5
- << 44 << standard.at(0) << standard.at(0).mid(5);
- QTest::newRow("select end of document") // ### Not handled.
- << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfDocument) << 3 << 3
- << 3 << standard.at(0) << QString();
- QTest::newRow("select end of block")
- << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfBlock) << 18 << 18
- << 44 << standard.at(0) << standard.at(0).mid(18);
- QTest::newRow("delete end of line")
- << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfLine) << 24 << 24
- << 24 << standard.at(0).mid(0, 24) << QString();
- QTest::newRow("move to start of line")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfLine) << 31 << 31
- << 0 << standard.at(0) << QString();
- QTest::newRow("move to start of block")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfBlock) << 25 << 25
- << 0 << standard.at(0) << QString();
- QTest::newRow("move to next char")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToNextChar) << 12 << 12
- << 13 << standard.at(0) << QString();
- QTest::newRow("move to previous char")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 3
- << 2 << standard.at(0) << QString();
- QTest::newRow("select next char")
- << standard.at(0) << QKeySequence(QKeySequence::SelectNextChar) << 23 << 23
- << 24 << standard.at(0) << standard.at(0).mid(23, 1);
- QTest::newRow("select previous char")
- << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousChar) << 19 << 19
- << 18 << standard.at(0) << standard.at(0).mid(18, 1);
- QTest::newRow("move to next word")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7
- << 10 << standard.at(0) << QString();
- QTest::newRow("move to previous word")
- << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7
- << 4 << standard.at(0) << QString();
- QTest::newRow("select previous word")
- << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousWord) << 11 << 11
- << 10 << standard.at(0) << standard.at(0).mid(10, 1);
- QTest::newRow("delete (selection)")
- << standard.at(0) << QKeySequence(QKeySequence::Delete) << 12 << 15
- << 12 << (standard.at(0).mid(0, 12) + standard.at(0).mid(15)) << QString();
- QTest::newRow("delete (no selection)")
- << standard.at(0) << QKeySequence(QKeySequence::Delete) << 15 << 15
- << 15 << (standard.at(0).mid(0, 15) + standard.at(0).mid(16)) << QString();
- QTest::newRow("delete end of word")
- << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfWord) << 24 << 24
- << 24 << (standard.at(0).mid(0, 24) + standard.at(0).mid(27)) << QString();
- QTest::newRow("delete start of word")
- << standard.at(0) << QKeySequence(QKeySequence::DeleteStartOfWord) << 7 << 7
- << 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString();
-}
-
-void tst_qquicktextinput::keySequence()
-{
- QFETCH(QString, text);
- QFETCH(QKeySequence, sequence);
- QFETCH(int, selectionStart);
- QFETCH(int, selectionEnd);
- QFETCH(int, cursorPosition);
- QFETCH(QString, expectedText);
- QFETCH(QString, selectedText);
-
- if (sequence.isEmpty()) {
- QSKIP("Key sequence is undefined");
- }
-
- QString componentStr = "import QtQuick 2.0\nTextInput { focus: true; text: \"" + text + "\" }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- QQuickCanvas canvas;
- textInput->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- textInput->select(selectionStart, selectionEnd);
-
- simulateKeys(&canvas, sequence);
-
- QCOMPARE(textInput->cursorPosition(), cursorPosition);
- QCOMPARE(textInput->text(), expectedText);
- QCOMPARE(textInput->selectedText(), selectedText);
-}
-
-#define NORMAL 0
-#define REPLACE_UNTIL_END 1
-
-void tst_qquicktextinput::undo_data()
-{
- QTest::addColumn<QStringList>("insertString");
- QTest::addColumn<IntList>("insertIndex");
- QTest::addColumn<IntList>("insertMode");
- QTest::addColumn<QStringList>("expectedString");
- QTest::addColumn<bool>("use_keys");
-
- for (int i=0; i<2; i++) {
- QString keys_str = "keyboard";
- bool use_keys = true;
- if (i==0) {
- keys_str = "insert";
- use_keys = false;
- }
-
- {
- IntList insertIndex;
- IntList insertMode;
- QStringList insertString;
- QStringList expectedString;
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << "1";
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << "5";
-
- insertIndex << 1;
- insertMode << NORMAL;
- insertString << "3";
-
- insertIndex << 1;
- insertMode << NORMAL;
- insertString << "2";
-
- insertIndex << 3;
- insertMode << NORMAL;
- insertString << "4";
-
- expectedString << "12345";
- expectedString << "1235";
- expectedString << "135";
- expectedString << "15";
- expectedString << "";
-
- QTest::newRow(QString(keys_str + "_numbers").toLatin1()) <<
- insertString <<
- insertIndex <<
- insertMode <<
- expectedString <<
- bool(use_keys);
- }
- {
- IntList insertIndex;
- IntList insertMode;
- QStringList insertString;
- QStringList expectedString;
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << "World"; // World
-
- insertIndex << 0;
- insertMode << NORMAL;
- insertString << "Hello"; // HelloWorld
-
- insertIndex << 0;
- insertMode << NORMAL;
- insertString << "Well"; // WellHelloWorld
-
- insertIndex << 9;
- insertMode << NORMAL;
- insertString << "There"; // WellHelloThereWorld;
-
- expectedString << "WellHelloThereWorld";
- expectedString << "WellHelloWorld";
- expectedString << "HelloWorld";
- expectedString << "World";
- expectedString << "";
-
- QTest::newRow(QString(keys_str + "_helloworld").toLatin1()) <<
- insertString <<
- insertIndex <<
- insertMode <<
- expectedString <<
- bool(use_keys);
- }
- {
- IntList insertIndex;
- IntList insertMode;
- QStringList insertString;
- QStringList expectedString;
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << "Ensuring";
-
- insertIndex << -1;
- insertMode << NORMAL;
- insertString << " instan";
-
- insertIndex << 9;
- insertMode << NORMAL;
- insertString << "an ";
-
- insertIndex << 10;
- insertMode << REPLACE_UNTIL_END;
- insertString << " unique instance.";
-
- expectedString << "Ensuring a unique instance.";
- expectedString << "Ensuring an instan";
- expectedString << "Ensuring instan";
- expectedString << "";
-
- QTest::newRow(QString(keys_str + "_patterns").toLatin1()) <<
- insertString <<
- insertIndex <<
- insertMode <<
- expectedString <<
- bool(use_keys);
- }
- }
-}
-
-void tst_qquicktextinput::undo()
-{
- QFETCH(QStringList, insertString);
- QFETCH(IntList, insertIndex);
- QFETCH(IntList, insertMode);
- QFETCH(QStringList, expectedString);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- QQuickCanvas canvas;
- textInput->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- QVERIFY(!textInput->canUndo());
-
- QSignalSpy spy(textInput, SIGNAL(canUndoChanged()));
-
- int i;
-
-// STEP 1: First build up an undo history by inserting or typing some strings...
- for (i = 0; i < insertString.size(); ++i) {
- if (insertIndex[i] > -1)
- textInput->setCursorPosition(insertIndex[i]);
-
- // experimental stuff
- if (insertMode[i] == REPLACE_UNTIL_END) {
- textInput->select(insertIndex[i], insertIndex[i] + 8);
-
- // This is what I actually want...
- // QTest::keyClick(testWidget, Qt::Key_End, Qt::ShiftModifier);
- }
-
- for (int j = 0; j < insertString.at(i).length(); j++)
- QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1());
- }
-
- QCOMPARE(spy.count(), 1);
-
-// STEP 2: Next call undo several times and see if we can restore to the previous state
- for (i = 0; i < expectedString.size() - 1; ++i) {
- QCOMPARE(textInput->text(), expectedString[i]);
- QVERIFY(textInput->canUndo());
- textInput->undo();
- }
-
-// STEP 3: Verify that we have undone everything
- QVERIFY(textInput->text().isEmpty());
- QVERIFY(!textInput->canUndo());
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktextinput::redo_data()
-{
- QTest::addColumn<QStringList>("insertString");
- QTest::addColumn<IntList>("insertIndex");
- QTest::addColumn<QStringList>("expectedString");
-
- {
- IntList insertIndex;
- QStringList insertString;
- QStringList expectedString;
-
- insertIndex << -1;
- insertString << "World"; // World
- insertIndex << 0;
- insertString << "Hello"; // HelloWorld
- insertIndex << 0;
- insertString << "Well"; // WellHelloWorld
- insertIndex << 9;
- insertString << "There"; // WellHelloThereWorld;
-
- expectedString << "World";
- expectedString << "HelloWorld";
- expectedString << "WellHelloWorld";
- expectedString << "WellHelloThereWorld";
-
- QTest::newRow("Inserts and setting cursor") << insertString << insertIndex << expectedString;
- }
-}
-
-void tst_qquicktextinput::redo()
-{
- QFETCH(QStringList, insertString);
- QFETCH(IntList, insertIndex);
- QFETCH(QStringList, expectedString);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- QQuickCanvas canvas;
- textInput->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- QVERIFY(!textInput->canUndo());
- QVERIFY(!textInput->canRedo());
-
- QSignalSpy spy(textInput, SIGNAL(canRedoChanged()));
-
- int i;
- // inserts the diff strings at diff positions
- for (i = 0; i < insertString.size(); ++i) {
- if (insertIndex[i] > -1)
- textInput->setCursorPosition(insertIndex[i]);
- for (int j = 0; j < insertString.at(i).length(); j++)
- QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1());
- QVERIFY(textInput->canUndo());
- QVERIFY(!textInput->canRedo());
- }
-
- QCOMPARE(spy.count(), 0);
-
- // undo everything
- while (!textInput->text().isEmpty()) {
- QVERIFY(textInput->canUndo());
- textInput->undo();
- QVERIFY(textInput->canRedo());
- }
-
- QCOMPARE(spy.count(), 1);
-
- for (i = 0; i < expectedString.size(); ++i) {
- QVERIFY(textInput->canRedo());
- textInput->redo();
- QCOMPARE(textInput->text() , expectedString[i]);
- QVERIFY(textInput->canUndo());
- }
- QVERIFY(!textInput->canRedo());
- QCOMPARE(spy.count(), 2);
-}
-
-void tst_qquicktextinput::undo_keypressevents_data()
-{
- QTest::addColumn<KeyList>("keys");
- QTest::addColumn<QStringList>("expectedString");
-
- {
- KeyList keys;
- QStringList expectedString;
-
- keys << "AFRAID"
- << QKeySequence::MoveToStartOfLine
- << "VERY"
- << Qt::Key_Left
- << Qt::Key_Left
- << Qt::Key_Left
- << Qt::Key_Left
- << "BE"
- << QKeySequence::MoveToEndOfLine
- << "!";
-
- expectedString << "BEVERYAFRAID!";
- expectedString << "BEVERYAFRAID";
- expectedString << "VERYAFRAID";
- expectedString << "AFRAID";
-
- QTest::newRow("Inserts and moving cursor") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting '1234'
- keys << "1234" << QKeySequence::MoveToStartOfLine
- // skipping '12'
- << Qt::Key_Right << Qt::Key_Right
- // selecting '34'
- << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
- // deleting '34'
- << Qt::Key_Delete;
-
- expectedString << "12";
- expectedString << "1234";
-
- QTest::newRow("Inserts,moving,selection and delete") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting 'AB12'
- keys << "AB12"
- << QKeySequence::MoveToStartOfLine
- // selecting 'AB'
- << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
- << Qt::Key_Delete
- << QKeySequence::Undo
- << Qt::Key_Right
-#ifdef Q_OS_WIN //Mac(?) has a specialcase to handle jumping to the end of a selection
- << Qt::Key_Left
-#endif
- << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
- << Qt::Key_Delete;
-
- expectedString << "AB";
- expectedString << "AB12";
-
- QTest::newRow("Inserts,moving,selection, delete and undo") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting 'ABCD'
- keys << "abcd"
- //move left two
- << Qt::Key_Left << Qt::Key_Left
- // inserting '1234'
- << "1234"
- // selecting '1234'
- << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier)
- // overwriting '1234' with '5'
- << "5"
- // undoing deletion of 'AB'
- << QKeySequence::Undo
- // overwriting '1234' with '6'
- << "6";
-
- expectedString << "ab6cd";
- // for versions previous to 3.2 we overwrite needed two undo operations
- expectedString << "ab1234cd";
- expectedString << "abcd";
-
- QTest::newRow("Inserts,moving,selection and undo, removing selection") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting 'ABC'
- keys << "ABC"
- // removes 'C'
- << Qt::Key_Backspace;
-
- expectedString << "AB";
- expectedString << "ABC";
-
- QTest::newRow("Inserts,backspace") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- keys << "ABC"
- // removes 'C'
- << Qt::Key_Backspace
- // inserting 'Z'
- << "Z";
-
- expectedString << "ABZ";
- expectedString << "AB";
- expectedString << "ABC";
-
- QTest::newRow("Inserts,backspace,inserts") << keys << expectedString;
- } {
- KeyList keys;
- QStringList expectedString;
-
- // inserting '123'
- keys << "123" << QKeySequence::MoveToStartOfLine
- // selecting '123'
- << QKeySequence::SelectEndOfLine
- // overwriting '123' with 'ABC'
- << "ABC";
-
- expectedString << "ABC";
- // for versions previous to 3.2 we overwrite needed two undo operations
- expectedString << "123";
-
- QTest::newRow("Inserts,moving,selection and overwriting") << keys << expectedString;
- }
-}
-
-void tst_qquicktextinput::undo_keypressevents()
-{
- QFETCH(KeyList, keys);
- QFETCH(QStringList, expectedString);
-
- QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }";
- QDeclarativeComponent textInputComponent(&engine);
- textInputComponent.setData(componentStr.toLatin1(), QUrl());
- QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
- QVERIFY(textInput != 0);
-
- QQuickCanvas canvas;
- textInput->setParentItem(canvas.rootItem());
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
-
- simulateKeys(&canvas, keys);
-
- for (int i = 0; i < expectedString.size(); ++i) {
- QCOMPARE(textInput->text() , expectedString[i]);
- textInput->undo();
- }
- QVERIFY(textInput->text().isEmpty());
-}
-
-void tst_qquicktextinput::QTBUG_19956()
-{
- QFETCH(QString, url);
-
- QQuickView canvas(testFileUrl(url));
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextInput *input = qobject_cast<QQuickTextInput*>(canvas.rootObject());
- QVERIFY(input);
- input->setFocus(true);
- QVERIFY(input->hasActiveFocus());
-
- QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 30);
- QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 10);
- QCOMPARE(canvas.rootObject()->property("text").toString(), QString("20"));
- QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
-
- canvas.rootObject()->setProperty("topvalue", 15);
- QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 15);
- QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool());
-
- canvas.rootObject()->setProperty("topvalue", 25);
- QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 25);
- QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
-
- canvas.rootObject()->setProperty("bottomvalue", 21);
- QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 21);
- QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool());
-
- canvas.rootObject()->setProperty("bottomvalue", 10);
- QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 10);
- QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
-}
-
-void tst_qquicktextinput::QTBUG_19956_regexp()
-{
- QUrl url = testFileUrl("qtbug-19956regexp.qml");
-
- QString warning = url.toString() + ":11: Unable to assign [undefined] to QRegExp";
- QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
-
- QQuickView canvas(url);
- canvas.show();
- canvas.requestActivateWindow();
- QTest::qWaitForWindowShown(&canvas);
- QVERIFY(canvas.rootObject() != 0);
- QQuickTextInput *input = qobject_cast<QQuickTextInput*>(canvas.rootObject());
- QVERIFY(input);
- input->setFocus(true);
- QVERIFY(input->hasActiveFocus());
-
- canvas.rootObject()->setProperty("regexvalue", QRegExp("abc"));
- QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abc"));
- QCOMPARE(canvas.rootObject()->property("text").toString(), QString("abc"));
- QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
-
- canvas.rootObject()->setProperty("regexvalue", QRegExp("abcd"));
- QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abcd"));
- QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool());
-
- canvas.rootObject()->setProperty("regexvalue", QRegExp("abc"));
- QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abc"));
- QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
-}
-
-
-void tst_qquicktextinput::negativeDimensions()
-{
- // Verify this doesn't assert during initialization.
- QDeclarativeComponent component(&engine, testFileUrl("negativeDimensions.qml"));
- QScopedPointer<QObject> o(component.create());
- QVERIFY(o);
- QQuickTextInput *input = o->findChild<QQuickTextInput *>("input");
- QVERIFY(input);
- QCOMPARE(input->width(), qreal(-1));
- QCOMPARE(input->height(), qreal(-1));
-}
-
-QTEST_MAIN(tst_qquicktextinput)
-
-#include "tst_qquicktextinput.moc"
diff --git a/tests/auto/qtquick2/qquickview/qquickview.pro b/tests/auto/qtquick2/qquickview/qquickview.pro
deleted file mode 100644
index c3bc0ddcaf..0000000000
--- a/tests/auto/qtquick2/qquickview/qquickview.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickview
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickview.cpp
-
-include (../../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-QT += core-private gui-private declarative-private quick-private testlib
diff --git a/tests/auto/qtquick2/qquickview/tst_qquickview.cpp b/tests/auto/qtquick2/qquickview/tst_qquickview.cpp
deleted file mode 100644
index fe290456eb..0000000000
--- a/tests/auto/qtquick2/qquickview/tst_qquickview.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtQuick/qquickview.h>
-#include <QtQuick/qquickitem.h>
-#include "../../shared/util.h"
-#include <QtGui/QWindow>
-#include <QtCore/QDebug>
-
-class tst_QQuickView : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_QQuickView();
-
-private slots:
- void resizemodeitem();
- void errors();
-};
-
-
-tst_QQuickView::tst_QQuickView()
-{
-}
-
-void tst_QQuickView::resizemodeitem()
-{
- QWindow window;
- window.setGeometry(0, 0, 400, 400);
-
- QQuickView *canvas = new QQuickView(&window);
- QVERIFY(canvas);
- canvas->setResizeMode(QQuickView::SizeRootObjectToView);
- QCOMPARE(QSize(0,0), canvas->initialSize());
- canvas->setSource(testFileUrl("resizemodeitem.qml"));
- QQuickItem* item = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(item);
- window.show();
-
- canvas->show();
-
- // initial size from root object
- QCOMPARE(item->width(), 200.0);
- QCOMPARE(item->height(), 200.0);
- QCOMPARE(canvas->size(), QSize(200, 200));
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(canvas->size(), canvas->initialSize());
-
- // size update from view
- canvas->resize(QSize(80,100));
-
- QTRY_COMPARE(item->width(), 80.0);
- QCOMPARE(item->height(), 100.0);
- QCOMPARE(canvas->size(), QSize(80, 100));
- QCOMPARE(canvas->size(), canvas->sizeHint());
-
- canvas->setResizeMode(QQuickView::SizeViewToRootObject);
-
- // size update from view disabled
- canvas->resize(QSize(60,80));
- QCOMPARE(item->width(), 80.0);
- QCOMPARE(item->height(), 100.0);
- QTest::qWait(50);
- QCOMPARE(canvas->size(), QSize(60, 80));
-
- // size update from root object
- item->setWidth(250);
- item->setHeight(350);
- QCOMPARE(item->width(), 250.0);
- QCOMPARE(item->height(), 350.0);
- QTRY_COMPARE(canvas->size(), QSize(250, 350));
- QCOMPARE(canvas->size(), QSize(250, 350));
- QCOMPARE(canvas->size(), canvas->sizeHint());
-
- // reset canvas
- window.hide();
- delete canvas;
- canvas = new QQuickView(&window);
- QVERIFY(canvas);
- canvas->setResizeMode(QQuickView::SizeViewToRootObject);
- canvas->setSource(testFileUrl("resizemodeitem.qml"));
- item = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(item);
- window.show();
-
- canvas->show();
-
- // initial size for root object
- QCOMPARE(item->width(), 200.0);
- QCOMPARE(item->height(), 200.0);
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(canvas->size(), canvas->initialSize());
-
- // size update from root object
- item->setWidth(80);
- item->setHeight(100);
- QCOMPARE(item->width(), 80.0);
- QCOMPARE(item->height(), 100.0);
- QTRY_COMPARE(canvas->size(), QSize(80, 100));
- QCOMPARE(canvas->size(), QSize(80, 100));
- QCOMPARE(canvas->size(), canvas->sizeHint());
-
- // size update from root object disabled
- canvas->setResizeMode(QQuickView::SizeRootObjectToView);
- item->setWidth(60);
- item->setHeight(80);
- QCOMPARE(canvas->width(), 80);
- QCOMPARE(canvas->height(), 100);
- QCOMPARE(QSize(item->width(), item->height()), canvas->sizeHint());
-
- // size update from view
- canvas->resize(QSize(200,300));
- QTest::qWait(50);
- QCOMPARE(item->width(), 200.0);
- QCOMPARE(item->height(), 300.0);
- QCOMPARE(canvas->size(), QSize(200, 300));
- QCOMPARE(canvas->size(), canvas->sizeHint());
-
- window.hide();
- delete canvas;
-
- // if we set a specific size for the view then it should keep that size
- // for SizeRootObjectToView mode.
- canvas = new QQuickView(&window);
- canvas->resize(300, 300);
- canvas->setResizeMode(QQuickView::SizeRootObjectToView);
- QCOMPARE(QSize(0,0), canvas->initialSize());
- canvas->setSource(testFileUrl("resizemodeitem.qml"));
- canvas->resize(300, 300);
- item = qobject_cast<QQuickItem*>(canvas->rootObject());
- QVERIFY(item);
- window.show();
-
- canvas->show();
- QTest::qWait(50);
-
- // initial size from root object
- QCOMPARE(item->width(), 300.0);
- QCOMPARE(item->height(), 300.0);
- QCOMPARE(canvas->size(), QSize(300, 300));
- QCOMPARE(canvas->size(), canvas->sizeHint());
- QCOMPARE(canvas->initialSize(), QSize(200, 200)); // initial object size
-
- delete canvas;
-}
-
-static void silentErrorsMsgHandler(QtMsgType, const char *)
-{
-}
-
-void tst_QQuickView::errors()
-{
- QQuickView *canvas = new QQuickView;
- QVERIFY(canvas);
- QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler);
- canvas->setSource(testFileUrl("error1.qml"));
- qInstallMsgHandler(old);
- QVERIFY(canvas->status() == QQuickView::Error);
- QVERIFY(canvas->errors().count() == 1);
- delete canvas;
-}
-
-
-QTEST_MAIN(tst_QQuickView)
-
-#include "tst_qquickview.moc"
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/qquickvisualdatamodel.pro b/tests/auto/qtquick2/qquickvisualdatamodel/qquickvisualdatamodel.pro
deleted file mode 100644
index 6db887d747..0000000000
--- a/tests/auto/qtquick2/qquickvisualdatamodel/qquickvisualdatamodel.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qquickvisualdatamodel
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qquickvisualdatamodel.cpp
-
-include (../../shared/util.pri)
-include (../shared/util.pri)
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-CONFIG += parallel_test
-
-QT += core-private gui-private v8-private declarative-private quick-private widgets testlib
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/qtquick2/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
deleted file mode 100644
index 1b6a7629d9..0000000000
--- a/tests/auto/qtquick2/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
+++ /dev/null
@@ -1,3446 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "../../shared/util.h"
-#include "../shared/visualtestutil.h"
-
-#include <qtest.h>
-#include <QtTest/QSignalSpy>
-#include <QStandardItemModel>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativecontext.h>
-#include <QtDeclarative/qdeclarativeexpression.h>
-#include <QtQuick/qquickview.h>
-#include <private/qquicklistview_p.h>
-#include <QtQuick/private/qquicktext_p.h>
-#include <QtQuick/private/qquickvisualdatamodel_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include <private/qdeclarativechangeset_p.h>
-#include <private/qdeclarativeengine_p.h>
-#include <math.h>
-
-using namespace QQuickVisualTestUtil;
-
-template <typename T, int N> int lengthOf(const T (&)[N]) { return N; }
-
-static void initStandardTreeModel(QStandardItemModel *model)
-{
- QStandardItem *item;
- item = new QStandardItem(QLatin1String("Row 1 Item"));
- model->insertRow(0, item);
-
- item = new QStandardItem(QLatin1String("Row 2 Item"));
- item->setCheckable(true);
- model->insertRow(1, item);
-
- QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item"));
- item->setChild(0, childItem);
-
- item = new QStandardItem(QLatin1String("Row 3 Item"));
- item->setIcon(QIcon());
- model->insertRow(2, item);
-}
-
-class SingleRoleModel : public QAbstractListModel
-{
- Q_OBJECT
- Q_PROPERTY(QStringList values WRITE setList)
-public:
- SingleRoleModel(const QByteArray &role = "name", QObject *parent = 0)
- : QAbstractListModel(parent)
- {
- QHash<int, QByteArray> roles;
- roles.insert(Qt::DisplayRole , role);
- setRoleNames(roles);
- list << "one" << "two" << "three" << "four";
- }
-
- void emitMove(int sourceFirst, int sourceLast, int destinationChild) {
- emit beginMoveRows(QModelIndex(), sourceFirst, sourceLast, QModelIndex(), destinationChild);
- emit endMoveRows();
- }
-
- QStringList list;
-
- void setList(const QStringList &l) { list = l; }
-
-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();
- }
-};
-
-class StandardItem : public QObject, public QStandardItem
-{
- Q_OBJECT
- Q_PROPERTY(QString text WRITE setText)
-
-public:
- void writeText(const QString &text) { setText(text); }
-};
-
-class StandardItemModel : public QStandardItemModel
-{
- Q_OBJECT
- Q_PROPERTY(QDeclarativeListProperty<StandardItem> items READ items CONSTANT)
- Q_CLASSINFO("DefaultProperty", "items")
-public:
- QDeclarativeListProperty<StandardItem> items() { return QDeclarativeListProperty<StandardItem>(this, 0, append); }
-
- static void append(QDeclarativeListProperty<StandardItem> *property, StandardItem *item)
- {
- static_cast<QStandardItemModel *>(property->object)->appendRow(item);
- }
-};
-
-class DataObject : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
- Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
-
-public:
- DataObject(QObject *parent=0) : QObject(parent) {}
- DataObject(const QString &name, const QString &color, QObject *parent=0)
- : QObject(parent), m_name(name), m_color(color) { }
-
-
- QString name() const { return m_name; }
- void setName(const QString &name) {
- if (name != m_name) {
- m_name = name;
- emit nameChanged();
- }
- }
-
- QString color() const { return m_color; }
- void setColor(const QString &color) {
- if (color != m_color) {
- m_color = color;
- emit colorChanged();
- }
- }
-
-signals:
- void nameChanged();
- void colorChanged();
-
-private:
- QString m_name;
- QString m_color;
-};
-
-QML_DECLARE_TYPE(SingleRoleModel)
-QML_DECLARE_TYPE(StandardItem)
-QML_DECLARE_TYPE(StandardItemModel)
-QML_DECLARE_TYPE(DataObject)
-
-class tst_qquickvisualdatamodel : public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_qquickvisualdatamodel();
-
-private slots:
- void initTestCase();
- void cleanupTestCase();
- void rootIndex();
- void updateLayout_data();
- void updateLayout();
- void childChanged_data();
- void childChanged();
- void objectListModel();
- void singleRole();
- void modelProperties();
- void noDelegate_data();
- void noDelegate();
- void itemsDestroyed_data();
- void itemsDestroyed();
- void packagesDestroyed();
- void qaimRowsMoved();
- void qaimRowsMoved_data();
- void remove_data();
- void remove();
- void move_data();
- void move();
- void groups_data();
- void groups();
- void invalidGroups();
- void get();
- void onChanged_data();
- void onChanged();
- void create();
- void incompleteModel();
- void insert_data();
- void insert();
- void resolve_data();
- void resolve();
- void warnings_data();
- void warnings();
-
-private:
- template <int N> void groups_verify(
- const SingleRoleModel &model,
- QQuickItem *contentItem,
- const int (&mIndex)[N],
- const int (&iIndex)[N],
- const int (&vIndex)[N],
- const int (&sIndex)[N],
- const bool (&vMember)[N],
- const bool (&sMember)[N]);
-
- template <int N> void get_verify(
- const SingleRoleModel &model,
- QQuickVisualDataModel *visualModel,
- QQuickVisualDataGroup *visibleItems,
- QQuickVisualDataGroup *selectedItems,
- const int (&mIndex)[N],
- const int (&iIndex)[N],
- const int (&vIndex)[N],
- const int (&sIndex)[N],
- const bool (&vMember)[N],
- const bool (&sMember)[N]);
-
- bool failed;
- QDeclarativeEngine engine;
-};
-
-Q_DECLARE_METATYPE(QDeclarativeChangeSet)
-
-template <typename T> static T evaluate(QObject *scope, const QString &expression)
-{
- QDeclarativeExpression expr(qmlContext(scope), scope, expression);
- T result = expr.evaluate().value<T>();
- if (expr.hasError())
- qWarning() << expr.error().toString();
- return result;
-}
-
-template <> void evaluate<void>(QObject *scope, const QString &expression)
-{
- QDeclarativeExpression expr(qmlContext(scope), scope, expression);
- expr.evaluate();
- if (expr.hasError())
- qWarning() << expr.error().toString();
-}
-
-void tst_qquickvisualdatamodel::initTestCase()
-{
- QDeclarativeDataTest::initTestCase();
- qRegisterMetaType<QDeclarativeChangeSet>();
-
- qmlRegisterType<SingleRoleModel>("tst_qquickvisualdatamodel", 1, 0, "SingleRoleModel");
- qmlRegisterType<StandardItem>("tst_qquickvisualdatamodel", 1, 0, "StandardItem");
- qmlRegisterType<StandardItemModel>("tst_qquickvisualdatamodel", 1, 0, "StandardItemModel");
- qmlRegisterType<DataObject>("tst_qquickvisualdatamodel", 1, 0, "DataObject");
-}
-
-void tst_qquickvisualdatamodel::cleanupTestCase()
-{
-
-}
-
-tst_qquickvisualdatamodel::tst_qquickvisualdatamodel()
-{
-}
-
-void tst_qquickvisualdatamodel::rootIndex()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("visualdatamodel.qml"));
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
-
- engine.rootContext()->setContextProperty("myModel", &model);
-
- QQuickVisualDataModel *obj = qobject_cast<QQuickVisualDataModel*>(c.create());
- QVERIFY(obj != 0);
-
- QMetaObject::invokeMethod(obj, "setRoot");
- QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == model.index(0,0));
-
- QMetaObject::invokeMethod(obj, "setRootToParent");
- QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex());
-
- QMetaObject::invokeMethod(obj, "setRoot");
- QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == model.index(0,0));
- model.clear(); // will emit modelReset()
- QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex());
-
- delete obj;
-}
-
-void tst_qquickvisualdatamodel::updateLayout_data()
-{
- QTest::addColumn<QUrl>("source");
-
- QTest::newRow("item delegate") << testFileUrl("datalist.qml");
- QTest::newRow("package delegate") << testFileUrl("datalist-package.qml");
-}
-
-void tst_qquickvisualdatamodel::updateLayout()
-{
- QFETCH(QUrl, source);
-
- QQuickView view;
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
-
- view.rootContext()->setContextProperty("myModel", &model);
-
- view.setSource(source);
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "display", 0);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 1 Item"));
- name = findItem<QQuickText>(contentItem, "display", 1);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 2 Item"));
- name = findItem<QQuickText>(contentItem, "display", 2);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 3 Item"));
-
- model.invisibleRootItem()->sortChildren(0, Qt::DescendingOrder);
-
- name = findItem<QQuickText>(contentItem, "display", 0);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 3 Item"));
- name = findItem<QQuickText>(contentItem, "display", 1);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 2 Item"));
- name = findItem<QQuickText>(contentItem, "display", 2);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 1 Item"));
-}
-
-void tst_qquickvisualdatamodel::childChanged_data()
-{
- QTest::addColumn<QUrl>("source");
-
- QTest::newRow("item delegate") << testFileUrl("datalist.qml");
- QTest::newRow("package delegate") << testFileUrl("datalist-package.qml");
-}
-
-void tst_qquickvisualdatamodel::childChanged()
-{
- QFETCH(QUrl, source);
-
- QQuickView view;
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
-
- view.rootContext()->setContextProperty("myModel", &model);
-
- view.setSource(source);
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickVisualDataModel *vdm = listview->findChild<QQuickVisualDataModel*>("visualModel");
- vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0))));
- QCOMPARE(listview->count(), 1);
-
- QQuickText *name = findItem<QQuickText>(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<QQuickText>(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")));
- QCOMPARE(listview->count(), 2);
-
- name = findItem<QQuickText>(contentItem, "display", 1);
- QVERIFY(name != 0);
- QCOMPARE(name->text(), QString("Row 2 Child Item 2"));
-
- model.item(1,0)->takeRow(1);
- name = findItem<QQuickText>(contentItem, "display", 1);
- QVERIFY(name == 0);
-
- vdm->setRootIndex(QVariant::fromValue(QModelIndex()));
- QCOMPARE(listview->count(), 3);
- name = findItem<QQuickText>(contentItem, "display", 0);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 1 Item"));
- name = findItem<QQuickText>(contentItem, "display", 1);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 2 Item"));
- name = findItem<QQuickText>(contentItem, "display", 2);
- QVERIFY(name);
- QCOMPARE(name->text(), QString("Row 3 Item"));
-}
-
-void tst_qquickvisualdatamodel::objectListModel()
-{
- QQuickView view;
-
- QList<QObject*> dataList;
- dataList.append(new DataObject("Item 1", "red"));
- dataList.append(new DataObject("Item 2", "green"));
- dataList.append(new DataObject("Item 3", "blue"));
- dataList.append(new DataObject("Item 4", "yellow"));
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
-
- view.setSource(testFileUrl("objectlist.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "name", 0);
- QCOMPARE(name->text(), QString("Item 1"));
-
- QQuickText *section = findItem<QQuickText>(contentItem, "section", 0);
- QCOMPARE(section->text(), QString("Item 1"));
-
- dataList[0]->setProperty("name", QLatin1String("Changed"));
- QCOMPARE(name->text(), QString("Changed"));
-}
-
-void tst_qquickvisualdatamodel::singleRole()
-{
- {
- QQuickView view;
-
- SingleRoleModel model;
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(testFileUrl("singlerole1.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "name", 1);
- QCOMPARE(name->text(), QString("two"));
-
- model.set(1, "Changed");
- QCOMPARE(name->text(), QString("Changed"));
- }
- {
- QQuickView view;
-
- SingleRoleModel model;
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(testFileUrl("singlerole2.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "name", 1);
- QCOMPARE(name->text(), QString("two"));
-
- model.set(1, "Changed");
- QCOMPARE(name->text(), QString("Changed"));
- }
- {
- QQuickView view;
-
- SingleRoleModel model("modelData");
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(testFileUrl("singlerole2.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickText *name = findItem<QQuickText>(contentItem, "name", 1);
- QCOMPARE(name->text(), QString("two"));
-
- model.set(1, "Changed");
- QCOMPARE(name->text(), QString("Changed"));
- }
-}
-
-void tst_qquickvisualdatamodel::modelProperties()
-{
- {
- QQuickView view;
-
- SingleRoleModel model;
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(testFileUrl("modelproperties.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 1);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(),QString("two"));
- QCOMPARE(delegate->property("test2").toString(),QString("two"));
- QCOMPARE(delegate->property("test3").toString(),QString("two"));
- QCOMPARE(delegate->property("test4").toString(),QString("two"));
- QVERIFY(!delegate->property("test9").isValid());
- QCOMPARE(delegate->property("test5").toString(),QString(""));
- QVERIFY(delegate->property("test6").value<QObject*>() != 0);
- QCOMPARE(delegate->property("test7").toInt(),1);
- QCOMPARE(delegate->property("test8").toInt(),1);
- }
-
- {
- QQuickView view;
-
- QList<QObject*> dataList;
- dataList.append(new DataObject("Item 1", "red"));
- dataList.append(new DataObject("Item 2", "green"));
- dataList.append(new DataObject("Item 3", "blue"));
- dataList.append(new DataObject("Item 4", "yellow"));
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
-
- view.setSource(testFileUrl("modelproperties.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 1);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(),QString("Item 2"));
- QCOMPARE(delegate->property("test2").toString(),QString("Item 2"));
- QVERIFY(qobject_cast<DataObject*>(delegate->property("test3").value<QObject*>()) != 0);
- QVERIFY(qobject_cast<DataObject*>(delegate->property("test4").value<QObject*>()) != 0);
- QCOMPARE(delegate->property("test5").toString(),QString("Item 2"));
- QCOMPARE(delegate->property("test9").toString(),QString("Item 2"));
- QVERIFY(delegate->property("test6").value<QObject*>() != 0);
- QCOMPARE(delegate->property("test7").toInt(),1);
- QCOMPARE(delegate->property("test8").toInt(),1);
- }
-
- {
- QQuickView view;
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
-
- view.rootContext()->setContextProperty("myModel", &model);
-
- QUrl source(testFileUrl("modelproperties2.qml"));
-
- //3 items, 3 i each
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined");
- QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined");
-
- view.setSource(source);
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 1);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(),QString("Row 2 Item"));
- QCOMPARE(delegate->property("test2").toString(),QString("Row 2 Item"));
- QVERIFY(!delegate->property("test3").isValid());
- QVERIFY(!delegate->property("test4").isValid());
- QVERIFY(!delegate->property("test5").isValid());
- QVERIFY(!delegate->property("test9").isValid());
- QVERIFY(delegate->property("test6").value<QObject*>() != 0);
- QCOMPARE(delegate->property("test7").toInt(),1);
- QCOMPARE(delegate->property("test8").toInt(),1);
- }
-
- //### should also test QStringList and QVariantList
-}
-
-void tst_qquickvisualdatamodel::noDelegate_data()
-{
- QTest::addColumn<QUrl>("source");
-
- QTest::newRow("item delegate") << testFileUrl("datalist.qml");
- QTest::newRow("package delegate") << testFileUrl("datalist-package.qml");
-}
-
-void tst_qquickvisualdatamodel::noDelegate()
-{
- QFETCH(QUrl, source);
-
- QQuickView view;
-
- QStandardItemModel model;
- initStandardTreeModel(&model);
-
- view.rootContext()->setContextProperty("myModel", &model);
-
- view.setSource(source);
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickVisualDataModel *vdm = listview->findChild<QQuickVisualDataModel*>("visualModel");
- QVERIFY(vdm != 0);
- QCOMPARE(vdm->count(), 3);
-
- vdm->setDelegate(0);
- QCOMPARE(vdm->count(), 0);
-}
-
-void tst_qquickvisualdatamodel::itemsDestroyed_data()
-{
- QTest::addColumn<QUrl>("source");
-
- QTest::newRow("listView") << testFileUrl("itemsDestroyed_listView.qml");
- QTest::newRow("package") << testFileUrl("itemsDestroyed_package.qml");
- QTest::newRow("pathView") << testFileUrl("itemsDestroyed_pathView.qml");
- QTest::newRow("repeater") << testFileUrl("itemsDestroyed_repeater.qml");
-}
-
-void tst_qquickvisualdatamodel::itemsDestroyed()
-{
- QFETCH(QUrl, source);
-
- QDeclarativeGuard<QQuickItem> delegate;
-
- {
- QQuickView view;
- QStandardItemModel model;
- initStandardTreeModel(&model);
- view.rootContext()->setContextProperty("myModel", &model);
- view.setSource(source);
-
- view.show();
- QTest::qWaitForWindowShown(&view);
-
- QVERIFY(delegate = findItem<QQuickItem>(view.rootItem(), "delegate", 1));
- }
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- QVERIFY(!delegate);
-}
-
-void tst_qquickvisualdatamodel::packagesDestroyed()
-{
- SingleRoleModel model;
- model.list.clear();
- for (int i=0; i<30; i++)
- model.list << ("item " + i);
-
- QQuickView view;
- view.rootContext()->setContextProperty("testModel", &model);
-
- QString filename(testFile("packageView.qml"));
- view.setSource(QUrl::fromLocalFile(filename));
-
- qApp->processEvents();
-
- QQuickListView *leftview = findItem<QQuickListView>(view.rootObject(), "leftList");
- QTRY_VERIFY(leftview != 0);
-
- QQuickListView *rightview = findItem<QQuickListView>(view.rootObject(), "rightList");
- QTRY_VERIFY(rightview != 0);
-
- QQuickItem *leftContent = leftview->contentItem();
- QTRY_VERIFY(leftContent != 0);
-
- QQuickItem *rightContent = rightview->contentItem();
- QTRY_VERIFY(rightContent != 0);
-
- QCOMPARE(leftview->currentIndex(), 0);
- QCOMPARE(rightview->currentIndex(), 0);
-
- rightview->setCurrentIndex(20);
- QTRY_COMPARE(rightview->contentY(), 100.0);
-
- QDeclarativeGuard<QQuickItem> left;
- QDeclarativeGuard<QQuickItem> right;
-
- QVERIFY(findItem<QQuickItem>(leftContent, "wrapper", 1));
- QVERIFY(findItem<QQuickItem>(rightContent, "wrapper", 1));
-
- QVERIFY(left = findItem<QQuickItem>(leftContent, "wrapper", 19));
- QVERIFY(right = findItem<QQuickItem>(rightContent, "wrapper", 19));
-
- rightview->setCurrentIndex(0);
- QCOMPARE(rightview->currentIndex(), 0);
-
- QTRY_COMPARE(rightview->contentY(), 0.0);
- QCoreApplication::sendPostedEvents();
-
- QVERIFY(!left);
- QVERIFY(!right);
-
- QVERIFY(left = findItem<QQuickItem>(leftContent, "wrapper", 1));
- QVERIFY(right = findItem<QQuickItem>(rightContent, "wrapper", 1));
-
- rightview->setCurrentIndex(20);
- QTRY_COMPARE(rightview->contentY(), 100.0);
-
- QVERIFY(left);
- QVERIFY(right);
-
- QVERIFY(findItem<QQuickItem>(leftContent, "wrapper", 19));
- QVERIFY(findItem<QQuickItem>(rightContent, "wrapper", 19));
-
- leftview->setCurrentIndex(20);
- QTRY_COMPARE(leftview->contentY(), 100.0);
-
- QVERIFY(!left);
- QVERIFY(!right);
-}
-
-void tst_qquickvisualdatamodel::qaimRowsMoved()
-{
- // Test parameters passed in QAIM::rowsMoved() signal are converted correctly
- // when translated and emitted as the QListModelInterface::itemsMoved() signal
- QFETCH(int, sourceFirst);
- QFETCH(int, sourceLast);
- QFETCH(int, destinationChild);
- QFETCH(int, expectFrom);
- QFETCH(int, expectTo);
- QFETCH(int, expectCount);
-
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, testFileUrl("visualdatamodel.qml"));
-
- SingleRoleModel model;
- model.list.clear();
- for (int i=0; i<30; i++)
- model.list << ("item " + i);
- engine.rootContext()->setContextProperty("myModel", &model);
-
- QQuickVisualDataModel *obj = qobject_cast<QQuickVisualDataModel*>(c.create());
- QVERIFY(obj != 0);
-
- QSignalSpy spy(obj, SIGNAL(modelUpdated(QDeclarativeChangeSet,bool)));
- model.emitMove(sourceFirst, sourceLast, destinationChild);
- QCOMPARE(spy.count(), 1);
-
- QCOMPARE(spy[0].count(), 2);
- QDeclarativeChangeSet changeSet = spy[0][0].value<QDeclarativeChangeSet>();
- QCOMPARE(changeSet.removes().count(), 1);
- QCOMPARE(changeSet.removes().at(0).index, expectFrom);
- QCOMPARE(changeSet.removes().at(0).count, expectCount);
- QCOMPARE(changeSet.inserts().count(), 1);
- QCOMPARE(changeSet.inserts().at(0).index, expectTo);
- QCOMPARE(changeSet.inserts().at(0).count, expectCount);
- QCOMPARE(changeSet.removes().at(0).moveId, changeSet.inserts().at(0).moveId);
- QCOMPARE(spy[0][1].toBool(), false);
-
- delete obj;
-}
-
-void tst_qquickvisualdatamodel::qaimRowsMoved_data()
-{
- QTest::addColumn<int>("sourceFirst");
- QTest::addColumn<int>("sourceLast");
- QTest::addColumn<int>("destinationChild");
- QTest::addColumn<int>("expectFrom");
- QTest::addColumn<int>("expectTo");
- QTest::addColumn<int>("expectCount");
-
- QTest::newRow("move 1 forward")
- << 1 << 1 << 6
- << 1 << 5 << 1;
-
- QTest::newRow("move 1 backwards")
- << 4 << 4 << 1
- << 4 << 1 << 1;
-
- QTest::newRow("move multiple forwards")
- << 0 << 2 << 13
- << 0 << 10 << 3;
-
- QTest::newRow("move multiple forwards, with same to")
- << 0 << 1 << 3
- << 0 << 1 << 2;
-
- QTest::newRow("move multiple backwards")
- << 10 << 14 << 1
- << 10 << 1 << 5;
-}
-
-void tst_qquickvisualdatamodel::remove_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<QString>("package delegate");
-
- QTest::newRow("item delegate")
- << testFileUrl("groups.qml")
- << QString();
- QTest::newRow("package")
- << testFileUrl("groups-package.qml")
- << QString("package.");
-}
-
-void tst_qquickvisualdatamodel::remove()
-{
- QQuickView view;
-
- SingleRoleModel model;
- model.list = QStringList()
- << "one"
- << "two"
- << "three"
- << "four"
- << "five"
- << "six"
- << "seven"
- << "eight"
- << "nine"
- << "ten"
- << "eleven"
- << "twelve";
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(testFileUrl("groups.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
- QVERIFY(visualModel);
-
- {
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
-
- for (int i = 0; i < lengthOf(mIndex); ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
- QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
- QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
- }
- } {
- evaluate<void>(visualModel, "items.remove(2)");
- QCOMPARE(listview->count(), 11);
- QCOMPARE(visualModel->items()->count(), 11);
- static const int mIndex[] = { 0, 1, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10 };
-
- for (int i = 0; i < lengthOf(mIndex); ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
- QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
- QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
- }
- } {
- evaluate<void>(visualModel, "items.remove(1, 4)");
- QCOMPARE(listview->count(), 7);
- QCOMPARE(visualModel->items()->count(), 7);
- static const int mIndex[] = { 0, 6, 7, 8, 9,10,11 };
- static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6 };
-
- for (int i = 0; i < lengthOf(mIndex); ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
- QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
- QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
- }
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: remove: index out of range");
- evaluate<void>(visualModel, "items.remove(-8, 4)");
- QCOMPARE(listview->count(), 7);
- QCOMPARE(visualModel->items()->count(), 7);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: remove: index out of range");
- evaluate<void>(visualModel, "items.remove(12, 2)");
- QCOMPARE(listview->count(), 7);
- QCOMPARE(visualModel->items()->count(), 7);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: remove: invalid count");
- evaluate<void>(visualModel, "items.remove(5, 3)");
- QCOMPARE(listview->count(), 7);
- QCOMPARE(visualModel->items()->count(), 7);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: remove: invalid count");
- evaluate<void>(visualModel, "items.remove(5, -2)");
- QCOMPARE(listview->count(), 7);
- QCOMPARE(visualModel->items()->count(), 7);
- }
-}
-
-void tst_qquickvisualdatamodel::move_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<QString>("package delegate");
-
- QTest::newRow("item delegate")
- << testFileUrl("groups.qml")
- << QString();
- QTest::newRow("package")
- << testFileUrl("groups-package.qml")
- << QString("package.");
-}
-
-void tst_qquickvisualdatamodel::move()
-{
- QQuickView view;
-
- SingleRoleModel model;
- model.list = QStringList()
- << "one"
- << "two"
- << "three"
- << "four"
- << "five"
- << "six"
- << "seven"
- << "eight"
- << "nine"
- << "ten"
- << "eleven"
- << "twelve";
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(testFileUrl("groups.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
- QVERIFY(visualModel);
-
- {
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
-
- for (int i = 0; i < lengthOf(mIndex); ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
- QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
- QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
- }
- } {
- evaluate<void>(visualModel, "items.move(2, 4)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- static const int mIndex[] = { 0, 1, 3, 4, 2, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
-
- for (int i = 0; i < lengthOf(mIndex); ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
- QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
- QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
- }
- } {
- evaluate<void>(visualModel, "items.move(4, 2)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
-
- for (int i = 0; i < lengthOf(mIndex); ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
- QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
- QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
- }
- } {
- evaluate<void>(visualModel, "items.move(8, 0, 4)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- static const int mIndex[] = { 8, 9,10,11, 0, 1, 2, 3, 4, 5, 6, 7 };
- static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
-
- for (int i = 0; i < lengthOf(mIndex); ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
- QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
- QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
- }
- } {
- evaluate<void>(visualModel, "items.move(3, 4, 5)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- static const int mIndex[] = { 8, 9,10,4, 11, 0, 1, 2, 3, 5, 6, 7 };
- static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
-
- for (int i = 0; i < lengthOf(mIndex); ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
- QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
- QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
- }
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: invalid count");
- evaluate<void>(visualModel, "items.move(5, 2, -2)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: from index out of range");
- evaluate<void>(visualModel, "items.move(-6, 2, 1)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: from index out of range");
- evaluate<void>(visualModel, "items.move(15, 2, 1)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: from index out of range");
- evaluate<void>(visualModel, "items.move(11, 1, 3)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: to index out of range");
- evaluate<void>(visualModel, "items.move(2, -5, 1)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: to index out of range");
- evaluate<void>(visualModel, "items.move(2, 14, 1)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: to index out of range");
- evaluate<void>(visualModel, "items.move(2, 11, 4)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- }
-}
-
-void tst_qquickvisualdatamodel::groups_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<QString>("part");
-
- QTest::newRow("item delegate")
- << testFileUrl("groups.qml")
- << QString();
- QTest::newRow("package")
- << testFileUrl("groups-package.qml")
- << QString("visualModel.parts.package.");
-}
-
-template <int N> void tst_qquickvisualdatamodel::groups_verify(
- const SingleRoleModel &model,
- QQuickItem *contentItem,
- const int (&mIndex)[N],
- const int (&iIndex)[N],
- const int (&vIndex)[N],
- const int (&sIndex)[N],
- const bool (&vMember)[N],
- const bool (&sMember)[N])
-{
- failed = true;
- for (int i = 0; i < N; ++i) {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
- QVERIFY(delegate);
- QCOMPARE(evaluate<QString>(delegate, "test1"), model.list.at(mIndex[i]));
- QCOMPARE(evaluate<int>(delegate, "test2") , mIndex[i]);
- QCOMPARE(evaluate<int>(delegate, "test3") , iIndex[i]);
- QCOMPARE(evaluate<bool>(delegate, "test4"), true);
- QCOMPARE(evaluate<int>(delegate, "test5") , vIndex[i]);
- QCOMPARE(evaluate<bool>(delegate, "test6"), vMember[i]);
- QCOMPARE(evaluate<int>(delegate, "test7") , sIndex[i]);
- QCOMPARE(evaluate<bool>(delegate, "test8"), sMember[i]);
- QCOMPARE(evaluate<QStringList>(delegate, "test9").contains("items") , bool(true));
- QCOMPARE(evaluate<QStringList>(delegate, "test9").contains("visible") , bool(vMember[i]));
- QCOMPARE(evaluate<QStringList>(delegate, "test9").contains("selected"), bool(sMember[i]));
- }
- failed = false;
-}
-
-#define VERIFY_GROUPS \
- groups_verify(model, contentItem, mIndex, iIndex, vIndex, sIndex, vMember, sMember); \
- QVERIFY(!failed)
-
-
-void tst_qquickvisualdatamodel::groups()
-{
- QFETCH(QUrl, source);
- QFETCH(QString, part);
-
- QQuickView view;
-
- SingleRoleModel model;
- model.list = QStringList()
- << "one"
- << "two"
- << "three"
- << "four"
- << "five"
- << "six"
- << "seven"
- << "eight"
- << "nine"
- << "ten"
- << "eleven"
- << "twelve";
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(source);
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickVisualDataModel *visualModel = listview->findChild<QQuickVisualDataModel *>("visualModel");
- QVERIFY(visualModel);
-
- QQuickVisualDataGroup *visibleItems = listview->findChild<QQuickVisualDataGroup *>("visibleItems");
- QVERIFY(visibleItems);
-
- QQuickVisualDataGroup *selectedItems = listview->findChild<QQuickVisualDataGroup *>("selectedItems");
- QVERIFY(selectedItems);
-
- const bool f = false;
- const bool t = true;
-
- {
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 12);
- QCOMPARE(selectedItems->count(), 0);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, f, f, f, f };
- VERIFY_GROUPS;
- } {
- evaluate<void>(visualModel, "items.addGroups(8, \"selected\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 12);
- QCOMPARE(selectedItems->count(), 1);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, t, f, f, f };
- VERIFY_GROUPS;
- } {
- evaluate<void>(visualModel, "items.addGroups(6, 4, [\"visible\", \"selected\"])");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 12);
- QCOMPARE(selectedItems->count(), 4);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4 };
- static const bool sMember[] = { f, f, f, f, f, f, t, t, t, t, f, f };
- VERIFY_GROUPS;
- } {
- evaluate<void>(visualModel, "items.setGroups(2, [\"items\", \"selected\"])");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 11);
- QCOMPARE(selectedItems->count(), 5);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9,10 };
- static const bool vMember[] = { t, t, f, t, t, t, t, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5, 5 };
- static const bool sMember[] = { f, f, t, f, f, f, t, t, t, t, f, f };
- VERIFY_GROUPS;
- } {
- evaluate<void>(selectedItems, "setGroups(0, 3, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 };
- static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
- VERIFY_GROUPS;
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: addGroups: invalid count");
- evaluate<void>(visualModel, "items.addGroups(11, -4, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: addGroups: index out of range");
- evaluate<void>(visualModel, "items.addGroups(-1, 3, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: addGroups: index out of range");
- evaluate<void>(visualModel, "items.addGroups(14, 3, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: addGroups: invalid count");
- evaluate<void>(visualModel, "items.addGroups(11, 5, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: setGroups: invalid count");
- evaluate<void>(visualModel, "items.setGroups(11, -4, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: setGroups: index out of range");
- evaluate<void>(visualModel, "items.setGroups(-1, 3, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: setGroups: index out of range");
- evaluate<void>(visualModel, "items.setGroups(14, 3, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: setGroups: invalid count");
- evaluate<void>(visualModel, "items.setGroups(11, 5, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: removeGroups: invalid count");
- evaluate<void>(visualModel, "items.removeGroups(11, -4, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: removeGroups: index out of range");
- evaluate<void>(visualModel, "items.removeGroups(-1, 3, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: removeGroups: index out of range");
- evaluate<void>(visualModel, "items.removeGroups(14, 3, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: removeGroups: invalid count");
- evaluate<void>(visualModel, "items.removeGroups(11, 5, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- } {
- evaluate<void>(visualModel, part + "filterOnGroup = \"visible\"");
- QCOMPARE(listview->count(), 9);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- QCOMPARE(evaluate<QString>(visualModel, part + "filterOnGroup"), QString("visible"));
- } {
- evaluate<void>(visualModel, part + "filterOnGroup = \"selected\"");
- QCOMPARE(listview->count(), 2);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- QCOMPARE(evaluate<QString>(visualModel, part + "filterOnGroup"), QString("selected"));
- } {
- evaluate<void>(visualModel, part + "filterOnGroup = undefined");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- QCOMPARE(evaluate<QString>(visualModel, part + "filterOnGroup"), QString("items"));
- } {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 5);
- QVERIFY(delegate);
-
- evaluate<void>(delegate, "hide()");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 8);
- QCOMPARE(selectedItems->count(), 2);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 };
- static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
- VERIFY_GROUPS;
- } {
- QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 5);
- QVERIFY(delegate);
-
- evaluate<void>(delegate, "select()");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 8);
- QCOMPARE(selectedItems->count(), 3);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 };
- static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 3, 3 };
- static const bool sMember[] = { f, f, f, f, f, t, f, f, t, t, f, f };
- VERIFY_GROUPS;
- } {
- evaluate<void>(visualModel, "items.move(2, 6, 3)");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 8);
- QCOMPARE(selectedItems->count(), 3);
- static const int mIndex [] = { 0, 1, 5, 6, 7, 8, 2, 3, 4, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 2, 2, 3, 3, 4, 5, 6, 7 };
- static const bool vMember[] = { t, t, f, f, f, t, f, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3 };
- static const bool sMember[] = { f, f, t, f, f, t, f, f, f, t, f, f };
- VERIFY_GROUPS;
- }
-}
-
-template <int N> void tst_qquickvisualdatamodel::get_verify(
- const SingleRoleModel &model,
- QQuickVisualDataModel *visualModel,
- QQuickVisualDataGroup *visibleItems,
- QQuickVisualDataGroup *selectedItems,
- const int (&mIndex)[N],
- const int (&iIndex)[N],
- const int (&vIndex)[N],
- const int (&sIndex)[N],
- const bool (&vMember)[N],
- const bool (&sMember)[N])
-{
- failed = true;
- for (int i = 0; i < N; ++i) {
- QCOMPARE(evaluate<QString>(visualModel, QString("items.get(%1).model.name").arg(i)), model.list.at(mIndex[i]));
- QCOMPARE(evaluate<QString>(visualModel, QString("items.get(%1).model.modelData").arg(i)), model.list.at(mIndex[i]));
- QCOMPARE(evaluate<int>(visualModel, QString("items.get(%1).model.index").arg(i)), mIndex[i]);
- QCOMPARE(evaluate<int>(visualModel, QString("items.get(%1).itemsIndex").arg(i)), iIndex[i]);
- QCOMPARE(evaluate<bool>(visualModel, QString("items.get(%1).inItems").arg(i)), true);
- QCOMPARE(evaluate<int>(visualModel, QString("items.get(%1).visibleIndex").arg(i)), vIndex[i]);
- QCOMPARE(evaluate<bool>(visualModel, QString("items.get(%1).inVisible").arg(i)), vMember[i]);
- QCOMPARE(evaluate<int>(visualModel, QString("items.get(%1).selectedIndex").arg(i)), sIndex[i]);
- QCOMPARE(evaluate<bool>(visualModel, QString("items.get(%1).inSelected").arg(i)), sMember[i]);
- QCOMPARE(evaluate<bool>(visualModel, QString("contains(items.get(%1).groups, \"items\")").arg(i)), true);
- QCOMPARE(evaluate<bool>(visualModel, QString("contains(items.get(%1).groups, \"visible\")").arg(i)), vMember[i]);
- QCOMPARE(evaluate<bool>(visualModel, QString("contains(items.get(%1).groups, \"selected\")").arg(i)), sMember[i]);
-
- if (vMember[i]) {
- QCOMPARE(evaluate<QString>(visibleItems, QString("get(%1).model.name").arg(vIndex[i])), model.list.at(mIndex[i]));
- QCOMPARE(evaluate<QString>(visibleItems, QString("get(%1).model.modelData").arg(vIndex[i])), model.list.at(mIndex[i]));
- QCOMPARE(evaluate<int>(visibleItems, QString("get(%1).model.index").arg(vIndex[i])), mIndex[i]);
- QCOMPARE(evaluate<int>(visibleItems, QString("get(%1).itemsIndex").arg(vIndex[i])), iIndex[i]);
- QCOMPARE(evaluate<bool>(visibleItems, QString("get(%1).inItems").arg(vIndex[i])), true);
- QCOMPARE(evaluate<int>(visibleItems, QString("get(%1).visibleIndex").arg(vIndex[i])), vIndex[i]);
- QCOMPARE(evaluate<bool>(visibleItems, QString("get(%1).inVisible").arg(vIndex[i])), vMember[i]);
- QCOMPARE(evaluate<int>(visibleItems, QString("get(%1).selectedIndex").arg(vIndex[i])), sIndex[i]);
- QCOMPARE(evaluate<bool>(visibleItems, QString("get(%1).inSelected").arg(vIndex[i])), sMember[i]);
-
- QCOMPARE(evaluate<bool>(visibleItems, QString("contains(get(%1).groups, \"items\")").arg(vIndex[i])), true);
- QCOMPARE(evaluate<bool>(visibleItems, QString("contains(get(%1).groups, \"visible\")").arg(vIndex[i])), vMember[i]);
- QCOMPARE(evaluate<bool>(visibleItems, QString("contains(get(%1).groups, \"selected\")").arg(vIndex[i])), sMember[i]);
- }
- if (sMember[i]) {
- QCOMPARE(evaluate<QString>(selectedItems, QString("get(%1).model.name").arg(sIndex[i])), model.list.at(mIndex[i]));
- QCOMPARE(evaluate<QString>(selectedItems, QString("get(%1).model.modelData").arg(sIndex[i])), model.list.at(mIndex[i]));
- QCOMPARE(evaluate<int>(selectedItems, QString("get(%1).model.index").arg(sIndex[i])), mIndex[i]);
- QCOMPARE(evaluate<int>(selectedItems, QString("get(%1).itemsIndex").arg(sIndex[i])), iIndex[i]);
- QCOMPARE(evaluate<bool>(selectedItems, QString("get(%1).inItems").arg(sIndex[i])), true);
- QCOMPARE(evaluate<int>(selectedItems, QString("get(%1).visibleIndex").arg(sIndex[i])), vIndex[i]);
- QCOMPARE(evaluate<bool>(selectedItems, QString("get(%1).inVisible").arg(sIndex[i])), vMember[i]);
- QCOMPARE(evaluate<int>(selectedItems, QString("get(%1).selectedIndex").arg(sIndex[i])), sIndex[i]);
- QCOMPARE(evaluate<bool>(selectedItems, QString("get(%1).inSelected").arg(sIndex[i])), sMember[i]);
- QCOMPARE(evaluate<bool>(selectedItems, QString("contains(get(%1).groups, \"items\")").arg(sIndex[i])), true);
- QCOMPARE(evaluate<bool>(selectedItems, QString("contains(get(%1).groups, \"visible\")").arg(sIndex[i])), vMember[i]);
- QCOMPARE(evaluate<bool>(selectedItems, QString("contains(get(%1).groups, \"selected\")").arg(sIndex[i])), sMember[i]);
- }
- }
- failed = false;
-}
-
-#define VERIFY_GET \
- get_verify(model, visualModel, visibleItems, selectedItems, mIndex, iIndex, vIndex, sIndex, vMember, sMember); \
- QVERIFY(!failed)
-
-void tst_qquickvisualdatamodel::get()
-{
- QQuickView view;
-
- SingleRoleModel model;
- model.list = QStringList()
- << "one"
- << "two"
- << "three"
- << "four"
- << "five"
- << "six"
- << "seven"
- << "eight"
- << "nine"
- << "ten"
- << "eleven"
- << "twelve";
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(testFileUrl("groups.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
- QVERIFY(visualModel);
-
- QQuickVisualDataGroup *visibleItems = visualModel->findChild<QQuickVisualDataGroup *>("visibleItems");
- QVERIFY(visibleItems);
-
- QQuickVisualDataGroup *selectedItems = visualModel->findChild<QQuickVisualDataGroup *>("selectedItems");
- QVERIFY(selectedItems);
-
- QV8Engine *v8Engine = QDeclarativeEnginePrivate::getV8Engine(ctxt->engine());
- QVERIFY(v8Engine);
-
- const bool f = false;
- const bool t = true;
-
- {
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 12);
- QCOMPARE(selectedItems->count(), 0);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, f, f, f, f };
- VERIFY_GET;
- } {
- evaluate<void>(visualModel, "items.addGroups(8, \"selected\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 12);
- QCOMPARE(selectedItems->count(), 1);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, t, f, f, f };
- VERIFY_GET;
- } {
- evaluate<void>(visualModel, "items.addGroups(6, 4, [\"visible\", \"selected\"])");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 12);
- QCOMPARE(selectedItems->count(), 4);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4 };
- static const bool sMember[] = { f, f, f, f, f, f, t, t, t, t, f, f };
- VERIFY_GET;
- } {
- evaluate<void>(visualModel, "items.setGroups(2, [\"items\", \"selected\"])");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 11);
- QCOMPARE(selectedItems->count(), 5);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9,10 };
- static const bool vMember[] = { t, t, f, t, t, t, t, t, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5, 5 };
- static const bool sMember[] = { f, f, t, f, f, f, t, t, t, t, f, f };
- VERIFY_GET;
- } {
- evaluate<void>(selectedItems, "setGroups(0, 3, \"items\")");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 };
- static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
- VERIFY_GET;
- } {
- evaluate<void>(visualModel, "items.get(5).inVisible = false");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 8);
- QCOMPARE(selectedItems->count(), 2);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 };
- static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
- VERIFY_GET;
- } {
- evaluate<void>(visualModel, "items.get(5).inSelected = true");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 8);
- QCOMPARE(selectedItems->count(), 3);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 };
- static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 3, 3 };
- static const bool sMember[] = { f, f, f, f, f, t, f, f, t, t, f, f };
- VERIFY_GET;
- } {
- evaluate<void>(visualModel, "items.get(5).groups = [\"visible\", \"items\"]");
- QCOMPARE(listview->count(), 12);
- QCOMPARE(visualModel->items()->count(), 12);
- QCOMPARE(visibleItems->count(), 9);
- QCOMPARE(selectedItems->count(), 2);
- static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
- static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 };
- static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t };
- static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
- static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
- VERIFY_GET;
- }
-}
-
-void tst_qquickvisualdatamodel::invalidGroups()
-{
- QUrl source = testFileUrl("groups-invalid.qml");
- QTest::ignoreMessage(QtWarningMsg, (source.toString() + ":12:9: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("Group names must start with a lower case letter")).toUtf8());
-
- QDeclarativeComponent component(&engine, source);
- QScopedPointer<QObject> object(component.create());
- QVERIFY(object);
-
- QCOMPARE(evaluate<int>(object.data(), "groups.length"), 4);
- QCOMPARE(evaluate<QString>(object.data(), "groups[0].name"), QString("items"));
- QCOMPARE(evaluate<QString>(object.data(), "groups[1].name"), QString("persistedItems"));
- QCOMPARE(evaluate<QString>(object.data(), "groups[2].name"), QString("visible"));
- QCOMPARE(evaluate<QString>(object.data(), "groups[3].name"), QString("selected"));
-}
-
-void tst_qquickvisualdatamodel::onChanged_data()
-{
- QTest::addColumn<QString>("expression");
- QTest::addColumn<QStringList>("tests");
-
- QTest::newRow("item appended")
- << QString("listModel.append({\"number\": \"five\"})")
- << (QStringList()
- << "verify(vm.removed, [], [], [])"
- << "verify(vm.inserted, [4], [1], [undefined])"
- << "verify(vi.removed, [], [], [])"
- << "verify(vi.inserted, [4], [1], [undefined])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
- QTest::newRow("item prepended")
- << QString("listModel.insert(0, {\"number\": \"five\"})")
- << (QStringList()
- << "verify(vm.removed, [], [], [])"
- << "verify(vm.inserted, [0], [1], [undefined])"
- << "verify(vi.removed, [], [], [])"
- << "verify(vi.inserted, [0], [1], [undefined])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
- QTest::newRow("item inserted")
- << QString("listModel.insert(2, {\"number\": \"five\"})")
- << (QStringList()
- << "verify(vm.removed, [], [], [])"
- << "verify(vm.inserted, [2], [1], [undefined])"
- << "verify(vi.removed, [], [], [])"
- << "verify(vi.inserted, [2], [1], [undefined])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
-
- QTest::newRow("item removed tail")
- << QString("listModel.remove(3)")
- << (QStringList()
- << "verify(vm.removed, [3], [1], [undefined])"
- << "verify(vm.inserted, [], [], [])"
- << "verify(vi.removed, [3], [1], [undefined])"
- << "verify(vi.inserted, [], [], [])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
- QTest::newRow("item removed head")
- << QString("listModel.remove(0)")
- << (QStringList()
- << "verify(vm.removed, [0], [1], [undefined])"
- << "verify(vm.inserted, [], [], [])"
- << "verify(vi.removed, [0], [1], [undefined])"
- << "verify(vi.inserted, [], [], [])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
- QTest::newRow("item removed middle")
- << QString("listModel.remove(1)")
- << (QStringList()
- << "verify(vm.removed, [1], [1], [undefined])"
- << "verify(vm.inserted, [], [], [])"
- << "verify(vi.removed, [1], [1], [undefined])"
- << "verify(vi.inserted, [], [], [])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
-
-
- QTest::newRow("item moved from tail")
- << QString("listModel.move(3, 0, 1)")
- << (QStringList()
- << "verify(vm.removed, [3], [1], [vm.inserted[0].moveId])"
- << "verify(vm.inserted, [0], [1], [vm.removed[0].moveId])"
- << "verify(vi.removed, [3], [1], [vi.inserted[0].moveId])"
- << "verify(vi.inserted, [0], [1], [vi.removed[0].moveId])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
- QTest::newRow("item moved from head")
- << QString("listModel.move(0, 2, 2)")
- << (QStringList()
- << "verify(vm.removed, [0], [2], [vm.inserted[0].moveId])"
- << "verify(vm.inserted, [2], [2], [vm.removed[0].moveId])"
- << "verify(vi.removed, [0], [2], [vi.inserted[0].moveId])"
- << "verify(vi.inserted, [2], [2], [vi.removed[0].moveId])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
-
- QTest::newRow("groups changed")
- << QString("items.setGroups(1, 2, [\"items\", \"selected\"])")
- << (QStringList()
- << "verify(vm.inserted, [], [], [])"
- << "verify(vm.removed, [], [], [])"
- << "verify(vi.removed, [1], [2], [undefined])"
- << "verify(vi.inserted, [], [], [])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [0], [2], [undefined])");
-
- QTest::newRow("multiple removes")
- << QString("{ vi.remove(1, 1); "
- "vi.removeGroups(0, 2, \"items\") }")
- << (QStringList()
- << "verify(vm.removed, [0, 1], [1, 1], [undefined, undefined])"
- << "verify(vm.inserted, [], [], [])"
- << "verify(vi.removed, [1], [1], [undefined])"
- << "verify(vi.inserted, [], [], [])"
- << "verify(si.removed, [], [], [])"
- << "verify(si.inserted, [], [], [])");
-}
-
-void tst_qquickvisualdatamodel::onChanged()
-{
- QFETCH(QString, expression);
- QFETCH(QStringList, tests);
-
- QDeclarativeComponent component(&engine, testFileUrl("onChanged.qml"));
- QScopedPointer<QObject> object(component.create());
- QVERIFY(object);
-
- evaluate<void>(object.data(), expression);
-
- foreach (const QString &test, tests) {
- bool passed = evaluate<bool>(object.data(), test);
- if (!passed)
- qWarning() << test;
- QVERIFY(passed);
- }
-}
-
-void tst_qquickvisualdatamodel::create()
-{
- QQuickView view;
-
- SingleRoleModel model;
- model.list = QStringList()
- << "one"
- << "two"
- << "three"
- << "four"
- << "five"
- << "six"
- << "seven"
- << "eight"
- << "nine"
- << "ten"
- << "eleven"
- << "twelve"
- << "thirteen"
- << "fourteen"
- << "fifteen"
- << "sixteen"
- << "seventeen"
- << "eighteen"
- << "nineteen"
- << "twenty";
-
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", &model);
-
- view.setSource(testFileUrl("create.qml"));
-
- QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
- QVERIFY(listview != 0);
-
- QQuickItem *contentItem = listview->contentItem();
- QVERIFY(contentItem != 0);
-
- QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
- QVERIFY(visualModel);
-
- QCOMPARE(listview->count(), 20);
-
- QDeclarativeGuard<QQuickItem> delegate;
-
- // persistedItems.includeByDefault is true, so all items belong to persistedItems initially.
- QVERIFY(delegate = findItem<QQuickItem>(contentItem, "delegate", 1));
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
-
- // changing include by default doesn't remove persistance.
- evaluate<void>(visualModel, "persistedItems.includeByDefault = false");
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
-
- // removing from persistedItems does.
- evaluate<void>(visualModel, "persistedItems.remove(0, 20)");
- QCOMPARE(listview->count(), 20);
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), false);
-
- // Request an item instantiated by the view.
- QVERIFY(delegate = qobject_cast<QQuickItem *>(evaluate<QObject *>(visualModel, "items.create(1)")));
- QCOMPARE(delegate.data(), findItem<QQuickItem>(contentItem, "delegate", 1));
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
-
- evaluate<void>(delegate, "VisualDataModel.inPersistedItems = false");
- QCOMPARE(listview->count(), 20);
- QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
- QVERIFY(delegate);
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), false);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 0);
-
- // Request an item not instantiated by the view.
- QVERIFY(!findItem<QQuickItem>(contentItem, "delegate", 15));
- QVERIFY(delegate = qobject_cast<QQuickItem *>(evaluate<QObject *>(visualModel, "items.create(15)")));
- QCOMPARE(delegate.data(), findItem<QQuickItem>(contentItem, "delegate", 15));
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
-
- evaluate<void>(visualModel, "persistedItems.remove(0)");
- QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
- QVERIFY(!delegate);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 0);
-
- // Request an item not instantiated by the view, then scroll the view so it will request it.
- QVERIFY(!findItem<QQuickItem>(contentItem, "delegate", 16));
- QVERIFY(delegate = qobject_cast<QQuickItem *>(evaluate<QObject *>(visualModel, "items.create(16)")));
- QCOMPARE(delegate.data(), findItem<QQuickItem>(contentItem, "delegate", 16));
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
-
- evaluate<void>(listview, "positionViewAtIndex(19, ListView.End)");
- QCOMPARE(listview->count(), 20);
- evaluate<void>(delegate, "VisualDataModel.groups = [\"items\"]");
- QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
- QVERIFY(delegate);
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), false);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 0);
-
- // Request and release an item instantiated by the view, then scroll the view so it releases it.
- QVERIFY(findItem<QQuickItem>(contentItem, "delegate", 17));
- QVERIFY(delegate = qobject_cast<QQuickItem *>(evaluate<QObject *>(visualModel, "items.create(17)")));
- QCOMPARE(delegate.data(), findItem<QQuickItem>(contentItem, "delegate", 17));
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
-
- evaluate<void>(visualModel, "items.removeGroups(17, \"persistedItems\")");
- QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
- QVERIFY(delegate);
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), false);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 0);
- evaluate<void>(listview, "positionViewAtIndex(1, ListView.Beginning)");
- QCOMPARE(listview->count(), 20);
- QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
- QVERIFY(!delegate);
-
- // Adding an item to the persistedItems group won't instantiate it, but if later requested by
- // the view it will be persisted.
- evaluate<void>(visualModel, "items.addGroups(18, \"persistedItems\")");
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
- QVERIFY(!findItem<QQuickItem>(contentItem, "delegate", 18));
- evaluate<void>(listview, "positionViewAtIndex(19, ListView.End)");
- QCOMPARE(listview->count(), 20);
- QVERIFY(delegate = findItem<QQuickItem>(contentItem, "delegate", 18));
- QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
- QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
- QVERIFY(delegate);
- evaluate<void>(listview, "positionViewAtIndex(1, ListView.Beginning)");
- QCOMPARE(listview->count(), 20);
- QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
- QVERIFY(delegate);
-
- // Remove an uninstantiated but cached item from the persistedItems group.
- evaluate<void>(visualModel, "items.addGroups(19, \"persistedItems\")");
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 2);
- QVERIFY(!findItem<QQuickItem>(contentItem, "delegate", 19));
- // Store a reference to the item so it is retained in the cache.
- evaluate<void>(visualModel, "persistentHandle = items.get(19)");
- QCOMPARE(evaluate<bool>(visualModel, "persistentHandle.inPersistedItems"), true);
- evaluate<void>(visualModel, "items.removeGroups(19, \"persistedItems\")");
- QCOMPARE(evaluate<bool>(visualModel, "persistentHandle.inPersistedItems"), false);
-}
-
-void tst_qquickvisualdatamodel::incompleteModel()
-{
- // VisualDataModel is first populated in componentComplete. Verify various functions are
- // harmlessly ignored until then.
-
- QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\n VisualDataModel {}", testFileUrl(""));
-
- QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
-
- QQuickVisualDataModel *model = qobject_cast<QQuickVisualDataModel *>(object.data());
- QVERIFY(model);
-
- QSignalSpy itemsSpy(model->items(), SIGNAL(countChanged()));
- QSignalSpy persistedItemsSpy(model->items(), SIGNAL(countChanged()));
-
- evaluate<void>(model, "items.removeGroups(0, items.count, \"items\")");
- QCOMPARE(itemsSpy.count(), 0);
- QCOMPARE(persistedItemsSpy.count(), 0);
-
- evaluate<void>(model, "items.setGroups(0, items.count, \"persistedItems\")");
- QCOMPARE(itemsSpy.count(), 0);
- QCOMPARE(persistedItemsSpy.count(), 0);
-
- evaluate<void>(model, "items.addGroups(0, items.count, \"persistedItems\")");
- QCOMPARE(itemsSpy.count(), 0);
- QCOMPARE(persistedItemsSpy.count(), 0);
-
- evaluate<void>(model, "items.remove(0, items.count)");
- QCOMPARE(itemsSpy.count(), 0);
- QCOMPARE(persistedItemsSpy.count(), 0);
-
- evaluate<void>(model, "items.insert([ \"color\": \"blue\" ])");
- QCOMPARE(itemsSpy.count(), 0);
- QCOMPARE(persistedItemsSpy.count(), 0);
-
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: get: index out of range");
- QVERIFY(evaluate<bool>(model, "items.get(0) === undefined"));
-
- component.completeCreate();
-}
-
-void tst_qquickvisualdatamodel::insert_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<QString>("expression");
- QTest::addColumn<int>("modelCount");
- QTest::addColumn<int>("visualCount");
- QTest::addColumn<int>("index");
- QTest::addColumn<bool>("inItems");
- QTest::addColumn<bool>("persisted");
- QTest::addColumn<bool>("visible");
- QTest::addColumn<bool>("selected");
- QTest::addColumn<bool>("modelData");
- QTest::addColumn<QString>("property");
- QTest::addColumn<QStringList>("propertyData");
-
- const QUrl listModelSource[] = {
- testFileUrl("listmodelproperties.qml"),
- testFileUrl("listmodelproperties-package.qml") };
- const QUrl singleRoleSource[] = {
- testFileUrl("singleroleproperties.qml"),
- testFileUrl("singleroleproperties-package.qml") };
- const QUrl multipleRoleSource[] = {
- testFileUrl("multipleroleproperties.qml"),
- testFileUrl("multipleroleproperties-package.qml") };
- const QUrl stringListSource[] = {
- testFileUrl("stringlistproperties.qml"),
- testFileUrl("stringlistproperties-package.qml") };
- const QUrl objectListSource[] = {
- testFileUrl("objectlistproperties.qml"),
- testFileUrl("objectlistproperties-package.qml") };
-
- for (int i = 0; i < 2; ++i) {
- // List Model.
- QTest::newRow("ListModel.items prepend")
- << listModelSource[i]
- << QString("items.insert(0, {\"number\": \"eight\"})")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items append")
- << listModelSource[i]
- << QString("items.insert({\"number\": \"eight\"})")
- << 4 << 5 << 4 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "eight");
-
- QTest::newRow("ListModel.items insert at 2")
- << listModelSource[i]
- << QString("items.insert(2, {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items insert at items.get(2)")
- << listModelSource[i]
- << QString("items.insert(items.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items insert at visibleItems.get(2)")
- << listModelSource[i]
- << QString("items.insert(visibleItems.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.selectedItems insert at items.get(2)")
- << listModelSource[i]
- << QString("selectedItems.insert(items.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << false << false << false << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.selectedItems insert at visibleItems.get(2)")
- << listModelSource[i]
- << QString("selectedItems.insert(visibleItems.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << false << false << false << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items prepend modelData")
- << listModelSource[i]
- << QString("items.insert(0, {\"modelData\": \"eight\"})")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items prepend, edit number")
- << listModelSource[i]
- << QString("{ "
- "items.insert(0, {\"number\": \"eight\"}); "
- "items.get(0).model.number = \"seven\"; }")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items prepend, edit modelData")
- << listModelSource[i]
- << QString("{ "
- "items.insert(0, {\"number\": \"eight\"}); "
- "items.get(0).model.modelData = \"seven\"; }")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items prepend, edit resolved")
- << listModelSource[i]
- << QString("{ "
- "items.insert(0, {\"number\": \"eight\"}); "
- "items.get(2).model.number = \"seven\"; }")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items prepend with groups")
- << listModelSource[i]
- << QString("items.insert(0, {\"number\": \"eight\"}, [\"visible\", \"truncheon\"])")
- << 4 << 5 << 0 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items append with groups")
- << listModelSource[i]
- << QString("items.insert({\"number\": \"eight\"}, [\"visible\", \"selected\"])")
- << 4 << 5 << 4 << true << false << true << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "eight");
-
- QTest::newRow("ListModel.items insert at 2 with groups")
- << listModelSource[i]
- << QString("items.insert(2, {\"number\": \"eight\"}, \"visible\")")
- << 4 << 5 << 2 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- // create ListModel
- QTest::newRow("ListModel.items prepend")
- << listModelSource[i]
- << QString("items.create(0, {\"number\": \"eight\"})")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items append")
- << listModelSource[i]
- << QString("items.create({\"number\": \"eight\"})")
- << 4 << 5 << 4 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "eight");
-
- QTest::newRow("ListModel.items create at 2")
- << listModelSource[i]
- << QString("items.create(2, {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items create at items.get(2)")
- << listModelSource[i]
- << QString("items.create(items.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items create at visibleItems.get(2)")
- << listModelSource[i]
- << QString("items.create(visibleItems.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.selectedItems create at items.get(2)")
- << listModelSource[i]
- << QString("selectedItems.create(items.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << false << true << false << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.selectedItems create at visibleItems.get(2)")
- << listModelSource[i]
- << QString("selectedItems.create(visibleItems.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << false << true << false << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items create prepended")
- << listModelSource[i]
- << QString("items.create(0, {\"number\": \"eight\"})")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items create appended")
- << listModelSource[i]
- << QString("items.create({\"number\": \"eight\"})")
- << 4 << 5 << 4 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "eight");
-
- QTest::newRow("ListModel.items create at 2")
- << listModelSource[i]
- << QString("items.create(2, {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items create at items.get(2)")
- << listModelSource[i]
- << QString("items.create(items.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items create at visibleItems.get(2)")
- << listModelSource[i]
- << QString("items.create(visibleItems.get(2), {\"number\": \"eight\"})")
- << 4 << 5 << 2 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.create prepend modelData")
- << listModelSource[i]
- << QString("items.create(0, {\"modelData\": \"eight\"})")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items create prepended, edit number")
- << listModelSource[i]
- << QString("{ "
- "var item = items.create(0, {\"number\": \"eight\"}); "
- "item.setTest3(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items create prepended, edit model.number")
- << listModelSource[i]
- << QString("{ "
- "var item = items.create(0, {\"number\": \"eight\"}); "
- "item.setTest4(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items create prepended, edit modelData")
- << listModelSource[i]
- << QString("{ "
- "var item = items.create(0, {\"number\": \"eight\"}); "
- "item.setTest5(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items create prepended, edit model.modelData")
- << listModelSource[i]
- << QString("{ "
- "var item = items.create(0, {\"number\": \"eight\"}); "
- "item.setTest6(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items create prepended with groups")
- << listModelSource[i]
- << QString("items.create(0, {\"number\": \"eight\"}, [\"visible\", \"truncheon\"])")
- << 4 << 5 << 0 << true << true << true << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items create appended with groups")
- << listModelSource[i]
- << QString("items.create({\"number\": \"eight\"}, [\"visible\", \"selected\"])")
- << 4 << 5 << 4 << true << true << true << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "eight");
-
- QTest::newRow("ListModel.items create inserted with groups")
- << listModelSource[i]
- << QString("items.create(2, {\"number\": \"eight\"}, \"visible\")")
- << 4 << 5 << 2 << true << true << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("ListModel.items create prepended clear persistence")
- << listModelSource[i]
- << QString("{ items.create(0, {\"number\": \"eight\"}); "
- "items.get(0).inPersistedItems = false }")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items create appended clear persistence")
- << listModelSource[i]
- << QString("{ items.create({\"number\": \"eight\"}); "
- "items.get(4).inPersistedItems = false }")
- << 4 << 5 << 4 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "eight");
-
- QTest::newRow("ListModel.items create inserted clear persistence")
- << listModelSource[i]
- << QString("{ items.create(2, {\"number\": \"eight\"}); "
- "items.get(2).inPersistedItems = false }")
- << 4 << 5 << 2 << true << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- // AbstractItemModel (Single Role).
- QTest::newRow("AbstractItemModel.items prepend")
- << singleRoleSource[i]
- << QString("items.insert(0, {\"name\": \"eight\"})")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("name")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items append")
- << singleRoleSource[i]
- << QString("items.insert({\"name\": \"eight\"})")
- << 4 << 5 << 4 << true << false << false << false << true
- << QString("name")
- << (QStringList() << "one" << "two" << "three" << "four" << "eight");
-
- QTest::newRow("AbstractItemModel.items insert at 2")
- << singleRoleSource[i]
- << QString("items.insert(2, {\"name\": \"eight\"})")
- << 4 << 5 << 2 << true << false << false << false << true
- << QString("name")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items prepend modelData")
- << singleRoleSource[i]
- << QString("items.insert(0, {\"modelData\": \"eight\"})")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("name")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items prepend, edit name")
- << singleRoleSource[i]
- << QString("{ "
- "items.insert(0, {\"name\": \"eight\"}); "
- "items.get(0).model.name = \"seven\"; }")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("name")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items prepend, edit modelData")
- << singleRoleSource[i]
- << QString("{ "
- "items.insert(0, {\"name\": \"eight\"}); "
- "items.get(0).model.modelData = \"seven\"; }")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("name")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items prepend, edit resolved")
- << singleRoleSource[i]
- << QString("{ "
- "items.insert(0, {\"name\": \"eight\"}); "
- "items.get(2).model.name = \"seven\"; }")
- << 4 << 5 << 0 << true << false << false << false << true
- << QString("name")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.create prepend modelData")
- << singleRoleSource[i]
- << QString("items.create(0, {\"modelData\": \"eight\"})")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("name")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items create prepended, edit name")
- << singleRoleSource[i]
- << QString("{ "
- "var item = items.create(0, {\"name\": \"eight\"}); "
- "item.setTest3(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("name")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items create prepended, edit model.name")
- << singleRoleSource[i]
- << QString("{ "
- "var item = items.create(0, {\"name\": \"eight\"}); "
- "item.setTest4(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("name")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items create prepended, edit modelData")
- << singleRoleSource[i]
- << QString("{ "
- "var item = items.create(0, {\"name\": \"eight\"}); "
- "item.setTest5(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("name")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items create prepended, edit model.modelData")
- << singleRoleSource[i]
- << QString("{ "
- "var item = items.create(0, {\"name\": \"eight\"}); "
- "item.setTest6(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << true
- << QString("name")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- // AbstractItemModel (Multiple Roles).
- QTest::newRow("StandardItemModel.items prepend")
- << multipleRoleSource[i]
- << QString("items.insert(0, {\"display\": \"Row 8 Item\"})")
- << 4 << 5 << 0 << true << false << false << false << false
- << QString("display")
- << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items append")
- << multipleRoleSource[i]
- << QString("items.insert({\"display\": \"Row 8 Item\"})")
- << 4 << 5 << 4 << true << false << false << false << false
- << QString("display")
- << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item" << "Row 8 Item");
-
- QTest::newRow("StandardItemModel.items insert at 2")
- << multipleRoleSource[i]
- << QString("items.insert(2, {\"display\": \"Row 8 Item\"})")
- << 4 << 5 << 2 << true << false << false << false << false
- << QString("display")
- << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 8 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items prepend modelData")
- << multipleRoleSource[i]
- << QString("items.insert(0, {\"modelData\": \"Row 8 Item\"})")
- << 4 << 5 << 0 << true << false << false << false << false
- << QString("display")
- << (QStringList() << QString() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items prepend, edit display")
- << multipleRoleSource[i]
- << QString("{ "
- "items.insert(0, {\"display\": \"Row 8 Item\"}); "
- "items.get(0).model.display = \"Row 7 Item\"; }")
- << 4 << 5 << 0 << true << false << false << false << false
- << QString("display")
- << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items prepend, edit modelData")
- << multipleRoleSource[i]
- << QString("{ "
- "items.insert(0, {\"display\": \"Row 8 Item\"}); "
- "items.get(0).model.modelData = \"Row 7 Item\"; }")
- << 4 << 5 << 0 << true << false << false << false << false
- << QString("display")
- << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items prepend, edit resolved")
- << multipleRoleSource[i]
- << QString("{ "
- "items.insert(0, {\"display\": \"Row 8 Item\"}); "
- "items.get(2).model.display = \"Row 7 Item\"; }")
- << 4 << 5 << 0 << true << false << false << false << false
- << QString("display")
- << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.create prepend modelData")
- << multipleRoleSource[i]
- << QString("items.create(0, {\"modelData\": \"Row 8 Item\"})")
- << 4 << 5 << 0 << true << true << false << false << false
- << QString("display")
- << (QStringList() << QString() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items create prepended, edit display")
- << multipleRoleSource[i]
- << QString("{ "
- "var item = items.create(0, {\"display\": \"Row 8 Item\"}); "
- "item.setTest3(\"Row 7 Item\"); }")
- << 4 << 5 << 0 << true << true << false << false << false
- << QString("display")
- << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items create prepended, edit model.display")
- << multipleRoleSource[i]
- << QString("{ "
- "var item = items.create(0, {\"display\": \"Row 8 Item\"}); "
- "item.setTest4(\"Row 7 Item\"); }")
- << 4 << 5 << 0 << true << true << false << false << false
- << QString("display")
- << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- // StringList.
- QTest::newRow("StringList.items prepend")
- << stringListSource[i]
- << QString("items.insert(0, {\"modelData\": \"eight\"})")
- << 4 << 5 << 0 << true << false << false << false << false
- << QString("modelData")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("StringList.items append")
- << stringListSource[i]
- << QString("items.insert({\"modelData\": \"eight\"})")
- << 4 << 5 << 4 << true << false << false << false << false
- << QString("modelData")
- << (QStringList() << "one" << "two" << "three" << "four" << "eight");
-
- QTest::newRow("StringList.items insert at 2")
- << stringListSource[i]
- << QString("items.insert(2, {\"modelData\": \"eight\"})")
- << 4 << 5 << 2 << true << false << false << false << false
- << QString("modelData")
- << (QStringList() << "one" << "two" << "eight" << "three" << "four");
-
- QTest::newRow("StringList.items prepend, edit modelData")
- << stringListSource[i]
- << QString("{ "
- "items.insert(0, {\"modelData\": \"eight\"}); "
- "items.get(0).model.modelData = \"seven\"; }")
- << 4 << 5 << 0 << true << false << false << false << false
- << QString("modelData")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("StringList.items prepend, edit resolved")
- << stringListSource[i]
- << QString("{ "
- "items.insert(0, {\"modelData\": \"eight\"}); "
- "items.get(2).model.modelData = \"seven\"; }")
- << 4 << 5 << 0 << true << false << false << false << false
- << QString("modelData")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("StringList.create prepend modelData")
- << stringListSource[i]
- << QString("items.create(0, {\"modelData\": \"eight\"})")
- << 4 << 5 << 0 << true << true << false << false << false
- << QString("modelData")
- << (QStringList() << "eight" << "one" << "two" << "three" << "four");
-
- QTest::newRow("StringList.items create prepended, edit modelData")
- << stringListSource[i]
- << QString("{ "
- "var item = items.create(0, {\"modelData\": \"eight\"}); "
- "item.setTest3(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << false
- << QString("modelData")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("StringList.items create prepended, edit model.modelData")
- << stringListSource[i]
- << QString("{ "
- "var item = items.create(0, {\"modelData\": \"eight\"}); "
- "item.setTest4(\"seven\"); }")
- << 4 << 5 << 0 << true << true << false << false << false
- << QString("modelData")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- // ObjectList
- QTest::newRow("ObjectList.items prepend")
- << objectListSource[i]
- << QString("items.insert(0, {\"name\": \"Item 8\"})")
- << 4 << 4 << 4 << false << false << false << false << false
- << QString("name")
- << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4");
-
- QTest::newRow("ObjectList.items append")
- << objectListSource[i]
- << QString("items.insert({\"name\": \"Item 8\"})")
- << 4 << 4 << 4 << false << false << false << false << false
- << QString("name")
- << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4");
-
- QTest::newRow("ObjectList.items insert at 2")
- << objectListSource[i]
- << QString("items.insert(2, {\"name\": \"Item 8\"})")
- << 4 << 4 << 4 << false << false << false << false << false
- << QString("name")
- << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4");
- }
-}
-
-void tst_qquickvisualdatamodel::insert()
-{
- QFETCH(QUrl, source);
- QFETCH(QString, expression);
- QFETCH(int, modelCount);
- QFETCH(int, visualCount);
- QFETCH(int, index);
- QFETCH(bool, inItems);
- QFETCH(bool, persisted);
- QFETCH(bool, visible);
- QFETCH(bool, selected);
- QFETCH(bool, modelData);
- QFETCH(QString, property);
- QFETCH(QStringList, propertyData);
-
- QQuickCanvas canvas;
-
- QDeclarativeComponent component(&engine);
- component.loadUrl(source);
- QScopedPointer<QObject> object(component.create());
- QQuickListView *listView = qobject_cast<QQuickListView *>(object.data());
- QVERIFY(listView);
- listView->setParentItem(canvas.rootItem());
-
- QQuickItem *contentItem = listView->contentItem();
- QVERIFY(contentItem);
-
- QObject *visualModel = listView->findChild<QObject *>("visualModel");
- QVERIFY(visualModel);
-
- evaluate<void>(visualModel, expression);
-
- QCOMPARE(evaluate<int>(listView, "count"), inItems ? visualCount : modelCount);
- QCOMPARE(evaluate<int>(visualModel, "count"), inItems ? visualCount : modelCount);
- QCOMPARE(evaluate<int>(visualModel, "items.count"), inItems ? visualCount : modelCount);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), persisted ? 1 : 0);
- QCOMPARE(evaluate<int>(visualModel, "visibleItems.count"), visible ? visualCount : modelCount);
- QCOMPARE(evaluate<int>(visualModel, "selectedItems.count"), selected ? 1 : 0);
-
- QCOMPARE(propertyData.count(), visualCount);
- for (int i = 0; i < visualCount; ++i) {
- int modelIndex = i;
- if (modelIndex > index)
- modelIndex -= 1;
- else if (modelIndex == index)
- modelIndex = -1;
-
- const int itemsIndex = inItems || i <= index ? i : i - 1;
- QString get;
-
- if (i != index) {
- get = QString("items.get(%1)").arg(itemsIndex);
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "delegate", modelIndex);
- QVERIFY(item);
-
- QCOMPARE(evaluate<int>(item, "test1"), modelIndex);
- QCOMPARE(evaluate<int>(item, "test2"), modelIndex);
- QCOMPARE(evaluate<QString>(item, "test3"), propertyData.at(i));
- QCOMPARE(evaluate<QString>(item, "test4"), propertyData.at(i));
-
- if (modelData) {
- QCOMPARE(evaluate<QString>(item, "test5"), propertyData.at(i));
- QCOMPARE(evaluate<QString>(item, "test6"), propertyData.at(i));
- }
-
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inItems"), true);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inPersistedItems"), false);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inVisible"), true);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inSelected"), false);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.isUnresolved"), false);
-
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.itemsIndex"), itemsIndex);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.persistedItemsIndex"), persisted && i > index ? 1 : 0);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.visibleIndex"), visible || i <= index ? i : i - 1);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.selectedIndex"), selected && i > index ? 1 : 0);
- } else if (inItems) {
- get = QString("items.get(%1)").arg(index);
- } else if (persisted) {
- get = "persistedItems.get(0)";
- } else if (visible) {
- get = QString("visibleItems.get(%1)").arg(index);
- } else if (selected) {
- get = "selectedItems.get(0)";
- } else {
- continue;
- }
-
- QCOMPARE(evaluate<int>(visualModel, get + ".model.index"), modelIndex);
-
- QCOMPARE(evaluate<QString>(visualModel, get + ".model." + property), propertyData.at(i));
-
- QCOMPARE(evaluate<bool>(visualModel, get + ".inItems"), inItems || i != index);
- QCOMPARE(evaluate<bool>(visualModel, get + ".inPersistedItems"), persisted && i == index);
- QCOMPARE(evaluate<bool>(visualModel, get + ".inVisible"), visible || i != index);
- QCOMPARE(evaluate<bool>(visualModel, get + ".inSelected"), selected && i == index);
- QCOMPARE(evaluate<bool>(visualModel, get + ".isUnresolved"), i == index);
-
- QCOMPARE(evaluate<int>(visualModel, get + ".itemsIndex"), inItems || i <= index ? i : i - 1);
- QCOMPARE(evaluate<int>(visualModel, get + ".persistedItemsIndex"), persisted && i > index ? 1 : 0);
- QCOMPARE(evaluate<int>(visualModel, get + ".visibleIndex"), visible || i <= index ? i : i - 1);
- QCOMPARE(evaluate<int>(visualModel, get + ".selectedIndex"), selected && i > index ? 1 : 0);
- }
-
- QObject *item = 0;
-
- if (inItems)
- item = evaluate<QObject *>(visualModel, QString("items.create(%1)").arg(index));
- else if (persisted)
- item = evaluate<QObject *>(visualModel, QString("persistedItems.create(%1)").arg(0));
- else if (visible)
- item = evaluate<QObject *>(visualModel, QString("visibleItems.create(%1)").arg(index));
- else if (selected)
- item = evaluate<QObject *>(visualModel, QString("selectedItems.create(%1)").arg(0));
- else
- return;
-
- QVERIFY(item);
-
- QCOMPARE(evaluate<int>(item, "test1"), -1);
- QCOMPARE(evaluate<int>(item, "test2"), -1);
- QCOMPARE(evaluate<QString>(item, "test3"), propertyData.at(index));
- QCOMPARE(evaluate<QString>(item, "test4"), propertyData.at(index));
-
- if (modelData) {
- QCOMPARE(evaluate<QString>(item, "test5"), propertyData.at(index));
- QCOMPARE(evaluate<QString>(item, "test6"), propertyData.at(index));
- }
-
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inItems"), inItems);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inPersistedItems"), true);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inVisible"), visible);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inSelected"), selected);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.isUnresolved"), true);
-
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.itemsIndex"), index);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.persistedItemsIndex"), 0);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.visibleIndex"), index);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.selectedIndex"), 0);
-}
-
-void tst_qquickvisualdatamodel::resolve_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<QString>("setupExpression");
- QTest::addColumn<QString>("resolveExpression");
- QTest::addColumn<int>("unresolvedCount");
- QTest::addColumn<int>("modelCount");
- QTest::addColumn<int>("visualCount");
- QTest::addColumn<int>("index");
- QTest::addColumn<bool>("inItems");
- QTest::addColumn<bool>("persisted");
- QTest::addColumn<bool>("visible");
- QTest::addColumn<bool>("selected");
- QTest::addColumn<bool>("modelData");
- QTest::addColumn<QString>("property");
- QTest::addColumn<QStringList>("propertyData");
-
- const QUrl listModelSource[] = {
- testFileUrl("listmodelproperties.qml"),
- testFileUrl("listmodelproperties-package.qml") };
- const QUrl singleRoleSource[] = {
- testFileUrl("singleroleproperties.qml"),
- testFileUrl("singleroleproperties-package.qml") };
- const QUrl multipleRoleSource[] = {
- testFileUrl("multipleroleproperties.qml"),
- testFileUrl("multipleroleproperties-package.qml") };
- const QUrl stringListSource[] = {
- testFileUrl("stringlistproperties.qml"),
- testFileUrl("stringlistproperties-package.qml") };
- const QUrl objectListSource[] = {
- testFileUrl("objectlistproperties.qml"),
- testFileUrl("objectlistproperties-package.qml") };
-
- for (int i = 0; i < 2; ++i) {
- // List Model.
- QTest::newRow("ListModel.items prepend, resolve prepended")
- << listModelSource[i]
- << QString("items.insert(0, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(0, 1) }")
- << 5 << 5 << 5 << 0 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items prepend, resolve appended")
- << listModelSource[i]
- << QString("items.insert(0, {\"number\": \"eight\"})")
- << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(0, 5) }")
- << 5 << 5 << 5 << 4 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "seven");
-
- QTest::newRow("ListModel.items prepend, resolve inserted")
- << listModelSource[i]
- << QString("items.insert(0, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(0, 3) }")
- << 5 << 5 << 5 << 2 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "seven" << "three" << "four");
-
- QTest::newRow("ListModel.items append, resolve prepended")
- << listModelSource[i]
- << QString("items.insert({\"number\": \"eight\"})")
- << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(5, 0) }")
- << 5 << 5 << 5 << 0 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items append, resolve appended")
- << listModelSource[i]
- << QString("items.insert({\"number\": \"eight\"})")
- << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(5, 4) }")
- << 5 << 5 << 5 << 4 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "seven");
-
- QTest::newRow("ListModel.items append, resolve inserted")
- << listModelSource[i]
- << QString("items.insert({\"number\": \"eight\"})")
- << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(5, 2) }")
- << 5 << 5 << 5 << 2 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "seven" << "three" << "four");
-
- QTest::newRow("ListModel.items insert, resolve prepended")
- << listModelSource[i]
- << QString("items.insert(2, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(3, 0) }")
- << 5 << 5 << 5 << 0 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items insert, resolve appended")
- << listModelSource[i]
- << QString("items.insert(2, {\"number\": \"eight\"})")
- << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(2, 5) }")
- << 5 << 5 << 5 << 4 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "seven");
-
- QTest::newRow("ListModel.items insert, resolve inserted")
- << listModelSource[i]
- << QString("items.insert(2, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(2, 3) }")
- << 5 << 5 << 5 << 2 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "seven" << "three" << "four");
-
- QTest::newRow("ListModel.items prepend, move resolved")
- << listModelSource[i]
- << QString("items.insert(0, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(0, {\"number\": \"seven\"}); "
- "items.resolve(0, 1); "
- "listModel.move(0, 2, 1) }")
- << 5 << 5 << 5 << 2 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "seven" << "three" << "four");
-
- QTest::newRow("ListModel.items append, move resolved")
- << listModelSource[i]
- << QString("items.insert({\"number\": \"eight\"})")
- << QString("{ listModel.append({\"number\": \"seven\"}); "
- "items.resolve(5, 4); "
- "listModel.move(4, 2, 1) }")
- << 5 << 5 << 5 << 2 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "seven" << "three" << "four");
-
- QTest::newRow("ListModel.items insert, move resolved")
- << listModelSource[i]
- << QString("items.insert(2, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(2, {\"number\": \"seven\"}); "
- "items.resolve(2, 3);"
- "listModel.move(2, 0, 1) }")
- << 5 << 5 << 5 << 0 << true << false << true << false << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items prepend, remove resolved")
- << listModelSource[i]
- << QString("items.insert(0, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(0, {\"number\": \"seven\"}); "
- "items.resolve(0, 1); "
- "listModel.remove(0, 1) }")
- << 5 << 4 << 4 << 4 << false << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items append, remove resolved")
- << listModelSource[i]
- << QString("items.insert({\"number\": \"eight\"})")
- << QString("{ listModel.append({\"number\": \"seven\"}); "
- "items.resolve(5, 4); "
- "listModel.remove(4, 1) }")
- << 5 << 4 << 4 << 4 << false << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items insert, remove resolved")
- << listModelSource[i]
- << QString("items.insert(2, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(2, {\"number\": \"seven\"}); "
- "items.resolve(2, 3);"
- "listModel.remove(2, 1) }")
- << 5 << 4 << 4 << 4 << false << false << false << false << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.selectedItems prepend, resolve prepended")
- << listModelSource[i]
- << QString("selectedItems.insert(0, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(0, {\"number\": \"seven\"}); "
- "selectedItems.resolve(selectedItems.get(0), items.get(0)) }")
- << 4 << 5 << 5 << 0 << true << false << true << true << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.selectedItems prepend, resolve appended")
- << listModelSource[i]
- << QString("selectedItems.insert(0, {\"number\": \"eight\"})")
- << QString("{ listModel.append({\"number\": \"seven\"}); "
- "selectedItems.resolve(selectedItems.get(0), items.get(4)) }")
- << 4 << 5 << 5 << 4 << true << false << true << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "seven");
-
- QTest::newRow("ListModel.selectedItems prepend, resolve inserted")
- << listModelSource[i]
- << QString("selectedItems.insert(0, {\"number\": \"eight\"})")
- << QString("{ listModel.insert(2, {\"number\": \"seven\"}); "
- "selectedItems.resolve(selectedItems.get(0), items.get(2)) }")
- << 4 << 5 << 5 << 2 << true << false << true << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "seven" << "three" << "four");
-
- QTest::newRow("ListModel.selectedItems append, resolve prepended")
- << listModelSource[i]
- << QString("selectedItems.insert({\"number\": \"eight\"})")
- << QString("{ listModel.insert(0, {\"number\": \"seven\"}); "
- "selectedItems.resolve(selectedItems.get(0), items.get(0)) }")
- << 4 << 5 << 5 << 0 << true << false << true << true << true
- << QString("number")
- << (QStringList() << "seven" << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.selectedItems append, resolve appended")
- << listModelSource[i]
- << QString("selectedItems.insert({\"number\": \"eight\"})")
- << QString("{ listModel.append({\"number\": \"seven\"}); "
- "selectedItems.resolve(selectedItems.get(0), items.get(4)) }")
- << 4 << 5 << 5 << 4 << true << false << true << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "three" << "four" << "seven");
-
- QTest::newRow("ListModel.selectedItems append, resolve inserted")
- << listModelSource[i]
- << QString("selectedItems.insert({\"number\": \"eight\"})")
- << QString("{ listModel.insert(2, {\"number\": \"seven\"}); "
- "selectedItems.resolve(selectedItems.get(0), items.get(2)) }")
- << 4 << 5 << 5 << 2 << true << false << true << true << true
- << QString("number")
- << (QStringList() << "one" << "two" << "seven" << "three" << "four");
-
- // AbstractItemModel (Single Role)
- QTest::newRow("ListModel.items prepend, resolve prepended")
- << singleRoleSource[i]
- << QString("items.insert(0, {\"name\": \"eight\"})")
- << QString("{ items.resolve(0, 1) }")
- << 5 << 4 << 4 << 0 << true << false << true << false << true
- << QString("name")
- << (QStringList() << "one" << "two" << "three" << "four");
-
-
- QTest::newRow("ListModel.items append, resolve appended")
- << singleRoleSource[i]
- << QString("items.insert({\"name\": \"eight\"})")
- << QString("{ items.resolve(4, 3) }")
- << 5 << 4 << 4 << 3 << true << false << true << false << true
- << QString("name")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- QTest::newRow("ListModel.items insert, resolve inserted")
- << singleRoleSource[i]
- << QString("items.insert(2, {\"name\": \"eight\"})")
- << QString("{ items.resolve(2, 3) }")
- << 5 << 4 << 4 << 2 << true << false << true << false << true
- << QString("name")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- // AbstractItemModel (Single Role)
- QTest::newRow("AbstractItemModel.items prepend, resolve prepended")
- << singleRoleSource[i]
- << QString("items.insert(0, {\"name\": \"eight\"})")
- << QString("{ items.resolve(0, 1) }")
- << 5 << 4 << 4 << 0 << true << false << true << false << true
- << QString("name")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items append, resolve appended")
- << singleRoleSource[i]
- << QString("items.insert({\"name\": \"eight\"})")
- << QString("{ items.resolve(4, 3) }")
- << 5 << 4 << 4 << 3 << true << false << true << false << true
- << QString("name")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- QTest::newRow("AbstractItemModel.items insert, resolve inserted")
- << singleRoleSource[i]
- << QString("items.insert(2, {\"name\": \"eight\"})")
- << QString("{ items.resolve(2, 3) }")
- << 5 << 4 << 4 << 2 << true << false << true << false << true
- << QString("name")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- // AbstractItemModel (Multiple Roles)
- QTest::newRow("StandardItemModel.items prepend, resolve prepended")
- << multipleRoleSource[i]
- << QString("items.insert(0, {\"display\": \"Row 8 Item\"})")
- << QString("{ items.resolve(0, 1) }")
- << 5 << 4 << 4 << 0 << true << false << true << false << false
- << QString("display")
- << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items append, resolve appended")
- << multipleRoleSource[i]
- << QString("items.insert({\"display\": \"Row 8 Item\"})")
- << QString("{ items.resolve(4, 3) }")
- << 5 << 4 << 4 << 3 << true << false << true << false << false
- << QString("display")
- << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- QTest::newRow("StandardItemModel.items insert, resolve inserted")
- << multipleRoleSource[i]
- << QString("items.insert(2, {\"display\": \"Row 8 Item\"})")
- << QString("{ items.resolve(2, 3) }")
- << 5 << 4 << 4 << 2 << true << false << true << false << false
- << QString("display")
- << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
-
- // StringList
- QTest::newRow("StringList.items prepend, resolve prepended")
- << stringListSource[i]
- << QString("items.insert(0, {\"modelData\": \"eight\"})")
- << QString("{ items.resolve(0, 1) }")
- << 5 << 4 << 4 << 0 << true << false << true << false << false
- << QString("modelData")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- QTest::newRow("StringList.items append, resolve appended")
- << stringListSource[i]
- << QString("items.insert({\"modelData\": \"eight\"})")
- << QString("{ items.resolve(4, 3) }")
- << 5 << 4 << 4 << 3 << true << false << true << false << false
- << QString("modelData")
- << (QStringList() << "one" << "two" << "three" << "four");
-
- QTest::newRow("StringList.items insert, resolve inserted")
- << stringListSource[i]
- << QString("items.insert(2, {\"modelData\": \"eight\"})")
- << QString("{ items.resolve(2, 3) }")
- << 5 << 4 << 4 << 2 << true << false << true << false << false
- << QString("modelData")
- << (QStringList() << "one" << "two" << "three" << "four");
- }
-}
-
-void tst_qquickvisualdatamodel::resolve()
-{
- QFETCH(QUrl, source);
- QFETCH(QString, setupExpression);
- QFETCH(QString, resolveExpression);
- QFETCH(int, unresolvedCount);
- QFETCH(int, modelCount);
- QFETCH(int, visualCount);
- QFETCH(int, index);
- QFETCH(bool, inItems);
- QFETCH(bool, persisted);
- QFETCH(bool, visible);
- QFETCH(bool, selected);
- QFETCH(bool, modelData);
- QFETCH(QString, property);
- QFETCH(QStringList, propertyData);
-
- QQuickCanvas canvas;
-
- QDeclarativeComponent component(&engine);
- component.loadUrl(source);
- QScopedPointer<QObject> object(component.create());
- QQuickListView *listView = qobject_cast<QQuickListView *>(object.data());
- QVERIFY(listView);
- listView->setParentItem(canvas.rootItem());
-
- QQuickItem *contentItem = listView->contentItem();
- QVERIFY(contentItem);
-
- QObject *visualModel = listView->findChild<QObject *>("visualModel");
- QVERIFY(visualModel);
-
- evaluate<void>(visualModel, setupExpression);
- QCOMPARE(evaluate<int>(listView, "count"), unresolvedCount);
-
- evaluate<void>(visualModel, resolveExpression);
-
- QCOMPARE(evaluate<int>(listView, "count"), inItems ? visualCount : modelCount);
- QCOMPARE(evaluate<int>(visualModel, "count"), inItems ? visualCount : modelCount);
- QCOMPARE(evaluate<int>(visualModel, "items.count"), inItems ? visualCount : modelCount);
- QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), persisted ? 1 : 0);
- QCOMPARE(evaluate<int>(visualModel, "visibleItems.count"), visible ? visualCount : modelCount);
- QCOMPARE(evaluate<int>(visualModel, "selectedItems.count"), selected ? 1 : 0);
-
- QCOMPARE(propertyData.count(), visualCount);
- for (int i = 0; i < visualCount; ++i) {
- int modelIndex = i;
-
- const int itemsIndex = inItems || i <= index ? i : i - 1;
- QString get;
-
- if (i != index) {
- get = QString("items.get(%1)").arg(itemsIndex);
-
- QQuickItem *item = findItem<QQuickItem>(contentItem, "delegate", modelIndex);
- QVERIFY(item);
-
- QCOMPARE(evaluate<int>(item, "test1"), modelIndex);
- QCOMPARE(evaluate<int>(item, "test2"), modelIndex);
- QCOMPARE(evaluate<QString>(item, "test3"), propertyData.at(i));
- QCOMPARE(evaluate<QString>(item, "test4"), propertyData.at(i));
-
- if (modelData) {
- QCOMPARE(evaluate<QString>(item, "test5"), propertyData.at(i));
- QCOMPARE(evaluate<QString>(item, "test6"), propertyData.at(i));
- }
-
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inItems"), true);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inPersistedItems"), false);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inVisible"), true);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inSelected"), false);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.isUnresolved"), false);
-
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.itemsIndex"), itemsIndex);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.persistedItemsIndex"), persisted && i > index ? 1 : 0);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.visibleIndex"), visible || i <= index ? i : i - 1);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.selectedIndex"), selected && i > index ? 1 : 0);
- } else if (inItems) {
- get = QString("items.get(%1)").arg(index);
- } else if (persisted) {
- get = "persistedItems.get(0)";
- } else if (visible) {
- get = QString("visibleItems.get(%1)").arg(index);
- } else if (selected) {
- get = "selectedItems.get(0)";
- } else {
- continue;
- }
-
- QCOMPARE(evaluate<int>(visualModel, get + ".model.index"), modelIndex);
-
- QCOMPARE(evaluate<QString>(visualModel, get + ".model." + property), propertyData.at(i));
-
- QCOMPARE(evaluate<bool>(visualModel, get + ".inItems"), inItems || i != index);
- QCOMPARE(evaluate<bool>(visualModel, get + ".inPersistedItems"), persisted && i == index);
- QCOMPARE(evaluate<bool>(visualModel, get + ".inVisible"), visible || i != index);
- QCOMPARE(evaluate<bool>(visualModel, get + ".inSelected"), selected && i == index);
- QCOMPARE(evaluate<bool>(visualModel, get + ".isUnresolved"), false);
-
- QCOMPARE(evaluate<int>(visualModel, get + ".itemsIndex"), inItems || i <= index ? i : i - 1);
- QCOMPARE(evaluate<int>(visualModel, get + ".persistedItemsIndex"), persisted && i > index ? 1 : 0);
- QCOMPARE(evaluate<int>(visualModel, get + ".visibleIndex"), visible || i <= index ? i : i - 1);
- QCOMPARE(evaluate<int>(visualModel, get + ".selectedIndex"), selected && i > index ? 1 : 0);
- }
-
- QObject *item = 0;
-
- if (inItems)
- item = evaluate<QObject *>(visualModel, QString("items.create(%1)").arg(index));
- else if (persisted)
- item = evaluate<QObject *>(visualModel, QString("persistedItems.create(%1)").arg(0));
- else if (visible)
- item = evaluate<QObject *>(visualModel, QString("visibleItems.create(%1)").arg(index));
- else if (selected)
- item = evaluate<QObject *>(visualModel, QString("selectedItems.create(%1)").arg(0));
- else
- return;
-
- QVERIFY(item);
-
- QCOMPARE(evaluate<int>(item, "test1"), index);
- QCOMPARE(evaluate<int>(item, "test2"), index);
- QCOMPARE(evaluate<QString>(item, "test3"), propertyData.at(index));
- QCOMPARE(evaluate<QString>(item, "test4"), propertyData.at(index));
-
- if (modelData) {
- QCOMPARE(evaluate<QString>(item, "test5"), propertyData.at(index));
- QCOMPARE(evaluate<QString>(item, "test6"), propertyData.at(index));
- }
-
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inItems"), inItems);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inPersistedItems"), true);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inVisible"), visible);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inSelected"), selected);
- QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.isUnresolved"), false);
-
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.itemsIndex"), index);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.persistedItemsIndex"), 0);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.visibleIndex"), index);
- QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.selectedIndex"), 0);
-}
-
-void tst_qquickvisualdatamodel::warnings_data()
-{
- QTest::addColumn<QUrl>("source");
- QTest::addColumn<QString>("expression");
- QTest::addColumn<QString>("warning");
- QTest::addColumn<int>("count");
-
- QTest::newRow("insert < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.insert(-2, {\"number\": \"eight\"})")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range"))
- << 4;
-
- QTest::newRow("insert > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.insert(8, {\"number\": \"eight\"})")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range"))
- << 4;
-
- QTest::newRow("create < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.create(-2, {\"number\": \"eight\"})")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range"))
- << 4;
-
- QTest::newRow("create > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.create(8, {\"number\": \"eight\"})")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range"))
- << 4;
-
- QTest::newRow("resolve from < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.resolve(-2, 3)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range"))
- << 4;
-
- QTest::newRow("resolve from > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.resolve(8, 3)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range"))
- << 4;
-
- QTest::newRow("resolve to < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.resolve(3, -2)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range"))
- << 4;
-
- QTest::newRow("resolve to > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.resolve(3, 8)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range"))
- << 4;
-
- QTest::newRow("resolve from invalid index")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.resolve(\"two\", 3)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index invalid"))
- << 4;
-
- QTest::newRow("resolve to invalid index")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.resolve(3, \"two\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index invalid"))
- << 4;
-
- QTest::newRow("resolve already resolved item")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.resolve(3, 2)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from is not an unresolved item"))
- << 4;
-
- QTest::newRow("resolve already resolved item")
- << testFileUrl("listmodelproperties.qml")
- << QString("{ items.insert(0, {\"number\": \"eight\"});"
- "items.insert(1, {\"number\": \"seven\"});"
- "items.resolve(0, 1)}")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to is not a model item"))
- << 6;
-
- QTest::newRow("remove index < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.remove(-2, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range"))
- << 4;
-
- QTest::newRow("remove index == length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.remove(4, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range"))
- << 4;
-
- QTest::newRow("remove index > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.remove(9, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range"))
- << 4;
-
- QTest::newRow("remove invalid index")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.remove(\"nine\", 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid index"))
- << 4;
-
- QTest::newRow("remove count < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.remove(1, -2)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count"))
- << 4;
-
- QTest::newRow("remove index + count > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.remove(2, 4, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count"))
- << 4;
-
- QTest::newRow("addGroups index < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.addGroups(-2, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range"))
- << 4;
-
- QTest::newRow("addGroups index == length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.addGroups(4, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range"))
- << 4;
-
- QTest::newRow("addGroups index > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.addGroups(9, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range"))
- << 4;
-
- QTest::newRow("addGroups count < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.addGroups(1, -2, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count"))
- << 4;
-
- QTest::newRow("addGroups index + count > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.addGroups(2, 4, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count"))
- << 4;
-
- QTest::newRow("removeGroups index < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.removeGroups(-2, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range"))
- << 4;
-
- QTest::newRow("removeGroups index == length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.removeGroups(4, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range"))
- << 4;
-
- QTest::newRow("removeGroups index > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.removeGroups(9, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range"))
- << 4;
-
- QTest::newRow("removeGroups count < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.removeGroups(1, -2, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count"))
- << 4;
-
- QTest::newRow("removeGroups index + count > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.removeGroups(2, 4, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count"))
- << 4;
-
- QTest::newRow("setGroups index < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.setGroups(-2, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range"))
- << 4;
-
- QTest::newRow("setGroups index == length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.setGroups(4, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range"))
- << 4;
-
- QTest::newRow("setGroups index > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.setGroups(9, 1, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range"))
- << 4;
-
- QTest::newRow("setGroups count < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.setGroups(1, -2, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count"))
- << 4;
-
- QTest::newRow("setGroups index + count > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.setGroups(2, 4, \"selected\")")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count"))
- << 4;
-
- QTest::newRow("move from < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(-2, 1, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
- << 4;
-
- QTest::newRow("move from == length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(4, 1, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
- << 4;
-
- QTest::newRow("move from > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(9, 1, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
- << 4;
-
- QTest::newRow("move invalid from")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(\"nine\", 1, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid from index"))
- << 4;
-
- QTest::newRow("move to < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(1, -2, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range"))
- << 4;
-
- QTest::newRow("move to == length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(1, 4, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range"))
- << 4;
-
- QTest::newRow("move to > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(1, 9, 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range"))
- << 4;
-
- QTest::newRow("move invalid to")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(1, \"nine\", 1)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid to index"))
- << 4;
-
- QTest::newRow("move count < 0")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(1, 1, -2)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid count"))
- << 4;
-
- QTest::newRow("move from + count > length")
- << testFileUrl("listmodelproperties.qml")
- << QString("items.move(2, 1, 4)")
- << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
- << 4;
-}
-
-void tst_qquickvisualdatamodel::warnings()
-{
- QFETCH(QUrl, source);
- QFETCH(QString, expression);
- QFETCH(QString, warning);
- QFETCH(int, count);
-
- QQuickCanvas canvas;
-
- QDeclarativeComponent component(&engine);
- component.loadUrl(source);
- QScopedPointer<QObject> object(component.create());
- QQuickListView *listView = qobject_cast<QQuickListView *>(object.data());
- QVERIFY(listView);
- listView->setParentItem(canvas.rootItem());
-
- QQuickItem *contentItem = listView->contentItem();
- QVERIFY(contentItem);
-
- QObject *visualModel = evaluate<QObject *>(listView, "model");
- QVERIFY(visualModel);
-
- QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
-
- evaluate<void>(visualModel, expression);
- QCOMPARE(evaluate<int>(listView, "count"), count);
-}
-
-
-QTEST_MAIN(tst_qquickvisualdatamodel)
-
-#include "tst_qquickvisualdatamodel.moc"
diff --git a/tests/auto/qtquick2/qtquick2.pro b/tests/auto/qtquick2/qtquick2.pro
deleted file mode 100644
index 7acd75f69e..0000000000
--- a/tests/auto/qtquick2/qtquick2.pro
+++ /dev/null
@@ -1,70 +0,0 @@
-TEMPLATE = subdirs
-
-PUBLICTESTS += \
- examples \
- geometry \
- nodes \
- rendernode \
- qdeclarativepixmapcache
-
-# This test requires the qtconcurrent module
-!contains(QT_CONFIG, concurrent):PUBLICTESTS -= qdeclarativepixmapcache
-
-PRIVATETESTS += \
- qdeclarativeanimations \
- qdeclarativeapplication \
- qdeclarativebehaviors \
- qdeclarativefontloader \
- qdeclarativepath \
- qdeclarativesmoothedanimation \
- qdeclarativespringanimation \
- qdeclarativestyledtext \
- qdeclarativestates \
- qdeclarativesystempalette \
- qdeclarativetimer \
- qdeclarativexmllistmodel
-
-# This test requires the xmlpatterns module
-!contains(QT_CONFIG,xmlpatterns):PRIVATETESTS -= qdeclarativexmllistmodel
-
-QUICKTESTS = \
- qquickaccessible \
- qquickanchors \
- qquickanimatedimage \
- qquickborderimage \
- qquickcanvas \
- qquickdrag \
- qquickdroparea \
- qquickflickable \
- qquickflipable \
- qquickfocusscope \
- qquickgridview \
- qquickimage \
- qquickitem \
- qquickitem2 \
- qquickitemlayer \
- qquicklistview \
- qquickloader \
- qquickmousearea \
- qquickmultipointtoucharea \
- qquickpathview \
- qquickpincharea \
- qquickpositioners \
- qquickrepeater \
- qquickshadereffect \
- qquickspriteimage \
- qquicktext \
- qquicktextedit \
- qquicktextinput \
- qquickvisualdatamodel \
- qquickview \
- qquickcanvasitem \
- qquickscreen \
-
-
-SUBDIRS += $$PUBLICTESTS
-
-contains(QT_CONFIG, private_tests) {
- SUBDIRS += $$PRIVATETESTS
- SUBDIRS += $$QUICKTESTS
-}
diff --git a/tests/auto/qtquick2/rendernode/rendernode.pro b/tests/auto/qtquick2/rendernode/rendernode.pro
deleted file mode 100644
index f915a58900..0000000000
--- a/tests/auto/qtquick2/rendernode/rendernode.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-CONFIG += testcase
-TARGET = tst_rendernode
-SOURCES += tst_rendernode.cpp
-
-macx:CONFIG -= app_bundle
-
-testDataFiles.files = data
-testDataFiles.path = .
-DEPLOYMENT += testDataFiles
-
-include(../../shared/util.pri)
-
-CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private quick-private testlib
-
-OTHER_FILES += \
- data/RenderOrder.qml \
- data/MessUpState.qml \
diff --git a/tests/auto/qtquick2/rendernode/tst_rendernode.cpp b/tests/auto/qtquick2/rendernode/tst_rendernode.cpp
deleted file mode 100644
index f0e385152e..0000000000
--- a/tests/auto/qtquick2/rendernode/tst_rendernode.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-
-#include <QtQuick/qquickitem.h>
-#include <QtQuick/qquickview.h>
-#include <QtGui/qopenglcontext.h>
-#include <private/qsgrendernode_p.h>
-
-#include "../../shared/util.h"
-
-class tst_rendernode: public QDeclarativeDataTest
-{
- Q_OBJECT
-public:
- tst_rendernode();
-
- QImage runTest(const QString &url)
- {
- QQuickView view;
- view.setSource(QUrl(url));
-
- view.show();
- QTest::qWaitForWindowShown(&view);
-
- return view.grabFrameBuffer();
- }
-
-private slots:
- void renderOrder();
- void messUpState();
-};
-
-class ClearNode : public QSGRenderNode
-{
-public:
- virtual StateFlags changedStates()
- {
- return ColorState;
- }
-
- virtual void render(const RenderState &)
- {
- // If clip has been set, scissoring will make sure the right area is cleared.
- glClearColor(color.redF(), color.greenF(), color.blueF(), 1.0f);
- glClear(GL_COLOR_BUFFER_BIT);
- }
-
- QColor color;
-};
-
-class ClearItem : public QQuickItem
-{
- Q_OBJECT
- Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
-public:
- ClearItem() : m_color(Qt::black)
- {
- setFlag(ItemHasContents, true);
- }
-
- QColor color() const { return m_color; }
- void setColor(const QColor &color)
- {
- if (color == m_color)
- return;
- m_color = color;
- emit colorChanged();
- }
-
-protected:
- virtual QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
- {
- ClearNode *node = static_cast<ClearNode *>(oldNode);
- if (!node)
- node = new ClearNode;
- node->color = m_color;
- return node;
- }
-
-Q_SIGNALS:
- void colorChanged();
-
-private:
- QColor m_color;
-};
-
-class MessUpNode : public QSGRenderNode
-{
-public:
- virtual StateFlags changedStates()
- {
- return StateFlags(DepthState) | StencilState | ScissorState | ColorState | BlendState
- | CullState | ViewportState;
- }
-
- virtual void render(const RenderState &)
- {
- // Don't draw anything, just mess up the state
- glViewport(10, 10, 10, 10);
- glDisable(GL_SCISSOR_TEST);
- glDepthMask(true);
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_EQUAL);
-#if defined(QT_OPENGL_ES)
- glClearDepthf(1);
-#else
- glClearDepth(1);
-#endif
- glClearStencil(42);
- glClearColor(1.0f, 0.5f, 1.0f, 0.0f);
- glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- glEnable(GL_SCISSOR_TEST);
- glScissor(190, 190, 10, 10);
- glStencilFunc(GL_EQUAL, 28, 0xff);
- glBlendFunc(GL_ZERO, GL_ZERO);
- GLint frontFace;
- glGetIntegerv(GL_FRONT_FACE, &frontFace);
- glFrontFace(frontFace == GL_CW ? GL_CCW : GL_CW);
- glEnable(GL_CULL_FACE);
- }
-};
-
-class MessUpItem : public QQuickItem
-{
- Q_OBJECT
-public:
- MessUpItem()
- {
- setFlag(ItemHasContents, true);
- }
-
-protected:
- virtual QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
- {
- MessUpNode *node = static_cast<MessUpNode *>(oldNode);
- if (!node)
- node = new MessUpNode;
- return node;
- }
-};
-
-tst_rendernode::tst_rendernode()
-{
- qmlRegisterType<ClearItem>("Test", 1, 0, "ClearItem");
- qmlRegisterType<MessUpItem>("Test", 1, 0, "MessUpItem");
-}
-
-static void fuzzyCompareColor(QRgb x, QRgb y)
-{
- QVERIFY(qAbs(qRed(x) - qRed(y)) < 4);
- QVERIFY(qAbs(qGreen(x) - qGreen(y)) < 4);
- QVERIFY(qAbs(qBlue(x) - qBlue(y)) < 4);
-}
-
-void tst_rendernode::renderOrder()
-{
- QImage fb = runTest(testFile("RenderOrder.qml"));
- int x1 = fb.width() / 8;
- int x2 = fb.width() * 3 / 8;
- int x3 = fb.width() * 5 / 8;
- int x4 = fb.width() * 7 / 8;
- int y1 = fb.height() / 8;
- int y2 = fb.height() * 3 / 8;
- int y3 = fb.height() * 5 / 8;
- int y4 = fb.height() * 7 / 8;
-
- fuzzyCompareColor(fb.pixel(x1, y1), qRgb(0x7f, 0x00, 0x00));
- QCOMPARE(fb.pixel(x2, y2), qRgb(0xff, 0xff, 0xff));
- QCOMPARE(fb.pixel(x3, y2), qRgb(0x00, 0x00, 0xff));
- QCOMPARE(fb.pixel(x4, y1), qRgb(0x00, 0x00, 0xff));
- QCOMPARE(fb.pixel(x1, y4), qRgb(0xff, 0x00, 0x00));
- QCOMPARE(fb.pixel(x2, y3), qRgb(0xff, 0xff, 0xff));
- fuzzyCompareColor(fb.pixel(x3, y3), qRgb(0x7f, 0x7f, 0xff));
- fuzzyCompareColor(fb.pixel(x4, y4), qRgb(0x00, 0x00, 0x7f));
-}
-
-void tst_rendernode::messUpState()
-{
- QImage fb = runTest(testFile("MessUpState.qml"));
- int x1 = 0;
- int x2 = fb.width() / 2;
- int x3 = fb.width() - 1;
- int y1 = 0;
- int y2 = fb.height() * 3 / 16;
- int y3 = fb.height() / 2;
- int y4 = fb.height() * 13 / 16;
- int y5 = fb.height() - 1;
-
- QCOMPARE(fb.pixel(x1, y3), qRgb(0xff, 0xff, 0xff));
- QCOMPARE(fb.pixel(x3, y3), qRgb(0xff, 0xff, 0xff));
-
- QCOMPARE(fb.pixel(x2, y1), qRgb(0x00, 0x00, 0x00));
- QCOMPARE(fb.pixel(x2, y2), qRgb(0x00, 0x00, 0x00));
- fuzzyCompareColor(fb.pixel(x2, y3), qRgb(0x7f, 0x00, 0x7f));
- QCOMPARE(fb.pixel(x2, y4), qRgb(0x00, 0x00, 0x00));
- QCOMPARE(fb.pixel(x2, y5), qRgb(0x00, 0x00, 0x00));
-}
-
-
-QTEST_MAIN(tst_rendernode)
-
-#include "tst_rendernode.moc"
diff --git a/tests/auto/qtquick2/shared/util.pri b/tests/auto/qtquick2/shared/util.pri
deleted file mode 100644
index eddbe4b6aa..0000000000
--- a/tests/auto/qtquick2/shared/util.pri
+++ /dev/null
@@ -1,7 +0,0 @@
-
-HEADERS += $$PWD/visualtestutil.h \
- $$PWD/viewtestutil.h
-SOURCES += $$PWD/visualtestutil.cpp \
- $$PWD/viewtestutil.cpp
-
-DEFINES += QT_DECLARATIVETEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\"
diff --git a/tests/auto/qtquick2/shared/viewtestutil.cpp b/tests/auto/qtquick2/shared/viewtestutil.cpp
deleted file mode 100644
index eeef23001e..0000000000
--- a/tests/auto/qtquick2/shared/viewtestutil.cpp
+++ /dev/null
@@ -1,493 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "viewtestutil.h"
-
-#include <QtQuick/QQuickView>
-
-#include <QtTest/QTest>
-
-template<typename T>
-static void qdeclarativemodelviewstestutil_move(int from, int to, int n, T *items)
-{
- if (from > to) {
- // Only move forwards - flip if backwards moving
- int tfrom = from;
- int tto = to;
- from = tto;
- to = tto+n;
- n = tfrom-tto;
- }
-
- T replaced;
- int i=0;
- typename T::ConstIterator it=items->begin(); it += from+n;
- for (; i<to-from; ++i,++it)
- replaced.append(*it);
- i=0;
- it=items->begin(); it += from;
- for (; i<n; ++i,++it)
- replaced.append(*it);
- typename T::ConstIterator f=replaced.begin();
- typename T::Iterator t=items->begin(); t += from;
- for (; f != replaced.end(); ++f, ++t)
- *t = *f;
-}
-
-QQuickView *QQuickViewTestUtil::createView()
-{
- QQuickView *canvas = new QQuickView(0);
- canvas->setGeometry(0,0,240,320);
-
- return canvas;
-}
-
-void QQuickViewTestUtil::flick(QQuickView *canvas, const QPoint &from, const QPoint &to, int duration)
-{
- const int pointCount = 5;
- QPoint diff = to - from;
-
- // send press, five equally spaced moves, and release.
- QTest::mousePress(canvas, Qt::LeftButton, 0, from);
-
- for (int i = 0; i < pointCount; ++i) {
- QMouseEvent mv(QEvent::MouseMove, from + (i+1)*diff/pointCount, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
- QGuiApplication::sendEvent(canvas, &mv);
- QTest::qWait(duration/pointCount);
- QCoreApplication::processEvents();
- }
-
- QTest::mouseRelease(canvas, Qt::LeftButton, 0, to);
- QTest::qWait(50);
-}
-
-QList<int> QQuickViewTestUtil::adjustIndexesForAddDisplaced(const QList<int> &indexes, int index, int count)
-{
- QList<int> result;
- for (int i=0; i<indexes.count(); i++) {
- int num = indexes[i];
- if (num >= index) {
- num += count;
- }
- result << num;
- }
- return result;
-}
-
-QList<int> QQuickViewTestUtil::adjustIndexesForMove(const QList<int> &indexes, int from, int to, int count)
-{
- QList<int> result;
- for (int i=0; i<indexes.count(); i++) {
- int num = indexes[i];
- if (from < to) {
- if (num >= from && num < from + count)
- num += (to - from); // target
- else if (num >= from && num < to + count)
- num -= count; // displaced
- } else if (from > to) {
- if (num >= from && num < from + count)
- num -= (from - to); // target
- else if (num >= to && num < from + count)
- num += count; // displaced
- }
- result << num;
- }
- return result;
-}
-
-QList<int> QQuickViewTestUtil::adjustIndexesForRemoveDisplaced(const QList<int> &indexes, int index, int count)
-{
- QList<int> result;
- for (int i=0; i<indexes.count(); i++) {
- int num = indexes[i];
- if (num >= index)
- num -= count;
- result << num;
- }
- return result;
-}
-
-
-QQuickViewTestUtil::QmlListModel::QmlListModel(QObject *parent)
- : QListModelInterface(parent)
-{
-}
-
-QQuickViewTestUtil::QmlListModel::~QmlListModel()
-{
-}
-
-QString QQuickViewTestUtil::QmlListModel::name(int index) const
-{
- return list.at(index).first;
-}
-
-QString QQuickViewTestUtil::QmlListModel::number(int index) const
-{
- return list.at(index).second;
-}
-
-int QQuickViewTestUtil::QmlListModel::count() const
-{
- return list.count();
-}
-
-QList<int> QQuickViewTestUtil::QmlListModel::roles() const
-{
- return QList<int>() << Name << Number;
-}
-
-QString QQuickViewTestUtil::QmlListModel::toString(int role) const
-{
- switch (role) {
- case Name:
- return "name";
- case Number:
- return "number";
- default:
- return "";
- }
-}
-
-QVariant QQuickViewTestUtil::QmlListModel::data(int index, int role) const
-{
- if (role==0)
- return list.at(index).first;
- if (role==1)
- return list.at(index).second;
- return QVariant();
-}
-
-QHash<int, QVariant> QQuickViewTestUtil::QmlListModel::data(int index, const QList<int> &roles) const
-{
- QHash<int,QVariant> returnHash;
-
- for (int i = 0; i < roles.size(); ++i) {
- int role = roles.at(i);
- QVariant info;
- switch (role) {
- case Name:
- info = list.at(index).first;
- break;
- case Number:
- info = list.at(index).second;
- break;
- default:
- break;
- }
- returnHash.insert(role, info);
- }
- return returnHash;
-}
-
-void QQuickViewTestUtil::QmlListModel::addItem(const QString &name, const QString &number)
-{
- list.append(QPair<QString,QString>(name, number));
- emit itemsInserted(list.count()-1, 1);
-}
-
-void QQuickViewTestUtil::QmlListModel::insertItem(int index, const QString &name, const QString &number)
-{
- list.insert(index, QPair<QString,QString>(name, number));
- emit itemsInserted(index, 1);
-}
-
-void QQuickViewTestUtil::QmlListModel::insertItems(int index, const QList<QPair<QString, QString> > &items)
-{
- for (int i=0; i<items.count(); i++)
- list.insert(index + i, QPair<QString,QString>(items[i].first, items[i].second));
- emit itemsInserted(index, items.count());
-}
-
-void QQuickViewTestUtil::QmlListModel::removeItem(int index)
-{
- list.removeAt(index);
- emit itemsRemoved(index, 1);
-}
-
-void QQuickViewTestUtil::QmlListModel::removeItems(int index, int count)
-{
- int c = count;
- while (c--)
- list.removeAt(index);
- emit itemsRemoved(index, count);
-}
-
-void QQuickViewTestUtil::QmlListModel::moveItem(int from, int to)
-{
- list.move(from, to);
- emit itemsMoved(from, to, 1);
-}
-
-void QQuickViewTestUtil::QmlListModel::moveItems(int from, int to, int count)
-{
- qdeclarativemodelviewstestutil_move(from, to, count, &list);
- emit itemsMoved(from, to, count);
-}
-
-void QQuickViewTestUtil::QmlListModel::modifyItem(int index, const QString &name, const QString &number)
-{
- list[index] = QPair<QString,QString>(name, number);
- emit itemsChanged(index, 1, roles());
-}
-
-void QQuickViewTestUtil::QmlListModel::clear() {
- int count = list.count();
- list.clear();
- emit itemsRemoved(0, count);
-}
-
-void QQuickViewTestUtil::QmlListModel::matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2) {
- for (int i=0; i<other.count(); i++) {
- QVERIFY2(list.contains(other[i]),
- QTest::toString(other[i].first + " " + other[i].second + " " + error1));
- }
- for (int i=0; i<list.count(); i++) {
- QVERIFY2(other.contains(list[i]),
- QTest::toString(list[i].first + " " + list[i].second + " " + error2));
- }
-}
-
-
-QQuickViewTestUtil::QaimModel::QaimModel(QObject *parent)
- : QAbstractListModel(parent)
-{
- QHash<int, QByteArray> roles;
- roles[Name] = "name";
- roles[Number] = "number";
- setRoleNames(roles);
-}
-
-int QQuickViewTestUtil::QaimModel::rowCount(const QModelIndex &parent) const
-{
- Q_UNUSED(parent);
- return list.count();
-}
-
-QVariant QQuickViewTestUtil::QaimModel::data(const QModelIndex &index, int role) const
-{
- QVariant rv;
- if (role == Name)
- rv = list.at(index.row()).first;
- else if (role == Number)
- rv = list.at(index.row()).second;
-
- return rv;
-}
-
-int QQuickViewTestUtil::QaimModel::count() const
-{
- return rowCount();
-}
-
-QString QQuickViewTestUtil::QaimModel::name(int index) const
-{
- return list.at(index).first;
-}
-
-QString QQuickViewTestUtil::QaimModel::number(int index) const
-{
- return list.at(index).second;
-}
-
-void QQuickViewTestUtil::QaimModel::addItem(const QString &name, const QString &number)
-{
- emit beginInsertRows(QModelIndex(), list.count(), list.count());
- list.append(QPair<QString,QString>(name, number));
- emit endInsertRows();
-}
-
-void QQuickViewTestUtil::QaimModel::addItems(const QList<QPair<QString, QString> > &items)
-{
- emit beginInsertRows(QModelIndex(), list.count(), list.count()+items.count()-1);
- for (int i=0; i<items.count(); i++)
- list.append(QPair<QString,QString>(items[i].first, items[i].second));
- emit endInsertRows();
-}
-
-void QQuickViewTestUtil::QaimModel::insertItem(int index, const QString &name, const QString &number)
-{
- emit beginInsertRows(QModelIndex(), index, index);
- list.insert(index, QPair<QString,QString>(name, number));
- emit endInsertRows();
-}
-
-void QQuickViewTestUtil::QaimModel::insertItems(int index, const QList<QPair<QString, QString> > &items)
-{
- emit beginInsertRows(QModelIndex(), index, index+items.count()-1);
- for (int i=0; i<items.count(); i++)
- list.insert(index + i, QPair<QString,QString>(items[i].first, items[i].second));
- emit endInsertRows();
-}
-
-void QQuickViewTestUtil::QaimModel::removeItem(int index)
-{
- emit beginRemoveRows(QModelIndex(), index, index);
- list.removeAt(index);
- emit endRemoveRows();
-}
-
-void QQuickViewTestUtil::QaimModel::removeItems(int index, int count)
-{
- emit beginRemoveRows(QModelIndex(), index, index+count-1);
- while (count--)
- list.removeAt(index);
- emit endRemoveRows();
-}
-
-void QQuickViewTestUtil::QaimModel::moveItem(int from, int to)
-{
- emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
- list.move(from, to);
- emit endMoveRows();
-}
-
-void QQuickViewTestUtil::QaimModel::moveItems(int from, int to, int count)
-{
- emit beginMoveRows(QModelIndex(), from, from+count-1, QModelIndex(), to > from ? to+count : to);
- qdeclarativemodelviewstestutil_move(from, to, count, &list);
- emit endMoveRows();
-}
-
-void QQuickViewTestUtil::QaimModel::modifyItem(int idx, const QString &name, const QString &number)
-{
- list[idx] = QPair<QString,QString>(name, number);
- emit dataChanged(index(idx,0), index(idx,0));
-}
-
-void QQuickViewTestUtil::QaimModel::clear()
-{
- int count = list.count();
- emit beginRemoveRows(QModelIndex(), 0, count-1);
- list.clear();
- emit endRemoveRows();
-}
-
-void QQuickViewTestUtil::QaimModel::reset()
-{
- emit beginResetModel();
- emit endResetModel();
-}
-
-void QQuickViewTestUtil::QaimModel::matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2) {
- for (int i=0; i<other.count(); i++) {
- QVERIFY2(list.contains(other[i]),
- QTest::toString(other[i].first + " " + other[i].second + " " + error1));
- }
- for (int i=0; i<list.count(); i++) {
- QVERIFY2(other.contains(list[i]),
- QTest::toString(list[i].first + " " + list[i].second + " " + error2));
- }
-}
-
-
-
-QQuickViewTestUtil::ListRange::ListRange()
- : valid(false)
-{
-}
-
-QQuickViewTestUtil::ListRange::ListRange(const ListRange &other)
- : valid(other.valid)
-{
- indexes = other.indexes;
-}
-
-QQuickViewTestUtil::ListRange::ListRange(int start, int end)
- : valid(true)
-{
- for (int i=start; i<=end; i++)
- indexes << i;
-}
-
-QQuickViewTestUtil::ListRange::~ListRange()
-{
-}
-
-QQuickViewTestUtil::ListRange QQuickViewTestUtil::ListRange::operator+(const ListRange &other) const
-{
- if (other == *this)
- return *this;
- ListRange a(*this);
- a.indexes.append(other.indexes);
- return a;
-}
-
-bool QQuickViewTestUtil::ListRange::operator==(const ListRange &other) const
-{
- return indexes.toSet() == other.indexes.toSet();
-}
-
-bool QQuickViewTestUtil::ListRange::operator!=(const ListRange &other) const
-{
- return !(*this == other);
-}
-
-bool QQuickViewTestUtil::ListRange::isValid() const
-{
- return valid;
-}
-
-int QQuickViewTestUtil::ListRange::count() const
-{
- return indexes.count();
-}
-
-QList<QPair<QString,QString> > QQuickViewTestUtil::ListRange::getModelDataValues(const QmlListModel &model)
-{
- QList<QPair<QString,QString> > data;
- if (!valid)
- return data;
- for (int i=0; i<indexes.count(); i++)
- data.append(qMakePair(model.name(indexes[i]), model.number(indexes[i])));
- return data;
-}
-
-QList<QPair<QString,QString> > QQuickViewTestUtil::ListRange::getModelDataValues(const QaimModel &model)
-{
- QList<QPair<QString,QString> > data;
- if (!valid)
- return data;
- for (int i=0; i<indexes.count(); i++)
- data.append(qMakePair(model.name(indexes[i]), model.number(indexes[i])));
- return data;
-}
-
diff --git a/tests/auto/qtquick2/shared/viewtestutil.h b/tests/auto/qtquick2/shared/viewtestutil.h
deleted file mode 100644
index 71fd5065df..0000000000
--- a/tests/auto/qtquick2/shared/viewtestutil.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKVIEWTESTUTIL_H
-#define QQUICKVIEWTESTUTIL_H
-
-#include <QtQuick/QQuickItem>
-#include <QtDeclarative/QDeclarativeExpression>
-#include <QtDeclarative/private/qlistmodelinterface_p.h>
-#include <QtCore/QAbstractListModel>
-
-QT_FORWARD_DECLARE_CLASS(QQuickView)
-
-namespace QQuickViewTestUtil
-{
- QQuickView *createView();
-
- void flick(QQuickView *canvas, const QPoint &from, const QPoint &to, int duration);
-
- QList<int> adjustIndexesForAddDisplaced(const QList<int> &indexes, int index, int count);
- QList<int> adjustIndexesForMove(const QList<int> &indexes, int from, int to, int count);
- QList<int> adjustIndexesForRemoveDisplaced(const QList<int> &indexes, int index, int count);
-
- struct ListChange {
- enum { Inserted, Removed, Moved, SetCurrent, SetContentY } type;
- int index;
- int count;
- int to; // Move
- qreal pos; // setContentY
-
- static ListChange insert(int index, int count = 1) { ListChange c = { Inserted, index, count, -1, 0.0 }; return c; }
- static ListChange remove(int index, int count = 1) { ListChange c = { Removed, index, count, -1, 0.0 }; return c; }
- static ListChange move(int index, int to, int count) { ListChange c = { Moved, index, count, to, 0.0 }; return c; }
- static ListChange setCurrent(int index) { ListChange c = { SetCurrent, index, -1, -1, 0.0 }; return c; }
- static ListChange setContentY(qreal pos) { ListChange c = { SetContentY, -1, -1, -1, pos }; return c; }
- };
-
- class QmlListModel : public QListModelInterface
- {
- Q_OBJECT
- public:
- QmlListModel(QObject *parent = 0);
- ~QmlListModel();
-
- enum Roles { Name, Number };
-
- QString name(int index) const;
- QString number(int index) const;
-
- int count() const;
-
- QList<int> roles() const;
- QString toString(int role) const;
-
- QVariant data(int index, int role) const;
- QHash<int, QVariant> data(int index, const QList<int> &roles) const;
-
- Q_INVOKABLE void addItem(const QString &name, const QString &number);
- void insertItem(int index, const QString &name, const QString &number);
- void insertItems(int index, const QList<QPair<QString, QString> > &items);
-
- void removeItem(int index);
- void removeItems(int index, int count);
-
- void moveItem(int from, int to);
- void moveItems(int from, int to, int count);
-
- void modifyItem(int index, const QString &name, const QString &number);
-
- void clear();
-
- void matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2);
-
- private:
- QList<QPair<QString,QString> > list;
- };
-
- class QaimModel : public QAbstractListModel
- {
- Q_OBJECT
- public:
- enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
-
- QaimModel(QObject *parent=0);
-
- int rowCount(const QModelIndex &parent=QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
-
- int count() const;
- QString name(int index) const;
- QString number(int index) const;
-
- Q_INVOKABLE void addItem(const QString &name, const QString &number);
- void addItems(const QList<QPair<QString, QString> > &items);
- void insertItem(int index, const QString &name, const QString &number);
- void insertItems(int index, const QList<QPair<QString, QString> > &items);
-
- void removeItem(int index);
- void removeItems(int index, int count);
-
- void moveItem(int from, int to);
- void moveItems(int from, int to, int count);
-
- void modifyItem(int idx, const QString &name, const QString &number);
-
- void clear();
- void reset();
-
- void matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2);
-
- private:
- QList<QPair<QString,QString> > list;
- };
-
- class ListRange
- {
- public:
- ListRange();
- ListRange(const ListRange &other);
- ListRange(int start, int end);
-
- ~ListRange();
-
- ListRange operator+(const ListRange &other) const;
- bool operator==(const ListRange &other) const;
- bool operator!=(const ListRange &other) const;
-
- bool isValid() const;
- int count() const;
-
- QList<QPair<QString,QString> > getModelDataValues(const QmlListModel &model);
- QList<QPair<QString,QString> > getModelDataValues(const QaimModel &model);
-
- QList<int> indexes;
- bool valid;
- };
-}
-
-Q_DECLARE_METATYPE(QList<QQuickViewTestUtil::ListChange>)
-Q_DECLARE_METATYPE(QQuickViewTestUtil::ListRange)
-
-#endif // QQUICKVIEWTESTUTIL_H
diff --git a/tests/auto/qtquick2/shared/visualtestutil.h b/tests/auto/qtquick2/shared/visualtestutil.h
deleted file mode 100644
index 09bb03c002..0000000000
--- a/tests/auto/qtquick2/shared/visualtestutil.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** 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.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QQUICKVISUALTESTUTIL_H
-#define QQUICKVISUALTESTUTIL_H
-
-#include <QtQuick/QQuickItem>
-#include <QtDeclarative/QDeclarativeExpression>
-
-namespace QQuickVisualTestUtil
-{
- QQuickItem *findVisibleChild(QQuickItem *parent, const QString &objectName);
-
- void dumpTree(QQuickItem *parent, int depth = 0);
-
-
- /*
- Find an item with the specified objectName. If index is supplied then the
- item must also evaluate the {index} expression equal to index
- */
- template<typename T>
- T *findItem(QQuickItem *parent, const QString &objectName, int index = -1)
- {
- const QMetaObject &mo = T::staticMetaObject;
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QQuickItem *item = qobject_cast<QQuickItem*>(parent->childItems().at(i));
- if (!item)
- continue;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
- if (index != -1) {
- QDeclarativeExpression e(qmlContext(item), item, "index");
- if (e.evaluate().toInt() == index)
- return static_cast<T*>(item);
- } else {
- return static_cast<T*>(item);
- }
- }
- item = findItem<T>(item, objectName, index);
- if (item)
- return static_cast<T*>(item);
- }
-
- return 0;
- }
-
- template<typename T>
- QList<T*> findItems(QQuickItem *parent, const QString &objectName, bool visibleOnly = true)
- {
- QList<T*> items;
- const QMetaObject &mo = T::staticMetaObject;
- for (int i = 0; i < parent->childItems().count(); ++i) {
- QQuickItem *item = qobject_cast<QQuickItem*>(parent->childItems().at(i));
- if (!item || (visibleOnly && !item->isVisible()))
- continue;
- if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
- items.append(static_cast<T*>(item));
- items += findItems<T>(item, objectName);
- }
-
- return items;
- }
-
- template<typename T>
- QList<T*> findItems(QQuickItem *parent, const QString &objectName, const QList<int> &indexes)
- {
- QList<T*> items;
- for (int i=0; i<indexes.count(); i++)
- items << qobject_cast<QQuickItem*>(findItem<T>(parent, objectName, indexes[i]));
- return items;
- }
-
-}
-
-#endif // QQUICKVISUALTESTUTIL_H
diff --git a/tests/auto/qtquick2/examples/data/dummytest.qml b/tests/auto/quick/examples/data/dummytest.qml
index b20e907f27..b20e907f27 100644
--- a/tests/auto/qtquick2/examples/data/dummytest.qml
+++ b/tests/auto/quick/examples/data/dummytest.qml
diff --git a/tests/auto/qtquick2/examples/data/webbrowser/webbrowser.qml b/tests/auto/quick/examples/data/webbrowser/webbrowser.qml
index d31787b939..d31787b939 100644
--- a/tests/auto/qtquick2/examples/data/webbrowser/webbrowser.qml
+++ b/tests/auto/quick/examples/data/webbrowser/webbrowser.qml
diff --git a/tests/auto/quick/examples/examples.pro b/tests/auto/quick/examples/examples.pro
new file mode 100644
index 0000000000..e67120d7c2
--- /dev/null
+++ b/tests/auto/quick/examples/examples.pro
@@ -0,0 +1,10 @@
+CONFIG += testcase
+TARGET = tst_examples
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_examples.cpp
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+#temporary
+QT += core-private gui-private qml-private quick-private widgets-private v8-private testlib
diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp
new file mode 100644
index 0000000000..24a60cb08a
--- /dev/null
+++ b/tests/auto/quick/examples/tst_examples.cpp
@@ -0,0 +1,307 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QLibraryInfo>
+#include <QDir>
+#include <QProcess>
+#include <QDebug>
+#include <QtQuick/QQuickItem>
+#include <QtQuick/QQuickView>
+#include <QQmlComponent>
+#include <QQmlEngine>
+#include <QQmlError>
+
+static QtMsgHandler testlibMsgHandler = 0;
+void msgHandlerFilter(QtMsgType type, const char *msg)
+{
+ if (type == QtCriticalMsg || type == QtFatalMsg)
+ (*testlibMsgHandler)(type, msg);
+}
+
+class tst_examples : public QObject
+{
+ Q_OBJECT
+public:
+ tst_examples();
+
+private slots:
+ void init();
+ void cleanup();
+
+ void sgexamples_data();
+ void sgexamples();
+ void sgsnippets_data();
+ void sgsnippets();
+
+ void namingConvention();
+private:
+ QStringList excludedDirs;
+ QStringList excludedFiles;
+
+ void namingConvention(const QDir &);
+ QStringList findQmlFiles(const QDir &);
+
+ QQmlEngine engine;
+};
+
+tst_examples::tst_examples()
+{
+ // Add files to exclude here
+ excludedFiles << "doc/src/snippets/qml/listmodel.qml"; //Just a ListModel, no root QQuickItem
+
+ // Add directories you want excluded here
+ excludedDirs << "examples/qml/text/fonts"; // QTBUG-21415
+ excludedDirs << "doc/src/snippets/qml/path"; //No root QQuickItem
+
+ // Not run in QQuickView
+ excludedDirs << "examples/qml/qtquick1";
+
+ // These snippets are not expected to run on their own.
+ excludedDirs << "doc/src/snippets/qml/visualdatamodel_rootindex";
+ excludedDirs << "doc/src/snippets/qml/qtbinding";
+ excludedDirs << "doc/src/snippets/qml/imports";
+ excludedDirs << "doc/src/snippets/qtquick1/visualdatamodel_rootindex";
+ excludedDirs << "doc/src/snippets/qtquick1/qtbinding";
+ excludedDirs << "doc/src/snippets/qtquick1/imports";
+
+#ifdef QT_NO_WEBKIT
+ excludedDirs << "examples/qml/modelviews/webview";
+ excludedDirs << "examples/qml/webbrowser";
+ excludedDirs << "doc/src/snippets/qml/webview";
+ excludedDirs << "doc/src/snippets/qtquick1/webview";
+#endif
+
+#ifdef QT_NO_XMLPATTERNS
+ excludedDirs << "examples/qml/xml/xmldata";
+ excludedDirs << "examples/qml/twitter";
+ excludedDirs << "examples/qml/flickr";
+ excludedDirs << "examples/qml/photoviewer";
+#endif
+}
+
+void tst_examples::init()
+{
+ if (!qstrcmp(QTest::currentTestFunction(), "sgsnippets"))
+ testlibMsgHandler = qInstallMsgHandler(msgHandlerFilter);
+}
+
+void tst_examples::cleanup()
+{
+ if (!qstrcmp(QTest::currentTestFunction(), "sgsnippets"))
+ qInstallMsgHandler(testlibMsgHandler);
+}
+
+/*
+This tests that the examples follow the naming convention required
+to have them tested by the examples() test.
+*/
+void tst_examples::namingConvention(const QDir &d)
+{
+ for (int ii = 0; ii < excludedDirs.count(); ++ii) {
+ QString s = excludedDirs.at(ii);
+ if (d.absolutePath().endsWith(s))
+ return;
+ }
+
+ QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
+ QDir::Files);
+
+ bool seenQml = !files.isEmpty();
+ bool seenLowercase = false;
+
+ foreach (const QString &file, files) {
+ if (file.at(0).isLower())
+ seenLowercase = true;
+ }
+
+ if (!seenQml) {
+ QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
+ QDir::NoSymLinks);
+ foreach (const QString &dir, dirs) {
+ QDir sub = d;
+ sub.cd(dir);
+ namingConvention(sub);
+ }
+ } else if(!seenLowercase) {
+ QFAIL(qPrintable(QString(
+ "Directory %1 violates naming convention; expected at least one qml file "
+ "starting with lower case, got: %2"
+ ).arg(d.absolutePath()).arg(files.join(","))));
+ }
+}
+
+void tst_examples::namingConvention()
+{
+ QString examples = QLibraryInfo::location(QLibraryInfo::ExamplesPath);
+
+ namingConvention(QDir(examples));
+}
+
+QStringList tst_examples::findQmlFiles(const QDir &d)
+{
+ for (int ii = 0; ii < excludedDirs.count(); ++ii) {
+ QString s = excludedDirs.at(ii);
+ if (d.absolutePath().endsWith(s))
+ return QStringList();
+ }
+
+ QStringList rv;
+
+ QStringList cppfiles = d.entryList(QStringList() << QLatin1String("*.cpp"), QDir::Files);
+ if (cppfiles.isEmpty()) {
+ QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"),
+ QDir::Files);
+ foreach (const QString &file, files) {
+ if (file.at(0).isLower()) {
+ bool superContinue = false;
+ for (int ii = 0; ii < excludedFiles.count(); ++ii) {
+ QString e = excludedFiles.at(ii);
+ if (d.absoluteFilePath(file).endsWith(e)) {
+ superContinue = true;
+ break;
+ }
+ }
+ if (superContinue)
+ continue;
+ rv << d.absoluteFilePath(file);
+ }
+ }
+ }
+
+
+ QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot |
+ QDir::NoSymLinks);
+ foreach (const QString &dir, dirs) {
+ QDir sub = d;
+ sub.cd(dir);
+ rv << findQmlFiles(sub);
+ }
+
+ return rv;
+}
+
+/*
+This test runs all the examples in the QtQml UI source tree and ensures
+that they start and exit cleanly.
+
+Examples are any .qml files under the examples/ directory that start
+with a lower case letter.
+*/
+void tst_examples::sgexamples_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QString examples = QLatin1String(SRCDIR) + "/../../../../examples/qml/";
+ QString tutorials = QLatin1String(SRCDIR) + "/../../../../examples/tutorials/"; //Only qml tutorials since modularization
+
+ QStringList files;
+ files << findQmlFiles(QDir(examples));
+ files << findQmlFiles(QDir(tutorials));
+
+ foreach (const QString &file, files)
+ QTest::newRow(qPrintable(file)) << file;
+}
+
+void tst_examples::sgexamples()
+{
+ QFETCH(QString, file);
+
+ QQmlComponent component(&engine, QUrl::fromLocalFile(file));
+ if (component.status() == QQmlComponent::Error)
+ qWarning() << component.errors();
+ QCOMPARE(component.status(), QQmlComponent::Ready);
+
+ QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
+ QQuickItem *root = qobject_cast<QQuickItem *>(object.data());
+ if (!root)
+ component.completeCreate();
+ QVERIFY(root);
+
+ QQuickCanvas canvas;
+ root->setParentItem(canvas.rootItem());
+ component.completeCreate();
+ canvas.show();
+
+ QTest::qWaitForWindowShown(&canvas);
+
+}
+
+void tst_examples::sgsnippets_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QString snippets = QLatin1String(SRCDIR) + "/../../../../doc/src/snippets/qml";
+
+ QStringList files;
+ files << findQmlFiles(QDir(snippets));
+
+ foreach (const QString &file, files)
+ QTest::newRow(qPrintable(file)) << file;
+}
+
+void tst_examples::sgsnippets()
+{
+ QFETCH(QString, file);
+
+ QQmlComponent component(&engine, QUrl::fromLocalFile(file));
+ if (component.status() == QQmlComponent::Error)
+ qWarning() << component.errors();
+ QCOMPARE(component.status(), QQmlComponent::Ready);
+
+ QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
+ QQuickItem *root = qobject_cast<QQuickItem *>(object.data());
+ if (!root)
+ component.completeCreate();
+ QVERIFY(root);
+
+ QQuickCanvas canvas;
+ root->setParentItem(canvas.rootItem());
+ component.completeCreate();
+ canvas.show();
+
+ QTest::qWaitForWindowShown(&canvas);
+
+}
+
+QTEST_MAIN(tst_examples)
+
+#include "tst_examples.moc"
diff --git a/tests/auto/quick/geometry/geometry.pro b/tests/auto/quick/geometry/geometry.pro
new file mode 100644
index 0000000000..41fcab7c8f
--- /dev/null
+++ b/tests/auto/quick/geometry/geometry.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_geometry
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_geometry.cpp
+
+CONFIG+=parallel_test
+
+QT += core-private gui-private qml-private quick-private opengl testlib
diff --git a/tests/auto/qtquick2/geometry/tst_geometry.cpp b/tests/auto/quick/geometry/tst_geometry.cpp
index 8d8f45b8cb..8d8f45b8cb 100644
--- a/tests/auto/qtquick2/geometry/tst_geometry.cpp
+++ b/tests/auto/quick/geometry/tst_geometry.cpp
diff --git a/tests/auto/quick/nodes/nodes.pro b/tests/auto/quick/nodes/nodes.pro
new file mode 100644
index 0000000000..51e3e2a156
--- /dev/null
+++ b/tests/auto/quick/nodes/nodes.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_nodestest
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_nodestest.cpp
+
+CONFIG+=parallel_test
+
+QT += core-private gui-private qml-private quick-private opengl widgets testlib
diff --git a/tests/auto/qtquick2/nodes/tst_nodestest.cpp b/tests/auto/quick/nodes/tst_nodestest.cpp
index 6a6de625d5..6a6de625d5 100644
--- a/tests/auto/qtquick2/nodes/tst_nodestest.cpp
+++ b/tests/auto/quick/nodes/tst_nodestest.cpp
diff --git a/tests/auto/qtquick2/qquickaccessible/data/checkbuttons.qml b/tests/auto/quick/qquickaccessible/data/checkbuttons.qml
index 22cdad1377..22cdad1377 100644
--- a/tests/auto/qtquick2/qquickaccessible/data/checkbuttons.qml
+++ b/tests/auto/quick/qquickaccessible/data/checkbuttons.qml
diff --git a/tests/auto/quick/qquickaccessible/data/hittest.qml b/tests/auto/quick/qquickaccessible/data/hittest.qml
new file mode 100644
index 0000000000..e8003e648a
--- /dev/null
+++ b/tests/auto/quick/qquickaccessible/data/hittest.qml
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+import QtQuick 2.0
+import "widgets"
+
+Rectangle {
+ id: page
+ width: 640
+ height: 480
+ color: "white"
+ Rectangle {
+ id: header
+ color: "#c0c0c0"
+ height: usage.height + chkClip.height
+ anchors.left: parent.left
+ anchors.right: parent.right
+ Text {
+ id: usage
+ text: "Use an a11y inspect tool to see if all visible rectangles can be found with hit testing."
+ }
+ Rectangle {
+ id: chkClip
+ property bool checked: true
+
+ color: (checked ? "#f0f0f0" : "#c0c0c0")
+ height: label.height
+ width: label.width
+ anchors.left: parent.left
+ anchors.bottom: parent.bottom
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: chkClip.checked = !chkClip.checked
+ }
+ Text {
+ id: label
+ text: "Click here to toggle clipping"
+ }
+ }
+ }
+ TextRect {
+ clip: chkClip.checked
+ z: 2
+ id: rect1
+ text: "rect1"
+ width: 100
+ height: 100
+ color: "#ffc0c0"
+ anchors.top: header.bottom
+ TextRect {
+ id: rect10
+ text: "rect10"
+ width: 100
+ height: 100
+ x: 50
+ y: 50
+ color: "#ffa0a0"
+ TextRect {
+ id: rect100
+ text: "rect100"
+ width: 100
+ height: 100
+ x: 80
+ y: 80
+ color: "#ff8080"
+ }
+ TextRect {
+ id: rect101
+ text: "rect101"
+ x: 100
+ y: 70
+ z: 3
+ width: 100
+ height: 100
+ color: "#e06060"
+ }
+ TextRect {
+ id: rect102
+ text: "rect102"
+ width: 100
+ height: 100
+ x: 150
+ y: 60
+ color: "#c04040"
+ }
+ }
+ }
+
+ TextRect {
+ x: 0
+ y: 50
+ id: rect2
+ text: "rect2"
+ width: 100
+ height: 100
+ color: "#c0c0ff"
+ TextRect {
+ id: rect20
+ text: "rect20"
+ width: 100
+ height: 100
+ x: 50
+ y: 50
+ color: "#a0a0ff"
+ TextRect {
+ id: rect200
+ text: "rect200"
+ width: 100
+ height: 100
+ x: 80
+ y: 80
+ color: "#8080ff"
+ }
+ TextRect {
+ id: rect201
+ text: "rect201"
+ x: 100
+ y: 70
+ z: 100
+ width: 100
+ height: 100
+ color: "#6060e0"
+ }
+ TextRect {
+ id: rect202
+ text: "rect202"
+ width: 100
+ height: 100
+ x: 150
+ y: 60
+ color: "#4040c0"
+ }
+ }
+ }
+
+}
diff --git a/tests/auto/qtquick2/qquickaccessible/data/pushbutton.qml b/tests/auto/quick/qquickaccessible/data/pushbutton.qml
index df19231703..df19231703 100644
--- a/tests/auto/qtquick2/qquickaccessible/data/pushbutton.qml
+++ b/tests/auto/quick/qquickaccessible/data/pushbutton.qml
diff --git a/tests/auto/qtquick2/qquickaccessible/data/statictext.qml b/tests/auto/quick/qquickaccessible/data/statictext.qml
index a0821cfc4d..a0821cfc4d 100644
--- a/tests/auto/qtquick2/qquickaccessible/data/statictext.qml
+++ b/tests/auto/quick/qquickaccessible/data/statictext.qml
diff --git a/tests/auto/qtquick2/qquickaccessible/data/widgets/TextRect.qml b/tests/auto/quick/qquickaccessible/data/widgets/TextRect.qml
index 937686974b..937686974b 100644
--- a/tests/auto/qtquick2/qquickaccessible/data/widgets/TextRect.qml
+++ b/tests/auto/quick/qquickaccessible/data/widgets/TextRect.qml
diff --git a/tests/auto/quick/qquickaccessible/qquickaccessible.pro b/tests/auto/quick/qquickaccessible/qquickaccessible.pro
new file mode 100644
index 0000000000..ca50f5d8af
--- /dev/null
+++ b/tests/auto/quick/qquickaccessible/qquickaccessible.pro
@@ -0,0 +1,25 @@
+CONFIG += testcase
+
+TARGET = tst_qquickaccessible
+QT += qml-private network quick-private testlib
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickaccessible.cpp
+
+include (../../shared/util.pri)
+
+OTHER_FILES += data/checkbuttons.qml
+OTHER_FILES += data/hittest.qml
+OTHER_FILES += data/pushbutton.qml
+OTHER_FILES += data/statictext.qml
+
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+CONFIG += parallel_test
+
+wince*: {
+ accessneeded.files = $$QT_BUILD_TREE\\plugins\\accessible\\*.dll
+ accessneeded.path = accessible
+ DEPLOYMENT += accessneeded
+}
+
diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
new file mode 100644
index 0000000000..d65666162d
--- /dev/null
+++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
@@ -0,0 +1,410 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include "QtTest/qtestaccessible.h"
+
+#include <QtGui/qaccessible.h>
+
+#include <QtQuick/qquickview.h>
+#include <QtQuick/qquickitem.h>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlproperty.h>
+#include <QtQuick/private/qquickaccessibleattached_p.h>
+
+#include "../../shared/util.h"
+
+
+typedef QSharedPointer<QAccessibleInterface> QAI;
+
+#define EXPECT(cond) \
+ do { \
+ if (!errorAt && !(cond)) { \
+ errorAt = __LINE__; \
+ qWarning("level: %d, middle: %d, role: %d (%s)", treelevel, middle, iface->role(), #cond); \
+ } \
+ } while (0)
+
+static int verifyHierarchy(QAccessibleInterface *iface)
+{
+ int errorAt = 0;
+ static int treelevel = 0; // for error diagnostics
+ QAccessibleInterface *middleChild, *if2;
+ middleChild = 0;
+ ++treelevel;
+ int middle = iface->childCount()/2 + 1;
+ if (iface->childCount() >= 2) {
+ middleChild = iface->child(middle - 1);
+ }
+ for (int i = 0; i < iface->childCount() && !errorAt; ++i) {
+ if2 = iface->child(i);
+ EXPECT(if2 != 0);
+ // navigate Ancestor...
+ QAccessibleInterface *parent = if2->parent();
+ EXPECT(iface->object() == parent->object());
+ delete parent;
+
+ // verify children...
+ if (!errorAt)
+ errorAt = verifyHierarchy(if2);
+ delete if2;
+ }
+ delete middleChild;
+
+ --treelevel;
+ return errorAt;
+}
+
+
+//TESTED_FILES=
+
+class tst_QQuickAccessible : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickAccessible();
+ virtual ~tst_QQuickAccessible();
+
+private slots:
+ void commonTests_data();
+ void commonTests();
+
+ void quickAttachedProperties();
+ void basicPropertiesTest();
+ void hitTest();
+ void checkableTest();
+};
+
+tst_QQuickAccessible::tst_QQuickAccessible()
+{
+
+}
+
+tst_QQuickAccessible::~tst_QQuickAccessible()
+{
+
+}
+
+void tst_QQuickAccessible::commonTests_data()
+{
+ QTest::addColumn<QString>("accessibleRoleFileName");
+
+ QTest::newRow("StaticText") << SRCDIR "/data/statictext.qml";
+ QTest::newRow("PushButton") << SRCDIR "/data/pushbutton.qml";
+}
+
+void tst_QQuickAccessible::commonTests()
+{
+ QFETCH(QString, accessibleRoleFileName);
+
+ qDebug() << "testing" << accessibleRoleFileName;
+
+ QQuickView *view = new QQuickView();
+// view->setFixedSize(240,320);
+ view->setSource(QUrl::fromLocalFile(accessibleRoleFileName));
+ view->show();
+// view->setFocus();
+ QVERIFY(view->rootObject() != 0);
+
+ QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(view);
+ QVERIFY(iface);
+
+ delete iface;
+ delete view;
+}
+
+
+
+QString eventName(const int ev)
+{
+ switch (ev) {
+ case 0x0001: return "SoundPlayed";
+ case 0x0002: return "Alert";
+ case 0x0003: return "ForegroundChanged";
+ case 0x0004: return "MenuStart";
+ case 0x0005: return "MenuEnd";
+ case 0x0006: return "PopupMenuStart";
+ case 0x0007: return "PopupMenuEnd";
+ case 0x000C: return "ContextHelpStart";
+ case 0x000D: return "ContextHelpEnd";
+ case 0x000E: return "DragDropStart";
+ case 0x000F: return "DragDropEnd";
+ case 0x0010: return "DialogStart";
+ case 0x0011: return "DialogEnd";
+ case 0x0012: return "ScrollingStart";
+ case 0x0013: return "ScrollingEnd";
+ case 0x0018: return "MenuCommand";
+ case 0x8000: return "ObjectCreated";
+ case 0x8001: return "ObjectDestroyed";
+ case 0x8002: return "ObjectShow";
+ case 0x8003: return "ObjectHide";
+ case 0x8004: return "ObjectReorder";
+ case 0x8005: return "Focus";
+ case 0x8006: return "Selection";
+ case 0x8007: return "SelectionAdd";
+ case 0x8008: return "SelectionRemove";
+ case 0x8009: return "SelectionWithin";
+ case 0x800A: return "StateChanged";
+ case 0x800B: return "LocationChanged";
+ case 0x800C: return "NameChanged";
+ case 0x800D: return "DescriptionChanged";
+ case 0x800E: return "ValueChanged";
+ case 0x800F: return "ParentChanged";
+ case 0x80A0: return "HelpChanged";
+ case 0x80B0: return "DefaultActionChanged";
+ case 0x80C0: return "AcceleratorChanged";
+ default: return "Unknown Event";
+ }
+}
+
+void tst_QQuickAccessible::quickAttachedProperties()
+{
+ {
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nItem {\n"
+ "}", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
+ QCOMPARE(attachedObject, static_cast<QObject*>(0));
+ delete object;
+ }
+
+ // Attached property
+ {
+ QObject parent;
+ QQuickAccessibleAttached *attachedObj = new QQuickAccessibleAttached(&parent);
+
+ attachedObj->name();
+
+ QVariant pp = attachedObj->property("name");
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nItem {\n"
+ "Accessible.role: Accessible.Button\n"
+ "}", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
+ QVERIFY(attachedObject);
+ if (attachedObject) {
+ QVariant p = attachedObject->property("role");
+ QCOMPARE(p.isNull(), false);
+ QCOMPARE(p.toInt(), int(QAccessible::PushButton));
+ p = attachedObject->property("name");
+ QCOMPARE(p.isNull(), true);
+ p = attachedObject->property("description");
+ QCOMPARE(p.isNull(), true);
+ }
+ delete object;
+ }
+
+ // Attached property
+ {
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nItem {\n"
+ "Accessible.role: Accessible.Button\n"
+ "Accessible.name: \"Donald\"\n"
+ "Accessible.description: \"Duck\"\n"
+ "}", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
+ QVERIFY(attachedObject);
+ if (attachedObject) {
+ QVariant p = attachedObject->property("role");
+ QCOMPARE(p.isNull(), false);
+ QCOMPARE(p.toInt(), int(QAccessible::PushButton));
+ p = attachedObject->property("name");
+ QCOMPARE(p.isNull(), false);
+ QCOMPARE(p.toString(), QLatin1String("Donald"));
+ p = attachedObject->property("description");
+ QCOMPARE(p.isNull(), false);
+ QCOMPARE(p.toString(), QLatin1String("Duck"));
+ }
+ delete object;
+ }
+}
+
+
+void tst_QQuickAccessible::basicPropertiesTest()
+{
+ QAI app = QAI(QAccessible::queryAccessibleInterface(qApp));
+ QCOMPARE(app->childCount(), 0);
+
+ QQuickView *canvas = new QQuickView();
+ canvas->setSource(testFileUrl("statictext.qml"));
+ canvas->show();
+ QCOMPARE(app->childCount(), 1);
+
+ QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas));
+ QVERIFY(iface.data());
+ QCOMPARE(iface->childCount(), 1);
+
+ QAI item = QAI(iface->child(0));
+ QVERIFY(item.data());
+ QCOMPARE(item->childCount(), 2);
+ QCOMPARE(item->rect().size(), QSize(400, 400));
+ QCOMPARE(item->role(), QAccessible::Pane);
+ QCOMPARE(iface->indexOfChild(item.data()), 0);
+
+ QAI text = QAI(item->child(0));
+ QVERIFY(text.data());
+ QCOMPARE(text->childCount(), 0);
+
+ QCOMPARE(text->text(QAccessible::Name), QLatin1String("Hello Accessibility"));
+ QCOMPARE(text->rect().size(), QSize(200, 50));
+ QCOMPARE(text->rect().x(), item->rect().x() + 100);
+ QCOMPARE(text->rect().y(), item->rect().y() + 20);
+ QCOMPARE(text->role(), QAccessible::StaticText);
+ QCOMPARE(item->indexOfChild(text.data()), 0);
+
+ QAI text2 = QAI(item->child(1));
+ QVERIFY(text2.data());
+ QCOMPARE(text2->childCount(), 0);
+
+ QCOMPARE(text2->text(QAccessible::Name), QLatin1String("The Hello 2 accessible text"));
+ QCOMPARE(text2->rect().size(), QSize(100, 40));
+ QCOMPARE(text2->rect().x(), item->rect().x() + 100);
+ QCOMPARE(text2->rect().y(), item->rect().y() + 40);
+ QCOMPARE(text2->role(), QAccessible::StaticText);
+ QCOMPARE(item->indexOfChild(text2.data()), 1);
+
+ QCOMPARE(iface->indexOfChild(text2.data()), -1);
+ QCOMPARE(text2->indexOfChild(item.data()), -1);
+
+ delete canvas;
+}
+
+QAI topLevelChildAt(QAccessibleInterface *iface, int x, int y)
+{
+ QAI child = QAI(iface->childAt(x, y));
+ if (!child)
+ return QAI();
+
+ QAI childOfChild;
+ while (childOfChild = QAI(child->childAt(x, y))) {
+ child = childOfChild;
+ }
+ return child;
+}
+
+void tst_QQuickAccessible::hitTest()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("hittest.qml"));
+ canvas->show();
+
+ QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas));
+ QVERIFY(iface.data());
+ QAI rootItem = QAI(iface->child(0));
+ QRect rootRect = rootItem->rect();
+
+ // hit the root item
+ QAI itemHit(iface->childAt(rootRect.x() + 200, rootRect.y() + 50));
+ QVERIFY(itemHit);
+ QCOMPARE(rootRect, itemHit->rect());
+
+ // hit rect1
+ QAI rect1(rootItem->child(1));
+ QRect rect1Rect = rect1->rect();
+ itemHit = QAI(rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10));
+ QVERIFY(itemHit);
+ QCOMPARE(rect1Rect, itemHit->rect());
+ QCOMPARE(itemHit->text(QAccessible::Name), QLatin1String("rect1"));
+
+ // should also work from top level (app)
+ QAI app(QAccessible::queryAccessibleInterface(qApp));
+ QAI itemHit2(topLevelChildAt(app.data(), rect1Rect.x() + 10, rect1Rect.y() + 10));
+ QVERIFY(itemHit2);
+ QCOMPARE(itemHit2->rect(), rect1Rect);
+ QCOMPARE(itemHit2->text(QAccessible::Name), QLatin1String("rect1"));
+
+ // hit rect201
+ QAI rect2(rootItem->child(2));
+ QAI rect20(rect2->child(1));
+ QAI rect201(rect20->child(2));
+ QVERIFY(rect201);
+
+ QRect rect201Rect = rect201->rect();
+ itemHit = QAI(iface->childAt(rect201Rect.x() + 20, rect201Rect.y() + 20));
+ QVERIFY(itemHit);
+ QCOMPARE(itemHit->rect(), rect201Rect);
+ QCOMPARE(itemHit->text(QAccessible::Name), QLatin1String("rect201"));
+
+ delete canvas;
+}
+
+void tst_QQuickAccessible::checkableTest()
+{
+ QQuickView *canvas = new QQuickView();
+ canvas->setSource(testFileUrl("checkbuttons.qml"));
+ canvas->show();
+
+ QAI iface = QAI(QAccessible::queryAccessibleInterface(canvas));
+ QVERIFY(iface.data());
+ QAI root = QAI(iface->child(0));
+
+ QAI button1 = QAI(root->child(0));
+ QCOMPARE(button1->role(), QAccessible::Button);
+ QVERIFY(!(button1->state().checked));
+ QAI button2 = QAI(root->child(1));
+ QVERIFY(!(button2->state().checked));
+ QAI button3 = QAI(root->child(2));
+ QVERIFY(button3->state().checked);
+
+ QAI checkBox1 = QAI(root->child(3));
+ QCOMPARE(checkBox1->role(), QAccessible::CheckBox);
+ QVERIFY((checkBox1->state().checked));
+ QAI checkBox2 = QAI(root->child(4));
+ QVERIFY(!(checkBox2->state().checked));
+}
+
+QTEST_MAIN(tst_QQuickAccessible)
+
+#include "tst_qquickaccessible.moc"
diff --git a/tests/auto/qtquick2/qquickanchors/data/anchors.qml b/tests/auto/quick/qquickanchors/data/anchors.qml
index 4be49a3468..4be49a3468 100644
--- a/tests/auto/qtquick2/qquickanchors/data/anchors.qml
+++ b/tests/auto/quick/qquickanchors/data/anchors.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/centerin.qml b/tests/auto/quick/qquickanchors/data/centerin.qml
index e6c9179116..e6c9179116 100644
--- a/tests/auto/qtquick2/qquickanchors/data/centerin.qml
+++ b/tests/auto/quick/qquickanchors/data/centerin.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/centerinRotation.qml b/tests/auto/quick/qquickanchors/data/centerinRotation.qml
index 933a25c100..933a25c100 100644
--- a/tests/auto/qtquick2/qquickanchors/data/centerinRotation.qml
+++ b/tests/auto/quick/qquickanchors/data/centerinRotation.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/crash1.qml b/tests/auto/quick/qquickanchors/data/crash1.qml
index 98dd6cfa41..98dd6cfa41 100644
--- a/tests/auto/qtquick2/qquickanchors/data/crash1.qml
+++ b/tests/auto/quick/qquickanchors/data/crash1.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/fill.qml b/tests/auto/quick/qquickanchors/data/fill.qml
index 08db199d7b..08db199d7b 100644
--- a/tests/auto/qtquick2/qquickanchors/data/fill.qml
+++ b/tests/auto/quick/qquickanchors/data/fill.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/hvCenter.qml b/tests/auto/quick/qquickanchors/data/hvCenter.qml
index 6763f8eb75..6763f8eb75 100644
--- a/tests/auto/qtquick2/qquickanchors/data/hvCenter.qml
+++ b/tests/auto/quick/qquickanchors/data/hvCenter.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/loop1.qml b/tests/auto/quick/qquickanchors/data/loop1.qml
index 342b2af052..342b2af052 100644
--- a/tests/auto/qtquick2/qquickanchors/data/loop1.qml
+++ b/tests/auto/quick/qquickanchors/data/loop1.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/loop2.qml b/tests/auto/quick/qquickanchors/data/loop2.qml
index 044152989e..044152989e 100644
--- a/tests/auto/qtquick2/qquickanchors/data/loop2.qml
+++ b/tests/auto/quick/qquickanchors/data/loop2.qml
diff --git a/tests/auto/qtquick2/qquickanchors/data/margins.qml b/tests/auto/quick/qquickanchors/data/margins.qml
index 9403f65a61..9403f65a61 100644
--- a/tests/auto/qtquick2/qquickanchors/data/margins.qml
+++ b/tests/auto/quick/qquickanchors/data/margins.qml
diff --git a/tests/auto/quick/qquickanchors/qquickanchors.pro b/tests/auto/quick/qquickanchors/qquickanchors.pro
new file mode 100644
index 0000000000..30e6e6dcf8
--- /dev/null
+++ b/tests/auto/quick/qquickanchors/qquickanchors.pro
@@ -0,0 +1,16 @@
+TARGET = tst_qquickanchors
+CONFIG += testcase
+SOURCES += tst_qquickanchors.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private v8-private testlib
diff --git a/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp b/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
new file mode 100644
index 0000000000..749b11f919
--- /dev/null
+++ b/tests/auto/quick/qquickanchors/tst_qquickanchors.cpp
@@ -0,0 +1,669 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <private/qquickitem_p.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuick/private/qquickanchors_p_p.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include "../../shared/util.h"
+#include "../shared/visualtestutil.h"
+
+Q_DECLARE_METATYPE(QQuickAnchors::Anchor)
+Q_DECLARE_METATYPE(QQuickAnchorLine::AnchorLine)
+
+using namespace QQuickVisualTestUtil;
+
+class tst_qquickanchors : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickanchors() {}
+
+private slots:
+ void basicAnchors();
+ void basicAnchorsRTL();
+ void loops();
+ void illegalSets();
+ void illegalSets_data();
+ void reset();
+ void reset_data();
+ void resetConvenience();
+ void nullItem();
+ void nullItem_data();
+ void crash1();
+ void centerIn();
+ void centerInRTL();
+ void centerInRotation();
+ void hvCenter();
+ void hvCenterRTL();
+ void fill();
+ void fillRTL();
+ void margins();
+ void marginsRTL();
+};
+
+void tst_qquickanchors::basicAnchors()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("anchors.qml"));
+
+ qApp->processEvents();
+
+ //sibling horizontal
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect1"))->x(), 26.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect2"))->x(), 122.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect3"))->x(), 74.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect4"))->x(), 16.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect5"))->x(), 112.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect6"))->x(), 64.0);
+
+ //parent horizontal
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect7"))->x(), 0.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect8"))->x(), 240.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect9"))->x(), 120.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect10"))->x(), -10.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect11"))->x(), 230.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect12"))->x(), 110.0);
+
+ //vertical
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect13"))->y(), 20.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect14"))->y(), 155.0);
+
+ //stretch
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect15"))->x(), 26.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect15"))->width(), 96.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect16"))->x(), 26.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect16"))->width(), 192.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect17"))->x(), -70.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect17"))->width(), 192.0);
+
+ //vertical stretch
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect18"))->y(), 20.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect18"))->height(), 40.0);
+
+ //more parent horizontal
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect19"))->x(), 115.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect20"))->x(), 235.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect21"))->x(), -5.0);
+
+ //centerIn
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect22"))->x(), 69.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect22"))->y(), 5.0);
+
+ //margins
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect23"))->x(), 31.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect23"))->y(), 5.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect23"))->width(), 86.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect23"))->height(), 10.0);
+
+ // offsets
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect24"))->x(), 26.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect25"))->y(), 60.0);
+ QCOMPARE(findItem<QQuickRectangle>(view->rootObject(), QLatin1String("rect26"))->y(), 5.0);
+
+ //baseline
+ QQuickText *text1 = findItem<QQuickText>(view->rootObject(), QLatin1String("text1"));
+ QQuickText *text2 = findItem<QQuickText>(view->rootObject(), QLatin1String("text2"));
+ QCOMPARE(text1->y(), text2->y());
+
+ delete view;
+}
+
+QQuickItem* childItem(QQuickItem *parentItem, const char * itemString) {
+ return findItem<QQuickItem>(parentItem, QLatin1String(itemString));
+}
+
+qreal offsetMasterRTL(QQuickItem *rootItem, const char * itemString) {
+ QQuickItem* masterItem = findItem<QQuickItem>(rootItem, QLatin1String("masterRect"));
+ return masterItem->width()+2*masterItem->x()-findItem<QQuickItem>(rootItem, QLatin1String(itemString))->width();
+}
+
+qreal offsetParentRTL(QQuickItem *rootItem, const char * itemString) {
+ return rootItem->width()+2*rootItem->x()-findItem<QQuickItem>(rootItem, QLatin1String(itemString))->width();
+}
+
+void mirrorAnchors(QQuickItem *item) {
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+ itemPrivate->setLayoutMirror(true);
+}
+
+void tst_qquickanchors::basicAnchorsRTL()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("anchors.qml"));
+
+ qApp->processEvents();
+
+ QQuickItem* rootItem = qobject_cast<QQuickItem*>(view->rootObject());
+ foreach (QObject *child, rootItem->children()) {
+ bool mirrored = QQuickItemPrivate::get(qobject_cast<QQuickItem*>(child))->anchors()->property("mirrored").toBool();
+ QCOMPARE(mirrored, false);
+ }
+
+ foreach (QObject *child, rootItem->children())
+ mirrorAnchors(qobject_cast<QQuickItem*>(child));
+
+ foreach (QObject *child, rootItem->children()) {
+ bool mirrored = QQuickItemPrivate::get(qobject_cast<QQuickItem*>(child))->anchors()->property("mirrored").toBool();
+ QCOMPARE(mirrored, true);
+ }
+
+ //sibling horizontal
+ QCOMPARE(childItem(rootItem, "rect1")->x(), offsetMasterRTL(rootItem, "rect1")-26.0);
+ QCOMPARE(childItem(rootItem, "rect2")->x(), offsetMasterRTL(rootItem, "rect2")-122.0);
+ QCOMPARE(childItem(rootItem, "rect3")->x(), offsetMasterRTL(rootItem, "rect3")-74.0);
+ QCOMPARE(childItem(rootItem, "rect4")->x(), offsetMasterRTL(rootItem, "rect4")-16.0);
+ QCOMPARE(childItem(rootItem, "rect5")->x(), offsetMasterRTL(rootItem, "rect5")-112.0);
+ QCOMPARE(childItem(rootItem, "rect6")->x(), offsetMasterRTL(rootItem, "rect6")-64.0);
+
+ //parent horizontal
+ QCOMPARE(childItem(rootItem, "rect7")->x(), offsetParentRTL(rootItem, "rect7")-0.0);
+ QCOMPARE(childItem(rootItem, "rect8")->x(), offsetParentRTL(rootItem, "rect8")-240.0);
+ QCOMPARE(childItem(rootItem, "rect9")->x(), offsetParentRTL(rootItem, "rect9")-120.0);
+ QCOMPARE(childItem(rootItem, "rect10")->x(), offsetParentRTL(rootItem, "rect10")+10.0);
+ QCOMPARE(childItem(rootItem, "rect11")->x(), offsetParentRTL(rootItem, "rect11")-230.0);
+ QCOMPARE(childItem(rootItem, "rect12")->x(), offsetParentRTL(rootItem, "rect12")-110.0);
+
+ //vertical
+ QCOMPARE(childItem(rootItem, "rect13")->y(), 20.0);
+ QCOMPARE(childItem(rootItem, "rect14")->y(), 155.0);
+
+ //stretch
+ QCOMPARE(childItem(rootItem, "rect15")->x(), offsetMasterRTL(rootItem, "rect15")-26.0);
+ QCOMPARE(childItem(rootItem, "rect15")->width(), 96.0);
+ QCOMPARE(childItem(rootItem, "rect16")->x(), offsetMasterRTL(rootItem, "rect16")-26.0);
+ QCOMPARE(childItem(rootItem, "rect16")->width(), 192.0);
+ QCOMPARE(childItem(rootItem, "rect17")->x(), offsetMasterRTL(rootItem, "rect17")+70.0);
+ QCOMPARE(childItem(rootItem, "rect17")->width(), 192.0);
+
+ //vertical stretch
+ QCOMPARE(childItem(rootItem, "rect18")->y(), 20.0);
+ QCOMPARE(childItem(rootItem, "rect18")->height(), 40.0);
+
+ //more parent horizontal
+ QCOMPARE(childItem(rootItem, "rect19")->x(), offsetParentRTL(rootItem, "rect19")-115.0);
+ QCOMPARE(childItem(rootItem, "rect20")->x(), offsetParentRTL(rootItem, "rect20")-235.0);
+ QCOMPARE(childItem(rootItem, "rect21")->x(), offsetParentRTL(rootItem, "rect21")+5.0);
+
+ //centerIn
+ QCOMPARE(childItem(rootItem, "rect22")->x(), offsetMasterRTL(rootItem, "rect22")-69.0);
+ QCOMPARE(childItem(rootItem, "rect22")->y(), 5.0);
+
+ //margins
+ QCOMPARE(childItem(rootItem, "rect23")->x(), offsetMasterRTL(rootItem, "rect23")-31.0);
+ QCOMPARE(childItem(rootItem, "rect23")->y(), 5.0);
+ QCOMPARE(childItem(rootItem, "rect23")->width(), 86.0);
+ QCOMPARE(childItem(rootItem, "rect23")->height(), 10.0);
+
+ // offsets
+ QCOMPARE(childItem(rootItem, "rect24")->x(), offsetMasterRTL(rootItem, "rect24")-26.0);
+ QCOMPARE(childItem(rootItem, "rect25")->y(), 60.0);
+ QCOMPARE(childItem(rootItem, "rect26")->y(), 5.0);
+
+ //baseline
+ QQuickText *text1 = findItem<QQuickText>(rootItem, QLatin1String("text1"));
+ QQuickText *text2 = findItem<QQuickText>(rootItem, QLatin1String("text2"));
+ QCOMPARE(text1->y(), text2->y());
+
+ delete view;
+}
+
+// mostly testing that we don't crash
+void tst_qquickanchors::loops()
+{
+ {
+ QUrl source(testFileUrl("loop1.qml"));
+
+ QString expect = source.toString() + ":6:5: QML Text: Possible anchor loop detected on horizontal anchor.";
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+
+ QQuickView *view = new QQuickView;
+ view->setSource(source);
+ qApp->processEvents();
+
+ delete view;
+ }
+
+ {
+ QUrl source(testFileUrl("loop2.qml"));
+
+ QString expect = source.toString() + ":8:3: QML Image: Possible anchor loop detected on horizontal anchor.";
+ QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
+
+ QQuickView *view = new QQuickView;
+ view->setSource(source);
+ qApp->processEvents();
+
+ delete view;
+ }
+}
+
+void tst_qquickanchors::illegalSets()
+{
+ QFETCH(QString, qml);
+ QFETCH(QString, warning);
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1());
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\n" + qml.toUtf8()), QUrl::fromLocalFile(""));
+ if (!component.isReady())
+ qWarning() << "Test errors:" << component.errors();
+ QVERIFY(component.isReady());
+ QObject *o = component.create();
+ delete o;
+}
+
+void tst_qquickanchors::illegalSets_data()
+{
+ QTest::addColumn<QString>("qml");
+ QTest::addColumn<QString>("warning");
+
+ QTest::newRow("H - too many anchors")
+ << "Rectangle { id: rect; Rectangle { anchors.left: rect.left; anchors.right: rect.right; anchors.horizontalCenter: rect.horizontalCenter } }"
+ << "file::2:23: QML Rectangle: Cannot specify left, right, and hcenter anchors.";
+
+ foreach (const QString &side, QStringList() << "left" << "right") {
+ QTest::newRow("H - anchor to V")
+ << QString("Rectangle { Rectangle { anchors.%1: parent.top } }").arg(side)
+ << "file::2:13: QML Rectangle: Cannot anchor a horizontal edge to a vertical edge.";
+
+ QTest::newRow("H - anchor to non parent/sibling")
+ << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side)
+ << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
+
+ QTest::newRow("H - anchor to self")
+ << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side)
+ << "file::2:1: QML Rectangle: Cannot anchor item to self.";
+ }
+
+
+ QTest::newRow("V - too many anchors")
+ << "Rectangle { id: rect; Rectangle { anchors.top: rect.top; anchors.bottom: rect.bottom; anchors.verticalCenter: rect.verticalCenter } }"
+ << "file::2:23: QML Rectangle: Cannot specify top, bottom, and vcenter anchors.";
+
+ QTest::newRow("V - too many anchors with baseline")
+ << "Rectangle { Text { id: text1; text: \"Hello\" } Text { anchors.baseline: text1.baseline; anchors.top: text1.top; } }"
+ << "file::2:47: QML Text: Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors.";
+
+ foreach (const QString &side, QStringList() << "top" << "bottom" << "baseline") {
+
+ QTest::newRow("V - anchor to H")
+ << QString("Rectangle { Rectangle { anchors.%1: parent.left } }").arg(side)
+ << "file::2:13: QML Rectangle: Cannot anchor a vertical edge to a horizontal edge.";
+
+ QTest::newRow("V - anchor to non parent/sibling")
+ << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side)
+ << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
+
+ QTest::newRow("V - anchor to self")
+ << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side)
+ << "file::2:1: QML Rectangle: Cannot anchor item to self.";
+ }
+
+
+ QTest::newRow("centerIn - anchor to non parent/sibling")
+ << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }"
+ << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
+
+
+ QTest::newRow("fill - anchor to non parent/sibling")
+ << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.fill: rect} }"
+ << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling.";
+}
+
+void tst_qquickanchors::reset()
+{
+ QFETCH(QString, side);
+ QFETCH(QQuickAnchorLine::AnchorLine, anchorLine);
+ QFETCH(QQuickAnchors::Anchor, usedAnchor);
+
+ QQuickItem *baseItem = new QQuickItem;
+
+ QQuickAnchorLine anchor;
+ anchor.item = baseItem;
+ anchor.anchorLine = anchorLine;
+
+ QQuickItem *item = new QQuickItem;
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+
+ const QMetaObject *meta = itemPrivate->anchors()->metaObject();
+ QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
+
+ QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor)));
+ QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), true);
+
+ QVERIFY(p.reset(itemPrivate->anchors()));
+ QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), false);
+
+ delete item;
+ delete baseItem;
+}
+
+void tst_qquickanchors::reset_data()
+{
+ QTest::addColumn<QString>("side");
+ QTest::addColumn<QQuickAnchorLine::AnchorLine>("anchorLine");
+ QTest::addColumn<QQuickAnchors::Anchor>("usedAnchor");
+
+ QTest::newRow("left") << "left" << QQuickAnchorLine::Left << QQuickAnchors::LeftAnchor;
+ QTest::newRow("top") << "top" << QQuickAnchorLine::Top << QQuickAnchors::TopAnchor;
+ QTest::newRow("right") << "right" << QQuickAnchorLine::Right << QQuickAnchors::RightAnchor;
+ QTest::newRow("bottom") << "bottom" << QQuickAnchorLine::Bottom << QQuickAnchors::BottomAnchor;
+
+ QTest::newRow("hcenter") << "horizontalCenter" << QQuickAnchorLine::HCenter << QQuickAnchors::HCenterAnchor;
+ QTest::newRow("vcenter") << "verticalCenter" << QQuickAnchorLine::VCenter << QQuickAnchors::VCenterAnchor;
+ QTest::newRow("baseline") << "baseline" << QQuickAnchorLine::Baseline << QQuickAnchors::BaselineAnchor;
+}
+
+void tst_qquickanchors::resetConvenience()
+{
+ QQuickItem *baseItem = new QQuickItem;
+ QQuickItem *item = new QQuickItem;
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+
+ //fill
+ itemPrivate->anchors()->setFill(baseItem);
+ QVERIFY(itemPrivate->anchors()->fill() == baseItem);
+ itemPrivate->anchors()->resetFill();
+ QVERIFY(itemPrivate->anchors()->fill() == 0);
+
+ //centerIn
+ itemPrivate->anchors()->setCenterIn(baseItem);
+ QVERIFY(itemPrivate->anchors()->centerIn() == baseItem);
+ itemPrivate->anchors()->resetCenterIn();
+ QVERIFY(itemPrivate->anchors()->centerIn() == 0);
+
+ delete item;
+ delete baseItem;
+}
+
+void tst_qquickanchors::nullItem()
+{
+ QFETCH(QString, side);
+
+ QQuickAnchorLine anchor;
+ QQuickItem *item = new QQuickItem;
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+
+ const QMetaObject *meta = itemPrivate->anchors()->metaObject();
+ QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData()));
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML Item: Cannot anchor to a null item.");
+ QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor)));
+
+ delete item;
+}
+
+void tst_qquickanchors::nullItem_data()
+{
+ QTest::addColumn<QString>("side");
+
+ QTest::newRow("left") << "left";
+ QTest::newRow("top") << "top";
+ QTest::newRow("right") << "right";
+ QTest::newRow("bottom") << "bottom";
+
+ QTest::newRow("hcenter") << "horizontalCenter";
+ QTest::newRow("vcenter") << "verticalCenter";
+ QTest::newRow("baseline") << "baseline";
+}
+
+//QTBUG-5428
+void tst_qquickanchors::crash1()
+{
+ QUrl source(testFileUrl("crash1.qml"));
+
+ QQuickView *view = new QQuickView(source);
+ qApp->processEvents();
+
+ delete view;
+}
+
+void tst_qquickanchors::fill()
+{
+ QQuickView *view = new QQuickView(testFileUrl("fill.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QCOMPARE(rect->x(), 0.0 + 10.0);
+ QCOMPARE(rect->y(), 0.0 + 30.0);
+ QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0);
+ //Alter Offsets (tests QTBUG-6631)
+ rectPrivate->anchors()->setLeftMargin(20.0);
+ rectPrivate->anchors()->setRightMargin(0.0);
+ rectPrivate->anchors()->setBottomMargin(0.0);
+ rectPrivate->anchors()->setTopMargin(10.0);
+ QCOMPARE(rect->x(), 0.0 + 20.0);
+ QCOMPARE(rect->y(), 0.0 + 10.0);
+ QCOMPARE(rect->width(), 200.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 10.0);
+
+ delete view;
+}
+
+void tst_qquickanchors::fillRTL()
+{
+ QQuickView *view = new QQuickView(testFileUrl("fill.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ mirrorAnchors(rect);
+
+ QCOMPARE(rect->x(), 0.0 + 20.0);
+ QCOMPARE(rect->y(), 0.0 + 30.0);
+ QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0);
+ //Alter Offsets (tests QTBUG-6631)
+ rectPrivate->anchors()->setLeftMargin(20.0);
+ rectPrivate->anchors()->setRightMargin(0.0);
+ rectPrivate->anchors()->setBottomMargin(0.0);
+ rectPrivate->anchors()->setTopMargin(10.0);
+ QCOMPARE(rect->x(), 0.0 + 0.0);
+ QCOMPARE(rect->y(), 0.0 + 10.0);
+ QCOMPARE(rect->width(), 200.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 10.0);
+
+ delete view;
+}
+
+void tst_qquickanchors::centerIn()
+{
+ QQuickView *view = new QQuickView(testFileUrl("centerin.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QCOMPARE(rect->x(), 75.0 + 10);
+ QCOMPARE(rect->y(), 75.0 + 30);
+ //Alter Offsets (tests QTBUG-6631)
+ rectPrivate->anchors()->setHorizontalCenterOffset(-20.0);
+ rectPrivate->anchors()->setVerticalCenterOffset(-10.0);
+ QCOMPARE(rect->x(), 75.0 - 20.0);
+ QCOMPARE(rect->y(), 75.0 - 10.0);
+
+ //QTBUG-21730 (use actual center to prevent animation jitter)
+ QQuickRectangle* rect2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered2"));
+ QCOMPARE(rect2->x(), 94.5);
+ QCOMPARE(rect2->y(), 94.5);
+
+ delete view;
+}
+
+void tst_qquickanchors::centerInRTL()
+{
+ QQuickView *view = new QQuickView(testFileUrl("centerin.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ mirrorAnchors(rect);
+
+ QCOMPARE(rect->x(), 75.0 - 10);
+ QCOMPARE(rect->y(), 75.0 + 30);
+ //Alter Offsets (tests QTBUG-6631)
+ rectPrivate->anchors()->setHorizontalCenterOffset(-20.0);
+ rectPrivate->anchors()->setVerticalCenterOffset(-10.0);
+ QCOMPARE(rect->x(), 75.0 + 20.0);
+ QCOMPARE(rect->y(), 75.0 - 10.0);
+
+ delete view;
+}
+
+//QTBUG-12441
+void tst_qquickanchors::centerInRotation()
+{
+ QQuickView *view = new QQuickView(testFileUrl("centerinRotation.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* outer = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("outer"));
+ QQuickRectangle* inner = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("inner"));
+
+ QCOMPARE(outer->x(), qreal(49.5));
+ QCOMPARE(outer->y(), qreal(49.5));
+ QCOMPARE(inner->x(), qreal(25.5));
+ QCOMPARE(inner->y(), qreal(25.5));
+
+ delete view;
+}
+
+void tst_qquickanchors::hvCenter()
+{
+ QQuickView *view = new QQuickView(testFileUrl("hvCenter.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ // test QTBUG-10999
+ QCOMPARE(rect->x(), 10.0);
+ QCOMPARE(rect->y(), 19.0);
+
+ rectPrivate->anchors()->setHorizontalCenterOffset(-5.0);
+ rectPrivate->anchors()->setVerticalCenterOffset(5.0);
+ QCOMPARE(rect->x(), 10.0 - 5.0);
+ QCOMPARE(rect->y(), 19.0 + 5.0);
+
+ delete view;
+}
+
+void tst_qquickanchors::hvCenterRTL()
+{
+ QQuickView *view = new QQuickView(testFileUrl("hvCenter.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ mirrorAnchors(rect);
+
+ // test QTBUG-10999
+ QCOMPARE(rect->x(), 10.0);
+ QCOMPARE(rect->y(), 19.0);
+
+ rectPrivate->anchors()->setHorizontalCenterOffset(-5.0);
+ rectPrivate->anchors()->setVerticalCenterOffset(5.0);
+ QCOMPARE(rect->x(), 10.0 + 5.0);
+ QCOMPARE(rect->y(), 19.0 + 5.0);
+
+ delete view;
+}
+void tst_qquickanchors::margins()
+{
+ QQuickView *view = new QQuickView(testFileUrl("margins.qml"));
+
+ qApp->processEvents();
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QCOMPARE(rect->x(), 5.0);
+ QCOMPARE(rect->y(), 6.0);
+ QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0);
+ QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0);
+
+ rectPrivate->anchors()->setTopMargin(0.0);
+ rectPrivate->anchors()->setMargins(20.0);
+
+ QCOMPARE(rect->x(), 5.0);
+ QCOMPARE(rect->y(), 20.0);
+ QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0);
+
+ delete view;
+}
+
+void tst_qquickanchors::marginsRTL()
+{
+ QQuickView *view = new QQuickView(testFileUrl("margins.qml"));
+
+ QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ mirrorAnchors(rect);
+
+ QCOMPARE(rect->x(), 10.0);
+ QCOMPARE(rect->y(), 6.0);
+ QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0);
+ QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0);
+
+ rectPrivate->anchors()->setTopMargin(0.0);
+ rectPrivate->anchors()->setMargins(20.0);
+
+ QCOMPARE(rect->x(), 20.0);
+ QCOMPARE(rect->y(), 20.0);
+ QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0);
+
+ delete view;
+}
+
+
+QTEST_MAIN(tst_qquickanchors)
+
+#include "tst_qquickanchors.moc"
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/colors.gif b/tests/auto/quick/qquickanimatedimage/data/colors.gif
index 1270bfaa79..1270bfaa79 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/colors.gif
+++ b/tests/auto/quick/qquickanimatedimage/data/colors.gif
Binary files differ
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/colors.qml b/tests/auto/quick/qquickanimatedimage/data/colors.qml
index 5ccc0148dd..5ccc0148dd 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/colors.qml
+++ b/tests/auto/quick/qquickanimatedimage/data/colors.qml
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/hearts.gif b/tests/auto/quick/qquickanimatedimage/data/hearts.gif
index cfb55f27f5..cfb55f27f5 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/hearts.gif
+++ b/tests/auto/quick/qquickanimatedimage/data/hearts.gif
Binary files differ
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/hearts.qml b/tests/auto/quick/qquickanimatedimage/data/hearts.qml
index 717bab430b..717bab430b 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/hearts.qml
+++ b/tests/auto/quick/qquickanimatedimage/data/hearts.qml
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/qmldir b/tests/auto/quick/qquickanimatedimage/data/qmldir
index ef7c1f44f3..ef7c1f44f3 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/qmldir
+++ b/tests/auto/quick/qquickanimatedimage/data/qmldir
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/qtbug-16520.qml b/tests/auto/quick/qquickanimatedimage/data/qtbug-16520.qml
index da77a4063b..da77a4063b 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/qtbug-16520.qml
+++ b/tests/auto/quick/qquickanimatedimage/data/qtbug-16520.qml
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickman.gif b/tests/auto/quick/qquickanimatedimage/data/stickman.gif
index 7c4cd18687..7c4cd18687 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/stickman.gif
+++ b/tests/auto/quick/qquickanimatedimage/data/stickman.gif
Binary files differ
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickman.qml b/tests/auto/quick/qquickanimatedimage/data/stickman.qml
index a47924de21..a47924de21 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/stickman.qml
+++ b/tests/auto/quick/qquickanimatedimage/data/stickman.qml
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanerror1.qml b/tests/auto/quick/qquickanimatedimage/data/stickmanerror1.qml
index 4f823b3d70..4f823b3d70 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanerror1.qml
+++ b/tests/auto/quick/qquickanimatedimage/data/stickmanerror1.qml
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanpause.qml b/tests/auto/quick/qquickanimatedimage/data/stickmanpause.qml
index ef771ed56f..ef771ed56f 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanpause.qml
+++ b/tests/auto/quick/qquickanimatedimage/data/stickmanpause.qml
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanscaled.qml b/tests/auto/quick/qquickanimatedimage/data/stickmanscaled.qml
index 1ef1f95165..1ef1f95165 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanscaled.qml
+++ b/tests/auto/quick/qquickanimatedimage/data/stickmanscaled.qml
diff --git a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanstopped.qml b/tests/auto/quick/qquickanimatedimage/data/stickmanstopped.qml
index 0bf80b8972..0bf80b8972 100644
--- a/tests/auto/qtquick2/qquickanimatedimage/data/stickmanstopped.qml
+++ b/tests/auto/quick/qquickanimatedimage/data/stickmanstopped.qml
diff --git a/tests/auto/quick/qquickanimatedimage/qquickanimatedimage.pro b/tests/auto/quick/qquickanimatedimage/qquickanimatedimage.pro
new file mode 100644
index 0000000000..468a3253f8
--- /dev/null
+++ b/tests/auto/quick/qquickanimatedimage/qquickanimatedimage.pro
@@ -0,0 +1,17 @@
+CONFIG += testcase
+TARGET = tst_qquickanimatedimage
+HEADERS += ../../shared/testhttpserver.h
+SOURCES += tst_qquickanimatedimage.cpp \
+ ../../shared/testhttpserver.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
new file mode 100644
index 0000000000..7775e395cb
--- /dev/null
+++ b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp
@@ -0,0 +1,374 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <private/qquickimage_p.h>
+#include <private/qquickanimatedimage_p.h>
+#include <QSignalSpy>
+#include <QtQml/qqmlcontext.h>
+
+#include "../../shared/testhttpserver.h"
+#include "../../shared/util.h"
+
+Q_DECLARE_METATYPE(QQuickImageBase::Status)
+
+class tst_qquickanimatedimage : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickanimatedimage() {}
+
+private slots:
+ void play();
+ void pause();
+ void stopped();
+ void setFrame();
+ void frameCount();
+ void mirror_running();
+ void mirror_notRunning();
+ void mirror_notRunning_data();
+ void remote();
+ void remote_data();
+ void sourceSize();
+ void sourceSizeReadOnly();
+ void invalidSource();
+ void qtbug_16520();
+ void progressAndStatusChanges();
+
+};
+
+void tst_qquickanimatedimage::play()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("stickman.qml"));
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(anim->isPlaying());
+
+ delete anim;
+}
+
+void tst_qquickanimatedimage::pause()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("stickmanpause.qml"));
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(anim->isPlaying());
+ QVERIFY(anim->isPaused());
+
+ delete anim;
+}
+
+void tst_qquickanimatedimage::stopped()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("stickmanstopped.qml"));
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(!anim->isPlaying());
+ QCOMPARE(anim->currentFrame(), 0);
+
+ delete anim;
+}
+
+void tst_qquickanimatedimage::setFrame()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("stickmanpause.qml"));
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(anim->isPlaying());
+ QCOMPARE(anim->currentFrame(), 2);
+
+ delete anim;
+}
+
+void tst_qquickanimatedimage::frameCount()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("colors.qml"));
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QVERIFY(anim->isPlaying());
+ QCOMPARE(anim->frameCount(), 3);
+
+ delete anim;
+}
+
+void tst_qquickanimatedimage::mirror_running()
+{
+ // test where mirror is set to true after animation has started
+
+ QQuickView canvas;
+ canvas.show();
+
+ canvas.setSource(testFileUrl("hearts.qml"));
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(canvas.rootObject());
+ QVERIFY(anim);
+
+ int width = anim->property("width").toInt();
+
+ QCOMPARE(anim->currentFrame(), 0);
+ QPixmap frame0 = QPixmap::fromImage(canvas.grabFrameBuffer());
+
+ anim->setCurrentFrame(1);
+ QPixmap frame1 = QPixmap::fromImage(canvas.grabFrameBuffer());
+
+ anim->setCurrentFrame(0);
+
+ QSignalSpy spy(anim, SIGNAL(frameChanged()));
+ anim->setPlaying(true);
+
+ QTRY_VERIFY(spy.count() == 1); spy.clear();
+ anim->setProperty("mirror", true);
+
+ QCOMPARE(anim->currentFrame(), 1);
+ QPixmap frame1_flipped = QPixmap::fromImage(canvas.grabFrameBuffer());
+
+ QTRY_VERIFY(spy.count() == 1); spy.clear();
+ QCOMPARE(anim->currentFrame(), 0); // animation only has 2 frames, should cycle back to first
+ QPixmap frame0_flipped = QPixmap::fromImage(canvas.grabFrameBuffer());
+
+ QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved");
+
+ QTransform transform;
+ transform.translate(width, 0).scale(-1, 1.0);
+ QPixmap frame0_expected = frame0.transformed(transform);
+ QPixmap frame1_expected = frame1.transformed(transform);
+
+ QCOMPARE(frame0_flipped, frame0_expected);
+ QCOMPARE(frame1_flipped, frame1_expected);
+}
+
+void tst_qquickanimatedimage::mirror_notRunning()
+{
+ QFETCH(QUrl, fileUrl);
+
+ QQuickView canvas;
+ canvas.show();
+
+ canvas.setSource(fileUrl);
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(canvas.rootObject());
+ QVERIFY(anim);
+
+ int width = anim->property("width").toInt();
+ QPixmap screenshot = QPixmap::fromImage(canvas.grabFrameBuffer());
+
+ QTransform transform;
+ transform.translate(width, 0).scale(-1, 1.0);
+ QPixmap expected = screenshot.transformed(transform);
+
+ int frame = anim->currentFrame();
+ bool playing = anim->isPlaying();
+ bool paused = anim->isPlaying();
+
+ anim->setProperty("mirror", true);
+ screenshot = QPixmap::fromImage(canvas.grabFrameBuffer());
+
+ QSKIP("Skip while QTBUG-19351 and QTBUG-19252 are not resolved");
+ QCOMPARE(screenshot, expected);
+
+ // mirroring should not change the current frame or playing status
+ QCOMPARE(anim->currentFrame(), frame);
+ QCOMPARE(anim->isPlaying(), playing);
+ QCOMPARE(anim->isPaused(), paused);
+}
+
+void tst_qquickanimatedimage::mirror_notRunning_data()
+{
+ QTest::addColumn<QUrl>("fileUrl");
+
+ QTest::newRow("paused") << testFileUrl("stickmanpause.qml");
+ QTest::newRow("stopped") << testFileUrl("stickmanstopped.qml");
+}
+
+void tst_qquickanimatedimage::remote()
+{
+ QFETCH(QString, fileName);
+ QFETCH(bool, paused);
+
+ TestHTTPServer server(14449);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName));
+ QTRY_VERIFY(component.isReady());
+
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
+ QVERIFY(anim);
+
+ QTRY_VERIFY(anim->isPlaying());
+ if (paused) {
+ QTRY_VERIFY(anim->isPaused());
+ QCOMPARE(anim->currentFrame(), 2);
+ }
+ QVERIFY(anim->status() != QQuickAnimatedImage::Error);
+
+ delete anim;
+}
+
+void tst_qquickanimatedimage::sourceSize()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("stickmanscaled.qml"));
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
+ QVERIFY(anim);
+ QCOMPARE(anim->width(),240.0);
+ QCOMPARE(anim->height(),180.0);
+ QCOMPARE(anim->sourceSize(),QSize(160,120));
+
+ delete anim;
+}
+
+void tst_qquickanimatedimage::sourceSizeReadOnly()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("stickmanerror1.qml"));
+ QVERIFY(component.isError());
+ QCOMPARE(component.errors().at(0).description(), QString("Invalid property assignment: \"sourceSize\" is a read-only property"));
+}
+
+void tst_qquickanimatedimage::remote_data()
+{
+ QTest::addColumn<QString>("fileName");
+ QTest::addColumn<bool>("paused");
+
+ QTest::newRow("playing") << "stickman.qml" << false;
+ QTest::newRow("paused") << "stickmanpause.qml" << true;
+}
+
+void tst_qquickanimatedimage::invalidSource()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl::fromLocalFile(""));
+ QVERIFY(component.isReady());
+
+ QTest::ignoreMessage(QtWarningMsg, "file::2:2: QML AnimatedImage: Error Reading Animated Image File file:no-such-file.gif");
+
+ QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
+ QVERIFY(anim);
+
+ QVERIFY(!anim->isPlaying());
+ QVERIFY(!anim->isPaused());
+ QCOMPARE(anim->currentFrame(), 0);
+ QCOMPARE(anim->frameCount(), 0);
+ QTRY_VERIFY(anim->status() == 3);
+}
+
+void tst_qquickanimatedimage::qtbug_16520()
+{
+ TestHTTPServer server(14449);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("qtbug-16520.qml"));
+ QTRY_VERIFY(component.isReady());
+
+ QQuickRectangle *root = qobject_cast<QQuickRectangle *>(component.create());
+ QVERIFY(root);
+ QQuickAnimatedImage *anim = root->findChild<QQuickAnimatedImage*>("anim");
+
+ anim->setProperty("source", "http://127.0.0.1:14449/stickman.gif");
+
+ QTRY_VERIFY(anim->opacity() == 0);
+ QTRY_VERIFY(anim->opacity() == 1);
+
+ delete anim;
+}
+
+void tst_qquickanimatedimage::progressAndStatusChanges()
+{
+ TestHTTPServer server(14449);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+
+ QQmlEngine engine;
+ QString componentStr = "import QtQuick 2.0\nAnimatedImage { source: srcImage }";
+ QQmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", testFileUrl("stickman.gif"));
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->status() == QQuickImage::Ready);
+ QTRY_VERIFY(obj->progress() == 1.0);
+
+ qRegisterMetaType<QQuickImageBase::Status>();
+ QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &)));
+ QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal)));
+ QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status)));
+
+ // Loading local file
+ ctxt->setContextProperty("srcImage", testFileUrl("colors.gif"));
+ QTRY_VERIFY(obj->status() == QQuickImage::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", "http://127.0.0.1:14449/stickman.gif");
+ QTRY_VERIFY(obj->status() == QQuickImage::Loading);
+ QTRY_VERIFY(obj->progress() == 0.0);
+ QTRY_VERIFY(obj->status() == QQuickImage::Ready);
+ QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(sourceSpy.count(), 2);
+ QTRY_VERIFY(progressSpy.count() > 1);
+ QTRY_COMPARE(statusSpy.count(), 2);
+
+ ctxt->setContextProperty("srcImage", "");
+ QTRY_VERIFY(obj->status() == QQuickImage::Null);
+ QTRY_VERIFY(obj->progress() == 0.0);
+ QTRY_COMPARE(sourceSpy.count(), 3);
+ QTRY_VERIFY(progressSpy.count() > 2);
+ QTRY_COMPARE(statusSpy.count(), 3);
+}
+
+QTEST_MAIN(tst_qquickanimatedimage)
+
+#include "tst_qquickanimatedimage.moc"
diff --git a/tests/auto/qtquick2/qdeclarativeanimationcontroller/data/tst_numberanimation.qml b/tests/auto/quick/qquickanimationcontroller/data/tst_numberanimation.qml
index 7c4496b206..7c4496b206 100644
--- a/tests/auto/qtquick2/qdeclarativeanimationcontroller/data/tst_numberanimation.qml
+++ b/tests/auto/quick/qquickanimationcontroller/data/tst_numberanimation.qml
diff --git a/tests/auto/quick/qquickanimationcontroller/qquickanimationcontroller.pro b/tests/auto/quick/qquickanimationcontroller/qquickanimationcontroller.pro
new file mode 100644
index 0000000000..72a09fcb9c
--- /dev/null
+++ b/tests/auto/quick/qquickanimationcontroller/qquickanimationcontroller.pro
@@ -0,0 +1,10 @@
+QT += core-private gui-private qml-private
+TEMPLATE=app
+TARGET=tst_qquickanimationcontroller
+
+CONFIG += warn_on qmltestcase
+SOURCES += tst_qquickanimationcontroller.cpp
+
+importFiles.files = data
+importFiles.path = .
+DEPLOYMENT += importFiles
diff --git a/tests/auto/quick/qquickanimationcontroller/tst_qquickanimationcontroller.cpp b/tests/auto/quick/qquickanimationcontroller/tst_qquickanimationcontroller.cpp
new file mode 100644
index 0000000000..8c851bcf65
--- /dev/null
+++ b/tests/auto/quick/qquickanimationcontroller/tst_qquickanimationcontroller.cpp
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtQuickTest/quicktest.h>
+QUICK_TEST_MAIN(qquickanimationcontroller)
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/Double.qml b/tests/auto/quick/qquickanimations/data/Double.qml
index 99ffca1d62..99ffca1d62 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/Double.qml
+++ b/tests/auto/quick/qquickanimations/data/Double.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/attached.qml b/tests/auto/quick/qquickanimations/data/attached.qml
index 9dcfcd8752..9dcfcd8752 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/attached.qml
+++ b/tests/auto/quick/qquickanimations/data/attached.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/badproperty1.qml b/tests/auto/quick/qquickanimations/data/badproperty1.qml
index 9634c2c169..9634c2c169 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/badproperty1.qml
+++ b/tests/auto/quick/qquickanimations/data/badproperty1.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/badproperty2.qml b/tests/auto/quick/qquickanimations/data/badproperty2.qml
index c121172a99..c121172a99 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/badproperty2.qml
+++ b/tests/auto/quick/qquickanimations/data/badproperty2.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype1.qml b/tests/auto/quick/qquickanimations/data/badtype1.qml
index 43e1ec8572..43e1ec8572 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype1.qml
+++ b/tests/auto/quick/qquickanimations/data/badtype1.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype2.qml b/tests/auto/quick/qquickanimations/data/badtype2.qml
index 5341cb3d1c..5341cb3d1c 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype2.qml
+++ b/tests/auto/quick/qquickanimations/data/badtype2.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype3.qml b/tests/auto/quick/qquickanimations/data/badtype3.qml
index 182efa0840..182efa0840 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype3.qml
+++ b/tests/auto/quick/qquickanimations/data/badtype3.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype4.qml b/tests/auto/quick/qquickanimations/data/badtype4.qml
index f091e2430f..f091e2430f 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/badtype4.qml
+++ b/tests/auto/quick/qquickanimations/data/badtype4.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/disabledTransition.qml b/tests/auto/quick/qquickanimations/data/disabledTransition.qml
index 0fbafead8b..0fbafead8b 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/disabledTransition.qml
+++ b/tests/auto/quick/qquickanimations/data/disabledTransition.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/dontAutoStart.qml b/tests/auto/quick/qquickanimations/data/dontAutoStart.qml
index c0c0c65e3f..c0c0c65e3f 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/dontAutoStart.qml
+++ b/tests/auto/quick/qquickanimations/data/dontAutoStart.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/dontStart.qml b/tests/auto/quick/qquickanimations/data/dontStart.qml
index 3eee0cfd35..3eee0cfd35 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/dontStart.qml
+++ b/tests/auto/quick/qquickanimations/data/dontStart.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/dontStart2.qml b/tests/auto/quick/qquickanimations/data/dontStart2.qml
index e7b4164e4e..e7b4164e4e 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/dontStart2.qml
+++ b/tests/auto/quick/qquickanimations/data/dontStart2.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/dotproperty.qml b/tests/auto/quick/qquickanimations/data/dotproperty.qml
index e0e46dcef5..e0e46dcef5 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/dotproperty.qml
+++ b/tests/auto/quick/qquickanimations/data/dotproperty.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/doubleRegistrationBug.qml b/tests/auto/quick/qquickanimations/data/doubleRegistrationBug.qml
index 9ef3da20c0..9ef3da20c0 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/doubleRegistrationBug.qml
+++ b/tests/auto/quick/qquickanimations/data/doubleRegistrationBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/looping.qml b/tests/auto/quick/qquickanimations/data/looping.qml
index a3d40ae837..a3d40ae837 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/looping.qml
+++ b/tests/auto/quick/qquickanimations/data/looping.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype1.qml b/tests/auto/quick/qquickanimations/data/mixedtype1.qml
index 76129dd15e..76129dd15e 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype1.qml
+++ b/tests/auto/quick/qquickanimations/data/mixedtype1.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype2.qml b/tests/auto/quick/qquickanimations/data/mixedtype2.qml
index 1a7166e3f3..1a7166e3f3 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/mixedtype2.qml
+++ b/tests/auto/quick/qquickanimations/data/mixedtype2.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/nonTransitionBug.qml b/tests/auto/quick/qquickanimations/data/nonTransitionBug.qml
index 909c533e7b..909c533e7b 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/nonTransitionBug.qml
+++ b/tests/auto/quick/qquickanimations/data/nonTransitionBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation.qml b/tests/auto/quick/qquickanimations/data/pathAnimation.qml
index d2006a1c6a..d2006a1c6a 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation.qml
+++ b/tests/auto/quick/qquickanimations/data/pathAnimation.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation2.qml b/tests/auto/quick/qquickanimations/data/pathAnimation2.qml
index 2f64dac2cc..2f64dac2cc 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimation2.qml
+++ b/tests/auto/quick/qquickanimations/data/pathAnimation2.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimationNoStart.qml b/tests/auto/quick/qquickanimations/data/pathAnimationNoStart.qml
index be3501fabb..be3501fabb 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathAnimationNoStart.qml
+++ b/tests/auto/quick/qquickanimations/data/pathAnimationNoStart.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolator.qml b/tests/auto/quick/qquickanimations/data/pathInterpolator.qml
index 0104412d7c..0104412d7c 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolator.qml
+++ b/tests/auto/quick/qquickanimations/data/pathInterpolator.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack.qml b/tests/auto/quick/qquickanimations/data/pathInterpolatorBack.qml
index 41366ef798..41366ef798 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack.qml
+++ b/tests/auto/quick/qquickanimations/data/pathInterpolatorBack.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack2.qml b/tests/auto/quick/qquickanimations/data/pathInterpolatorBack2.qml
index eb3d4c3f86..eb3d4c3f86 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathInterpolatorBack2.qml
+++ b/tests/auto/quick/qquickanimations/data/pathInterpolatorBack2.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pathTransition.qml b/tests/auto/quick/qquickanimations/data/pathTransition.qml
index 55ffc33f95..55ffc33f95 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pathTransition.qml
+++ b/tests/auto/quick/qquickanimations/data/pathTransition.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pauseBindingBug.qml b/tests/auto/quick/qquickanimations/data/pauseBindingBug.qml
index 359cda166f..359cda166f 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pauseBindingBug.qml
+++ b/tests/auto/quick/qquickanimations/data/pauseBindingBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/pauseBug.qml b/tests/auto/quick/qquickanimations/data/pauseBug.qml
index fa2c4be4ba..fa2c4be4ba 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/pauseBug.qml
+++ b/tests/auto/quick/qquickanimations/data/pauseBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/properties.qml b/tests/auto/quick/qquickanimations/data/properties.qml
index f0f730967c..f0f730967c 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/properties.qml
+++ b/tests/auto/quick/qquickanimations/data/properties.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/properties2.qml b/tests/auto/quick/qquickanimations/data/properties2.qml
index 6b7f026e0b..6b7f026e0b 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/properties2.qml
+++ b/tests/auto/quick/qquickanimations/data/properties2.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/properties3.qml b/tests/auto/quick/qquickanimations/data/properties3.qml
index 5eb65496d4..5eb65496d4 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/properties3.qml
+++ b/tests/auto/quick/qquickanimations/data/properties3.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/properties4.qml b/tests/auto/quick/qquickanimations/data/properties4.qml
index dfe8ad17e7..dfe8ad17e7 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/properties4.qml
+++ b/tests/auto/quick/qquickanimations/data/properties4.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/properties5.qml b/tests/auto/quick/qquickanimations/data/properties5.qml
index 075fc9bc5a..075fc9bc5a 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/properties5.qml
+++ b/tests/auto/quick/qquickanimations/data/properties5.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition.qml
index 968c5f6285..968c5f6285 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition.qml
+++ b/tests/auto/quick/qquickanimations/data/propertiesTransition.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition2.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition2.qml
index f06165604a..f06165604a 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition2.qml
+++ b/tests/auto/quick/qquickanimations/data/propertiesTransition2.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition3.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition3.qml
index 7d3b3b9c6d..7d3b3b9c6d 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition3.qml
+++ b/tests/auto/quick/qquickanimations/data/propertiesTransition3.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition4.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition4.qml
index 1c31a79634..1c31a79634 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition4.qml
+++ b/tests/auto/quick/qquickanimations/data/propertiesTransition4.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition5.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition5.qml
index a2ff746900..a2ff746900 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition5.qml
+++ b/tests/auto/quick/qquickanimations/data/propertiesTransition5.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition6.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition6.qml
index d3db01efb0..d3db01efb0 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition6.qml
+++ b/tests/auto/quick/qquickanimations/data/propertiesTransition6.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition7.qml b/tests/auto/quick/qquickanimations/data/propertiesTransition7.qml
index 98898de8ef..98898de8ef 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/propertiesTransition7.qml
+++ b/tests/auto/quick/qquickanimations/data/propertiesTransition7.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/reanchor.qml b/tests/auto/quick/qquickanimations/data/reanchor.qml
index 241cc81a96..241cc81a96 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/reanchor.qml
+++ b/tests/auto/quick/qquickanimations/data/reanchor.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/registrationBug.qml b/tests/auto/quick/qquickanimations/data/registrationBug.qml
index 633da4e17f..633da4e17f 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/registrationBug.qml
+++ b/tests/auto/quick/qquickanimations/data/registrationBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/reparent.qml b/tests/auto/quick/qquickanimations/data/reparent.qml
index 39f1e7a6d2..39f1e7a6d2 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/reparent.qml
+++ b/tests/auto/quick/qquickanimations/data/reparent.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/rotation.qml b/tests/auto/quick/qquickanimations/data/rotation.qml
index 4dc42a1bd2..4dc42a1bd2 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/rotation.qml
+++ b/tests/auto/quick/qquickanimations/data/rotation.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/runningTrueBug.qml b/tests/auto/quick/qquickanimations/data/runningTrueBug.qml
index bec6fab368..bec6fab368 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/runningTrueBug.qml
+++ b/tests/auto/quick/qquickanimations/data/runningTrueBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/transitionAssignmentBug.qml b/tests/auto/quick/qquickanimations/data/transitionAssignmentBug.qml
index 508693e0fc..508693e0fc 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/transitionAssignmentBug.qml
+++ b/tests/auto/quick/qquickanimations/data/transitionAssignmentBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/valuesource.qml b/tests/auto/quick/qquickanimations/data/valuesource.qml
index 7a636b4003..7a636b4003 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/valuesource.qml
+++ b/tests/auto/quick/qquickanimations/data/valuesource.qml
diff --git a/tests/auto/qtquick2/qdeclarativeanimations/data/valuesource2.qml b/tests/auto/quick/qquickanimations/data/valuesource2.qml
index 9788761ee8..9788761ee8 100644
--- a/tests/auto/qtquick2/qdeclarativeanimations/data/valuesource2.qml
+++ b/tests/auto/quick/qquickanimations/data/valuesource2.qml
diff --git a/tests/auto/quick/qquickanimations/qquickanimations.pro b/tests/auto/quick/qquickanimations/qquickanimations.pro
new file mode 100644
index 0000000000..0e432ab9f1
--- /dev/null
+++ b/tests/auto/quick/qquickanimations/qquickanimations.pro
@@ -0,0 +1,18 @@
+CONFIG += testcase
+TARGET = tst_qquickanimations
+SOURCES += tst_qquickanimations.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
+
+# QTBUG-23385 - color mixing tests failing on Ubuntu 11.10 x64
+linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC
diff --git a/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
new file mode 100644
index 0000000000..108bce64f9
--- /dev/null
+++ b/tests/auto/quick/qquickanimations/tst_qquickanimations.cpp
@@ -0,0 +1,1319 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/private/qanimationgroupjob_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQuick/private/qquickanimation_p.h>
+#include <QtQuick/private/qquicktransition_p.h>
+#include <QtQuick/private/qquickitemanimation_p.h>
+#include <QtQuick/private/qquickpathinterpolator_p.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QEasingCurve>
+
+#include <limits.h>
+#include <math.h>
+
+#include "../../shared/util.h"
+
+class tst_qquickanimations : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickanimations() {}
+
+private slots:
+ void initTestCase()
+ {
+ QQmlEngine engine; // ensure types are registered
+ QQmlDataTest::initTestCase();
+ }
+
+ void simpleProperty();
+ void simpleNumber();
+ void simpleColor();
+ void simpleRotation();
+ void simplePath();
+ void simpleAnchor();
+ void reparent();
+ void pathInterpolator();
+ void pathInterpolatorBackwardJump();
+ void pathWithNoStart();
+ void alwaysRunToEnd();
+ void complete();
+ void resume();
+ void dotProperty();
+ void badTypes();
+ void badProperties();
+ void mixedTypes();
+ void properties();
+ void propertiesTransition();
+ void pathTransition();
+ void disabledTransition();
+ void invalidDuration();
+ void attached();
+ void propertyValueSourceDefaultStart();
+ void dontStart();
+ void easingProperties();
+ void rotation();
+ void runningTrueBug();
+ void nonTransitionBug();
+ void registrationBug();
+ void doubleRegistrationBug();
+ void alwaysRunToEndRestartBug();
+ void transitionAssignmentBug();
+ void pauseBindingBug();
+ void pauseBug();
+ void loopingBug();
+};
+
+#define QTIMED_COMPARE(lhs, rhs) do { \
+ for (int ii = 0; ii < 5; ++ii) { \
+ if (lhs == rhs) \
+ break; \
+ QTest::qWait(50); \
+ } \
+ QCOMPARE(lhs, rhs); \
+} while (false)
+
+void tst_qquickanimations::simpleProperty()
+{
+ QQuickRectangle rect;
+ QQuickPropertyAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("x");
+ animation.setTo(200);
+ QVERIFY(animation.target() == &rect);
+ QVERIFY(animation.property() == "x");
+ QVERIFY(animation.to().toReal() == 200.0);
+ animation.start();
+ QVERIFY(animation.isRunning());
+ QTest::qWait(animation.duration());
+ QTIMED_COMPARE(rect.x(), 200.0);
+
+ rect.setPos(QPointF(0,0));
+ animation.start();
+ QVERIFY(animation.isRunning());
+ animation.pause();
+ QVERIFY(animation.isPaused());
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(rect.x(),100.0);
+}
+
+void tst_qquickanimations::simpleNumber()
+{
+ QQuickRectangle rect;
+ QQuickNumberAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("x");
+ animation.setTo(200);
+ QVERIFY(animation.target() == &rect);
+ QVERIFY(animation.property() == "x");
+ QVERIFY(animation.to() == 200);
+ animation.start();
+ QVERIFY(animation.isRunning());
+ QTest::qWait(animation.duration());
+ QTIMED_COMPARE(rect.x(), qreal(200));
+
+ rect.setX(0);
+ animation.start();
+ animation.pause();
+ QVERIFY(animation.isRunning());
+ QVERIFY(animation.isPaused());
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(rect.x(), qreal(100));
+}
+
+void tst_qquickanimations::simpleColor()
+{
+ QQuickRectangle rect;
+ QQuickColorAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("color");
+ animation.setTo(QColor("red"));
+ QVERIFY(animation.target() == &rect);
+ QVERIFY(animation.property() == "color");
+ QVERIFY(animation.to() == QColor("red"));
+ animation.start();
+ QVERIFY(animation.isRunning());
+ QTest::qWait(animation.duration());
+ QTIMED_COMPARE(rect.color(), QColor("red"));
+
+ rect.setColor(QColor("blue"));
+ animation.start();
+ animation.pause();
+ QVERIFY(animation.isRunning());
+ QVERIFY(animation.isPaused());
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__)
+ QEXPECT_FAIL("", "Fails on this platform - QTBUG-23385", Abort);
+#endif
+ QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
+
+ rect.setColor(QColor("green"));
+ animation.setFrom(QColor("blue"));
+ QVERIFY(animation.from() == QColor("blue"));
+ animation.restart();
+ QCOMPARE(rect.color(), QColor("blue"));
+ QVERIFY(animation.isRunning());
+ animation.setCurrentTime(125);
+ QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1));
+}
+
+void tst_qquickanimations::simpleRotation()
+{
+ QQuickRectangle rect;
+ QQuickRotationAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("rotation");
+ animation.setTo(270);
+ QVERIFY(animation.target() == &rect);
+ QVERIFY(animation.property() == "rotation");
+ QVERIFY(animation.to() == 270);
+ QVERIFY(animation.direction() == QQuickRotationAnimation::Numerical);
+ animation.start();
+ QVERIFY(animation.isRunning());
+ QTest::qWait(animation.duration());
+ QTIMED_COMPARE(rect.rotation(), qreal(270));
+
+ rect.setRotation(0);
+ animation.start();
+ animation.pause();
+ QVERIFY(animation.isRunning());
+ QVERIFY(animation.isPaused());
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(rect.rotation(), qreal(135));
+}
+
+void tst_qquickanimations::simplePath()
+{
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathAnimation.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
+ QVERIFY(redRect);
+ QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
+ QVERIFY(pathAnim);
+
+ QCOMPARE(pathAnim->duration(), 100);
+ QCOMPARE(pathAnim->target(), redRect);
+
+ pathAnim->start();
+ pathAnim->pause();
+
+ pathAnim->setCurrentTime(30);
+ QCOMPARE(redRect->x(), qreal(167));
+ QCOMPARE(redRect->y(), qreal(104));
+
+ pathAnim->setCurrentTime(100);
+ QCOMPARE(redRect->x(), qreal(300));
+ QCOMPARE(redRect->y(), qreal(300));
+
+ //verify animation runs to end
+ pathAnim->start();
+ QCOMPARE(redRect->x(), qreal(50));
+ QCOMPARE(redRect->y(), qreal(50));
+ QTRY_COMPARE(redRect->x(), qreal(300));
+ QCOMPARE(redRect->y(), qreal(300));
+
+ pathAnim->setOrientation(QQuickPathAnimation::RightFirst);
+ QCOMPARE(pathAnim->orientation(), QQuickPathAnimation::RightFirst);
+ pathAnim->start();
+ QTRY_VERIFY(redRect->rotation() != 0);
+ pathAnim->stop();
+
+ delete rect;
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathAnimation2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
+ QVERIFY(redRect);
+ QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
+ QVERIFY(pathAnim);
+
+ QCOMPARE(pathAnim->orientation(), QQuickPathAnimation::RightFirst);
+ QCOMPARE(pathAnim->endRotation(), qreal(0));
+ QCOMPARE(pathAnim->orientationEntryDuration(), 10);
+ QCOMPARE(pathAnim->orientationExitDuration(), 10);
+
+ pathAnim->start();
+ pathAnim->pause();
+ QCOMPARE(redRect->x(), qreal(50));
+ QCOMPARE(redRect->y(), qreal(50));
+ QCOMPARE(redRect->rotation(), qreal(-360));
+
+ pathAnim->setCurrentTime(50);
+ QCOMPARE(redRect->x(), qreal(175));
+ QCOMPARE(redRect->y(), qreal(175));
+ QCOMPARE(redRect->rotation(), qreal(-315));
+
+ pathAnim->setCurrentTime(100);
+ QCOMPARE(redRect->x(), qreal(300));
+ QCOMPARE(redRect->y(), qreal(300));
+ QCOMPARE(redRect->rotation(), qreal(0));
+
+ delete rect;
+ }
+}
+
+void tst_qquickanimations::simpleAnchor()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("reanchor.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *greenRect = rect->findChild<QQuickRectangle*>();
+ QVERIFY(greenRect);
+
+ QCOMPARE(rect->state(), QLatin1String("reanchored"));
+ QCOMPARE(greenRect->x(), qreal(10));
+ QCOMPARE(greenRect->y(), qreal(0));
+ QCOMPARE(greenRect->width(), qreal(190));
+ QCOMPARE(greenRect->height(), qreal(150));
+
+ rect->setState("");
+
+ //verify animation in progress
+ QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0);
+ QVERIFY(greenRect->y() > 0 && greenRect->y() < 10);
+ QVERIFY(greenRect->width() < 190 && greenRect->width() > 150);
+ QVERIFY(greenRect->height() > 150 && greenRect->height() < 190);
+
+ //verify end state ("")
+ QTRY_COMPARE(greenRect->x(), qreal(0));
+ QCOMPARE(greenRect->y(), qreal(10));
+ QCOMPARE(greenRect->width(), qreal(150));
+ QCOMPARE(greenRect->height(), qreal(190));
+
+ rect->setState("reanchored2");
+
+ //verify animation in progress
+ QTRY_VERIFY(greenRect->y() > 10 && greenRect->y() < 50);
+ QVERIFY(greenRect->height() > 125 && greenRect->height() < 190);
+ //NOTE: setting left/right anchors to undefined removes the anchors, but does not resize.
+ QCOMPARE(greenRect->x(), qreal(0));
+ QCOMPARE(greenRect->width(), qreal(150));
+
+ //verify end state ("reanchored2")
+ QTRY_COMPARE(greenRect->y(), qreal(50));
+ QCOMPARE(greenRect->height(), qreal(125));
+ QCOMPARE(greenRect->x(), qreal(0));
+ QCOMPARE(greenRect->width(), qreal(150));
+
+ rect->setState("reanchored");
+
+ //verify animation in progress
+ QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0);
+ QVERIFY(greenRect->y() > 0 && greenRect->y() < 50);
+ QVERIFY(greenRect->width() < 190 && greenRect->width() > 150);
+ QVERIFY(greenRect->height() > 125 && greenRect->height() < 150);
+
+ //verify end state ("reanchored")
+ QTRY_COMPARE(greenRect->x(), qreal(10));
+ QCOMPARE(greenRect->y(), qreal(0));
+ QCOMPARE(greenRect->width(), qreal(190));
+ QCOMPARE(greenRect->height(), qreal(150));
+
+ rect->setState("reanchored2");
+
+ //verify animation in progress
+ QTRY_VERIFY(greenRect->x() < 10 && greenRect->x() > 0);
+ QVERIFY(greenRect->y() > 0 && greenRect->y() < 50);
+ QVERIFY(greenRect->width() < 190 && greenRect->width() > 150);
+ QVERIFY(greenRect->height() > 125 && greenRect->height() < 150);
+
+ //verify end state ("reanchored2")
+ QTRY_COMPARE(greenRect->x(), qreal(0));
+ QCOMPARE(greenRect->y(), qreal(50));
+ QCOMPARE(greenRect->width(), qreal(150));
+ QCOMPARE(greenRect->height(), qreal(125));
+
+ delete rect;
+}
+
+void tst_qquickanimations::reparent()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("reparent.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *target = rect->findChild<QQuickRectangle*>("target");
+ QVERIFY(target);
+
+ QCOMPARE(target->parentItem(), rect);
+ QCOMPARE(target->x(), qreal(0));
+ QCOMPARE(target->y(), qreal(0));
+ QCOMPARE(target->width(), qreal(50));
+ QCOMPARE(target->height(), qreal(50));
+ QCOMPARE(target->rotation(), qreal(0));
+ QCOMPARE(target->scale(), qreal(1));
+
+ rect->setState("state1");
+
+ QQuickRectangle *viaParent = rect->findChild<QQuickRectangle*>("viaParent");
+ QVERIFY(viaParent);
+
+ QQuickRectangle *newParent = rect->findChild<QQuickRectangle*>("newParent");
+ QVERIFY(newParent);
+
+ QTest::qWait(100);
+
+ //animation in progress
+ QTRY_COMPARE(target->parentItem(), viaParent);
+ QVERIFY(target->x() > -100 && target->x() < 50);
+ QVERIFY(target->y() > -100 && target->y() < 50);
+ QVERIFY(target->width() > 50 && target->width() < 100);
+ QCOMPARE(target->height(), qreal(50));
+ QCOMPARE(target->rotation(), qreal(-45));
+ QCOMPARE(target->scale(), qreal(.5));
+
+ //end state
+ QTRY_COMPARE(target->parentItem(), newParent);
+ QCOMPARE(target->x(), qreal(50));
+ QCOMPARE(target->y(), qreal(50));
+ QCOMPARE(target->width(), qreal(100));
+ QCOMPARE(target->height(), qreal(50));
+ QCOMPARE(target->rotation(), qreal(0));
+ QCOMPARE(target->scale(), qreal(1));
+
+ delete rect;
+}
+
+void tst_qquickanimations::pathInterpolator()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathInterpolator.qml"));
+ QQuickPathInterpolator *interpolator = qobject_cast<QQuickPathInterpolator*>(c.create());
+ QVERIFY(interpolator);
+
+ QCOMPARE(interpolator->progress(), qreal(0));
+ QCOMPARE(interpolator->x(), qreal(50));
+ QCOMPARE(interpolator->y(), qreal(50));
+ QCOMPARE(interpolator->angle(), qreal(0));
+
+ interpolator->setProgress(.5);
+ QCOMPARE(interpolator->progress(), qreal(.5));
+ QCOMPARE(interpolator->x(), qreal(175));
+ QCOMPARE(interpolator->y(), qreal(175));
+ QCOMPARE(interpolator->angle(), qreal(90));
+
+ interpolator->setProgress(1);
+ QCOMPARE(interpolator->progress(), qreal(1));
+ QCOMPARE(interpolator->x(), qreal(300));
+ QCOMPARE(interpolator->y(), qreal(300));
+ QCOMPARE(interpolator->angle(), qreal(0));
+}
+
+void tst_qquickanimations::pathInterpolatorBackwardJump()
+{
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathInterpolatorBack.qml"));
+ QQuickPathInterpolator *interpolator = qobject_cast<QQuickPathInterpolator*>(c.create());
+ QVERIFY(interpolator);
+
+ QCOMPARE(interpolator->progress(), qreal(0));
+ QCOMPARE(interpolator->x(), qreal(50));
+ QCOMPARE(interpolator->y(), qreal(50));
+ QCOMPARE(interpolator->angle(), qreal(90));
+
+ interpolator->setProgress(.5);
+ QCOMPARE(interpolator->progress(), qreal(.5));
+ QCOMPARE(interpolator->x(), qreal(100));
+ QCOMPARE(interpolator->y(), qreal(75));
+ QCOMPARE(interpolator->angle(), qreal(270));
+
+ interpolator->setProgress(1);
+ QCOMPARE(interpolator->progress(), qreal(1));
+ QCOMPARE(interpolator->x(), qreal(200));
+ QCOMPARE(interpolator->y(), qreal(50));
+ QCOMPARE(interpolator->angle(), qreal(0));
+
+ //make sure we don't get caught in infinite loop here
+ interpolator->setProgress(0);
+ QCOMPARE(interpolator->progress(), qreal(0));
+ QCOMPARE(interpolator->x(), qreal(50));
+ QCOMPARE(interpolator->y(), qreal(50));
+ QCOMPARE(interpolator->angle(), qreal(90));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathInterpolatorBack2.qml"));
+ QQuickPathInterpolator *interpolator = qobject_cast<QQuickPathInterpolator*>(c.create());
+ QVERIFY(interpolator);
+
+ QCOMPARE(interpolator->progress(), qreal(0));
+ QCOMPARE(interpolator->x(), qreal(200));
+ QCOMPARE(interpolator->y(), qreal(280));
+ QCOMPARE(interpolator->angle(), qreal(180));
+
+ interpolator->setProgress(1);
+ QCOMPARE(interpolator->progress(), qreal(1));
+ QCOMPARE(interpolator->x(), qreal(0));
+ QCOMPARE(interpolator->y(), qreal(80));
+ QCOMPARE(interpolator->angle(), qreal(180));
+
+ //make sure we don't get caught in infinite loop here
+ interpolator->setProgress(0);
+ QCOMPARE(interpolator->progress(), qreal(0));
+ QCOMPARE(interpolator->x(), qreal(200));
+ QCOMPARE(interpolator->y(), qreal(280));
+ QCOMPARE(interpolator->angle(), qreal(180));
+ }
+}
+
+void tst_qquickanimations::pathWithNoStart()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathAnimationNoStart.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *redRect = rect->findChild<QQuickRectangle*>();
+ QVERIFY(redRect);
+ QQuickPathAnimation *pathAnim = rect->findChild<QQuickPathAnimation*>();
+ QVERIFY(pathAnim);
+
+ pathAnim->start();
+ pathAnim->pause();
+ QCOMPARE(redRect->x(), qreal(50));
+ QCOMPARE(redRect->y(), qreal(50));
+
+ pathAnim->setCurrentTime(50);
+ QCOMPARE(redRect->x(), qreal(175));
+ QCOMPARE(redRect->y(), qreal(175));
+
+ pathAnim->setCurrentTime(100);
+ QCOMPARE(redRect->x(), qreal(300));
+ QCOMPARE(redRect->y(), qreal(300));
+
+ redRect->setX(100);
+ redRect->setY(100);
+ pathAnim->start();
+ QCOMPARE(redRect->x(), qreal(100));
+ QCOMPARE(redRect->y(), qreal(100));
+ QTRY_COMPARE(redRect->x(), qreal(300));
+ QCOMPARE(redRect->y(), qreal(300));
+}
+
+void tst_qquickanimations::alwaysRunToEnd()
+{
+ QQuickRectangle rect;
+ QQuickPropertyAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("x");
+ animation.setTo(200);
+ animation.setDuration(1000);
+ animation.setLoops(-1);
+ animation.setAlwaysRunToEnd(true);
+ QVERIFY(animation.loops() == -1);
+ QVERIFY(animation.alwaysRunToEnd() == true);
+ animation.start();
+ QTest::qWait(1500);
+ animation.stop();
+ QVERIFY(rect.x() != qreal(200));
+ QTest::qWait(500);
+ QTIMED_COMPARE(rect.x(), qreal(200));
+}
+
+void tst_qquickanimations::complete()
+{
+ QQuickRectangle rect;
+ QQuickPropertyAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("x");
+ animation.setFrom(1);
+ animation.setTo(200);
+ animation.setDuration(500);
+ QVERIFY(animation.from() == 1);
+ animation.start();
+ QTest::qWait(50);
+ animation.stop();
+ QVERIFY(rect.x() != qreal(200));
+ animation.start();
+ QTest::qWait(50);
+ QVERIFY(animation.isRunning());
+ animation.complete();
+ QCOMPARE(rect.x(), qreal(200));
+}
+
+void tst_qquickanimations::resume()
+{
+ QQuickRectangle rect;
+ QQuickPropertyAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("x");
+ animation.setFrom(10);
+ animation.setTo(200);
+ animation.setDuration(1000);
+ QVERIFY(animation.from() == 10);
+
+ animation.start();
+ QTest::qWait(400);
+ animation.pause();
+ qreal x = rect.x();
+ QVERIFY(x != qreal(200) && x != qreal(10));
+ QVERIFY(animation.isRunning());
+ QVERIFY(animation.isPaused());
+
+ animation.resume();
+ QVERIFY(animation.isRunning());
+ QVERIFY(!animation.isPaused());
+ QTest::qWait(400);
+ animation.stop();
+ QVERIFY(rect.x() > x);
+}
+
+void tst_qquickanimations::dotProperty()
+{
+ QQuickRectangle rect;
+ QQuickNumberAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("border.width");
+ animation.setTo(10);
+ animation.start();
+ QTest::qWait(animation.duration()+50);
+ QTIMED_COMPARE(rect.border()->width(), 10.0);
+
+ rect.border()->setWidth(0);
+ animation.start();
+ animation.pause();
+ animation.setCurrentTime(125);
+ QVERIFY(animation.currentTime() == 125);
+ QCOMPARE(rect.border()->width(), 5.0);
+}
+
+void tst_qquickanimations::badTypes()
+{
+ //don't crash
+ {
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("badtype1.qml"));
+
+ qApp->processEvents();
+
+ delete view;
+ }
+
+ //make sure we get a compiler error
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("badtype2.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ c.create();
+
+ QVERIFY(c.errors().count() == 1);
+ QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: number expected"));
+ }
+
+ //make sure we get a compiler error
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("badtype3.qml"));
+ QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
+ c.create();
+
+ QVERIFY(c.errors().count() == 1);
+ QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: color expected"));
+ }
+
+ //don't crash
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("badtype4.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("state1");
+ QTest::qWait(1000 + 50);
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("MyRect");
+ QVERIFY(myRect);
+ QCOMPARE(myRect->x(),qreal(200));
+ }
+}
+
+void tst_qquickanimations::badProperties()
+{
+ //make sure we get a runtime error
+ {
+ QQmlEngine engine;
+
+ QQmlComponent c1(&engine, testFileUrl("badproperty1.qml"));
+ QByteArray message = testFileUrl("badproperty1.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\"";
+ QTest::ignoreMessage(QtWarningMsg, message);
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c1.create());
+ QVERIFY(rect);
+
+ QQmlComponent c2(&engine, testFileUrl("badproperty2.qml"));
+ message = testFileUrl("badproperty2.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\"";
+ QTest::ignoreMessage(QtWarningMsg, message);
+ rect = qobject_cast<QQuickRectangle*>(c2.create());
+ QVERIFY(rect);
+
+ //### should we warn here are well?
+ //rect->setState("state1");
+ }
+}
+
+//test animating mixed types with property animation in a transition
+//for example, int + real; color + real; etc
+void tst_qquickanimations::mixedTypes()
+{
+ //assumes border.width stays a real -- not real robust
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("mixedtype1.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("state1");
+ QTest::qWait(500);
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("MyRect");
+ QVERIFY(myRect);
+
+ //rather inexact -- is there a better way?
+ QVERIFY(myRect->x() > 100 && myRect->x() < 200);
+ QVERIFY(myRect->border()->width() > 1 && myRect->border()->width() < 10);
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("mixedtype2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("state1");
+ QTest::qWait(500);
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("MyRect");
+ QVERIFY(myRect);
+
+ //rather inexact -- is there a better way?
+ QVERIFY(myRect->x() > 100 && myRect->x() < 200);
+#if defined(UBUNTU_ONEIRIC) && defined(__x86_64__)
+ QEXPECT_FAIL("", "Fails on this platform - QTBUG-23385", Continue);
+#endif
+ QVERIFY(myRect->color() != QColor("red") && myRect->color() != QColor("blue"));
+ }
+}
+
+void tst_qquickanimations::properties()
+{
+ const int waitDuration = 300;
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("properties.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("properties2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("properties3.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(300));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("properties4.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->y(),qreal(200));
+ QTIMED_COMPARE(myRect->x(),qreal(100));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("properties5.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(100));
+ QTIMED_COMPARE(myRect->y(),qreal(200));
+ }
+}
+
+void tst_qquickanimations::propertiesTransition()
+{
+ const int waitDuration = 300;
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("propertiesTransition.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("propertiesTransition2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QCOMPARE(myRect->x(),qreal(200));
+ QCOMPARE(myRect->y(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->y(),qreal(200));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("propertiesTransition3.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QCOMPARE(myRect->x(),qreal(200));
+ QCOMPARE(myRect->y(),qreal(100));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("propertiesTransition4.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QCOMPARE(myRect->x(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("propertiesTransition5.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QCOMPARE(myRect->x(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+ /*{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("propertiesTransition6.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QCOMPARE(myRect->x(),qreal(100));
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(100));
+ }*/
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("propertiesTransition7.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+ QTest::qWait(waitDuration);
+ QTIMED_COMPARE(myRect->x(),qreal(200));
+ }
+
+}
+
+void tst_qquickanimations::pathTransition()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathTransition.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("redRect");
+ QVERIFY(myRect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QTRY_VERIFY(myRect->x() < 500 && myRect->x() > 100 && myRect->y() > 50 && myRect->y() < 700 ); //animation started
+ QTRY_VERIFY(qFuzzyCompare(myRect->x(), qreal(100)) && qFuzzyCompare(myRect->y(), qreal(700)));
+ QTest::qWait(100);
+
+ QQuickItemPrivate::get(rect)->setState("");
+ QTRY_VERIFY(myRect->x() < 500 && myRect->x() > 100 && myRect->y() > 50 && myRect->y() < 700 ); //animation started
+ QTRY_VERIFY(qFuzzyCompare(myRect->x(), qreal(500)) && qFuzzyCompare(myRect->y(), qreal(50)));
+}
+
+void tst_qquickanimations::disabledTransition()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("disabledTransition.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *myRect = rect->findChild<QQuickRectangle*>("TheRect");
+ QVERIFY(myRect);
+
+ QQuickTransition *trans = rect->findChild<QQuickTransition*>();
+ QVERIFY(trans);
+
+ QCOMPARE(trans->enabled(), false);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QCOMPARE(myRect->x(),qreal(200));
+
+ trans->setEnabled(true);
+
+ QQuickItemPrivate::get(rect)->setState("");
+ QCOMPARE(myRect->x(),qreal(200));
+ QTest::qWait(300);
+ QTIMED_COMPARE(myRect->x(),qreal(100));
+}
+
+void tst_qquickanimations::invalidDuration()
+{
+ QQuickPropertyAnimation *animation = new QQuickPropertyAnimation;
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML PropertyAnimation: Cannot set a duration of < 0");
+ animation->setDuration(-1);
+ QCOMPARE(animation->duration(), 250);
+
+ QQuickPauseAnimation *pauseAnimation = new QQuickPauseAnimation;
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML PauseAnimation: Cannot set a duration of < 0");
+ pauseAnimation->setDuration(-1);
+ QCOMPARE(pauseAnimation->duration(), 250);
+}
+
+void tst_qquickanimations::attached()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("attached.qml"));
+ QTest::ignoreMessage(QtDebugMsg, "off");
+ QTest::ignoreMessage(QtDebugMsg, "on");
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+}
+
+void tst_qquickanimations::propertyValueSourceDefaultStart()
+{
+ {
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("valuesource.qml"));
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim);
+ QVERIFY(myAnim->isRunning());
+ }
+
+ {
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("valuesource2.qml"));
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim);
+ QVERIFY(myAnim->isRunning() == false);
+ }
+
+ {
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("dontAutoStart.qml"));
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && !myAnim->qtAnimation());
+ //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped);
+ }
+}
+
+
+void tst_qquickanimations::dontStart()
+{
+ {
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("dontStart.qml"));
+
+ QString warning = c.url().toString() + ":14:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && !myAnim->qtAnimation());
+ //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped);
+ }
+
+ {
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("dontStart2.qml"));
+
+ QString warning = c.url().toString() + ":15:17: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && !myAnim->qtAnimation());
+ //QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimationJob::Stopped);
+ }
+}
+
+void tst_qquickanimations::easingProperties()
+{
+ {
+ QQmlEngine engine;
+ QString componentStr = "import QtQuick 2.0\nNumberAnimation { easing.type: \"InOutQuad\" }";
+ QQmlComponent animationComponent(&engine);
+ animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickPropertyAnimation *animObject = qobject_cast<QQuickPropertyAnimation*>(animationComponent.create());
+
+ QVERIFY(animObject != 0);
+ QCOMPARE(animObject->easing().type(), QEasingCurve::InOutQuad);
+ }
+
+ {
+ QQmlEngine engine;
+ QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"OutBounce\"; easing.amplitude: 5.0 }";
+ QQmlComponent animationComponent(&engine);
+ animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickPropertyAnimation *animObject = qobject_cast<QQuickPropertyAnimation*>(animationComponent.create());
+
+ QVERIFY(animObject != 0);
+ QCOMPARE(animObject->easing().type(), QEasingCurve::OutBounce);
+ QCOMPARE(animObject->easing().amplitude(), 5.0);
+ }
+
+ {
+ QQmlEngine engine;
+ QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"OutElastic\"; easing.amplitude: 5.0; easing.period: 3.0}";
+ QQmlComponent animationComponent(&engine);
+ animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickPropertyAnimation *animObject = qobject_cast<QQuickPropertyAnimation*>(animationComponent.create());
+
+ QVERIFY(animObject != 0);
+ QCOMPARE(animObject->easing().type(), QEasingCurve::OutElastic);
+ QCOMPARE(animObject->easing().amplitude(), 5.0);
+ QCOMPARE(animObject->easing().period(), 3.0);
+ }
+
+ {
+ QQmlEngine engine;
+ QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"InOutBack\"; easing.overshoot: 2 }";
+ QQmlComponent animationComponent(&engine);
+ animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickPropertyAnimation *animObject = qobject_cast<QQuickPropertyAnimation*>(animationComponent.create());
+
+ QVERIFY(animObject != 0);
+ QCOMPARE(animObject->easing().type(), QEasingCurve::InOutBack);
+ QCOMPARE(animObject->easing().overshoot(), 2.0);
+ }
+
+ {
+ QQmlEngine engine;
+ QString componentStr = "import QtQuick 2.0\nPropertyAnimation { easing.type: \"Bezier\"; easing.bezierCurve: [0.5, 0.2, 0.13, 0.65, 1.0, 1.0] }";
+ QQmlComponent animationComponent(&engine);
+ animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickPropertyAnimation *animObject = qobject_cast<QQuickPropertyAnimation*>(animationComponent.create());
+
+ QVERIFY(animObject != 0);
+ QCOMPARE(animObject->easing().type(), QEasingCurve::BezierSpline);
+ QList<QPointF> points = animObject->easing().cubicBezierSpline();
+ QCOMPARE(points.count(), 3);
+ QCOMPARE(points.at(0), QPointF(0.5, 0.2));
+ QCOMPARE(points.at(1), QPointF(0.13, 0.65));
+ QCOMPARE(points.at(2), QPointF(1.0, 1.0));
+ }
+}
+
+void tst_qquickanimations::rotation()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("rotation.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *rr = rect->findChild<QQuickRectangle*>("rr");
+ QQuickRectangle *rr2 = rect->findChild<QQuickRectangle*>("rr2");
+ QQuickRectangle *rr3 = rect->findChild<QQuickRectangle*>("rr3");
+ QQuickRectangle *rr4 = rect->findChild<QQuickRectangle*>("rr4");
+
+ QQuickItemPrivate::get(rect)->setState("state1");
+ QTest::qWait(800);
+ qreal r1 = rr->rotation();
+ qreal r2 = rr2->rotation();
+ qreal r3 = rr3->rotation();
+ qreal r4 = rr4->rotation();
+
+ QVERIFY(r1 > qreal(0) && r1 < qreal(370));
+ QVERIFY(r2 > qreal(0) && r2 < qreal(370));
+ QVERIFY(r3 < qreal(0) && r3 > qreal(-350));
+ QVERIFY(r4 > qreal(0) && r4 < qreal(10));
+ QCOMPARE(r1,r2);
+ QVERIFY(r4 < r2);
+
+ QTest::qWait(800);
+ QTIMED_COMPARE(rr->rotation() + rr2->rotation() + rr3->rotation() + rr4->rotation(), qreal(370*4));
+}
+
+void tst_qquickanimations::runningTrueBug()
+{
+ //ensure we start correctly when "running: true" is explicitly set
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("runningTrueBug.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *cloud = rect->findChild<QQuickRectangle*>("cloud");
+ QVERIFY(cloud);
+ QTest::qWait(1000);
+ QVERIFY(cloud->x() > qreal(0));
+}
+
+//QTBUG-12805
+void tst_qquickanimations::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)
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("nonTransitionBug.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QQuickRectangle *mover = rect->findChild<QQuickRectangle*>("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));
+}
+
+//QTBUG-14042
+void tst_qquickanimations::registrationBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("registrationBug.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QTRY_COMPARE(rect->property("value"), QVariant(int(100)));
+}
+
+void tst_qquickanimations::doubleRegistrationBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("doubleRegistrationBug.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickAbstractAnimation *anim = rect->findChild<QQuickAbstractAnimation*>("animation");
+ QVERIFY(anim != 0);
+ QTRY_COMPARE(anim->qtAnimation()->state(), QAbstractAnimationJob::Stopped);
+}
+
+//QTBUG-16736
+void tst_qquickanimations::alwaysRunToEndRestartBug()
+{
+ QQuickRectangle rect;
+ QQuickPropertyAnimation animation;
+ animation.setTargetObject(&rect);
+ animation.setProperty("x");
+ animation.setTo(200);
+ animation.setDuration(1000);
+ animation.setLoops(-1);
+ animation.setAlwaysRunToEnd(true);
+ QVERIFY(animation.loops() == -1);
+ QVERIFY(animation.alwaysRunToEnd() == true);
+ animation.start();
+ animation.stop();
+ animation.start();
+ animation.stop();
+ QTest::qWait(500);
+ QVERIFY(rect.x() != qreal(200));
+ QTest::qWait(800);
+ QTIMED_COMPARE(rect.x(), qreal(200));
+ QCOMPARE(static_cast<QQuickAbstractAnimation*>(&animation)->qtAnimation()->state(), QAbstractAnimationJob::Stopped);
+}
+
+//QTBUG-20227
+void tst_qquickanimations::transitionAssignmentBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("transitionAssignmentBug.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->property("nullObject").toBool(), false);
+}
+
+//QTBUG-19080
+void tst_qquickanimations::pauseBindingBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("pauseBindingBug.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QQuickAbstractAnimation *anim = rect->findChild<QQuickAbstractAnimation*>("animation");
+ QVERIFY(anim->qtAnimation()->state() == QAbstractAnimationJob::Paused);
+
+ delete rect;
+}
+
+//QTBUG-13598
+void tst_qquickanimations::pauseBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("pauseBug.qml"));
+ QQuickAbstractAnimation *anim = qobject_cast<QQuickAbstractAnimation*>(c.create());
+ QVERIFY(anim != 0);
+ QCOMPARE(anim->qtAnimation()->state(), QAbstractAnimationJob::Paused);
+ QCOMPARE(anim->isPaused(), true);
+ QCOMPARE(anim->isRunning(), true);
+
+ delete anim;
+}
+
+//QTBUG-23092
+void tst_qquickanimations::loopingBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("looping.qml"));
+ QObject *obj = c.create();
+
+ QQuickAbstractAnimation *anim = obj->findChild<QQuickAbstractAnimation*>();
+ QVERIFY(anim != 0);
+ QCOMPARE(anim->qtAnimation()->totalDuration(), 300);
+ QCOMPARE(anim->isRunning(), true);
+ QTRY_COMPARE(static_cast<QAnimationGroupJob*>(anim->qtAnimation())->firstChild()->currentLoop(), 2);
+ QTRY_COMPARE(anim->isRunning(), false);
+
+ QQuickRectangle *rect = obj->findChild<QQuickRectangle*>();
+ QVERIFY(rect != 0);
+ QCOMPARE(rect->rotation(), qreal(90));
+
+ delete obj;
+}
+
+QTEST_MAIN(tst_qquickanimations)
+
+#include "tst_qquickanimations.moc"
diff --git a/tests/auto/quick/qquickapplication/qquickapplication.pro b/tests/auto/quick/qquickapplication/qquickapplication.pro
new file mode 100644
index 0000000000..96cfe82a82
--- /dev/null
+++ b/tests/auto/quick/qquickapplication/qquickapplication.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase
+TARGET = tst_qquickapplication
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickapplication.cpp
+QT += core-private gui-private qml-private quick-private testlib
+
diff --git a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp
new file mode 100644
index 0000000000..61675d980d
--- /dev/null
+++ b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+#include <QtGui/qinputmethod.h>
+
+class tst_qquickapplication : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qquickapplication();
+
+private slots:
+ void active();
+ void layoutDirection();
+ void inputPanel();
+ void inputMethod();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquickapplication::tst_qquickapplication()
+{
+}
+
+void tst_qquickapplication::active()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Item { property bool active: Qt.application.active }", QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
+ QVERIFY(item);
+ QQuickView view;
+ item->setParentItem(view.rootObject());
+
+ // not active
+ QVERIFY(!item->property("active").toBool());
+ QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0);
+
+ // active
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWait(50);
+ QEXPECT_FAIL("", "QTBUG-21573", Abort);
+ QTRY_COMPARE(view.status(), QQuickView::Ready);
+ QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0);
+
+#if 0
+ // QGuiApplication has no equivalent of setActiveWindow(0). QTBUG-21573
+ // Is this different to clearing the active state of the window or can it be removed?
+ // On Mac, setActiveWindow(0) on mac does not deactivate the current application,
+ // must switch to a different app or hide the current app to trigger this
+ // on mac, setActiveWindow(0) on mac does not deactivate the current application
+ // (you have to switch to a different app or hide the current app to trigger this)
+
+ // not active again
+ QGuiApplication::setActiveWindow(0);
+ QVERIFY(!item->property("active").toBool());
+ QCOMPARE(item->property("active").toBool(), QGuiApplication::activeWindow() != 0);
+#endif
+
+}
+
+void tst_qquickapplication::layoutDirection()
+{
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Item { property bool layoutDirection: Qt.application.layoutDirection }", QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
+ QVERIFY(item);
+ QQuickView view;
+ item->setParentItem(view.rootObject());
+
+ // not mirrored
+ QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight);
+
+ // mirrored
+ QGuiApplication::setLayoutDirection(Qt::RightToLeft);
+ QEXPECT_FAIL("", "QTBUG-21573", Abort);
+ QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::RightToLeft);
+
+ // not mirrored again
+ QGuiApplication::setLayoutDirection(Qt::LeftToRight);
+ QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight);
+}
+
+void tst_qquickapplication::inputPanel()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Item { property variant inputPanel: Qt.application.inputPanel }", QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
+ QVERIFY(item);
+ QQuickView view;
+ item->setParentItem(view.rootObject());
+
+ // check that the inputPanel property maches with application's input panel
+ QCOMPARE(qvariant_cast<QObject*>(item->property("inputPanel")), qApp->inputMethod());
+}
+
+void tst_qquickapplication::inputMethod()
+{
+ // technically not in QQuickApplication, but testing anyway here
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Item { property variant inputMethod: Qt.inputMethod }", QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem *>(component.create());
+ QVERIFY(item);
+ QQuickView view;
+ item->setParentItem(view.rootObject());
+
+ // check that the inputMethod property maches with application's input method
+ QCOMPARE(qvariant_cast<QObject*>(item->property("inputMethod")), qApp->inputMethod());
+}
+
+
+QTEST_MAIN(tst_qquickapplication)
+
+#include "tst_qquickapplication.moc"
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/binding.qml b/tests/auto/quick/qquickbehaviors/data/binding.qml
index 5aceefa743..5aceefa743 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/binding.qml
+++ b/tests/auto/quick/qquickbehaviors/data/binding.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/color.qml b/tests/auto/quick/qquickbehaviors/data/color.qml
index a318578a9b..a318578a9b 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/color.qml
+++ b/tests/auto/quick/qquickbehaviors/data/color.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/cpptrigger.qml b/tests/auto/quick/qquickbehaviors/data/cpptrigger.qml
index f033ec5aeb..f033ec5aeb 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/cpptrigger.qml
+++ b/tests/auto/quick/qquickbehaviors/data/cpptrigger.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/delayedRegistration.qml b/tests/auto/quick/qquickbehaviors/data/delayedRegistration.qml
index ed35a308f7..ed35a308f7 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/delayedRegistration.qml
+++ b/tests/auto/quick/qquickbehaviors/data/delayedRegistration.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/disabled.qml b/tests/auto/quick/qquickbehaviors/data/disabled.qml
index 20860d8dde..20860d8dde 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/disabled.qml
+++ b/tests/auto/quick/qquickbehaviors/data/disabled.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/dontStart.qml b/tests/auto/quick/qquickbehaviors/data/dontStart.qml
index 38e1ea9d9e..38e1ea9d9e 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/dontStart.qml
+++ b/tests/auto/quick/qquickbehaviors/data/dontStart.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/empty.qml b/tests/auto/quick/qquickbehaviors/data/empty.qml
index d8f115390a..d8f115390a 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/empty.qml
+++ b/tests/auto/quick/qquickbehaviors/data/empty.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/explicit.qml b/tests/auto/quick/qquickbehaviors/data/explicit.qml
index 20875c30e3..20875c30e3 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/explicit.qml
+++ b/tests/auto/quick/qquickbehaviors/data/explicit.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty.qml b/tests/auto/quick/qquickbehaviors/data/groupProperty.qml
index a05ab7d54b..a05ab7d54b 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty.qml
+++ b/tests/auto/quick/qquickbehaviors/data/groupProperty.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty2.qml b/tests/auto/quick/qquickbehaviors/data/groupProperty2.qml
index 2f3de5131c..2f3de5131c 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupProperty2.qml
+++ b/tests/auto/quick/qquickbehaviors/data/groupProperty2.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupedPropertyCrash.qml b/tests/auto/quick/qquickbehaviors/data/groupedPropertyCrash.qml
index 6835902bc5..6835902bc5 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/groupedPropertyCrash.qml
+++ b/tests/auto/quick/qquickbehaviors/data/groupedPropertyCrash.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/loop.qml b/tests/auto/quick/qquickbehaviors/data/loop.qml
index 3e8d88734d..3e8d88734d 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/loop.qml
+++ b/tests/auto/quick/qquickbehaviors/data/loop.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/nonSelecting2.qml b/tests/auto/quick/qquickbehaviors/data/nonSelecting2.qml
index 6357094cfe..6357094cfe 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/nonSelecting2.qml
+++ b/tests/auto/quick/qquickbehaviors/data/nonSelecting2.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/parent.qml b/tests/auto/quick/qquickbehaviors/data/parent.qml
index f8c2731d86..f8c2731d86 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/parent.qml
+++ b/tests/auto/quick/qquickbehaviors/data/parent.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/qtbug12295.qml b/tests/auto/quick/qquickbehaviors/data/qtbug12295.qml
index c6bef581a4..c6bef581a4 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/qtbug12295.qml
+++ b/tests/auto/quick/qquickbehaviors/data/qtbug12295.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/reassignedAnimation.qml b/tests/auto/quick/qquickbehaviors/data/reassignedAnimation.qml
index 5731cb3efd..5731cb3efd 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/reassignedAnimation.qml
+++ b/tests/auto/quick/qquickbehaviors/data/reassignedAnimation.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/runningTrue.qml b/tests/auto/quick/qquickbehaviors/data/runningTrue.qml
index 4fd1136f3a..4fd1136f3a 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/runningTrue.qml
+++ b/tests/auto/quick/qquickbehaviors/data/runningTrue.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/scripttrigger.qml b/tests/auto/quick/qquickbehaviors/data/scripttrigger.qml
index ff71f2b1b0..ff71f2b1b0 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/scripttrigger.qml
+++ b/tests/auto/quick/qquickbehaviors/data/scripttrigger.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/simple.qml b/tests/auto/quick/qquickbehaviors/data/simple.qml
index c64a6e1928..c64a6e1928 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/simple.qml
+++ b/tests/auto/quick/qquickbehaviors/data/simple.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/startOnCompleted.qml b/tests/auto/quick/qquickbehaviors/data/startOnCompleted.qml
index fdc3779a5c..fdc3779a5c 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/startOnCompleted.qml
+++ b/tests/auto/quick/qquickbehaviors/data/startOnCompleted.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/startup.qml b/tests/auto/quick/qquickbehaviors/data/startup.qml
index 9fa74ca39e..9fa74ca39e 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/startup.qml
+++ b/tests/auto/quick/qquickbehaviors/data/startup.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/startup2.qml b/tests/auto/quick/qquickbehaviors/data/startup2.qml
index 0654ef3644..0654ef3644 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/startup2.qml
+++ b/tests/auto/quick/qquickbehaviors/data/startup2.qml
diff --git a/tests/auto/qtquick2/qdeclarativebehaviors/data/valueType.qml b/tests/auto/quick/qquickbehaviors/data/valueType.qml
index 7bc8297dc7..7bc8297dc7 100644
--- a/tests/auto/qtquick2/qdeclarativebehaviors/data/valueType.qml
+++ b/tests/auto/quick/qquickbehaviors/data/valueType.qml
diff --git a/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro b/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro
new file mode 100644
index 0000000000..fc103ed4c2
--- /dev/null
+++ b/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickbehaviors
+SOURCES += tst_qquickbehaviors.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
new file mode 100644
index 0000000000..bd17bf4143
--- /dev/null
+++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp
@@ -0,0 +1,473 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <qsignalspy.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuick/private/qquickbehavior_p.h>
+#include <QtQuick/private/qquickanimation_p.h>
+#include <private/qquickitem_p.h>
+#include "../../shared/util.h"
+
+class tst_qquickbehaviors : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickbehaviors() {}
+
+private slots:
+ void init() { qApp->processEvents(); } //work around animation timer bug (QTBUG-22865)
+ void simpleBehavior();
+ void scriptTriggered();
+ void cppTriggered();
+ void loop();
+ void colorBehavior();
+ void parentBehavior();
+ void replaceBinding();
+ //void transitionOverrides();
+ void group();
+ void valueType();
+ void emptyBehavior();
+ void explicitSelection();
+ void nonSelectingBehavior();
+ void reassignedAnimation();
+ void disabled();
+ void dontStart();
+ void startup();
+ void groupedPropertyCrash();
+ void runningTrue();
+ void sameValue();
+ void delayedRegistration();
+ void startOnCompleted();
+};
+
+void tst_qquickbehaviors::simpleBehavior()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("simple.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QTRY_VERIFY(rect);
+ QTRY_VERIFY(qobject_cast<QQuickBehavior*>(rect->findChild<QQuickBehavior*>("MyBehavior"))->animation());
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
+ //i.e. the behavior has been triggered
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::scriptTriggered()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("scripttrigger.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QTRY_VERIFY(rect);
+
+ rect->setColor(QColor("red"));
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
+ //i.e. the behavior has been triggered
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::cppTriggered()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("cpptrigger.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QTRY_VERIFY(rect);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QTRY_VERIFY(innerRect);
+
+ innerRect->setProperty("x", 200);
+ QTRY_VERIFY(innerRect->x() > 0);
+ QTRY_VERIFY(innerRect->x() < 200); //i.e. the behavior has been triggered
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::loop()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("loop.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QTRY_VERIFY(rect);
+
+ //don't crash
+ QQuickItemPrivate::get(rect)->setState("moved");
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::colorBehavior()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("color.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QTRY_VERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("red");
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->color() != QColor("red"));
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->color() != QColor("green"));
+ //i.e. the behavior has been triggered
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::parentBehavior()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("parent.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QTRY_VERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("reparented");
+ QTRY_VERIFY(rect->findChild<QQuickRectangle*>("MyRect")->parentItem() != rect->findChild<QQuickItem*>("NewParent"));
+ QTRY_VERIFY(rect->findChild<QQuickRectangle*>("MyRect")->parentItem() == rect->findChild<QQuickItem*>("NewParent"));
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::replaceBinding()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("binding.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QTRY_VERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QTRY_VERIFY(innerRect);
+ QTRY_VERIFY(innerRect->x() > 0);
+ QTRY_VERIFY(innerRect->x() < 200);
+ //i.e. the behavior has been triggered
+ QTRY_COMPARE(innerRect->x(), (qreal)200);
+ rect->setProperty("basex", 10);
+ QTRY_COMPARE(innerRect->x(), (qreal)200);
+ rect->setProperty("movedx", 210);
+ QTRY_COMPARE(innerRect->x(), (qreal)210);
+
+ QQuickItemPrivate::get(rect)->setState("");
+ QTRY_VERIFY(innerRect->x() > 10);
+ QTRY_VERIFY(innerRect->x() < 210); //i.e. the behavior has been triggered
+ QTRY_COMPARE(innerRect->x(), (qreal)10);
+ rect->setProperty("movedx", 200);
+ QTRY_COMPARE(innerRect->x(), (qreal)10);
+ rect->setProperty("basex", 20);
+ QTRY_COMPARE(innerRect->x(), (qreal)20);
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::group()
+{
+ /* XXX TODO Create a test element for this case.
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("groupProperty.qml")));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ qDebug() << c.errorString();
+ QTRY_VERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ //QTest::qWait(200);
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
+ //i.e. the behavior has been triggered
+
+ delete rect;
+ }
+ */
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("groupProperty2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QTRY_VERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->border()->width() > 0);
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->border()->width() < 4);
+ //i.e. the behavior has been triggered
+
+ delete rect;
+ }
+}
+
+void tst_qquickbehaviors::valueType()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("valueType.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ //QTBUG-20827
+ QCOMPARE(rect->color(), QColor::fromRgb(255,0,255));
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::emptyBehavior()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("empty.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ qreal x = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x();
+ QCOMPARE(x, qreal(200)); //should change immediately
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::explicitSelection()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("explicit.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() > 0);
+ QTRY_VERIFY(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x() < 200);
+ //i.e. the behavior has been triggered
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::nonSelectingBehavior()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("nonSelecting2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ qreal x = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x();
+ QCOMPARE(x, qreal(200)); //should change immediately
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::reassignedAnimation()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("reassignedAnimation.qml"));
+ QString warning = testFileUrl("reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior.";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+ QCOMPARE(qobject_cast<QQuickNumberAnimation*>(
+ rect->findChild<QQuickBehavior*>("MyBehavior")->animation())->duration(), 200);
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::disabled()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("disabled.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+ QCOMPARE(rect->findChild<QQuickBehavior*>("MyBehavior")->enabled(), false);
+
+ QQuickItemPrivate::get(rect)->setState("moved");
+ qreal x = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"))->x();
+ QCOMPARE(x, qreal(200)); //should change immediately
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::dontStart()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("dontStart.qml"));
+
+ QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickAbstractAnimation *myAnim = rect->findChild<QQuickAbstractAnimation*>("MyAnim");
+ QVERIFY(myAnim && !myAnim->qtAnimation());
+
+ delete rect;
+}
+
+void tst_qquickbehaviors::startup()
+{
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("startup.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *innerRect = rect->findChild<QQuickRectangle*>("innerRect");
+ QVERIFY(innerRect);
+
+ QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately
+
+ delete rect;
+ }
+
+ {
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("startup2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *innerRect = rect->findChild<QQuickRectangle*>("innerRect");
+ QVERIFY(innerRect);
+
+ QQuickText *text = rect->findChild<QQuickText*>();
+ QVERIFY(text);
+
+ QCOMPARE(innerRect->x(), text->width()); //should be set immediately
+
+ delete rect;
+ }
+}
+
+//QTBUG-10799
+void tst_qquickbehaviors::groupedPropertyCrash()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("groupedPropertyCrash.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect); //don't crash
+
+ delete rect;
+}
+
+//QTBUG-5491
+void tst_qquickbehaviors::runningTrue()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("runningTrue.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickAbstractAnimation *animation = rect->findChild<QQuickAbstractAnimation*>("rotAnim");
+ QVERIFY(animation);
+
+ QSignalSpy runningSpy(animation, SIGNAL(runningChanged(bool)));
+ rect->setProperty("myValue", 180);
+ QTRY_VERIFY(runningSpy.count() > 0);
+
+ delete rect;
+}
+
+//QTBUG-12295
+void tst_qquickbehaviors::sameValue()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("qtbug12295.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *target = rect->findChild<QQuickRectangle*>("myRect");
+ QVERIFY(target);
+
+ target->setX(100);
+ QCOMPARE(target->x(), qreal(100));
+
+ target->setProperty("x", 0);
+ QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100));
+ QTRY_VERIFY(target->x() == qreal(0)); //make sure Behavior has finished.
+
+ target->setX(100);
+ QCOMPARE(target->x(), qreal(100));
+
+ //this is the main point of the test -- the behavior needs to be triggered again
+ //even though we set 0 twice in a row.
+ target->setProperty("x", 0);
+ QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100));
+
+ delete rect;
+}
+
+//QTBUG-18362
+void tst_qquickbehaviors::delayedRegistration()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("delayedRegistration.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickItem *innerRect = rect->property("myItem").value<QQuickItem*>();
+ QVERIFY(innerRect != 0);
+
+ QCOMPARE(innerRect->property("x").toInt(), int(0));
+
+ QTRY_COMPARE(innerRect->property("x").toInt(), int(100));
+}
+
+//QTBUG-22555
+void tst_qquickbehaviors::startOnCompleted()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("startOnCompleted.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickItem *innerRect = rect->findChild<QQuickRectangle*>();
+ QVERIFY(innerRect != 0);
+
+ QCOMPARE(innerRect->property("x").toInt(), int(0));
+
+ QTRY_COMPARE(innerRect->property("x").toInt(), int(100));
+
+ delete rect;
+}
+
+QTEST_MAIN(tst_qquickbehaviors)
+
+#include "tst_qquickbehaviors.moc"
diff --git a/tests/auto/qtquick2/qquickborderimage/data/colors-mirror.png b/tests/auto/quick/qquickborderimage/data/colors-mirror.png
index e30870dd1e..e30870dd1e 100644
--- a/tests/auto/qtquick2/qquickborderimage/data/colors-mirror.png
+++ b/tests/auto/quick/qquickborderimage/data/colors-mirror.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickborderimage/data/colors-round-quotes.sci b/tests/auto/quick/qquickborderimage/data/colors-round-quotes.sci
index 294f3cfe48..294f3cfe48 100644
--- a/tests/auto/qtquick2/qquickborderimage/data/colors-round-quotes.sci
+++ b/tests/auto/quick/qquickborderimage/data/colors-round-quotes.sci
diff --git a/tests/auto/qtquick2/qquickborderimage/data/colors-round-remote.sci b/tests/auto/quick/qquickborderimage/data/colors-round-remote.sci
index c673bed598..c673bed598 100644
--- a/tests/auto/qtquick2/qquickborderimage/data/colors-round-remote.sci
+++ b/tests/auto/quick/qquickborderimage/data/colors-round-remote.sci
diff --git a/tests/auto/qtquick2/qquickborderimage/data/colors-round.sci b/tests/auto/quick/qquickborderimage/data/colors-round.sci
index 5d2f49f0e1..5d2f49f0e1 100644
--- a/tests/auto/qtquick2/qquickborderimage/data/colors-round.sci
+++ b/tests/auto/quick/qquickborderimage/data/colors-round.sci
diff --git a/tests/auto/qtquick2/qquickborderimage/data/colors.png b/tests/auto/quick/qquickborderimage/data/colors.png
index dfb62f3d64..dfb62f3d64 100644
--- a/tests/auto/qtquick2/qquickborderimage/data/colors.png
+++ b/tests/auto/quick/qquickborderimage/data/colors.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickborderimage/data/heart200.png b/tests/auto/quick/qquickborderimage/data/heart200.png
index 5a31ae8f4d..5a31ae8f4d 100644
--- a/tests/auto/qtquick2/qquickborderimage/data/heart200.png
+++ b/tests/auto/quick/qquickborderimage/data/heart200.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickborderimage/data/invalid.sci b/tests/auto/quick/qquickborderimage/data/invalid.sci
index 98c72c9bf1..98c72c9bf1 100644
--- a/tests/auto/qtquick2/qquickborderimage/data/invalid.sci
+++ b/tests/auto/quick/qquickborderimage/data/invalid.sci
diff --git a/tests/auto/qtquick2/qquickborderimage/data/mirror.qml b/tests/auto/quick/qquickborderimage/data/mirror.qml
index abab076e08..abab076e08 100644
--- a/tests/auto/qtquick2/qquickborderimage/data/mirror.qml
+++ b/tests/auto/quick/qquickborderimage/data/mirror.qml
diff --git a/tests/auto/quick/qquickborderimage/qquickborderimage.pro b/tests/auto/quick/qquickborderimage/qquickborderimage.pro
new file mode 100644
index 0000000000..f50149aead
--- /dev/null
+++ b/tests/auto/quick/qquickborderimage/qquickborderimage.pro
@@ -0,0 +1,17 @@
+CONFIG += testcase
+TARGET = tst_qquickborderimage
+macx:CONFIG -= app_bundle
+
+HEADERS += ../../shared/testhttpserver.h
+SOURCES += tst_qquickborderimage.cpp \
+ ../../shared/testhttpserver.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network widgets testlib
diff --git a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
new file mode 100644
index 0000000000..13b12f6020
--- /dev/null
+++ b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp
@@ -0,0 +1,373 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QTextDocument>
+#include <QTcpServer>
+#include <QTcpSocket>
+#include <QDir>
+#include <QGraphicsScene>
+#include <QPainter>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <private/qquickborderimage_p.h>
+#include <private/qquickimagebase_p.h>
+#include <private/qquickscalegrid_p_p.h>
+#include <private/qquickloader_p.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlcontext.h>
+
+#include "../../shared/testhttpserver.h"
+#include "../../shared/util.h"
+
+#define SERVER_PORT 14446
+#define SERVER_ADDR "http://127.0.0.1:14446"
+
+class tst_qquickborderimage : public QQmlDataTest
+
+{
+ Q_OBJECT
+public:
+ tst_qquickborderimage();
+
+private slots:
+ void noSource();
+ void imageSource();
+ void imageSource_data();
+ void clearSource();
+ void resized();
+ void smooth();
+ void mirror();
+ void tileModes();
+ void sciSource();
+ void sciSource_data();
+ void invalidSciFile();
+ void pendingRemoteRequest();
+ void pendingRemoteRequest_data();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquickborderimage::tst_qquickborderimage()
+{
+}
+
+void tst_qquickborderimage::noSource()
+{
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"\" }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->source(), QUrl());
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+ QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qquickborderimage::imageSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<bool>("remote");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("local") << testFileUrl("colors.png").toString() << false << "";
+ QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << false
+ << "file::2:1: QML BorderImage: Cannot open: " + testFileUrl("no-such-file.png").toString();
+ QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << "";
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true
+ << "file::2:1: QML BorderImage: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found";
+}
+
+void tst_qquickborderimage::imageSource()
+{
+ QFETCH(QString, source);
+ QFETCH(bool, remote);
+ QFETCH(QString, error);
+
+ TestHTTPServer *server = 0;
+ if (remote) {
+ server = new TestHTTPServer(SERVER_PORT);
+ QVERIFY(server->isValid());
+ server->serveDirectory(dataDirectory());
+ }
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\" }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ if (remote)
+ QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading);
+
+ QCOMPARE(obj->source(), remote ? source : QUrl(source));
+
+ if (error.isEmpty()) {
+ QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+ QCOMPARE(obj->sourceSize().width(), 120);
+ QCOMPARE(obj->sourceSize().height(), 120);
+ QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
+ } else {
+ QTRY_VERIFY(obj->status() == QQuickBorderImage::Error);
+ }
+
+ delete obj;
+ delete server;
+}
+
+void tst_qquickborderimage::clearSource()
+{
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: srcImage }";
+ QQmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->status() == QQuickBorderImage::Ready);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+
+ ctxt->setContextProperty("srcImage", "");
+ QVERIFY(obj->source().isEmpty());
+ QVERIFY(obj->status() == QQuickBorderImage::Null);
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+}
+
+void tst_qquickborderimage::resized()
+{
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFileUrl("colors.png").toString() + "\"; width: 300; height: 300 }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->sourceSize().width(), 120);
+ QCOMPARE(obj->sourceSize().height(), 120);
+ QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qquickborderimage::smooth()
+{
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; smooth: true; width: 300; height: 300 }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->smooth(), true);
+ QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qquickborderimage::mirror()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("mirror.qml"));
+ QQuickBorderImage *image = qobject_cast<QQuickBorderImage*>(canvas->rootObject());
+ QVERIFY(image != 0);
+
+ QImage screenshot = canvas->grabFrameBuffer();
+
+ QImage srcPixmap(screenshot);
+ QTransform transform;
+ transform.translate(image->width(), 0).scale(-1, 1.0);
+ srcPixmap = srcPixmap.transformed(transform);
+
+ image->setProperty("mirror", true);
+ screenshot = canvas->grabFrameBuffer();
+ QCOMPARE(screenshot, srcPixmap);
+
+ delete canvas;
+}
+
+void tst_qquickborderimage::tileModes()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 100.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Repeat);
+ QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Repeat);
+
+ delete obj;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 150.);
+ QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Round);
+ QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Round);
+
+ delete obj;
+ }
+}
+
+void tst_qquickborderimage::sciSource()
+{
+ QFETCH(QString, source);
+ QFETCH(bool, valid);
+
+ bool remote = source.startsWith("http");
+ TestHTTPServer *server = 0;
+ if (remote) {
+ server = new TestHTTPServer(SERVER_PORT);
+ QVERIFY(server->isValid());
+ server->serveDirectory(dataDirectory());
+ }
+
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ if (remote)
+ QTRY_VERIFY(obj->status() == QQuickBorderImage::Loading);
+
+ QCOMPARE(obj->source(), remote ? source : QUrl(source));
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+
+ if (valid) {
+ QTRY_VERIFY(obj->status() == QQuickBorderImage::Ready);
+ QCOMPARE(obj->border()->left(), 10);
+ QCOMPARE(obj->border()->top(), 20);
+ QCOMPARE(obj->border()->right(), 30);
+ QCOMPARE(obj->border()->bottom(), 40);
+ QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Round);
+ QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Repeat);
+ } else {
+ QTRY_VERIFY(obj->status() == QQuickBorderImage::Error);
+ }
+
+ delete obj;
+ delete server;
+}
+
+void tst_qquickborderimage::sciSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<bool>("valid");
+
+ QTest::newRow("local") << testFileUrl("colors-round.sci").toString() << true;
+ QTest::newRow("local quoted filename") << testFileUrl("colors-round-quotes.sci").toString() << true;
+ QTest::newRow("local not found") << testFileUrl("no-such-file.sci").toString() << false;
+ QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
+ QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true;
+ QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true;
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false;
+}
+
+void tst_qquickborderimage::invalidSciFile()
+{
+ QTest::ignoreMessage(QtWarningMsg, "QQuickGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Roun"
+ QTest::ignoreMessage(QtWarningMsg, "QQuickGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Repea"
+
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFileUrl("invalid.sci").toString() +"\"; width: 300; height: 300 }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->status(), QQuickImageBase::Error);
+ QCOMPARE(obj->horizontalTileMode(), QQuickBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QQuickBorderImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qquickborderimage::pendingRemoteRequest()
+{
+ QFETCH(QString, source);
+
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\" }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->status(), QQuickBorderImage::Loading);
+
+ // verify no crash
+ // This will cause a delayed "QThread: Destroyed while thread is still running" warning
+ delete obj;
+ QTest::qWait(50);
+}
+
+void tst_qquickborderimage::pendingRemoteRequest_data()
+{
+ QTest::addColumn<QString>("source");
+
+ QTest::newRow("png file") << "http://localhost/none.png";
+ QTest::newRow("sci file") << "http://localhost/none.sci";
+}
+
+QTEST_MAIN(tst_qquickborderimage)
+
+#include "tst_qquickborderimage.moc"
diff --git a/tests/auto/qtquick2/qquickcanvas/data/AnimationsWhileHidden.qml b/tests/auto/quick/qquickcanvas/data/AnimationsWhileHidden.qml
index e95b029210..e95b029210 100644
--- a/tests/auto/qtquick2/qquickcanvas/data/AnimationsWhileHidden.qml
+++ b/tests/auto/quick/qquickcanvas/data/AnimationsWhileHidden.qml
diff --git a/tests/auto/qtquick2/qquickcanvas/data/Headless.qml b/tests/auto/quick/qquickcanvas/data/Headless.qml
index 2e09cb1f24..2e09cb1f24 100644
--- a/tests/auto/qtquick2/qquickcanvas/data/Headless.qml
+++ b/tests/auto/quick/qquickcanvas/data/Headless.qml
diff --git a/tests/auto/qtquick2/qquickcanvas/data/colors.png b/tests/auto/quick/qquickcanvas/data/colors.png
index dfb62f3d64..dfb62f3d64 100644
--- a/tests/auto/qtquick2/qquickcanvas/data/colors.png
+++ b/tests/auto/quick/qquickcanvas/data/colors.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvas/data/focus.qml b/tests/auto/quick/qquickcanvas/data/focus.qml
index 901f2fcf2e..901f2fcf2e 100644
--- a/tests/auto/qtquick2/qquickcanvas/data/focus.qml
+++ b/tests/auto/quick/qquickcanvas/data/focus.qml
diff --git a/tests/auto/qtquick2/qquickcanvas/data/window.qml b/tests/auto/quick/qquickcanvas/data/window.qml
index d79d5161b5..d79d5161b5 100644
--- a/tests/auto/qtquick2/qquickcanvas/data/window.qml
+++ b/tests/auto/quick/qquickcanvas/data/window.qml
diff --git a/tests/auto/quick/qquickcanvas/qquickcanvas.pro b/tests/auto/quick/qquickcanvas/qquickcanvas.pro
new file mode 100644
index 0000000000..7f27a05243
--- /dev/null
+++ b/tests/auto/quick/qquickcanvas/qquickcanvas.pro
@@ -0,0 +1,20 @@
+CONFIG += testcase
+TARGET = tst_qquickcanvas
+SOURCES += tst_qquickcanvas.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private quick-private testlib
+
+testData.files = data
+testData.path = .
+DEPLOYMENT += testData
+
+OTHER_FILES += \
+ data/AnimationsWhileHidden.qml \
+ data/Headless.qml
+
+
diff --git a/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp b/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp
new file mode 100644
index 0000000000..3a27d179c5
--- /dev/null
+++ b/tests/auto/quick/qquickcanvas/tst_qquickcanvas.cpp
@@ -0,0 +1,775 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDebug>
+#include <QTouchEvent>
+#include <QtQuick/QQuickItem>
+#include <QtQuick/QQuickCanvas>
+#include <QtQml/QQmlEngine>
+#include <QtQml/QQmlComponent>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtGui/QWindowSystemInterface>
+#include "../../shared/util.h"
+#include <QSignalSpy>
+
+struct TouchEventData {
+ QEvent::Type type;
+ QWidget *widget;
+ QWindow *window;
+ Qt::TouchPointStates states;
+ QList<QTouchEvent::TouchPoint> touchPoints;
+};
+
+static QTouchEvent::TouchPoint makeTouchPoint(QQuickItem *item, const QPointF &p, const QPointF &lastPoint = QPointF())
+{
+ QPointF last = lastPoint.isNull() ? p : lastPoint;
+
+ QTouchEvent::TouchPoint tp;
+
+ tp.setPos(p);
+ tp.setLastPos(last);
+ tp.setScenePos(item->mapToScene(p));
+ tp.setLastScenePos(item->mapToScene(last));
+ tp.setScreenPos(item->canvas()->mapToGlobal(tp.scenePos().toPoint()));
+ tp.setLastScreenPos(item->canvas()->mapToGlobal(tp.lastScenePos().toPoint()));
+ return tp;
+}
+
+static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, Qt::TouchPointStates states = 0,
+ const QList<QTouchEvent::TouchPoint>& touchPoints = QList<QTouchEvent::TouchPoint>())
+{
+ TouchEventData d = { type, 0, w, states, touchPoints };
+ return d;
+}
+static TouchEventData makeTouchData(QEvent::Type type, QWindow *w, Qt::TouchPointStates states, const QTouchEvent::TouchPoint &touchPoint)
+{
+ QList<QTouchEvent::TouchPoint> points;
+ points << touchPoint;
+ return makeTouchData(type, w, states, points);
+}
+
+#define COMPARE_TOUCH_POINTS(tp1, tp2) \
+{ \
+ QCOMPARE(tp1.pos(), tp2.pos()); \
+ QCOMPARE(tp1.lastPos(), tp2.lastPos()); \
+ QCOMPARE(tp1.scenePos(), tp2.scenePos()); \
+ QCOMPARE(tp1.lastScenePos(), tp2.lastScenePos()); \
+ QCOMPARE(tp1.screenPos(), tp2.screenPos()); \
+ QCOMPARE(tp1.lastScreenPos(), tp2.lastScreenPos()); \
+}
+
+#define COMPARE_TOUCH_DATA(d1, d2) \
+{ \
+ QCOMPARE((int)d1.type, (int)d2.type); \
+ QCOMPARE(d1.widget, d2.widget); \
+ QCOMPARE((int)d1.states, (int)d2.states); \
+ QCOMPARE(d1.touchPoints.count(), d2.touchPoints.count()); \
+ for (int i=0; i<d1.touchPoints.count(); i++) { \
+ COMPARE_TOUCH_POINTS(d1.touchPoints[i], d2.touchPoints[i]); \
+ } \
+}
+
+class TestTouchItem : public QQuickRectangle
+{
+ Q_OBJECT
+public:
+ TestTouchItem(QQuickItem *parent = 0)
+ : QQuickRectangle(parent), acceptEvents(true), mousePressId(0)
+ {
+ border()->setWidth(1);
+ setAcceptedMouseButtons(Qt::LeftButton);
+ setFiltersChildMouseEvents(true);
+ }
+
+ void reset() {
+ acceptEvents = true;
+ setEnabled(true);
+ setOpacity(1.0);
+
+ lastEvent = makeTouchData(QEvent::None, canvas(), 0, QList<QTouchEvent::TouchPoint>());//CHECK_VALID
+ }
+
+ static void clearMousePressCounter()
+ {
+ mousePressNum = 0;
+ }
+
+ bool acceptEvents;
+ TouchEventData lastEvent;
+ int mousePressId;
+protected:
+ virtual void touchEvent(QTouchEvent *event) {
+ if (!acceptEvents) {
+ event->ignore();
+ return;
+ }
+ lastEvent = makeTouchData(event->type(), event->window(), event->touchPointStates(), event->touchPoints());
+ event->accept();
+ }
+
+ virtual void mousePressEvent(QMouseEvent *) {
+ mousePressId = ++mousePressNum;
+ }
+
+ bool childMouseEventFilter(QQuickItem *, QEvent *event) {
+ if (event->type() == QEvent::MouseButtonPress)
+ mousePressId = ++mousePressNum;
+ return false;
+ }
+
+ static int mousePressNum;
+};
+
+int TestTouchItem::mousePressNum = 0;
+
+class ConstantUpdateItem : public QQuickItem
+{
+Q_OBJECT
+public:
+ ConstantUpdateItem(QQuickItem *parent = 0) : QQuickItem(parent), iterations(0) {setFlag(ItemHasContents);}
+
+ int iterations;
+protected:
+ QSGNode* updatePaintNode(QSGNode *, UpdatePaintNodeData *){
+ iterations++;
+ update();
+ return 0;
+ }
+};
+
+class tst_qquickcanvas : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+
+private slots:
+ void initTestCase()
+ {
+ QQmlDataTest::initTestCase();
+ touchDevice = new QTouchDevice();
+ touchDevice->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(touchDevice);
+ }
+
+
+ void constantUpdates();
+ void mouseFiltering();
+ void headless();
+
+ void touchEvent_basic();
+ void touchEvent_propagation();
+ void touchEvent_propagation_data();
+ void touchEvent_cancel();
+
+ void clearCanvas();
+
+ void qmlCreation();
+ void clearColor();
+
+ void grab();
+ void multipleWindows();
+
+ void animationsWhileHidden();
+
+ void focusObject();
+
+ void ignoreUnhandledMouseEvents();
+
+private:
+ QTouchDevice *touchDevice;
+};
+
+//If the item calls update inside updatePaintNode, it should schedule another update
+void tst_qquickcanvas::constantUpdates()
+{
+ QQuickCanvas canvas;
+ canvas.resize(250, 250);
+ ConstantUpdateItem item(canvas.rootItem());
+ canvas.show();
+ QTRY_VERIFY(item.iterations > 60);
+}
+
+void tst_qquickcanvas::touchEvent_basic()
+{
+ TestTouchItem::clearMousePressCounter();
+
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(250, 250);
+ canvas->move(100, 100);
+ canvas->show();
+
+ TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem());
+ bottomItem->setObjectName("Bottom Item");
+ bottomItem->setSize(QSizeF(150, 150));
+
+ TestTouchItem *middleItem = new TestTouchItem(bottomItem);
+ middleItem->setObjectName("Middle Item");
+ middleItem->setPos(QPointF(50, 50));
+ middleItem->setSize(QSizeF(150, 150));
+
+ TestTouchItem *topItem = new TestTouchItem(middleItem);
+ topItem->setObjectName("Top Item");
+ topItem->setPos(QPointF(50, 50));
+ topItem->setSize(QSizeF(150, 150));
+
+ QPointF pos(10, 10);
+
+ // press single point
+ QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas);
+ QTest::qWait(50);
+
+ QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
+
+ QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
+ QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
+ TouchEventData d = makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem,pos));
+ COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos)));
+ topItem->reset();
+
+ // press multiple points
+ QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas)
+ .press(1, bottomItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
+ QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
+ QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
+ COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos)));
+ COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos)));
+ topItem->reset();
+ bottomItem->reset();
+
+ // touch point on top item moves to bottom item, but top item should still receive the event
+ QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QTest::touchEvent(canvas, touchDevice).move(0, bottomItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
+ COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchUpdate, canvas, Qt::TouchPointMoved,
+ makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos), pos)));
+ topItem->reset();
+
+ // touch point on bottom item moves to top item, but bottom item should still receive the event
+ QTest::touchEvent(canvas, touchDevice).press(0, bottomItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QTest::touchEvent(canvas, touchDevice).move(0, topItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
+ COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchUpdate, canvas, Qt::TouchPointMoved,
+ makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos), pos)));
+ bottomItem->reset();
+
+ // a single stationary press on an item shouldn't cause an event
+ QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QTest::touchEvent(canvas, touchDevice).stationary(0)
+ .press(1, bottomItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QCOMPARE(topItem->lastEvent.touchPoints.count(), 1); // received press only, not stationary
+ QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
+ QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
+ COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(topItem, pos)));
+ COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos)));
+ topItem->reset();
+ bottomItem->reset();
+
+ // move touch point from top item to bottom, and release
+ QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas);
+ QTest::qWait(50);
+ QTest::touchEvent(canvas, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(),canvas);
+ QTest::qWait(50);
+ QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
+ COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, canvas, Qt::TouchPointReleased,
+ makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos), pos)));
+ topItem->reset();
+
+ // release while another point is pressed
+ QTest::touchEvent(canvas, touchDevice).press(0, topItem->mapToScene(pos).toPoint(),canvas)
+ .press(1, bottomItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QTest::touchEvent(canvas, touchDevice).move(0, bottomItem->mapToScene(pos).toPoint(), canvas);
+ QTest::qWait(50);
+ QTest::touchEvent(canvas, touchDevice).release(0, bottomItem->mapToScene(pos).toPoint(), canvas)
+ .stationary(1);
+ QTest::qWait(50);
+ QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
+ QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
+ QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
+ COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchEnd, canvas, Qt::TouchPointReleased,
+ makeTouchPoint(topItem, topItem->mapFromItem(bottomItem, pos))));
+ COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(bottomItem, pos)));
+ topItem->reset();
+ bottomItem->reset();
+
+ delete topItem;
+ delete middleItem;
+ delete bottomItem;
+ delete canvas;
+}
+
+void tst_qquickcanvas::touchEvent_propagation()
+{
+ TestTouchItem::clearMousePressCounter();
+
+ QFETCH(bool, acceptEvents);
+ QFETCH(bool, enableItem);
+ QFETCH(qreal, itemOpacity);
+
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(250, 250);
+ canvas->move(100, 100);
+ canvas->show();
+
+ TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem());
+ bottomItem->setObjectName("Bottom Item");
+ bottomItem->setSize(QSizeF(150, 150));
+
+ TestTouchItem *middleItem = new TestTouchItem(bottomItem);
+ middleItem->setObjectName("Middle Item");
+ middleItem->setPos(QPointF(50, 50));
+ middleItem->setSize(QSizeF(150, 150));
+
+ TestTouchItem *topItem = new TestTouchItem(middleItem);
+ topItem->setObjectName("Top Item");
+ topItem->setPos(QPointF(50, 50));
+ topItem->setSize(QSizeF(150, 150));
+
+ QPointF pos(10, 10);
+ QPoint pointInBottomItem = bottomItem->mapToScene(pos).toPoint(); // (10, 10)
+ QPoint pointInMiddleItem = middleItem->mapToScene(pos).toPoint(); // (60, 60) overlaps with bottomItem
+ QPoint pointInTopItem = topItem->mapToScene(pos).toPoint(); // (110, 110) overlaps with bottom & top items
+
+ // disable topItem
+ topItem->acceptEvents = acceptEvents;
+ topItem->setEnabled(enableItem);
+ topItem->setOpacity(itemOpacity);
+
+ // single touch to top item, should be received by middle item
+ QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas);
+ QTest::qWait(50);
+ QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
+ QCOMPARE(middleItem->lastEvent.touchPoints.count(), 1);
+ QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
+ COMPARE_TOUCH_DATA(middleItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
+ makeTouchPoint(middleItem, middleItem->mapFromItem(topItem, pos))));
+
+ // touch top and middle items, middle item should get both events
+ QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas)
+ .press(1, pointInMiddleItem, canvas);
+ QTest::qWait(50);
+ QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
+ QCOMPARE(middleItem->lastEvent.touchPoints.count(), 2);
+ QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
+ COMPARE_TOUCH_DATA(middleItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
+ (QList<QTouchEvent::TouchPoint>() << makeTouchPoint(middleItem, middleItem->mapFromItem(topItem, pos))
+ << makeTouchPoint(middleItem, pos) )));
+ middleItem->reset();
+
+ // disable middleItem as well
+ middleItem->acceptEvents = acceptEvents;
+ middleItem->setEnabled(enableItem);
+ middleItem->setOpacity(itemOpacity);
+
+ // touch top and middle items, bottom item should get all events
+ QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas)
+ .press(1, pointInMiddleItem, canvas);
+ QTest::qWait(50);
+ QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
+ QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
+ QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 2);
+ COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
+ (QList<QTouchEvent::TouchPoint>() << makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos))
+ << makeTouchPoint(bottomItem, bottomItem->mapFromItem(middleItem, pos)) )));
+ bottomItem->reset();
+
+ // disable bottom item as well
+ bottomItem->acceptEvents = acceptEvents;
+ bottomItem->setEnabled(enableItem);
+ bottomItem->setOpacity(itemOpacity);
+
+ // no events should be received
+ QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas)
+ .press(1, pointInMiddleItem, canvas)
+ .press(2, pointInBottomItem, canvas);
+ QTest::qWait(50);
+ QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
+ QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
+ QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
+
+ topItem->reset();
+ middleItem->reset();
+ bottomItem->reset();
+
+ // disable middle item, touch on top item
+ middleItem->acceptEvents = acceptEvents;
+ middleItem->setEnabled(enableItem);
+ middleItem->setOpacity(itemOpacity);
+ QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas);
+ QTest::qWait(50);
+ if (!enableItem || itemOpacity == 0) {
+ // middle item is disabled or has 0 opacity, bottom item receives the event
+ QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
+ QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
+ QCOMPARE(bottomItem->lastEvent.touchPoints.count(), 1);
+ COMPARE_TOUCH_DATA(bottomItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
+ makeTouchPoint(bottomItem, bottomItem->mapFromItem(topItem, pos))));
+ } else {
+ // middle item ignores event, sends it to the top item (top-most child)
+ QCOMPARE(topItem->lastEvent.touchPoints.count(), 1);
+ QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
+ QVERIFY(bottomItem->lastEvent.touchPoints.isEmpty());
+ COMPARE_TOUCH_DATA(topItem->lastEvent, makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed,
+ makeTouchPoint(topItem, pos)));
+ }
+
+ delete topItem;
+ delete middleItem;
+ delete bottomItem;
+ delete canvas;
+}
+
+void tst_qquickcanvas::touchEvent_propagation_data()
+{
+ QTest::addColumn<bool>("acceptEvents");
+ QTest::addColumn<bool>("enableItem");
+ QTest::addColumn<qreal>("itemOpacity");
+
+ QTest::newRow("disable events") << false << true << 1.0;
+ QTest::newRow("disable item") << true << false << 1.0;
+ QTest::newRow("opacity of 0") << true << true << 0.0;
+}
+
+void tst_qquickcanvas::touchEvent_cancel()
+{
+ TestTouchItem::clearMousePressCounter();
+
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(250, 250);
+ canvas->move(100, 100);
+ canvas->show();
+
+ TestTouchItem *item = new TestTouchItem(canvas->rootItem());
+ item->setPos(QPointF(50, 50));
+ item->setSize(QSizeF(150, 150));
+
+ QPointF pos(10, 10);
+ QTest::touchEvent(canvas, touchDevice).press(0, item->mapToScene(pos).toPoint(),canvas);
+ QCoreApplication::processEvents();
+
+ QTRY_COMPARE(item->lastEvent.touchPoints.count(), 1);
+ TouchEventData d = makeTouchData(QEvent::TouchBegin, canvas, Qt::TouchPointPressed, makeTouchPoint(item,pos));
+ COMPARE_TOUCH_DATA(item->lastEvent, d);
+ item->reset();
+
+ QWindowSystemInterface::handleTouchCancelEvent(0, touchDevice);
+ QCoreApplication::processEvents();
+ d = makeTouchData(QEvent::TouchCancel, canvas);
+ COMPARE_TOUCH_DATA(item->lastEvent, d);
+
+ delete item;
+ delete canvas;
+}
+
+void tst_qquickcanvas::clearCanvas()
+{
+ QQuickCanvas *canvas = new QQuickCanvas;
+ QQuickItem *item = new QQuickItem;
+ item->setParentItem(canvas->rootItem());
+
+ QVERIFY(item->canvas() == canvas);
+
+ delete canvas;
+
+ QVERIFY(item->canvas() == 0);
+
+ delete item;
+}
+
+void tst_qquickcanvas::mouseFiltering()
+{
+ TestTouchItem::clearMousePressCounter();
+
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(250, 250);
+ canvas->move(100, 100);
+ canvas->show();
+
+ TestTouchItem *bottomItem = new TestTouchItem(canvas->rootItem());
+ bottomItem->setObjectName("Bottom Item");
+ bottomItem->setSize(QSizeF(150, 150));
+
+ TestTouchItem *middleItem = new TestTouchItem(bottomItem);
+ middleItem->setObjectName("Middle Item");
+ middleItem->setPos(QPointF(50, 50));
+ middleItem->setSize(QSizeF(150, 150));
+
+ TestTouchItem *topItem = new TestTouchItem(middleItem);
+ topItem->setObjectName("Top Item");
+ topItem->setPos(QPointF(50, 50));
+ topItem->setSize(QSizeF(150, 150));
+
+ QPoint pos(100, 100);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, pos);
+
+ // Mouse filtering propagates down the stack, so the
+ // correct order is
+ // 1. middleItem filters event
+ // 2. bottomItem filters event
+ // 3. topItem receives event
+ QTRY_COMPARE(middleItem->mousePressId, 1);
+ QTRY_COMPARE(bottomItem->mousePressId, 2);
+ QTRY_COMPARE(topItem->mousePressId, 3);
+
+ delete canvas;
+}
+
+void tst_qquickcanvas::qmlCreation()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("window.qml"));
+ QObject* created = component.create();
+ QVERIFY(created);
+
+ QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created);
+ QVERIFY(canvas);
+ QCOMPARE(canvas->clearColor(), QColor(Qt::green));
+
+ QQuickItem* item = canvas->findChild<QQuickItem*>("item");
+ QVERIFY(item);
+ QCOMPARE(item->canvas(), canvas);
+
+ delete canvas;
+}
+
+void tst_qquickcanvas::clearColor()
+{
+ //### Can we examine rendering to make sure it is really blue?
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(250, 250);
+ canvas->move(100, 100);
+ canvas->setClearColor(Qt::blue);
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+ QCOMPARE(canvas->clearColor(), QColor(Qt::blue));
+ delete canvas;
+}
+
+void tst_qquickcanvas::grab()
+{
+ QQuickCanvas canvas;
+ canvas.setClearColor(Qt::red);
+
+ canvas.resize(250, 250);
+ canvas.show();
+
+ QTest::qWaitForWindowShown(&canvas);
+
+ QImage content = canvas.grabFrameBuffer();
+ QCOMPARE(content.width(), canvas.width());
+ QCOMPARE(content.height(), canvas.height());
+ QCOMPARE((uint) content.convertToFormat(QImage::Format_RGB32).pixel(0, 0), (uint) 0xffff0000);
+}
+
+void tst_qquickcanvas::multipleWindows()
+{
+ QList<QQuickCanvas *> windows;
+ for (int i=0; i<6; ++i) {
+ QQuickCanvas *c = new QQuickCanvas();
+ c->setClearColor(Qt::GlobalColor(Qt::red + i));
+ c->resize(300, 200);
+ c->setPos(100 + i * 30, 100 + i * 20);
+ c->show();
+ windows << c;
+ QVERIFY(c->visible());
+ }
+
+ // move them
+ for (int i=0; i<windows.size(); ++i) {
+ QQuickCanvas *c = windows.at(i);
+ c->setPos(c->x() - 10, c->y() - 10);
+ }
+
+ // resize them
+ for (int i=0; i<windows.size(); ++i) {
+ QQuickCanvas *c = windows.at(i);
+ c->resize(200, 150);
+ }
+
+ qDeleteAll(windows);
+}
+
+void tst_qquickcanvas::animationsWhileHidden()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("AnimationsWhileHidden.qml"));
+ QObject* created = component.create();
+
+ QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created);
+ QVERIFY(canvas);
+ QVERIFY(canvas->visible());
+
+ // Now hide the window and verify that it went off screen
+ canvas->hide();
+ QTest::qWait(10);
+ QVERIFY(!canvas->visible());
+
+ // Running animaiton should cause it to become visible again shortly.
+ QTRY_VERIFY(canvas->visible());
+
+ delete canvas;
+}
+
+
+void tst_qquickcanvas::headless()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("Headless.qml"));
+ QObject* created = component.create();
+
+ QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created);
+ QVERIFY(canvas);
+
+ QTest::qWaitForWindowShown(canvas);
+ QVERIFY(canvas->visible());
+
+ QSignalSpy initialized(canvas, SIGNAL(sceneGraphInitialized()));
+ QSignalSpy invalidated(canvas, SIGNAL(sceneGraphInvalidated()));
+
+ // Verify that the canvas is alive and kicking
+ QVERIFY(canvas->openglContext() != 0);
+
+ // Store the visual result
+ QImage originalContent = canvas->grabFrameBuffer();
+
+ // Hide the canvas and verify signal emittion and GL context deletion
+ canvas->hide();
+ canvas->releaseResources();
+
+ QTRY_COMPARE(invalidated.size(), 1);
+ QVERIFY(canvas->openglContext() == 0);
+
+ // Destroy the native windowing system buffers
+ canvas->destroy();
+ QVERIFY(canvas->handle() == 0);
+
+ // Show and verify that we are back and running
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QCOMPARE(initialized.size(), 1);
+ QVERIFY(canvas->openglContext() != 0);
+
+ // Verify that the visual output is the same
+ QImage newContent = canvas->grabFrameBuffer();
+
+ QCOMPARE(originalContent, newContent);
+
+ delete canvas;
+}
+
+void tst_qquickcanvas::focusObject()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("focus.qml"));
+ QObject *created = component.create();
+ QVERIFY(created);
+
+ QQuickCanvas *canvas = qobject_cast<QQuickCanvas*>(created);
+ QVERIFY(canvas);
+
+ QQuickItem *item1 = canvas->findChild<QQuickItem*>("item1");
+ QVERIFY(item1);
+ item1->setFocus(true);
+ QCOMPARE(item1, canvas->focusObject());
+
+ QQuickItem *item2 = canvas->findChild<QQuickItem*>("item2");
+ QVERIFY(item2);
+ item2->setFocus(true);
+ QCOMPARE(item2, canvas->focusObject());
+
+ delete canvas;
+}
+
+void tst_qquickcanvas::ignoreUnhandledMouseEvents()
+{
+ QQuickCanvas* canvas = new QQuickCanvas;
+ canvas->resize(100, 100);
+ canvas->show();
+
+ QQuickItem* item = new QQuickItem;
+ item->setSize(QSizeF(100, 100));
+ item->setParentItem(canvas->rootItem());
+
+ {
+ QMouseEvent me(QEvent::MouseButtonPress, QPointF(50, 50), Qt::LeftButton, Qt::LeftButton,
+ Qt::NoModifier);
+ me.setAccepted(true);
+ QVERIFY(QCoreApplication::sendEvent(canvas, &me));
+ QVERIFY(!me.isAccepted());
+ }
+
+ {
+ QMouseEvent me(QEvent::MouseMove, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton,
+ Qt::NoModifier);
+ me.setAccepted(true);
+ QVERIFY(QCoreApplication::sendEvent(canvas, &me));
+ QVERIFY(!me.isAccepted());
+ }
+
+ {
+ QMouseEvent me(QEvent::MouseButtonRelease, QPointF(51, 51), Qt::LeftButton, Qt::LeftButton,
+ Qt::NoModifier);
+ me.setAccepted(true);
+ QVERIFY(QCoreApplication::sendEvent(canvas, &me));
+ QVERIFY(!me.isAccepted());
+ }
+
+ delete canvas;
+}
+
+QTEST_MAIN(tst_qquickcanvas)
+
+#include "tst_qquickcanvas.moc"
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.gif b/tests/auto/quick/qquickcanvasitem/data/anim-gr.gif
index 45263e0afb..45263e0afb 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.gif
+++ b/tests/auto/quick/qquickcanvasitem/data/anim-gr.gif
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.png b/tests/auto/quick/qquickcanvasitem/data/anim-gr.png
index 925e2efc9a..925e2efc9a 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/anim-gr.png
+++ b/tests/auto/quick/qquickcanvasitem/data/anim-gr.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/anim-poster-gr.png b/tests/auto/quick/qquickcanvasitem/data/anim-poster-gr.png
index 6941207373..6941207373 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/anim-poster-gr.png
+++ b/tests/auto/quick/qquickcanvasitem/data/anim-poster-gr.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/background.png b/tests/auto/quick/qquickcanvasitem/data/background.png
index 6db6c6b1b9..6db6c6b1b9 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/background.png
+++ b/tests/auto/quick/qquickcanvasitem/data/background.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/broken.png b/tests/auto/quick/qquickcanvasitem/data/broken.png
index f2581017b4..f2581017b4 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/broken.png
+++ b/tests/auto/quick/qquickcanvasitem/data/broken.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/ggrr-256x256.png b/tests/auto/quick/qquickcanvasitem/data/ggrr-256x256.png
index 0342e4a384..0342e4a384 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/ggrr-256x256.png
+++ b/tests/auto/quick/qquickcanvasitem/data/ggrr-256x256.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/green-16x16.png b/tests/auto/quick/qquickcanvasitem/data/green-16x16.png
index e19a3ffddd..e19a3ffddd 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/green-16x16.png
+++ b/tests/auto/quick/qquickcanvasitem/data/green-16x16.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/green-1x1.png b/tests/auto/quick/qquickcanvasitem/data/green-1x1.png
index 862d1dd10c..862d1dd10c 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/green-1x1.png
+++ b/tests/auto/quick/qquickcanvasitem/data/green-1x1.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/green-256x256.png b/tests/auto/quick/qquickcanvasitem/data/green-256x256.png
index b06945c310..b06945c310 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/green-256x256.png
+++ b/tests/auto/quick/qquickcanvasitem/data/green-256x256.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/green-2x2.png b/tests/auto/quick/qquickcanvasitem/data/green-2x2.png
index adc059449c..adc059449c 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/green-2x2.png
+++ b/tests/auto/quick/qquickcanvasitem/data/green-2x2.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/green.png b/tests/auto/quick/qquickcanvasitem/data/green.png
index 28a1faab37..28a1faab37 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/green.png
+++ b/tests/auto/quick/qquickcanvasitem/data/green.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/grgr-256x256.png b/tests/auto/quick/qquickcanvasitem/data/grgr-256x256.png
index b8c7189d62..b8c7189d62 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/grgr-256x256.png
+++ b/tests/auto/quick/qquickcanvasitem/data/grgr-256x256.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/red-16x16.png b/tests/auto/quick/qquickcanvasitem/data/red-16x16.png
index 9038fef784..9038fef784 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/red-16x16.png
+++ b/tests/auto/quick/qquickcanvasitem/data/red-16x16.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/red.png b/tests/auto/quick/qquickcanvasitem/data/red.png
index a6e195d59c..a6e195d59c 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/red.png
+++ b/tests/auto/quick/qquickcanvasitem/data/red.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/redtransparent.png b/tests/auto/quick/qquickcanvasitem/data/redtransparent.png
index 75da08c3d6..75da08c3d6 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/redtransparent.png
+++ b/tests/auto/quick/qquickcanvasitem/data/redtransparent.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/rgrg-256x256.png b/tests/auto/quick/qquickcanvasitem/data/rgrg-256x256.png
index e6fba3daa5..e6fba3daa5 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/rgrg-256x256.png
+++ b/tests/auto/quick/qquickcanvasitem/data/rgrg-256x256.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/rrgg-256x256.png b/tests/auto/quick/qquickcanvasitem/data/rrgg-256x256.png
index 7f63515654..7f63515654 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/rrgg-256x256.png
+++ b/tests/auto/quick/qquickcanvasitem/data/rrgg-256x256.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/testhelper.js b/tests/auto/quick/qquickcanvasitem/data/testhelper.js
index bac0210e16..bac0210e16 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/testhelper.js
+++ b/tests/auto/quick/qquickcanvasitem/data/testhelper.js
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/transparent.png b/tests/auto/quick/qquickcanvasitem/data/transparent.png
index 2b498699a8..2b498699a8 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/transparent.png
+++ b/tests/auto/quick/qquickcanvasitem/data/transparent.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/transparent50.png b/tests/auto/quick/qquickcanvasitem/data/transparent50.png
index 55f8e69325..55f8e69325 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/transparent50.png
+++ b/tests/auto/quick/qquickcanvasitem/data/transparent50.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_arc.qml b/tests/auto/quick/qquickcanvasitem/data/tst_arc.qml
index 6006a5a4c0..6006a5a4c0 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_arc.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_arc.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_arcto.qml b/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml
index cc1d88672b..cc1d88672b 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_arcto.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_arcto.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_canvas.qml b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml
index a00ccc3c3f..a00ccc3c3f 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_canvas.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_canvas.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_composite.qml b/tests/auto/quick/qquickcanvasitem/data/tst_composite.qml
index 11e1dce902..11e1dce902 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_composite.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_composite.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_context.qml b/tests/auto/quick/qquickcanvasitem/data/tst_context.qml
index b72e755ed9..b72e755ed9 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_context.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_context.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_drawimage.qml b/tests/auto/quick/qquickcanvasitem/data/tst_drawimage.qml
index 102217dc0c..102217dc0c 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_drawimage.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_drawimage.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_fillStyle.qml b/tests/auto/quick/qquickcanvasitem/data/tst_fillStyle.qml
index 8f5a78cec0..8f5a78cec0 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_fillStyle.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_fillStyle.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_fillrect.qml b/tests/auto/quick/qquickcanvasitem/data/tst_fillrect.qml
index 08197816e9..08197816e9 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_fillrect.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_fillrect.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_gradient.qml b/tests/auto/quick/qquickcanvasitem/data/tst_gradient.qml
index d454c2efe1..d454c2efe1 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_gradient.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_gradient.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_line.qml b/tests/auto/quick/qquickcanvasitem/data/tst_line.qml
index baf9987ce3..baf9987ce3 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_line.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_line.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_path.qml b/tests/auto/quick/qquickcanvasitem/data/tst_path.qml
index b04ccf5458..b04ccf5458 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_path.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_path.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_pattern.qml b/tests/auto/quick/qquickcanvasitem/data/tst_pattern.qml
index dd5b6628e8..dd5b6628e8 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_pattern.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_pattern.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_pixel.qml b/tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml
index 1a3793d7a3..1a3793d7a3 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_pixel.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_shadow.qml b/tests/auto/quick/qquickcanvasitem/data/tst_shadow.qml
index 4405ca6c0e..4405ca6c0e 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_shadow.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_shadow.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_state.qml b/tests/auto/quick/qquickcanvasitem/data/tst_state.qml
index 8042cf6a1d..8042cf6a1d 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_state.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_state.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_strokeStyle.qml b/tests/auto/quick/qquickcanvasitem/data/tst_strokeStyle.qml
index 6b42f8a770..6b42f8a770 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_strokeStyle.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_strokeStyle.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_text.qml b/tests/auto/quick/qquickcanvasitem/data/tst_text.qml
index baeb17c9fb..baeb17c9fb 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_text.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_text.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/tst_transform.qml b/tests/auto/quick/qquickcanvasitem/data/tst_transform.qml
index 834a22f549..834a22f549 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/tst_transform.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_transform.qml
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/yellow.png b/tests/auto/quick/qquickcanvasitem/data/yellow.png
index 51e8aaf38c..51e8aaf38c 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/yellow.png
+++ b/tests/auto/quick/qquickcanvasitem/data/yellow.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickcanvasitem/data/yellow75.png b/tests/auto/quick/qquickcanvasitem/data/yellow75.png
index 2bb82c9834..2bb82c9834 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/data/yellow75.png
+++ b/tests/auto/quick/qquickcanvasitem/data/yellow75.png
Binary files differ
diff --git a/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro b/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro
new file mode 100644
index 0000000000..ccf894715f
--- /dev/null
+++ b/tests/auto/quick/qquickcanvasitem/qquickcanvasitem.pro
@@ -0,0 +1,34 @@
+QT += core-private gui-private qml-private widgets
+TEMPLATE=app
+TARGET=tst_qquickcanvasitem
+
+CONFIG += warn_on qmltestcase
+SOURCES += tst_qquickcanvasitem.cpp
+
+importFiles.files = data
+importFiles.path = .
+DEPLOYMENT += importFiles
+
+OTHER_FILES += \
+ data/testhelper.js \
+ data/tst_transform.qml \
+ data/tst_text.qml \
+ data/tst_strokeStyle.qml \
+ data/tst_state.qml \
+ data/tst_shadow.qml \
+ data/tst_pattern.qml \
+ data/tst_path.qml \
+ data/tst_line.qml \
+ data/tst_fillStyle.qml \
+ data/tst_fillrect.qml \
+ data/tst_drawimage.qml \
+ data/tst_composite.qml \
+ data/tst_canvas.qml \
+ data/tst_pixel.qml \
+ data/tst_gradient.qml \
+ data/tst_arcto.qml \
+ data/tst_arc.qml \
+ data/tst_context.qml
+
+
+
diff --git a/tests/auto/qtquick2/qquickcanvasitem/tst_qquickcanvasitem.cpp b/tests/auto/quick/qquickcanvasitem/tst_qquickcanvasitem.cpp
index 468c7cb9db..468c7cb9db 100644
--- a/tests/auto/qtquick2/qquickcanvasitem/tst_qquickcanvasitem.cpp
+++ b/tests/auto/quick/qquickcanvasitem/tst_qquickcanvasitem.cpp
diff --git a/tests/auto/quick/qquickdrag/qquickdrag.pro b/tests/auto/quick/qquickdrag/qquickdrag.pro
new file mode 100644
index 0000000000..820661ac23
--- /dev/null
+++ b/tests/auto/quick/qquickdrag/qquickdrag.pro
@@ -0,0 +1,9 @@
+TARGET = tst_qquickdrag
+CONFIG += testcase
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickdrag.cpp
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
new file mode 100644
index 0000000000..37fb6d2d1f
--- /dev/null
+++ b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
@@ -0,0 +1,1034 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlexpression.h>
+
+template <typename T> static T evaluate(QObject *scope, const QString &expression)
+{
+ QQmlExpression expr(qmlContext(scope), scope, expression);
+ QVariant result = expr.evaluate();
+ if (expr.hasError())
+ qWarning() << expr.error().toString();
+ return result.value<T>();
+}
+
+template <> void evaluate<void>(QObject *scope, const QString &expression)
+{
+ QQmlExpression expr(qmlContext(scope), scope, expression);
+ expr.evaluate();
+ if (expr.hasError())
+ qWarning() << expr.error().toString();
+}
+
+Q_DECLARE_METATYPE(Qt::DropActions)
+
+class TestDropTarget : public QQuickItem
+{
+ Q_OBJECT
+public:
+ TestDropTarget(QQuickItem *parent = 0)
+ : QQuickItem(parent)
+ , enterEvents(0)
+ , moveEvents(0)
+ , leaveEvents(0)
+ , dropEvents(0)
+ , acceptAction(Qt::MoveAction)
+ , defaultAction(Qt::IgnoreAction)
+ , proposedAction(Qt::IgnoreAction)
+ , accept(true)
+ {
+ setFlags(ItemAcceptsDrops);
+ }
+
+ void reset()
+ {
+ enterEvents = 0;
+ moveEvents = 0;
+ leaveEvents = 0;
+ dropEvents = 0;
+ defaultAction = Qt::IgnoreAction;
+ proposedAction = Qt::IgnoreAction;
+ supportedActions = Qt::IgnoreAction;
+ }
+
+ void dragEnterEvent(QDragEnterEvent *event)
+ {
+ ++enterEvents;
+ position = event->pos();
+ defaultAction = event->dropAction();
+ proposedAction = event->proposedAction();
+ supportedActions = event->possibleActions();
+ event->setAccepted(accept);
+ }
+
+ void dragMoveEvent(QDragMoveEvent *event)
+ {
+ ++moveEvents;
+ position = event->pos();
+ defaultAction = event->dropAction();
+ proposedAction = event->proposedAction();
+ supportedActions = event->possibleActions();
+ event->setAccepted(accept);
+ }
+
+ void dragLeaveEvent(QDragLeaveEvent *event)
+ {
+ ++leaveEvents;
+ event->setAccepted(accept);
+ }
+
+ void dropEvent(QDropEvent *event)
+ {
+ ++dropEvents;
+ position = event->pos();
+ defaultAction = event->dropAction();
+ proposedAction = event->proposedAction();
+ supportedActions = event->possibleActions();
+ event->setDropAction(acceptAction);
+ event->setAccepted(accept);
+ }
+
+ int enterEvents;
+ int moveEvents;
+ int leaveEvents;
+ int dropEvents;
+ Qt::DropAction acceptAction;
+ Qt::DropAction defaultAction;
+ Qt::DropAction proposedAction;
+ Qt::DropActions supportedActions;
+ QPointF position;
+ bool accept;
+};
+
+class tst_QQuickDrag: public QObject
+{
+ Q_OBJECT
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void active();
+ void drop();
+ void move();
+ void hotSpot();
+ void supportedActions();
+ void proposedAction();
+ void keys();
+ void source();
+ void recursion_data();
+ void recursion();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_QQuickDrag::initTestCase()
+{
+
+}
+
+void tst_QQuickDrag::cleanupTestCase()
+{
+
+}
+
+void tst_QQuickDrag::active()
+{
+ QQuickCanvas canvas;
+ TestDropTarget dropTarget(canvas.rootItem());
+ dropTarget.setSize(QSizeF(100, 100));
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property bool dragActive: Drag.active\n"
+ "property Item dragTarget: Drag.target\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+ item->setParentItem(&dropTarget);
+
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1);
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.cancel()");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.start()");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ // Start while a drag is active, cancels the previous drag and starts a new one.
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.start()");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 1);
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.cancel()");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1);
+
+ // Enter events aren't sent to items without the QQuickItem::ItemAcceptsDrops flag.
+ dropTarget.setFlags(QQuickItem::Flags());
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ dropTarget.setFlags(QQuickItem::ItemAcceptsDrops);
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ dropTarget.setFlags(QQuickItem::Flags());
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1);
+
+ // Follow up events aren't sent to items if the enter event isn't accepted.
+ dropTarget.setFlags(QQuickItem::ItemAcceptsDrops);
+ dropTarget.accept = false;
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ dropTarget.accept = true;
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ dropTarget.accept = false;
+
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 1);
+
+ // Events are sent to hidden or disabled items.
+ dropTarget.accept = true;
+ dropTarget.setVisible(false);
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ evaluate<void>(item, "Drag.active = false");
+ dropTarget.setVisible(true);
+
+ dropTarget.setOpacity(0.0);
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
+
+ evaluate<void>(item, "Drag.active = false");
+ dropTarget.setOpacity(1.0);
+
+ dropTarget.setEnabled(false);
+ dropTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
+}
+
+void tst_QQuickDrag::drop()
+{
+ QQuickCanvas canvas;
+ TestDropTarget outerTarget(canvas.rootItem());
+ outerTarget.setSize(QSizeF(100, 100));
+ outerTarget.acceptAction = Qt::CopyAction;
+ TestDropTarget innerTarget(&outerTarget);
+ innerTarget.setSize(QSizeF(100, 100));
+ innerTarget.acceptAction = Qt::MoveAction;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property bool dragActive: Drag.active\n"
+ "property Item dragTarget: Drag.target\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+ item->setParentItem(&outerTarget);
+
+ innerTarget.reset(); outerTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&innerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&innerTarget));
+ QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
+ QCOMPARE(innerTarget.enterEvents, 1); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
+
+ innerTarget.reset(); outerTarget.reset();
+ QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.MoveAction"), true);
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&innerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&innerTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 1); QCOMPARE(outerTarget.dropEvents, 0);
+ QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 1);
+
+ innerTarget.reset(); outerTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&innerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&innerTarget));
+ QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
+ QCOMPARE(innerTarget.enterEvents, 1); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
+
+ // Inner target declines the drop so it is propagated to the outer target.
+ innerTarget.accept = false;
+
+ innerTarget.reset(); outerTarget.reset();
+ QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.CopyAction"), true);
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1);
+ QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 1);
+
+
+ // Inner target doesn't accept enter so drop goes directly to outer.
+ innerTarget.accept = true;
+ innerTarget.setFlags(QQuickItem::Flags());
+
+ innerTarget.reset(); outerTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
+ QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
+
+ innerTarget.reset(); outerTarget.reset();
+ QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.CopyAction"), true);
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1);
+ QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
+
+ // Neither target accepts drop so Qt::IgnoreAction is returned.
+ innerTarget.reset(); outerTarget.reset();
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
+ QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
+
+ outerTarget.accept = false;
+
+ innerTarget.reset(); outerTarget.reset();
+ QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.IgnoreAction"), true);
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 1);
+ QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
+
+ // drop doesn't send an event and returns Qt.IgnoreAction if not active.
+ innerTarget.accept = true;
+ outerTarget.accept = true;
+ innerTarget.reset(); outerTarget.reset();
+ QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.IgnoreAction"), true);
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), false);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), false);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.dropEvents, 0);
+ QCOMPARE(innerTarget.enterEvents, 0); QCOMPARE(innerTarget.leaveEvents, 0); QCOMPARE(innerTarget.dropEvents, 0);
+}
+
+void tst_QQuickDrag::move()
+{
+ QQuickCanvas canvas;
+ TestDropTarget outerTarget(canvas.rootItem());
+ outerTarget.setSize(QSizeF(100, 100));
+ TestDropTarget leftTarget(&outerTarget);
+ leftTarget.setPos(QPointF(0, 35));
+ leftTarget.setSize(QSizeF(30, 30));
+ TestDropTarget rightTarget(&outerTarget);
+ rightTarget.setPos(QPointF(70, 35));
+ rightTarget.setSize(QSizeF(30, 30));
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property bool dragActive: Drag.active\n"
+ "property Item dragTarget: Drag.target\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+ item->setParentItem(&outerTarget);
+
+ evaluate<void>(item, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
+ QCOMPARE(evaluate<bool>(item, "dragActive"), true);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 0);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(50)); QCOMPARE(outerTarget.position.y(), qreal(50));
+
+ // Move within the outer target.
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(60, 50));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(60)); QCOMPARE(outerTarget.position.y(), qreal(50));
+
+ // Move into the right target.
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(75, 50));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&rightTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&rightTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 1); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(75)); QCOMPARE(outerTarget.position.y(), qreal(50));
+ QCOMPARE(rightTarget.position.x(), qreal(5)); QCOMPARE(rightTarget.position.y(), qreal(15));
+
+ // Move into the left target.
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(25, 50));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&leftTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&leftTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
+ QCOMPARE(leftTarget .enterEvents, 1); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 1); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(50));
+ QCOMPARE(leftTarget.position.x(), qreal(25)); QCOMPARE(leftTarget.position.y(), qreal(15));
+
+ // Move within the left target.
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(25, 40));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&leftTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&leftTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 1);
+ QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(40));
+ QCOMPARE(leftTarget.position.x(), qreal(25)); QCOMPARE(leftTarget.position.y(), qreal(5));
+
+ // Move out of all targets.
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(110, 50));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 1); QCOMPARE(outerTarget.moveEvents, 0);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 1); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+
+ // Stop the right target accepting drag events and move into it.
+ rightTarget.accept = false;
+
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(80, 50));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 1); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 0);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 1); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(80)); QCOMPARE(outerTarget.position.y(), qreal(50));
+
+ // Stop the outer target accepting drag events after it has accepted an enter event.
+ outerTarget.accept = false;
+
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(60, 50));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(60)); QCOMPARE(outerTarget.position.y(), qreal(50));
+
+ // Clear the QQuickItem::ItemAcceptsDrops flag from the outer target after it accepted an enter event.
+ outerTarget.setFlags(QQuickItem::Flags());
+
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(40, 50));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(40)); QCOMPARE(outerTarget.position.y(), qreal(50));
+
+ // Clear the QQuickItem::ItemAcceptsDrops flag from the left target before it accepts an enter event.
+ leftTarget.setFlags(QQuickItem::Flags());
+
+ outerTarget.reset(); leftTarget.reset(); rightTarget.reset();
+ item->setPos(QPointF(25, 50));
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&outerTarget));
+ QCOMPARE(outerTarget.enterEvents, 0); QCOMPARE(outerTarget.leaveEvents, 0); QCOMPARE(outerTarget.moveEvents, 1);
+ QCOMPARE(leftTarget .enterEvents, 0); QCOMPARE(leftTarget .leaveEvents, 0); QCOMPARE(leftTarget .moveEvents, 0);
+ QCOMPARE(rightTarget.enterEvents, 0); QCOMPARE(rightTarget.leaveEvents, 0); QCOMPARE(rightTarget.moveEvents, 0);
+ QCOMPARE(outerTarget.position.x(), qreal(25)); QCOMPARE(outerTarget.position.y(), qreal(50));
+}
+
+
+void tst_QQuickDrag::hotSpot()
+{
+ QQuickCanvas canvas;
+ TestDropTarget dropTarget(canvas.rootItem());
+ dropTarget.setSize(QSizeF(100, 100));
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property real hotSpotX: Drag.hotSpot.x\n"
+ "property real hotSpotY: Drag.hotSpot.y\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+ item->setParentItem(&dropTarget);
+
+ QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.x"), qreal(0));
+ QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.y"), qreal(0));
+ QCOMPARE(evaluate<qreal>(item, "hotSpotX"), qreal(0));
+ QCOMPARE(evaluate<qreal>(item, "hotSpotY"), qreal(0));
+
+ evaluate<void>(item, "{ Drag.start(); Drag.cancel() }");
+ QCOMPARE(dropTarget.position.x(), qreal(50));
+ QCOMPARE(dropTarget.position.y(), qreal(50));
+
+ evaluate<void>(item, "{ Drag.hotSpot.x = 5, Drag.hotSpot.y = 5 }");
+ QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.x"), qreal(5));
+ QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.y"), qreal(5));
+ QCOMPARE(evaluate<qreal>(item, "hotSpotX"), qreal(5));
+ QCOMPARE(evaluate<qreal>(item, "hotSpotY"), qreal(5));
+
+ evaluate<void>(item, "Drag.start()");
+ QCOMPARE(dropTarget.position.x(), qreal(55));
+ QCOMPARE(dropTarget.position.y(), qreal(55));
+
+ item->setPos(QPointF(30, 20));
+ QCOMPARE(dropTarget.position.x(), qreal(35));
+ QCOMPARE(dropTarget.position.y(), qreal(25));
+
+ evaluate<void>(item, "{ Drag.hotSpot.x = 10; Drag.hotSpot.y = 10 }");
+ QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.x"), qreal(10));
+ QCOMPARE(evaluate<qreal>(item, "Drag.hotSpot.y"), qreal(10));
+ QCOMPARE(evaluate<qreal>(item, "hotSpotX"), qreal(10));
+ QCOMPARE(evaluate<qreal>(item, "hotSpotY"), qreal(10));
+ // Changing the hotSpot won't generate a move event so the position is unchanged. Should it?
+ QCOMPARE(dropTarget.position.x(), qreal(35));
+ QCOMPARE(dropTarget.position.y(), qreal(25));
+
+ item->setPos(QPointF(10, 20));
+ QCOMPARE(dropTarget.position.x(), qreal(20));
+ QCOMPARE(dropTarget.position.y(), qreal(30));
+}
+
+void tst_QQuickDrag::supportedActions()
+{
+ QQuickCanvas canvas;
+ TestDropTarget dropTarget(canvas.rootItem());
+ dropTarget.setSize(QSizeF(100, 100));
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property int supportedActions: Drag.supportedActions\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+ item->setParentItem(&dropTarget);
+
+ QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.CopyAction | Qt.MoveAction | Qt.LinkAction"), true);
+ QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.CopyAction | Qt.MoveAction | Qt.LinkAction"), true);
+ evaluate<void>(item, "{ Drag.start(); Drag.cancel() }");
+ QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction | Qt::LinkAction);
+
+ evaluate<void>(item, "Drag.supportedActions = Qt.CopyAction | Qt.MoveAction");
+ QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.CopyAction | Qt.MoveAction"), true);
+ QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.CopyAction | Qt.MoveAction"), true);
+ evaluate<void>(item, "Drag.start()");
+ QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction);
+
+ // Once a drag is started the proposed actions are locked in for future events.
+ evaluate<void>(item, "Drag.supportedActions = Qt.MoveAction");
+ QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.MoveAction"), true);
+ QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.MoveAction"), true);
+ item->setPos(QPointF(60, 60));
+ QCOMPARE(dropTarget.supportedActions, Qt::CopyAction | Qt::MoveAction);
+
+ // Calling start with proposed actions will override the current actions for the next sequence.
+ evaluate<void>(item, "Drag.start(Qt.CopyAction)");
+ QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.MoveAction"), true);
+ QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.MoveAction"), true);
+ QCOMPARE(dropTarget.supportedActions, Qt::CopyAction);
+
+ evaluate<void>(item, "Drag.start()");
+ QCOMPARE(evaluate<bool>(item, "Drag.supportedActions == Qt.MoveAction"), true);
+ QCOMPARE(evaluate<bool>(item, "supportedActions == Qt.MoveAction"), true);
+ QCOMPARE(dropTarget.supportedActions, Qt::MoveAction);
+}
+
+void tst_QQuickDrag::proposedAction()
+{
+ QQuickCanvas canvas;
+ TestDropTarget dropTarget(canvas.rootItem());
+ dropTarget.setSize(QSizeF(100, 100));
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property int proposedAction: Drag.proposedAction\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+ item->setParentItem(&dropTarget);
+
+
+ QCOMPARE(evaluate<bool>(item, "Drag.proposedAction == Qt.MoveAction"), true);
+ QCOMPARE(evaluate<bool>(item, "proposedAction == Qt.MoveAction"), true);
+ evaluate<void>(item, "{ Drag.start(); Drag.cancel() }");
+ QCOMPARE(dropTarget.defaultAction, Qt::MoveAction);
+ QCOMPARE(dropTarget.proposedAction, Qt::MoveAction);
+
+ evaluate<void>(item, "Drag.proposedAction = Qt.CopyAction");
+ QCOMPARE(evaluate<bool>(item, "Drag.proposedAction == Qt.CopyAction"), true);
+ QCOMPARE(evaluate<bool>(item, "proposedAction == Qt.CopyAction"), true);
+ evaluate<void>(item, "Drag.start()");
+ QCOMPARE(dropTarget.defaultAction, Qt::CopyAction);
+ QCOMPARE(dropTarget.proposedAction, Qt::CopyAction);
+
+ // The proposed action can change during a drag.
+ evaluate<void>(item, "Drag.proposedAction = Qt.MoveAction");
+ QCOMPARE(evaluate<bool>(item, "Drag.proposedAction == Qt.MoveAction"), true);
+ QCOMPARE(evaluate<bool>(item, "proposedAction == Qt.MoveAction"), true);
+ item->setPos(QPointF(60, 60));
+ QCOMPARE(dropTarget.defaultAction, Qt::MoveAction);
+ QCOMPARE(dropTarget.proposedAction, Qt::MoveAction);
+
+ evaluate<void>(item, "Drag.proposedAction = Qt.LinkAction");
+ QCOMPARE(evaluate<bool>(item, "Drag.proposedAction == Qt.LinkAction"), true);
+ QCOMPARE(evaluate<bool>(item, "proposedAction == Qt.LinkAction"), true);
+ evaluate<void>(item, "Drag.drop()");
+ QCOMPARE(dropTarget.defaultAction, Qt::LinkAction);
+ QCOMPARE(dropTarget.proposedAction, Qt::LinkAction);
+}
+
+void tst_QQuickDrag::keys()
+{
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property variant keys: Drag.keys\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+
+// QCOMPARE(evaluate<QStringList>(item, "Drag.keys"), QStringList());
+// QCOMPARE(evaluate<QStringList>(item, "keys"), QStringList());
+ QCOMPARE(item->property("keys").toStringList(), QStringList());
+
+ evaluate<void>(item, "Drag.keys = [\"red\", \"blue\"]");
+// QCOMPARE(evaluate<QStringList>(item, "Drag.keys"), QStringList() << "red" << "blue");
+// QCOMPARE(evaluate<QStringList>(item, "keys"), QStringList() << "red" << "blue");
+ QCOMPARE(item->property("keys").toStringList(), QStringList() << "red" << "blue");
+}
+
+void tst_QQuickDrag::source()
+{
+
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "property Item source: Drag.source\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "Item { id: proxySource; objectName: \"proxySource\" }\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+
+ QCOMPARE(evaluate<QObject *>(item, "Drag.source"), static_cast<QObject *>(item));
+ QCOMPARE(evaluate<QObject *>(item, "source"), static_cast<QObject *>(item));
+
+ QQuickItem *proxySource = item->findChild<QQuickItem *>("proxySource");
+ QVERIFY(proxySource);
+
+ evaluate<void>(item, "Drag.source = proxySource");
+ QCOMPARE(evaluate<QObject *>(item, "Drag.source"), static_cast<QObject *>(proxySource));
+ QCOMPARE(evaluate<QObject *>(item, "source"), static_cast<QObject *>(proxySource));
+
+ evaluate<void>(item, "Drag.source = undefined");
+ QCOMPARE(evaluate<QObject *>(item, "Drag.source"), static_cast<QObject *>(item));
+ QCOMPARE(evaluate<QObject *>(item, "source"), static_cast<QObject *>(item));
+}
+
+class RecursingDropTarget : public TestDropTarget
+{
+public:
+ RecursingDropTarget(const QString &script, int type, QQuickItem *parent)
+ : TestDropTarget(parent), script(script), type(type), item(0) {}
+
+ void setItem(QQuickItem *i) { item = i; }
+
+protected:
+ void dragEnterEvent(QDragEnterEvent *event)
+ {
+ TestDropTarget::dragEnterEvent(event);
+ if (type == QEvent::DragEnter && enterEvents < 2)
+ evaluate<void>(item, script);
+ }
+
+ void dragMoveEvent(QDragMoveEvent *event)
+ {
+ TestDropTarget::dragMoveEvent(event);
+ if (type == QEvent::DragMove && moveEvents < 2)
+ evaluate<void>(item, script);
+ }
+
+ void dragLeaveEvent(QDragLeaveEvent *event)
+ {
+ TestDropTarget::dragLeaveEvent(event);
+ if (type == QEvent::DragLeave && leaveEvents < 2)
+ evaluate<void>(item, script);
+ }
+
+ void dropEvent(QDropEvent *event)
+ {
+ TestDropTarget::dropEvent(event);
+ if (type == QEvent::Drop && dropEvents < 2)
+ evaluate<void>(item, script);
+ }
+
+private:
+ QString script;
+ int type;
+ QQuickItem *item;
+
+};
+
+void tst_QQuickDrag::recursion_data()
+{
+ QTest::addColumn<QString>("script");
+ QTest::addColumn<int>("type");
+ QTest::addColumn<QByteArray>("warning");
+
+ QTest::newRow("Drag.start() in Enter")
+ << QString("Drag.start()")
+ << int(QEvent::DragEnter)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.cancel() in Enter")
+ << QString("Drag.cancel()")
+ << int(QEvent::DragEnter)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.drop() in Enter")
+ << QString("Drag.drop()")
+ << int(QEvent::DragEnter)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.active = true in Enter")
+ << QString("Drag.active = true")
+ << int(QEvent::DragEnter)
+ << QByteArray();
+ QTest::newRow("Drag.active = false in Enter")
+ << QString("Drag.active = false")
+ << int(QEvent::DragEnter)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
+ QTest::newRow("move in Enter")
+ << QString("x = 23")
+ << int(QEvent::DragEnter)
+ << QByteArray();
+
+ QTest::newRow("Drag.start() in Move")
+ << QString("Drag.start()")
+ << int(QEvent::DragMove)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.cancel() in Move")
+ << QString("Drag.cancel()")
+ << int(QEvent::DragMove)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.drop() in Move")
+ << QString("Drag.drop()")
+ << int(QEvent::DragMove)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.active = true in Move")
+ << QString("Drag.active = true")
+ << int(QEvent::DragMove)
+ << QByteArray();
+ QTest::newRow("Drag.active = false in Move")
+ << QString("Drag.active = false")
+ << int(QEvent::DragMove)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
+ QTest::newRow("move in Move")
+ << QString("x = 23")
+ << int(QEvent::DragMove)
+ << QByteArray();
+
+ QTest::newRow("Drag.start() in Leave")
+ << QString("Drag.start()")
+ << int(QEvent::DragLeave)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.cancel() in Leave")
+ << QString("Drag.cancel()")
+ << int(QEvent::DragLeave)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.drop() in Leave")
+ << QString("Drag.drop()")
+ << int(QEvent::DragLeave)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.active = true in Leave")
+ << QString("Drag.active = true")
+ << int(QEvent::DragLeave)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
+ QTest::newRow("Drag.active = false in Leave")
+ << QString("Drag.active = false")
+ << int(QEvent::DragLeave)
+ << QByteArray();
+ QTest::newRow("move in Leave")
+ << QString("x = 23")
+ << int(QEvent::DragLeave)
+ << QByteArray();
+
+ QTest::newRow("Drag.start() in Drop")
+ << QString("Drag.start()")
+ << int(QEvent::Drop)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: start() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.cancel() in Drop")
+ << QString("Drag.cancel()")
+ << int(QEvent::Drop)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: cancel() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.drop() in Drop")
+ << QString("Drag.drop()")
+ << int(QEvent::Drop)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: drop() cannot be called from within a drag event handler");
+ QTest::newRow("Drag.active = true in Drop")
+ << QString("Drag.active = true")
+ << int(QEvent::Drop)
+ << QByteArray("<Unknown File>: QML QQuickDragAttached: active cannot be changed from within a drag event handler");
+ QTest::newRow("Drag.active = false in Drop")
+ << QString("Drag.active = false")
+ << int(QEvent::Drop)
+ << QByteArray();
+ QTest::newRow("move in Drop")
+ << QString("x = 23")
+ << int(QEvent::Drop)
+ << QByteArray();
+}
+
+void tst_QQuickDrag::recursion()
+{
+ QFETCH(QString, script);
+ QFETCH(int, type);
+ QFETCH(QByteArray, warning);
+
+ if (!warning.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, warning.constData());
+
+ QQuickCanvas canvas;
+ RecursingDropTarget dropTarget(script, type, canvas.rootItem());
+ dropTarget.setSize(QSizeF(100, 100));
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "Item {\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+ item->setParentItem(canvas.rootItem());
+
+ dropTarget.setItem(item);
+
+ evaluate<void>(item, "Drag.start()");
+ QCOMPARE(dropTarget.enterEvents, 1);
+ QCOMPARE(dropTarget.moveEvents, 0);
+ QCOMPARE(dropTarget.dropEvents, 0);
+ QCOMPARE(dropTarget.leaveEvents, 0);
+
+ evaluate<void>(item, "y = 15");
+ QCOMPARE(dropTarget.enterEvents, 1);
+ QCOMPARE(dropTarget.moveEvents, 1);
+ QCOMPARE(dropTarget.dropEvents, 0);
+ QCOMPARE(dropTarget.leaveEvents, 0);
+
+ if (type == QEvent::Drop) {
+ QCOMPARE(evaluate<bool>(item, "Drag.drop() == Qt.MoveAction"), true);
+ QCOMPARE(dropTarget.enterEvents, 1);
+ QCOMPARE(dropTarget.moveEvents, 1);
+ QCOMPARE(dropTarget.dropEvents, 1);
+ QCOMPARE(dropTarget.leaveEvents, 0);
+ } else {
+ evaluate<void>(item, "Drag.cancel()");
+ QCOMPARE(dropTarget.enterEvents, 1);
+ QCOMPARE(dropTarget.moveEvents, 1);
+ QCOMPARE(dropTarget.dropEvents, 0);
+ QCOMPARE(dropTarget.leaveEvents, 1);
+ }
+}
+
+
+QTEST_MAIN(tst_QQuickDrag)
+
+#include "tst_qquickdrag.moc"
diff --git a/tests/auto/quick/qquickdroparea/qquickdroparea.pro b/tests/auto/quick/qquickdroparea/qquickdroparea.pro
new file mode 100644
index 0000000000..5ae8d222c4
--- /dev/null
+++ b/tests/auto/quick/qquickdroparea/qquickdroparea.pro
@@ -0,0 +1,9 @@
+TARGET = tst_qquickdroparea
+CONFIG += testcase
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickdroparea.cpp
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp
new file mode 100644
index 0000000000..ed7a0aa0fa
--- /dev/null
+++ b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp
@@ -0,0 +1,1117 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlexpression.h>
+
+#include <QtGui/qwindowsysteminterface_qpa.h>
+
+template <typename T> static T evaluate(QObject *scope, const QString &expression)
+{
+ QQmlExpression expr(qmlContext(scope), scope, expression);
+ QVariant result = expr.evaluate();
+ if (expr.hasError())
+ qWarning() << expr.error().toString();
+ return result.value<T>();
+}
+
+template <> void evaluate<void>(QObject *scope, const QString &expression)
+{
+ QQmlExpression expr(qmlContext(scope), scope, expression);
+ expr.evaluate();
+ if (expr.hasError())
+ qWarning() << expr.error().toString();
+}
+
+class tst_QQuickDropArea: public QObject
+{
+ Q_OBJECT
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void containsDrag_internal();
+ void containsDrag_external();
+ void keys_internal();
+ void keys_external();
+ void source_internal();
+// void source_external();
+ void position_internal();
+ void position_external();
+ void drop_internal();
+// void drop_external();
+ void simultaneousDrags();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_QQuickDropArea::initTestCase()
+{
+
+}
+
+void tst_QQuickDropArea::cleanupTestCase()
+{
+
+}
+
+void tst_QQuickDropArea::containsDrag_internal()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property bool hasDrag: containsDrag\n"
+ "property int enterEvents: 0\n"
+ "property int exitEvents: 0\n"
+ "width: 100; height: 100\n"
+ "onEntered: {++enterEvents}\n"
+ "onExited: {++exitEvents}\n"
+ "Item {\n"
+ "objectName: \"dragItem\"\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(dropArea);
+ dropArea->setParentItem(canvas.rootItem());
+
+ QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
+ QVERIFY(dragItem);
+
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
+
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
+
+ dragItem->setPos(QPointF(150, 50));
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
+
+ dragItem->setPos(QPointF(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
+ dragItem->setPos(QPointF(150, 50));
+
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
+
+ evaluate<void>(dragItem, "Drag.active = false");
+}
+
+void tst_QQuickDropArea::containsDrag_external()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property bool hasDrag: containsDrag\n"
+ "property int enterEvents: 0\n"
+ "property int exitEvents: 0\n"
+ "width: 100; height: 100\n"
+ "onEntered: {++enterEvents}\n"
+ "onExited: {++exitEvents}\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(dropArea);
+ dropArea->setParentItem(canvas.rootItem());
+
+ QMimeData data;
+ QQuickCanvas alternateCanvas;
+
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
+
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
+
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50));
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
+
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 0);
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; exitEvents = 0 }");
+
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(150, 50));
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<bool>(dropArea, "hasDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "exitEvents"), 1);
+
+ QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(150, 50));
+}
+
+void tst_QQuickDropArea::keys_internal()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property variant dragKeys\n"
+ "property variant dropKeys: keys\n"
+ "property int enterEvents: 0\n"
+ "width: 100; height: 100\n"
+ "onEntered: {++enterEvents; dragKeys = drag.keys }\n"
+ "Item {\n"
+ "objectName: \"dragItem\"\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "Drag.keys: [\"red\", \"blue\"]\n"
+ "}\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(dropArea);
+ dropArea->setParentItem(canvas.rootItem());
+
+ QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
+ QVERIFY(dragItem);
+
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ evaluate<void>(dropArea, "keys = \"blue\"");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "blue");
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "blue");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ evaluate<void>(dropArea, "keys = \"red\"");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "red");
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "red");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ evaluate<void>(dropArea, "keys = \"green\"");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "green");
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "green");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ evaluate<void>(dropArea, "keys = [\"red\", \"green\"]");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "red" << "green");
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "red" << "green");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ evaluate<void>(dragItem, "Drag.keys = []");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ evaluate<void>(dropArea, "keys = []");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList());
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList());
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList());
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ evaluate<void>(dropArea, "keys = []");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList());
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ evaluate<void>(dragItem, "Drag.keys = [\"red\", \"blue\"]");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "red" << "blue");
+}
+
+void tst_QQuickDropArea::keys_external()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property variant dragKeys\n"
+ "property variant dropKeys: keys\n"
+ "property int enterEvents: 0\n"
+ "width: 100; height: 100\n"
+ "onEntered: {++enterEvents; dragKeys = drag.keys }\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
+ dropArea->setParentItem(canvas.rootItem());
+
+ QMimeData data;
+ QQuickCanvas alternateCanvas;
+
+ data.setData("text/x-red", "red");
+ data.setData("text/x-blue", "blue");
+
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ evaluate<void>(dropArea, "keys = \"text/x-blue\"");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-blue");
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-blue");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ evaluate<void>(dropArea, "keys = \"text/x-red\"");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red");
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ evaluate<void>(dropArea, "keys = \"text/x-green\"");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-green");
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-green");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ evaluate<void>(dropArea, "keys = [\"text/x-red\", \"text/x-green\"]");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList() << "text/x-red" << "text/x-green");
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList() << "text/x-red" << "text/x-green");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ data.removeFormat("text/x-red");
+ data.removeFormat("text/x-blue");
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ evaluate<void>(dropArea, "keys = []");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList());
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList());
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList());
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ data.setData("text/x-red", "red");
+ data.setData("text/x-blue", "blue");
+ QCOMPARE(dropArea->property("keys").toStringList(), QStringList());
+ QCOMPARE(dropArea->property("dropKeys").toStringList(), QStringList());
+ evaluate<void>(dropArea, "{ enterEvents = 0; dragKeys = undefined }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(dropArea->property("dragKeys").toStringList(), QStringList() << "text/x-red" << "text/x-blue");
+
+ QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(50, 50));
+}
+
+void tst_QQuickDropArea::source_internal()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property Item source: drag.source\n"
+ "property Item eventSource\n"
+ "width: 100; height: 100\n"
+ "onEntered: {eventSource = drag.source}\n"
+ "Item {\n"
+ "objectName: \"dragItem\"\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}\n"
+ "Item { id: dragSource; objectName: \"dragSource\" }\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(dropArea);
+ dropArea->setParentItem(canvas.rootItem());
+
+ QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
+ QVERIFY(dragItem);
+
+ QQuickItem *dragSource = dropArea->findChild<QQuickItem *>("dragSource");
+ QVERIFY(dragSource);
+
+ QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(0));
+
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(dragItem));
+ QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(dragItem));
+ QCOMPARE(evaluate<QObject *>(dropArea, "eventSource"), static_cast<QObject *>(dragItem));
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(0));
+
+
+ evaluate<void>(dropArea, "{ eventSource = null }");
+ evaluate<void>(dragItem, "Drag.source = dragSource");
+
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(dragSource));
+ QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(dragSource));
+ QCOMPARE(evaluate<QObject *>(dropArea, "eventSource"), static_cast<QObject *>(dragSource));
+
+ evaluate<void>(dragItem, "Drag.active = false");
+ QCOMPARE(evaluate<QObject *>(dropArea, "source"), static_cast<QObject *>(0));
+ QCOMPARE(evaluate<QObject *>(dropArea, "drag.source"), static_cast<QObject *>(0));
+}
+
+// Setting a source can't be emulated using the QWindowSystemInterface API.
+
+//void tst_QQuickDropArea::source_external()
+//{
+//}
+
+void tst_QQuickDropArea::position_internal()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property real dragX: drag.x\n"
+ "property real dragY: drag.y\n"
+ "property real eventX\n"
+ "property real eventY\n"
+ "property int enterEvents: 0\n"
+ "property int moveEvents: 0\n"
+ "width: 100; height: 100\n"
+ "onEntered: {++enterEvents; eventX = drag.x; eventY = drag.y}\n"
+ "onPositionChanged: {++moveEvents; eventX = drag.x; eventY = drag.y}\n"
+ "Item {\n"
+ "objectName: \"dragItem\"\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(dropArea);
+ dropArea->setParentItem(canvas.rootItem());
+
+ QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
+ QVERIFY(dragItem);
+
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 0);
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
+ dragItem->setPos(QPointF(40, 50));
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(40));
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(40));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(40));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
+ dragItem->setPos(QPointF(75, 25));
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(75));
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(25));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(75));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(25));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(75));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(25));
+
+ evaluate<void>(dragItem, "Drag.active = false");
+}
+
+void tst_QQuickDropArea::position_external()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property real dragX: drag.x\n"
+ "property real dragY: drag.y\n"
+ "property real eventX\n"
+ "property real eventY\n"
+ "property int enterEvents: 0\n"
+ "property int moveEvents: 0\n"
+ "width: 100; height: 100\n"
+ "onEntered: {++enterEvents; eventX = drag.x; eventY = drag.y}\n"
+ "onPositionChanged: {++moveEvents; eventX = drag.x; eventY = drag.y}\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(dropArea);
+ dropArea->setParentItem(canvas.rootItem());
+
+ QMimeData data;
+
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(40, 50));
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(40));
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(40));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(50));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(40));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(50));
+
+ evaluate<void>(dropArea, "{ enterEvents = 0; moveEvents = 0; eventX = -1; eventY = -1 }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(75, 25));
+ QCOMPARE(evaluate<int>(dropArea, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea, "moveEvents"), 1);
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.x"), qreal(75));
+ QCOMPARE(evaluate<qreal>(dropArea, "drag.y"), qreal(25));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragX"), qreal(75));
+ QCOMPARE(evaluate<qreal>(dropArea, "dragY"), qreal(25));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventX"), qreal(75));
+ QCOMPARE(evaluate<qreal>(dropArea, "eventY"), qreal(25));
+
+ QWindowSystemInterface::handleDrop(&canvas, &data, QPoint(75, 25));
+}
+
+void tst_QQuickDropArea::drop_internal()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property bool accept: false\n"
+ "property bool setAccepted: false\n"
+ "property bool acceptDropAction: false\n"
+ "property bool setDropAction: false\n"
+ "property int dropAction: Qt.IgnoreAction\n"
+ "property int proposedAction: Qt.IgnoreAction\n"
+ "property int supportedActions: Qt.IgnoreAction\n"
+ "property int dropEvents: 0\n"
+ "width: 100; height: 100\n"
+ "onDropped: {\n"
+ "++dropEvents\n"
+ "supportedActions = drop.supportedActions\n"
+ "proposedAction = drop.action\n"
+ "if (setDropAction)\n"
+ "drop.action = dropAction\n"
+ "if (acceptDropAction)\n"
+ "drop.accept(dropAction)\n"
+ "else if (setAccepted)\n"
+ "drop.accepted = accept\n"
+ "else if (accept)\n"
+ "drop.accept()\n"
+ "}\n"
+ "Item {\n"
+ "objectName: \"dragItem\"\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "}\n"
+ "}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(dropArea);
+ dropArea->setParentItem(canvas.rootItem());
+
+ QQuickItem *dragItem = dropArea->findChild<QQuickItem *>("dragItem");
+ QVERIFY(dragItem);
+
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::IgnoreAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ accept = true; setDropAction = true; dropAction = Qt.LinkAction }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ setAccepted = true; }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ accept = false; setAccepted = true; }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::IgnoreAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ setAccepted = false; setDropAction = false; acceptDropAction = true; }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ acceptDropAction = false; dropAction = Qt.IgnoreAction; accept = true }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::MoveAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ setAccepted = true }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::MoveAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ setAccepted = false }");
+ evaluate<void>(dragItem, "Drag.supportedActions = Qt.LinkAction");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::MoveAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ setAccepted = true }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::MoveAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::MoveAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ setAccepted = false }");
+ evaluate<void>(dragItem, "Drag.proposedAction = Qt.LinkAction");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::LinkAction));
+
+ evaluate<void>(dropArea, "{ dropEvents = 0; proposedAction = Qt.IgnoreAction; supportedActions = Qt.IgnoreAction }");
+ evaluate<void>(dropArea, "{ setAccepted = true }");
+ evaluate<void>(dragItem, "Drag.active = true");
+ QCOMPARE(evaluate<int>(dragItem, "Drag.drop()"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "dropEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea, "supportedActions"), int(Qt::LinkAction));
+ QCOMPARE(evaluate<int>(dropArea, "proposedAction"), int(Qt::LinkAction));
+}
+
+// Setting the supportedActions can't be emulated using the QWindowSystemInterface API.
+
+//void tst_QQuickDropArea::drop_external()
+//{
+//}
+
+void tst_QQuickDropArea::simultaneousDrags()
+{
+ QQuickCanvas canvas;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQuick 2.0\n"
+ "DropArea {\n"
+ "property int enterEvents: 0\n"
+ "property int exitEvents: 0\n"
+ "width: 100; height: 100\n"
+ "keys: [\"red\", \"text/x-red\"]\n"
+ "onEntered: {++enterEvents}\n"
+ "onExited: {++exitEvents}\n"
+ "DropArea {\n"
+ "objectName: \"dropArea2\"\n"
+ "property int enterEvents: 0\n"
+ "property int exitEvents: 0\n"
+ "width: 100; height: 100\n"
+ "keys: [\"blue\", \"text/x-blue\"]\n"
+ "onEntered: {++enterEvents}\n"
+ "onExited: {++exitEvents}\n"
+ "}\n"
+ "Item {\n"
+ "objectName: \"dragItem1\"\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "Drag.keys: [\"red\", \"blue\"]"
+ "}\n"
+ "Item {\n"
+ "objectName: \"dragItem2\"\n"
+ "x: 50; y: 50\n"
+ "width: 10; height: 10\n"
+ "Drag.keys: [\"red\", \"blue\"]"
+ "}\n"
+ "}", QUrl());
+
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *dropArea1 = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(dropArea1);
+ dropArea1->setParentItem(canvas.rootItem());
+
+ QQuickItem *dropArea2 = dropArea1->findChild<QQuickItem *>("dropArea2");
+ QVERIFY(dropArea2);
+
+ QQuickItem *dragItem1 = dropArea1->findChild<QQuickItem *>("dragItem1");
+ QVERIFY(dragItem1);
+
+ QQuickItem *dragItem2 = dropArea1->findChild<QQuickItem *>("dragItem2");
+ QVERIFY(dragItem2);
+
+ QMimeData data;
+ data.setData("text/x-red", "red");
+ data.setData("text/x-blue", "blue");
+
+ QQuickCanvas alternateCanvas;
+
+ // Mixed internal drags.
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem1, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem2, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dragItem2, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dragItem2, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dragItem1, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem2, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ // internal then external.
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem1, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dragItem1, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ // external then internal.
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem2, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dragItem2, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dragItem2, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem2, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ // Different acceptance
+ evaluate<void>(dragItem1, "Drag.keys = \"red\"");
+ evaluate<void>(dragItem2, "Drag.keys = \"blue\"");
+ data.removeFormat("text/x-red");
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem1, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem2, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem2, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem2, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem1, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem2, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
+
+ // internal then external
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem1, "Drag.active = true");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ QWindowSystemInterface::handleDrag(&canvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 1);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dragItem1, "Drag.active = false");
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 1);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), true);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 0);
+
+ evaluate<void>(dropArea1, "{ enterEvents = 0; exitEvents = 0 }");
+ evaluate<void>(dropArea2, "{ enterEvents = 0; exitEvents = 0 }");
+ QWindowSystemInterface::handleDrag(&alternateCanvas, &data, QPoint(50, 50));
+ QCOMPARE(evaluate<bool>(dropArea1, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea1, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea1, "exitEvents"), 0);
+ QCOMPARE(evaluate<bool>(dropArea2, "containsDrag"), false);
+ QCOMPARE(evaluate<int>(dropArea2, "enterEvents"), 0);
+ QCOMPARE(evaluate<int>(dropArea2, "exitEvents"), 1);
+
+ QWindowSystemInterface::handleDrop(&alternateCanvas, &data, QPoint(50, 50));
+}
+
+QTEST_MAIN(tst_QQuickDropArea)
+
+#include "tst_qquickdroparea.moc"
diff --git a/tests/auto/qtquick2/qquickflickable/data/disabled.qml b/tests/auto/quick/qquickflickable/data/disabled.qml
index 9b679827c7..9b679827c7 100644
--- a/tests/auto/qtquick2/qquickflickable/data/disabled.qml
+++ b/tests/auto/quick/qquickflickable/data/disabled.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/flickable01.qml b/tests/auto/quick/qquickflickable/data/flickable01.qml
index cbec44bb4f..cbec44bb4f 100644
--- a/tests/auto/qtquick2/qquickflickable/data/flickable01.qml
+++ b/tests/auto/quick/qquickflickable/data/flickable01.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/flickable02.qml b/tests/auto/quick/qquickflickable/data/flickable02.qml
index 80caa32da5..80caa32da5 100644
--- a/tests/auto/qtquick2/qquickflickable/data/flickable02.qml
+++ b/tests/auto/quick/qquickflickable/data/flickable02.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/flickable03.qml b/tests/auto/quick/qquickflickable/data/flickable03.qml
index 719c682ee6..719c682ee6 100644
--- a/tests/auto/qtquick2/qquickflickable/data/flickable03.qml
+++ b/tests/auto/quick/qquickflickable/data/flickable03.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/flickable04.qml b/tests/auto/quick/qquickflickable/data/flickable04.qml
index b2f30b84ec..b2f30b84ec 100644
--- a/tests/auto/qtquick2/qquickflickable/data/flickable04.qml
+++ b/tests/auto/quick/qquickflickable/data/flickable04.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/flickableqgraphicswidget.qml b/tests/auto/quick/qquickflickable/data/flickableqgraphicswidget.qml
index bb8f1eefc6..bb8f1eefc6 100644
--- a/tests/auto/qtquick2/qquickflickable/data/flickableqgraphicswidget.qml
+++ b/tests/auto/quick/qquickflickable/data/flickableqgraphicswidget.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/margins.qml b/tests/auto/quick/qquickflickable/data/margins.qml
index 4866bd8301..4866bd8301 100644
--- a/tests/auto/qtquick2/qquickflickable/data/margins.qml
+++ b/tests/auto/quick/qquickflickable/data/margins.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/nestedPressDelay.qml b/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml
index 60dadcc73c..60dadcc73c 100644
--- a/tests/auto/qtquick2/qquickflickable/data/nestedPressDelay.qml
+++ b/tests/auto/quick/qquickflickable/data/nestedPressDelay.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/resize.qml b/tests/auto/quick/qquickflickable/data/resize.qml
index 1a9ef54107..1a9ef54107 100644
--- a/tests/auto/qtquick2/qquickflickable/data/resize.qml
+++ b/tests/auto/quick/qquickflickable/data/resize.qml
diff --git a/tests/auto/qtquick2/qquickflickable/data/wheel.qml b/tests/auto/quick/qquickflickable/data/wheel.qml
index 2928bbcd72..2928bbcd72 100644
--- a/tests/auto/qtquick2/qquickflickable/data/wheel.qml
+++ b/tests/auto/quick/qquickflickable/data/wheel.qml
diff --git a/tests/auto/quick/qquickflickable/qquickflickable.pro b/tests/auto/quick/qquickflickable/qquickflickable.pro
new file mode 100644
index 0000000000..0ca03b2497
--- /dev/null
+++ b/tests/auto/quick/qquickflickable/qquickflickable.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickflickable
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickflickable.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
new file mode 100644
index 0000000000..e46659e6d0
--- /dev/null
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -0,0 +1,663 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <private/qquickflickable_p.h>
+#include <private/qquickflickable_p_p.h>
+#include <private/qqmlvaluetype_p.h>
+#include <math.h>
+#include "../../shared/util.h"
+#include "../shared/viewtestutil.h"
+#include "../shared/visualtestutil.h"
+#include <QtOpenGL/QGLShaderProgram>
+
+using namespace QQuickViewTestUtil;
+using namespace QQuickVisualTestUtil;
+
+class tst_qquickflickable : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+
+private slots:
+ void create();
+ void horizontalViewportSize();
+ void verticalViewportSize();
+ void properties();
+ void boundsBehavior();
+ void maximumFlickVelocity();
+ void flickDeceleration();
+ void pressDelay();
+ void nestedPressDelay();
+ void flickableDirection();
+ void resizeContent();
+ void returnToBounds();
+ void wheel();
+ void movingAndDragging();
+ void disabled();
+ void flickVelocity();
+ void margins();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_qquickflickable::create()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("flickable01.qml"));
+ QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->isAtXBeginning(), true);
+ QCOMPARE(obj->isAtXEnd(), false);
+ QCOMPARE(obj->isAtYBeginning(), true);
+ QCOMPARE(obj->isAtYEnd(), false);
+ QCOMPARE(obj->contentX(), 0.);
+ QCOMPARE(obj->contentY(), 0.);
+
+ QCOMPARE(obj->horizontalVelocity(), 0.);
+ QCOMPARE(obj->verticalVelocity(), 0.);
+
+ QCOMPARE(obj->isInteractive(), true);
+ QCOMPARE(obj->boundsBehavior(), QQuickFlickable::DragAndOvershootBounds);
+ QCOMPARE(obj->pressDelay(), 0);
+ QCOMPARE(obj->maximumFlickVelocity(), 2500.);
+
+ delete obj;
+}
+
+void tst_qquickflickable::horizontalViewportSize()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("flickable02.qml"));
+ QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->contentWidth(), 800.);
+ QCOMPARE(obj->contentHeight(), 300.);
+ QCOMPARE(obj->isAtXBeginning(), true);
+ QCOMPARE(obj->isAtXEnd(), false);
+ QCOMPARE(obj->isAtYBeginning(), true);
+ QCOMPARE(obj->isAtYEnd(), false);
+
+ delete obj;
+}
+
+void tst_qquickflickable::verticalViewportSize()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("flickable03.qml"));
+ QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->contentWidth(), 200.);
+ QCOMPARE(obj->contentHeight(), 6000.);
+ QCOMPARE(obj->isAtXBeginning(), true);
+ QCOMPARE(obj->isAtXEnd(), false);
+ QCOMPARE(obj->isAtYBeginning(), true);
+ QCOMPARE(obj->isAtYEnd(), false);
+
+ delete obj;
+}
+
+void tst_qquickflickable::properties()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("flickable04.qml"));
+ QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->isInteractive(), false);
+ QCOMPARE(obj->boundsBehavior(), QQuickFlickable::StopAtBounds);
+ QCOMPARE(obj->pressDelay(), 200);
+ QCOMPARE(obj->maximumFlickVelocity(), 2000.);
+
+ QVERIFY(obj->property("ok").toBool() == false);
+ QMetaObject::invokeMethod(obj, "check");
+ QVERIFY(obj->property("ok").toBool() == true);
+
+ delete obj;
+}
+
+void tst_qquickflickable::boundsBehavior()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Flickable { boundsBehavior: Flickable.StopAtBounds }", QUrl::fromLocalFile(""));
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(boundsBehaviorChanged()));
+
+ QVERIFY(flickable);
+ QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds);
+
+ flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
+ QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragAndOvershootBounds);
+ QCOMPARE(spy.count(),1);
+ flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
+ QCOMPARE(spy.count(),1);
+
+ flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds);
+ QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragOverBounds);
+ QCOMPARE(spy.count(),2);
+ flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds);
+ QCOMPARE(spy.count(),2);
+
+ flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds);
+ QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds);
+ QCOMPARE(spy.count(),3);
+ flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds);
+ QCOMPARE(spy.count(),3);
+}
+
+void tst_qquickflickable::maximumFlickVelocity()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile(""));
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged()));
+
+ QVERIFY(flickable);
+ QCOMPARE(flickable->maximumFlickVelocity(), 1.0);
+
+ flickable->setMaximumFlickVelocity(2.0);
+ QCOMPARE(flickable->maximumFlickVelocity(), 2.0);
+ QCOMPARE(spy.count(),1);
+ flickable->setMaximumFlickVelocity(2.0);
+ QCOMPARE(spy.count(),1);
+}
+
+void tst_qquickflickable::flickDeceleration()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile(""));
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged()));
+
+ QVERIFY(flickable);
+ QCOMPARE(flickable->flickDeceleration(), 1.0);
+
+ flickable->setFlickDeceleration(2.0);
+ QCOMPARE(flickable->flickDeceleration(), 2.0);
+ QCOMPARE(spy.count(),1);
+ flickable->setFlickDeceleration(2.0);
+ QCOMPARE(spy.count(),1);
+}
+
+void tst_qquickflickable::pressDelay()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Flickable { pressDelay: 100; }", QUrl::fromLocalFile(""));
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(pressDelayChanged()));
+
+ QVERIFY(flickable);
+ QCOMPARE(flickable->pressDelay(), 100);
+
+ flickable->setPressDelay(200);
+ QCOMPARE(flickable->pressDelay(), 200);
+ QCOMPARE(spy.count(),1);
+ flickable->setPressDelay(200);
+ QCOMPARE(spy.count(),1);
+}
+
+// QTBUG-17361
+void tst_qquickflickable::nestedPressDelay()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("nestedPressDelay.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(canvas->rootObject());
+ QVERIFY(outer != 0);
+
+ QQuickFlickable *inner = canvas->rootObject()->findChild<QQuickFlickable*>("innerFlickable");
+ QVERIFY(inner != 0);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(150, 150));
+ // the MouseArea is not pressed immediately
+ QVERIFY(outer->property("pressed").toBool() == false);
+
+ // The outer pressDelay will prevail (50ms, vs. 10sec)
+ // QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec.
+ QTRY_VERIFY(outer->property("pressed").toBool() == true);
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(150, 150));
+
+ delete canvas;
+}
+
+void tst_qquickflickable::flickableDirection()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Flickable { flickableDirection: Flickable.VerticalFlick; }", QUrl::fromLocalFile(""));
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
+ QSignalSpy spy(flickable, SIGNAL(flickableDirectionChanged()));
+
+ QVERIFY(flickable);
+ QCOMPARE(flickable->flickableDirection(), QQuickFlickable::VerticalFlick);
+
+ flickable->setFlickableDirection(QQuickFlickable::HorizontalAndVerticalFlick);
+ QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalAndVerticalFlick);
+ QCOMPARE(spy.count(),1);
+
+ flickable->setFlickableDirection(QQuickFlickable::AutoFlickDirection);
+ QCOMPARE(flickable->flickableDirection(), QQuickFlickable::AutoFlickDirection);
+ QCOMPARE(spy.count(),2);
+
+ flickable->setFlickableDirection(QQuickFlickable::HorizontalFlick);
+ QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalFlick);
+ QCOMPARE(spy.count(),3);
+
+ flickable->setFlickableDirection(QQuickFlickable::HorizontalFlick);
+ QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalFlick);
+ QCOMPARE(spy.count(),3);
+}
+
+// QtQuick 1.1
+void tst_qquickflickable::resizeContent()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("resize.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
+ QQuickFlickable *obj = findItem<QQuickFlickable>(root, "flick");
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->contentX(), 0.);
+ QCOMPARE(obj->contentY(), 0.);
+ QCOMPARE(obj->contentWidth(), 300.);
+ QCOMPARE(obj->contentHeight(), 300.);
+
+ QMetaObject::invokeMethod(root, "resizeContent");
+
+ QCOMPARE(obj->contentX(), 100.);
+ QCOMPARE(obj->contentY(), 100.);
+ QCOMPARE(obj->contentWidth(), 600.);
+ QCOMPARE(obj->contentHeight(), 600.);
+
+ delete root;
+}
+
+// QtQuick 1.1
+void tst_qquickflickable::returnToBounds()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("resize.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
+ QQuickFlickable *obj = findItem<QQuickFlickable>(root, "flick");
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->contentX(), 0.);
+ QCOMPARE(obj->contentY(), 0.);
+ QCOMPARE(obj->contentWidth(), 300.);
+ QCOMPARE(obj->contentHeight(), 300.);
+
+ obj->setContentX(100);
+ obj->setContentY(400);
+ QTRY_COMPARE(obj->contentX(), 100.);
+ QTRY_COMPARE(obj->contentY(), 400.);
+
+ QMetaObject::invokeMethod(root, "returnToBounds");
+
+ QTRY_COMPARE(obj->contentX(), 0.);
+ QTRY_COMPARE(obj->contentY(), 0.);
+
+ delete root;
+}
+
+void tst_qquickflickable::wheel()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("wheel.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlickable *flick = canvas->rootObject()->findChild<QQuickFlickable*>("flick");
+ QVERIFY(flick != 0);
+
+ {
+ QWheelEvent event(QPoint(200, 200), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical);
+ event.setAccepted(false);
+ QGuiApplication::sendEvent(canvas, &event);
+ }
+
+ QTRY_VERIFY(flick->contentY() > 0);
+ QVERIFY(flick->contentX() == 0);
+
+ flick->setContentY(0);
+ QVERIFY(flick->contentY() == 0);
+
+ {
+ QWheelEvent event(QPoint(200, 200), -120, Qt::NoButton, Qt::NoModifier, Qt::Horizontal);
+ event.setAccepted(false);
+ QGuiApplication::sendEvent(canvas, &event);
+ }
+
+ QTRY_VERIFY(flick->contentX() > 0);
+ QVERIFY(flick->contentY() == 0);
+
+ delete canvas;
+}
+
+void tst_qquickflickable::movingAndDragging()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("flickable03.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(canvas->rootObject());
+ QVERIFY(flickable != 0);
+
+ QSignalSpy vDragSpy(flickable, SIGNAL(draggingVerticallyChanged()));
+ QSignalSpy hDragSpy(flickable, SIGNAL(draggingHorizontallyChanged()));
+ QSignalSpy dragSpy(flickable, SIGNAL(draggingChanged()));
+ QSignalSpy vMoveSpy(flickable, SIGNAL(movingVerticallyChanged()));
+ QSignalSpy hMoveSpy(flickable, SIGNAL(movingHorizontallyChanged()));
+ QSignalSpy moveSpy(flickable, SIGNAL(movingChanged()));
+ QSignalSpy dragStartSpy(flickable, SIGNAL(dragStarted()));
+ QSignalSpy dragEndSpy(flickable, SIGNAL(dragEnded()));
+
+ //Vertical
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90));
+
+ QTest::mouseMove(canvas, QPoint(50, 80));
+ QTest::mouseMove(canvas, QPoint(50, 70));
+ QTest::mouseMove(canvas, QPoint(50, 60));
+
+ QMouseEvent moveEvent(QEvent::MouseMove, QPoint(50, 80), Qt::LeftButton, Qt::LeftButton, 0);
+
+ QVERIFY(!flickable->isDraggingHorizontally());
+ QVERIFY(flickable->isDraggingVertically());
+ QVERIFY(flickable->isDragging());
+ QCOMPARE(vDragSpy.count(), 1);
+ QCOMPARE(dragSpy.count(), 1);
+ QCOMPARE(hDragSpy.count(), 0);
+ QCOMPARE(dragStartSpy.count(), 1);
+ QCOMPARE(dragEndSpy.count(), 0);
+
+ QVERIFY(!flickable->isMovingHorizontally());
+ QVERIFY(flickable->isMovingVertically());
+ QVERIFY(flickable->isMoving());
+ QCOMPARE(vMoveSpy.count(), 1);
+ QCOMPARE(moveSpy.count(), 1);
+ QCOMPARE(hMoveSpy.count(), 0);
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 60));
+
+ QTRY_VERIFY(!flickable->isDraggingVertically());
+ QVERIFY(!flickable->isDragging());
+ QCOMPARE(vDragSpy.count(), 2);
+ QCOMPARE(dragSpy.count(), 2);
+ QCOMPARE(hDragSpy.count(), 0);
+ QCOMPARE(dragStartSpy.count(), 1);
+ QCOMPARE(dragEndSpy.count(), 1);
+
+ // wait for any motion to end
+ QTRY_VERIFY(flickable->isMoving() == false);
+
+ //Horizontal
+ vDragSpy.clear();
+ hDragSpy.clear();
+ dragSpy.clear();
+ vMoveSpy.clear();
+ hMoveSpy.clear();
+ moveSpy.clear();
+ dragStartSpy.clear();
+ dragEndSpy.clear();
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(90, 50));
+
+ QTest::mouseMove(canvas, QPoint(80, 50));
+ QTest::mouseMove(canvas, QPoint(70, 50));
+ QTest::mouseMove(canvas, QPoint(60, 50));
+
+ QVERIFY(!flickable->isDraggingVertically());
+ QVERIFY(flickable->isDraggingHorizontally());
+ QVERIFY(flickable->isDragging());
+ QCOMPARE(vDragSpy.count(), 0);
+ QCOMPARE(dragSpy.count(), 1);
+ QCOMPARE(hDragSpy.count(), 1);
+ QCOMPARE(dragStartSpy.count(), 1);
+ QCOMPARE(dragEndSpy.count(), 0);
+
+ QVERIFY(!flickable->isMovingVertically());
+ QVERIFY(flickable->isMovingHorizontally());
+ QVERIFY(flickable->isMoving());
+ QCOMPARE(vMoveSpy.count(), 0);
+ QCOMPARE(moveSpy.count(), 1);
+ QCOMPARE(hMoveSpy.count(), 1);
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(60, 50));
+
+ QTRY_VERIFY(!flickable->isDraggingHorizontally());
+ QVERIFY(!flickable->isDragging());
+ QCOMPARE(vDragSpy.count(), 0);
+ QCOMPARE(dragSpy.count(), 2);
+ QCOMPARE(hDragSpy.count(), 2);
+ QCOMPARE(dragStartSpy.count(), 1);
+ QCOMPARE(dragEndSpy.count(), 1);
+ // Don't test moving because a flick could occur
+
+#ifdef Q_OS_MAC
+ QSKIP("Producing flicks on Mac CI impossible due to timing problems");
+#endif
+
+ QTRY_VERIFY(!flickable->isMoving());
+
+ vMoveSpy.clear();
+ hMoveSpy.clear();
+ moveSpy.clear();
+ QSignalSpy vFlickSpy(flickable, SIGNAL(flickingVerticallyChanged()));
+ QSignalSpy hFlickSpy(flickable, SIGNAL(flickingHorizontallyChanged()));
+ QSignalSpy flickSpy(flickable, SIGNAL(flickingChanged()));
+
+ // flick then press while it is still moving
+ // flicking == false, moving == true;
+ flick(canvas, QPoint(20,190), QPoint(20, 50), 200);
+ QVERIFY(flickable->verticalVelocity() > 0.0);
+ QVERIFY(flickable->isFlicking());
+ QVERIFY(flickable->isFlickingVertically());
+ QVERIFY(!flickable->isFlickingHorizontally());
+ QVERIFY(flickable->isMoving());
+ QVERIFY(flickable->isMovingVertically());
+ QVERIFY(!flickable->isMovingHorizontally());
+ QCOMPARE(vMoveSpy.count(), 1);
+ QCOMPARE(hMoveSpy.count(), 0);
+ QCOMPARE(moveSpy.count(), 1);
+ QCOMPARE(vFlickSpy.count(), 1);
+ QCOMPARE(hFlickSpy.count(), 0);
+ QCOMPARE(flickSpy.count(), 1);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(20, 50));
+ QTRY_VERIFY(!flickable->isFlicking());
+ QVERIFY(!flickable->isFlickingVertically());
+ QVERIFY(flickable->isMoving());
+ QVERIFY(flickable->isMovingVertically());
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(20,50));
+ QVERIFY(!flickable->isFlicking());
+ QVERIFY(!flickable->isFlickingVertically());
+ QTRY_VERIFY(!flickable->isMoving());
+ QVERIFY(!flickable->isMovingVertically());
+
+ delete canvas;
+}
+
+void tst_qquickflickable::disabled()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("disabled.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlickable *flick = canvas->rootObject()->findChild<QQuickFlickable*>("flickable");
+ QVERIFY(flick != 0);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90));
+
+ QTest::mouseMove(canvas, QPoint(50, 80));
+ QTest::mouseMove(canvas, QPoint(50, 70));
+ QTest::mouseMove(canvas, QPoint(50, 60));
+
+ QVERIFY(flick->isMoving() == false);
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 60));
+
+ // verify that mouse clicks on other elements still work (QTBUG-20584)
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 10));
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 10));
+
+ QTRY_VERIFY(canvas->rootObject()->property("clicked").toBool() == true);
+}
+
+void tst_qquickflickable::flickVelocity()
+{
+#ifdef Q_OS_MAC
+ QSKIP("Producing flicks on Mac CI impossible due to timing problems");
+#endif
+
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("flickable03.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(canvas->rootObject());
+ QVERIFY(flickable != 0);
+
+ // flick up
+ flick(canvas, QPoint(20,190), QPoint(20, 50), 200);
+ QVERIFY(flickable->verticalVelocity() > 0.0);
+ QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+
+ // flick down
+ flick(canvas, QPoint(20,10), QPoint(20, 140), 200);
+ QVERIFY(flickable->verticalVelocity() < 0.0);
+ QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
+
+ // Flick multiple times and verify that flick acceleration is applied.
+ QQuickFlickablePrivate *fp = QQuickFlickablePrivate::get(flickable);
+ bool boosted = false;
+ for (int i = 0; i < 6; ++i) {
+ flick(canvas, QPoint(20,390), QPoint(20, 50), 200);
+ boosted |= fp->flickBoost > 1.0;
+ }
+ QVERIFY(boosted);
+
+ // Flick in opposite direction -> boost cancelled.
+ flick(canvas, QPoint(20,10), QPoint(20, 340), 200);
+ QTRY_VERIFY(flickable->verticalVelocity() < 0.0);
+ QVERIFY(fp->flickBoost == 1.0);
+
+ delete canvas;
+}
+
+void tst_qquickflickable::margins()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("margins.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
+ QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(root);
+ QVERIFY(obj != 0);
+
+ // starting state
+ QCOMPARE(obj->contentX(), -40.);
+ QCOMPARE(obj->contentY(), -20.);
+ QCOMPARE(obj->contentWidth(), 1600.);
+ QCOMPARE(obj->contentHeight(), 600.);
+ QCOMPARE(obj->xOrigin(), 0.);
+ QCOMPARE(obj->yOrigin(), 0.);
+
+ // Reduce left margin
+ obj->setLeftMargin(30);
+ QTRY_COMPARE(obj->contentX(), -30.);
+
+ // Reduce top margin
+ obj->setTopMargin(20);
+ QTRY_COMPARE(obj->contentY(), -20.);
+
+ // position to the far right, including margin
+ obj->setContentX(1600 + 50 - obj->width());
+ obj->returnToBounds();
+ QTest::qWait(200);
+ QCOMPARE(obj->contentX(), 1600. + 50. - obj->width());
+
+ // position beyond the far right, including margin
+ obj->setContentX(1600 + 50 - obj->width() + 1.);
+ obj->returnToBounds();
+ QTRY_COMPARE(obj->contentX(), 1600. + 50. - obj->width());
+
+ // Reduce right margin
+ obj->setRightMargin(40);
+ QTRY_COMPARE(obj->contentX(), 1600. + 40. - obj->width());
+ QCOMPARE(obj->contentWidth(), 1600.);
+
+ // position to the far bottom, including margin
+ obj->setContentY(600 + 30 - obj->height());
+ obj->returnToBounds();
+ QTest::qWait(200);
+ QCOMPARE(obj->contentY(), 600. + 30. - obj->height());
+
+ // position beyond the far bottom, including margin
+ obj->setContentY(600 + 30 - obj->height() + 1.);
+ obj->returnToBounds();
+ QTRY_COMPARE(obj->contentY(), 600. + 30. - obj->height());
+
+ // Reduce bottom margin
+ obj->setBottomMargin(20);
+ QTRY_COMPARE(obj->contentY(), 600. + 20. - obj->height());
+ QCOMPARE(obj->contentHeight(), 600.);
+
+ delete root;
+}
+
+QTEST_MAIN(tst_qquickflickable)
+
+#include "tst_qquickflickable.moc"
diff --git a/tests/auto/qtquick2/qquickflipable/data/crash.qml b/tests/auto/quick/qquickflipable/data/crash.qml
index a0327918cb..a0327918cb 100644
--- a/tests/auto/qtquick2/qquickflipable/data/crash.qml
+++ b/tests/auto/quick/qquickflipable/data/crash.qml
diff --git a/tests/auto/qtquick2/qquickflipable/data/flipable-abort.qml b/tests/auto/quick/qquickflipable/data/flipable-abort.qml
index 90fc03a5f9..90fc03a5f9 100644
--- a/tests/auto/qtquick2/qquickflipable/data/flipable-abort.qml
+++ b/tests/auto/quick/qquickflipable/data/flipable-abort.qml
diff --git a/tests/auto/qtquick2/qquickflipable/data/test-flipable.qml b/tests/auto/quick/qquickflipable/data/test-flipable.qml
index dff6d3fe39..dff6d3fe39 100644
--- a/tests/auto/qtquick2/qquickflipable/data/test-flipable.qml
+++ b/tests/auto/quick/qquickflipable/data/test-flipable.qml
diff --git a/tests/auto/quick/qquickflipable/qquickflipable.pro b/tests/auto/quick/qquickflipable/qquickflipable.pro
new file mode 100644
index 0000000000..ca98cbe279
--- /dev/null
+++ b/tests/auto/quick/qquickflipable/qquickflipable.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickflipable
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickflipable.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp b/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp
new file mode 100644
index 0000000000..2f399359ef
--- /dev/null
+++ b/tests/auto/quick/qquickflipable/tst_qquickflipable.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <private/qquickflipable_p.h>
+#include <private/qqmlvaluetype_p.h>
+#include <QFontMetrics>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <math.h>
+#include <QtOpenGL/QGLShaderProgram>
+#include "../../shared/util.h"
+
+class tst_qquickflipable : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+
+private slots:
+ void create();
+ void checkFrontAndBack();
+ void setFrontAndBack();
+
+ // below here task issues
+ void QTBUG_9161_crash();
+ void QTBUG_8474_qgv_abort();
+
+private:
+ QQmlEngine engine;
+};
+
+void tst_qquickflipable::create()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-flipable.qml"));
+ QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
+
+ QVERIFY(obj != 0);
+ delete obj;
+}
+
+void tst_qquickflipable::checkFrontAndBack()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-flipable.qml"));
+ QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->front() != 0);
+ QVERIFY(obj->back() != 0);
+ delete obj;
+}
+
+void tst_qquickflipable::setFrontAndBack()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("test-flipable.qml"));
+ QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->front() != 0);
+ QVERIFY(obj->back() != 0);
+
+ QString message = c.url().toString() + ":3:1: QML Flipable: front is a write-once property";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ obj->setFront(new QQuickRectangle());
+
+ message = c.url().toString() + ":3:1: QML Flipable: back is a write-once property";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
+ obj->setBack(new QQuickRectangle());
+ delete obj;
+}
+
+void tst_qquickflipable::QTBUG_9161_crash()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("crash.qml"));
+ QQuickItem *root = canvas->rootObject();
+ QVERIFY(root != 0);
+ canvas->show();
+ delete canvas;
+}
+
+void tst_qquickflipable::QTBUG_8474_qgv_abort()
+{
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("flipable-abort.qml"));
+ QQuickItem *root = canvas->rootObject();
+ QVERIFY(root != 0);
+ canvas->show();
+ delete canvas;
+}
+
+QTEST_MAIN(tst_qquickflipable)
+
+#include "tst_qquickflipable.moc"
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/canvasFocus.qml b/tests/auto/quick/qquickfocusscope/data/canvasFocus.qml
index 7d8dac5a22..7d8dac5a22 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/canvasFocus.qml
+++ b/tests/auto/quick/qquickfocusscope/data/canvasFocus.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/chain.qml b/tests/auto/quick/qquickfocusscope/data/chain.qml
index 4b96662318..4b96662318 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/chain.qml
+++ b/tests/auto/quick/qquickfocusscope/data/chain.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/forceActiveFocus.qml b/tests/auto/quick/qquickfocusscope/data/forceActiveFocus.qml
index 74d2106888..74d2106888 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/forceActiveFocus.qml
+++ b/tests/auto/quick/qquickfocusscope/data/forceActiveFocus.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/forcefocus.qml b/tests/auto/quick/qquickfocusscope/data/forcefocus.qml
index f41582a951..f41582a951 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/forcefocus.qml
+++ b/tests/auto/quick/qquickfocusscope/data/forcefocus.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/qtBug13380.qml b/tests/auto/quick/qquickfocusscope/data/qtBug13380.qml
index 29de046b38..29de046b38 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/qtBug13380.qml
+++ b/tests/auto/quick/qquickfocusscope/data/qtBug13380.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/signalEmission.qml b/tests/auto/quick/qquickfocusscope/data/signalEmission.qml
index 999a40c5ad..999a40c5ad 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/signalEmission.qml
+++ b/tests/auto/quick/qquickfocusscope/data/signalEmission.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/test.qml b/tests/auto/quick/qquickfocusscope/data/test.qml
index 67be29c3fb..67be29c3fb 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/test.qml
+++ b/tests/auto/quick/qquickfocusscope/data/test.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/test2.qml b/tests/auto/quick/qquickfocusscope/data/test2.qml
index ad74f3e9f4..ad74f3e9f4 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/test2.qml
+++ b/tests/auto/quick/qquickfocusscope/data/test2.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/test3.qml b/tests/auto/quick/qquickfocusscope/data/test3.qml
index 537c30816e..537c30816e 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/test3.qml
+++ b/tests/auto/quick/qquickfocusscope/data/test3.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/test4.qml b/tests/auto/quick/qquickfocusscope/data/test4.qml
index 0eea649f5d..0eea649f5d 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/test4.qml
+++ b/tests/auto/quick/qquickfocusscope/data/test4.qml
diff --git a/tests/auto/qtquick2/qquickfocusscope/data/test5.qml b/tests/auto/quick/qquickfocusscope/data/test5.qml
index 9c37cd1303..9c37cd1303 100644
--- a/tests/auto/qtquick2/qquickfocusscope/data/test5.qml
+++ b/tests/auto/quick/qquickfocusscope/data/test5.qml
diff --git a/tests/auto/quick/qquickfocusscope/qquickfocusscope.pro b/tests/auto/quick/qquickfocusscope/qquickfocusscope.pro
new file mode 100644
index 0000000000..34de32b173
--- /dev/null
+++ b/tests/auto/quick/qquickfocusscope/qquickfocusscope.pro
@@ -0,0 +1,14 @@
+CONFIG += testcase
+TARGET = tst_qquickfocusscope
+SOURCES += tst_qquickfocusscope.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp b/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp
new file mode 100644
index 0000000000..3571392b17
--- /dev/null
+++ b/tests/auto/quick/qquickfocusscope/tst_qquickfocusscope.cpp
@@ -0,0 +1,636 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QSignalSpy>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <private/qquicktextedit_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuick/private/qquickfocusscope_p.h>
+#include "../../shared/util.h"
+#include "../shared/visualtestutil.h"
+
+using namespace QQuickVisualTestUtil;
+
+class tst_qquickfocusscope : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickfocusscope() {}
+
+private slots:
+ void basic();
+ void nested();
+ void noFocus();
+ void textEdit();
+ void forceFocus();
+ void noParentFocus();
+ void signalEmission();
+ void qtBug13380();
+ void forceActiveFocus();
+ void canvasFocus();
+};
+
+void tst_qquickfocusscope::basic()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("test.qml"));
+
+ QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0"));
+ QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
+ QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
+ QQuickRectangle *item3 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item3"));
+ QVERIFY(item0 != 0);
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+
+ view->show();
+ view->requestActivateWindow();
+
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+
+ QVERIFY(view->isTopLevel());
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Right);
+ QTest::qWait(50);
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == true);
+ QVERIFY(item3->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Down);
+ QTest::qWait(50);
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == true);
+
+ delete view;
+}
+
+void tst_qquickfocusscope::nested()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("test2.qml"));
+
+ QQuickFocusScope *item1 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item1"));
+ QQuickFocusScope *item2 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item2"));
+ QQuickFocusScope *item3 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item3"));
+ QQuickFocusScope *item4 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item4"));
+ QQuickFocusScope *item5 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item5"));
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+ QVERIFY(item4 != 0);
+ QVERIFY(item5 != 0);
+
+ view->show();
+ view->requestActivateWindow();
+
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == true);
+ QVERIFY(item3->hasActiveFocus() == true);
+ QVERIFY(item4->hasActiveFocus() == true);
+ QVERIFY(item5->hasActiveFocus() == true);
+ delete view;
+}
+
+void tst_qquickfocusscope::noFocus()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("test4.qml"));
+
+ QQuickRectangle *item0 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item0"));
+ QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
+ QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
+ QQuickRectangle *item3 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item3"));
+ QVERIFY(item0 != 0);
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+
+ view->show();
+ view->requestActivateWindow();
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Right);
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Down);
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+
+ delete view;
+}
+
+void tst_qquickfocusscope::textEdit()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("test5.qml"));
+
+ QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0"));
+ QQuickTextEdit *item1 = findItem<QQuickTextEdit>(view->rootObject(), QLatin1String("item1"));
+ QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
+ QQuickTextEdit *item3 = findItem<QQuickTextEdit>(view->rootObject(), QLatin1String("item3"));
+ QVERIFY(item0 != 0);
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+
+ view->show();
+ view->requestActivateWindow();
+
+ QTest::qWaitForWindowShown(view);
+
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Right);
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Right);
+ QTest::keyClick(view, Qt::Key_Right);
+ QTest::keyClick(view, Qt::Key_Right);
+ QTest::keyClick(view, Qt::Key_Right);
+ QTest::keyClick(view, Qt::Key_Right);
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == true);
+ QVERIFY(item3->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_Down);
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == true);
+
+ delete view;
+}
+
+void tst_qquickfocusscope::forceFocus()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("forcefocus.qml"));
+
+ QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0"));
+ QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
+ QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
+ QQuickFocusScope *item3 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item3"));
+ QQuickRectangle *item4 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item4"));
+ QQuickRectangle *item5 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item5"));
+ QVERIFY(item0 != 0);
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+ QVERIFY(item4 != 0);
+ QVERIFY(item5 != 0);
+
+ view->show();
+ view->requestActivateWindow();
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+ QVERIFY(item4->hasActiveFocus() == false);
+ QVERIFY(item5->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_4);
+ QVERIFY(item0->hasActiveFocus() == true);
+ QVERIFY(item1->hasActiveFocus() == true);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == false);
+ QVERIFY(item4->hasActiveFocus() == false);
+ QVERIFY(item5->hasActiveFocus() == false);
+
+ QTest::keyClick(view, Qt::Key_5);
+ QVERIFY(item0->hasActiveFocus() == false);
+ QVERIFY(item1->hasActiveFocus() == false);
+ QVERIFY(item2->hasActiveFocus() == false);
+ QVERIFY(item3->hasActiveFocus() == true);
+ QVERIFY(item4->hasActiveFocus() == false);
+ QVERIFY(item5->hasActiveFocus() == true);
+
+ delete view;
+}
+
+void tst_qquickfocusscope::noParentFocus()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("chain.qml"));
+ QVERIFY(view->rootObject());
+
+ view->show();
+ view->requestActivateWindow();
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+
+ QVERIFY(view->rootObject()->property("focus1") == false);
+ QVERIFY(view->rootObject()->property("focus2") == false);
+ QVERIFY(view->rootObject()->property("focus3") == true);
+ QVERIFY(view->rootObject()->property("focus4") == true);
+ QVERIFY(view->rootObject()->property("focus5") == true);
+
+ delete view;
+}
+
+void tst_qquickfocusscope::signalEmission()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("signalEmission.qml"));
+
+ QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
+ QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
+ QQuickRectangle *item3 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item3"));
+ QQuickRectangle *item4 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item4"));
+ QVERIFY(item1 != 0);
+ QVERIFY(item2 != 0);
+ QVERIFY(item3 != 0);
+ QVERIFY(item4 != 0);
+
+ view->show();
+ view->requestActivateWindow();
+
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+
+ QVariant blue(QColor("blue"));
+ QVariant red(QColor("red"));
+
+ item1->setFocus(true);
+ QCOMPARE(item1->property("color"), red);
+ QCOMPARE(item2->property("color"), blue);
+ QCOMPARE(item3->property("color"), blue);
+ QCOMPARE(item4->property("color"), blue);
+
+ item2->setFocus(true);
+ QCOMPARE(item1->property("color"), blue);
+ QCOMPARE(item2->property("color"), red);
+ QCOMPARE(item3->property("color"), blue);
+ QCOMPARE(item4->property("color"), blue);
+
+ item3->setFocus(true);
+ QCOMPARE(item1->property("color"), blue);
+ QCOMPARE(item2->property("color"), red);
+ QCOMPARE(item3->property("color"), red);
+ QCOMPARE(item4->property("color"), blue);
+
+ item4->setFocus(true);
+ QCOMPARE(item1->property("color"), blue);
+ QCOMPARE(item2->property("color"), red);
+ QCOMPARE(item3->property("color"), blue);
+ QCOMPARE(item4->property("color"), red);
+
+ item4->setFocus(false);
+ QCOMPARE(item1->property("color"), blue);
+ QCOMPARE(item2->property("color"), red);
+ QCOMPARE(item3->property("color"), blue);
+ QCOMPARE(item4->property("color"), blue);
+
+ delete view;
+}
+
+void tst_qquickfocusscope::qtBug13380()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("qtBug13380.qml"));
+
+ view->show();
+ QVERIFY(view->rootObject());
+ view->requestActivateWindow();
+ qApp->processEvents();
+
+ QTest::qWaitForWindowShown(view);
+
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+ QVERIFY(view->rootObject()->property("noFocus").toBool());
+
+ view->rootObject()->setProperty("showRect", true);
+ QVERIFY(view->rootObject()->property("noFocus").toBool());
+
+ delete view;
+}
+
+void tst_qquickfocusscope::forceActiveFocus()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("forceActiveFocus.qml"));
+
+ view->show();
+ view->requestActivateWindow();
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+
+ QQuickItem *rootObject = view->rootObject();
+ QVERIFY(rootObject);
+
+ QQuickItem *scope = findItem<QQuickItem>(rootObject, QLatin1String("scope"));
+ QQuickItem *itemA1 = findItem<QQuickItem>(rootObject, QLatin1String("item-a1"));
+ QQuickItem *scopeA = findItem<QQuickItem>(rootObject, QLatin1String("scope-a"));
+ QQuickItem *itemA2 = findItem<QQuickItem>(rootObject, QLatin1String("item-a2"));
+ QQuickItem *itemB1 = findItem<QQuickItem>(rootObject, QLatin1String("item-b1"));
+ QQuickItem *scopeB = findItem<QQuickItem>(rootObject, QLatin1String("scope-b"));
+ QQuickItem *itemB2 = findItem<QQuickItem>(rootObject, QLatin1String("item-b2"));
+
+ QVERIFY(scope);
+ QVERIFY(itemA1);
+ QVERIFY(scopeA);
+ QVERIFY(itemA2);
+ QVERIFY(itemB1);
+ QVERIFY(scopeB);
+ QVERIFY(itemB2);
+
+ QSignalSpy rootSpy(rootObject, SIGNAL(activeFocusChanged(bool)));
+ QSignalSpy scopeSpy(scope, SIGNAL(activeFocusChanged(bool)));
+ QSignalSpy scopeASpy(scopeA, SIGNAL(activeFocusChanged(bool)));
+ QSignalSpy scopeBSpy(scopeB, SIGNAL(activeFocusChanged(bool)));
+
+ // First, walk the focus from item-a1 down to item-a2 and back again
+ itemA1->forceActiveFocus();
+ QVERIFY(itemA1->hasActiveFocus());
+ QVERIFY(!rootObject->hasActiveFocus());
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ scopeA->forceActiveFocus();
+ QVERIFY(!itemA1->hasActiveFocus());
+ QVERIFY(scopeA->hasActiveFocus());
+ QCOMPARE(scopeASpy.count(), 1);
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ itemA2->forceActiveFocus();
+ QVERIFY(!itemA1->hasActiveFocus());
+ QVERIFY(itemA2->hasActiveFocus());
+ QVERIFY(scopeA->hasActiveFocus());
+ QCOMPARE(scopeASpy.count(), 1);
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ scopeA->forceActiveFocus();
+ QVERIFY(!itemA1->hasActiveFocus());
+ QVERIFY(itemA2->hasActiveFocus());
+ QVERIFY(scopeA->hasActiveFocus());
+ QCOMPARE(scopeASpy.count(), 1);
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ itemA1->forceActiveFocus();
+ QVERIFY(itemA1->hasActiveFocus());
+ QVERIFY(!scopeA->hasActiveFocus());
+ QVERIFY(!itemA2->hasActiveFocus());
+ QCOMPARE(scopeASpy.count(), 2);
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ // Then jump back and forth between branch 'a' and 'b'
+ itemB1->forceActiveFocus();
+ QVERIFY(itemB1->hasActiveFocus());
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ scopeA->forceActiveFocus();
+ QVERIFY(!itemA1->hasActiveFocus());
+ QVERIFY(!itemB1->hasActiveFocus());
+ QVERIFY(scopeA->hasActiveFocus());
+ QCOMPARE(scopeASpy.count(), 3);
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ scopeB->forceActiveFocus();
+ QVERIFY(!scopeA->hasActiveFocus());
+ QVERIFY(!itemB1->hasActiveFocus());
+ QVERIFY(scopeB->hasActiveFocus());
+ QCOMPARE(scopeASpy.count(), 4);
+ QCOMPARE(scopeBSpy.count(), 1);
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ itemA2->forceActiveFocus();
+ QVERIFY(!scopeB->hasActiveFocus());
+ QVERIFY(itemA2->hasActiveFocus());
+ QCOMPARE(scopeASpy.count(), 5);
+ QCOMPARE(scopeBSpy.count(), 2);
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ itemB2->forceActiveFocus();
+ QVERIFY(!itemA2->hasActiveFocus());
+ QVERIFY(itemB2->hasActiveFocus());
+ QCOMPARE(scopeASpy.count(), 6);
+ QCOMPARE(scopeBSpy.count(), 3);
+ QCOMPARE(rootSpy.count(), 0);
+ QCOMPARE(scopeSpy.count(), 1);
+
+ delete view;
+}
+
+void tst_qquickfocusscope::canvasFocus()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("canvasFocus.qml"));
+
+ QQuickView alternateView;
+
+ QQuickItem *rootObject = view->rootObject();
+ QVERIFY(rootObject);
+
+ QQuickItem *rootItem = view->rootItem();
+ QQuickItem *scope1 = findItem<QQuickItem>(rootObject, QLatin1String("scope1"));
+ QQuickItem *item1 = findItem<QQuickItem>(rootObject, QLatin1String("item1"));
+ QQuickItem *scope2 = findItem<QQuickItem>(rootObject, QLatin1String("scope2"));
+ QQuickItem *item2 = findItem<QQuickItem>(rootObject, QLatin1String("item2"));
+
+ QVERIFY(scope1);
+ QVERIFY(item1);
+ QVERIFY(scope2);
+ QVERIFY(item2);
+
+ QSignalSpy rootFocusSpy(rootItem, SIGNAL(focusChanged(bool)));
+ QSignalSpy scope1FocusSpy(scope1, SIGNAL(focusChanged(bool)));
+ QSignalSpy item1FocusSpy(item1, SIGNAL(focusChanged(bool)));
+ QSignalSpy scope2FocusSpy(scope2, SIGNAL(focusChanged(bool)));
+ QSignalSpy item2FocusSpy(item2, SIGNAL(focusChanged(bool)));
+ QSignalSpy rootActiveFocusSpy(rootItem, SIGNAL(activeFocusChanged(bool)));
+ QSignalSpy scope1ActiveFocusSpy(scope1, SIGNAL(activeFocusChanged(bool)));
+ QSignalSpy item1ActiveFocusSpy(item1, SIGNAL(activeFocusChanged(bool)));
+ QSignalSpy scope2ActiveFocusSpy(scope2, SIGNAL(activeFocusChanged(bool)));
+ QSignalSpy item2ActiveFocusSpy(item2, SIGNAL(activeFocusChanged(bool)));
+
+ QEXPECT_FAIL("", "QTBUG-22415", Abort);
+ QCOMPARE(rootItem->hasFocus(), false);
+ QCOMPARE(rootItem->hasActiveFocus(), false);
+ QCOMPARE(scope1->hasFocus(), true);
+ QCOMPARE(scope1->hasActiveFocus(), false);
+ QCOMPARE(item1->hasFocus(), true);
+ QCOMPARE(item1->hasActiveFocus(), false);
+ QCOMPARE(scope2->hasFocus(), false);
+ QCOMPARE(scope2->hasActiveFocus(), false);
+ QCOMPARE(item2->hasFocus(), false);
+ QCOMPARE(item2->hasActiveFocus(), false);
+
+ view->show();
+ view->requestActivateWindow();
+
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(view == qGuiApp->focusWindow());
+
+ // Now the canvas has focus, active focus given to item1
+ QCOMPARE(rootItem->hasFocus(), true);
+ QCOMPARE(rootItem->hasActiveFocus(), true);
+ QCOMPARE(scope1->hasFocus(), true);
+ QCOMPARE(scope1->hasActiveFocus(), true);
+ QCOMPARE(item1->hasFocus(), true);
+ QCOMPARE(item1->hasActiveFocus(), true);
+ QCOMPARE(scope2->hasFocus(), false);
+ QCOMPARE(scope2->hasActiveFocus(), false);
+ QCOMPARE(item2->hasFocus(), false);
+ QCOMPARE(item2->hasActiveFocus(), false);
+
+ QCOMPARE(rootFocusSpy.count(), 1);
+ QCOMPARE(rootActiveFocusSpy.count(), 1);
+ QCOMPARE(scope1FocusSpy.count(), 0);
+ QCOMPARE(scope1ActiveFocusSpy.count(), 1);
+ QCOMPARE(item1FocusSpy.count(), 0);
+ QCOMPARE(item1ActiveFocusSpy.count(), 1);
+
+
+ // view->hide(); // seemingly doesn't remove focus, so have an another view steal it.
+ alternateView.show();
+ alternateView.requestActivateWindow();
+ QTest::qWaitForWindowShown(&alternateView);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &alternateView);
+
+ QCOMPARE(rootItem->hasFocus(), false);
+ QCOMPARE(rootItem->hasActiveFocus(), false);
+ QCOMPARE(scope1->hasFocus(), true);
+ QCOMPARE(scope1->hasActiveFocus(), false);
+ QCOMPARE(item1->hasFocus(), true);
+ QCOMPARE(item1->hasActiveFocus(), false);
+
+ QCOMPARE(rootFocusSpy.count(), 2);
+ QCOMPARE(rootActiveFocusSpy.count(), 2);
+ QCOMPARE(scope1FocusSpy.count(), 0);
+ QCOMPARE(scope1ActiveFocusSpy.count(), 2);
+ QCOMPARE(item1FocusSpy.count(), 0);
+ QCOMPARE(item1ActiveFocusSpy.count(), 2);
+
+
+ // canvas does not have focus, so item2 will not get active focus
+ item2->forceActiveFocus();
+
+ QCOMPARE(rootItem->hasFocus(), false);
+ QCOMPARE(rootItem->hasActiveFocus(), false);
+ QCOMPARE(scope1->hasFocus(), false);
+ QCOMPARE(scope1->hasActiveFocus(), false);
+ QCOMPARE(item1->hasFocus(), true);
+ QCOMPARE(item1->hasActiveFocus(), false);
+ QCOMPARE(scope2->hasFocus(), true);
+ QCOMPARE(scope2->hasActiveFocus(), false);
+ QCOMPARE(item2->hasFocus(), true);
+ QCOMPARE(item2->hasActiveFocus(), false);
+
+ QCOMPARE(rootFocusSpy.count(), 2);
+ QCOMPARE(rootActiveFocusSpy.count(), 2);
+ QCOMPARE(scope1FocusSpy.count(), 1);
+ QCOMPARE(scope1ActiveFocusSpy.count(), 2);
+ QCOMPARE(item1FocusSpy.count(), 0);
+ QCOMPARE(item1ActiveFocusSpy.count(), 2);
+ QCOMPARE(scope2FocusSpy.count(), 1);
+ QCOMPARE(scope2ActiveFocusSpy.count(), 0);
+ QCOMPARE(item2FocusSpy.count(), 1);
+ QCOMPARE(item2ActiveFocusSpy.count(), 0);
+
+ // give the canvas focus, and item2 will get active focus
+ view->show();
+ view->requestActivateWindow();
+ QTest::qWaitForWindowShown(view);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == view);
+
+ QCOMPARE(rootItem->hasFocus(), true);
+ QCOMPARE(rootItem->hasActiveFocus(), true);
+ QCOMPARE(scope2->hasFocus(), true);
+ QCOMPARE(scope2->hasActiveFocus(), true);
+ QCOMPARE(item2->hasFocus(), true);
+ QCOMPARE(item2->hasActiveFocus(), true);
+ QCOMPARE(rootFocusSpy.count(), 3);
+ QCOMPARE(rootActiveFocusSpy.count(), 3);
+ QCOMPARE(scope2FocusSpy.count(), 1);
+ QCOMPARE(scope2ActiveFocusSpy.count(), 1);
+ QCOMPARE(item2FocusSpy.count(), 1);
+ QCOMPARE(item2ActiveFocusSpy.count(), 1);
+
+ delete view;
+}
+
+QTEST_MAIN(tst_qquickfocusscope)
+
+#include "tst_qquickfocusscope.moc"
diff --git a/tests/auto/qtquick2/qdeclarativefontloader/data/daniel.ttf b/tests/auto/quick/qquickfontloader/data/daniel.ttf
index aae50d5035..aae50d5035 100644
--- a/tests/auto/qtquick2/qdeclarativefontloader/data/daniel.ttf
+++ b/tests/auto/quick/qquickfontloader/data/daniel.ttf
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativefontloader/data/dummy.ttf b/tests/auto/quick/qquickfontloader/data/dummy.ttf
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/qtquick2/qdeclarativefontloader/data/dummy.ttf
+++ b/tests/auto/quick/qquickfontloader/data/dummy.ttf
diff --git a/tests/auto/qtquick2/qdeclarativefontloader/data/qtbug-20268.qml b/tests/auto/quick/qquickfontloader/data/qtbug-20268.qml
index 0eafdfa17b..0eafdfa17b 100644
--- a/tests/auto/qtquick2/qdeclarativefontloader/data/qtbug-20268.qml
+++ b/tests/auto/quick/qquickfontloader/data/qtbug-20268.qml
diff --git a/tests/auto/qtquick2/qdeclarativefontloader/data/tarzeau_ocr_a.ttf b/tests/auto/quick/qquickfontloader/data/tarzeau_ocr_a.ttf
index cf93f9651f..cf93f9651f 100644
--- a/tests/auto/qtquick2/qdeclarativefontloader/data/tarzeau_ocr_a.ttf
+++ b/tests/auto/quick/qquickfontloader/data/tarzeau_ocr_a.ttf
Binary files differ
diff --git a/tests/auto/quick/qquickfontloader/qquickfontloader.pro b/tests/auto/quick/qquickfontloader/qquickfontloader.pro
new file mode 100644
index 0000000000..7c34c43d04
--- /dev/null
+++ b/tests/auto/quick/qquickfontloader/qquickfontloader.pro
@@ -0,0 +1,17 @@
+CONFIG += testcase
+TARGET = tst_qquickfontloader
+macx:CONFIG -= app_bundle
+
+HEADERS += ../../shared/testhttpserver.h
+SOURCES += tst_qquickfontloader.cpp \
+ ../../shared/testhttpserver.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp b/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp
new file mode 100644
index 0000000000..d8f368cf3e
--- /dev/null
+++ b/tests/auto/quick/qquickfontloader/tst_qquickfontloader.cpp
@@ -0,0 +1,255 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQuick/private/qquickfontloader_p.h>
+#include "../../shared/util.h"
+#include "../../shared/testhttpserver.h"
+#include <QtQuick/QQuickView>
+#include <QtQuick/QQuickItem>
+
+#define SERVER_PORT 14448
+
+class tst_qquickfontloader : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickfontloader();
+
+private slots:
+ void initTestCase();
+ void noFont();
+ void namedFont();
+ void localFont();
+ void failLocalFont();
+ void webFont();
+ void redirWebFont();
+ void failWebFont();
+ void changeFont();
+ void changeFontSourceViaState();
+
+private:
+ QQmlEngine engine;
+ TestHTTPServer server;
+};
+
+tst_qquickfontloader::tst_qquickfontloader() :
+ server(SERVER_PORT)
+{
+}
+
+void tst_qquickfontloader::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ server.serveDirectory(dataDirectory());
+ QVERIFY(server.isValid());
+}
+
+void tst_qquickfontloader::noFont()
+{
+ QString componentStr = "import QtQuick 2.0\nFontLoader { }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QCOMPARE(fontObject->name(), QString(""));
+ QCOMPARE(fontObject->source(), QUrl(""));
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Null);
+
+ delete fontObject;
+}
+
+void tst_qquickfontloader::namedFont()
+{
+ QString componentStr = "import QtQuick 2.0\nFontLoader { name: \"Helvetica\" }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QCOMPARE(fontObject->source(), QUrl(""));
+ QCOMPARE(fontObject->name(), QString("Helvetica"));
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+}
+
+void tst_qquickfontloader::localFont()
+{
+ QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFile("tarzeau_ocr_a.ttf") + "\" }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+}
+
+void tst_qquickfontloader::failLocalFont()
+{
+ QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFileUrl("dummy.ttf").toString() + "\" }";
+ QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + testFileUrl("dummy.ttf").toString() + "\"").toUtf8().constData());
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString(""));
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Error);
+}
+
+void tst_qquickfontloader::webFont()
+{
+ QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/tarzeau_ocr_a.ttf\" }";
+ QQmlComponent component(&engine);
+
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+}
+
+void tst_qquickfontloader::redirWebFont()
+{
+ server.addRedirect("olddir/oldname.ttf","../tarzeau_ocr_a.ttf");
+
+ QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/olddir/oldname.ttf\" }";
+ QQmlComponent component(&engine);
+
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+}
+
+void tst_qquickfontloader::failWebFont()
+{
+ QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"http://localhost:14448/nonexist.ttf\" }";
+ QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML FontLoader: Cannot load font: \"http://localhost:14448/nonexist.ttf\"");
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString(""));
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Error);
+}
+
+void tst_qquickfontloader::changeFont()
+{
+ QString componentStr = "import QtQuick 2.0\nFontLoader { source: font }";
+ QQmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("font", testFileUrl("tarzeau_ocr_a.ttf"));
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(component.create());
+
+ QVERIFY(fontObject != 0);
+
+ QSignalSpy nameSpy(fontObject, SIGNAL(nameChanged()));
+ QSignalSpy statusSpy(fontObject, SIGNAL(statusChanged()));
+
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::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() == QQuickFontLoader::Loading);
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 1);
+ QCOMPARE(statusSpy.count(), 2);
+ QTRY_COMPARE(fontObject->name(), QString("Daniel"));
+
+ ctxt->setContextProperty("font", testFileUrl("tarzeau_ocr_a.ttf"));
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::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() == QQuickFontLoader::Ready);
+ QCOMPARE(nameSpy.count(), 3);
+ QCOMPARE(statusSpy.count(), 2);
+ QTRY_COMPARE(fontObject->name(), QString("Daniel"));
+}
+
+void tst_qquickfontloader::changeFontSourceViaState()
+{
+ QQuickView canvas(testFileUrl("qtbug-20268.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QQuickFontLoader *fontObject = qobject_cast<QQuickFontLoader*>(qvariant_cast<QObject *>(canvas.rootObject()->property("fontloader")));
+ QVERIFY(fontObject != 0);
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QVERIFY(fontObject->source() != QUrl(""));
+ QTRY_COMPARE(fontObject->name(), QString("OCRA"));
+
+ canvas.rootObject()->setProperty("usename", true);
+
+ // This warning should probably not be printed once QTBUG-20268 is fixed
+ QString warning = QString(testFileUrl("qtbug-20268.qml").toString()) +
+ QLatin1String(":13:5: QML FontLoader: Cannot load font: \"\"");
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ QEXPECT_FAIL("", "QTBUG-20268", Abort);
+ QTRY_VERIFY(fontObject->status() == QQuickFontLoader::Ready);
+ QCOMPARE(canvas.rootObject()->property("name").toString(), QString("Tahoma"));
+}
+
+QTEST_MAIN(tst_qquickfontloader)
+
+#include "tst_qquickfontloader.moc"
diff --git a/tests/auto/qtquick2/qquickgridview/data/ComponentView.qml b/tests/auto/quick/qquickgridview/data/ComponentView.qml
index 12ab6c92d1..12ab6c92d1 100644
--- a/tests/auto/qtquick2/qquickgridview/data/ComponentView.qml
+++ b/tests/auto/quick/qquickgridview/data/ComponentView.qml
diff --git a/tests/auto/quick/qquickgridview/data/addTransitions.qml b/tests/auto/quick/qquickgridview/data/addTransitions.qml
new file mode 100644
index 0000000000..3f47cbd7b7
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/data/addTransitions.qml
@@ -0,0 +1,129 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 550
+ height: 600
+
+ property int duration: 10
+ property int count: grid.count
+
+ Component {
+ id: myDelegate
+
+ Rectangle {
+ id: wrapper
+
+ property string nameData: name
+
+ objectName: "wrapper"
+ width: 80
+ height: 60
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text {
+ text: wrapper.x + ", " + wrapper.y
+ }
+ Text {
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ }
+ color: GridView.isCurrentItem ? "lightsteelblue" : "white"
+
+ onXChanged: checkPos()
+ onYChanged: checkPos()
+
+ function checkPos() {
+ if (Qt.point(x, y) == targetItems_transitionFrom)
+ model_targetItems_transitionFrom.addItem(name, "")
+ if (Qt.point(x, y) == displacedItems_transitionVia)
+ model_displacedItems_transitionVia.addItem(name, "")
+ }
+ }
+ }
+
+ GridView {
+ id: grid
+
+ property int targetTransitionsDone
+ property int displaceTransitionsDone
+
+ property var targetTrans_items: new Object()
+ property var targetTrans_targetIndexes: new Array()
+ property var targetTrans_targetItems: new Array()
+
+ property var displacedTrans_items: new Object()
+ property var displacedTrans_targetIndexes: new Array()
+ property var displacedTrans_targetItems: new Array()
+
+ objectName: "grid"
+ width: 240
+ height: 320
+ cellWidth: 80
+ cellHeight: 60
+ anchors.centerIn: parent
+ model: testModel
+ delegate: myDelegate
+
+ // for QQmlListProperty types
+ function copyList(propList) {
+ var temp = new Array()
+ for (var i=0; i<propList.length; i++)
+ temp.push(propList[i])
+ return temp
+ }
+
+ add: Transition {
+ id: targetTransition
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ grid.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
+ grid.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
+ grid.targetTrans_targetItems.push(grid.copyList(targetTransition.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; from: targetItems_transitionFrom.x; duration: root.duration }
+ NumberAnimation { properties: "y"; from: targetItems_transitionFrom.y; duration: root.duration }
+ }
+
+ ScriptAction { script: grid.targetTransitionsDone += 1 }
+ }
+ }
+
+ addDisplaced: Transition {
+ id: displaced
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ grid.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
+ grid.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
+ grid.displacedTrans_targetItems.push(grid.copyList(displaced.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; duration: root.duration; to: displacedItems_transitionVia.x }
+ NumberAnimation { properties: "y"; duration: root.duration; to: displacedItems_transitionVia.y }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: grid.displaceTransitionsDone += 1 }
+ }
+
+ }
+ }
+
+ Rectangle {
+ anchors.fill: grid
+ color: "lightsteelblue"
+ opacity: 0.2
+ }
+}
+
+
diff --git a/tests/auto/qtquick2/qquickgridview/data/asyncloader.qml b/tests/auto/quick/qquickgridview/data/asyncloader.qml
index ab66f20a1e..ab66f20a1e 100644
--- a/tests/auto/qtquick2/qquickgridview/data/asyncloader.qml
+++ b/tests/auto/quick/qquickgridview/data/asyncloader.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/attachedSignals.qml b/tests/auto/quick/qquickgridview/data/attachedSignals.qml
index 73c10d8caf..73c10d8caf 100644
--- a/tests/auto/qtquick2/qquickgridview/data/attachedSignals.qml
+++ b/tests/auto/quick/qquickgridview/data/attachedSignals.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/creationContext.qml b/tests/auto/quick/qquickgridview/data/creationContext.qml
index 79a682788b..79a682788b 100644
--- a/tests/auto/qtquick2/qquickgridview/data/creationContext.qml
+++ b/tests/auto/quick/qquickgridview/data/creationContext.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/displaygrid.qml b/tests/auto/quick/qquickgridview/data/displaygrid.qml
index 1da4fe50ac..1da4fe50ac 100644
--- a/tests/auto/qtquick2/qquickgridview/data/displaygrid.qml
+++ b/tests/auto/quick/qquickgridview/data/displaygrid.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/footer.qml b/tests/auto/quick/qquickgridview/data/footer.qml
index 9083f9f57c..9083f9f57c 100644
--- a/tests/auto/qtquick2/qquickgridview/data/footer.qml
+++ b/tests/auto/quick/qquickgridview/data/footer.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/gridview-enforcerange.qml b/tests/auto/quick/qquickgridview/data/gridview-enforcerange.qml
index 2bfe7da78e..2bfe7da78e 100644
--- a/tests/auto/qtquick2/qquickgridview/data/gridview-enforcerange.qml
+++ b/tests/auto/quick/qquickgridview/data/gridview-enforcerange.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/gridview-initCurrent.qml b/tests/auto/quick/qquickgridview/data/gridview-initCurrent.qml
index 624f639962..624f639962 100644
--- a/tests/auto/qtquick2/qquickgridview/data/gridview-initCurrent.qml
+++ b/tests/auto/quick/qquickgridview/data/gridview-initCurrent.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/gridview-noCurrent.qml b/tests/auto/quick/qquickgridview/data/gridview-noCurrent.qml
index 600716e2d4..600716e2d4 100644
--- a/tests/auto/qtquick2/qquickgridview/data/gridview-noCurrent.qml
+++ b/tests/auto/quick/qquickgridview/data/gridview-noCurrent.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/gridview1.qml b/tests/auto/quick/qquickgridview/data/gridview1.qml
index 4bf6f0b952..4bf6f0b952 100644
--- a/tests/auto/qtquick2/qquickgridview/data/gridview1.qml
+++ b/tests/auto/quick/qquickgridview/data/gridview1.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/gridview2.qml b/tests/auto/quick/qquickgridview/data/gridview2.qml
index 5fb45a1613..5fb45a1613 100644
--- a/tests/auto/qtquick2/qquickgridview/data/gridview2.qml
+++ b/tests/auto/quick/qquickgridview/data/gridview2.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/gridview3.qml b/tests/auto/quick/qquickgridview/data/gridview3.qml
index a8c1c5a0f7..a8c1c5a0f7 100644
--- a/tests/auto/qtquick2/qquickgridview/data/gridview3.qml
+++ b/tests/auto/quick/qquickgridview/data/gridview3.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/gridview4.qml b/tests/auto/quick/qquickgridview/data/gridview4.qml
index eed3a2bdb1..eed3a2bdb1 100644
--- a/tests/auto/qtquick2/qquickgridview/data/gridview4.qml
+++ b/tests/auto/quick/qquickgridview/data/gridview4.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/header.qml b/tests/auto/quick/qquickgridview/data/header.qml
index 648e2a2298..648e2a2298 100644
--- a/tests/auto/qtquick2/qquickgridview/data/header.qml
+++ b/tests/auto/quick/qquickgridview/data/header.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/manual-highlight.qml b/tests/auto/quick/qquickgridview/data/manual-highlight.qml
index c2f1d20fb1..c2f1d20fb1 100644
--- a/tests/auto/qtquick2/qquickgridview/data/manual-highlight.qml
+++ b/tests/auto/quick/qquickgridview/data/manual-highlight.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/margins.qml b/tests/auto/quick/qquickgridview/data/margins.qml
index d369658a91..d369658a91 100644
--- a/tests/auto/qtquick2/qquickgridview/data/margins.qml
+++ b/tests/auto/quick/qquickgridview/data/margins.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/mirroring.qml b/tests/auto/quick/qquickgridview/data/mirroring.qml
index b9aff501c1..b9aff501c1 100644
--- a/tests/auto/qtquick2/qquickgridview/data/mirroring.qml
+++ b/tests/auto/quick/qquickgridview/data/mirroring.qml
diff --git a/tests/auto/quick/qquickgridview/data/moveTransitions.qml b/tests/auto/quick/qquickgridview/data/moveTransitions.qml
new file mode 100644
index 0000000000..a91f5a3295
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/data/moveTransitions.qml
@@ -0,0 +1,143 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 500
+ height: 600
+
+ property int duration: 10
+ property int count: grid.count
+
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+
+ property string nameData: name
+
+ objectName: "wrapper"
+ width: 80
+ height: 60
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text {
+ text: wrapper.x + ", " + wrapper.y
+ }
+ Text {
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ }
+ color: GridView.isCurrentItem ? "lightsteelblue" : "white"
+
+ onXChanged: checkPos()
+ onYChanged: checkPos()
+
+ function checkPos() {
+ if (Qt.point(x, y) == targetItems_transitionVia)
+ model_targetItems_transitionVia.addItem(name, "")
+ if (Qt.point(x, y) == displacedItems_transitionVia)
+ model_displacedItems_transitionVia.addItem(name, "")
+ }
+ }
+ }
+
+ GridView {
+ id: grid
+
+ property int targetTransitionsDone
+ property int displaceTransitionsDone
+
+ property var targetTrans_items: new Object()
+ property var targetTrans_targetIndexes: new Array()
+ property var targetTrans_targetItems: new Array()
+
+ property var displacedTrans_items: new Object()
+ property var displacedTrans_targetIndexes: new Array()
+ property var displacedTrans_targetItems: new Array()
+
+ objectName: "grid"
+ width: 240
+ height: 320
+ cellWidth: 80
+ cellHeight: 60
+ anchors.centerIn: parent
+ model: testModel
+ delegate: myDelegate
+
+ // for QQmlListProperty types
+ function copyList(propList) {
+ var temp = new Array()
+ for (var i=0; i<propList.length; i++)
+ temp.push(propList[i])
+ return temp
+ }
+
+ move: Transition {
+ id: targetTransition
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ grid.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
+ grid.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
+ grid.targetTrans_targetItems.push(grid.copyList(targetTransition.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: targetItems_transitionVia.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: targetItems_transitionVia.y; duration: root.duration }
+ }
+
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: grid.targetTransitionsDone += 1 }
+ }
+ }
+
+ moveDisplaced: Transition {
+ id: displaced
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ grid.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
+ grid.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
+ grid.displacedTrans_targetItems.push(grid.copyList(displaced.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation {
+ properties: "x"; duration: root.duration
+ to: displacedItems_transitionVia.x
+ }
+ NumberAnimation {
+ properties: "y"; duration: root.duration
+ to: displacedItems_transitionVia.y
+ }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: grid.displaceTransitionsDone += 1 }
+ }
+
+ }
+ }
+
+ Rectangle {
+ anchors.fill: grid
+ color: "lightsteelblue"
+ opacity: 0.2
+ }
+
+ Rectangle {
+ anchors.bottom: parent.bottom
+ width: 20; height: 20
+ color: "white"
+ NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 10000 }
+ }
+}
+
+
diff --git a/tests/auto/qtquick2/qquickgridview/data/multipleTransitions.qml b/tests/auto/quick/qquickgridview/data/multipleTransitions.qml
index 45b86e22cf..45b86e22cf 100644
--- a/tests/auto/qtquick2/qquickgridview/data/multipleTransitions.qml
+++ b/tests/auto/quick/qquickgridview/data/multipleTransitions.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/populateTransitions.qml b/tests/auto/quick/qquickgridview/data/populateTransitions.qml
index c12d5ac39d..c12d5ac39d 100644
--- a/tests/auto/qtquick2/qquickgridview/data/populateTransitions.qml
+++ b/tests/auto/quick/qquickgridview/data/populateTransitions.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/propertychangestest.qml b/tests/auto/quick/qquickgridview/data/propertychangestest.qml
index 97efbe78f5..97efbe78f5 100644
--- a/tests/auto/qtquick2/qquickgridview/data/propertychangestest.qml
+++ b/tests/auto/quick/qquickgridview/data/propertychangestest.qml
diff --git a/tests/auto/quick/qquickgridview/data/removeTransitions.qml b/tests/auto/quick/qquickgridview/data/removeTransitions.qml
new file mode 100644
index 0000000000..3e82cf7f96
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/data/removeTransitions.qml
@@ -0,0 +1,146 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 500
+ height: 600
+
+ property int duration: 10
+ property int count: grid.count
+
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+
+ property string nameData: name
+
+ objectName: "wrapper"
+ width: 80
+ height: 60
+ border.width: 1
+ Column {
+ Text { text: index }
+ Text {
+ text: wrapper.x + ", " + wrapper.y
+ }
+ Text {
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ }
+ color: GridView.isCurrentItem ? "lightsteelblue" : "white"
+
+ onXChanged: checkPos()
+ onYChanged: checkPos()
+
+ function checkPos() {
+ if (Qt.point(x, y) == targetItems_transitionTo) {
+ model_targetItems_transitionTo.addItem(nameData, "") // name is invalid once model removes the item
+ }
+ if (Qt.point(x, y) == displacedItems_transitionVia) {
+ model_displacedItems_transitionVia.addItem(name, "")
+ }
+ }
+ }
+ }
+
+ GridView {
+ id: grid
+
+ property int targetTransitionsDone
+ property int displaceTransitionsDone
+
+ property var targetTrans_items: new Object()
+ property var targetTrans_targetIndexes: new Array()
+ property var targetTrans_targetItems: new Array()
+
+ property var displacedTrans_items: new Object()
+ property var displacedTrans_targetIndexes: new Array()
+ property var displacedTrans_targetItems: new Array()
+
+ objectName: "grid"
+ width: 240
+ height: 320
+ cellWidth: 80
+ cellHeight: 60
+ anchors.centerIn: parent
+ model: testModel
+ delegate: myDelegate
+
+ // for QQmlListProperty types
+ function copyList(propList) {
+ var temp = new Array()
+ for (var i=0; i<propList.length; i++)
+ temp.push(propList[i])
+ return temp
+ }
+
+ remove: Transition {
+ id: targetTransition
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ grid.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
+ grid.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
+ grid.targetTrans_targetItems.push(grid.copyList(targetTransition.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: targetItems_transitionTo.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: targetItems_transitionTo.y; duration: root.duration }
+ }
+ ScriptAction { script: grid.targetTransitionsDone += 1 }
+
+ // delay deleting this item so that it stays valid for the tests
+ // (this doesn't delay the test itself)
+ PauseAnimation { duration: 10000 }
+ }
+ }
+
+ removeDisplaced: Transition {
+ id: displaced
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ grid.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
+ grid.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
+ grid.displacedTrans_targetItems.push(grid.copyList(displaced.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation {
+ properties: "x"; duration: root.duration
+ to: displacedItems_transitionVia.x
+ }
+ NumberAnimation {
+ properties: "y"; duration: root.duration
+ to: displacedItems_transitionVia.y
+ }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: grid.displaceTransitionsDone += 1 }
+ }
+
+ }
+ }
+
+ Rectangle {
+ anchors.fill: grid
+ color: "lightsteelblue"
+ opacity: 0.2
+ }
+
+ Rectangle {
+ anchors.bottom: parent.bottom
+ width: 20; height: 20
+ color: "white"
+ NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 10000 }
+ }
+}
+
+
diff --git a/tests/auto/qtquick2/qquickgridview/data/resizeview.qml b/tests/auto/quick/qquickgridview/data/resizeview.qml
index 130a0defc1..130a0defc1 100644
--- a/tests/auto/qtquick2/qquickgridview/data/resizeview.qml
+++ b/tests/auto/quick/qquickgridview/data/resizeview.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/setindex.qml b/tests/auto/quick/qquickgridview/data/setindex.qml
index ef80f3a2fb..ef80f3a2fb 100644
--- a/tests/auto/qtquick2/qquickgridview/data/setindex.qml
+++ b/tests/auto/quick/qquickgridview/data/setindex.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/snapOneRow.qml b/tests/auto/quick/qquickgridview/data/snapOneRow.qml
index 3d32d75c45..3d32d75c45 100644
--- a/tests/auto/qtquick2/qquickgridview/data/snapOneRow.qml
+++ b/tests/auto/quick/qquickgridview/data/snapOneRow.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/snapToRow.qml b/tests/auto/quick/qquickgridview/data/snapToRow.qml
index f079a048f0..f079a048f0 100644
--- a/tests/auto/qtquick2/qquickgridview/data/snapToRow.qml
+++ b/tests/auto/quick/qquickgridview/data/snapToRow.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/unaligned.qml b/tests/auto/quick/qquickgridview/data/unaligned.qml
index 445400e8b4..445400e8b4 100644
--- a/tests/auto/qtquick2/qquickgridview/data/unaligned.qml
+++ b/tests/auto/quick/qquickgridview/data/unaligned.qml
diff --git a/tests/auto/qtquick2/qquickgridview/data/unrequestedItems.qml b/tests/auto/quick/qquickgridview/data/unrequestedItems.qml
index 79f845fd25..79f845fd25 100644
--- a/tests/auto/qtquick2/qquickgridview/data/unrequestedItems.qml
+++ b/tests/auto/quick/qquickgridview/data/unrequestedItems.qml
diff --git a/tests/auto/quick/qquickgridview/qquickgridview.pro b/tests/auto/quick/qquickgridview/qquickgridview.pro
new file mode 100644
index 0000000000..cabf4396b4
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/qquickgridview.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickgridview
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickgridview.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib widgets
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
new file mode 100644
index 0000000000..d156ed0957
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -0,0 +1,5075 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/qstringlistmodel.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlincubator.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/private/qquickgridview_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuick/private/qquickvisualitemmodel_p.h>
+#include <QtQml/private/qquicklistmodel_p.h>
+#include <QtQml/private/qlistmodelinterface_p.h>
+#include "../../shared/util.h"
+#include "../shared/viewtestutil.h"
+#include "../shared/visualtestutil.h"
+#include <QtGui/qguiapplication.h>
+
+Q_DECLARE_METATYPE(Qt::LayoutDirection)
+Q_DECLARE_METATYPE(QQuickGridView::Flow)
+
+using namespace QQuickViewTestUtil;
+using namespace QQuickVisualTestUtil;
+
+class tst_QQuickGridView : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickGridView();
+
+private slots:
+ void items();
+ void changed();
+ void inserted();
+ void inserted_more();
+ void inserted_more_data();
+ void insertBeforeVisible();
+ void insertBeforeVisible_data();
+ void removed();
+ void removed_more();
+ void removed_more_data();
+ void addOrRemoveBeforeVisible();
+ void addOrRemoveBeforeVisible_data();
+ void clear();
+ void moved();
+ void moved_data();
+ void multipleChanges();
+ void multipleChanges_data();
+ void swapWithFirstItem();
+ void changeFlow();
+ void currentIndex();
+ void noCurrentIndex();
+ void defaultValues();
+ void properties();
+ void propertyChanges();
+ void componentChanges();
+ void modelChanges();
+ void positionViewAtIndex();
+ void positionViewAtIndex_rightToLeft();
+ void mirroring();
+ void snapping();
+ void resetModel();
+ void enforceRange();
+ void enforceRange_rightToLeft();
+ void QTBUG_8456();
+ void manualHighlight();
+ void footer();
+ void footer_data();
+ void header();
+ void header_data();
+ void resizeViewAndRepaint();
+ void changeColumnCount();
+ void indexAt_itemAt_data();
+ void indexAt_itemAt();
+ void onAdd();
+ void onAdd_data();
+ void onRemove();
+ void onRemove_data();
+ void columnCount();
+ void margins();
+ void creationContext();
+ void snapToRow_data();
+ void snapToRow();
+ void snapOneRow_data();
+ void snapOneRow();
+ void unaligned();
+ void cacheBuffer();
+ void asynchronous();
+ void unrequestedVisibility();
+
+ void populateTransitions();
+ void populateTransitions_data();
+ void addTransitions();
+ void addTransitions_data();
+ void moveTransitions();
+ void moveTransitions_data();
+ void removeTransitions();
+ void removeTransitions_data();
+ void multipleTransitions();
+ void multipleTransitions_data();
+
+private:
+ QList<int> toIntList(const QVariantList &list);
+ void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes);
+ void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes);
+ void matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems);
+};
+
+tst_QQuickGridView::tst_QQuickGridView()
+{
+}
+
+void tst_QQuickGridView::items()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Billy", "22345");
+ model.addItem("Sam", "2945");
+ model.addItem("Ben", "04321");
+ model.addItem("Jim", "0780");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(gridview->count(), model.count());
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ for (int i = 0; i < model.count(); ++i) {
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ // set an empty model and confirm that items are destroyed
+ QaimModel model2;
+ ctxt->setContextProperty("testModel", &model2);
+
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ QTRY_VERIFY(itemCount == 0);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::changed()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Billy", "22345");
+ model.addItem("Sam", "2945");
+ model.addItem("Ben", "04321");
+ model.addItem("Jim", "0780");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ qApp->processEvents();
+
+ QQuickFlickable *gridview = findItem<QQuickFlickable>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ model.modifyItem(1, "Will", "9876");
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::inserted()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ model.insertItem(1, "Will", "9876");
+
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
+
+ // Checks that onAdd is called
+ int added = canvas->rootObject()->property("added").toInt();
+ QTRY_COMPARE(added, 1);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_COMPARE(item->x(), (i%3)*80.0);
+ QTRY_COMPARE(item->y(), (i/3)*60.0);
+ }
+
+ model.insertItem(0, "Foo", "1111"); // zero index, and current item
+
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ name = findItem<QQuickText>(contentItem, "textName", 0);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
+ number = findItem<QQuickText>(contentItem, "textNumber", 0);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
+
+ QTRY_COMPARE(gridview->currentIndex(), 1);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
+ }
+
+ for (int i = model.count(); i < 30; ++i)
+ model.insertItem(i, "Hello", QString::number(i));
+
+ gridview->setContentY(120);
+
+ // Insert item outside visible area
+ model.insertItem(1, "Hello", "1324");
+
+ QTRY_VERIFY(gridview->contentY() == 120);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::inserted_more()
+{
+ QFETCH(qreal, contentY);
+ QFETCH(int, insertIndex);
+ QFETCH(int, insertCount);
+ QFETCH(qreal, itemsOffsetAfterMove);
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ gridview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QList<QPair<QString, QString> > newData;
+ for (int i=0; i<insertCount; i++)
+ newData << qMakePair(QString("value %1").arg(i), QString::number(i));
+ model.insertItems(insertIndex, newData);
+ QTRY_COMPARE(gridview->property("count").toInt(), model.count());
+
+ // check visibleItems.first() is in correct position
+ QQuickItem *item0 = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item0);
+ QCOMPARE(item0->y(), 0.0);
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ QQuickText *name;
+ QQuickText *number;
+ for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
+
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::inserted_more_data()
+{
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<int>("insertIndex");
+ QTest::addColumn<int>("insertCount");
+ QTest::addColumn<qreal>("itemsOffsetAfterMove");
+
+ QTest::newRow("add 1, before visible items")
+ << 120.0 // show 6-23
+ << 5 << 1
+ << 0.0; // insert 1 above first visible, grid is rearranged; first visible moves forward within its row
+ // new 1st visible item is at 0
+
+ QTest::newRow("add 2, before visible items")
+ << 120.0 // show 6-23
+ << 5 << 2
+ << 0.0; // insert 2 above first visible, grid is rearranged; first visible moves forward within its row
+
+ QTest::newRow("add 3, before visible items")
+ << 120.0 // show 6-23
+ << 5 << 3
+ << -60.0; // insert 3 (1 row) above first visible in negative pos, first visible does not move
+
+ QTest::newRow("add 5, before visible items")
+ << 120.0 // show 6-23
+ << 5 << 5
+ << -60.0; // insert 1 row + 2 items above first visible, 1 row added at negative pos,
+ // grid is rearranged and first visible moves forward within its row
+
+ QTest::newRow("add 6, before visible items")
+ << 120.0 // show 6-23
+ << 5 << 6
+ << -60.0 * 2; // insert 2 rows above first visible in negative pos, first visible does not move
+
+
+
+ QTest::newRow("add 1, at start of visible, content at start")
+ << 0.0
+ << 0 << 1
+ << 0.0;
+
+ QTest::newRow("add multiple, at start of visible, content at start")
+ << 0.0
+ << 0 << 3
+ << 0.0;
+
+ QTest::newRow("add 1, at start of visible, content not at start")
+ << 120.0 // show 6-23
+ << 6 << 1
+ << 0.0;
+
+ QTest::newRow("add multiple, at start of visible, content not at start")
+ << 120.0 // show 6-23
+ << 6 << 3
+ << 0.0;
+
+
+ QTest::newRow("add 1, at end of visible, content at start")
+ << 0.0
+ << 17 << 1
+ << 0.0;
+
+ QTest::newRow("add 1, at end of visible, content at start")
+ << 0.0
+ << 17 << 3
+ << 0.0;
+
+ QTest::newRow("add 1, at end of visible, content not at start")
+ << 120.0 // show 6-23
+ << 23 << 1
+ << 0.0;
+
+ QTest::newRow("add multiple, at end of visible, content not at start")
+ << 120.0 // show 6-23
+ << 23 << 3
+ << 0.0;
+
+
+ QTest::newRow("add 1, after visible, content at start")
+ << 0.0
+ << 20 << 1
+ << 0.0;
+
+ QTest::newRow("add 1, after visible, content at start")
+ << 0.0
+ << 20 << 3
+ << 0.0;
+
+ QTest::newRow("add 1, after visible, content not at start")
+ << 120.0 // show 6-23
+ << 24 << 1
+ << 0.0;
+
+ QTest::newRow("add multiple, after visible, content not at start")
+ << 120.0 // show 6-23
+ << 24 << 3
+ << 0.0;
+}
+
+void tst_QQuickGridView::insertBeforeVisible()
+{
+ QFETCH(int, insertIndex);
+ QFETCH(int, insertCount);
+ QFETCH(int, cacheBuffer);
+
+ QQuickText *name;
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ gridview->setCacheBuffer(cacheBuffer);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ // trigger a refill (not just setting contentY) so that the visibleItems grid is updated
+ int firstVisibleIndex = 12; // move to an index where the top item is not visible
+ gridview->setContentY(firstVisibleIndex/3 * 60.0);
+ gridview->setCurrentIndex(firstVisibleIndex);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QTRY_COMPARE(gridview->currentIndex(), firstVisibleIndex);
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", firstVisibleIndex);
+ QVERIFY(item);
+ QCOMPARE(item->y(), gridview->contentY());
+
+ QList<QPair<QString, QString> > newData;
+ for (int i=0; i<insertCount; i++)
+ newData << qMakePair(QString("value %1").arg(i), QString::number(i));
+ model.insertItems(insertIndex, newData);
+ QTRY_COMPARE(gridview->property("count").toInt(), model.count());
+
+ // now, moving to the top of the view should position the inserted items correctly
+ int itemsOffsetAfterMove = (insertCount / 3) * -60.0;
+ gridview->setCurrentIndex(0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->contentY(), 0.0 + itemsOffsetAfterMove);
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::insertBeforeVisible_data()
+{
+ QTest::addColumn<int>("insertIndex");
+ QTest::addColumn<int>("insertCount");
+ QTest::addColumn<int>("cacheBuffer");
+
+ QTest::newRow("insert 1 at 0, 0 buffer") << 0 << 1 << 0;
+ QTest::newRow("insert 1 at 0, 100 buffer") << 0 << 1 << 100;
+ QTest::newRow("insert 1 at 0, 500 buffer") << 0 << 1 << 500;
+
+ QTest::newRow("insert 1 at 1, 0 buffer") << 1 << 1 << 0;
+ QTest::newRow("insert 1 at 1, 100 buffer") << 1 << 1 << 100;
+ QTest::newRow("insert 1 at 1, 500 buffer") << 1 << 1 << 500;
+
+ QTest::newRow("insert multiple at 0, 0 buffer") << 0 << 6 << 0;
+ QTest::newRow("insert multiple at 0, 100 buffer") << 0 << 6 << 100;
+ QTest::newRow("insert multiple at 0, 500 buffer") << 0 << 6 << 500;
+
+ QTest::newRow("insert multiple at 1, 0 buffer") << 1 << 6 << 0;
+ QTest::newRow("insert multiple at 1, 100 buffer") << 1 << 6 << 100;
+ QTest::newRow("insert multiple at 1, 500 buffer") << 1 << 6 << 500;
+}
+
+void tst_QQuickGridView::removed()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ model.removeItem(1);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
+
+
+ // Checks that onRemove is called
+ QString removed = canvas->rootObject()->property("removed").toString();
+ QTRY_COMPARE(removed, QString("Item1"));
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
+ }
+
+ // Remove first item (which is the current item);
+ model.removeItem(0);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ name = findItem<QQuickText>(contentItem, "textName", 0);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
+ number = findItem<QQuickText>(contentItem, "textNumber", 0);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
+
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
+ }
+
+ // Remove items not visible
+ model.removeItem(25);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
+ }
+
+ // Remove items before visible
+ gridview->setContentY(120);
+ gridview->setCurrentIndex(10);
+
+ // Setting currentIndex above shouldn't cause view to scroll
+ QTRY_COMPARE(gridview->contentY(), 120.0);
+
+ model.removeItem(1);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ // Confirm items positioned correctly
+ for (int i = 6; i < 18; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
+ }
+
+ // Remove currentIndex
+ QQuickItem *oldCurrent = gridview->currentItem();
+ model.removeItem(9);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ QTRY_COMPARE(gridview->currentIndex(), 9);
+ QTRY_VERIFY(gridview->currentItem() != oldCurrent);
+
+ gridview->setContentY(0);
+ // let transitions settle.
+ QTest::qWait(300);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60);
+ }
+
+ // remove item outside current view.
+ gridview->setCurrentIndex(32);
+ gridview->setContentY(240);
+
+ model.removeItem(30);
+ QTRY_VERIFY(gridview->currentIndex() == 31);
+
+ // remove current item beyond visible items.
+ gridview->setCurrentIndex(20);
+ gridview->setContentY(0);
+ model.removeItem(20);
+
+ QTRY_COMPARE(gridview->currentIndex(), 20);
+ QTRY_VERIFY(gridview->currentItem() != 0);
+
+ // remove item before current, but visible
+ gridview->setCurrentIndex(8);
+ gridview->setContentY(240);
+ oldCurrent = gridview->currentItem();
+ model.removeItem(6);
+
+ QTRY_COMPARE(gridview->currentIndex(), 7);
+ QTRY_VERIFY(gridview->currentItem() == oldCurrent);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::removed_more()
+{
+ QFETCH(qreal, contentY);
+ QFETCH(int, removeIndex);
+ QFETCH(int, removeCount);
+ QFETCH(qreal, itemsOffsetAfterMove);
+ QFETCH(QString, firstVisible);
+
+ QQuickText *name;
+ QQuickText *number;
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ gridview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ model.removeItems(removeIndex, removeCount);
+ QTRY_COMPARE(gridview->property("count").toInt(), model.count());
+
+ QString firstName;
+ int firstVisibleIndex = -1;
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ QQmlExpression en(qmlContext(items[i]), items[i], "name");
+ firstName = en.evaluate().toString();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+ QCOMPARE(firstName, firstVisible);
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+
+ QTRY_COMPARE(item->x(), (i%3)*80.0);
+ QTRY_COMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
+
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QVERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::removed_more_data()
+{
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<int>("removeIndex");
+ QTest::addColumn<int>("removeCount");
+ QTest::addColumn<qreal>("itemsOffsetAfterMove");
+ QTest::addColumn<QString>("firstVisible");
+
+ QTest::newRow("remove 1, before visible items")
+ << 120.0 // show 6-23
+ << 2 << 1
+ << 0.0 << "Item7";
+
+ QTest::newRow("remove 1, before visible position")
+ << 120.0 // show 6-23
+ << 3 << 1
+ << 0.0 << "Item7";
+
+ QTest::newRow("remove multiple, all before visible items")
+ << 120.0
+ << 1 << 3
+ << 60.0 << "Item6"; // removed top row, slide down by 1 row
+
+ QTest::newRow("remove multiple, all before visible items, remove item 0")
+ << 120.0
+ << 0 << 4
+ << 60.0 << "Item7"; // removed top row, slide down by 1 row
+
+ QTest::newRow("remove multiple rows, all before visible items")
+ << 240.0 // show 12-29
+ << 1 << 7
+ << 120.0 << "Item13";
+
+ QTest::newRow("remove one row before visible, content y not on item border")
+ << 100.0
+ << 0 << 3
+ << 60.0 << "Item6"; // 1 row removed
+
+ QTest::newRow("remove mix of visible/non-visible")
+ << 120.0 // show 6-23
+ << 2 << 3
+ << 60.0 << "Item6"; // 1 row removed
+
+
+ // remove 3,4,5 before the visible pos, first row moves down to just before the visible pos,
+ // items 6,7 are removed from view, item 8 slides up to original pos of item 6 (120px)
+ QTest::newRow("remove multiple, mix of items from before and within visible items")
+ << 120.0
+ << 3 << 5
+ << 60.0 << "Item8"; // adjust for the 1 row removed before the visible
+
+ QTest::newRow("remove multiple, mix of items from before and within visible items, remove item 0")
+ << 120.0
+ << 0 << 8
+ << 60.0 * 2 << "Item8"; // adjust for the 2 rows removed before the visible
+
+
+ QTest::newRow("remove 1, from start of visible, content at start")
+ << 0.0
+ << 0 << 1
+ << 0.0 << "Item1";
+
+ QTest::newRow("remove multiple, from start of visible, content at start")
+ << 0.0
+ << 0 << 3
+ << 0.0 << "Item3";
+
+ QTest::newRow("remove 1, from start of visible, content not at start")
+ << 120.0 // show 6-23
+ << 4 << 1
+ << 0.0 << "Item7";
+
+ QTest::newRow("remove multiple, from start of visible, content not at start")
+ << 120.0 // show 6-23
+ << 4 << 3
+ << 0.0 << "Item9";
+
+
+ QTest::newRow("remove 1, from middle of visible, content at start")
+ << 0.0
+ << 10 << 1
+ << 0.0 << "Item0";
+
+ QTest::newRow("remove multiple, from middle of visible, content at start")
+ << 0.0
+ << 10 << 5
+ << 0.0 << "Item0";
+
+ QTest::newRow("remove 1, from middle of visible, content not at start")
+ << 120.0 // show 6-23
+ << 10 << 1
+ << 0.0 << "Item6";
+
+ QTest::newRow("remove multiple, from middle of visible, content not at start")
+ << 120.0 // show 6-23
+ << 10 << 5
+ << 0.0 << "Item6";
+
+
+ QTest::newRow("remove 1, after visible, content at start")
+ << 0.0
+ << 16 << 1
+ << 0.0 << "Item0";
+
+ QTest::newRow("remove multiple, after visible, content at start")
+ << 0.0
+ << 16 << 5
+ << 0.0 << "Item0";
+
+ QTest::newRow("remove 1, after visible, content not at start")
+ << 120.0 // show 6-23
+ << 16+4 << 1
+ << 0.0 << "Item6";
+
+ QTest::newRow("remove multiple, after visible, content not at start")
+ << 120.0 // show 6-23
+ << 16+4 << 5
+ << 0.0 << "Item6";
+
+ QTest::newRow("remove multiple, mix of items from within and after visible items")
+ << 120.0 // show 6-23
+ << 20 << 5
+ << 0.0 << "Item6";
+}
+
+void tst_QQuickGridView::addOrRemoveBeforeVisible()
+{
+ // QTBUG-21588: ensure re-layout is done on grid after adding or removing
+ // items from before the visible area
+
+ QFETCH(bool, doAdd);
+ QFETCH(qreal, newTopContentY);
+
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+ canvas->setSource(testFileUrl("gridview1.qml"));
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 0);
+ QTRY_COMPARE(name->text(), QString("Item0"));
+
+ gridview->setCurrentIndex(0);
+ qApp->processEvents();
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ // scroll down until item 0 is no longer drawn
+ // (bug not triggered if we just move using content y, since that doesn't
+ // refill and change the visible items)
+ gridview->setCurrentIndex(24);
+ qApp->processEvents();
+
+ QTRY_COMPARE(gridview->currentIndex(), 24);
+ QTRY_COMPARE(gridview->contentY(), 220.0);
+
+ QTest::qWait(100); // wait for refill to complete
+ QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 0)); // 0 shouldn't be visible
+
+ if (doAdd) {
+ model.insertItem(0, "New Item", "New Item number");
+ QTRY_COMPARE(gridview->count(), 31);
+ } else {
+ model.removeItem(0);
+ QTRY_COMPARE(gridview->count(), 29);
+ }
+
+ // scroll back up and item 0 should be gone
+ gridview->setCurrentIndex(0);
+ qApp->processEvents();
+ QTRY_COMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->contentY(), newTopContentY);
+
+ name = findItem<QQuickText>(contentItem, "textName", 0);
+ if (doAdd)
+ QCOMPARE(name->text(), QString("New Item"));
+ else
+ QCOMPARE(name->text(), QString("Item1"));
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QTRY_VERIFY(findItem<QQuickItem>(contentItem, "wrapper", i));
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item->x() == (i%3)*80);
+ QTRY_VERIFY(item->y() == (i/3)*60 + newTopContentY);
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::addOrRemoveBeforeVisible_data()
+{
+ QTest::addColumn<bool>("doAdd");
+ QTest::addColumn<qreal>("newTopContentY");
+
+ QTest::newRow("add") << true << -60.0;
+ QTest::newRow("remove") << false << -60.0;
+}
+
+void tst_QQuickGridView::clear()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ model.clear();
+
+ QVERIFY(gridview->count() == 0);
+ QVERIFY(gridview->currentItem() == 0);
+ QVERIFY(gridview->contentY() == 0);
+ QVERIFY(gridview->currentIndex() == -1);
+
+ // confirm sanity when adding an item to cleared list
+ model.addItem("New", "1");
+ QTRY_COMPARE(gridview->count(), 1);
+ QVERIFY(gridview->currentItem() != 0);
+ QVERIFY(gridview->currentIndex() == 0);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::moved()
+{
+ QFETCH(qreal, contentY);
+ QFETCH(int, from);
+ QFETCH(int, to);
+ QFETCH(int, count);
+ QFETCH(qreal, itemsOffsetAfterMove);
+
+ QQuickText *name;
+ QQuickText *number;
+ QScopedPointer<QQuickView> canvas(createView());
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QQuickItem *currentItem = gridview->currentItem();
+ QTRY_VERIFY(currentItem != 0);
+
+ if (contentY != 0) {
+ gridview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ }
+
+ model.moveItems(from, to, count);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ // Confirm items positioned correctly and indexes correct
+ int firstVisibleIndex = qCeil(contentY / 60.0) * 3;
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ if (i >= firstVisibleIndex + 18) // index has moved out of view
+ continue;
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+
+ QTRY_COMPARE(item->x(), (i%3)*80.0);
+ QTRY_COMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
+
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QVERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+
+ // current index should have been updated
+ if (item == currentItem)
+ QTRY_COMPARE(gridview->currentIndex(), i);
+ }
+}
+
+void tst_QQuickGridView::moved_data()
+{
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<int>("from");
+ QTest::addColumn<int>("to");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<qreal>("itemsOffsetAfterMove");
+
+ // model starts with 30 items, each 80x60, in area 240x320
+ // 18 items should be visible at a time
+
+ // The first visible item should not move upwards and out of the view
+ // if items are moved/removed before it.
+
+
+ QTest::newRow("move 1 forwards, within visible items")
+ << 0.0
+ << 1 << 8 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 forwards, from non-visible -> visible")
+ << 120.0 // show 6-23
+ << 1 << 23 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 forwards, from non-visible -> visible (move first item)")
+ << 120.0 // // show 6-23
+ << 0 << 6 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 forwards, from visible -> non-visible")
+ << 0.0
+ << 1 << 20 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 forwards, from visible -> non-visible (move first item)")
+ << 0.0
+ << 0 << 20 << 1
+ << 0.0;
+
+
+ QTest::newRow("move 1 backwards, within visible items")
+ << 0.0
+ << 10 << 5 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 backwards, within visible items (to first index)")
+ << 0.0
+ << 10 << 0 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 backwards, from non-visible -> visible")
+ << 0.0
+ << 28 << 8 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 backwards, from non-visible -> visible (move last item)")
+ << 0.0
+ << 29 << 14 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 backwards, from visible -> non-visible")
+ << 120.0 // show 6-23
+ << 7 << 1 << 1
+ << 0.0; // only 1 item moved back, so items shift accordingly and first row doesn't move
+
+ QTest::newRow("move 1 backwards, from visible -> non-visible (move first item)")
+ << 120.0 // show 6-23
+ << 7 << 0 << 1
+ << 0.0; // only 1 item moved back, so items shift accordingly and first row doesn't move
+
+
+ QTest::newRow("move multiple forwards, within visible items")
+ << 0.0
+ << 0 << 5 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple backwards, within visible items (move first item)")
+ << 0.0
+ << 10 << 0 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, before visible items")
+ << 120.0 // show 6-23
+ << 3 << 4 << 3 // 3, 4, 5 move to after 6
+ << 60.0; // row of 3,4,5 has moved down
+
+ QTest::newRow("move multiple forwards, from non-visible -> visible")
+ << 120.0 // show 6-23
+ << 1 << 6 << 3
+ << 60.0; // 1st row (it's above visible area) disappears, 0 drops down 1 row, first visible item (6) stays where it is
+
+ QTest::newRow("move multiple forwards, from non-visible -> visible (move first item)")
+ << 120.0 // show 6-23
+ << 0 << 6 << 3
+ << 60.0; // top row moved and shifted to below 3rd row, all items should shift down by 1 row
+
+ QTest::newRow("move multiple forwards, mix of non-visible/visible")
+ << 120.0
+ << 3 << 16 << 6
+ << 60.0; // top two rows removed, third row is now the first visible
+
+ QTest::newRow("move multiple forwards, to bottom of view")
+ << 0.0
+ << 5 << 13 << 5
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, to bottom of view, first row -> last")
+ << 0.0
+ << 0 << 15 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, to bottom of view, content y not 0")
+ << 120.0
+ << 5+4 << 13+4 << 5
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, from visible -> non-visible")
+ << 0.0
+ << 1 << 16 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, from visible -> non-visible (move first item)")
+ << 0.0
+ << 0 << 16 << 3
+ << 0.0;
+
+
+ QTest::newRow("move multiple backwards, within visible items")
+ << 0.0
+ << 4 << 1 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple backwards, from non-visible -> visible")
+ << 0.0
+ << 20 << 4 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple backwards, from non-visible -> visible (move last item)")
+ << 0.0
+ << 27 << 10 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple backwards, from visible -> non-visible")
+ << 120.0 // show 6-23
+ << 16 << 1 << 3
+ << -60.0; // to minimize movement, items are added above visible area, all items move up by 1 row
+
+ QTest::newRow("move multiple backwards, from visible -> non-visible (move first item)")
+ << 120.0 // show 6-23
+ << 16 << 0 << 3
+ << -60.0; // 16,17,18 move to above item 0, all items move up by 1 row
+}
+
+void tst_QQuickGridView::multipleChanges()
+{
+ QFETCH(int, startCount);
+ QFETCH(QList<ListChange>, changes);
+ QFETCH(int, newCount);
+ QFETCH(int, newCurrentIndex);
+
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < startCount; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ for (int i=0; i<changes.count(); i++) {
+ switch (changes[i].type) {
+ case ListChange::Inserted:
+ {
+ QList<QPair<QString, QString> > items;
+ for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
+ items << qMakePair(QString("new item " + j), QString::number(j));
+ model.insertItems(changes[i].index, items);
+ break;
+ }
+ case ListChange::Removed:
+ model.removeItems(changes[i].index, changes[i].count);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ break;
+ case ListChange::Moved:
+ model.moveItems(changes[i].index, changes[i].to, changes[i].count);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ break;
+ case ListChange::SetCurrent:
+ gridview->setCurrentIndex(changes[i].index);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ break;
+ case ListChange::SetContentY:
+ gridview->setContentY(changes[i].pos);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ break;
+ }
+ }
+
+ QTRY_COMPARE(gridview->count(), newCount);
+ QCOMPARE(gridview->count(), model.count());
+ QTRY_COMPARE(gridview->currentIndex(), newCurrentIndex);
+
+ QQuickText *name;
+ QQuickText *number;
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i=0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QVERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::multipleChanges_data()
+{
+ QTest::addColumn<int>("startCount");
+ QTest::addColumn<QList<ListChange> >("changes");
+ QTest::addColumn<int>("newCount");
+ QTest::addColumn<int>("newCurrentIndex");
+
+ QList<ListChange> changes;
+
+ for (int i=1; i<30; i++)
+ changes << ListChange::remove(0);
+ QTest::newRow("remove all but 1, first->last") << 30 << changes << 1 << 0;
+
+ changes << ListChange::remove(0);
+ QTest::newRow("remove all") << 30 << changes << 0 << -1;
+
+ changes.clear();
+ changes << ListChange::setCurrent(29);
+ for (int i=29; i>0; i--)
+ changes << ListChange::remove(i);
+ QTest::newRow("remove last (current) -> first") << 30 << changes << 1 << 0;
+
+ QTest::newRow("remove then insert at 0") << 10 << (QList<ListChange>()
+ << ListChange::remove(0, 1)
+ << ListChange::insert(0, 1)
+ ) << 10 << 1;
+
+ QTest::newRow("remove then insert at non-zero index") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(2)
+ << ListChange::remove(2, 1)
+ << ListChange::insert(2, 1)
+ ) << 10 << 3;
+
+ QTest::newRow("remove current then insert below it") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(1)
+ << ListChange::remove(1, 3)
+ << ListChange::insert(2, 2)
+ ) << 9 << 1;
+
+ QTest::newRow("remove current index then move it down") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(2)
+ << ListChange::remove(1, 3)
+ << ListChange::move(1, 5, 1)
+ ) << 7 << 5;
+
+ QTest::newRow("remove current index then move it up") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(5)
+ << ListChange::remove(4, 3)
+ << ListChange::move(4, 1, 1)
+ ) << 7 << 1;
+
+
+ QTest::newRow("insert multiple times") << 0 << (QList<ListChange>()
+ << ListChange::insert(0, 2)
+ << ListChange::insert(0, 4)
+ << ListChange::insert(0, 6)
+ ) << 12 << 10;
+
+ QTest::newRow("insert multiple times with current index changes") << 0 << (QList<ListChange>()
+ << ListChange::insert(0, 2)
+ << ListChange::insert(0, 4)
+ << ListChange::insert(0, 6)
+ << ListChange::setCurrent(3)
+ << ListChange::insert(3, 2)
+ ) << 14 << 5;
+
+ QTest::newRow("insert and remove all") << 0 << (QList<ListChange>()
+ << ListChange::insert(0, 30)
+ << ListChange::remove(0, 30)
+ ) << 0 << -1;
+
+ QTest::newRow("insert and remove current") << 30 << (QList<ListChange>()
+ << ListChange::insert(1)
+ << ListChange::setCurrent(1)
+ << ListChange::remove(1)
+ ) << 30 << 1;
+
+ QTest::newRow("insert before 0, then remove cross section of new and old items") << 10 << (QList<ListChange>()
+ << ListChange::insert(0, 10)
+ << ListChange::remove(5, 10)
+ ) << 10 << 5;
+
+ QTest::newRow("insert multiple, then move new items to end") << 10 << (QList<ListChange>()
+ << ListChange::insert(0, 3)
+ << ListChange::move(0, 10, 3)
+ ) << 13 << 0;
+
+ QTest::newRow("insert multiple, then move new and some old items to end") << 10 << (QList<ListChange>()
+ << ListChange::insert(0, 3)
+ << ListChange::move(0, 8, 5)
+ ) << 13 << 11;
+
+ QTest::newRow("insert multiple at end, then move new and some old items to start") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(9)
+ << ListChange::insert(10, 3)
+ << ListChange::move(8, 0, 5)
+ ) << 13 << 1;
+
+
+ QTest::newRow("move back and forth to same index") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(1)
+ << ListChange::move(1, 2, 2)
+ << ListChange::move(2, 1, 2)
+ ) << 10 << 1;
+
+ QTest::newRow("move forwards then back") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(2)
+ << ListChange::move(1, 2, 3)
+ << ListChange::move(3, 0, 5)
+ ) << 10 << 0;
+
+ QTest::newRow("move current, then remove it") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(5)
+ << ListChange::move(5, 0, 1)
+ << ListChange::remove(0)
+ ) << 9 << 0;
+
+ QTest::newRow("move current, then insert before it") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(5)
+ << ListChange::move(5, 0, 1)
+ << ListChange::insert(0)
+ ) << 11 << 1;
+
+ QTest::newRow("move multiple, then remove them") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(1)
+ << ListChange::move(5, 1, 3)
+ << ListChange::remove(1, 3)
+ ) << 7 << 1;
+
+ QTest::newRow("move multiple, then insert before them") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(5)
+ << ListChange::move(5, 1, 3)
+ << ListChange::insert(1, 5)
+ ) << 15 << 6;
+
+ QTest::newRow("move multiple, then insert after them") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(3)
+ << ListChange::move(0, 1, 2)
+ << ListChange::insert(3, 5)
+ ) << 15 << 8;
+
+
+ QTest::newRow("clear current") << 0 << (QList<ListChange>()
+ << ListChange::insert(0, 5)
+ << ListChange::setCurrent(-1)
+ << ListChange::remove(0, 5)
+ << ListChange::insert(0, 5)
+ ) << 5 << -1;
+}
+
+
+void tst_QQuickGridView::swapWithFirstItem()
+{
+ // QTBUG_9697
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ // ensure content position is stable
+ gridview->setContentY(0);
+ model.moveItem(10, 0);
+ QTRY_VERIFY(gridview->contentY() == 0);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::currentIndex()
+{
+ QaimModel model;
+ for (int i = 0; i < 60; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+ canvas->show();
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ QString filename(testFile("gridview-initCurrent.qml"));
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+ QTRY_VERIFY(!QQuickItemPrivate::get(gridview)->polishScheduled);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ // current item should be third item
+ QCOMPARE(gridview->currentIndex(), 35);
+ QCOMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 35));
+ QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
+ QCOMPARE(gridview->contentY(), 400.0);
+
+ gridview->moveCurrentIndexRight();
+ QCOMPARE(gridview->currentIndex(), 36);
+ gridview->moveCurrentIndexDown();
+ QCOMPARE(gridview->currentIndex(), 39);
+ gridview->moveCurrentIndexUp();
+ QCOMPARE(gridview->currentIndex(), 36);
+ gridview->moveCurrentIndexLeft();
+ QCOMPARE(gridview->currentIndex(), 35);
+
+ // wait until motion stops
+ QTRY_VERIFY(gridview->verticalVelocity() == 0.0);
+
+ // 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);
+
+ gridview->moveCurrentIndexLeft();
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ gridview->setCurrentIndex(model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
+
+ gridview->moveCurrentIndexRight();
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
+
+ gridview->moveCurrentIndexDown();
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
+
+ // with wrap
+ gridview->setWrapEnabled(true);
+
+ gridview->setCurrentIndex(0);
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ gridview->moveCurrentIndexLeft();
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
+
+ qApp->processEvents();
+ QTRY_COMPARE(gridview->contentY(), 880.0);
+
+ gridview->moveCurrentIndexRight();
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ QTRY_COMPARE(gridview->contentY(), 0.0);
+
+
+ // footer should become visible if it is out of view, and then current index moves to the first row
+ canvas->rootObject()->setProperty("showFooter", true);
+ QTRY_VERIFY(gridview->footerItem());
+ gridview->setCurrentIndex(model.count()-3);
+ QTRY_VERIFY(gridview->footerItem()->y() > gridview->contentY() + gridview->height());
+ gridview->setCurrentIndex(model.count()-2);
+ QTRY_COMPARE(gridview->contentY() + gridview->height(), (60.0 * model.count()/3) + gridview->footerItem()->height());
+ canvas->rootObject()->setProperty("showFooter", false);
+
+ // header should become visible if it is out of view, and then current index moves to the last row
+ canvas->rootObject()->setProperty("showHeader", true);
+ QTRY_VERIFY(gridview->headerItem());
+ gridview->setCurrentIndex(3);
+ QTRY_VERIFY(gridview->headerItem()->y() + gridview->headerItem()->height() < gridview->contentY());
+ gridview->setCurrentIndex(1);
+ QTRY_COMPARE(gridview->contentY(), -gridview->headerItem()->height());
+ canvas->rootObject()->setProperty("showHeader", false);
+
+
+ // Test keys
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(qGuiApp->focusWindow() == canvas);
+
+ gridview->setCurrentIndex(0);
+
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QCOMPARE(gridview->currentIndex(), 3);
+
+ QTest::keyClick(canvas, Qt::Key_Up);
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ // hold down Key_Down
+ for (int i=0; i<(model.count() / 3) - 1; i++) {
+ QTest::simulateEvent(canvas, true, Qt::Key_Down, Qt::NoModifier, "", true);
+ QTRY_COMPARE(gridview->currentIndex(), i*3 + 3);
+ }
+ QTest::keyRelease(canvas, Qt::Key_Down);
+ QTRY_COMPARE(gridview->currentIndex(), 57);
+ QTRY_COMPARE(gridview->contentY(), 880.0);
+
+ // hold down Key_Up
+ for (int i=(model.count() / 3) - 1; i > 0; i--) {
+ QTest::simulateEvent(canvas, true, Qt::Key_Up, Qt::NoModifier, "", true);
+ QTRY_COMPARE(gridview->currentIndex(), i*3 - 3);
+ }
+ QTest::keyRelease(canvas, Qt::Key_Up);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->contentY(), 0.0);
+
+
+ gridview->setFlow(QQuickGridView::TopToBottom);
+
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QVERIFY(qGuiApp->focusWindow() == canvas);
+ qApp->processEvents();
+
+ QTest::keyClick(canvas, Qt::Key_Right);
+ QCOMPARE(gridview->currentIndex(), 5);
+
+ QTest::keyClick(canvas, Qt::Key_Left);
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QCOMPARE(gridview->currentIndex(), 1);
+
+ QTest::keyClick(canvas, Qt::Key_Up);
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ // hold down Key_Right
+ for (int i=0; i<(model.count() / 5) - 1; i++) {
+ QTest::simulateEvent(canvas, true, Qt::Key_Right, Qt::NoModifier, "", true);
+ QTRY_COMPARE(gridview->currentIndex(), i*5 + 5);
+ }
+
+ QTest::keyRelease(canvas, Qt::Key_Right);
+ QTRY_COMPARE(gridview->currentIndex(), 55);
+ QTRY_COMPARE(gridview->contentX(), 720.0);
+
+ // hold down Key_Left
+ for (int i=(model.count() / 5) - 1; i > 0; i--) {
+ QTest::simulateEvent(canvas, true, Qt::Key_Left, Qt::NoModifier, "", true);
+ QTRY_COMPARE(gridview->currentIndex(), i*5 - 5);
+ }
+ QTest::keyRelease(canvas, Qt::Key_Left);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->contentX(), 0.0);
+
+
+ // turn off auto highlight
+ gridview->setHighlightFollowsCurrentItem(false);
+ QVERIFY(gridview->highlightFollowsCurrentItem() == false);
+ QVERIFY(gridview->highlightItem());
+ qreal hlPosX = gridview->highlightItem()->x();
+ qreal hlPosY = gridview->highlightItem()->y();
+
+ gridview->setCurrentIndex(5);
+ QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX);
+ QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY);
+
+ // insert item before currentIndex
+ gridview->setCurrentIndex(28);
+ model.insertItem(0, "Foo", "1111");
+ QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
+
+ // check removing highlight by setting currentIndex to -1;
+ gridview->setCurrentIndex(-1);
+
+ QCOMPARE(gridview->currentIndex(), -1);
+ QVERIFY(!gridview->highlightItem());
+ QVERIFY(!gridview->currentItem());
+
+ gridview->setHighlightFollowsCurrentItem(true);
+
+ gridview->setFlow(QQuickGridView::LeftToRight);
+ gridview->setLayoutDirection(Qt::RightToLeft);
+
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(qGuiApp->focusWindow() == canvas);
+ qApp->processEvents();
+
+ gridview->setCurrentIndex(35);
+
+ QTest::keyClick(canvas, Qt::Key_Right);
+ QCOMPARE(gridview->currentIndex(), 34);
+
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QCOMPARE(gridview->currentIndex(), 37);
+
+ QTest::keyClick(canvas, Qt::Key_Up);
+ QCOMPARE(gridview->currentIndex(), 34);
+
+ QTest::keyClick(canvas, Qt::Key_Left);
+ QCOMPARE(gridview->currentIndex(), 35);
+
+
+ // turn off auto highlight
+ gridview->setHighlightFollowsCurrentItem(false);
+ QVERIFY(gridview->highlightFollowsCurrentItem() == false);
+ QVERIFY(gridview->highlightItem());
+ hlPosX = gridview->highlightItem()->x();
+ hlPosY = gridview->highlightItem()->y();
+
+ gridview->setCurrentIndex(5);
+ QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX);
+ QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY);
+
+ // insert item before currentIndex
+ gridview->setCurrentIndex(28);
+ model.insertItem(0, "Foo", "1111");
+ QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
+
+ // check removing highlight by setting currentIndex to -1;
+ gridview->setCurrentIndex(-1);
+
+ QCOMPARE(gridview->currentIndex(), -1);
+ QVERIFY(!gridview->highlightItem());
+ QVERIFY(!gridview->currentItem());
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::noCurrentIndex()
+{
+ QaimModel model;
+ for (int i = 0; i < 60; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ QString filename(testFile("gridview-noCurrent.qml"));
+ canvas->setSource(QUrl::fromLocalFile(filename));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ // current index should be -1
+ QCOMPARE(gridview->currentIndex(), -1);
+ QVERIFY(!gridview->currentItem());
+ QVERIFY(!gridview->highlightItem());
+ QCOMPARE(gridview->contentY(), 0.0);
+
+ gridview->setCurrentIndex(5);
+ QCOMPARE(gridview->currentIndex(), 5);
+ QVERIFY(gridview->currentItem());
+ QVERIFY(gridview->highlightItem());
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::changeFlow()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal((i%3)*80));
+ QTRY_COMPARE(item->y(), qreal((i/3)*60));
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ ctxt->setContextProperty("testTopToBottom", QVariant(true));
+
+ // Confirm items positioned correctly and indexes correct
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal((i/5)*80));
+ QTRY_COMPARE(item->y(), qreal((i%5)*60));
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ ctxt->setContextProperty("testRightToLeft", QVariant(true));
+
+ // Confirm items positioned correctly and indexes correct
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal(-(i/5)*80 - item->width()));
+ QTRY_COMPARE(item->y(), qreal((i%5)*60));
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+ gridview->setContentX(100);
+ QTRY_COMPARE(gridview->contentX(), 100.);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+ QTRY_COMPARE(gridview->contentX(), 0.);
+
+ // Confirm items positioned correctly and indexes correct
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal(240 - (i%3+1)*80));
+ QTRY_COMPARE(item->y(), qreal((i/3)*60));
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::defaultValues()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("gridview3.qml"));
+ QQuickGridView *obj = qobject_cast<QQuickGridView*>(c.create());
+
+ QTRY_VERIFY(obj != 0);
+ QTRY_VERIFY(obj->model() == QVariant());
+ QTRY_VERIFY(obj->delegate() == 0);
+ QTRY_COMPARE(obj->currentIndex(), -1);
+ QTRY_VERIFY(obj->currentItem() == 0);
+ QTRY_COMPARE(obj->count(), 0);
+ QTRY_VERIFY(obj->highlight() == 0);
+ QTRY_VERIFY(obj->highlightItem() == 0);
+ QTRY_COMPARE(obj->highlightFollowsCurrentItem(), true);
+ QTRY_VERIFY(obj->flow() == 0);
+ QTRY_COMPARE(obj->isWrapEnabled(), false);
+ QTRY_COMPARE(obj->cacheBuffer(), 0);
+ QTRY_COMPARE(obj->cellWidth(), qreal(100)); //### Should 100 be the default?
+ QTRY_COMPARE(obj->cellHeight(), qreal(100));
+ delete obj;
+}
+
+void tst_QQuickGridView::properties()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("gridview2.qml"));
+ QQuickGridView *obj = qobject_cast<QQuickGridView*>(c.create());
+
+ QTRY_VERIFY(obj != 0);
+ QTRY_VERIFY(obj->model() != QVariant());
+ QTRY_VERIFY(obj->delegate() != 0);
+ QTRY_COMPARE(obj->currentIndex(), 0);
+ QTRY_VERIFY(obj->currentItem() != 0);
+ QTRY_COMPARE(obj->count(), 4);
+ QTRY_VERIFY(obj->highlight() != 0);
+ QTRY_VERIFY(obj->highlightItem() != 0);
+ QTRY_COMPARE(obj->highlightFollowsCurrentItem(), false);
+ QTRY_VERIFY(obj->flow() == 0);
+ QTRY_COMPARE(obj->isWrapEnabled(), true);
+ QTRY_COMPARE(obj->cacheBuffer(), 200);
+ QTRY_COMPARE(obj->cellWidth(), qreal(100));
+ QTRY_COMPARE(obj->cellHeight(), qreal(100));
+ delete obj;
+}
+
+void tst_QQuickGridView::propertyChanges()
+{
+ QQuickView *canvas = createView();
+ QTRY_VERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
+
+ QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView");
+ QTRY_VERIFY(gridView);
+
+ QSignalSpy keyNavigationWrapsSpy(gridView, SIGNAL(keyNavigationWrapsChanged()));
+ QSignalSpy cacheBufferSpy(gridView, SIGNAL(cacheBufferChanged()));
+ QSignalSpy layoutSpy(gridView, SIGNAL(layoutDirectionChanged()));
+ QSignalSpy flowSpy(gridView, SIGNAL(flowChanged()));
+
+ QTRY_COMPARE(gridView->isWrapEnabled(), true);
+ QTRY_COMPARE(gridView->cacheBuffer(), 10);
+ QTRY_COMPARE(gridView->flow(), QQuickGridView::LeftToRight);
+
+ gridView->setWrapEnabled(false);
+ gridView->setCacheBuffer(3);
+ gridView->setFlow(QQuickGridView::TopToBottom);
+
+ QTRY_COMPARE(gridView->isWrapEnabled(), false);
+ QTRY_COMPARE(gridView->cacheBuffer(), 3);
+ QTRY_COMPARE(gridView->flow(), QQuickGridView::TopToBottom);
+
+ QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
+ QTRY_COMPARE(cacheBufferSpy.count(),1);
+ QTRY_COMPARE(flowSpy.count(),1);
+
+ gridView->setWrapEnabled(false);
+ gridView->setCacheBuffer(3);
+ gridView->setFlow(QQuickGridView::TopToBottom);
+
+ QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
+ QTRY_COMPARE(cacheBufferSpy.count(),1);
+ QTRY_COMPARE(flowSpy.count(),1);
+
+ gridView->setFlow(QQuickGridView::LeftToRight);
+ QTRY_COMPARE(gridView->flow(), QQuickGridView::LeftToRight);
+
+ gridView->setWrapEnabled(true);
+ gridView->setCacheBuffer(5);
+ gridView->setLayoutDirection(Qt::RightToLeft);
+
+ QTRY_COMPARE(gridView->isWrapEnabled(), true);
+ QTRY_COMPARE(gridView->cacheBuffer(), 5);
+ QTRY_COMPARE(gridView->layoutDirection(), Qt::RightToLeft);
+
+ QTRY_COMPARE(keyNavigationWrapsSpy.count(),2);
+ QTRY_COMPARE(cacheBufferSpy.count(),2);
+ QTRY_COMPARE(layoutSpy.count(),1);
+ QTRY_COMPARE(flowSpy.count(),2);
+
+ gridView->setWrapEnabled(true);
+ gridView->setCacheBuffer(5);
+ gridView->setLayoutDirection(Qt::RightToLeft);
+
+ QTRY_COMPARE(keyNavigationWrapsSpy.count(),2);
+ QTRY_COMPARE(cacheBufferSpy.count(),2);
+ QTRY_COMPARE(layoutSpy.count(),1);
+ QTRY_COMPARE(flowSpy.count(),2);
+
+ gridView->setFlow(QQuickGridView::TopToBottom);
+ QTRY_COMPARE(gridView->flow(), QQuickGridView::TopToBottom);
+ QTRY_COMPARE(flowSpy.count(),3);
+
+ gridView->setFlow(QQuickGridView::TopToBottom);
+ QTRY_COMPARE(flowSpy.count(),3);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::componentChanges()
+{
+ QQuickView *canvas = createView();
+ QTRY_VERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
+
+ QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView");
+ QTRY_VERIFY(gridView);
+
+ QQmlComponent component(canvas->engine());
+ component.setData("import QtQuick 2.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile(""));
+
+ QQmlComponent delegateComponent(canvas->engine());
+ delegateComponent.setData("import QtQuick 2.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
+
+ QSignalSpy highlightSpy(gridView, SIGNAL(highlightChanged()));
+ QSignalSpy delegateSpy(gridView, SIGNAL(delegateChanged()));
+ QSignalSpy headerSpy(gridView, SIGNAL(headerChanged()));
+ QSignalSpy footerSpy(gridView, SIGNAL(footerChanged()));
+
+ gridView->setHighlight(&component);
+ gridView->setDelegate(&delegateComponent);
+ gridView->setHeader(&component);
+ gridView->setFooter(&component);
+
+ QTRY_COMPARE(gridView->highlight(), &component);
+ QTRY_COMPARE(gridView->delegate(), &delegateComponent);
+ QTRY_COMPARE(gridView->header(), &component);
+ QTRY_COMPARE(gridView->footer(), &component);
+
+ QTRY_COMPARE(highlightSpy.count(),1);
+ QTRY_COMPARE(delegateSpy.count(),1);
+ QTRY_COMPARE(headerSpy.count(),1);
+ QTRY_COMPARE(footerSpy.count(),1);
+
+ gridView->setHighlight(&component);
+ gridView->setDelegate(&delegateComponent);
+ gridView->setHeader(&component);
+ gridView->setFooter(&component);
+
+ QTRY_COMPARE(highlightSpy.count(),1);
+ QTRY_COMPARE(delegateSpy.count(),1);
+ QTRY_COMPARE(headerSpy.count(),1);
+ QTRY_COMPARE(footerSpy.count(),1);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::modelChanges()
+{
+ QQuickView *canvas = createView();
+ QTRY_VERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
+
+ QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView");
+ QTRY_VERIFY(gridView);
+
+ QQuickListModel *alternateModel = canvas->rootObject()->findChild<QQuickListModel*>("alternateModel");
+ QTRY_VERIFY(alternateModel);
+ QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
+ QSignalSpy modelSpy(gridView, SIGNAL(modelChanged()));
+
+ gridView->setModel(modelVariant);
+ QTRY_COMPARE(gridView->model(), modelVariant);
+ QTRY_COMPARE(modelSpy.count(),1);
+
+ gridView->setModel(modelVariant);
+ QTRY_COMPARE(modelSpy.count(),1);
+
+ gridView->setModel(QVariant());
+ QTRY_COMPARE(modelSpy.count(),2);
+ delete canvas;
+}
+
+void tst_QQuickGridView::positionViewAtIndex()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.);
+ QTRY_COMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position on a currently visible item
+ gridview->positionViewAtIndex(4, QQuickGridView::Beginning);
+ QTRY_COMPARE(gridview->indexAt(120, 90), 4);
+ QTRY_COMPARE(gridview->contentY(), 60.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.);
+ QTRY_COMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position on an item beyond the visible items
+ gridview->positionViewAtIndex(21, QQuickGridView::Beginning);
+ QTRY_COMPARE(gridview->indexAt(40, 450), 21);
+ QTRY_COMPARE(gridview->contentY(), 420.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.);
+ QTRY_COMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position on an item that would leave empty space if positioned at the top
+ gridview->positionViewAtIndex(31, QQuickGridView::Beginning);
+ QTRY_COMPARE(gridview->indexAt(120, 630), 31);
+ QTRY_COMPARE(gridview->contentY(), 520.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.);
+ QTRY_COMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position at the beginning again
+ gridview->positionViewAtIndex(0, QQuickGridView::Beginning);
+ QTRY_COMPARE(gridview->indexAt(0, 0), 0);
+ QTRY_COMPARE(gridview->indexAt(40, 30), 0);
+ QTRY_COMPARE(gridview->indexAt(80, 60), 4);
+ QTRY_COMPARE(gridview->contentY(), 0.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.);
+ QTRY_COMPARE(item->y(), (i/3)*60.);
+ }
+
+ // Position at End
+ gridview->positionViewAtIndex(30, QQuickGridView::End);
+ QTRY_COMPARE(gridview->contentY(), 340.);
+
+ // Position in Center
+ gridview->positionViewAtIndex(15, QQuickGridView::Center);
+ QTRY_COMPARE(gridview->contentY(), 170.);
+
+ // Ensure at least partially visible
+ gridview->positionViewAtIndex(15, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentY(), 170.);
+
+ gridview->setContentY(302);
+ gridview->positionViewAtIndex(15, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentY(), 302.);
+
+ gridview->setContentY(360);
+ gridview->positionViewAtIndex(15, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentY(), 300.);
+
+ gridview->setContentY(60);
+ gridview->positionViewAtIndex(20, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentY(), 60.);
+
+ gridview->setContentY(20);
+ gridview->positionViewAtIndex(20, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentY(), 100.);
+
+ // Ensure completely visible
+ gridview->setContentY(120);
+ gridview->positionViewAtIndex(20, QQuickGridView::Contain);
+ QTRY_COMPARE(gridview->contentY(), 120.);
+
+ gridview->setContentY(302);
+ gridview->positionViewAtIndex(15, QQuickGridView::Contain);
+ QTRY_COMPARE(gridview->contentY(), 300.);
+
+ gridview->setContentY(60);
+ gridview->positionViewAtIndex(20, QQuickGridView::Contain);
+ QTRY_COMPARE(gridview->contentY(), 100.);
+
+ // Test for Top To Bottom layout
+ ctxt->setContextProperty("testTopToBottom", QVariant(true));
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), (i/5)*80.);
+ QTRY_COMPARE(item->y(), (i%5)*60.);
+ }
+
+ // Position at End
+ gridview->positionViewAtIndex(30, QQuickGridView::End);
+ QTRY_COMPARE(gridview->contentX(), 320.);
+ QTRY_COMPARE(gridview->contentY(), 0.);
+
+ // Position in Center
+ gridview->positionViewAtIndex(15, QQuickGridView::Center);
+ QTRY_COMPARE(gridview->contentX(), 160.);
+
+ // Ensure at least partially visible
+ gridview->positionViewAtIndex(15, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentX(), 160.);
+
+ gridview->setContentX(170);
+ gridview->positionViewAtIndex(25, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentX(), 170.);
+
+ gridview->positionViewAtIndex(30, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentX(), 320.);
+
+ gridview->setContentX(170);
+ gridview->positionViewAtIndex(25, QQuickGridView::Contain);
+ QTRY_COMPARE(gridview->contentX(), 240.);
+
+ // positionViewAtBeginning
+ gridview->positionViewAtBeginning();
+ QTRY_COMPARE(gridview->contentX(), 0.);
+
+ gridview->setContentX(80);
+ canvas->rootObject()->setProperty("showHeader", true);
+ gridview->positionViewAtBeginning();
+ QTRY_COMPARE(gridview->contentX(), -30.);
+
+ // positionViewAtEnd
+ gridview->positionViewAtEnd();
+ QTRY_COMPARE(gridview->contentX(), 400.); // 8*80 - 240 (8 columns)
+
+ gridview->setContentX(80);
+ canvas->rootObject()->setProperty("showFooter", true);
+ gridview->positionViewAtEnd();
+ QTRY_COMPARE(gridview->contentX(), 430.);
+
+ // set current item to outside visible view, position at beginning
+ // and ensure highlight moves to current item
+ gridview->setCurrentIndex(6);
+ gridview->positionViewAtBeginning();
+ QTRY_COMPARE(gridview->contentX(), -30.);
+ QVERIFY(gridview->highlightItem());
+ QCOMPARE(gridview->highlightItem()->x(), 80.);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::snapping()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ gridview->setHeight(220);
+ QCOMPARE(gridview->height(), 220.);
+
+ gridview->positionViewAtIndex(12, QQuickGridView::Visible);
+ QCOMPARE(gridview->contentY(), 80.);
+
+ gridview->setContentY(0);
+ QCOMPARE(gridview->contentY(), 0.);
+
+ gridview->setSnapMode(QQuickGridView::SnapToRow);
+ QCOMPARE(gridview->snapMode(), QQuickGridView::SnapToRow);
+
+ gridview->positionViewAtIndex(12, QQuickGridView::Visible);
+ QCOMPARE(gridview->contentY(), 60.);
+
+ gridview->positionViewAtIndex(15, QQuickGridView::End);
+ QCOMPARE(gridview->contentY(), 120.);
+
+ delete canvas;
+
+}
+
+void tst_QQuickGridView::mirroring()
+{
+ QQuickView *canvasA = createView();
+ canvasA->setSource(testFileUrl("mirroring.qml"));
+ QQuickGridView *gridviewA = findItem<QQuickGridView>(canvasA->rootObject(), "view");
+ QTRY_VERIFY(gridviewA != 0);
+
+ QQuickView *canvasB = createView();
+ canvasB->setSource(testFileUrl("mirroring.qml"));
+ QQuickGridView *gridviewB = findItem<QQuickGridView>(canvasB->rootObject(), "view");
+ QTRY_VERIFY(gridviewA != 0);
+ qApp->processEvents();
+
+ QList<QString> objectNames;
+ objectNames << "item1" << "item2"; // << "item3"
+
+ gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
+ gridviewB->setProperty("layoutDirection", Qt::RightToLeft);
+ QCOMPARE(gridviewA->layoutDirection(), gridviewA->effectiveLayoutDirection());
+
+ // LTR != RTL
+ foreach (const QString objectName, objectNames)
+ QVERIFY(findItem<QQuickItem>(gridviewA, objectName)->x() != findItem<QQuickItem>(gridviewB, objectName)->x());
+
+ gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
+ gridviewB->setProperty("layoutDirection", Qt::LeftToRight);
+
+ // LTR == LTR
+ foreach (const QString objectName, objectNames)
+ QCOMPARE(findItem<QQuickItem>(gridviewA, objectName)->x(), findItem<QQuickItem>(gridviewB, objectName)->x());
+
+ QVERIFY(gridviewB->layoutDirection() == gridviewB->effectiveLayoutDirection());
+ QQuickItemPrivate::get(gridviewB)->setLayoutMirror(true);
+ QVERIFY(gridviewB->layoutDirection() != gridviewB->effectiveLayoutDirection());
+
+ // LTR != LTR+mirror
+ foreach (const QString objectName, objectNames)
+ QVERIFY(findItem<QQuickItem>(gridviewA, objectName)->x() != findItem<QQuickItem>(gridviewB, objectName)->x());
+
+ gridviewA->setProperty("layoutDirection", Qt::RightToLeft);
+
+ // RTL == LTR+mirror
+ foreach (const QString objectName, objectNames)
+ QCOMPARE(findItem<QQuickItem>(gridviewA, objectName)->x(), findItem<QQuickItem>(gridviewB, objectName)->x());
+
+ gridviewB->setProperty("layoutDirection", Qt::RightToLeft);
+
+ // RTL != RTL+mirror
+ foreach (const QString objectName, objectNames)
+ QVERIFY(findItem<QQuickItem>(gridviewA, objectName)->x() != findItem<QQuickItem>(gridviewB, objectName)->x());
+
+ gridviewA->setProperty("layoutDirection", Qt::LeftToRight);
+
+ // LTR == RTL+mirror
+ foreach (const QString objectName, objectNames)
+ QCOMPARE(findItem<QQuickItem>(gridviewA, objectName)->x(), findItem<QQuickItem>(gridviewB, objectName)->x());
+
+ delete canvasA;
+ delete canvasB;
+}
+
+void tst_QQuickGridView::positionViewAtIndex_rightToLeft()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testTopToBottom", QVariant(true));
+ ctxt->setContextProperty("testRightToLeft", QVariant(true));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
+ QTRY_COMPARE(item->y(), qreal((i%5)*60));
+ }
+
+ // Position on a currently visible item
+ gridview->positionViewAtIndex(6, QQuickGridView::Beginning);
+ QTRY_COMPARE(gridview->contentX(), -320.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
+ QTRY_COMPARE(item->y(), qreal((i%5)*60));
+ }
+
+ // Position on an item beyond the visible items
+ gridview->positionViewAtIndex(21, QQuickGridView::Beginning);
+ QTRY_COMPARE(gridview->contentX(), -560.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
+ QTRY_COMPARE(item->y(), qreal((i%5)*60));
+ }
+
+ // Position on an item that would leave empty space if positioned at the top
+ gridview->positionViewAtIndex(31, QQuickGridView::Beginning);
+ QTRY_COMPARE(gridview->contentX(), -640.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
+ QTRY_COMPARE(item->y(), qreal((i%5)*60));
+ }
+
+ // Position at the beginning again
+ gridview->positionViewAtIndex(0, QQuickGridView::Beginning);
+ QTRY_COMPARE(gridview->contentX(), -240.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width()));
+ QTRY_COMPARE(item->y(), qreal((i%5)*60));
+ }
+
+ // Position at End
+ gridview->positionViewAtIndex(30, QQuickGridView::End);
+ QTRY_COMPARE(gridview->contentX(), -560.);
+
+ // Position in Center
+ gridview->positionViewAtIndex(15, QQuickGridView::Center);
+ QTRY_COMPARE(gridview->contentX(), -400.);
+
+ // Ensure at least partially visible
+ gridview->positionViewAtIndex(15, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentX(), -400.);
+
+ gridview->setContentX(-555.);
+ gridview->positionViewAtIndex(15, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentX(), -555.);
+
+ gridview->setContentX(-239);
+ gridview->positionViewAtIndex(15, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentX(), -320.);
+
+ gridview->setContentX(-239);
+ gridview->positionViewAtIndex(20, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentX(), -400.);
+
+ gridview->setContentX(-640);
+ gridview->positionViewAtIndex(20, QQuickGridView::Visible);
+ QTRY_COMPARE(gridview->contentX(), -560.);
+
+ // Ensure completely visible
+ gridview->setContentX(-400);
+ gridview->positionViewAtIndex(20, QQuickGridView::Contain);
+ QTRY_COMPARE(gridview->contentX(), -400.);
+
+ gridview->setContentX(-315);
+ gridview->positionViewAtIndex(15, QQuickGridView::Contain);
+ QTRY_COMPARE(gridview->contentX(), -320.);
+
+ gridview->setContentX(-640);
+ gridview->positionViewAtIndex(20, QQuickGridView::Contain);
+ QTRY_COMPARE(gridview->contentX(), -560.);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::resetModel()
+{
+ QQuickView *canvas = createView();
+
+ QStringList strings;
+ strings << "one" << "two" << "three";
+ QStringListModel model(strings);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("displaygrid.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QTRY_COMPARE(gridview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QQuickText *display = findItem<QQuickText>(contentItem, "displayText", i);
+ QTRY_VERIFY(display != 0);
+ QTRY_COMPARE(display->text(), strings.at(i));
+ }
+
+ strings.clear();
+ strings << "four" << "five" << "six" << "seven";
+ model.setStringList(strings);
+
+ QTRY_COMPARE(gridview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QQuickText *display = findItem<QQuickText>(contentItem, "displayText", i);
+ QTRY_VERIFY(display != 0);
+ QTRY_COMPARE(display->text(), strings.at(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::enforceRange()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview-enforcerange.qml"));
+ canvas->show();
+ qApp->processEvents();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QTRY_COMPARE(gridview->preferredHighlightBegin(), 100.0);
+ QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0);
+ QTRY_COMPARE(gridview->highlightRangeMode(), QQuickGridView::StrictlyEnforceRange);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // view should be positioned at the top of the range.
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(gridview->contentY(), -100.0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 0);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 0);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
+
+ // Check currentIndex is updated when contentItem moves
+ gridview->setContentY(0);
+ QTRY_COMPARE(gridview->currentIndex(), 2);
+
+ gridview->setCurrentIndex(5);
+ QTRY_COMPARE(gridview->contentY(), 100.);
+
+ QaimModel model2;
+ for (int i = 0; i < 5; i++)
+ model2.addItem("Item" + QString::number(i), "");
+
+ ctxt->setContextProperty("testModel", &model2);
+ QCOMPARE(gridview->count(), 5);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::enforceRange_rightToLeft()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(true));
+ ctxt->setContextProperty("testTopToBottom", QVariant(true));
+
+ canvas->setSource(testFileUrl("gridview-enforcerange.qml"));
+ qApp->processEvents();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QCOMPARE(gridview->preferredHighlightBegin(), 100.0);
+ QCOMPARE(gridview->preferredHighlightEnd(), 100.0);
+ QCOMPARE(gridview->highlightRangeMode(), QQuickGridView::StrictlyEnforceRange);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ // view should be positioned at the top of the range.
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QTRY_COMPARE(gridview->contentX(), -140.);
+ QTRY_COMPARE(gridview->contentY(), 0.0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 0);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 0);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
+
+ // Check currentIndex is updated when contentItem moves
+ gridview->setContentX(-240);
+ QTRY_COMPARE(gridview->currentIndex(), 3);
+
+ gridview->setCurrentIndex(7);
+ QTRY_COMPARE(gridview->contentX(), -340.);
+ QTRY_COMPARE(gridview->contentY(), 0.0);
+
+ QaimModel model2;
+ for (int i = 0; i < 5; i++)
+ model2.addItem("Item" + QString::number(i), "");
+
+ ctxt->setContextProperty("testModel", &model2);
+ QCOMPARE(gridview->count(), 5);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::QTBUG_8456()
+{
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("setindex.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QTRY_COMPARE(gridview->currentIndex(), 0);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::manualHighlight()
+{
+ QQuickView *canvas = createView();
+
+ QString filename(testFile("manual-highlight.qml"));
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
+ QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
+ QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
+
+ gridview->setCurrentIndex(2);
+
+ QTRY_COMPARE(gridview->currentIndex(), 2);
+ QTRY_COMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
+ QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
+ QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
+
+ gridview->positionViewAtIndex(8, QQuickGridView::Contain);
+
+ QTRY_COMPARE(gridview->currentIndex(), 2);
+ QTRY_COMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
+ QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
+ QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
+
+ gridview->setFlow(QQuickGridView::TopToBottom);
+ QTRY_COMPARE(gridview->flow(), QQuickGridView::TopToBottom);
+
+ gridview->setCurrentIndex(0);
+ QTRY_COMPARE(gridview->currentIndex(), 0);
+ QTRY_COMPARE(gridview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
+ QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y());
+ QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x());
+
+ delete canvas;
+}
+
+
+void tst_QQuickGridView::footer()
+{
+ QFETCH(QQuickGridView::Flow, flow);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(QPointF, initialFooterPos);
+ QFETCH(QPointF, changedFooterPos);
+ QFETCH(QPointF, initialContentPos);
+ QFETCH(QPointF, changedContentPos);
+ QFETCH(QPointF, firstDelegatePos);
+ QFETCH(QPointF, resizeContentPos);
+
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ for (int i = 0; i < 7; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("footer.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ gridview->setFlow(flow);
+ gridview->setLayoutDirection(layoutDirection);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickText *footer = findItem<QQuickText>(contentItem, "footer");
+ QVERIFY(footer);
+
+ QVERIFY(footer == gridview->footerItem());
+
+ QCOMPARE(footer->pos(), initialFooterPos);
+ QCOMPARE(footer->width(), 100.);
+ QCOMPARE(footer->height(), 30.);
+ QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->pos(), firstDelegatePos);
+
+ if (flow == QQuickGridView::LeftToRight) {
+ // shrink by one row
+ model.removeItem(2);
+ QTRY_COMPARE(footer->y(), initialFooterPos.y() - gridview->cellHeight());
+ } else {
+ // shrink by one column
+ model.removeItem(2);
+ model.removeItem(3);
+ if (layoutDirection == Qt::LeftToRight)
+ QTRY_COMPARE(footer->x(), initialFooterPos.x() - gridview->cellWidth());
+ else
+ QTRY_COMPARE(footer->x(), initialFooterPos.x() + gridview->cellWidth());
+ }
+
+ // remove all items
+ model.clear();
+
+ QPointF posWhenNoItems(0, 0);
+ if (layoutDirection == Qt::RightToLeft)
+ posWhenNoItems.setX(flow == QQuickGridView::LeftToRight ? gridview->width() - footer->width() : -footer->width());
+ QTRY_COMPARE(footer->pos(), posWhenNoItems);
+
+ // if header is present, it's at a negative pos, so the footer should not move
+ canvas->rootObject()->setProperty("showHeader", true);
+ QVERIFY(findItem<QQuickItem>(contentItem, "header") != 0);
+ QTRY_COMPARE(footer->pos(), posWhenNoItems);
+ canvas->rootObject()->setProperty("showHeader", false);
+
+ // add 30 items
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QSignalSpy footerItemSpy(gridview, SIGNAL(footerItemChanged()));
+ QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter");
+
+ QCOMPARE(footerItemSpy.count(), 1);
+
+ footer = findItem<QQuickText>(contentItem, "footer");
+ QVERIFY(!footer);
+ footer = findItem<QQuickText>(contentItem, "footer2");
+ QVERIFY(footer);
+
+ QVERIFY(footer == gridview->footerItem());
+
+ QCOMPARE(footer->pos(), changedFooterPos);
+ QCOMPARE(footer->width(), 50.);
+ QCOMPARE(footer->height(), 20.);
+ QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), changedContentPos);
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->pos(), firstDelegatePos);
+
+ gridview->positionViewAtEnd();
+ footer->setHeight(10);
+ footer->setWidth(40);
+ QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), resizeContentPos);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::footer_data()
+{
+ QTest::addColumn<QQuickGridView::Flow>("flow");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<QPointF>("initialFooterPos");
+ QTest::addColumn<QPointF>("changedFooterPos");
+ QTest::addColumn<QPointF>("initialContentPos");
+ QTest::addColumn<QPointF>("changedContentPos");
+ QTest::addColumn<QPointF>("firstDelegatePos");
+ QTest::addColumn<QPointF>("resizeContentPos");
+
+ // footer1 = 100 x 30
+ // footer2 = 50 x 20
+ // cells = 80 * 60
+ // view width = 240
+ // view height = 320
+
+ // footer below items, bottom left
+ QTest::newRow("flow left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight
+ << QPointF(0, 3 * 60) // 180 = height of 3 rows (cell height is 60)
+ << QPointF(0, 10 * 60) // 30 items = 10 rows
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 10 * 60 - 320 + 10);
+
+ // footer below items, bottom right
+ QTest::newRow("flow left to right, layout right to left") << QQuickGridView::LeftToRight << Qt::RightToLeft
+ << QPointF(240 - 100, 3 * 60)
+ << QPointF((240 - 100) + 50, 10 * 60) // 50 = width diff between old and new footers
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(240 - 80, 0)
+ << QPointF(0, 10 * 60 - 320 + 10);
+
+ // footer to right of items
+ QTest::newRow("flow top to bottom, layout left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight
+ << QPointF(2 * 80, 0) // 2 columns, cell width 80
+ << QPointF(6 * 80, 0) // 30 items = 6 columns
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(6 * 80 - 240 + 40, 0);
+
+ // footer to left of items
+ QTest::newRow("flow top to bottom, layout right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft
+ << QPointF(-(2 * 80) - 100, 0)
+ << QPointF(-(6 * 80) - 50, 0) // 50 = new footer width
+ << QPointF(-240, 0)
+ << QPointF(-240, 0) // unchanged, footer change doesn't change content pos
+ << QPointF(-80, 0)
+ << QPointF(-(6 * 80) - 40, 0);
+}
+
+void tst_QQuickGridView::header()
+{
+ QFETCH(QQuickGridView::Flow, flow);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(QPointF, initialHeaderPos);
+ QFETCH(QPointF, changedHeaderPos);
+ QFETCH(QPointF, initialContentPos);
+ QFETCH(QPointF, changedContentPos);
+ QFETCH(QPointF, firstDelegatePos);
+ QFETCH(QPointF, resizeContentPos);
+
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQuickView *canvas = createView();
+ canvas->rootContext()->setContextProperty("testModel", &model);
+ canvas->rootContext()->setContextProperty("initialViewWidth", 240);
+ canvas->rootContext()->setContextProperty("initialViewHeight", 320);
+ canvas->setSource(testFileUrl("header.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ gridview->setFlow(flow);
+ gridview->setLayoutDirection(layoutDirection);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickText *header = findItem<QQuickText>(contentItem, "header");
+ QVERIFY(header);
+
+ QVERIFY(header == gridview->headerItem());
+
+ QCOMPARE(header->pos(), initialHeaderPos);
+ QCOMPARE(header->width(), 100.);
+ QCOMPARE(header->height(), 30.);
+ QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->pos(), firstDelegatePos);
+
+ model.clear();
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QCOMPARE(header->pos(), initialHeaderPos); // header should stay where it is
+
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QSignalSpy headerItemSpy(gridview, SIGNAL(headerItemChanged()));
+ QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader");
+
+ QCOMPARE(headerItemSpy.count(), 1);
+
+ header = findItem<QQuickText>(contentItem, "header");
+ QVERIFY(!header);
+ header = findItem<QQuickText>(contentItem, "header2");
+ QVERIFY(header);
+
+ QVERIFY(header == gridview->headerItem());
+
+ QCOMPARE(header->pos(), changedHeaderPos);
+ QCOMPARE(header->width(), 50.);
+ QCOMPARE(header->height(), 20.);
+ QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), changedContentPos);
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->pos(), firstDelegatePos);
+
+ header->setHeight(10);
+ header->setWidth(40);
+ QTRY_COMPARE(QPointF(gridview->contentX(), gridview->contentY()), resizeContentPos);
+
+ delete canvas;
+
+
+ // QTBUG-21207 header should become visible if view resizes from initial empty size
+
+ canvas = createView();
+ canvas->rootContext()->setContextProperty("testModel", &model);
+ canvas->rootContext()->setContextProperty("initialViewWidth", 240);
+ canvas->rootContext()->setContextProperty("initialViewHeight", 320);
+ canvas->setSource(testFileUrl("header.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ gridview->setFlow(flow);
+ gridview->setLayoutDirection(layoutDirection);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ gridview->setWidth(240);
+ gridview->setHeight(320);
+ QTRY_COMPARE(gridview->headerItem()->pos(), initialHeaderPos);
+ QCOMPARE(QPointF(gridview->contentX(), gridview->contentY()), initialContentPos);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::header_data()
+{
+ QTest::addColumn<QQuickGridView::Flow>("flow");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<QPointF>("initialHeaderPos");
+ QTest::addColumn<QPointF>("changedHeaderPos");
+ QTest::addColumn<QPointF>("initialContentPos");
+ QTest::addColumn<QPointF>("changedContentPos");
+ QTest::addColumn<QPointF>("firstDelegatePos");
+ QTest::addColumn<QPointF>("resizeContentPos");
+
+ // header1 = 100 x 30
+ // header2 = 50 x 20
+ // cells = 80 x 60
+ // view width = 240
+
+ // header above items, top left
+ QTest::newRow("flow left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight
+ << QPointF(0, -30)
+ << QPointF(0, -20)
+ << QPointF(0, -30)
+ << QPointF(0, -20)
+ << QPointF(0, 0)
+ << QPointF(0, -10);
+
+ // header above items, top right
+ QTest::newRow("flow left to right, layout right to left") << QQuickGridView::LeftToRight << Qt::RightToLeft
+ << QPointF(240 - 100, -30)
+ << QPointF((240 - 100) + 50, -20) // 50 = width diff between old and new headers
+ << QPointF(0, -30)
+ << QPointF(0, -20)
+ << QPointF(160, 0)
+ << QPointF(0, -10);
+
+ // header to left of items
+ QTest::newRow("flow top to bottom, layout left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight
+ << QPointF(-100, 0)
+ << QPointF(-50, 0)
+ << QPointF(-100, 0)
+ << QPointF(-50, 0)
+ << QPointF(0, 0)
+ << QPointF(-40, 0);
+
+ // header to right of items
+ QTest::newRow("flow top to bottom, layout right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(-(240 - 100), 0)
+ << QPointF(-(240 - 50), 0)
+ << QPointF(-80, 0)
+ << QPointF(-(240 - 40), 0);
+}
+
+void tst_QQuickGridView::resizeViewAndRepaint()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("initialWidth", 240);
+ ctxt->setContextProperty("initialHeight", 100);
+
+ canvas->setSource(testFileUrl("resizeview.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ // item at index 10 should not be currently visible
+ QVERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
+
+ gridview->setHeight(320);
+ QTRY_VERIFY(findItem<QQuickItem>(contentItem, "wrapper", 10));
+
+ gridview->setHeight(100);
+ QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
+
+ // Ensure we handle -ve sizes
+ gridview->setHeight(-100);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 3);
+
+ gridview->setCacheBuffer(120);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 9);
+
+ // ensure items in cache become visible
+ gridview->setHeight(120);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 15);
+
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal((i%3)*80));
+ QTRY_COMPARE(item->y(), qreal((i/3)*60));
+ QCOMPARE(item->isVisible(), i < 9); // inside view visible, outside not visible
+ }
+
+ // ensure items outside view become invisible
+ gridview->setHeight(60);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 12);
+
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), qreal((i%3)*80));
+ QTRY_COMPARE(item->y(), qreal((i/3)*60));
+ QCOMPARE(item->isVisible(), i < 6); // inside view visible, outside not visible
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::changeColumnCount()
+{
+ QmlListModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("initialWidth", 100);
+ ctxt->setContextProperty("initialHeight", 320);
+ canvas->setSource(testFileUrl("resizeview.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ // a single column of 6 items are visible
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ QCOMPARE(itemCount, 6);
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), 0.0);
+ QCOMPARE(item->y(), qreal(i*60));
+ }
+
+ // now 6x3 grid is visible, plus 1 extra below for refill
+ gridview->setWidth(240);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ QCOMPARE(itemCount, 6*3 + 1);
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), qreal((i%3)*80));
+ QCOMPARE(item->y(), qreal((i/3)*60));
+ }
+
+ // back to single column
+ gridview->setWidth(100);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ QCOMPARE(itemCount, 6);
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), 0.0);
+ QCOMPARE(item->y(), qreal(i*60));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::indexAt_itemAt_data()
+{
+ QTest::addColumn<qreal>("x");
+ QTest::addColumn<qreal>("y");
+ QTest::addColumn<int>("index");
+
+ QTest::newRow("Item 0 - 0, 0") << 0. << 0. << 0;
+ QTest::newRow("Item 0 - 79, 59") << 79. << 59. << 0;
+ QTest::newRow("Item 1 - 80, 0") << 80. << 0. << 1;
+ QTest::newRow("Item 3 - 0, 60") << 0. << 60. << 3;
+ QTest::newRow("No Item - 240, 0") << 240. << 0. << -1;
+}
+
+void tst_QQuickGridView::indexAt_itemAt()
+{
+ QFETCH(qreal, x);
+ QFETCH(qreal, y);
+ QFETCH(int, index);
+
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Billy", "22345");
+ model.addItem("Sam", "2945");
+ model.addItem("Ben", "04321");
+ model.addItem("Jim", "0780");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(gridview->count(), model.count());
+
+ QQuickItem *item = 0;
+ if (index >= 0) {
+ item = findItem<QQuickItem>(contentItem, "wrapper", index);
+ QVERIFY(item);
+ }
+ QCOMPARE(gridview->indexAt(x, y), index);
+ QVERIFY(gridview->itemAt(x, y) == item);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::onAdd()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(int, itemsToAdd);
+
+ const int delegateWidth = 50;
+ const int delegateHeight = 100;
+ QaimModel model;
+ QQuickView *canvas = createView();
+ canvas->setGeometry(0,0,5 * delegateWidth, 5 * delegateHeight); // just ensure all items fit
+
+ // these initial items should not trigger GridView.onAdd
+ for (int i=0; i<initialItemCount; i++)
+ model.addItem("dummy value", "dummy value");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("delegateWidth", delegateWidth);
+ ctxt->setContextProperty("delegateHeight", delegateHeight);
+ canvas->setSource(testFileUrl("attachedSignals.qml"));
+
+ QObject *object = canvas->rootObject();
+ object->setProperty("width", canvas->width());
+ object->setProperty("height", canvas->height());
+ qApp->processEvents();
+
+ QList<QPair<QString, QString> > items;
+ for (int i=0; i<itemsToAdd; i++)
+ items << qMakePair(QString("value %1").arg(i), QString::number(i));
+ model.addItems(items);
+
+ QTRY_COMPARE(model.count(), qobject_cast<QQuickGridView*>(canvas->rootObject())->count());
+ qApp->processEvents();
+
+ QVariantList result = object->property("addedDelegates").toList();
+ QTRY_COMPARE(result.count(), items.count());
+ for (int i=0; i<items.count(); i++)
+ QCOMPARE(result[i].toString(), items[i].first);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::onAdd_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<int>("itemsToAdd");
+
+ QTest::newRow("0, add 1") << 0 << 1;
+ QTest::newRow("0, add 2") << 0 << 2;
+ QTest::newRow("0, add 10") << 0 << 10;
+
+ QTest::newRow("1, add 1") << 1 << 1;
+ QTest::newRow("1, add 2") << 1 << 2;
+ QTest::newRow("1, add 10") << 1 << 10;
+
+ QTest::newRow("5, add 1") << 5 << 1;
+ QTest::newRow("5, add 2") << 5 << 2;
+ QTest::newRow("5, add 10") << 5 << 10;
+}
+
+void tst_QQuickGridView::onRemove()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(int, indexToRemove);
+ QFETCH(int, removeCount);
+
+ const int delegateWidth = 50;
+ const int delegateHeight = 100;
+ QaimModel model;
+ for (int i=0; i<initialItemCount; i++)
+ model.addItem(QString("value %1").arg(i), "dummy value");
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("delegateWidth", delegateWidth);
+ ctxt->setContextProperty("delegateHeight", delegateHeight);
+ canvas->setSource(testFileUrl("attachedSignals.qml"));
+ QObject *object = canvas->rootObject();
+
+ model.removeItems(indexToRemove, removeCount);
+ QTRY_COMPARE(model.count(), qobject_cast<QQuickGridView*>(canvas->rootObject())->count());
+ QCOMPARE(object->property("removedDelegateCount"), QVariant(removeCount));
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::onRemove_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<int>("indexToRemove");
+ QTest::addColumn<int>("removeCount");
+
+ QTest::newRow("remove first") << 1 << 0 << 1;
+ QTest::newRow("two items, remove first") << 2 << 0 << 1;
+ QTest::newRow("two items, remove last") << 2 << 1 << 1;
+ QTest::newRow("two items, remove all") << 2 << 0 << 2;
+
+ QTest::newRow("four items, remove first") << 4 << 0 << 1;
+ QTest::newRow("four items, remove 0-2") << 4 << 0 << 2;
+ QTest::newRow("four items, remove 1-3") << 4 << 1 << 2;
+ QTest::newRow("four items, remove 2-4") << 4 << 2 << 2;
+ QTest::newRow("four items, remove last") << 4 << 3 << 1;
+ QTest::newRow("four items, remove all") << 4 << 0 << 4;
+
+ QTest::newRow("ten items, remove 1-8") << 10 << 0 << 8;
+ QTest::newRow("ten items, remove 2-7") << 10 << 2 << 5;
+ QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6;
+}
+
+void tst_QQuickGridView::columnCount()
+{
+ QQuickView canvas;
+ canvas.setSource(testFileUrl("gridview4.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+
+ QQuickGridView *view = qobject_cast<QQuickGridView*>(canvas.rootObject());
+
+ QCOMPARE(view->cellWidth(), qreal(405)/qreal(9));
+ QCOMPARE(view->cellHeight(), qreal(100));
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(view, "delegate");
+ QCOMPARE(items.size(), 18);
+ QCOMPARE(items.at(8)->y(), qreal(0));
+ QCOMPARE(items.at(9)->y(), qreal(100));
+}
+
+void tst_QQuickGridView::margins()
+{
+ {
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+
+ canvas->setSource(testFileUrl("margins.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QCOMPARE(gridview->contentX(), -30.);
+ QCOMPARE(gridview->xOrigin(), 0.);
+
+ // check end bound
+ gridview->positionViewAtEnd();
+ qreal pos = gridview->contentX();
+ gridview->setContentX(pos + 80);
+ gridview->returnToBounds();
+ QTRY_COMPARE(gridview->contentX(), pos + 50);
+
+ // remove item before visible and check that left margin is maintained
+ // and xOrigin is updated
+ gridview->setContentX(200);
+ model.removeItems(0, 4);
+ QTest::qWait(100);
+ gridview->setContentX(-50);
+ gridview->returnToBounds();
+ QCOMPARE(gridview->xOrigin(), 100.);
+ QTRY_COMPARE(gridview->contentX(), 70.);
+
+ // reduce left margin
+ gridview->setLeftMargin(20);
+ QCOMPARE(gridview->xOrigin(), 100.);
+ QTRY_COMPARE(gridview->contentX(), 80.);
+
+ // check end bound
+ gridview->positionViewAtEnd();
+ QCOMPARE(gridview->xOrigin(), 0.); // positionViewAtEnd() resets origin
+ pos = gridview->contentX();
+ gridview->setContentX(pos + 80);
+ gridview->returnToBounds();
+ QTRY_COMPARE(gridview->contentX(), pos + 50);
+
+ // reduce right margin
+ pos = gridview->contentX();
+ gridview->setRightMargin(40);
+ QCOMPARE(gridview->xOrigin(), 0.);
+ QTRY_COMPARE(gridview->contentX(), pos-10);
+
+ delete canvas;
+ }
+ {
+ //RTL
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(true));
+
+ canvas->setSource(testFileUrl("margins.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QCOMPARE(gridview->contentX(), -240+30.);
+ QCOMPARE(gridview->xOrigin(), 0.);
+
+ // check end bound
+ gridview->positionViewAtEnd();
+ qreal pos = gridview->contentX();
+ gridview->setContentX(pos - 80);
+ gridview->returnToBounds();
+ QTRY_COMPARE(gridview->contentX(), pos - 50);
+
+ // remove item before visible and check that left margin is maintained
+ // and xOrigin is updated
+ gridview->setContentX(-400);
+ model.removeItems(0, 4);
+ QTest::qWait(100);
+ gridview->setContentX(-240+50);
+ gridview->returnToBounds();
+ QCOMPARE(gridview->xOrigin(), -100.);
+ QTRY_COMPARE(gridview->contentX(), -240-70.);
+
+ // reduce left margin (i.e. right side due to RTL)
+ pos = gridview->contentX();
+ gridview->setLeftMargin(20);
+ QCOMPARE(gridview->xOrigin(), -100.);
+ QTRY_COMPARE(gridview->contentX(), -240-80.);
+
+ // check end bound
+ gridview->positionViewAtEnd();
+ QCOMPARE(gridview->xOrigin(), 0.); // positionViewAtEnd() resets origin
+ pos = gridview->contentX();
+ gridview->setContentX(pos - 80);
+ gridview->returnToBounds();
+ QTRY_COMPARE(gridview->contentX(), pos - 50);
+
+ // reduce right margin (i.e. left side due to RTL)
+ pos = gridview->contentX();
+ gridview->setRightMargin(40);
+ QCOMPARE(gridview->xOrigin(), 0.);
+ QTRY_COMPARE(gridview->contentX(), pos+10);
+
+ delete canvas;
+ }
+}
+
+void tst_QQuickGridView::creationContext()
+{
+ QQuickView canvas;
+ canvas.setGeometry(0,0,240,320);
+ canvas.setSource(testFileUrl("creationContext.qml"));
+ qApp->processEvents();
+
+ QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
+ QVERIFY(rootItem);
+ QVERIFY(rootItem->property("count").toInt() > 0);
+
+ QQuickItem *item;
+ QVERIFY(item = rootItem->findChild<QQuickItem *>("listItem"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QQuickItem *>("header"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QQuickItem *>("footer"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+}
+
+void tst_QQuickGridView::snapToRow_data()
+{
+ QTest::addColumn<QQuickGridView::Flow>("flow");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<int>("highlightRangeMode");
+ QTest::addColumn<QPoint>("flickStart");
+ QTest::addColumn<QPoint>("flickEnd");
+ QTest::addColumn<qreal>("snapAlignment");
+ QTest::addColumn<qreal>("endExtent");
+ QTest::addColumn<qreal>("startExtent");
+
+ QTest::newRow("vertical, left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
+
+ QTest::newRow("horizontal, left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
+
+ QTest::newRow("horizontal, right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 << -240.0;
+
+ QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
+
+ QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
+
+ QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 - 140.0 << -220.0;
+}
+
+void tst_QQuickGridView::snapToRow()
+{
+ QFETCH(QQuickGridView::Flow, flow);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(int, highlightRangeMode);
+ QFETCH(QPoint, flickStart);
+ QFETCH(QPoint, flickEnd);
+ QFETCH(qreal, snapAlignment);
+ QFETCH(qreal, endExtent);
+ QFETCH(qreal, startExtent);
+
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("snapToRow.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ gridview->setFlow(flow);
+ gridview->setLayoutDirection(layoutDirection);
+ gridview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // confirm that a flick hits an item boundary
+ flick(canvas, flickStart, flickEnd, 180);
+ QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
+ if (flow == QQuickGridView::LeftToRight)
+ QCOMPARE(qreal(fmod(gridview->contentY(),80.0)), snapAlignment);
+ else
+ QCOMPARE(qreal(fmod(gridview->contentX(),80.0)), snapAlignment);
+
+ // flick to end
+ do {
+ flick(canvas, flickStart, flickEnd, 180);
+ QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
+ } while (flow == QQuickGridView::LeftToRight
+ ? !gridview->isAtYEnd()
+ : layoutDirection == Qt::LeftToRight ? !gridview->isAtXEnd() : !gridview->isAtXBeginning());
+
+ if (flow == QQuickGridView::LeftToRight)
+ QCOMPARE(gridview->contentY(), endExtent);
+ else
+ QCOMPARE(gridview->contentX(), endExtent);
+
+ // flick to start
+ do {
+ flick(canvas, flickEnd, flickStart, 180);
+ QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
+ } while (flow == QQuickGridView::LeftToRight
+ ? !gridview->isAtYBeginning()
+ : layoutDirection == Qt::LeftToRight ? !gridview->isAtXBeginning() : !gridview->isAtXEnd());
+
+ if (flow == QQuickGridView::LeftToRight)
+ QCOMPARE(gridview->contentY(), startExtent);
+ else
+ QCOMPARE(gridview->contentX(), startExtent);
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::snapOneRow_data()
+{
+ QTest::addColumn<QQuickGridView::Flow>("flow");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<int>("highlightRangeMode");
+ QTest::addColumn<QPoint>("flickStart");
+ QTest::addColumn<QPoint>("flickEnd");
+ QTest::addColumn<qreal>("snapAlignment");
+ QTest::addColumn<qreal>("endExtent");
+ QTest::addColumn<qreal>("startExtent");
+
+ QTest::newRow("vertical, left to right") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 360.0 << 0.0;
+
+ QTest::newRow("horizontal, left to right") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 360.0 << 0.0;
+
+ QTest::newRow("horizontal, right to left") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -360.0 - 240.0 << -240.0;
+
+ QTest::newRow("vertical, left to right, enforce range") << QQuickGridView::LeftToRight << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 200) << QPoint(20, 20) << 100.0 << 460.0 << -20.0;
+
+ QTest::newRow("horizontal, left to right, enforce range") << QQuickGridView::TopToBottom << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(200, 20) << QPoint(20, 20) << 100.0 << 460.0 << -20.0;
+
+ QTest::newRow("horizontal, right to left, enforce range") << QQuickGridView::TopToBottom << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 20) << QPoint(200, 20) << -340.0 << -360.0 - 240.0 - 100.0 << -220.0;
+}
+
+void tst_QQuickGridView::snapOneRow()
+{
+ QFETCH(QQuickGridView::Flow, flow);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(int, highlightRangeMode);
+ QFETCH(QPoint, flickStart);
+ QFETCH(QPoint, flickEnd);
+ QFETCH(qreal, snapAlignment);
+ QFETCH(qreal, endExtent);
+ QFETCH(qreal, startExtent);
+
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("snapOneRow.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ gridview->setFlow(flow);
+ gridview->setLayoutDirection(layoutDirection);
+ gridview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QSignalSpy currentIndexSpy(gridview, SIGNAL(currentIndexChanged()));
+
+ // confirm that a flick hits next row boundary
+ flick(canvas, flickStart, flickEnd, 180);
+ QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
+ if (flow == QQuickGridView::LeftToRight)
+ QCOMPARE(gridview->contentY(), snapAlignment);
+ else
+ QCOMPARE(gridview->contentX(), snapAlignment);
+
+ if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
+ QCOMPARE(gridview->currentIndex(), 2);
+ QCOMPARE(currentIndexSpy.count(), 1);
+ }
+
+ // flick to end
+ do {
+ flick(canvas, flickStart, flickEnd, 180);
+ QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
+ } while (flow == QQuickGridView::LeftToRight
+ ? !gridview->isAtYEnd()
+ : layoutDirection == Qt::LeftToRight ? !gridview->isAtXEnd() : !gridview->isAtXBeginning());
+
+ if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
+ QCOMPARE(gridview->currentIndex(), 8);
+ QCOMPARE(currentIndexSpy.count(), 4);
+ }
+
+ if (flow == QQuickGridView::LeftToRight)
+ QCOMPARE(gridview->contentY(), endExtent);
+ else
+ QCOMPARE(gridview->contentX(), endExtent);
+
+ // flick to start
+ do {
+ flick(canvas, flickEnd, flickStart, 180);
+ QTRY_VERIFY(gridview->isMoving() == false); // wait until it stops
+ } while (flow == QQuickGridView::LeftToRight
+ ? !gridview->isAtYBeginning()
+ : layoutDirection == Qt::LeftToRight ? !gridview->isAtXBeginning() : !gridview->isAtXEnd());
+
+ if (flow == QQuickGridView::LeftToRight)
+ QCOMPARE(gridview->contentY(), startExtent);
+ else
+ QCOMPARE(gridview->contentX(), startExtent);
+
+ if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
+ QCOMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(currentIndexSpy.count(), 8);
+ }
+
+ delete canvas;
+}
+
+
+void tst_QQuickGridView::unaligned()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ for (int i = 0; i < 10; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("unaligned.qml"));
+ qApp->processEvents();
+
+ QQuickGridView *gridview = qobject_cast<QQuickGridView*>(canvas->rootObject());
+ QVERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ for (int i = 0; i < 10; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth()));
+ QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight()));
+ }
+
+ // appending
+ for (int i = 10; i < 18; ++i) {
+ model.addItem("Item" + QString::number(i), "");
+ QQuickItem *item = 0;
+ QTRY_VERIFY(item = findItem<QQuickItem>(contentItem, "wrapper", i));
+ QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth()));
+ QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight()));
+ }
+
+ // inserting
+ for (int i = 0; i < 10; ++i) {
+ model.insertItem(i, "Item" + QString::number(i), "");
+ QQuickItem *item = 0;
+ QTRY_VERIFY(item = findItem<QQuickItem>(contentItem, "wrapper", i));
+ QCOMPARE(item->x(), qreal((i%9)*gridview->cellWidth()));
+ QCOMPARE(item->y(), qreal((i/9)*gridview->cellHeight()));
+ }
+
+ // removing
+ model.removeItems(7, 10);
+ QTRY_COMPARE(model.count(), gridview->count());
+ for (int i = 0; i < 18; ++i) {
+ QQuickItem *item = 0;
+ QTRY_VERIFY(item = findItem<QQuickItem>(contentItem, "wrapper", i));
+ QCOMPARE(item->x(), qreal(i%9)*gridview->cellWidth());
+ QCOMPARE(item->y(), qreal(i/9)*gridview->cellHeight());
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::populateTransitions()
+{
+ QFETCH(bool, staticallyPopulate);
+ QFETCH(bool, dynamicallyPopulate);
+ QFETCH(bool, usePopulateTransition);
+
+ QPointF transitionFrom(-50, -50);
+ QPointF transitionVia(100, 100);
+ QaimModel model_transitionFrom;
+ QaimModel model_transitionVia;
+
+ QaimModel model;
+ if (staticallyPopulate) {
+ for (int i = 0; i < 30; i++)
+ model.addItem("item" + QString::number(i), "");
+ }
+
+ QQuickView *canvas = createView();
+ canvas->rootContext()->setContextProperty("testModel", &model);
+ canvas->rootContext()->setContextProperty("usePopulateTransition", usePopulateTransition);
+ canvas->rootContext()->setContextProperty("dynamicallyPopulate", dynamicallyPopulate);
+ canvas->rootContext()->setContextProperty("transitionFrom", transitionFrom);
+ canvas->rootContext()->setContextProperty("transitionVia", transitionVia);
+ canvas->rootContext()->setContextProperty("model_transitionFrom", &model_transitionFrom);
+ canvas->rootContext()->setContextProperty("model_transitionVia", &model_transitionVia);
+ canvas->setSource(testFileUrl("populateTransitions.qml"));
+ canvas->show();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem);
+
+ if (staticallyPopulate || dynamicallyPopulate) {
+ // check the populate transition is run
+ if (usePopulateTransition) {
+ QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 19);
+ } else {
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 0);
+ }
+ QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0);
+ } else {
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ }
+
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ if (usePopulateTransition)
+ QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt());
+ for (int i=0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ // add an item and check this is done with add transition, not populate
+ model.insertItem(0, "another item", "");
+ QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 1);
+ QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(),
+ (usePopulateTransition && (staticallyPopulate || dynamicallyPopulate)) ? 19 : 0);
+
+ // clear the model
+ canvas->rootContext()->setContextProperty("testModel", QVariant());
+ QTRY_COMPARE(gridview->count(), 0);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 0);
+ gridview->setProperty("countPopulateTransitions", 0);
+ gridview->setProperty("countAddTransitions", 0);
+
+ // set to a valid model and check populate transition is run a second time
+ model.clear();
+ for (int i = 0; i < 30; i++)
+ model.addItem("item" + QString::number(i), "");
+ canvas->rootContext()->setContextProperty("testModel", &model);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 19 : 0);
+ QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0);
+
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ if (usePopulateTransition)
+ QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt());
+ for (int i=0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ // reset model and check populate transition is run again
+ gridview->setProperty("countPopulateTransitions", 0);
+ gridview->setProperty("countAddTransitions", 0);
+ model.reset();
+ QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 19 : 0);
+ QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0);
+
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ if (usePopulateTransition)
+ QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt());
+ for (int i=0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::populateTransitions_data()
+{
+ QTest::addColumn<bool>("staticallyPopulate");
+ QTest::addColumn<bool>("dynamicallyPopulate");
+ QTest::addColumn<bool>("usePopulateTransition");
+
+ QTest::newRow("static") << true << false << true;
+ QTest::newRow("static, no populate") << true << false << false;
+
+ QTest::newRow("dynamic") << false << true << true;
+ QTest::newRow("dynamic, no populate") << false << true << false;
+
+ QTest::newRow("empty to start with") << false << false << true;
+ QTest::newRow("empty to start with, no populate") << false << false << false;
+}
+
+void tst_QQuickGridView::addTransitions()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(bool, shouldAnimateTargets);
+ QFETCH(qreal, contentY);
+ QFETCH(int, insertionIndex);
+ QFETCH(int, insertionCount);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ // added items should start here
+ QPointF targetItems_transitionFrom(-50, -50);
+
+ // displaced items should pass through this point
+ QPointF displacedItems_transitionVia(100, 100);
+
+ QaimModel model;
+ for (int i = 0; i < initialItemCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_targetItems_transitionFrom;
+ QaimModel model_displacedItems_transitionVia;
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
+ ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
+ ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
+ ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ canvas->setSource(testFileUrl("addTransitions.qml"));
+ canvas->show();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ if (contentY != 0) {
+ gridview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ }
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+
+ // only target items that will become visible should be animated
+ QList<QPair<QString, QString> > newData;
+ QList<QPair<QString, QString> > expectedTargetData;
+ QList<int> targetIndexes;
+ if (shouldAnimateTargets) {
+ for (int i=insertionIndex; i<insertionIndex+insertionCount; i++) {
+ newData << qMakePair(QString("New item %1").arg(i), QString(""));
+
+ // last visible item is the first item of the row beneath the view
+ if (i >= (contentY / 60)*3 && i < qCeil((contentY + gridview->height()) / 60.0)*3) {
+ expectedTargetData << newData.last();
+ targetIndexes << i;
+ }
+ }
+ QVERIFY(expectedTargetData.count() > 0);
+ }
+
+ // start animation
+ if (!newData.isEmpty()) {
+ model.insertItems(insertionIndex, newData);
+ QTRY_COMPARE(model.count(), gridview->count());
+ }
+
+ QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
+
+ if (shouldAnimateTargets) {
+ QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(),
+ expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
+
+ // check the target and displaced items were animated
+ model_targetItems_transitionFrom.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
+ model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
+
+ // check attached properties
+ matchItemsAndIndexes(gridview->property("targetTrans_items").toMap(), model, targetIndexes);
+ matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems);
+ if (expectedDisplacedIndexes.isValid()) {
+ // adjust expectedDisplacedIndexes to their final values after the move
+ QList<int> displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount);
+ matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes);
+ matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems);
+ }
+ } else {
+ QTRY_COMPARE(model_targetItems_transitionFrom.count(), 0);
+ QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0);
+ }
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // verify all items moved to the correct final positions
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::addTransitions_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<bool>("shouldAnimateTargets");
+ QTest::addColumn<int>("insertionIndex");
+ QTest::addColumn<int>("insertionCount");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ // if inserting a full row before visible index, items don't appear or animate in, even if there are > 1 new items
+ QTest::newRow("insert 1, just before start")
+ << 30 << 20.0 << false
+ << 0 << 1 << ListRange();
+ QTest::newRow("insert 1, way before start")
+ << 30 << 20.0 << false
+ << 0 << 1 << ListRange();
+ QTest::newRow("insert multiple, just before start")
+ << 30 << 100.0 << false
+ << 0 << 3 << ListRange();
+ QTest::newRow("insert multiple (< 1 row), just before start")
+ << 30 << 100.0 << false
+ << 0 << 2 << ListRange();
+ QTest::newRow("insert multiple, way before start")
+ << 30 << 100.0 << false
+ << 0 << 3 << ListRange();
+
+ QTest::newRow("insert 1 at start")
+ << 30 << 0.0 << true
+ << 0 << 1 << ListRange(0, 17);
+ QTest::newRow("insert multiple at start")
+ << 30 << 0.0 << true
+ << 0 << 3 << ListRange(0, 17);
+ QTest::newRow("insert multiple (> 1 row) at start")
+ << 30 << 0.0 << true
+ << 0 << 5 << ListRange(0, 17);
+ QTest::newRow("insert 1 at start, content y not 0")
+ << 30 << 60.0 << true // first visible is index 3
+ << 3 << 1 << ListRange(0 + 3, 17 + 3);
+ QTest::newRow("insert multiple at start, content y not 0")
+ << 30 << 60.0 << true // first visible is index 3
+ << 3 << 3 << ListRange(0 + 3, 17 + 3);
+ QTest::newRow("insert multiple (> 1 row) at start, content y not 0")
+ << 30 << 60.0 << true // first visible is index 3
+ << 3 << 5 << ListRange(0 + 3, 17 + 3);
+
+ QTest::newRow("insert 1 at start, to empty grid")
+ << 0 << 0.0 << true
+ << 0 << 1 << ListRange();
+ QTest::newRow("insert multiple at start, to empty grid")
+ << 0 << 0.0 << true
+ << 0 << 3 << ListRange();
+
+ QTest::newRow("insert 1 at middle")
+ << 30 << 0.0 << true
+ << 7 << 1 << ListRange(7, 17);
+ QTest::newRow("insert multiple at middle")
+ << 30 << 0.0 << true
+ << 7 << 3 << ListRange(7, 17);
+ QTest::newRow("insert multiple (> 1 row) at middle")
+ << 30 << 0.0 << true
+ << 7 << 5 << ListRange(7, 17);
+
+ QTest::newRow("insert 1 at bottom")
+ << 30 << 0.0 << true
+ << 17 << 1 << ListRange(17, 17);
+ QTest::newRow("insert multiple at bottom")
+ << 30 << 0.0 << true
+ << 17 << 3 << ListRange(17, 17);
+ QTest::newRow("insert 1 at bottom, content y not 0")
+ << 30 << 20.0 * 3 << true
+ << 17 + 3 << 1 << ListRange(17 + 3, 17 + 3);
+ QTest::newRow("insert multiple at bottom, content y not 0")
+ << 30 << 20.0 * 3 << true
+ << 17 + 3 << 3 << ListRange(17 + 3, 17 + 3);
+
+
+ // items added after the last visible will not be animated in, since they
+ // do not appear in the final view
+ QTest::newRow("insert 1 after end")
+ << 30 << 0.0 << false
+ << 18 << 1 << ListRange();
+ QTest::newRow("insert multiple after end")
+ << 30 << 0.0 << false
+ << 18 << 3 << ListRange();
+}
+
+void tst_QQuickGridView::moveTransitions()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(qreal, contentY);
+ QFETCH(qreal, itemsOffsetAfterMove);
+ QFETCH(int, moveFrom);
+ QFETCH(int, moveTo);
+ QFETCH(int, moveCount);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ // target and displaced items should pass through these points
+ QPointF targetItems_transitionVia(-50, 50);
+ QPointF displacedItems_transitionVia(100, 100);
+
+ QaimModel model;
+ for (int i = 0; i < initialItemCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_targetItems_transitionVia;
+ QaimModel model_displacedItems_transitionVia;
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("model_targetItems_transitionVia", &model_targetItems_transitionVia);
+ ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
+ ctxt->setContextProperty("targetItems_transitionVia", targetItems_transitionVia);
+ ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ canvas->setSource(testFileUrl("moveTransitions.qml"));
+ canvas->show();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+ QQuickText *name;
+
+ if (contentY != 0) {
+ gridview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ }
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+
+ // Items moving to *or* from visible positions should be animated.
+ // Otherwise, they should not be animated.
+ QList<QPair<QString, QString> > expectedTargetData;
+ QList<int> targetIndexes;
+ for (int i=moveFrom; i<moveFrom+moveCount; i++) {
+ int toIndex = moveTo + (i - moveFrom);
+ int firstVisibleIndex = (contentY / 60) * 3;
+ int lastVisibleIndex = (qCeil((contentY + gridview->height()) / 60.0)*3) - 1;
+ if ((i >= firstVisibleIndex && i <= lastVisibleIndex)
+ || (toIndex >= firstVisibleIndex && toIndex <= lastVisibleIndex)) {
+ expectedTargetData << qMakePair(model.name(i), model.number(i));
+ targetIndexes << i;
+ }
+ }
+ // ViewTransition.index provides the indices that items are moving to, not from
+ targetIndexes = adjustIndexesForMove(targetIndexes, moveFrom, moveTo, moveCount);
+
+ // start animation
+ model.moveItems(moveFrom, moveTo, moveCount);
+
+ QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(),
+ expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
+
+ QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
+
+ // check the target and displaced items were animated
+ model_targetItems_transitionVia.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
+ model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
+
+ // check attached properties
+ matchItemsAndIndexes(gridview->property("targetTrans_items").toMap(), model, targetIndexes);
+ matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems);
+ if (expectedDisplacedIndexes.isValid()) {
+ // adjust expectedDisplacedIndexes to their final values after the move
+ QList<int> displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, moveFrom, moveTo, moveCount);
+ matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes);
+ matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems);
+ }
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // verify all items moved to the correct final positions
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0 + itemsOffsetAfterMove);
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::moveTransitions_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<qreal>("itemsOffsetAfterMove");
+ QTest::addColumn<int>("moveFrom");
+ QTest::addColumn<int>("moveTo");
+ QTest::addColumn<int>("moveCount");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ QTest::newRow("move from above view, outside visible items, move 1") << 30 << 120.0 << 0.0
+ << 1 << 10 << 1 << ListRange(6, 10);
+ QTest::newRow("move from above view, outside visible items, move 1 (first item)") << 30 << 120.0 << 0.0
+ << 0 << 10 << 1 << ListRange(6, 10);
+ QTest::newRow("move from above view, outside visible items, move multiple") << 30 << 120.0 << 60.0
+ << 1 << 10 << 3 << ListRange(13, 23);
+ QTest::newRow("move from above view, mix of visible/non-visible") << 30 << 120.0 << 60.0
+ << 1 << 10 << 6 << (ListRange(7, 15) + ListRange(16, 23));
+ QTest::newRow("move from above view, mix of visible/non-visible (move first)") << 30 << 120.0 << 120.0
+ << 0 << 10 << 6 << ListRange(16, 23);
+
+ QTest::newRow("move within view, move 1 down") << 30 << 0.0 << 0.0
+ << 1 << 10 << 1 << ListRange(2, 10);
+ QTest::newRow("move within view, move 1 down, move first item") << 30 << 0.0 << 0.0
+ << 0 << 10 << 1 << ListRange(1, 10);
+ QTest::newRow("move within view, move 1 down, move first item, contentY not 0") << 30 << 120.0 << 0.0
+ << 0+6 << 10+6 << 1 << ListRange(1+6, 10+6);
+ QTest::newRow("move within view, move 1 down, to last item") << 30 << 0.0 << 0.0
+ << 10 << 17 << 1 << ListRange(11, 17);
+ QTest::newRow("move within view, move first->last") << 30 << 0.0 << 0.0
+ << 0 << 17 << 1 << ListRange(1, 17);
+
+ QTest::newRow("move within view, move multiple down") << 30 << 0.0 << 0.0
+ << 1 << 10 << 3 << ListRange(4, 12);
+ QTest::newRow("move within view, move multiple down, move first item") << 30 << 0.0 << 0.0
+ << 0 << 10 << 3 << ListRange(3, 12);
+ QTest::newRow("move within view, move multiple down, move first item, contentY not 0") << 30 << 60.0 << 0.0
+ << 0+3 << 10+3 << 3 << ListRange(3+3, 12+3);
+ QTest::newRow("move within view, move multiple down, displace last item") << 30 << 0.0 << 0.0
+ << 5 << 15 << 3 << ListRange(8, 17);
+ QTest::newRow("move within view, move multiple down, move first->last") << 30 << 0.0 << 0.0
+ << 0 << 15 << 3 << ListRange(3, 17);
+
+ QTest::newRow("move within view, move 1 up") << 30 << 0.0 << 0.0
+ << 10 << 1 << 1 << ListRange(1, 9);
+ QTest::newRow("move within view, move 1 up, move to first index") << 30 << 0.0 << 0.0
+ << 10 << 0 << 1 << ListRange(0, 9);
+ QTest::newRow("move within view, move 1 up, move to first index, contentY not 0") << 30 << 120.0 << 0.0
+ << 10+6 << 0+6 << 1 << ListRange(0+6, 9+6);
+ QTest::newRow("move within view, move 1 up, move to first index, contentY not on item border") << 30 << 80.0 << 0.0
+ << 10+3 << 0+3 << 1 << ListRange(0+3, 9+3);
+ QTest::newRow("move within view, move 1 up, move last item") << 30 << 0.0 << 0.0
+ << 17 << 10 << 1 << ListRange(10, 16);
+ QTest::newRow("move within view, move 1 up, move last->first") << 30 << 0.0 << 0.0
+ << 17 << 0 << 1 << ListRange(0, 16);
+
+ QTest::newRow("move within view, move multiple up") << 30 << 0.0 << 0.0
+ << 10 << 1 << 3 << ListRange(1, 9);
+ QTest::newRow("move within view, move multiple (> 1 row) up") << 30 << 0.0 << 0.0
+ << 10 << 1 << 5 << ListRange(1, 9);
+ QTest::newRow("move within view, move multiple up, move to first index") << 30 << 0.0 << 0.0
+ << 10 << 0 << 3 << ListRange(0, 9);
+ QTest::newRow("move within view, move multiple up, move to first index, contentY not 0") << 30 << 60.0 << 0.0
+ << 10+3 << 0+3 << 3 << ListRange(0+3, 9+3);
+ QTest::newRow("move within view, move multiple up (> 1 row), move to first index, contentY not on border") << 30 << 80.0 << 0.0
+ << 10+3 << 0+3 << 5 << ListRange(0+3, 9+3);
+ QTest::newRow("move within view, move multiple up, move last item") << 30 << 0.0 << 0.0
+ << 15 << 5 << 3 << ListRange(5, 14);
+ QTest::newRow("move within view, move multiple up, move last->first") << 30 << 0.0 << 0.0
+ << 15 << 0 << 3 << ListRange(0, 14);
+
+ QTest::newRow("move from below view, move 1 up") << 30 << 0.0 << 0.0
+ << 20 << 5 << 1 << ListRange(5, 17);
+ QTest::newRow("move from below view, move 1 up, move to top") << 30 << 0.0 << 0.0
+ << 20 << 0 << 1 << ListRange(0, 17);
+ QTest::newRow("move from below view, move 1 up, move to top, contentY not 0") << 30 << 60.0 << 0.0
+ << 25 << 3 << 1 << ListRange(0+3, 17+3);
+ QTest::newRow("move from below view, move multiple (> 1 row) up") << 30 << 0.0 << 0.0
+ << 20 << 5 << 5 << ListRange(5, 17);
+ QTest::newRow("move from below view, move multiple up, move to top") << 30 << 0.0 << 0.0
+ << 20 << 0 << 3 << ListRange(0, 17);
+ QTest::newRow("move from below view, move multiple up, move to top, contentY not 0") << 30 << 60.0 << 0.0
+ << 25 << 3 << 3 << ListRange(0+3, 17+3);
+
+ QTest::newRow("move from below view, move 1 up, move to bottom") << 30 << 0.0 << 0.0
+ << 20 << 17 << 1 << ListRange(17, 17);
+ QTest::newRow("move from below view, move 1 up, move to bottom, contentY not 0") << 30 << 60.0 << 0.0
+ << 25 << 17+3 << 1 << ListRange(17+3, 17+3);
+ QTest::newRow("move from below view, move multiple up, move to to bottom") << 30 << 0.0 << 0.0
+ << 20 << 17 << 3 << ListRange(17, 17);
+ QTest::newRow("move from below view, move multiple up, move to bottom, contentY not 0") << 30 << 60.0 << 0.0
+ << 25 << 17+3 << 3 << ListRange(17+3, 17+3);
+}
+
+void tst_QQuickGridView::removeTransitions()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(bool, shouldAnimateTargets);
+ QFETCH(qreal, contentY);
+ QFETCH(int, removalIndex);
+ QFETCH(int, removalCount);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ // added items should end here
+ QPointF targetItems_transitionTo(-50, -50);
+
+ // displaced items should pass through this points
+ QPointF displacedItems_transitionVia(100, 100);
+
+ QaimModel model;
+ for (int i = 0; i < initialItemCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_targetItems_transitionTo;
+ QaimModel model_displacedItems_transitionVia;
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("model_targetItems_transitionTo", &model_targetItems_transitionTo);
+ ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
+ ctxt->setContextProperty("targetItems_transitionTo", targetItems_transitionTo);
+ ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ canvas->setSource(testFileUrl("removeTransitions.qml"));
+ canvas->show();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ if (contentY != 0) {
+ gridview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ }
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+
+ // only target items that are visible should be animated
+ QList<QPair<QString, QString> > expectedTargetData;
+ QList<int> targetIndexes;
+ if (shouldAnimateTargets) {
+ for (int i=removalIndex; i<removalIndex+removalCount; i++) {
+ int firstVisibleIndex = (contentY / 60.0)*3;
+ int lastVisibleIndex = (qCeil((contentY + gridview->height()) / 60.0)*3) - 1;
+ if (i >= firstVisibleIndex && i <= lastVisibleIndex) {
+ expectedTargetData << qMakePair(model.name(i), model.number(i));
+ targetIndexes << i;
+ }
+ }
+ QVERIFY(expectedTargetData.count() > 0);
+ }
+
+ // calculate targetItems and expectedTargets before model changes
+ QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
+ QVariantMap expectedTargets;
+ for (int i=0; i<targetIndexes.count(); i++)
+ expectedTargets[model.name(targetIndexes[i])] = targetIndexes[i];
+
+ // start animation
+ model.removeItems(removalIndex, removalCount);
+ QTRY_COMPARE(model.count(), gridview->count());
+
+ if (shouldAnimateTargets || expectedDisplacedIndexes.isValid()) {
+ QTRY_COMPARE(gridview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(gridview->property("displaceTransitionsDone").toInt(),
+ expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
+
+ // check the target and displaced items were animated
+ model_targetItems_transitionTo.matchAgainst(expectedTargetData, "wasn't animated to target 'to' pos", "shouldn't have been animated to target 'to' pos");
+ model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
+
+ // check attached properties
+ QCOMPARE(gridview->property("targetTrans_items").toMap(), expectedTargets);
+ matchIndexLists(gridview->property("targetTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(gridview->property("targetTrans_targetItems").toList(), targetItems);
+ if (expectedDisplacedIndexes.isValid()) {
+ // adjust expectedDisplacedIndexes to their final values after the move
+ QList<int> displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, removalIndex, removalCount);
+ matchItemsAndIndexes(gridview->property("displacedTrans_items").toMap(), model, displacedIndexes);
+ matchIndexLists(gridview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(gridview->property("displacedTrans_targetItems").toList(), targetItems);
+ }
+ } else {
+ QTRY_COMPARE(model_targetItems_transitionTo.count(), 0);
+ QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0);
+ }
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int itemCount = items.count();
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ int index = e.evaluate().toInt();
+ if (firstVisibleIndex < 0 && items[i]->y() >= contentY)
+ firstVisibleIndex = index;
+ else if (index < 0)
+ itemCount--; // exclude deleted items
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // verify all items moved to the correct final positions
+ for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), contentY + ((i-firstVisibleIndex)/3) * 60.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::removeTransitions_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<bool>("shouldAnimateTargets");
+ QTest::addColumn<int>("removalIndex");
+ QTest::addColumn<int>("removalCount");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ // All items that are visible following the remove operation should be animated.
+ // Remove targets that are outside of the view should not be animated.
+
+ // For a GridView, removing any number of items other than a full row before the start
+ // should displace all items in the view
+ QTest::newRow("remove 1 before start")
+ << 30 << 120.0 << false
+ << 2 << 1 << ListRange(6, 24); // 6-24 are displaced
+ QTest::newRow("remove 1 row, before start")
+ << 30 << 120.0 << false
+ << 3 << 3 << ListRange();
+ QTest::newRow("remove between 1-2 rows, before start")
+ << 30 << 120.0 << false
+ << 0 << 5 << ListRange(6, 25);
+ QTest::newRow("remove 2 rows, before start")
+ << 30 << 120.0 << false
+ << 0 << 6 << ListRange();
+ QTest::newRow("remove mix of before and after start")
+ << 30 << 60.0 << true
+ << 2 << 3 << ListRange(5, 23); // 5-23 are displaced into view
+
+
+ QTest::newRow("remove 1 from start")
+ << 30 << 0.0 << true
+ << 0 << 1 << ListRange(1, 18); // 1-18 are displaced into view
+ QTest::newRow("remove multiple from start")
+ << 30 << 0.0 << true
+ << 0 << 3 << ListRange(3, 20); // 3-18 are displaced into view
+ QTest::newRow("remove 1 from start, content y not 0")
+ << 30 << 60.0 << true
+ << 3 << 1 << ListRange(1 + 3, 18 + 3);
+ QTest::newRow("remove multiple from start, content y not 0")
+ << 30 << 60.0 << true
+ << 3 << 3 << ListRange(3 + 3, 20 + 3);
+
+
+ QTest::newRow("remove 1 from middle")
+ << 30 << 0.0 << true
+ << 5 << 1 << ListRange(6, 18);
+ QTest::newRow("remove multiple from middle")
+ << 30 << 0.0 << true
+ << 5 << 3 << ListRange(8, 20);
+
+
+ QTest::newRow("remove 1 from bottom")
+ << 30 << 0.0 << true
+ << 17 << 1 << ListRange(18, 18);
+ QTest::newRow("remove multiple (1 row) from bottom")
+ << 30 << 0.0 << true
+ << 15 << 3 << ListRange(18, 20);
+ QTest::newRow("remove multiple (> 1 row) from bottom")
+ << 30 << 0.0 << true
+ << 15 << 5 << ListRange(20, 22);
+ QTest::newRow("remove 1 from bottom, content y not 0")
+ << 30 << 60.0 << true
+ << 17 + 3 << 1 << ListRange(18 + 3, 18 + 3);
+ QTest::newRow("remove multiple (1 row) from bottom, content y not 0")
+ << 30 << 60.0 << true
+ << 15 + 3 << 3 << ListRange(18 + 3, 20 + 3);
+
+
+ QTest::newRow("remove 1 after end")
+ << 30 << 0.0 << false
+ << 18 << 1 << ListRange();
+ QTest::newRow("remove multiple after end")
+ << 30 << 0.0 << false
+ << 18 << 3 << ListRange();
+}
+
+void tst_QQuickGridView::multipleTransitions()
+{
+ // Tests that if you interrupt a transition in progress with another action that
+ // cancels the previous transition, the resulting items are still placed correctly.
+
+ QFETCH(int, initialCount);
+ QFETCH(qreal, contentY);
+ QFETCH(QList<ListChange>, changes);
+
+ // add transitions on the left, moves on the right
+ QPointF addTargets_transitionFrom(-50, -50);
+ QPointF addDisplaced_transitionFrom(-50, 50);
+ QPointF moveTargets_transitionFrom(50, -50);
+ QPointF moveDisplaced_transitionFrom(50, 50);
+
+ QmlListModel model;
+ for (int i = 0; i < initialCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("addTargets_transitionFrom", addTargets_transitionFrom);
+ ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom);
+ ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom);
+ ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom);
+ canvas->setSource(testFileUrl("multipleTransitions.qml"));
+ canvas->show();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+
+ int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt();
+
+ QList<QPair<QString, QString> > targetItems;
+ for (int i=0; i<changes.count(); i++) {
+ switch (changes[i].type) {
+ case ListChange::Inserted:
+ {
+ for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
+ targetItems << qMakePair(QString("new item %1").arg(j), QString::number(j));
+ model.insertItems(changes[i].index, targetItems);
+ QTRY_COMPARE(model.count(), gridview->count());
+ QTRY_VERIFY(gridview->property("runningAddTargets").toBool());
+ QTRY_VERIFY(gridview->property("runningAddDisplaced").toBool());
+ if (i == changes.count() - 1) {
+ QTRY_VERIFY(!gridview->property("runningAddTargets").toBool());
+ QTRY_VERIFY(!gridview->property("runningAddDisplaced").toBool());
+ } else {
+ QTest::qWait(timeBetweenActions);
+ }
+ break;
+ }
+ case ListChange::Removed:
+ for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
+ targetItems << qMakePair(model.name(i), model.number(i));
+ model.removeItems(changes[i].index, changes[i].count);
+ QTRY_COMPARE(model.count(), gridview->count());
+ QTRY_VERIFY(gridview->property("runningRemoveTargets").toBool());
+ QTRY_VERIFY(gridview->property("runningRemoveDisplaced").toBool());
+ if (i == changes.count() - 1) {
+ QTRY_VERIFY(!gridview->property("runningRemoveTargets").toBool());
+ QTRY_VERIFY(!gridview->property("runningRemoveDisplaced").toBool());
+ } else {
+ QTest::qWait(timeBetweenActions);
+ }
+ break;
+ case ListChange::Moved:
+ for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
+ targetItems << qMakePair(model.name(i), model.number(i));
+ model.moveItems(changes[i].index, changes[i].to, changes[i].count);
+ QTRY_VERIFY(gridview->property("runningMoveTargets").toBool());
+ QTRY_VERIFY(gridview->property("runningMoveDisplaced").toBool());
+ if (i == changes.count() - 1) {
+ QTRY_VERIFY(!gridview->property("runningMoveTargets").toBool());
+ QTRY_VERIFY(!gridview->property("runningMoveDisplaced").toBool());
+ } else {
+ QTest::qWait(timeBetweenActions);
+ }
+ break;
+ case ListChange::SetCurrent:
+ gridview->setCurrentIndex(changes[i].index);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ break;
+ case ListChange::SetContentY:
+ gridview->setContentY(changes[i].pos);
+ QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false);
+ break;
+ }
+ }
+ QCOMPARE(gridview->count(), model.count());
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // verify all items moved to the correct final positions
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), (i%3)*80.0);
+ QCOMPARE(item->y(), (i/3)*60.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::multipleTransitions_data()
+{
+ QTest::addColumn<int>("initialCount");
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<QList<ListChange> >("changes");
+
+ // the added item and displaced items should move to final dest correctly
+ QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList<ListChange>()
+ << ListChange::insert(0, 1)
+ << ListChange::move(0, 3, 1)
+ );
+
+ // items affected by the add should change from move to add transition
+ QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList<ListChange>()
+ << ListChange::move(1, 10, 3)
+ << ListChange::insert(0, 1)
+ );
+
+ // items should be placed correctly if you trigger a transition then refill for that index
+ QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList<ListChange>()
+ << ListChange::insert(0, 1)
+ << ListChange::setContentY(160.0)
+ << ListChange::setContentY(0.0)
+ << ListChange::insert(0, 1)
+ );
+}
+
+void tst_QQuickGridView::cacheBuffer()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 90; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testRightToLeft", QVariant(false));
+ ctxt->setContextProperty("testTopToBottom", QVariant(false));
+
+ canvas->setSource(testFileUrl("gridview1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QQuickItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
+ QVERIFY(gridview->delegate() != 0);
+ QVERIFY(gridview->model() != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_COMPARE(item->x(), (i%3)*80.0);
+ QTRY_COMPARE(item->y(), (i/3)*60.0);
+ }
+
+ QQmlIncubationController controller;
+ canvas->engine()->setIncubationController(&controller);
+
+ canvas->rootObject()->setProperty("cacheBuffer", 200);
+ QTRY_VERIFY(gridview->cacheBuffer() == 200);
+
+ // items will be created one at a time
+ for (int i = itemCount; i < qMin(itemCount+9,model.count()); ++i) {
+ QVERIFY(findItem<QQuickItem>(gridview, "wrapper", i) == 0);
+ QQuickItem *item = 0;
+ while (!item) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ item = findItem<QQuickItem>(gridview, "wrapper", i);
+ }
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ int newItemCount = 0;
+ newItemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count() && i < newItemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.0);
+ QTRY_COMPARE(item->y(), (i/3)*60.0);
+ }
+
+ // move view and confirm items in view are visible immediately and outside are created async
+ gridview->setContentY(300);
+
+ for (int i = 15; i < 34; ++i) { // 34 due to staggered item creation
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY(item);
+ QTRY_COMPARE(item->x(), (i%3)*80.0);
+ QTRY_COMPARE(item->y(), (i/3)*60.0);
+ }
+
+ QVERIFY(findItem<QQuickItem>(gridview, "wrapper", 34) == 0);
+
+ // ensure buffered items are created
+ for (int i = 34; i < qMin(44,model.count()); ++i) {
+ QQuickItem *item = 0;
+ while (!item) {
+ qGuiApp->processEvents(); // allow refill to happen
+ bool b = false;
+ controller.incubateWhile(&b);
+ item = findItem<QQuickItem>(gridview, "wrapper", i);
+ }
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::asynchronous()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+ QQmlIncubationController controller;
+ canvas->engine()->setIncubationController(&controller);
+
+ canvas->setSource(testFile("asyncloader.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootObject);
+
+ QQuickGridView *gridview = 0;
+ while (!gridview) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ gridview = rootObject->findChild<QQuickGridView*>("view");
+ }
+
+ // items will be created one at a time
+ for (int i = 0; i < 12; ++i) {
+ QVERIFY(findItem<QQuickItem>(gridview, "wrapper", i) == 0);
+ QQuickItem *item = 0;
+ while (!item) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ item = findItem<QQuickItem>(gridview, "wrapper", i);
+ }
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ // verify positioning
+ QQuickItem *contentItem = gridview->contentItem();
+ for (int i = 0; i < 12; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item->x() == (i%3)*100);
+ QVERIFY(item->y() == (i/3)*100);
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickGridView::unrequestedVisibility()
+{
+ QaimModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testWrap", QVariant(false));
+
+ canvas->setSource(testFileUrl("unrequestedItems.qml"));
+
+ canvas->show();
+
+ qApp->processEvents();
+
+ QQuickGridView *leftview = findItem<QQuickGridView>(canvas->rootObject(), "leftGrid");
+ QTRY_VERIFY(leftview != 0);
+
+ QQuickGridView *rightview = findItem<QQuickGridView>(canvas->rootObject(), "rightGrid");
+ QTRY_VERIFY(rightview != 0);
+
+ QQuickItem *leftContent = leftview->contentItem();
+ QTRY_VERIFY(leftContent != 0);
+
+ QQuickItem *rightContent = rightview->contentItem();
+ QTRY_VERIFY(rightContent != 0);
+
+ rightview->setCurrentIndex(12);
+
+ QTRY_COMPARE(leftview->contentY(), 0.0);
+ QTRY_COMPARE(rightview->contentY(), 240.0);
+
+ QQuickItem *item;
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 11));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 11));
+ QCOMPARE(item->isVisible(), true);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 9));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 10));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 4));
+ QCOMPARE(item->isVisible(), true);
+
+ rightview->setCurrentIndex(0);
+
+ QTRY_COMPARE(leftview->contentY(), 0.0);
+ QTRY_COMPARE(rightview->contentY(), 0.0);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ QTRY_COMPARE(item->isVisible(), true);
+
+ QVERIFY(!findItem<QQuickItem>(leftContent, "wrapper", 11));
+ QVERIFY(!findItem<QQuickItem>(rightContent, "wrapper", 11));
+
+ leftview->setCurrentIndex(12);
+
+ QTRY_COMPARE(leftview->contentY(), 240.0);
+ QTRY_COMPARE(rightview->contentY(), 0.0);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QTRY_COMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), true);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 11));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 11));
+ QCOMPARE(item->isVisible(), false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
+ QCOMPARE(item->isVisible(), false);
+
+ // move a non-visible item into view
+ model.moveItems(10, 9, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QTRY_VERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), true);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 11));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 11));
+ QCOMPARE(item->isVisible(), false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
+ QCOMPARE(item->isVisible(), false);
+
+ // move a visible item out of view
+ model.moveItems(5, 3, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
+ QCOMPARE(item->isVisible(), false);
+
+ // move a non-visible item into view
+ model.moveItems(3, 5, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
+ QCOMPARE(item->isVisible(), false);
+
+ // move a visible item out of view
+ model.moveItems(9, 10, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
+ QCOMPARE(item->isVisible(), false);
+
+ // move a non-visible item into view
+ model.moveItems(10, 9, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 9));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 10));
+ QCOMPARE(item->isVisible(), false);
+
+ delete canvas;
+}
+
+QList<int> tst_QQuickGridView::toIntList(const QVariantList &list)
+{
+ QList<int> ret;
+ bool ok = true;
+ for (int i=0; i<list.count(); i++) {
+ ret << list[i].toInt(&ok);
+ if (!ok)
+ qWarning() << "tst_QQuickGridView::toIntList(): not a number:" << list[i];
+ }
+
+ return ret;
+}
+
+void tst_QQuickGridView::matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes)
+{
+ for (int i=0; i<indexLists.count(); i++) {
+ QSet<int> current = indexLists[i].value<QList<int> >().toSet();
+ if (current != expectedIndexes.toSet())
+ qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes;
+ QCOMPARE(current, expectedIndexes.toSet());
+ }
+}
+
+void tst_QQuickGridView::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes)
+{
+ for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) {
+ QVERIFY(it.value().type() == QVariant::Int);
+ QString name = it.key();
+ int itemIndex = it.value().toInt();
+ QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex)));
+ if (model.name(itemIndex) != name)
+ qDebug() << itemIndex;
+ QCOMPARE(model.name(itemIndex), name);
+ }
+ QCOMPARE(items.count(), expectedIndexes.count());
+}
+
+void tst_QQuickGridView::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems)
+{
+ for (int i=0; i<itemLists.count(); i++) {
+ QVariantList current = itemLists[i].toList();
+ for (int j=0; j<current.count(); j++) {
+ QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
+ QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j)));
+ QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j)));
+ }
+ QCOMPARE(current.count(), expectedItems.count());
+ }
+}
+
+QTEST_MAIN(tst_QQuickGridView)
+
+#include "tst_qquickgridview.moc"
+
diff --git a/tests/auto/qtquick2/qquickimage/data/aspectratio.qml b/tests/auto/quick/qquickimage/data/aspectratio.qml
index b26f0e1f04..b26f0e1f04 100644
--- a/tests/auto/qtquick2/qquickimage/data/aspectratio.qml
+++ b/tests/auto/quick/qquickimage/data/aspectratio.qml
diff --git a/tests/auto/qtquick2/qquickimage/data/big.jpeg b/tests/auto/quick/qquickimage/data/big.jpeg
index bed7bd65c3..bed7bd65c3 100644
--- a/tests/auto/qtquick2/qquickimage/data/big.jpeg
+++ b/tests/auto/quick/qquickimage/data/big.jpeg
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/big256.png b/tests/auto/quick/qquickimage/data/big256.png
index 1dc1596d03..1dc1596d03 100644
--- a/tests/auto/qtquick2/qquickimage/data/big256.png
+++ b/tests/auto/quick/qquickimage/data/big256.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/colors.png b/tests/auto/quick/qquickimage/data/colors.png
index dfb62f3d64..dfb62f3d64 100644
--- a/tests/auto/qtquick2/qquickimage/data/colors.png
+++ b/tests/auto/quick/qquickimage/data/colors.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/colors1.png b/tests/auto/quick/qquickimage/data/colors1.png
index dfb62f3d64..dfb62f3d64 100644
--- a/tests/auto/qtquick2/qquickimage/data/colors1.png
+++ b/tests/auto/quick/qquickimage/data/colors1.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/green.png b/tests/auto/quick/qquickimage/data/green.png
index 0a2e153ba1..0a2e153ba1 100644
--- a/tests/auto/qtquick2/qquickimage/data/green.png
+++ b/tests/auto/quick/qquickimage/data/green.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/heart-win32.png b/tests/auto/quick/qquickimage/data/heart-win32.png
index 351da13772..351da13772 100644
--- a/tests/auto/qtquick2/qquickimage/data/heart-win32.png
+++ b/tests/auto/quick/qquickimage/data/heart-win32.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/heart.png b/tests/auto/quick/qquickimage/data/heart.png
index abe97fee4b..abe97fee4b 100644
--- a/tests/auto/qtquick2/qquickimage/data/heart.png
+++ b/tests/auto/quick/qquickimage/data/heart.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/heart.svg b/tests/auto/quick/qquickimage/data/heart.svg
index 8c982cd93c..8c982cd93c 100644
--- a/tests/auto/qtquick2/qquickimage/data/heart.svg
+++ b/tests/auto/quick/qquickimage/data/heart.svg
diff --git a/tests/auto/qtquick2/qquickimage/data/heart200-win32.png b/tests/auto/quick/qquickimage/data/heart200-win32.png
index 4976ff98ba..4976ff98ba 100644
--- a/tests/auto/qtquick2/qquickimage/data/heart200-win32.png
+++ b/tests/auto/quick/qquickimage/data/heart200-win32.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/heart200.png b/tests/auto/quick/qquickimage/data/heart200.png
index 7fbb13c5bb..7fbb13c5bb 100644
--- a/tests/auto/qtquick2/qquickimage/data/heart200.png
+++ b/tests/auto/quick/qquickimage/data/heart200.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/htiling.qml b/tests/auto/quick/qquickimage/data/htiling.qml
index f192f931c9..f192f931c9 100644
--- a/tests/auto/qtquick2/qquickimage/data/htiling.qml
+++ b/tests/auto/quick/qquickimage/data/htiling.qml
diff --git a/tests/auto/qtquick2/qquickimage/data/mirror.qml b/tests/auto/quick/qquickimage/data/mirror.qml
index 98fddf083e..98fddf083e 100644
--- a/tests/auto/qtquick2/qquickimage/data/mirror.qml
+++ b/tests/auto/quick/qquickimage/data/mirror.qml
diff --git a/tests/auto/qtquick2/qquickimage/data/nullpixmap.qml b/tests/auto/quick/qquickimage/data/nullpixmap.qml
index d52f41f164..d52f41f164 100644
--- a/tests/auto/qtquick2/qquickimage/data/nullpixmap.qml
+++ b/tests/auto/quick/qquickimage/data/nullpixmap.qml
diff --git a/tests/auto/qtquick2/qquickimage/data/pattern.png b/tests/auto/quick/qquickimage/data/pattern.png
index d3d5e1e007..d3d5e1e007 100644
--- a/tests/auto/qtquick2/qquickimage/data/pattern.png
+++ b/tests/auto/quick/qquickimage/data/pattern.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/qtbug_16389.qml b/tests/auto/quick/qquickimage/data/qtbug_16389.qml
index 7b8adecb11..7b8adecb11 100644
--- a/tests/auto/qtquick2/qquickimage/data/qtbug_16389.qml
+++ b/tests/auto/quick/qquickimage/data/qtbug_16389.qml
diff --git a/tests/auto/qtquick2/qquickimage/data/qtbug_22125.qml b/tests/auto/quick/qquickimage/data/qtbug_22125.qml
index 9b68c0a125..9b68c0a125 100644
--- a/tests/auto/qtquick2/qquickimage/data/qtbug_22125.qml
+++ b/tests/auto/quick/qquickimage/data/qtbug_22125.qml
diff --git a/tests/auto/qtquick2/qquickimage/data/rect.png b/tests/auto/quick/qquickimage/data/rect.png
index d564a2d5a5..d564a2d5a5 100644
--- a/tests/auto/qtquick2/qquickimage/data/rect.png
+++ b/tests/auto/quick/qquickimage/data/rect.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquickimage/data/sourceSize.qml b/tests/auto/quick/qquickimage/data/sourceSize.qml
index 8e25c254d3..8e25c254d3 100644
--- a/tests/auto/qtquick2/qquickimage/data/sourceSize.qml
+++ b/tests/auto/quick/qquickimage/data/sourceSize.qml
diff --git a/tests/auto/qtquick2/qquickimage/data/vtiling.qml b/tests/auto/quick/qquickimage/data/vtiling.qml
index f730f6e050..f730f6e050 100644
--- a/tests/auto/qtquick2/qquickimage/data/vtiling.qml
+++ b/tests/auto/quick/qquickimage/data/vtiling.qml
diff --git a/tests/auto/quick/qquickimage/qquickimage.pro b/tests/auto/quick/qquickimage/qquickimage.pro
new file mode 100644
index 0000000000..a68a7870d8
--- /dev/null
+++ b/tests/auto/quick/qquickimage/qquickimage.pro
@@ -0,0 +1,17 @@
+CONFIG += testcase
+TARGET = tst_qquickimage
+macx:CONFIG -= app_bundle
+
+HEADERS += ../../shared/testhttpserver.h
+SOURCES += tst_qquickimage.cpp \
+ ../../shared/testhttpserver.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickimage/tst_qquickimage.cpp b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
new file mode 100644
index 0000000000..eda56fa789
--- /dev/null
+++ b/tests/auto/quick/qquickimage/tst_qquickimage.cpp
@@ -0,0 +1,749 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QTextDocument>
+#include <QTcpServer>
+#include <QTcpSocket>
+#include <QDir>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <private/qquickimage_p.h>
+#include <private/qquickimagebase_p.h>
+#include <private/qquickloader_p.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtTest/QSignalSpy>
+#include <QtGui/QPainter>
+#include <QtGui/QImageReader>
+
+#include "../../shared/util.h"
+#include "../../shared/testhttpserver.h"
+#include "../shared/visualtestutil.h"
+
+#define SERVER_PORT 14451
+#define SERVER_ADDR "http://127.0.0.1:14451"
+
+
+using namespace QQuickVisualTestUtil;
+
+Q_DECLARE_METATYPE(QQuickImageBase::Status)
+
+class tst_qquickimage : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickimage();
+
+private slots:
+ void noSource();
+ void imageSource();
+ void imageSource_data();
+ void clearSource();
+ void resized();
+ void preserveAspectRatio();
+ void smooth();
+ void mirror();
+ void svg();
+ void geometry();
+ void geometry_data();
+ void big();
+ void tiling_QTBUG_6716();
+ void tiling_QTBUG_6716_data();
+ void noLoading();
+ void paintedWidthHeight();
+ void sourceSize_QTBUG_14303();
+ void sourceSize_QTBUG_16389();
+ void nullPixmapPaint();
+ void imageCrash_QTBUG_22125();
+ void sourceSize_data();
+ void sourceSize();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquickimage::tst_qquickimage()
+{
+}
+
+void tst_qquickimage::noSource()
+{
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"\" }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->source(), QUrl());
+ QVERIFY(obj->status() == QQuickImage::Null);
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+ QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
+ QCOMPARE(obj->progress(), 0.0);
+
+ delete obj;
+}
+
+void tst_qquickimage::imageSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<double>("width");
+ QTest::addColumn<double>("height");
+ QTest::addColumn<bool>("remote");
+ QTest::addColumn<bool>("async");
+ QTest::addColumn<bool>("cache");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("local") << testFileUrl("colors.png").toString() << 120.0 << 120.0 << false << false << true << "";
+ QTest::newRow("local no cache") << testFileUrl("colors.png").toString() << 120.0 << 120.0 << false << false << false << "";
+ QTest::newRow("local async") << testFileUrl("colors1.png").toString() << 120.0 << 120.0 << false << true << true << "";
+ QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << 0.0 << 0.0 << false
+ << false << true << "file::2:1: QML Image: Cannot open: " + testFileUrl("no-such-file.png").toString();
+ QTest::newRow("local async not found") << testFileUrl("no-such-file-1.png").toString() << 0.0 << 0.0 << false
+ << true << true << "file::2:1: QML Image: Cannot open: " + testFileUrl("no-such-file-1.png").toString();
+ QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << true << "";
+ QTest::newRow("remote redirected") << SERVER_ADDR "/oldcolors.png" << 120.0 << 120.0 << true << false << false << "";
+ if (QImageReader::supportedImageFormats().contains("svg"))
+ QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << false << "";
+
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true
+ << false << true << "file::2:1: QML Image: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found";
+
+}
+
+void tst_qquickimage::imageSource()
+{
+ QFETCH(QString, source);
+ QFETCH(double, width);
+ QFETCH(double, height);
+ QFETCH(bool, remote);
+ QFETCH(bool, async);
+ QFETCH(bool, cache);
+ QFETCH(QString, error);
+
+ TestHTTPServer server(SERVER_PORT);
+ if (remote) {
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+ server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
+ }
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + source + "\"; asynchronous: "
+ + (async ? QLatin1String("true") : QLatin1String("false")) + "; cache: "
+ + (cache ? QLatin1String("true") : QLatin1String("false")) + " }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ if (async)
+ QVERIFY(obj->asynchronous() == true);
+ else
+ QVERIFY(obj->asynchronous() == false);
+
+ if (cache)
+ QVERIFY(obj->cache() == true);
+ else
+ QVERIFY(obj->cache() == false);
+
+ if (remote || async)
+ QTRY_VERIFY(obj->status() == QQuickImage::Loading);
+
+ QCOMPARE(obj->source(), remote ? source : QUrl(source));
+
+ if (error.isEmpty()) {
+ QTRY_VERIFY(obj->status() == QQuickImage::Ready);
+ QCOMPARE(obj->width(), qreal(width));
+ QCOMPARE(obj->height(), qreal(height));
+ QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
+ QCOMPARE(obj->progress(), 1.0);
+ } else {
+ QTRY_VERIFY(obj->status() == QQuickImage::Error);
+ }
+
+ delete obj;
+}
+
+void tst_qquickimage::clearSource()
+{
+ QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }";
+ QQmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->status() == QQuickImage::Ready);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+ QCOMPARE(obj->progress(), 1.0);
+
+ ctxt->setContextProperty("srcImage", "");
+ QVERIFY(obj->source().isEmpty());
+ QVERIFY(obj->status() == QQuickImage::Null);
+ QCOMPARE(obj->width(), 0.);
+ QCOMPARE(obj->height(), 0.);
+ QCOMPARE(obj->progress(), 0.0);
+
+ delete obj;
+}
+
+void tst_qquickimage::resized()
+{
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + testFile("colors.png") + "\"; width: 300; height: 300 }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
+ delete obj;
+}
+
+
+void tst_qquickimage::preserveAspectRatio()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->show();
+
+ canvas->setSource(testFileUrl("aspectratio.qml"));
+ QQuickImage *image = qobject_cast<QQuickImage*>(canvas->rootObject());
+ QVERIFY(image != 0);
+ image->setWidth(80.0);
+ QCOMPARE(image->width(), 80.);
+ QCOMPARE(image->height(), 80.);
+
+ canvas->setSource(testFileUrl("aspectratio.qml"));
+ image = qobject_cast<QQuickImage*>(canvas->rootObject());
+ image->setHeight(60.0);
+ QVERIFY(image != 0);
+ QCOMPARE(image->height(), 60.);
+ QCOMPARE(image->width(), 60.);
+ delete canvas;
+}
+
+void tst_qquickimage::smooth()
+{
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + testFile("colors.png") + "\"; smooth: true; width: 300; height: 300 }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.);
+ QCOMPARE(obj->height(), 300.);
+ QCOMPARE(obj->smooth(), true);
+ QCOMPARE(obj->fillMode(), QQuickImage::Stretch);
+
+ delete obj;
+}
+
+void tst_qquickimage::mirror()
+{
+ QSKIP("Test is broken on multiple levels, will need incremental fixes");
+
+ QMap<QQuickImage::FillMode, QImage> screenshots;
+ QList<QQuickImage::FillMode> fillModes;
+ fillModes << QQuickImage::Stretch << QQuickImage::PreserveAspectFit << QQuickImage::PreserveAspectCrop
+ << QQuickImage::Tile << QQuickImage::TileVertically << QQuickImage::TileHorizontally;
+
+ qreal width = 300;
+ qreal height = 250;
+
+ foreach (QQuickImage::FillMode fillMode, fillModes) {
+ QQuickView *canvas = new QQuickView;
+ canvas->setSource(testFileUrl("mirror.qml"));
+
+ QQuickImage *obj = canvas->rootObject()->findChild<QQuickImage*>("image");
+ QVERIFY(obj != 0);
+
+ obj->setFillMode(fillMode);
+ obj->setProperty("mirror", true);
+ canvas->show();
+
+ QImage screenshot = canvas->grabFrameBuffer();
+ screenshots[fillMode] = screenshot;
+ delete canvas;
+ }
+
+ foreach (QQuickImage::FillMode fillMode, fillModes) {
+ QPixmap srcPixmap;
+ QVERIFY(srcPixmap.load(testFile("pattern.png")));
+
+ QPixmap expected(width, height);
+ expected.fill();
+ QPainter p_e(&expected);
+ QTransform transform;
+ transform.translate(width, 0).scale(-1, 1.0);
+ p_e.setTransform(transform);
+
+ switch (fillMode) {
+ case QQuickImage::Stretch:
+ p_e.drawPixmap(QRect(0, 0, width, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
+ break;
+ case QQuickImage::PreserveAspectFit:
+ p_e.drawPixmap(QRect(25, 0, height, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
+ break;
+ case QQuickImage::PreserveAspectCrop:
+ {
+ qreal ratio = width/srcPixmap.width(); // width is the longer side
+ QRect rect(0, 0, srcPixmap.width()*ratio, srcPixmap.height()*ratio);
+ rect.moveCenter(QRect(0, 0, width, height).center());
+ p_e.drawPixmap(rect, srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height()));
+ break;
+ }
+ case QQuickImage::Tile:
+ p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap);
+ break;
+ case QQuickImage::TileVertically:
+ transform.scale(width / srcPixmap.width(), 1.0);
+ p_e.setTransform(transform);
+ p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap);
+ break;
+ case QQuickImage::TileHorizontally:
+ transform.scale(1.0, height / srcPixmap.height());
+ p_e.setTransform(transform);
+ p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap);
+ break;
+ case QQuickImage::Pad:
+ break;
+ }
+
+ QImage img = expected.toImage();
+ QEXPECT_FAIL("", "QTBUG-21005 fails", Continue);
+ QCOMPARE(screenshots[fillMode], img);
+ }
+}
+
+void tst_qquickimage::svg()
+{
+ if (!QImageReader::supportedImageFormats().contains("svg"))
+ QSKIP("svg support not available");
+
+ QString src = testFileUrl("heart.svg").toString();
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; sourceSize.width: 300; sourceSize.height: 300 }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 300.0);
+ QCOMPARE(obj->height(), 300.0);
+ obj->setSourceSize(QSize(200,200));
+
+ QCOMPARE(obj->width(), 200.0);
+ QCOMPARE(obj->height(), 200.0);
+ delete obj;
+}
+
+void tst_qquickimage::geometry_data()
+{
+ QTest::addColumn<QString>("fillMode");
+ QTest::addColumn<bool>("explicitWidth");
+ QTest::addColumn<bool>("explicitHeight");
+ QTest::addColumn<double>("itemWidth");
+ QTest::addColumn<double>("paintedWidth");
+ QTest::addColumn<double>("boundingWidth");
+ QTest::addColumn<double>("itemHeight");
+ QTest::addColumn<double>("paintedHeight");
+ QTest::addColumn<double>("boundingHeight");
+
+ // tested image has width 200, height 100
+
+ // bounding rect and item rect are equal with fillMode PreserveAspectFit, painted rect may be smaller if the aspect ratio doesn't match
+ QTest::newRow("PreserveAspectFit") << "PreserveAspectFit" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0;
+ QTest::newRow("PreserveAspectFit explicit width 300") << "PreserveAspectFit" << true << false << 300.0 << 200.0 << 300.0 << 100.0 << 100.0 << 100.0;
+ QTest::newRow("PreserveAspectFit explicit height 400") << "PreserveAspectFit" << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 100.0 << 400.0;
+ QTest::newRow("PreserveAspectFit explicit width 300, height 400") << "PreserveAspectFit" << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 150.0 << 400.0;
+
+ // bounding rect and painted rect are equal with fillMode PreserveAspectCrop, item rect may be smaller if the aspect ratio doesn't match
+ QTest::newRow("PreserveAspectCrop") << "PreserveAspectCrop" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0;
+ QTest::newRow("PreserveAspectCrop explicit width 300") << "PreserveAspectCrop" << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 150.0 << 150.0;
+ QTest::newRow("PreserveAspectCrop explicit height 400") << "PreserveAspectCrop" << false << true << 200.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0;
+ QTest::newRow("PreserveAspectCrop explicit width 300, height 400") << "PreserveAspectCrop" << true << true << 300.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0;
+
+ // bounding rect, painted rect and item rect are equal in stretching and tiling images
+ QStringList fillModes;
+ fillModes << "Stretch" << "Tile" << "TileVertically" << "TileHorizontally";
+ foreach (QString fillMode, fillModes) {
+ QTest::newRow(fillMode.toLatin1()) << fillMode << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0;
+ QTest::newRow(QString(fillMode + " explicit width 300").toLatin1()) << fillMode << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 100.0 << 100.0;
+ QTest::newRow(QString(fillMode + " explicit height 400").toLatin1()) << fillMode << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 400.0 << 400.0;
+ QTest::newRow(QString(fillMode + " explicit width 300, height 400").toLatin1()) << fillMode << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 400.0 << 400.0;
+ }
+}
+
+void tst_qquickimage::geometry()
+{
+ QFETCH(QString, fillMode);
+ QFETCH(bool, explicitWidth);
+ QFETCH(bool, explicitHeight);
+ QFETCH(double, itemWidth);
+ QFETCH(double, itemHeight);
+ QFETCH(double, paintedWidth);
+ QFETCH(double, paintedHeight);
+ QFETCH(double, boundingWidth);
+ QFETCH(double, boundingHeight);
+
+ QString src = testFileUrl("rect.png").toString();
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; fillMode: Image." + fillMode + "; ";
+
+ if (explicitWidth)
+ componentStr.append("width: 300; ");
+ if (explicitHeight)
+ componentStr.append("height: 400; ");
+ componentStr.append("}");
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->width(), itemWidth);
+ QCOMPARE(obj->paintedWidth(), paintedWidth);
+ QCOMPARE(obj->boundingRect().width(), boundingWidth);
+
+ QCOMPARE(obj->height(), itemHeight);
+ QCOMPARE(obj->paintedHeight(), paintedHeight);
+ QCOMPARE(obj->boundingRect().height(), boundingHeight);
+ delete obj;
+}
+
+void tst_qquickimage::big()
+{
+ // If the JPEG loader does not implement scaling efficiently, it would
+ // have to build a 400 MB image. That would be a bug in the JPEG loader.
+
+ QString src = testFileUrl("big.jpeg").toString();
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 100; sourceSize.height: 256 }";
+
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 100.0);
+ QCOMPARE(obj->height(), 256.0);
+
+ delete obj;
+}
+
+// As tiling_QTBUG_6716 doesn't complete, it doesn't delete the
+// canvas which causes leak warnings. Use this delete on stack
+// destruction pattern to work around this.
+template<typename T>
+struct AutoDelete {
+ AutoDelete(T *t) : t(t) {}
+ ~AutoDelete() { delete t; }
+private:
+ T *t;
+};
+
+void tst_qquickimage::tiling_QTBUG_6716()
+{
+ QSKIP("Test is broken on multiple levels, will need incremental fixes");
+
+ QFETCH(QString, source);
+
+ QQuickView *canvas = new QQuickView(0);
+ AutoDelete<QQuickView> del(canvas);
+
+ canvas->setSource(testFileUrl(source));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickImage *tiling = findItem<QQuickImage>(canvas->rootObject(), "tiling");
+
+ QVERIFY(tiling != 0);
+ QImage img = canvas->grabFrameBuffer();
+ for (int x = 0; x < tiling->width(); ++x) {
+ for (int y = 0; y < tiling->height(); ++y) {
+ QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0));
+ }
+ }
+
+ delete canvas;
+}
+
+void tst_qquickimage::tiling_QTBUG_6716_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::newRow("vertical_tiling") << "vtiling.qml";
+ QTest::newRow("horizontal_tiling") << "htiling.qml";
+}
+
+void tst_qquickimage::noLoading()
+{
+ qRegisterMetaType<QQuickImageBase::Status>();
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+ server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
+
+ QString componentStr = "import QtQuick 2.0\nImage { source: srcImage; cache: true }";
+ QQmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", testFileUrl("heart.png"));
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QVERIFY(obj->status() == QQuickImage::Ready);
+
+ QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &)));
+ QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal)));
+ QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status)));
+
+ // Loading local file
+ ctxt->setContextProperty("srcImage", testFileUrl("green.png"));
+ QTRY_VERIFY(obj->status() == QQuickImage::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) + "/rect.png");
+ QTRY_VERIFY(obj->status() == QQuickImage::Loading);
+ QTRY_VERIFY(obj->progress() == 0.0);
+ QTRY_VERIFY(obj->status() == QQuickImage::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", testFileUrl("green.png"));
+ ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png");
+ QTRY_VERIFY(obj->status() == QQuickImage::Ready);
+ QTRY_VERIFY(obj->progress() == 1.0);
+ QTRY_COMPARE(sourceSpy.count(), 4);
+ QTRY_COMPARE(progressSpy.count(), 2);
+ QTRY_COMPARE(statusSpy.count(), 2);
+
+ delete obj;
+}
+
+void tst_qquickimage::paintedWidthHeight()
+{
+ {
+ QString src = testFileUrl("heart.png").toString();
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 200; height: 25; fillMode: Image.PreserveAspectFit }";
+
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 200.0);
+ QCOMPARE(obj->height(), 25.0);
+ QCOMPARE(obj->paintedWidth(), 25.0);
+ QCOMPARE(obj->paintedHeight(), 25.0);
+
+ delete obj;
+ }
+
+ {
+ QString src = testFileUrl("heart.png").toString();
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 26; height: 175; fillMode: Image.PreserveAspectFit }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->width(), 26.0);
+ QCOMPARE(obj->height(), 175.0);
+ QCOMPARE(obj->paintedWidth(), 26.0);
+ QCOMPARE(obj->paintedHeight(), 26.0);
+
+ delete obj;
+ }
+}
+
+void tst_qquickimage::sourceSize_QTBUG_14303()
+{
+ QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }";
+ QQmlContext *ctxt = engine.rootContext();
+ ctxt->setContextProperty("srcImage", testFileUrl("heart200.png"));
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
+
+ QSignalSpy sourceSizeSpy(obj, SIGNAL(sourceSizeChanged()));
+
+ QTRY_VERIFY(obj != 0);
+ QTRY_VERIFY(obj->status() == QQuickImage::Ready);
+
+ QTRY_COMPARE(obj->sourceSize().width(), 200);
+ QTRY_COMPARE(obj->sourceSize().height(), 200);
+ QTRY_COMPARE(sourceSizeSpy.count(), 0);
+
+ ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
+ QTRY_COMPARE(obj->sourceSize().width(), 120);
+ QTRY_COMPARE(obj->sourceSize().height(), 120);
+ QTRY_COMPARE(sourceSizeSpy.count(), 1);
+
+ ctxt->setContextProperty("srcImage", testFileUrl("heart200.png"));
+ QTRY_COMPARE(obj->sourceSize().width(), 200);
+ QTRY_COMPARE(obj->sourceSize().height(), 200);
+ QTRY_COMPARE(sourceSizeSpy.count(), 2);
+
+ delete obj;
+}
+
+void tst_qquickimage::sourceSize_QTBUG_16389()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(testFileUrl("qtbug_16389.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickImage *image = findItem<QQuickImage>(canvas->rootObject(), "iconImage");
+ QQuickItem *handle = findItem<QQuickItem>(canvas->rootObject(), "blueHandle");
+
+ QCOMPARE(image->sourceSize().width(), 200);
+ QCOMPARE(image->sourceSize().height(), 200);
+ QCOMPARE(image->paintedWidth(), 0.0);
+ QCOMPARE(image->paintedHeight(), 0.0);
+
+ handle->setY(20);
+
+ QCOMPARE(image->sourceSize().width(), 200);
+ QCOMPARE(image->sourceSize().height(), 200);
+ QCOMPARE(image->paintedWidth(), 20.0);
+ QCOMPARE(image->paintedHeight(), 20.0);
+
+ delete canvas;
+}
+
+static int numberOfWarnings = 0;
+static void checkWarnings(QtMsgType, const char *msg)
+{
+ if (!QString(msg).contains("QGLContext::makeCurrent(): Failed."))
+ numberOfWarnings++;
+}
+
+// QTBUG-15690
+void tst_qquickimage::nullPixmapPaint()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(testFileUrl("nullpixmap.qml"));
+ canvas->show();
+
+ QQuickImage *image = qobject_cast<QQuickImage*>(canvas->rootObject());
+ QTRY_VERIFY(image != 0);
+ image->setSource(SERVER_ADDR + QString("/no-such-file.png"));
+
+ QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings);
+
+ // used to print "QTransform::translate with NaN called"
+ QPixmap pm = QPixmap::fromImage(canvas->grabFrameBuffer());
+ qInstallMsgHandler(previousMsgHandler);
+ QVERIFY(numberOfWarnings == 0);
+ delete image;
+
+ delete canvas;
+}
+
+void tst_qquickimage::imageCrash_QTBUG_22125()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
+
+ {
+ QQuickView view(testFileUrl("qtbug_22125.qml"));
+ view.show();
+ qApp->processEvents();
+ qApp->processEvents();
+ // shouldn't crash when the view drops out of scope due to
+ // QQuickPixmapData attempting to dereference a pointer to
+ // the destroyed reader.
+ }
+
+ // shouldn't crash when deleting cancelled QQmlPixmapReplys.
+ QTest::qWait(520); // Delay mode delays for 500 ms.
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+}
+
+void tst_qquickimage::sourceSize_data()
+{
+ QTest::addColumn<int>("sourceWidth");
+ QTest::addColumn<int>("sourceHeight");
+ QTest::addColumn<qreal>("implicitWidth");
+ QTest::addColumn<qreal>("implicitHeight");
+
+ QTest::newRow("unscaled") << 0 << 0 << 300.0 << 300.0;
+ QTest::newRow("scale width") << 100 << 0 << 100.0 << 100.0;
+ QTest::newRow("scale height") << 0 << 150 << 150.0 << 150.0;
+ QTest::newRow("larger sourceSize") << 400 << 400 << 300.0 << 300.0;
+}
+
+void tst_qquickimage::sourceSize()
+{
+ QFETCH(int, sourceWidth);
+ QFETCH(int, sourceHeight);
+ QFETCH(qreal, implicitWidth);
+ QFETCH(qreal, implicitHeight);
+
+ QQuickView *canvas = new QQuickView(0);
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("srcWidth", sourceWidth);
+ ctxt->setContextProperty("srcHeight", sourceHeight);
+
+ canvas->setSource(testFileUrl("sourceSize.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickImage *image = qobject_cast<QQuickImage*>(canvas->rootObject());
+ QVERIFY(image);
+
+ QCOMPARE(image->sourceSize().width(), sourceWidth);
+ QCOMPARE(image->sourceSize().height(), sourceHeight);
+ QCOMPARE(image->implicitWidth(), implicitWidth);
+ QCOMPARE(image->implicitHeight(), implicitHeight);
+
+ delete canvas;
+}
+
+QTEST_MAIN(tst_qquickimage)
+
+#include "tst_qquickimage.moc"
diff --git a/tests/auto/qtquick2/qquickitem/data/order.1.qml b/tests/auto/quick/qquickitem/data/order.1.qml
index 963288b257..963288b257 100644
--- a/tests/auto/qtquick2/qquickitem/data/order.1.qml
+++ b/tests/auto/quick/qquickitem/data/order.1.qml
diff --git a/tests/auto/qtquick2/qquickitem/data/order.2.qml b/tests/auto/quick/qquickitem/data/order.2.qml
index 5609c77e28..5609c77e28 100644
--- a/tests/auto/qtquick2/qquickitem/data/order.2.qml
+++ b/tests/auto/quick/qquickitem/data/order.2.qml
diff --git a/tests/auto/qtquick2/qquickitem/data/polishOnCompleted.qml b/tests/auto/quick/qquickitem/data/polishOnCompleted.qml
index 7008cdc67e..7008cdc67e 100644
--- a/tests/auto/qtquick2/qquickitem/data/polishOnCompleted.qml
+++ b/tests/auto/quick/qquickitem/data/polishOnCompleted.qml
diff --git a/tests/auto/quick/qquickitem/qquickitem.pro b/tests/auto/quick/qquickitem/qquickitem.pro
new file mode 100644
index 0000000000..cf24e63d05
--- /dev/null
+++ b/tests/auto/quick/qquickitem/qquickitem.pro
@@ -0,0 +1,14 @@
+CONFIG += testcase
+TARGET = tst_qquickitem
+SOURCES += tst_qquickitem.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private quick-private widgets testlib
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
new file mode 100644
index 0000000000..7a589a48cd
--- /dev/null
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -0,0 +1,1468 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickcanvas.h>
+#include <QtQuick/qquickview.h>
+#include <QtWidgets/QGraphicsSceneMouseEvent>
+#include "private/qquickfocusscope_p.h"
+#include "private/qquickitem_p.h"
+#include <QDebug>
+#include <QTimer>
+#include "../../shared/util.h"
+
+class TestItem : public QQuickItem
+{
+Q_OBJECT
+public:
+ TestItem(QQuickItem *parent = 0)
+ : QQuickItem(parent), focused(false), pressCount(0), releaseCount(0)
+ , wheelCount(0), acceptIncomingTouchEvents(true)
+ , touchEventReached(false) {}
+
+ bool focused;
+ int pressCount;
+ int releaseCount;
+ int wheelCount;
+ bool acceptIncomingTouchEvents;
+ bool touchEventReached;
+protected:
+ virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; }
+ virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; }
+ virtual void mousePressEvent(QMouseEvent *event) { event->accept(); ++pressCount; }
+ virtual void mouseReleaseEvent(QMouseEvent *event) { event->accept(); ++releaseCount; }
+ virtual void touchEvent(QTouchEvent *event) {
+ touchEventReached = true;
+ event->setAccepted(acceptIncomingTouchEvents);
+ }
+ virtual void wheelEvent(QWheelEvent *event) { event->accept(); ++wheelCount; }
+};
+
+class TestCanvas: public QQuickCanvas
+{
+public:
+ TestCanvas()
+ : QQuickCanvas()
+ {}
+
+ virtual bool event(QEvent *event)
+ {
+ return QQuickCanvas::event(event);
+ }
+};
+
+class TestPolishItem : public QQuickItem
+{
+Q_OBJECT
+public:
+ TestPolishItem(QQuickItem *parent = 0)
+ : QQuickItem(parent), wasPolished(false) {
+
+ }
+
+ bool wasPolished;
+
+protected:
+ virtual void updatePolish() {
+ wasPolished = true;
+ }
+
+public slots:
+ void doPolish() {
+ polish();
+ }
+};
+
+class TestFocusScope : public QQuickFocusScope
+{
+Q_OBJECT
+public:
+ TestFocusScope(QQuickItem *parent = 0) : QQuickFocusScope(parent), focused(false) {}
+
+ bool focused;
+protected:
+ virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; }
+ virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; }
+};
+
+class tst_qquickitem : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+
+private slots:
+ void initTestCase();
+
+ void noCanvas();
+ void simpleFocus();
+ void scopedFocus();
+ void addedToCanvas();
+ void changeParent();
+
+ void constructor();
+ void setParentItem();
+
+ void visible();
+ void enabled();
+ void enabledFocus();
+
+ void mouseGrab();
+ void touchEventAcceptIgnore_data();
+ void touchEventAcceptIgnore();
+ void polishOutsideAnimation();
+ void polishOnCompleted();
+
+ void wheelEvent_data();
+ void wheelEvent();
+ void hoverEvent_data();
+ void hoverEvent();
+ void hoverEventInParent();
+
+ void paintOrder_data();
+ void paintOrder();
+
+private:
+
+ enum PaintOrderOp {
+ NoOp, Append, Remove, StackBefore, StackAfter, SetZ
+ };
+
+ void ensureFocus(QWindow *w) {
+ w->show();
+ w->requestActivateWindow();
+ qApp->processEvents();
+ }
+};
+
+void tst_qquickitem::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ qmlRegisterType<TestPolishItem>("Qt.test", 1, 0, "TestPolishItem");
+}
+
+// Focus has no effect when outside a canvas
+void tst_qquickitem::noCanvas()
+{
+ QQuickItem *root = new TestItem;
+ QQuickItem *child = new TestItem(root);
+ QQuickItem *scope = new TestItem(root);
+ QQuickFocusScope *scopedChild = new TestFocusScope(scope);
+ QQuickFocusScope *scopedChild2 = new TestFocusScope(scope);
+
+ QCOMPARE(root->hasFocus(), false);
+ QCOMPARE(child->hasFocus(), false);
+ QCOMPARE(scope->hasFocus(), false);
+ QCOMPARE(scopedChild->hasFocus(), false);
+ QCOMPARE(scopedChild2->hasFocus(), false);
+
+ root->setFocus(true);
+ scope->setFocus(true);
+ scopedChild2->setFocus(true);
+ QCOMPARE(root->hasFocus(), true);
+ QCOMPARE(child->hasFocus(), false);
+ QCOMPARE(scope->hasFocus(), true);
+ QCOMPARE(scopedChild->hasFocus(), false);
+ QCOMPARE(scopedChild2->hasFocus(), true);
+
+ root->setFocus(false);
+ child->setFocus(true);
+ scopedChild->setFocus(true);
+ scope->setFocus(false);
+ QCOMPARE(root->hasFocus(), false);
+ QCOMPARE(child->hasFocus(), true);
+ QCOMPARE(scope->hasFocus(), false);
+ QCOMPARE(scopedChild->hasFocus(), true);
+ QCOMPARE(scopedChild2->hasFocus(), true);
+
+ delete root;
+}
+
+struct FocusData {
+ FocusData() : focus(false), activeFocus(false) {}
+
+ void set(bool f, bool af) { focus = f; activeFocus = af; }
+ bool focus;
+ bool activeFocus;
+};
+struct FocusState : public QHash<QQuickItem *, FocusData>
+{
+ FocusState() : activeFocusItem(0) {}
+ FocusState &operator<<(QQuickItem *item) {
+ insert(item, FocusData());
+ return *this;
+ }
+
+ void active(QQuickItem *i) {
+ activeFocusItem = i;
+ }
+ QQuickItem *activeFocusItem;
+};
+
+#define FVERIFY() \
+ do { \
+ if (focusState.activeFocusItem) { \
+ QCOMPARE(canvas.activeFocusItem(), focusState.activeFocusItem); \
+ if (qobject_cast<TestItem *>(canvas.activeFocusItem())) \
+ QCOMPARE(qobject_cast<TestItem *>(canvas.activeFocusItem())->focused, true); \
+ else if (qobject_cast<TestFocusScope *>(canvas.activeFocusItem())) \
+ QCOMPARE(qobject_cast<TestFocusScope *>(canvas.activeFocusItem())->focused, true); \
+ } else { \
+ QCOMPARE(canvas.activeFocusItem(), canvas.rootItem()); \
+ } \
+ for (QHash<QQuickItem *, FocusData>::Iterator iter = focusState.begin(); \
+ iter != focusState.end(); \
+ iter++) { \
+ QCOMPARE(iter.key()->hasFocus(), iter.value().focus); \
+ QCOMPARE(iter.key()->hasActiveFocus(), iter.value().activeFocus); \
+ } \
+ } while (false)
+
+// Tests a simple set of top-level scoped items
+void tst_qquickitem::simpleFocus()
+{
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+
+#ifdef Q_OS_MAC
+ QSKIP("QTBUG-24094: fails on Mac OS X 10.7");
+#endif
+
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+
+ QQuickItem *l1c1 = new TestItem(canvas.rootItem());
+ QQuickItem *l1c2 = new TestItem(canvas.rootItem());
+ QQuickItem *l1c3 = new TestItem(canvas.rootItem());
+
+ QQuickItem *l2c1 = new TestItem(l1c1);
+ QQuickItem *l2c2 = new TestItem(l1c1);
+ QQuickItem *l2c3 = new TestItem(l1c3);
+
+ FocusState focusState;
+ focusState << l1c1 << l1c2 << l1c3
+ << l2c1 << l2c2 << l2c3;
+ FVERIFY();
+
+ l1c1->setFocus(true);
+ focusState[l1c1].set(true, true);
+ focusState.active(l1c1);
+ FVERIFY();
+
+ l2c3->setFocus(true);
+ focusState[l1c1].set(false, false);
+ focusState[l2c3].set(true, true);
+ focusState.active(l2c3);
+ FVERIFY();
+
+ l1c3->setFocus(true);
+ focusState[l2c3].set(false, false);
+ focusState[l1c3].set(true, true);
+ focusState.active(l1c3);
+ FVERIFY();
+
+ l1c2->setFocus(false);
+ FVERIFY();
+
+ l1c3->setFocus(false);
+ focusState[l1c3].set(false, false);
+ focusState.active(0);
+ FVERIFY();
+
+ l2c1->setFocus(true);
+ focusState[l2c1].set(true, true);
+ focusState.active(l2c1);
+ FVERIFY();
+}
+
+// Items with a focus scope
+void tst_qquickitem::scopedFocus()
+{
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+
+ QQuickItem *l1c1 = new TestItem(canvas.rootItem());
+ QQuickItem *l1c2 = new TestItem(canvas.rootItem());
+ QQuickItem *l1c3 = new TestItem(canvas.rootItem());
+
+ QQuickItem *l2c1 = new TestItem(l1c1);
+ QQuickItem *l2c2 = new TestItem(l1c1);
+ QQuickItem *l2c3 = new TestFocusScope(l1c3);
+
+ QQuickItem *l3c1 = new TestItem(l2c3);
+ QQuickItem *l3c2 = new TestFocusScope(l2c3);
+
+ QQuickItem *l4c1 = new TestItem(l3c2);
+ QQuickItem *l4c2 = new TestItem(l3c2);
+
+ FocusState focusState;
+ focusState << l1c1 << l1c2 << l1c3
+ << l2c1 << l2c2 << l2c3
+ << l3c1 << l3c2
+ << l4c1 << l4c2;
+ FVERIFY();
+
+ l4c2->setFocus(true);
+ focusState[l4c2].set(true, false);
+ FVERIFY();
+
+ l4c1->setFocus(true);
+ focusState[l4c2].set(false, false);
+ focusState[l4c1].set(true, false);
+ FVERIFY();
+
+ l1c1->setFocus(true);
+ focusState[l1c1].set(true, true);
+ focusState.active(l1c1);
+ FVERIFY();
+
+ l3c2->setFocus(true);
+ focusState[l3c2].set(true, false);
+ FVERIFY();
+
+ l2c3->setFocus(true);
+ focusState[l1c1].set(false, false);
+ focusState[l2c3].set(true, true);
+ focusState[l3c2].set(true, true);
+ focusState[l4c1].set(true, true);
+ focusState.active(l4c1);
+ FVERIFY();
+
+ l3c2->setFocus(false);
+ focusState[l3c2].set(false, false);
+ focusState[l4c1].set(true, false);
+ focusState.active(l2c3);
+ FVERIFY();
+
+ l3c2->setFocus(true);
+ focusState[l3c2].set(true, true);
+ focusState[l4c1].set(true, true);
+ focusState.active(l4c1);
+ FVERIFY();
+
+ l4c1->setFocus(false);
+ focusState[l4c1].set(false, false);
+ focusState.active(l3c2);
+ FVERIFY();
+
+ l1c3->setFocus(true);
+ focusState[l1c3].set(true, true);
+ focusState[l2c3].set(false, false);
+ focusState[l3c2].set(true, false);
+ focusState.active(l1c3);
+ FVERIFY();
+}
+
+// Tests focus corrects itself when a tree is added to a canvas for the first time
+void tst_qquickitem::addedToCanvas()
+{
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+
+ QQuickItem *item = new TestItem;
+
+ FocusState focusState;
+ focusState << item;
+
+ item->setFocus(true);
+ focusState[item].set(true, false);
+ FVERIFY();
+
+ item->setParentItem(canvas.rootItem());
+ focusState[item].set(true, true);
+ focusState.active(item);
+ FVERIFY();
+ }
+
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+
+ QQuickItem *item = new TestItem(canvas.rootItem());
+
+ QQuickItem *tree = new TestItem;
+ QQuickItem *c1 = new TestItem(tree);
+ QQuickItem *c2 = new TestItem(tree);
+
+ FocusState focusState;
+ focusState << item << tree << c1 << c2;
+
+ item->setFocus(true);
+ c1->setFocus(true);
+ c2->setFocus(true);
+ focusState[item].set(true, true);
+ focusState[c1].set(true, false);
+ focusState[c2].set(true, false);
+ focusState.active(item);
+ FVERIFY();
+
+ tree->setParentItem(item);
+ focusState[c1].set(false, false);
+ focusState[c2].set(false, false);
+ FVERIFY();
+ }
+
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+
+ QQuickItem *tree = new TestItem;
+ QQuickItem *c1 = new TestItem(tree);
+ QQuickItem *c2 = new TestItem(tree);
+
+ FocusState focusState;
+ focusState << tree << c1 << c2;
+ c1->setFocus(true);
+ c2->setFocus(true);
+ focusState[c1].set(true, false);
+ focusState[c2].set(true, false);
+ FVERIFY();
+
+ tree->setParentItem(canvas.rootItem());
+ focusState[c1].set(true, true);
+ focusState[c2].set(false, false);
+ focusState.active(c1);
+ FVERIFY();
+ }
+
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+ QQuickItem *tree = new TestFocusScope;
+ QQuickItem *c1 = new TestItem(tree);
+ QQuickItem *c2 = new TestItem(tree);
+
+ FocusState focusState;
+ focusState << tree << c1 << c2;
+ c1->setFocus(true);
+ c2->setFocus(true);
+ focusState[c1].set(true, false);
+ focusState[c2].set(true, false);
+ FVERIFY();
+
+ tree->setParentItem(canvas.rootItem());
+ focusState[c1].set(true, false);
+ focusState[c2].set(false, false);
+ FVERIFY();
+
+ tree->setFocus(true);
+ focusState[tree].set(true, true);
+ focusState[c1].set(true, true);
+ focusState.active(c1);
+ FVERIFY();
+ }
+
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+ QQuickItem *tree = new TestFocusScope;
+ QQuickItem *c1 = new TestItem(tree);
+ QQuickItem *c2 = new TestItem(tree);
+
+ FocusState focusState;
+ focusState << tree << c1 << c2;
+ tree->setFocus(true);
+ c1->setFocus(true);
+ c2->setFocus(true);
+ focusState[tree].set(true, false);
+ focusState[c1].set(true, false);
+ focusState[c2].set(true, false);
+ FVERIFY();
+
+ tree->setParentItem(canvas.rootItem());
+ focusState[tree].set(true, true);
+ focusState[c1].set(true, true);
+ focusState[c2].set(false, false);
+ focusState.active(c1);
+ FVERIFY();
+ }
+
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+ QQuickItem *child = new TestItem(canvas.rootItem());
+ QQuickItem *tree = new TestFocusScope;
+ QQuickItem *c1 = new TestItem(tree);
+ QQuickItem *c2 = new TestItem(tree);
+
+ FocusState focusState;
+ focusState << child << tree << c1 << c2;
+ child->setFocus(true);
+ tree->setFocus(true);
+ c1->setFocus(true);
+ c2->setFocus(true);
+ focusState[child].set(true, true);
+ focusState[tree].set(true, false);
+ focusState[c1].set(true, false);
+ focusState[c2].set(true, false);
+ focusState.active(child);
+ FVERIFY();
+
+ tree->setParentItem(canvas.rootItem());
+ focusState[tree].set(false, false);
+ focusState[c1].set(true, false);
+ focusState[c2].set(false, false);
+ FVERIFY();
+
+ tree->setFocus(true);
+ focusState[child].set(false, false);
+ focusState[tree].set(true, true);
+ focusState[c1].set(true, true);
+ focusState.active(c1);
+ FVERIFY();
+ }
+}
+
+void tst_qquickitem::changeParent()
+{
+ // Parent to no parent
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+ QQuickItem *child = new TestItem(canvas.rootItem());
+
+ FocusState focusState;
+ focusState << child;
+ FVERIFY();
+
+ child->setFocus(true);
+ focusState[child].set(true, true);
+ focusState.active(child);
+ FVERIFY();
+
+ child->setParentItem(0);
+ focusState[child].set(true, false);
+ focusState.active(0);
+ FVERIFY();
+ }
+
+ // Different parent, same focus scope
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+ QQuickItem *child = new TestItem(canvas.rootItem());
+ QQuickItem *child2 = new TestItem(canvas.rootItem());
+
+ FocusState focusState;
+ focusState << child << child2;
+ FVERIFY();
+
+ child->setFocus(true);
+ focusState[child].set(true, true);
+ focusState.active(child);
+ FVERIFY();
+
+ child->setParentItem(child2);
+ FVERIFY();
+ }
+
+ // Different parent, different focus scope
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+ QQuickItem *child = new TestItem(canvas.rootItem());
+ QQuickItem *child2 = new TestFocusScope(canvas.rootItem());
+ QQuickItem *item = new TestItem(child);
+
+ FocusState focusState;
+ focusState << child << child2 << item;
+ FVERIFY();
+
+ item->setFocus(true);
+ focusState[item].set(true, true);
+ focusState.active(item);
+ FVERIFY();
+
+ item->setParentItem(child2);
+ focusState[item].set(true, false);
+ focusState.active(0);
+ FVERIFY();
+ }
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+ QQuickItem *child = new TestItem(canvas.rootItem());
+ QQuickItem *child2 = new TestFocusScope(canvas.rootItem());
+ QQuickItem *item = new TestItem(child2);
+
+ FocusState focusState;
+ focusState << child << child2 << item;
+ FVERIFY();
+
+ item->setFocus(true);
+ focusState[item].set(true, false);
+ focusState.active(0);
+ FVERIFY();
+
+ item->setParentItem(child);
+ focusState[item].set(true, true);
+ focusState.active(item);
+ FVERIFY();
+ }
+ {
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == &canvas);
+ QQuickItem *child = new TestItem(canvas.rootItem());
+ QQuickItem *child2 = new TestFocusScope(canvas.rootItem());
+ QQuickItem *item = new TestItem(child2);
+
+ FocusState focusState;
+ focusState << child << child2 << item;
+ FVERIFY();
+
+ child->setFocus(true);
+ item->setFocus(true);
+ focusState[child].set(true, true);
+ focusState[item].set(true, false);
+ focusState.active(child);
+ FVERIFY();
+
+ item->setParentItem(child);
+ focusState[item].set(false, false);
+ FVERIFY();
+ }
+
+}
+
+void tst_qquickitem::constructor()
+{
+ QQuickItem *root = new QQuickItem;
+ QVERIFY(root->parent() == 0);
+ QVERIFY(root->parentItem() == 0);
+
+ QQuickItem *child1 = new QQuickItem(root);
+ QVERIFY(child1->parent() == root);
+ QVERIFY(child1->parentItem() == root);
+ QCOMPARE(root->childItems().count(), 1);
+ QCOMPARE(root->childItems().at(0), child1);
+
+ QQuickItem *child2 = new QQuickItem(root);
+ QVERIFY(child2->parent() == root);
+ QVERIFY(child2->parentItem() == root);
+ QCOMPARE(root->childItems().count(), 2);
+ QCOMPARE(root->childItems().at(0), child1);
+ QCOMPARE(root->childItems().at(1), child2);
+
+ delete root;
+}
+
+void tst_qquickitem::setParentItem()
+{
+ QQuickItem *root = new QQuickItem;
+ QVERIFY(root->parent() == 0);
+ QVERIFY(root->parentItem() == 0);
+
+ QQuickItem *child1 = new QQuickItem;
+ QVERIFY(child1->parent() == 0);
+ QVERIFY(child1->parentItem() == 0);
+
+ child1->setParentItem(root);
+ QVERIFY(child1->parent() == 0);
+ QVERIFY(child1->parentItem() == root);
+ QCOMPARE(root->childItems().count(), 1);
+ QCOMPARE(root->childItems().at(0), child1);
+
+ QQuickItem *child2 = new QQuickItem;
+ QVERIFY(child2->parent() == 0);
+ QVERIFY(child2->parentItem() == 0);
+ child2->setParentItem(root);
+ QVERIFY(child2->parent() == 0);
+ QVERIFY(child2->parentItem() == root);
+ QCOMPARE(root->childItems().count(), 2);
+ QCOMPARE(root->childItems().at(0), child1);
+ QCOMPARE(root->childItems().at(1), child2);
+
+ child1->setParentItem(0);
+ QVERIFY(child1->parent() == 0);
+ QVERIFY(child1->parentItem() == 0);
+ QCOMPARE(root->childItems().count(), 1);
+ QCOMPARE(root->childItems().at(0), child2);
+
+ delete root;
+
+ QVERIFY(child1->parent() == 0);
+ QVERIFY(child1->parentItem() == 0);
+ QVERIFY(child2->parent() == 0);
+ QVERIFY(child2->parentItem() == 0);
+
+ delete child1;
+ delete child2;
+}
+
+void tst_qquickitem::visible()
+{
+ QQuickItem *root = new QQuickItem;
+
+ QQuickItem *child1 = new QQuickItem;
+ child1->setParentItem(root);
+
+ QQuickItem *child2 = new QQuickItem;
+ child2->setParentItem(root);
+
+ QVERIFY(child1->isVisible());
+ QVERIFY(child2->isVisible());
+
+ root->setVisible(false);
+ QVERIFY(!child1->isVisible());
+ QVERIFY(!child2->isVisible());
+
+ root->setVisible(true);
+ QVERIFY(child1->isVisible());
+ QVERIFY(child2->isVisible());
+
+ child1->setVisible(false);
+ QVERIFY(!child1->isVisible());
+ QVERIFY(child2->isVisible());
+
+ child2->setParentItem(child1);
+ QVERIFY(!child1->isVisible());
+ QVERIFY(!child2->isVisible());
+
+ child2->setParentItem(root);
+ QVERIFY(!child1->isVisible());
+ QVERIFY(child2->isVisible());
+
+ delete root;
+ delete child1;
+ delete child2;
+}
+
+void tst_qquickitem::enabled()
+{
+ QQuickItem *root = new QQuickItem;
+
+ QQuickItem *child1 = new QQuickItem;
+ child1->setParentItem(root);
+
+ QQuickItem *child2 = new QQuickItem;
+ child2->setParentItem(root);
+
+ QVERIFY(child1->isEnabled());
+ QVERIFY(child2->isEnabled());
+
+ root->setEnabled(false);
+ QVERIFY(!child1->isEnabled());
+ QVERIFY(!child2->isEnabled());
+
+ root->setEnabled(true);
+ QVERIFY(child1->isEnabled());
+ QVERIFY(child2->isEnabled());
+
+ child1->setEnabled(false);
+ QVERIFY(!child1->isEnabled());
+ QVERIFY(child2->isEnabled());
+
+ child2->setParentItem(child1);
+ QVERIFY(!child1->isEnabled());
+ QVERIFY(!child2->isEnabled());
+
+ child2->setParentItem(root);
+ QVERIFY(!child1->isEnabled());
+ QVERIFY(child2->isEnabled());
+
+ delete root;
+ delete child1;
+ delete child2;
+}
+
+void tst_qquickitem::enabledFocus()
+{
+ QQuickCanvas canvas;
+ ensureFocus(&canvas);
+
+ QQuickFocusScope root;
+
+ root.setFocus(true);
+ root.setEnabled(false);
+
+ QCOMPARE(root.isEnabled(), false);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), false);
+
+ root.setParentItem(canvas.rootItem());
+
+ QCOMPARE(root.isEnabled(), false);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), canvas.rootItem());
+
+ root.setEnabled(true);
+ QCOMPARE(root.isEnabled(), true);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), true);
+ QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
+
+ QQuickItem child1;
+ child1.setParentItem(&root);
+
+ QCOMPARE(child1.isEnabled(), true);
+ QCOMPARE(child1.hasFocus(), false);
+ QCOMPARE(child1.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
+
+ QQuickItem child2;
+ child2.setFocus(true);
+ child2.setParentItem(&root);
+
+ QCOMPARE(root.isEnabled(), true);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), true);
+ QCOMPARE(child2.isEnabled(), true);
+ QCOMPARE(child2.hasFocus(), true);
+ QCOMPARE(child2.hasActiveFocus(), true);
+ QCOMPARE(canvas.activeFocusItem(), &child2);
+
+ child2.setEnabled(false);
+
+ QCOMPARE(root.isEnabled(), true);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), true);
+ QCOMPARE(child1.isEnabled(), true);
+ QCOMPARE(child1.hasFocus(), false);
+ QCOMPARE(child1.hasActiveFocus(), false);
+ QCOMPARE(child2.isEnabled(), false);
+ QCOMPARE(child2.hasFocus(), true);
+ QCOMPARE(child2.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
+
+ child1.setEnabled(false);
+ QCOMPARE(child1.isEnabled(), false);
+ QCOMPARE(child1.hasFocus(), false);
+ QCOMPARE(child1.hasActiveFocus(), false);
+
+ child1.setFocus(true);
+ QCOMPARE(child1.isEnabled(), false);
+ QCOMPARE(child1.hasFocus(), true);
+ QCOMPARE(child1.hasActiveFocus(), false);
+ QCOMPARE(child2.isEnabled(), false);
+ QCOMPARE(child2.hasFocus(), false);
+ QCOMPARE(child2.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
+
+ child1.setEnabled(true);
+ QCOMPARE(child1.isEnabled(), true);
+ QCOMPARE(child1.hasFocus(), true);
+ QCOMPARE(child1.hasActiveFocus(), true);
+ QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&child1));
+
+ root.setFocus(false);
+ QCOMPARE(root.isEnabled(), true);
+ QCOMPARE(root.hasFocus(), false);
+ QCOMPARE(root.hasActiveFocus(), false);
+ QCOMPARE(child1.isEnabled(), true);
+ QCOMPARE(child1.hasFocus(), true);
+ QCOMPARE(child1.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), canvas.rootItem());
+
+ child2.forceActiveFocus();
+ QCOMPARE(root.isEnabled(), true);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), true);
+ QCOMPARE(child1.isEnabled(), true);
+ QCOMPARE(child1.hasFocus(), false);
+ QCOMPARE(child1.hasActiveFocus(), false);
+ QCOMPARE(child2.isEnabled(), false);
+ QCOMPARE(child2.hasFocus(), true);
+ QCOMPARE(child2.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&root));
+
+ root.setEnabled(false);
+ QCOMPARE(root.isEnabled(), false);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), false);
+ QCOMPARE(child1.isEnabled(), false);
+ QCOMPARE(child1.hasFocus(), false);
+ QCOMPARE(child1.hasActiveFocus(), false);
+ QCOMPARE(child2.isEnabled(), false);
+ QCOMPARE(child2.hasFocus(), true);
+ QCOMPARE(child2.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), canvas.rootItem());
+
+ child1.forceActiveFocus();
+ QCOMPARE(root.isEnabled(), false);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), false);
+ QCOMPARE(child1.isEnabled(), false);
+ QCOMPARE(child1.hasFocus(), true);
+ QCOMPARE(child1.hasActiveFocus(), false);
+ QCOMPARE(child2.isEnabled(), false);
+ QCOMPARE(child2.hasFocus(), false);
+ QCOMPARE(child2.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), canvas.rootItem());
+
+ root.setEnabled(true);
+ QCOMPARE(root.isEnabled(), true);
+ QCOMPARE(root.hasFocus(), true);
+ QCOMPARE(root.hasActiveFocus(), true);
+ QCOMPARE(child1.isEnabled(), true);
+ QCOMPARE(child1.hasFocus(), true);
+ QCOMPARE(child1.hasActiveFocus(), true);
+ QCOMPARE(child2.isEnabled(), false);
+ QCOMPARE(child2.hasFocus(), false);
+ QCOMPARE(child2.hasActiveFocus(), false);
+ QCOMPARE(canvas.activeFocusItem(), static_cast<QQuickItem *>(&child1));
+}
+
+void tst_qquickitem::mouseGrab()
+{
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(200, 200);
+ canvas->show();
+
+ TestItem *child1 = new TestItem;
+ child1->setAcceptedMouseButtons(Qt::LeftButton);
+ child1->setSize(QSizeF(200, 100));
+ child1->setParentItem(canvas->rootItem());
+
+ TestItem *child2 = new TestItem;
+ child2->setAcceptedMouseButtons(Qt::LeftButton);
+ child2->setY(51);
+ child2->setSize(QSizeF(200, 100));
+ child2->setParentItem(canvas->rootItem());
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(100);
+ QVERIFY(canvas->mouseGrabberItem() == child1);
+ QTest::qWait(100);
+
+ QCOMPARE(child1->pressCount, 1);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(50);
+ QVERIFY(canvas->mouseGrabberItem() == 0);
+ QCOMPARE(child1->releaseCount, 1);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(50);
+ QVERIFY(canvas->mouseGrabberItem() == child1);
+ QCOMPARE(child1->pressCount, 2);
+ child1->setEnabled(false);
+ QVERIFY(canvas->mouseGrabberItem() == 0);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(50);
+ QCOMPARE(child1->releaseCount, 1);
+ child1->setEnabled(true);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(50);
+ QVERIFY(canvas->mouseGrabberItem() == child1);
+ QCOMPARE(child1->pressCount, 3);
+ child1->setVisible(false);
+ QVERIFY(canvas->mouseGrabberItem() == 0);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QCOMPARE(child1->releaseCount, 1);
+ child1->setVisible(true);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(50);
+ QVERIFY(canvas->mouseGrabberItem() == child1);
+ QCOMPARE(child1->pressCount, 4);
+ child2->grabMouse();
+ QVERIFY(canvas->mouseGrabberItem() == child2);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(50);
+ QCOMPARE(child1->releaseCount, 1);
+ QCOMPARE(child2->releaseCount, 1);
+
+ child2->grabMouse();
+ QVERIFY(canvas->mouseGrabberItem() == child2);
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(50);
+ QCOMPARE(child1->pressCount, 4);
+ QCOMPARE(child2->pressCount, 1);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50,50));
+ QTest::qWait(50);
+ QCOMPARE(child1->releaseCount, 1);
+ QCOMPARE(child2->releaseCount, 2);
+
+ delete child1;
+ delete child2;
+ delete canvas;
+}
+
+void tst_qquickitem::touchEventAcceptIgnore_data()
+{
+ QTest::addColumn<bool>("itemSupportsTouch");
+
+ QTest::newRow("with touch") << true;
+ QTest::newRow("without touch") << false;
+}
+
+void tst_qquickitem::touchEventAcceptIgnore()
+{
+ QFETCH(bool, itemSupportsTouch);
+
+ TestCanvas *canvas = new TestCanvas;
+ canvas->resize(100, 100);
+ canvas->show();
+
+ TestItem *item = new TestItem;
+ item->setSize(QSizeF(100, 100));
+ item->setParentItem(canvas->rootItem());
+ item->acceptIncomingTouchEvents = itemSupportsTouch;
+
+ static QTouchDevice* device = 0;
+ if (!device) {
+ device =new QTouchDevice;
+ device->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(device);
+ }
+
+ // Send Begin, Update & End touch sequence
+ {
+ QTouchEvent::TouchPoint point;
+ point.setId(1);
+ point.setPos(QPointF(50, 50));
+ point.setScreenPos(point.pos());
+ point.setState(Qt::TouchPointPressed);
+
+ QTouchEvent event(QEvent::TouchBegin, device,
+ Qt::NoModifier,
+ Qt::TouchPointPressed,
+ QList<QTouchEvent::TouchPoint>() << point);
+ event.setAccepted(true);
+
+ item->touchEventReached = false;
+
+ bool accepted = canvas->event(&event);
+
+ QVERIFY(item->touchEventReached);
+ QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch);
+ }
+ {
+ QTouchEvent::TouchPoint point;
+ point.setId(1);
+ point.setPos(QPointF(60, 60));
+ point.setScreenPos(point.pos());
+ point.setState(Qt::TouchPointMoved);
+
+ QTouchEvent event(QEvent::TouchUpdate, device,
+ Qt::NoModifier,
+ Qt::TouchPointMoved,
+ QList<QTouchEvent::TouchPoint>() << point);
+ event.setAccepted(true);
+
+ item->touchEventReached = false;
+
+ bool accepted = canvas->event(&event);
+
+ QCOMPARE(item->touchEventReached, itemSupportsTouch);
+ QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch);
+ }
+ {
+ QTouchEvent::TouchPoint point;
+ point.setId(1);
+ point.setPos(QPointF(60, 60));
+ point.setScreenPos(point.pos());
+ point.setState(Qt::TouchPointReleased);
+
+ QTouchEvent event(QEvent::TouchEnd, device,
+ Qt::NoModifier,
+ Qt::TouchPointReleased,
+ QList<QTouchEvent::TouchPoint>() << point);
+ event.setAccepted(true);
+
+ item->touchEventReached = false;
+
+ bool accepted = canvas->event(&event);
+
+ QCOMPARE(item->touchEventReached, itemSupportsTouch);
+ QCOMPARE(accepted && event.isAccepted(), itemSupportsTouch);
+ }
+
+ delete item;
+ delete canvas;
+}
+
+void tst_qquickitem::polishOutsideAnimation()
+{
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(200, 200);
+ canvas->show();
+
+ TestPolishItem *item = new TestPolishItem(canvas->rootItem());
+ item->setSize(QSizeF(200, 100));
+ QTest::qWait(50);
+
+ QTimer::singleShot(10, item, SLOT(doPolish()));
+ QTRY_VERIFY(item->wasPolished);
+
+ delete item;
+ delete canvas;
+}
+
+void tst_qquickitem::polishOnCompleted()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("polishOnCompleted.qml"));
+ view->show();
+
+ TestPolishItem *item = qobject_cast<TestPolishItem*>(view->rootObject());
+ QVERIFY(item);
+
+#ifdef Q_OS_MAC
+ QSKIP("QTBUG-21590 view does not reliably receive polish without a running animation");
+#endif
+
+ QTRY_VERIFY(item->wasPolished);
+
+ delete view;
+}
+
+void tst_qquickitem::wheelEvent_data()
+{
+ QTest::addColumn<bool>("visible");
+ QTest::addColumn<bool>("enabled");
+
+ QTest::newRow("visible and enabled") << true << true;
+ QTest::newRow("visible and disabled") << true << false;
+ QTest::newRow("invisible and enabled") << false << true;
+ QTest::newRow("invisible and disabled") << false << false;
+}
+
+void tst_qquickitem::wheelEvent()
+{
+ QFETCH(bool, visible);
+ QFETCH(bool, enabled);
+
+ const bool shouldReceiveWheelEvents = visible && enabled;
+
+ QQuickCanvas *canvas = new QQuickCanvas;
+ canvas->resize(200, 200);
+ canvas->show();
+
+ TestItem *item = new TestItem;
+ item->setSize(QSizeF(200, 100));
+ item->setParentItem(canvas->rootItem());
+
+ item->setEnabled(enabled);
+ item->setVisible(visible);
+
+ QWheelEvent event(QPoint(100, 50), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical);
+ event.setAccepted(false);
+ QGuiApplication::sendEvent(canvas, &event);
+
+ if (shouldReceiveWheelEvents) {
+ QVERIFY(event.isAccepted());
+ QCOMPARE(item->wheelCount, 1);
+ } else {
+ QVERIFY(!event.isAccepted());
+ QCOMPARE(item->wheelCount, 0);
+ }
+
+ delete canvas;
+}
+
+class HoverItem : public QQuickItem
+{
+Q_OBJECT
+public:
+ HoverItem(QQuickItem *parent = 0)
+ : QQuickItem(parent), hoverEnterCount(0), hoverMoveCount(0), hoverLeaveCount(0)
+ { }
+ void resetCounters() {
+ hoverEnterCount = 0;
+ hoverMoveCount = 0;
+ hoverLeaveCount = 0;
+ }
+ int hoverEnterCount;
+ int hoverMoveCount;
+ int hoverLeaveCount;
+protected:
+ virtual void hoverEnterEvent(QHoverEvent *event) {
+ event->accept();
+ ++hoverEnterCount;
+ }
+ virtual void hoverMoveEvent(QHoverEvent *event) {
+ event->accept();
+ ++hoverMoveCount;
+ }
+ virtual void hoverLeaveEvent(QHoverEvent *event) {
+ event->accept();
+ ++hoverLeaveCount;
+ }
+};
+
+void tst_qquickitem::hoverEvent_data()
+{
+ QTest::addColumn<bool>("visible");
+ QTest::addColumn<bool>("enabled");
+ QTest::addColumn<bool>("acceptHoverEvents");
+
+ QTest::newRow("visible, enabled, accept hover") << true << true << true;
+ QTest::newRow("visible, disabled, accept hover") << true << false << true;
+ QTest::newRow("invisible, enabled, accept hover") << false << true << true;
+ QTest::newRow("invisible, disabled, accept hover") << false << false << true;
+
+ QTest::newRow("visible, enabled, not accept hover") << true << true << false;
+ QTest::newRow("visible, disabled, not accept hover") << true << false << false;
+ QTest::newRow("invisible, enabled, not accept hover") << false << true << false;
+ QTest::newRow("invisible, disabled, not accept hover") << false << false << false;
+}
+
+// ### For some unknown reason QTest::mouseMove() isn't working correctly.
+static void sendMouseMove(QObject *object, const QPoint &position)
+{
+ QMouseEvent moveEvent(QEvent::MouseMove, position, Qt::NoButton, Qt::NoButton, 0);
+ QGuiApplication::sendEvent(object, &moveEvent);
+}
+
+void tst_qquickitem::hoverEvent()
+{
+ QFETCH(bool, visible);
+ QFETCH(bool, enabled);
+ QFETCH(bool, acceptHoverEvents);
+
+ QQuickCanvas *canvas = new QQuickCanvas();
+ canvas->resize(200, 200);
+ canvas->show();
+
+ HoverItem *item = new HoverItem;
+ item->setSize(QSizeF(100, 100));
+ item->setParentItem(canvas->rootItem());
+
+ item->setEnabled(enabled);
+ item->setVisible(visible);
+ item->setAcceptHoverEvents(acceptHoverEvents);
+
+ const QPoint outside(150, 150);
+ const QPoint inside(50, 50);
+ const QPoint anotherInside(51, 51);
+
+ sendMouseMove(canvas, outside);
+ item->resetCounters();
+
+ // Enter, then move twice inside, then leave.
+ sendMouseMove(canvas, inside);
+ sendMouseMove(canvas, anotherInside);
+ sendMouseMove(canvas, inside);
+ sendMouseMove(canvas, outside);
+
+ const bool shouldReceiveHoverEvents = visible && enabled && acceptHoverEvents;
+ if (shouldReceiveHoverEvents) {
+ QCOMPARE(item->hoverEnterCount, 1);
+ QCOMPARE(item->hoverMoveCount, 2);
+ QCOMPARE(item->hoverLeaveCount, 1);
+ } else {
+ QCOMPARE(item->hoverEnterCount, 0);
+ QCOMPARE(item->hoverMoveCount, 0);
+ QCOMPARE(item->hoverLeaveCount, 0);
+ }
+
+ delete canvas;
+}
+
+void tst_qquickitem::hoverEventInParent()
+{
+ QQuickCanvas *canvas = new QQuickCanvas();
+ canvas->resize(200, 200);
+ canvas->show();
+
+ HoverItem *parentItem = new HoverItem(canvas->rootItem());
+ parentItem->setSize(QSizeF(200, 200));
+ parentItem->setAcceptHoverEvents(true);
+
+ HoverItem *leftItem = new HoverItem(parentItem);
+ leftItem->setSize(QSizeF(100, 200));
+ leftItem->setAcceptHoverEvents(true);
+
+ HoverItem *rightItem = new HoverItem(parentItem);
+ rightItem->setSize(QSizeF(100, 200));
+ rightItem->setPos(QPointF(100, 0));
+ rightItem->setAcceptHoverEvents(true);
+
+ const QPoint insideLeft(50, 100);
+ const QPoint insideRight(150, 100);
+
+ sendMouseMove(canvas, insideLeft);
+ parentItem->resetCounters();
+ leftItem->resetCounters();
+ rightItem->resetCounters();
+
+ sendMouseMove(canvas, insideRight);
+ QCOMPARE(parentItem->hoverEnterCount, 0);
+ QCOMPARE(parentItem->hoverLeaveCount, 0);
+ QCOMPARE(leftItem->hoverEnterCount, 0);
+ QCOMPARE(leftItem->hoverLeaveCount, 1);
+ QCOMPARE(rightItem->hoverEnterCount, 1);
+ QCOMPARE(rightItem->hoverLeaveCount, 0);
+
+ sendMouseMove(canvas, insideLeft);
+ QCOMPARE(parentItem->hoverEnterCount, 0);
+ QCOMPARE(parentItem->hoverLeaveCount, 0);
+ QCOMPARE(leftItem->hoverEnterCount, 1);
+ QCOMPARE(leftItem->hoverLeaveCount, 1);
+ QCOMPARE(rightItem->hoverEnterCount, 1);
+ QCOMPARE(rightItem->hoverLeaveCount, 1);
+
+ delete canvas;
+}
+
+void tst_qquickitem::paintOrder_data()
+{
+ const QUrl order1Url = testFileUrl("order.1.qml");
+ const QUrl order2Url = testFileUrl("order.2.qml");
+
+ QTest::addColumn<QUrl>("source");
+ QTest::addColumn<int>("op");
+ QTest::addColumn<QVariant>("param1");
+ QTest::addColumn<QVariant>("param2");
+ QTest::addColumn<QStringList>("expected");
+
+ QTest::newRow("test 1 noop") << order1Url
+ << int(NoOp) << QVariant() << QVariant()
+ << (QStringList() << "1" << "2" << "3");
+ QTest::newRow("test 1 add") << order1Url
+ << int(Append) << QVariant("new") << QVariant()
+ << (QStringList() << "1" << "2" << "3" << "new");
+ QTest::newRow("test 1 remove") << order1Url
+ << int(Remove) << QVariant(1) << QVariant()
+ << (QStringList() << "1" << "3");
+ QTest::newRow("test 1 stack before") << order1Url
+ << int(StackBefore) << QVariant(2) << QVariant(1)
+ << (QStringList() << "1" << "3" << "2");
+ QTest::newRow("test 1 stack after") << order1Url
+ << int(StackAfter) << QVariant(0) << QVariant(1)
+ << (QStringList() << "2" << "1" << "3");
+ QTest::newRow("test 1 set z") << order1Url
+ << int(SetZ) << QVariant(1) << QVariant(qreal(1.))
+ << (QStringList() << "1" << "3" << "2");
+
+ QTest::newRow("test 2 noop") << order2Url
+ << int(NoOp) << QVariant() << QVariant()
+ << (QStringList() << "1" << "3" << "2");
+ QTest::newRow("test 2 add") << order2Url
+ << int(Append) << QVariant("new") << QVariant()
+ << (QStringList() << "1" << "3" << "new" << "2");
+ QTest::newRow("test 2 remove 1") << order2Url
+ << int(Remove) << QVariant(1) << QVariant()
+ << (QStringList() << "1" << "3");
+ QTest::newRow("test 2 remove 2") << order2Url
+ << int(Remove) << QVariant(2) << QVariant()
+ << (QStringList() << "1" << "2");
+ QTest::newRow("test 2 stack before 1") << order2Url
+ << int(StackBefore) << QVariant(1) << QVariant(0)
+ << (QStringList() << "1" << "3" << "2");
+ QTest::newRow("test 2 stack before 2") << order2Url
+ << int(StackBefore) << QVariant(2) << QVariant(0)
+ << (QStringList() << "3" << "1" << "2");
+ QTest::newRow("test 2 stack after 1") << order2Url
+ << int(StackAfter) << QVariant(0) << QVariant(1)
+ << (QStringList() << "1" << "3" << "2");
+ QTest::newRow("test 2 stack after 2") << order2Url
+ << int(StackAfter) << QVariant(0) << QVariant(2)
+ << (QStringList() << "3" << "1" << "2");
+ QTest::newRow("test 1 set z") << order1Url
+ << int(SetZ) << QVariant(2) << QVariant(qreal(2.))
+ << (QStringList() << "1" << "2" << "3");
+}
+
+void tst_qquickitem::paintOrder()
+{
+ QFETCH(QUrl, source);
+ QFETCH(int, op);
+ QFETCH(QVariant, param1);
+ QFETCH(QVariant, param2);
+ QFETCH(QStringList, expected);
+
+ QQuickView view;
+ view.setSource(source);
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(view.rootObject());
+ QVERIFY(root);
+
+ switch (op) {
+ case Append: {
+ QQuickItem *item = new QQuickItem(root);
+ item->setObjectName(param1.toString());
+ }
+ break;
+ case Remove: {
+ QQuickItem *item = root->childItems().at(param1.toInt());
+ delete item;
+ }
+ break;
+ case StackBefore: {
+ QQuickItem *item1 = root->childItems().at(param1.toInt());
+ QQuickItem *item2 = root->childItems().at(param2.toInt());
+ item1->stackBefore(item2);
+ }
+ break;
+ case StackAfter: {
+ QQuickItem *item1 = root->childItems().at(param1.toInt());
+ QQuickItem *item2 = root->childItems().at(param2.toInt());
+ item1->stackAfter(item2);
+ }
+ break;
+ case SetZ: {
+ QQuickItem *item = root->childItems().at(param1.toInt());
+ item->setZ(param2.toReal());
+ }
+ break;
+ default:
+ break;
+ }
+
+ QList<QQuickItem*> list = QQuickItemPrivate::get(root)->paintOrderChildItems();
+
+ QStringList items;
+ for (int i = 0; i < list.count(); ++i)
+ items << list.at(i)->objectName();
+
+ QCOMPARE(items, expected);
+}
+
+
+QTEST_MAIN(tst_qquickitem)
+
+#include "tst_qquickitem.moc"
diff --git a/tests/auto/qtquick2/qquickitem2/data/childrenProperty.qml b/tests/auto/quick/qquickitem2/data/childrenProperty.qml
index 85ddbc1446..85ddbc1446 100644
--- a/tests/auto/qtquick2/qquickitem2/data/childrenProperty.qml
+++ b/tests/auto/quick/qquickitem2/data/childrenProperty.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/childrenRect.qml b/tests/auto/quick/qquickitem2/data/childrenRect.qml
index ebc57aefbe..ebc57aefbe 100644
--- a/tests/auto/qtquick2/qquickitem2/data/childrenRect.qml
+++ b/tests/auto/quick/qquickitem2/data/childrenRect.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug.qml b/tests/auto/quick/qquickitem2/data/childrenRectBug.qml
index 86a4f19c5c..86a4f19c5c 100644
--- a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug.qml
+++ b/tests/auto/quick/qquickitem2/data/childrenRectBug.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug2.qml b/tests/auto/quick/qquickitem2/data/childrenRectBug2.qml
index 6e80ed28af..6e80ed28af 100644
--- a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug2.qml
+++ b/tests/auto/quick/qquickitem2/data/childrenRectBug2.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug3.qml b/tests/auto/quick/qquickitem2/data/childrenRectBug3.qml
index 518e76509e..518e76509e 100644
--- a/tests/auto/qtquick2/qquickitem2/data/childrenRectBug3.qml
+++ b/tests/auto/quick/qquickitem2/data/childrenRectBug3.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/implicitsize.qml b/tests/auto/quick/qquickitem2/data/implicitsize.qml
index cc6aaf7d60..cc6aaf7d60 100644
--- a/tests/auto/qtquick2/qquickitem2/data/implicitsize.qml
+++ b/tests/auto/quick/qquickitem2/data/implicitsize.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/keynavigationtest.qml b/tests/auto/quick/qquickitem2/data/keynavigationtest.qml
index aacb621fb0..aacb621fb0 100644
--- a/tests/auto/qtquick2/qquickitem2/data/keynavigationtest.qml
+++ b/tests/auto/quick/qquickitem2/data/keynavigationtest.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/keynavigationtest_implicit.qml b/tests/auto/quick/qquickitem2/data/keynavigationtest_implicit.qml
index 92d4ae23de..92d4ae23de 100644
--- a/tests/auto/qtquick2/qquickitem2/data/keynavigationtest_implicit.qml
+++ b/tests/auto/quick/qquickitem2/data/keynavigationtest_implicit.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/keysim.qml b/tests/auto/quick/qquickitem2/data/keysim.qml
index 7da8a47681..7da8a47681 100644
--- a/tests/auto/qtquick2/qquickitem2/data/keysim.qml
+++ b/tests/auto/quick/qquickitem2/data/keysim.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/keyspriority.qml b/tests/auto/quick/qquickitem2/data/keyspriority.qml
index ae51aae776..ae51aae776 100644
--- a/tests/auto/qtquick2/qquickitem2/data/keyspriority.qml
+++ b/tests/auto/quick/qquickitem2/data/keyspriority.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/keystest.qml b/tests/auto/quick/qquickitem2/data/keystest.qml
index c70e0061f5..c70e0061f5 100644
--- a/tests/auto/qtquick2/qquickitem2/data/keystest.qml
+++ b/tests/auto/quick/qquickitem2/data/keystest.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/layoutmirroring.qml b/tests/auto/quick/qquickitem2/data/layoutmirroring.qml
index 036819740c..036819740c 100644
--- a/tests/auto/qtquick2/qquickitem2/data/layoutmirroring.qml
+++ b/tests/auto/quick/qquickitem2/data/layoutmirroring.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/mapCoordinates.qml b/tests/auto/quick/qquickitem2/data/mapCoordinates.qml
index 7b979a54b3..7b979a54b3 100644
--- a/tests/auto/qtquick2/qquickitem2/data/mapCoordinates.qml
+++ b/tests/auto/quick/qquickitem2/data/mapCoordinates.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/parentLoop.qml b/tests/auto/quick/qquickitem2/data/parentLoop.qml
index 7b6560fbf7..7b6560fbf7 100644
--- a/tests/auto/qtquick2/qquickitem2/data/parentLoop.qml
+++ b/tests/auto/quick/qquickitem2/data/parentLoop.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/propertychanges.qml b/tests/auto/quick/qquickitem2/data/propertychanges.qml
index 3fa5ea9c23..3fa5ea9c23 100644
--- a/tests/auto/qtquick2/qquickitem2/data/propertychanges.qml
+++ b/tests/auto/quick/qquickitem2/data/propertychanges.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/qtbug_16871.qml b/tests/auto/quick/qquickitem2/data/qtbug_16871.qml
index f1e7377730..f1e7377730 100644
--- a/tests/auto/qtquick2/qquickitem2/data/qtbug_16871.qml
+++ b/tests/auto/quick/qquickitem2/data/qtbug_16871.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/resourcesProperty.qml b/tests/auto/quick/qquickitem2/data/resourcesProperty.qml
index b8f18bb375..b8f18bb375 100644
--- a/tests/auto/qtquick2/qquickitem2/data/resourcesProperty.qml
+++ b/tests/auto/quick/qquickitem2/data/resourcesProperty.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/transformCrash.qml b/tests/auto/quick/qquickitem2/data/transformCrash.qml
index 284e85f0e0..284e85f0e0 100644
--- a/tests/auto/qtquick2/qquickitem2/data/transformCrash.qml
+++ b/tests/auto/quick/qquickitem2/data/transformCrash.qml
diff --git a/tests/auto/qtquick2/qquickitem2/data/visiblechildren.qml b/tests/auto/quick/qquickitem2/data/visiblechildren.qml
index e51eb3551b..e51eb3551b 100644
--- a/tests/auto/qtquick2/qquickitem2/data/visiblechildren.qml
+++ b/tests/auto/quick/qquickitem2/data/visiblechildren.qml
diff --git a/tests/auto/quick/qquickitem2/qquickitem2.pro b/tests/auto/quick/qquickitem2/qquickitem2.pro
new file mode 100644
index 0000000000..29897ba3c1
--- /dev/null
+++ b/tests/auto/quick/qquickitem2/qquickitem2.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickitem2
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickitem.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
new file mode 100644
index 0000000000..c2390c4525
--- /dev/null
+++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
@@ -0,0 +1,1380 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQuick/qquickview.h>
+#include <QtGui/private/qinputmethod_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQuick/private/qquicktextinput_p.h>
+#include <private/qquickitem_p.h>
+#include "../../shared/util.h"
+#include "../shared/visualtestutil.h"
+#include "../../shared/platforminputcontext.h"
+
+using namespace QQuickVisualTestUtil;
+
+class tst_QQuickItem : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickItem();
+
+private slots:
+ void initTestCase();
+ void cleanup();
+
+ void keys();
+ void keysProcessingOrder();
+ void keysim();
+ void keyNavigation();
+ void keyNavigation_RightToLeft();
+ void keyNavigation_skipNotVisible();
+ void keyNavigation_implicitSetting();
+ void layoutMirroring();
+ void layoutMirroringIllegalParent();
+ void smooth();
+ void clip();
+ void mapCoordinates();
+ void mapCoordinates_data();
+ void propertyChanges();
+ void transforms();
+ void transforms_data();
+ void childrenRect();
+ void childrenRectBug();
+ void childrenRectBug2();
+ void childrenRectBug3();
+
+ void childrenProperty();
+ void resourcesProperty();
+
+ void transformCrash();
+ void implicitSize();
+ void qtbug_16871();
+ void visibleChildren();
+ void parentLoop();
+private:
+ QQmlEngine engine;
+};
+
+class KeysTestObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool processLast READ processLast NOTIFY processLastChanged)
+
+public:
+ KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0), mLast(false) {}
+
+ void reset() {
+ mKey = 0;
+ mText = QString();
+ mModifiers = 0;
+ mForwardedKey = 0;
+ }
+
+ bool processLast() const { return mLast; }
+ void setProcessLast(bool b) {
+ if (b != mLast) {
+ mLast = b;
+ emit processLastChanged();
+ }
+ }
+
+public slots:
+ void keyPress(int key, QString text, int modifiers) {
+ mKey = key;
+ mText = text;
+ mModifiers = modifiers;
+ }
+ void keyRelease(int key, QString text, int modifiers) {
+ mKey = key;
+ mText = text;
+ mModifiers = modifiers;
+ }
+ void forwardedKey(int key) {
+ mForwardedKey = key;
+ }
+
+signals:
+ void processLastChanged();
+
+public:
+ int mKey;
+ QString mText;
+ int mModifiers;
+ int mForwardedKey;
+ bool mLast;
+
+private:
+};
+
+class KeyTestItem : public QQuickItem
+{
+ Q_OBJECT
+public:
+ KeyTestItem(QQuickItem *parent=0) : QQuickItem(parent), mKey(0) {}
+
+protected:
+ void keyPressEvent(QKeyEvent *e) {
+ mKey = e->key();
+
+ if (e->key() == Qt::Key_A)
+ e->accept();
+ else
+ e->ignore();
+ }
+
+ void keyReleaseEvent(QKeyEvent *e) {
+ if (e->key() == Qt::Key_B)
+ e->accept();
+ else
+ e->ignore();
+ }
+
+public:
+ int mKey;
+};
+
+QML_DECLARE_TYPE(KeyTestItem);
+
+
+tst_QQuickItem::tst_QQuickItem()
+{
+}
+
+void tst_QQuickItem::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ qmlRegisterType<KeyTestItem>("Test",1,0,"KeyTestItem");
+}
+
+void tst_QQuickItem::cleanup()
+{
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = 0;
+}
+
+void tst_QQuickItem::keys()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(240,320));
+
+ KeysTestObject *testObject = new KeysTestObject;
+ canvas->rootContext()->setContextProperty("keysTestObject", testObject);
+
+ canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true));
+ canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(true));
+
+ canvas->setSource(testFileUrl("keystest.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
+
+ QVERIFY(canvas->rootObject());
+ QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true);
+
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_A));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A));
+ QCOMPARE(testObject->mText, QLatin1String("A"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(!key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::ShiftModifier, "A", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_A));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A));
+ QCOMPARE(testObject->mText, QLatin1String("A"));
+ QVERIFY(testObject->mModifiers == Qt::ShiftModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_Return));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Return));
+ QCOMPARE(testObject->mText, QLatin1String("Return"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_0, Qt::NoModifier, "0", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_0));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_0));
+ QCOMPARE(testObject->mText, QLatin1String("0"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_9, Qt::NoModifier, "9", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_9));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_9));
+ QCOMPARE(testObject->mText, QLatin1String("9"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(!key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_Tab));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Tab));
+ QCOMPARE(testObject->mText, QLatin1String("Tab"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_Backtab));
+ QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Backtab));
+ QCOMPARE(testObject->mText, QLatin1String("Backtab"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(false));
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_A));
+ QCOMPARE(testObject->mForwardedKey, 0);
+ QCOMPARE(testObject->mText, QLatin1String("A"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(!key.isAccepted());
+
+ testObject->reset();
+
+ canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false));
+ QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), false);
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, 0);
+ QVERIFY(!key.isAccepted());
+
+ canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true));
+ QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true);
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_Return));
+ QVERIFY(key.isAccepted());
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickItem::keysProcessingOrder()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(240,320));
+
+ KeysTestObject *testObject = new KeysTestObject;
+ canvas->rootContext()->setContextProperty("keysTestObject", testObject);
+
+ canvas->setSource(testFileUrl("keyspriority.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
+
+ KeyTestItem *testItem = qobject_cast<KeyTestItem*>(canvas->rootObject());
+ QVERIFY(testItem);
+
+ QCOMPARE(testItem->property("priorityTest").toInt(), 0);
+
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_A));
+ QCOMPARE(testObject->mText, QLatin1String("A"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ testObject->setProcessLast(true);
+
+ QCOMPARE(testItem->property("priorityTest").toInt(), 1);
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, 0);
+ QVERIFY(key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_B, Qt::NoModifier, "B", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, int(Qt::Key_B));
+ QCOMPARE(testObject->mText, QLatin1String("B"));
+ QVERIFY(testObject->mModifiers == Qt::NoModifier);
+ QVERIFY(!key.isAccepted());
+
+ testObject->reset();
+
+ key = QKeyEvent(QEvent::KeyRelease, Qt::Key_B, Qt::NoModifier, "B", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QCOMPARE(testObject->mKey, 0);
+ QVERIFY(key.isAccepted());
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickItem::keysim()
+{
+ PlatformInputContext platformInputContext;
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &platformInputContext;
+
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(240,320));
+
+ canvas->setSource(testFileUrl("keysim.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
+
+ QVERIFY(canvas->rootObject());
+ QVERIFY(canvas->rootObject()->hasFocus() && canvas->rootObject()->hasActiveFocus());
+
+ QQuickTextInput *input = canvas->rootObject()->findChild<QQuickTextInput*>();
+ QVERIFY(input);
+
+ QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>());
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev);
+
+ QEXPECT_FAIL("", "QTBUG-24280", Continue);
+ QCOMPARE(input->text(), QLatin1String("Hello world!"));
+
+ delete canvas;
+}
+
+QQuickItemPrivate *childPrivate(QQuickItem *rootItem, const char * itemString)
+{
+ QQuickItem *item = findItem<QQuickItem>(rootItem, QString(QLatin1String(itemString)));
+ QQuickItemPrivate* itemPrivate = QQuickItemPrivate::get(item);
+ return itemPrivate;
+}
+
+QVariant childProperty(QQuickItem *rootItem, const char * itemString, const char * property)
+{
+ QQuickItem *item = findItem<QQuickItem>(rootItem, QString(QLatin1String(itemString)));
+ return item->property(property);
+}
+
+bool anchorsMirrored(QQuickItem *rootItem, const char * itemString)
+{
+ QQuickItem *item = findItem<QQuickItem>(rootItem, QString(QLatin1String(itemString)));
+ QQuickItemPrivate* itemPrivate = QQuickItemPrivate::get(item);
+ return itemPrivate->anchors()->mirrored();
+}
+
+void tst_QQuickItem::layoutMirroring()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(testFileUrl("layoutmirroring.qml"));
+ canvas->show();
+
+ QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootItem);
+ QQuickItemPrivate *rootPrivate = QQuickItemPrivate::get(rootItem);
+ QVERIFY(rootPrivate);
+
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "mirrored2")->effectiveLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored2")->effectiveLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true);
+
+ QCOMPARE(anchorsMirrored(rootItem, "mirrored1"), true);
+ QCOMPARE(anchorsMirrored(rootItem, "mirrored2"), true);
+ QCOMPARE(anchorsMirrored(rootItem, "notMirrored1"), false);
+ QCOMPARE(anchorsMirrored(rootItem, "notMirrored2"), false);
+ QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror1"), true);
+ QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror2"), true);
+
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritedLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritedLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true);
+
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->isMirrorImplicit, false);
+ QCOMPARE(childPrivate(rootItem, "mirrored2")->isMirrorImplicit, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->isMirrorImplicit, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored2")->isMirrorImplicit, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->isMirrorImplicit, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->isMirrorImplicit, true);
+
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromParent, true);
+ QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromParent, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromParent, true);
+ QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromParent, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromParent, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromParent, true);
+
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromItem, true);
+ QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromItem, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromItem, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromItem, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromItem, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromItem, false);
+
+ // load dynamic content using Loader that needs to inherit mirroring
+ rootItem->setProperty("state", "newContent");
+ QCOMPARE(childPrivate(rootItem, "notMirrored3")->effectiveLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->effectiveLayoutMirror, true);
+
+ QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritedLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritedLayoutMirror, true);
+
+ QCOMPARE(childPrivate(rootItem, "notMirrored3")->isMirrorImplicit, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->isMirrorImplicit, true);
+
+ QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromParent, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritMirrorFromParent, true);
+
+ QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false);
+
+ // disable inheritance
+ rootItem->setProperty("childrenInherit", false);
+
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false);
+
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, false);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, false);
+
+ // re-enable inheritance
+ rootItem->setProperty("childrenInherit", true);
+
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false);
+
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true);
+ QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true);
+
+ //
+ // dynamic parenting
+ //
+ QQuickItem *parentItem1 = new QQuickItem();
+ QQuickItemPrivate::get(parentItem1)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true
+ QQuickItemPrivate::get(parentItem1)->isMirrorImplicit = false;
+ QQuickItemPrivate::get(parentItem1)->inheritMirrorFromItem = true; // LayoutMirroring.childrenInherit: true
+ QQuickItemPrivate::get(parentItem1)->resolveLayoutMirror();
+
+ // inherit in constructor
+ QQuickItem *childItem1 = new QQuickItem(parentItem1);
+ QCOMPARE(QQuickItemPrivate::get(childItem1)->effectiveLayoutMirror, true);
+ QCOMPARE(QQuickItemPrivate::get(childItem1)->inheritMirrorFromParent, true);
+
+ // inherit through a parent change
+ QQuickItem *childItem2 = new QQuickItem();
+ QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, false);
+ QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, false);
+ childItem2->setParentItem(parentItem1);
+ QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, true);
+ QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, true);
+
+ // stop inherting through a parent change
+ QQuickItem *parentItem2 = new QQuickItem();
+ QQuickItemPrivate::get(parentItem2)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true
+ QQuickItemPrivate::get(parentItem2)->resolveLayoutMirror();
+ childItem2->setParentItem(parentItem2);
+ QCOMPARE(QQuickItemPrivate::get(childItem2)->effectiveLayoutMirror, false);
+ QCOMPARE(QQuickItemPrivate::get(childItem2)->inheritMirrorFromParent, false);
+
+ delete parentItem1;
+ delete parentItem2;
+}
+
+void tst_QQuickItem::layoutMirroringIllegalParent()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { LayoutMirroring.enabled: true; LayoutMirroring.childrenInherit: true }", QUrl::fromLocalFile(""));
+ QTest::ignoreMessage(QtWarningMsg, "file::1:21: QML QtObject: LayoutDirection attached property only works with Items");
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
+void tst_QQuickItem::keyNavigation()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(240,320));
+
+ canvas->setSource(testFileUrl("keynavigationtest.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
+
+ QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ QVariant result;
+ QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify",
+ Q_RETURN_ARG(QVariant, result)));
+ QVERIFY(result.toBool());
+
+ // right
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // down
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item4");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // left
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item3");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // up
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // tab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // backtab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ delete canvas;
+}
+
+void tst_QQuickItem::keyNavigation_RightToLeft()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(240,320));
+
+ canvas->setSource(testFileUrl("keynavigationtest.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
+
+ QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootItem);
+ QQuickItemPrivate* rootItemPrivate = QQuickItemPrivate::get(rootItem);
+
+ rootItemPrivate->effectiveLayoutMirror = true; // LayoutMirroring.mirror: true
+ rootItemPrivate->isMirrorImplicit = false;
+ rootItemPrivate->inheritMirrorFromItem = true; // LayoutMirroring.inherit: true
+ rootItemPrivate->resolveLayoutMirror();
+
+ QEvent wa(QEvent::WindowActivate);
+ QGuiApplication::sendEvent(canvas, &wa);
+ QFocusEvent fe(QEvent::FocusIn);
+ QGuiApplication::sendEvent(canvas, &fe);
+
+ QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ QVariant result;
+ QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify",
+ Q_RETURN_ARG(QVariant, result)));
+ QVERIFY(result.toBool());
+
+ // right
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // left
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ delete canvas;
+}
+
+void tst_QQuickItem::keyNavigation_skipNotVisible()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(240,320));
+
+ canvas->setSource(testFileUrl("keynavigationtest.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
+
+ QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // Set item 2 to not visible
+ item = findItem<QQuickItem>(canvas->rootObject(), "item2");
+ QVERIFY(item);
+ item->setVisible(false);
+ QVERIFY(!item->isVisible());
+
+ // right
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // tab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item3");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // backtab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ //Set item 3 to not visible
+ item = findItem<QQuickItem>(canvas->rootObject(), "item3");
+ QVERIFY(item);
+ item->setVisible(false);
+ QVERIFY(!item->isVisible());
+
+ // tab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item4");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // backtab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ delete canvas;
+}
+
+void tst_QQuickItem::keyNavigation_implicitSetting()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(240,320));
+
+ canvas->setSource(testFileUrl("keynavigationtest_implicit.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
+
+ QEvent wa(QEvent::WindowActivate);
+ QGuiApplication::sendEvent(canvas, &wa);
+ QFocusEvent fe(QEvent::FocusIn);
+ QGuiApplication::sendEvent(canvas, &fe);
+
+ QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ QVariant result;
+ QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify",
+ Q_RETURN_ARG(QVariant, result)));
+ QVERIFY(result.toBool());
+
+ // right
+ QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // back to item1
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // down
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item3");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // move to item4
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item4");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // left
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item3");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // back to item4
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item4");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // up
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item2");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // back to item4
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item4");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // tab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item1");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // back to item4
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item4");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ // backtab
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1);
+ QGuiApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+
+ item = findItem<QQuickItem>(canvas->rootObject(), "item3");
+ QVERIFY(item);
+ QVERIFY(item->hasActiveFocus());
+
+ delete canvas;
+}
+
+void tst_QQuickItem::smooth()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; Item { smooth: false; }", QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QSignalSpy spy(item, SIGNAL(smoothChanged(bool)));
+
+ QVERIFY(item);
+ QVERIFY(!item->smooth());
+
+ item->setSmooth(true);
+ QVERIFY(item->smooth());
+ QCOMPARE(spy.count(),1);
+ QList<QVariant> arguments = spy.first();
+ QVERIFY(arguments.count() == 1);
+ QVERIFY(arguments.at(0).toBool() == true);
+
+ item->setSmooth(true);
+ QCOMPARE(spy.count(),1);
+
+ item->setSmooth(false);
+ QVERIFY(!item->smooth());
+ QCOMPARE(spy.count(),2);
+ item->setSmooth(false);
+ QCOMPARE(spy.count(),2);
+
+ delete item;
+}
+
+void tst_QQuickItem::clip()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nItem { clip: false\n }", QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QSignalSpy spy(item, SIGNAL(clipChanged(bool)));
+
+ QVERIFY(item);
+ QVERIFY(!item->clip());
+
+ item->setClip(true);
+ QVERIFY(item->clip());
+
+ QList<QVariant> arguments = spy.first();
+ QVERIFY(arguments.count() == 1);
+ QVERIFY(arguments.at(0).toBool() == true);
+
+ QCOMPARE(spy.count(),1);
+ item->setClip(true);
+ QCOMPARE(spy.count(),1);
+
+ item->setClip(false);
+ QVERIFY(!item->clip());
+ QCOMPARE(spy.count(),2);
+ item->setClip(false);
+ QCOMPARE(spy.count(),2);
+
+ delete item;
+}
+
+void tst_QQuickItem::mapCoordinates()
+{
+ QFETCH(int, x);
+ QFETCH(int, y);
+
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(300, 300));
+ canvas->setSource(testFileUrl("mapCoordinates.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root != 0);
+ QQuickItem *a = findItem<QQuickItem>(canvas->rootObject(), "itemA");
+ QVERIFY(a != 0);
+ QQuickItem *b = findItem<QQuickItem>(canvas->rootObject(), "itemB");
+ QVERIFY(b != 0);
+
+ QVariant result;
+
+ QVERIFY(QMetaObject::invokeMethod(root, "mapAToB",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapToItem(b, QPointF(x, y)));
+
+ QVERIFY(QMetaObject::invokeMethod(root, "mapAFromB",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapFromItem(b, QPointF(x, y)));
+
+ QVERIFY(QMetaObject::invokeMethod(root, "mapAToNull",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapToScene(QPointF(x, y)));
+
+ QVERIFY(QMetaObject::invokeMethod(root, "mapAFromNull",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapFromScene(QPointF(x, y)));
+
+ QString warning1 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapToItem() given argument \"1122\" which is neither null nor an Item";
+ QString warning2 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapFromItem() given argument \"1122\" which is neither null nor an Item";
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QVERIFY(QMetaObject::invokeMethod(root, "checkMapAToInvalid",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QVERIFY(result.toBool());
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QVERIFY(QMetaObject::invokeMethod(root, "checkMapAFromInvalid",
+ Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
+ QVERIFY(result.toBool());
+
+ delete canvas;
+}
+
+void tst_QQuickItem::mapCoordinates_data()
+{
+ QTest::addColumn<int>("x");
+ QTest::addColumn<int>("y");
+
+ for (int i=-20; i<=20; i+=10)
+ QTest::newRow(QTest::toString(i)) << i << i;
+}
+
+void tst_QQuickItem::transforms_data()
+{
+ QTest::addColumn<QByteArray>("qml");
+ QTest::addColumn<QTransform>("transform");
+ QTest::newRow("translate") << QByteArray("Translate { x: 10; y: 20 }")
+ << QTransform(1,0,0,0,1,0,10,20,1);
+ QTest::newRow("rotation") << QByteArray("Rotation { angle: 90 }")
+ << QTransform(0,1,0,-1,0,0,0,0,1);
+ QTest::newRow("scale") << QByteArray("Scale { xScale: 1.5; yScale: -2 }")
+ << QTransform(1.5,0,0,0,-2,0,0,0,1);
+ QTest::newRow("sequence") << QByteArray("[ Translate { x: 10; y: 20 }, Scale { xScale: 1.5; yScale: -2 } ]")
+ << QTransform(1,0,0,0,1,0,10,20,1) * QTransform(1.5,0,0,0,-2,0,0,0,1);
+}
+
+void tst_QQuickItem::transforms()
+{
+ QFETCH(QByteArray, qml);
+ QFETCH(QTransform, transform);
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nItem { transform: "+qml+"}", QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(item->itemTransform(0,0), transform);
+}
+
+void tst_QQuickItem::childrenProperty()
+{
+ QQmlComponent component(&engine, testFileUrl("childrenProperty.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+ delete o;
+}
+
+void tst_QQuickItem::resourcesProperty()
+{
+ QQmlComponent component(&engine, testFileUrl("resourcesProperty.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test4").toBool(), true);
+ QCOMPARE(o->property("test5").toBool(), true);
+ delete o;
+}
+
+void tst_QQuickItem::propertyChanges()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(300, 300));
+ canvas->setSource(testFileUrl("propertychanges.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(QGuiApplication::focusWindow() == canvas);
+
+ QQuickItem *item = findItem<QQuickItem>(canvas->rootObject(), "item");
+ QQuickItem *parentItem = findItem<QQuickItem>(canvas->rootObject(), "parentItem");
+
+ QVERIFY(item);
+ QVERIFY(parentItem);
+
+ QSignalSpy parentSpy(item, SIGNAL(parentChanged(QQuickItem *)));
+ QSignalSpy widthSpy(item, SIGNAL(widthChanged()));
+ QSignalSpy heightSpy(item, SIGNAL(heightChanged()));
+ QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal)));
+ QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF)));
+ QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool)));
+ QSignalSpy wantsFocusSpy(parentItem, SIGNAL(activeFocusChanged(bool)));
+ QSignalSpy childrenChangedSpy(parentItem, SIGNAL(childrenChanged()));
+ QSignalSpy xSpy(item, SIGNAL(xChanged()));
+ QSignalSpy ySpy(item, SIGNAL(yChanged()));
+
+ item->setParentItem(parentItem);
+ item->setWidth(100.0);
+ item->setHeight(200.0);
+ item->setFocus(true);
+ item->setBaselineOffset(10.0);
+
+ QCOMPARE(item->parentItem(), parentItem);
+ QCOMPARE(parentSpy.count(),1);
+ QList<QVariant> parentArguments = parentSpy.first();
+ QVERIFY(parentArguments.count() == 1);
+ QCOMPARE(item->parentItem(), qvariant_cast<QQuickItem *>(parentArguments.at(0)));
+ QCOMPARE(childrenChangedSpy.count(),1);
+
+ item->setParentItem(parentItem);
+ QCOMPARE(childrenChangedSpy.count(),1);
+
+ QCOMPARE(item->width(), 100.0);
+ QCOMPARE(widthSpy.count(),1);
+
+ QCOMPARE(item->height(), 200.0);
+ QCOMPARE(heightSpy.count(),1);
+
+ QCOMPARE(item->baselineOffset(), 10.0);
+ QCOMPARE(baselineOffsetSpy.count(),1);
+ QList<QVariant> baselineOffsetArguments = baselineOffsetSpy.first();
+ QVERIFY(baselineOffsetArguments.count() == 1);
+ QCOMPARE(item->baselineOffset(), baselineOffsetArguments.at(0).toReal());
+
+ QCOMPARE(parentItem->childrenRect(), QRectF(0.0,0.0,100.0,200.0));
+ QCOMPARE(childrenRectSpy.count(),1);
+ QList<QVariant> childrenRectArguments = childrenRectSpy.at(0);
+ QVERIFY(childrenRectArguments.count() == 1);
+ QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF());
+
+ QCOMPARE(item->hasActiveFocus(), true);
+ QCOMPARE(focusSpy.count(),1);
+ QList<QVariant> focusArguments = focusSpy.first();
+ QVERIFY(focusArguments.count() == 1);
+ QCOMPARE(focusArguments.at(0).toBool(), true);
+
+ QCOMPARE(parentItem->hasActiveFocus(), false);
+ QCOMPARE(parentItem->hasFocus(), false);
+ QCOMPARE(wantsFocusSpy.count(),0);
+
+ item->setX(10.0);
+ QCOMPARE(item->x(), 10.0);
+ QCOMPARE(xSpy.count(), 1);
+
+ item->setY(10.0);
+ QCOMPARE(item->y(), 10.0);
+ QCOMPARE(ySpy.count(), 1);
+
+ delete canvas;
+}
+
+void tst_QQuickItem::childrenRect()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(testFileUrl("childrenRect.qml"));
+ canvas->setBaseSize(QSize(240,320));
+ canvas->show();
+
+ QQuickItem *o = canvas->rootObject();
+ QQuickItem *item = o->findChild<QQuickItem*>("testItem");
+ QCOMPARE(item->width(), qreal(0));
+ QCOMPARE(item->height(), qreal(0));
+
+ o->setProperty("childCount", 1);
+ QCOMPARE(item->width(), qreal(10));
+ QCOMPARE(item->height(), qreal(20));
+
+ o->setProperty("childCount", 5);
+ QCOMPARE(item->width(), qreal(50));
+ QCOMPARE(item->height(), qreal(100));
+
+ o->setProperty("childCount", 0);
+ QCOMPARE(item->width(), qreal(0));
+ QCOMPARE(item->height(), qreal(0));
+
+ delete o;
+ delete canvas;
+}
+
+// QTBUG-11383
+void tst_QQuickItem::childrenRectBug()
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ QString warning = testFileUrl("childrenRectBug.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\"";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ canvas->setSource(testFileUrl("childrenRectBug.qml"));
+ canvas->show();
+
+ QQuickItem *o = canvas->rootObject();
+ QQuickItem *item = o->findChild<QQuickItem*>("theItem");
+ QCOMPARE(item->width(), qreal(200));
+ QCOMPARE(item->height(), qreal(100));
+ QCOMPARE(item->x(), qreal(100));
+
+ delete canvas;
+}
+
+// QTBUG-11465
+void tst_QQuickItem::childrenRectBug2()
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ QString warning1 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"width\"";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+
+ QString warning2 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\"";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ canvas->setSource(testFileUrl("childrenRectBug2.qml"));
+ canvas->show();
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(canvas->rootObject());
+ QVERIFY(rect);
+ QQuickItem *item = rect->findChild<QQuickItem*>("theItem");
+ QCOMPARE(item->width(), qreal(100));
+ QCOMPARE(item->height(), qreal(110));
+ QCOMPARE(item->x(), qreal(130));
+
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ rectPrivate->setState("row");
+ QCOMPARE(item->width(), qreal(210));
+ QCOMPARE(item->height(), qreal(50));
+ QCOMPARE(item->x(), qreal(75));
+
+ delete canvas;
+}
+
+// QTBUG-12722
+void tst_QQuickItem::childrenRectBug3()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(testFileUrl("childrenRectBug3.qml"));
+ canvas->show();
+
+ //don't crash on delete
+ delete canvas;
+}
+
+// QTBUG-13893
+void tst_QQuickItem::transformCrash()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(testFileUrl("transformCrash.qml"));
+ canvas->show();
+
+ delete canvas;
+}
+
+void tst_QQuickItem::implicitSize()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(testFileUrl("implicitsize.qml"));
+ canvas->show();
+
+ QQuickItem *item = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(item);
+ QCOMPARE(item->width(), qreal(80));
+ QCOMPARE(item->height(), qreal(60));
+
+ QCOMPARE(item->implicitWidth(), qreal(200));
+ QCOMPARE(item->implicitHeight(), qreal(100));
+
+ QMetaObject::invokeMethod(item, "resetSize");
+
+ QCOMPARE(item->width(), qreal(200));
+ QCOMPARE(item->height(), qreal(100));
+
+ QMetaObject::invokeMethod(item, "changeImplicit");
+
+ QCOMPARE(item->implicitWidth(), qreal(150));
+ QCOMPARE(item->implicitHeight(), qreal(80));
+ QCOMPARE(item->width(), qreal(150));
+ QCOMPARE(item->height(), qreal(80));
+
+ delete canvas;
+}
+
+void tst_QQuickItem::qtbug_16871()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_16871.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ delete o;
+}
+
+
+void tst_QQuickItem::visibleChildren()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(testFileUrl("visiblechildren.qml"));
+ canvas->show();
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root);
+
+ QCOMPARE(root->property("test1_1").toBool(), true);
+ QCOMPARE(root->property("test1_2").toBool(), true);
+ QCOMPARE(root->property("test1_3").toBool(), true);
+ QCOMPARE(root->property("test1_4").toBool(), true);
+
+ QMetaObject::invokeMethod(root, "hideFirstAndLastRowChild");
+ QCOMPARE(root->property("test2_1").toBool(), true);
+ QCOMPARE(root->property("test2_2").toBool(), true);
+ QCOMPARE(root->property("test2_3").toBool(), true);
+ QCOMPARE(root->property("test2_4").toBool(), true);
+
+ QMetaObject::invokeMethod(root, "showLastRowChildsLastChild");
+ QCOMPARE(root->property("test3_1").toBool(), true);
+ QCOMPARE(root->property("test3_2").toBool(), true);
+ QCOMPARE(root->property("test3_3").toBool(), true);
+ QCOMPARE(root->property("test3_4").toBool(), true);
+
+ QMetaObject::invokeMethod(root, "showLastRowChild");
+ QCOMPARE(root->property("test4_1").toBool(), true);
+ QCOMPARE(root->property("test4_2").toBool(), true);
+ QCOMPARE(root->property("test4_3").toBool(), true);
+ QCOMPARE(root->property("test4_4").toBool(), true);
+
+ QString warning1 = testFileUrl("visiblechildren.qml").toString() + ":96:32: QML Item: QQuickItem: visibleChildren property is readonly and cannot be assigned to.";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QMetaObject::invokeMethod(root, "tryWriteToReadonlyVisibleChildren");
+ QCOMPARE(root->property("test5_1").toBool(), true);
+
+ QMetaObject::invokeMethod(root, "reparentVisibleItem3");
+ QCOMPARE(root->property("test6_1").toBool(), true);
+ QCOMPARE(root->property("test6_2").toBool(), true);
+ QCOMPARE(root->property("test6_3").toBool(), true);
+ QCOMPARE(root->property("test6_4").toBool(), true);
+
+ QMetaObject::invokeMethod(root, "reparentImlicitlyInvisibleItem4_1");
+ QCOMPARE(root->property("test7_1").toBool(), true);
+ QCOMPARE(root->property("test7_2").toBool(), true);
+ QCOMPARE(root->property("test7_3").toBool(), true);
+ QCOMPARE(root->property("test7_4").toBool(), true);
+
+ // FINALLY TEST THAT EVERYTHING IS AS EXPECTED
+ QCOMPARE(root->property("test8_1").toBool(), true);
+ QCOMPARE(root->property("test8_2").toBool(), true);
+ QCOMPARE(root->property("test8_3").toBool(), true);
+ QCOMPARE(root->property("test8_4").toBool(), true);
+ QCOMPARE(root->property("test8_5").toBool(), true);
+
+ delete canvas;
+}
+
+void tst_QQuickItem::parentLoop()
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ QTest::ignoreMessage(QtWarningMsg, "QQuickItem::setParentItem: Parent is already part of this items subtree.");
+ canvas->setSource(testFileUrl("parentLoop.qml"));
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root);
+
+ QQuickItem *item1 = root->findChild<QQuickItem*>("item1");
+ QVERIFY(item1);
+ QCOMPARE(item1->parentItem(), root);
+
+ QQuickItem *item2 = root->findChild<QQuickItem*>("item2");
+ QVERIFY(item2);
+ QCOMPARE(item2->parentItem(), item1);
+
+ delete canvas;
+}
+
+QTEST_MAIN(tst_QQuickItem)
+
+#include "tst_qquickitem.moc"
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/DisableLayer.qml b/tests/auto/quick/qquickitemlayer/data/DisableLayer.qml
index 70fc05e937..70fc05e937 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/DisableLayer.qml
+++ b/tests/auto/quick/qquickitemlayer/data/DisableLayer.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/Effect.qml b/tests/auto/quick/qquickitemlayer/data/Effect.qml
index 630c8f90ed..630c8f90ed 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/Effect.qml
+++ b/tests/auto/quick/qquickitemlayer/data/Effect.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/Enabled.qml b/tests/auto/quick/qquickitemlayer/data/Enabled.qml
index 0e7d4f56b8..0e7d4f56b8 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/Enabled.qml
+++ b/tests/auto/quick/qquickitemlayer/data/Enabled.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/ItemEffect.qml b/tests/auto/quick/qquickitemlayer/data/ItemEffect.qml
index 2f17d78efd..2f17d78efd 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/ItemEffect.qml
+++ b/tests/auto/quick/qquickitemlayer/data/ItemEffect.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/Mipmap.qml b/tests/auto/quick/qquickitemlayer/data/Mipmap.qml
index 8de41076e9..8de41076e9 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/Mipmap.qml
+++ b/tests/auto/quick/qquickitemlayer/data/Mipmap.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/RectangleEffect.qml b/tests/auto/quick/qquickitemlayer/data/RectangleEffect.qml
index 94c43f2caf..94c43f2caf 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/RectangleEffect.qml
+++ b/tests/auto/quick/qquickitemlayer/data/RectangleEffect.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/SamplerNameChange.qml b/tests/auto/quick/qquickitemlayer/data/SamplerNameChange.qml
index a4c2ebff6b..a4c2ebff6b 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/SamplerNameChange.qml
+++ b/tests/auto/quick/qquickitemlayer/data/SamplerNameChange.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/Smooth.qml b/tests/auto/quick/qquickitemlayer/data/Smooth.qml
index 3f9575bb0b..3f9575bb0b 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/Smooth.qml
+++ b/tests/auto/quick/qquickitemlayer/data/Smooth.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/SourceRect.qml b/tests/auto/quick/qquickitemlayer/data/SourceRect.qml
index 7cc7e8b21e..7cc7e8b21e 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/SourceRect.qml
+++ b/tests/auto/quick/qquickitemlayer/data/SourceRect.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/TextureProvider.qml b/tests/auto/quick/qquickitemlayer/data/TextureProvider.qml
index ccd515652a..ccd515652a 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/TextureProvider.qml
+++ b/tests/auto/quick/qquickitemlayer/data/TextureProvider.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/ToggleLayerAndEffect.qml b/tests/auto/quick/qquickitemlayer/data/ToggleLayerAndEffect.qml
index 174b669b6c..174b669b6c 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/ToggleLayerAndEffect.qml
+++ b/tests/auto/quick/qquickitemlayer/data/ToggleLayerAndEffect.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/Visible.qml b/tests/auto/quick/qquickitemlayer/data/Visible.qml
index 8267f18250..8267f18250 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/Visible.qml
+++ b/tests/auto/quick/qquickitemlayer/data/Visible.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/ZOrder.qml b/tests/auto/quick/qquickitemlayer/data/ZOrder.qml
index 59ccb32224..59ccb32224 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/ZOrder.qml
+++ b/tests/auto/quick/qquickitemlayer/data/ZOrder.qml
diff --git a/tests/auto/qtquick2/qquickitemlayer/data/ZOrderChange.qml b/tests/auto/quick/qquickitemlayer/data/ZOrderChange.qml
index ebbd3b7e15..ebbd3b7e15 100644
--- a/tests/auto/qtquick2/qquickitemlayer/data/ZOrderChange.qml
+++ b/tests/auto/quick/qquickitemlayer/data/ZOrderChange.qml
diff --git a/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro b/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro
new file mode 100644
index 0000000000..a2d5f401ff
--- /dev/null
+++ b/tests/auto/quick/qquickitemlayer/qquickitemlayer.pro
@@ -0,0 +1,38 @@
+CONFIG += testcase
+TARGET = tst_qquickitemlayer
+SOURCES += tst_qquickitemlayer.cpp
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+include(../../shared/util.pri)
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private quick-private testlib
+
+OTHER_FILES += \
+ data/Smooth.qml \
+ data/Enabled.qml \
+ data/Mipmap.qml \
+ data/Effect.qml \
+ data/SourceRect.qml \
+ data/TextureProvider.qml \
+ data/Visible.qml \
+ data/ZOrder.qml \
+ data/ZOrderChange.qml \
+ data/ToggleLayerAndEffect.qml \
+ data/DisableLayer.qml \
+ data/SamplerNameChange.qml \
+ data/ItemEffect.qml \
+ data/RectangleEffect.qml
+
+
+
+
+
+
+
+
diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
new file mode 100644
index 0000000000..44d0d6d09c
--- /dev/null
+++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp
@@ -0,0 +1,436 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+#include <QtGui/qopenglcontext.h>
+
+#include "../../shared/util.h"
+
+class tst_QQuickItemLayer: public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickItemLayer();
+
+ QImage runTest(const QString &url)
+ {
+ QQuickView view;
+ view.setSource(QUrl(url));
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ return view.grabFrameBuffer();
+ }
+
+private slots:
+ void layerEnabled();
+ void layerSmooth();
+ void layerMipmap();
+ void layerEffect();
+
+ void layerVisibility_data();
+ void layerVisibility();
+
+ void layerSourceRect();
+
+ void layerZOrder_data();
+ void layerZOrder();
+
+ void layerIsTextureProvider();
+
+ void changeZOrder_data();
+ void changeZOrder();
+
+ void toggleLayerAndEffect();
+ void disableLayer();
+ void changeSamplerName();
+ void itemEffect();
+ void rectangleEffect();
+
+private:
+ bool m_isMesaSoftwareRasterizer;
+ int m_mesaVersion;
+};
+
+tst_QQuickItemLayer::tst_QQuickItemLayer()
+ : m_mesaVersion(0)
+{
+ QWindow window;
+ QOpenGLContext context;
+ window.setSurfaceType(QWindow::OpenGLSurface);
+ window.create();
+ context.create();
+ context.makeCurrent(&window);
+ const char *vendor = (const char *)glGetString(GL_VENDOR);
+ const char *renderer = (const char *)glGetString(GL_RENDERER);
+ m_isMesaSoftwareRasterizer = strcmp(vendor, "Mesa Project") == 0
+ && strcmp(renderer, "Software Rasterizer") == 0;
+ if (m_isMesaSoftwareRasterizer) {
+ // Expects format: <OpenGL version> Mesa <Mesa version>[-devel] [...]
+ const char *version = (const char *)glGetString(GL_VERSION);
+ QList<QByteArray> list = QByteArray(version).split(' ');
+ if (list.size() >= 3) {
+ list = list.at(2).split('-').at(0).split('.');
+ int major = 0;
+ int minor = 0;
+ int patch = 0;
+ if (list.size() >= 1)
+ major = list.at(0).toInt();
+ if (list.size() >= 2)
+ minor = list.at(1).toInt();
+ if (list.size() >= 3)
+ patch = list.at(2).toInt();
+ m_mesaVersion = QT_VERSION_CHECK(major, minor, patch);
+ }
+ }
+}
+
+// The test draws a red and a blue box next to each other and tests that the
+// output is still red and blue on the left and right and a combination of
+// the two in the middle.
+
+void tst_QQuickItemLayer::layerSmooth()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+ QImage fb = runTest(testFile("Smooth.qml"));
+ QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff));
+
+ uint pixel = fb.pixel(fb.width() / 2, 0);
+ QVERIFY(qRed(pixel) > 0);
+ QVERIFY(qBlue(pixel) > 0);
+}
+
+
+
+// The test draws a gradient at a small size into a layer and scales the
+// layer. If the layer is enabled there should be very visible bands in
+// the gradient.
+
+void tst_QQuickItemLayer::layerEnabled()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+ QImage fb = runTest(testFile("Enabled.qml"));
+ // Verify the banding
+ QCOMPARE(fb.pixel(0, 0), fb.pixel(0, 1));
+ // Verify the gradient
+ QVERIFY(fb.pixel(0, 0) != fb.pixel(0, fb.height() - 1));
+}
+
+
+
+// The test draws a one pixel wide line and scales it down by more than a a factor 2
+// If mipmpping works, the pixels should be gray, not white or black
+
+void tst_QQuickItemLayer::layerMipmap()
+{
+ if (m_isMesaSoftwareRasterizer)
+ QSKIP("Mipmapping does not work with the Mesa Software Rasterizer.");
+ QImage fb = runTest(testFile("Mipmap.qml"));
+ QVERIFY(fb.pixel(0, 0) != 0xff000000);
+ QVERIFY(fb.pixel(0, 0) != 0xffffffff);
+}
+
+
+
+// The test implements an rgb swapping effect sourced from a blue rectangle. The
+// resulting pixel should be red
+
+void tst_QQuickItemLayer::layerEffect()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+ QImage fb = runTest(testFile("Effect.qml"));
+ QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0));
+}
+
+
+
+// The test draws a rectangle and verifies that there is padding on each side
+// as the source rect spans outside the item. The padding is verified using
+// a shader that pads transparent to blue. Everything else is red.
+void tst_QQuickItemLayer::layerSourceRect()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+
+ QImage fb = runTest(testFile("SourceRect.qml"));
+
+ // Check that the edges are converted to blue
+ QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(0, fb.height() - 1), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(fb.width() - 1, fb.height() - 1), qRgb(0, 0, 0xff));
+
+ // The center pixel should be red
+ QCOMPARE(fb.pixel(fb.width() / 2, fb.height() / 2), qRgb(0xff, 0, 0));
+}
+
+
+
+// Same as the effect test up above, but this time use the item
+// directly in a stand alone ShaderEffect
+void tst_QQuickItemLayer::layerIsTextureProvider()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+ QImage fb = runTest(testFile("TextureProvider.qml"));
+ QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0));
+}
+
+
+void tst_QQuickItemLayer::layerVisibility_data()
+{
+ QTest::addColumn<bool>("visible");
+ QTest::addColumn<bool>("effect");
+ QTest::addColumn<qreal>("opacity");
+
+ QTest::newRow("!effect, !visible, a=1") << false << false << 1.;
+ QTest::newRow("!effect, visible, a=1") << false << true << 1.;
+ QTest::newRow("effect, !visible, a=1") << true << false << 1.;
+ QTest::newRow("effect, visible, a=1") << true << true << 1.;
+
+ QTest::newRow("!effect, !visible, a=.5") << false << false << .5;
+ QTest::newRow("!effect, visible, a=.5") << false << true << .5;
+ QTest::newRow("effect, !visible, a=.5") << true << false << .5;
+ QTest::newRow("effect, visible, a=.5") << true << true << .5;
+
+ QTest::newRow("!effect, !visible, a=0") << false << false << 0.;
+ QTest::newRow("!effect, visible, a=0") << false << true << 0.;
+ QTest::newRow("effect, !visible, a=0") << true << false << 0.;
+ QTest::newRow("effect, visible, a=0") << true << true << 0.;
+}
+
+void tst_QQuickItemLayer::layerVisibility()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+
+ QFETCH(bool, visible);
+ QFETCH(bool, effect);
+ QFETCH(qreal, opacity);
+
+ QQuickView view;
+ view.setSource(testFile("Visible.qml"));
+
+ QQuickItem *child = view.rootItem()->childItems().at(0);
+ child->setProperty("layerVisible", visible);
+ child->setProperty("layerEffect", effect);
+ child->setProperty("layerOpacity", opacity);
+
+ view.show();
+
+ QTest::qWaitForWindowShown(&view);
+
+ QImage fb = view.grabFrameBuffer();
+ uint pixel = fb.pixel(0, 0);
+
+ if (!visible || opacity == 0) {
+ QCOMPARE(pixel, qRgb(0xff, 0xff, 0xff));
+ } else if (effect) {
+ QCOMPARE(qRed(pixel), 0xff);
+ QVERIFY(qGreen(pixel) < 0xff);
+ QVERIFY(qBlue(pixel) < 0xff);
+ } else { // no effect
+ QCOMPARE(qBlue(pixel), 0xff);
+ QVERIFY(qGreen(pixel) < 0xff);
+ QVERIFY(qRed(pixel) < 0xff);
+ }
+}
+
+
+
+
+void tst_QQuickItemLayer::layerZOrder_data()
+{
+ QTest::addColumn<bool>("effect");
+
+ QTest::newRow("!effect") << false;
+ QTest::newRow("effect") << true;
+}
+
+void tst_QQuickItemLayer::layerZOrder()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+
+ QFETCH(bool, effect);
+
+ QQuickView view;
+ view.setSource(testFile("ZOrder.qml"));
+
+ QQuickItem *child = view.rootItem()->childItems().at(0);
+ child->setProperty("layerEffect", effect);
+
+ view.show();
+
+ QTest::qWaitForWindowShown(&view);
+
+ QImage fb = view.grabFrameBuffer();
+
+ QCOMPARE(fb.pixel(50, 50), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(150, 150), qRgb(0, 0xff, 00));
+
+}
+
+void tst_QQuickItemLayer::changeZOrder_data()
+{
+ QTest::addColumn<bool>("layered");
+ QTest::addColumn<bool>("effect");
+
+ QTest::newRow("layered, effect") << true << true;
+ QTest::newRow("layered, !effect") << true << false;
+ QTest::newRow("!layered") << false << false;
+}
+
+void tst_QQuickItemLayer::changeZOrder()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+
+ QFETCH(bool, layered);
+ QFETCH(bool, effect);
+
+ QQuickView view;
+ view.setSource(testFile("ZOrderChange.qml"));
+
+ QQuickItem *child = view.rootItem()->childItems().at(0);
+ child->setProperty("layerEnabled", layered);
+ child->setProperty("layerEffect", effect);
+ child->setProperty("layerZ", 1);
+
+ view.show();
+
+ QTest::qWaitForWindowShown(&view);
+
+ QImage fb = view.grabFrameBuffer();
+
+ QRgb topLeft = fb.pixel(50, 50);
+ QRgb topRight = fb.pixel(150, 50);
+ QRgb bottomLeft = fb.pixel(50, 150);
+ QRgb bottomRight = fb.pixel(150, 150);
+
+ QCOMPARE(bottomLeft, qRgb(0, 0, 0xff));
+
+ if (layered) {
+ QCOMPARE(topLeft, qRgb(0, 0xff, 0xff));
+ } else {
+ QCOMPARE(qGreen(topLeft), 0xff);
+ QVERIFY(qAbs(qRed(topLeft) - 0x3f) < 4);
+ QVERIFY(qAbs(qBlue(topLeft) - 0xbf) < 4);
+ }
+
+ if (layered && effect) {
+ QCOMPARE(qRed(topRight), 0xff);
+ QCOMPARE(qGreen(topRight), 0x00);
+ QVERIFY(qAbs(qBlue(topRight) - 0x7f) < 4);
+
+ QVERIFY(qAbs(qRed(bottomRight) - 0x7f) < 4);
+ QCOMPARE(qBlue(bottomRight), 0xff);
+ QVERIFY(qAbs(qGreen(bottomRight) - 0x7f) < 4);
+ } else {
+ QCOMPARE(qRed(topRight), 0xff);
+ QCOMPARE(qBlue(topRight), 0x00);
+ QVERIFY(qAbs(qGreen(topRight) - 0x7f) < 4);
+
+ QVERIFY(qAbs(qRed(bottomRight) - 0x7f) < 4);
+ QCOMPARE(qGreen(bottomRight), 0xff);
+ QVERIFY(qAbs(qBlue(bottomRight) - 0x7f) < 4);
+ }
+}
+
+void tst_QQuickItemLayer::toggleLayerAndEffect()
+{
+ // This test passes if it doesn't crash.
+ runTest(testFile("ToggleLayerAndEffect.qml"));
+}
+
+void tst_QQuickItemLayer::disableLayer()
+{
+ // This test passes if it doesn't crash.
+ runTest(testFile("DisableLayer.qml"));
+}
+
+void tst_QQuickItemLayer::changeSamplerName()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+ QImage fb = runTest(testFile("SamplerNameChange.qml"));
+ QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff));
+}
+
+void tst_QQuickItemLayer::itemEffect()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+ QImage fb = runTest(testFile("ItemEffect.qml"));
+ QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(199, 0), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(0, 199), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(199, 199), qRgb(0, 0, 0xff));
+}
+
+void tst_QQuickItemLayer::rectangleEffect()
+{
+ QImage fb = runTest(testFile("RectangleEffect.qml"));
+ QCOMPARE(fb.pixel(0, 0), qRgb(0, 0xff, 0));
+ QCOMPARE(fb.pixel(199, 0), qRgb(0, 0xff, 0));
+ QCOMPARE(fb.pixel(0, 199), qRgb(0, 0xff, 0));
+ QCOMPARE(fb.pixel(199, 199), qRgb(0, 0xff, 0));
+
+ QCOMPARE(fb.pixel(100, 0), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(199, 100), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(100, 199), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(0, 100), qRgb(0, 0, 0xff));
+}
+
+
+QTEST_MAIN(tst_QQuickItemLayer)
+
+#include "tst_qquickitemlayer.moc"
diff --git a/tests/auto/qtquick2/qquicklistview/data/ComponentView.qml b/tests/auto/quick/qquicklistview/data/ComponentView.qml
index 3e87be8799..3e87be8799 100644
--- a/tests/auto/qtquick2/qquicklistview/data/ComponentView.qml
+++ b/tests/auto/quick/qquicklistview/data/ComponentView.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/Page.qml b/tests/auto/quick/qquicklistview/data/Page.qml
index abe4364315..abe4364315 100644
--- a/tests/auto/qtquick2/qquicklistview/data/Page.qml
+++ b/tests/auto/quick/qquicklistview/data/Page.qml
diff --git a/tests/auto/quick/qquicklistview/data/addTransitions.qml b/tests/auto/quick/qquicklistview/data/addTransitions.qml
new file mode 100644
index 0000000000..6a7c3234f6
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/addTransitions.qml
@@ -0,0 +1,134 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 500
+ height: 600
+
+ property int duration: 10
+ property int count: list.count
+
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+
+ property string nameData: name
+
+ objectName: "wrapper"
+ height: 20
+ width: 240
+ Text { text: index }
+ Text {
+ x: 30
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ Text {
+ x: 200
+ text: wrapper.y
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+
+ onXChanged: checkPos()
+ onYChanged: checkPos()
+
+ function checkPos() {
+ if (Qt.point(x, y) == targetItems_transitionFrom)
+ model_targetItems_transitionFrom.addItem(name, "")
+ if (Qt.point(x, y) == displacedItems_transitionVia)
+ model_displacedItems_transitionVia.addItem(name, "")
+ }
+ }
+ }
+
+ ListView {
+ id: list
+
+ property int targetTransitionsDone
+ property int displaceTransitionsDone
+
+ property var targetTrans_items: new Object()
+ property var targetTrans_targetIndexes: new Array()
+ property var targetTrans_targetItems: new Array()
+
+ property var displacedTrans_items: new Object()
+ property var displacedTrans_targetIndexes: new Array()
+ property var displacedTrans_targetItems: new Array()
+
+ objectName: "list"
+ focus: true
+ anchors.centerIn: parent
+ width: 240
+ height: 320
+ model: testModel
+ delegate: myDelegate
+
+ // for QQmlListProperty types
+ function copyList(propList) {
+ var temp = new Array()
+ for (var i=0; i<propList.length; i++)
+ temp.push(propList[i])
+ return temp
+ }
+
+ add: Transition {
+ id: targetTransition
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ list.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
+ list.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
+ list.targetTrans_targetItems.push(list.copyList(targetTransition.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; from: targetItems_transitionFrom.x; duration: root.duration }
+ NumberAnimation { properties: "y"; from: targetItems_transitionFrom.y; duration: root.duration }
+ }
+
+ ScriptAction { script: list.targetTransitionsDone += 1 }
+ }
+ }
+
+ addDisplaced: Transition {
+ id: displaced
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ list.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
+ list.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
+ list.displacedTrans_targetItems.push(list.copyList(displaced.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; duration: root.duration; to: displacedItems_transitionVia.x }
+ NumberAnimation { properties: "y"; duration: root.duration; to: displacedItems_transitionVia.y }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: list.displaceTransitionsDone += 1 }
+ }
+
+ }
+ }
+
+ Rectangle {
+ anchors.fill: list
+ color: "lightsteelblue"
+ opacity: 0.2
+ }
+
+ // XXX will it pass without these if I just wait for polish?
+ // check all of these tests - if not, then mark this bit with the bug number!
+ Rectangle {
+ anchors.bottom: parent.bottom
+ width: 20; height: 20
+ color: "white"
+ NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 100000 }
+ }
+}
+
diff --git a/tests/auto/qtquick2/qquicklistview/data/asyncloader.qml b/tests/auto/quick/qquicklistview/data/asyncloader.qml
index f038f0960c..f038f0960c 100644
--- a/tests/auto/qtquick2/qquicklistview/data/asyncloader.qml
+++ b/tests/auto/quick/qquicklistview/data/asyncloader.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/attachedSignals.qml b/tests/auto/quick/qquicklistview/data/attachedSignals.qml
index 2c3c0bbada..2c3c0bbada 100644
--- a/tests/auto/qtquick2/qquicklistview/data/attachedSignals.qml
+++ b/tests/auto/quick/qquicklistview/data/attachedSignals.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/creationContext.qml b/tests/auto/quick/qquicklistview/data/creationContext.qml
index 79a682788b..79a682788b 100644
--- a/tests/auto/qtquick2/qquicklistview/data/creationContext.qml
+++ b/tests/auto/quick/qquicklistview/data/creationContext.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/displaylist.qml b/tests/auto/quick/qquicklistview/data/displaylist.qml
index 4e8fd32f6a..4e8fd32f6a 100644
--- a/tests/auto/qtquick2/qquicklistview/data/displaylist.qml
+++ b/tests/auto/quick/qquicklistview/data/displaylist.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/fillModelOnComponentCompleted.qml b/tests/auto/quick/qquicklistview/data/fillModelOnComponentCompleted.qml
index 906e6adb6b..906e6adb6b 100644
--- a/tests/auto/qtquick2/qquicklistview/data/fillModelOnComponentCompleted.qml
+++ b/tests/auto/quick/qquicklistview/data/fillModelOnComponentCompleted.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/footer.qml b/tests/auto/quick/qquicklistview/data/footer.qml
index 2a5619999e..2a5619999e 100644
--- a/tests/auto/qtquick2/qquicklistview/data/footer.qml
+++ b/tests/auto/quick/qquicklistview/data/footer.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/header.qml b/tests/auto/quick/qquicklistview/data/header.qml
index bf70310630..bf70310630 100644
--- a/tests/auto/qtquick2/qquicklistview/data/header.qml
+++ b/tests/auto/quick/qquicklistview/data/header.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/headerfooter.qml b/tests/auto/quick/qquicklistview/data/headerfooter.qml
index 8e8463d645..8e8463d645 100644
--- a/tests/auto/qtquick2/qquicklistview/data/headerfooter.qml
+++ b/tests/auto/quick/qquicklistview/data/headerfooter.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/itemlist.qml b/tests/auto/quick/qquicklistview/data/itemlist.qml
index 5c7ecdd5e8..5c7ecdd5e8 100644
--- a/tests/auto/qtquick2/qquicklistview/data/itemlist.qml
+++ b/tests/auto/quick/qquicklistview/data/itemlist.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listview-enforcerange-nohighlight.qml b/tests/auto/quick/qquicklistview/data/listview-enforcerange-nohighlight.qml
index 1db1096499..1db1096499 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listview-enforcerange-nohighlight.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-enforcerange-nohighlight.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listview-enforcerange.qml b/tests/auto/quick/qquicklistview/data/listview-enforcerange.qml
index f1bf6c2b57..f1bf6c2b57 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listview-enforcerange.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-enforcerange.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listview-initCurrent.qml b/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml
index c4f1860eda..c4f1860eda 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listview-initCurrent.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listview-noCurrent.qml b/tests/auto/quick/qquicklistview/data/listview-noCurrent.qml
index 079966d8e4..079966d8e4 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listview-noCurrent.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-noCurrent.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listview-sections-package.qml b/tests/auto/quick/qquicklistview/data/listview-sections-package.qml
index 8e5a4c4aa7..8e5a4c4aa7 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listview-sections-package.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-sections-package.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listview-sections.qml b/tests/auto/quick/qquicklistview/data/listview-sections.qml
index d5b8a4400d..d5b8a4400d 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listview-sections.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-sections.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listview-sections_delegate.qml b/tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml
index 496d8d7784..496d8d7784 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listview-sections_delegate.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-sections_delegate.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listviewtest-package.qml b/tests/auto/quick/qquicklistview/data/listviewtest-package.qml
index 54d4dabc86..54d4dabc86 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listviewtest-package.qml
+++ b/tests/auto/quick/qquicklistview/data/listviewtest-package.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/listviewtest.qml b/tests/auto/quick/qquicklistview/data/listviewtest.qml
index 47b341c1fc..47b341c1fc 100644
--- a/tests/auto/qtquick2/qquicklistview/data/listviewtest.qml
+++ b/tests/auto/quick/qquicklistview/data/listviewtest.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/manual-highlight.qml b/tests/auto/quick/qquicklistview/data/manual-highlight.qml
index aac4599f01..aac4599f01 100644
--- a/tests/auto/qtquick2/qquicklistview/data/manual-highlight.qml
+++ b/tests/auto/quick/qquicklistview/data/manual-highlight.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/margins.qml b/tests/auto/quick/qquicklistview/data/margins.qml
index 19bbef500f..19bbef500f 100644
--- a/tests/auto/qtquick2/qquicklistview/data/margins.qml
+++ b/tests/auto/quick/qquicklistview/data/margins.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/margins2.qml b/tests/auto/quick/qquicklistview/data/margins2.qml
index e11c803c4b..e11c803c4b 100644
--- a/tests/auto/qtquick2/qquicklistview/data/margins2.qml
+++ b/tests/auto/quick/qquicklistview/data/margins2.qml
diff --git a/tests/auto/quick/qquicklistview/data/moveTransitions.qml b/tests/auto/quick/qquicklistview/data/moveTransitions.qml
new file mode 100644
index 0000000000..2f907bdc8a
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/moveTransitions.qml
@@ -0,0 +1,141 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 500
+ height: 600
+
+ property int duration: 10
+ property int count: list.count
+
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+
+ property string nameData: name
+
+ objectName: "wrapper"
+ height: 20
+ width: 240
+ Text { text: index }
+ Text {
+ x: 30
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ Text {
+ x: 200
+ text: wrapper.y
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+
+ onXChanged: checkPos()
+ onYChanged: checkPos()
+
+ function checkPos() {
+ if (Qt.point(x, y) == targetItems_transitionVia)
+ model_targetItems_transitionVia.addItem(name, "")
+ if (Qt.point(x, y) == displacedItems_transitionVia)
+ model_displacedItems_transitionVia.addItem(name, "")
+ }
+ }
+ }
+
+ ListView {
+ id: list
+
+ property int targetTransitionsDone
+ property int displaceTransitionsDone
+
+ property var targetTrans_items: new Object()
+ property var targetTrans_targetIndexes: new Array()
+ property var targetTrans_targetItems: new Array()
+
+ property var displacedTrans_items: new Object()
+ property var displacedTrans_targetIndexes: new Array()
+ property var displacedTrans_targetItems: new Array()
+
+ objectName: "list"
+ focus: true
+ anchors.centerIn: parent
+ width: 240
+ height: 320
+ model: testModel
+ delegate: myDelegate
+
+ // for QQmlListProperty types
+ function copyList(propList) {
+ var temp = new Array()
+ for (var i=0; i<propList.length; i++)
+ temp.push(propList[i])
+ return temp
+ }
+
+ move: Transition {
+ id: targetTransition
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ list.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
+ list.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
+ list.targetTrans_targetItems.push(list.copyList(targetTransition.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: targetItems_transitionVia.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: targetItems_transitionVia.y; duration: root.duration }
+ }
+
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: list.targetTransitionsDone += 1 }
+ }
+ }
+
+ moveDisplaced: Transition {
+ id: displaced
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ list.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
+ list.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
+ list.displacedTrans_targetItems.push(list.copyList(displaced.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation {
+ properties: "x"; duration: root.duration
+ to: displacedItems_transitionVia.x
+ }
+ NumberAnimation {
+ properties: "y"; duration: root.duration
+ to: displacedItems_transitionVia.y
+ }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: list.displaceTransitionsDone += 1 }
+ }
+
+ }
+ }
+
+ Rectangle {
+ anchors.fill: list
+ color: "lightsteelblue"
+ opacity: 0.2
+ }
+
+ Rectangle {
+ anchors.bottom: parent.bottom
+ width: 20; height: 20
+ color: "white"
+ NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 10000 }
+ }
+}
+
+
diff --git a/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml b/tests/auto/quick/qquicklistview/data/multipleTransitions.qml
index 50ffbc53c3..50ffbc53c3 100644
--- a/tests/auto/qtquick2/qquicklistview/data/multipleTransitions.qml
+++ b/tests/auto/quick/qquicklistview/data/multipleTransitions.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/populateTransitions.qml b/tests/auto/quick/qquicklistview/data/populateTransitions.qml
index 0994e0943d..0994e0943d 100644
--- a/tests/auto/qtquick2/qquicklistview/data/populateTransitions.qml
+++ b/tests/auto/quick/qquicklistview/data/populateTransitions.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/propertychangestest.qml b/tests/auto/quick/qquicklistview/data/propertychangestest.qml
index 146f3f13b0..146f3f13b0 100644
--- a/tests/auto/qtquick2/qquicklistview/data/propertychangestest.qml
+++ b/tests/auto/quick/qquicklistview/data/propertychangestest.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/qtbug-21742.qml b/tests/auto/quick/qquicklistview/data/qtbug-21742.qml
index 774f9041fb..774f9041fb 100644
--- a/tests/auto/qtquick2/qquicklistview/data/qtbug-21742.qml
+++ b/tests/auto/quick/qquicklistview/data/qtbug-21742.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/qtbug14821.qml b/tests/auto/quick/qquicklistview/data/qtbug14821.qml
index 0a5e0acbb4..0a5e0acbb4 100644
--- a/tests/auto/qtquick2/qquicklistview/data/qtbug14821.qml
+++ b/tests/auto/quick/qquicklistview/data/qtbug14821.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/qtbug16037.qml b/tests/auto/quick/qquicklistview/data/qtbug16037.qml
index 21faeb3f32..21faeb3f32 100644
--- a/tests/auto/qtquick2/qquicklistview/data/qtbug16037.qml
+++ b/tests/auto/quick/qquicklistview/data/qtbug16037.qml
diff --git a/tests/auto/quick/qquicklistview/data/removeTransitions.qml b/tests/auto/quick/qquicklistview/data/removeTransitions.qml
new file mode 100644
index 0000000000..a85b217138
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/removeTransitions.qml
@@ -0,0 +1,144 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: 500
+ height: 600
+
+ property int duration: 10
+ property int count: list.count
+
+ Component {
+ id: myDelegate
+ Rectangle {
+ id: wrapper
+
+ property string nameData: name
+
+ objectName: "wrapper"
+ height: 20
+ width: 240
+ Text { text: index }
+ Text {
+ x: 30
+ id: textName
+ objectName: "textName"
+ text: name
+ }
+ Text {
+ x: 200
+ text: wrapper.y
+ }
+ color: ListView.isCurrentItem ? "lightsteelblue" : "white"
+
+ onXChanged: checkPos()
+ onYChanged: checkPos()
+
+ function checkPos() {
+ if (Qt.point(x, y) == targetItems_transitionTo) {
+ model_targetItems_transitionTo.addItem(nameData, "") // name is invalid once model removes the item
+ }
+ if (Qt.point(x, y) == displacedItems_transitionVia) {
+ model_displacedItems_transitionVia.addItem(name, "")
+ }
+ }
+ }
+ }
+
+ ListView {
+ id: list
+
+ property int targetTransitionsDone
+ property int displaceTransitionsDone
+
+ property var targetTrans_items: new Object()
+ property var targetTrans_targetIndexes: new Array()
+ property var targetTrans_targetItems: new Array()
+
+ property var displacedTrans_items: new Object()
+ property var displacedTrans_targetIndexes: new Array()
+ property var displacedTrans_targetItems: new Array()
+
+ objectName: "list"
+ focus: true
+ anchors.centerIn: parent
+ width: 240
+ height: 320
+ model: testModel
+ delegate: myDelegate
+
+ // for QQmlListProperty types
+ function copyList(propList) {
+ var temp = new Array()
+ for (var i=0; i<propList.length; i++)
+ temp.push(propList[i])
+ return temp
+ }
+
+ remove: Transition {
+ id: targetTransition
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ list.targetTrans_items[targetTransition.ViewTransition.item.nameData] = targetTransition.ViewTransition.index
+ list.targetTrans_targetIndexes.push(targetTransition.ViewTransition.targetIndexes)
+ list.targetTrans_targetItems.push(list.copyList(targetTransition.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation { properties: "x"; to: targetItems_transitionTo.x; duration: root.duration }
+ NumberAnimation { properties: "y"; to: targetItems_transitionTo.y; duration: root.duration }
+ }
+ ScriptAction { script: list.targetTransitionsDone += 1 }
+
+ // delay deleting this item so that it stays valid for the tests
+ // (this doesn't delay the test itself)
+ PauseAnimation { duration: 10000 }
+ }
+ }
+
+ removeDisplaced: Transition {
+ id: displaced
+
+ SequentialAnimation {
+ ScriptAction {
+ script: {
+ list.displacedTrans_items[displaced.ViewTransition.item.nameData] = displaced.ViewTransition.index
+ list.displacedTrans_targetIndexes.push(displaced.ViewTransition.targetIndexes)
+ list.displacedTrans_targetItems.push(list.copyList(displaced.ViewTransition.targetItems))
+ }
+ }
+ ParallelAnimation {
+ NumberAnimation {
+ properties: "x"; duration: root.duration
+ to: displacedItems_transitionVia.x
+ }
+ NumberAnimation {
+ properties: "y"; duration: root.duration
+ to: displacedItems_transitionVia.y
+ }
+ }
+ NumberAnimation { properties: "x,y"; duration: root.duration }
+
+ ScriptAction { script: list.displaceTransitionsDone += 1 }
+ }
+
+ }
+ }
+
+ Rectangle {
+ anchors.fill: list
+ color: "lightsteelblue"
+ opacity: 0.2
+ }
+
+ Rectangle {
+ anchors.bottom: parent.bottom
+ width: 20; height: 20
+ color: "white"
+ NumberAnimation on x { loops: Animation.Infinite; from: 0; to: 300; duration: 10000 }
+ }
+}
+
+
diff --git a/tests/auto/qtquick2/qquicklistview/data/resizeview.qml b/tests/auto/quick/qquicklistview/data/resizeview.qml
index 8b13adba40..8b13adba40 100644
--- a/tests/auto/qtquick2/qquicklistview/data/resizeview.qml
+++ b/tests/auto/quick/qquicklistview/data/resizeview.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/rightToLeft.qml b/tests/auto/quick/qquicklistview/data/rightToLeft.qml
index 6d77de26f4..6d77de26f4 100644
--- a/tests/auto/qtquick2/qquicklistview/data/rightToLeft.qml
+++ b/tests/auto/quick/qquicklistview/data/rightToLeft.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/sizelessthan1.qml b/tests/auto/quick/qquicklistview/data/sizelessthan1.qml
index aa9dc20ae9..aa9dc20ae9 100644
--- a/tests/auto/qtquick2/qquicklistview/data/sizelessthan1.qml
+++ b/tests/auto/quick/qquicklistview/data/sizelessthan1.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/snapOneItem.qml b/tests/auto/quick/qquicklistview/data/snapOneItem.qml
index d67d8040ca..d67d8040ca 100644
--- a/tests/auto/qtquick2/qquicklistview/data/snapOneItem.qml
+++ b/tests/auto/quick/qquicklistview/data/snapOneItem.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/snapToItem.qml b/tests/auto/quick/qquicklistview/data/snapToItem.qml
index 6f201072f0..6f201072f0 100644
--- a/tests/auto/qtquick2/qquicklistview/data/snapToItem.qml
+++ b/tests/auto/quick/qquicklistview/data/snapToItem.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/strictlyenforcerange.qml b/tests/auto/quick/qquicklistview/data/strictlyenforcerange.qml
index 7960ac4abb..7960ac4abb 100644
--- a/tests/auto/qtquick2/qquicklistview/data/strictlyenforcerange.qml
+++ b/tests/auto/quick/qquicklistview/data/strictlyenforcerange.qml
diff --git a/tests/auto/qtquick2/qquicklistview/data/unrequestedItems.qml b/tests/auto/quick/qquicklistview/data/unrequestedItems.qml
index 682f3833d1..682f3833d1 100644
--- a/tests/auto/qtquick2/qquicklistview/data/unrequestedItems.qml
+++ b/tests/auto/quick/qquicklistview/data/unrequestedItems.qml
diff --git a/tests/auto/qtquick2/qquicklistview/incrementalmodel.cpp b/tests/auto/quick/qquicklistview/incrementalmodel.cpp
index bbdcabf253..bbdcabf253 100644
--- a/tests/auto/qtquick2/qquicklistview/incrementalmodel.cpp
+++ b/tests/auto/quick/qquicklistview/incrementalmodel.cpp
diff --git a/tests/auto/qtquick2/qquicklistview/incrementalmodel.h b/tests/auto/quick/qquicklistview/incrementalmodel.h
index bf524d16e6..bf524d16e6 100644
--- a/tests/auto/qtquick2/qquicklistview/incrementalmodel.h
+++ b/tests/auto/quick/qquicklistview/incrementalmodel.h
diff --git a/tests/auto/quick/qquicklistview/qquicklistview.pro b/tests/auto/quick/qquicklistview/qquicklistview.pro
new file mode 100644
index 0000000000..4cac8e7665
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/qquicklistview.pro
@@ -0,0 +1,16 @@
+CONFIG += testcase
+TARGET = tst_qquicklistview
+macx:CONFIG -= app_bundle
+
+HEADERS += incrementalmodel.h
+SOURCES += tst_qquicklistview.cpp \
+ incrementalmodel.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+QT += core-private gui-private qml-private quick-private widgets widgets-private v8-private opengl-private testlib
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
new file mode 100644
index 0000000000..bcac5917d6
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -0,0 +1,5716 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/QStringListModel>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlincubator.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/private/qquicklistview_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuick/private/qquickvisualitemmodel_p.h>
+#include <QtQml/private/qquicklistmodel_p.h>
+#include <QtQuick/private/qquickchangeset_p.h>
+#include "../../shared/util.h"
+#include "../shared/viewtestutil.h"
+#include "../shared/visualtestutil.h"
+#include "incrementalmodel.h"
+#include <math.h>
+
+Q_DECLARE_METATYPE(Qt::LayoutDirection)
+Q_DECLARE_METATYPE(QQuickListView::Orientation)
+
+using namespace QQuickViewTestUtil;
+using namespace QQuickVisualTestUtil;
+
+class tst_QQuickListView : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickListView();
+
+private slots:
+ // Test both QListModelInterface and QAbstractItemModel model types
+ void qListModelInterface_items();
+ void qListModelInterface_package_items();
+ void qAbstractItemModel_items();
+
+ void qListModelInterface_changed();
+ void qListModelInterface_package_changed();
+ void qAbstractItemModel_changed();
+
+ void qListModelInterface_inserted();
+ void qListModelInterface_inserted_more();
+ void qListModelInterface_inserted_more_data();
+ void qListModelInterface_package_inserted();
+ void qAbstractItemModel_inserted();
+ void qAbstractItemModel_inserted_more();
+ void qAbstractItemModel_inserted_more_data();
+
+ void qListModelInterface_removed();
+ void qListModelInterface_removed_more();
+ void qListModelInterface_removed_more_data();
+ void qListModelInterface_package_removed();
+ void qAbstractItemModel_removed();
+ void qAbstractItemModel_removed_more();
+ void qAbstractItemModel_removed_more_data();
+
+ void qListModelInterface_moved();
+ void qListModelInterface_moved_data();
+ void qListModelInterface_package_moved();
+ void qListModelInterface_package_moved_data();
+ void qAbstractItemModel_moved();
+ void qAbstractItemModel_moved_data();
+
+ void multipleChanges();
+ void multipleChanges_data();
+
+ void qListModelInterface_clear();
+ void qListModelInterface_package_clear();
+ void qAbstractItemModel_clear();
+
+ void insertBeforeVisible();
+ void insertBeforeVisible_data();
+ void swapWithFirstItem();
+ void itemList();
+ void currentIndex_delayedItemCreation();
+ void currentIndex_delayedItemCreation_data();
+ void currentIndex();
+ void noCurrentIndex();
+ void enforceRange();
+ void enforceRange_withoutHighlight();
+ void spacing();
+ void qListModelInterface_sections();
+ void qListModelInterface_package_sections();
+ void qAbstractItemModel_sections();
+ void sectionsPositioning();
+ void sectionsDelegate();
+ void cacheBuffer();
+ void positionViewAtIndex();
+ void resetModel();
+ void propertyChanges();
+ void componentChanges();
+ void modelChanges();
+ void manualHighlight();
+ void header();
+ void header_data();
+ void header_delayItemCreation();
+ void footer();
+ void footer_data();
+ void headerFooter();
+ void resizeView();
+ void resizeViewAndRepaint();
+ void sizeLessThan1();
+ void QTBUG_14821();
+ void resizeDelegate();
+ void resizeFirstDelegate();
+ void QTBUG_16037();
+ void indexAt_itemAt_data();
+ void indexAt_itemAt();
+ void incrementalModel();
+ void onAdd();
+ void onAdd_data();
+ void onRemove();
+ void onRemove_data();
+ void rightToLeft();
+ void test_mirroring();
+ void margins();
+ void marginsResize();
+ void marginsResize_data();
+ void creationContext();
+ void snapToItem_data();
+ void snapToItem();
+ void snapOneItem_data();
+ void snapOneItem();
+
+ void QTBUG_9791();
+ void QTBUG_11105();
+ void QTBUG_21742();
+
+ void asynchronous();
+ void unrequestedVisibility();
+
+ void populateTransitions();
+ void populateTransitions_data();
+ void addTransitions();
+ void addTransitions_data();
+ void moveTransitions();
+ void moveTransitions_data();
+ void removeTransitions();
+ void removeTransitions_data();
+ void multipleTransitions();
+ void multipleTransitions_data();
+
+private:
+ template <class T> void items(const QUrl &source, bool forceLayout);
+ template <class T> void changed(const QUrl &source, bool forceLayout);
+ template <class T> void inserted(const QUrl &source);
+ template <class T> void inserted_more();
+ template <class T> void removed(const QUrl &source, bool animated);
+ template <class T> void removed_more(const QUrl &source);
+ template <class T> void moved(const QUrl &source);
+ template <class T> void clear(const QUrl &source);
+ template <class T> void sections(const QUrl &source);
+
+ QList<int> toIntList(const QVariantList &list);
+ void matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes);
+ void matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes);
+ void matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems);
+
+ void inserted_more_data();
+ void removed_more_data();
+ void moved_data();
+};
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool error READ error WRITE setError NOTIFY changedError)
+ Q_PROPERTY(bool animate READ animate NOTIFY changedAnim)
+ Q_PROPERTY(bool invalidHighlight READ invalidHighlight NOTIFY changedHl)
+ Q_PROPERTY(int cacheBuffer READ cacheBuffer NOTIFY changedCacheBuffer)
+
+public:
+ TestObject(QObject *parent = 0)
+ : QObject(parent), mError(true), mAnimate(false), mInvalidHighlight(false)
+ , mCacheBuffer(0) {}
+
+ bool error() const { return mError; }
+ void setError(bool err) { mError = err; emit changedError(); }
+
+ bool animate() const { return mAnimate; }
+ void setAnimate(bool anim) { mAnimate = anim; emit changedAnim(); }
+
+ bool invalidHighlight() const { return mInvalidHighlight; }
+ void setInvalidHighlight(bool invalid) { mInvalidHighlight = invalid; emit changedHl(); }
+
+ int cacheBuffer() const { return mCacheBuffer; }
+ void setCacheBuffer(int buffer) { mCacheBuffer = buffer; emit changedCacheBuffer(); }
+
+signals:
+ void changedError();
+ void changedAnim();
+ void changedHl();
+ void changedCacheBuffer();
+
+public:
+ bool mError;
+ bool mAnimate;
+ bool mInvalidHighlight;
+ int mCacheBuffer;
+};
+
+tst_QQuickListView::tst_QQuickListView()
+{
+}
+
+template <class T>
+void tst_QQuickListView::items(const QUrl &source, bool forceLayout)
+{
+ QQuickView *canvas = createView();
+
+ T model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(source);
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QTRY_VERIFY(testObject->error() == false);
+
+ QTRY_VERIFY(listview->highlightItem() != 0);
+ QTRY_COMPARE(listview->count(), model.count());
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ // current item should be first item
+ QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
+
+ for (int i = 0; i < model.count(); ++i) {
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ // switch to other delegate
+ testObject->setAnimate(true);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QTRY_VERIFY(testObject->error() == false);
+ QTRY_VERIFY(listview->currentItem());
+
+ // set invalid highlight
+ testObject->setInvalidHighlight(true);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QTRY_VERIFY(testObject->error() == false);
+ QTRY_VERIFY(listview->currentItem());
+ QTRY_VERIFY(listview->highlightItem() == 0);
+
+ // back to normal highlight
+ testObject->setInvalidHighlight(false);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QTRY_VERIFY(testObject->error() == false);
+ QTRY_VERIFY(listview->currentItem());
+ QTRY_VERIFY(listview->highlightItem() != 0);
+
+ // set an empty model and confirm that items are destroyed
+ T model2;
+ ctxt->setContextProperty("testModel", &model2);
+
+ // Force a layout, necessary if ListView is completed before VisualDataModel.
+ if (forceLayout)
+ QCOMPARE(listview->property("count").toInt(), 0);
+
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ QTRY_VERIFY(itemCount == 0);
+
+ QTRY_COMPARE(listview->highlightResizeSpeed(), 1000.0);
+ QTRY_COMPARE(listview->highlightMoveSpeed(), 1000.0);
+
+ delete canvas;
+ delete testObject;
+}
+
+
+template <class T>
+void tst_QQuickListView::changed(const QUrl &source, bool forceLayout)
+{
+ QQuickView *canvas = createView();
+
+ T model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(source);
+ qApp->processEvents();
+
+ QQuickFlickable *listview = findItem<QQuickFlickable>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // Force a layout, necessary if ListView is completed before VisualDataModel.
+ if (forceLayout)
+ QCOMPARE(listview->property("count").toInt(), model.count());
+
+ model.modifyItem(1, "Will", "9876");
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
+
+ delete canvas;
+ delete testObject;
+}
+
+template <class T>
+void tst_QQuickListView::inserted(const QUrl &source)
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ T model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(source);
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ model.insertItem(1, "Will", "9876");
+
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_COMPARE(item->y(), i*20.0);
+ }
+
+ model.insertItem(0, "Foo", "1111"); // zero index, and current item
+
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+
+ name = findItem<QQuickText>(contentItem, "textName", 0);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
+ number = findItem<QQuickText>(contentItem, "textNumber", 0);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
+
+ QTRY_COMPARE(listview->currentIndex(), 1);
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_COMPARE(item->y(), i*20.0);
+ }
+
+ for (int i = model.count(); i < 30; ++i)
+ model.insertItem(i, "Hello", QString::number(i));
+
+ listview->setContentY(80);
+
+ // Insert item outside visible area
+ model.insertItem(1, "Hello", "1324");
+
+ QTRY_VERIFY(listview->contentY() == 80);
+
+ // Confirm items positioned correctly
+ for (int i = 5; i < 5+15; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.0 - 20.0);
+ }
+
+// QTRY_COMPARE(listview->contentItemHeight(), model.count() * 20.0);
+
+ // QTBUG-19675
+ model.clear();
+ model.insertItem(0, "Hello", "1234");
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->y(), 0.);
+ QTRY_VERIFY(listview->contentY() == 0);
+
+ delete canvas;
+ delete testObject;
+}
+
+template <class T>
+void tst_QQuickListView::inserted_more()
+{
+ QFETCH(qreal, contentY);
+ QFETCH(int, insertIndex);
+ QFETCH(int, insertCount);
+ QFETCH(qreal, itemsOffsetAfterMove);
+
+ T model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ listview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QList<QPair<QString, QString> > newData;
+ for (int i=0; i<insertCount; i++)
+ newData << qMakePair(QString("value %1").arg(i), QString::number(i));
+ model.insertItems(insertIndex, newData);
+ QTRY_COMPARE(listview->property("count").toInt(), model.count());
+
+ // check visibleItems.first() is in correct position
+ QQuickItem *item0 = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item0);
+ QCOMPARE(item0->y(), itemsOffsetAfterMove);
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ QQuickText *name;
+ QQuickText *number;
+ for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QVERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::inserted_more_data()
+{
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<int>("insertIndex");
+ QTest::addColumn<int>("insertCount");
+ QTest::addColumn<qreal>("itemsOffsetAfterMove");
+
+ QTest::newRow("add 1, before visible items")
+ << 80.0 // show 4-19
+ << 3 << 1
+ << -20.0; // insert above first visible i.e. 0 is at -20, first visible should not move
+
+ QTest::newRow("add multiple, before visible")
+ << 80.0 // show 4-19
+ << 3 << 3
+ << -20.0 * 3; // again first visible should not move
+
+ QTest::newRow("add 1, at start of visible, content at start")
+ << 0.0
+ << 0 << 1
+ << 0.0;
+
+ QTest::newRow("add multiple, start of visible, content at start")
+ << 0.0
+ << 0 << 3
+ << 0.0;
+
+ QTest::newRow("add 1, at start of visible, content not at start")
+ << 80.0 // show 4-19
+ << 4 << 1
+ << 0.0;
+
+ QTest::newRow("add multiple, at start of visible, content not at start")
+ << 80.0 // show 4-19
+ << 4 << 3
+ << 0.0;
+
+
+ QTest::newRow("add 1, at end of visible, content at start")
+ << 0.0
+ << 15 << 1
+ << 0.0;
+
+ QTest::newRow("add 1, at end of visible, content at start")
+ << 0.0
+ << 15 << 3
+ << 0.0;
+
+ QTest::newRow("add 1, at end of visible, content not at start")
+ << 80.0 // show 4-19
+ << 19 << 1
+ << 0.0;
+
+ QTest::newRow("add multiple, at end of visible, content not at start")
+ << 80.0 // show 4-19
+ << 19 << 3
+ << 0.0;
+
+
+ QTest::newRow("add 1, after visible, content at start")
+ << 0.0
+ << 16 << 1
+ << 0.0;
+
+ QTest::newRow("add 1, after visible, content at start")
+ << 0.0
+ << 16 << 3
+ << 0.0;
+
+ QTest::newRow("add 1, after visible, content not at start")
+ << 80.0 // show 4-19
+ << 20 << 1
+ << 0.0;
+
+ QTest::newRow("add multiple, after visible, content not at start")
+ << 80.0 // show 4-19
+ << 20 << 3
+ << 0.0;
+}
+
+void tst_QQuickListView::insertBeforeVisible()
+{
+ QFETCH(int, insertIndex);
+ QFETCH(int, insertCount);
+ QFETCH(int, cacheBuffer);
+
+ QQuickText *name;
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ listview->setCacheBuffer(cacheBuffer);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // trigger a refill (not just setting contentY) so that the visibleItems grid is updated
+ int firstVisibleIndex = 20; // move to an index where the top item is not visible
+ listview->setContentY(firstVisibleIndex * 20.0);
+ listview->setCurrentIndex(firstVisibleIndex);
+
+ qApp->processEvents();
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QTRY_COMPARE(listview->currentIndex(), firstVisibleIndex);
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", firstVisibleIndex);
+ QVERIFY(item);
+ QCOMPARE(item->y(), listview->contentY());
+
+ QList<QPair<QString, QString> > newData;
+ for (int i=0; i<insertCount; i++)
+ newData << qMakePair(QString("value %1").arg(i), QString::number(i));
+ model.insertItems(insertIndex, newData);
+ QTRY_COMPARE(listview->property("count").toInt(), model.count());
+
+ // now, moving to the top of the view should position the inserted items correctly
+ int itemsOffsetAfterMove = -(insertCount * 20);
+ listview->setCurrentIndex(0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QTRY_COMPARE(listview->currentIndex(), 0);
+ QTRY_COMPARE(listview->contentY(), 0.0 + itemsOffsetAfterMove);
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::insertBeforeVisible_data()
+{
+ QTest::addColumn<int>("insertIndex");
+ QTest::addColumn<int>("insertCount");
+ QTest::addColumn<int>("cacheBuffer");
+
+ QTest::newRow("insert 1 at 0, 0 buffer") << 0 << 1 << 0;
+ QTest::newRow("insert 1 at 0, 100 buffer") << 0 << 1 << 100;
+ QTest::newRow("insert 1 at 0, 500 buffer") << 0 << 1 << 500;
+
+ QTest::newRow("insert 1 at 1, 0 buffer") << 1 << 1 << 0;
+ QTest::newRow("insert 1 at 1, 100 buffer") << 1 << 1 << 100;
+ QTest::newRow("insert 1 at 1, 500 buffer") << 1 << 1 << 500;
+
+ QTest::newRow("insert multiple at 0, 0 buffer") << 0 << 3 << 0;
+ QTest::newRow("insert multiple at 0, 100 buffer") << 0 << 3 << 100;
+ QTest::newRow("insert multiple at 0, 500 buffer") << 0 << 3 << 500;
+
+ QTest::newRow("insert multiple at 1, 0 buffer") << 1 << 3 << 0;
+ QTest::newRow("insert multiple at 1, 100 buffer") << 1 << 3 << 100;
+ QTest::newRow("insert multiple at 1, 500 buffer") << 1 << 3 << 500;
+}
+
+template <class T>
+void tst_QQuickListView::removed(const QUrl &source, bool /* animated */)
+{
+ QQuickView *canvas = createView();
+
+ T model;
+ for (int i = 0; i < 50; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(source);
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ model.removeItem(1);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 1);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(1));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 1);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(1));
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ // Remove first item (which is the current item);
+ model.removeItem(0);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ name = findItem<QQuickText>(contentItem, "textName", 0);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
+ number = findItem<QQuickText>(contentItem, "textNumber", 0);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(),i*20.0);
+ }
+
+ // Remove items not visible
+ model.removeItem(18);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(),i*20.0);
+ }
+
+ // Remove items before visible
+ listview->setContentY(80);
+ listview->setCurrentIndex(10);
+
+ model.removeItem(1); // post: top item will be at 20
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ // Confirm items positioned correctly
+ for (int i = 2; i < 18; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(),20+i*20.0);
+ }
+
+ // Remove current index
+ QTRY_VERIFY(listview->currentIndex() == 9);
+ QQuickItem *oldCurrent = listview->currentItem();
+ model.removeItem(9);
+
+ QTRY_COMPARE(listview->currentIndex(), 9);
+ QTRY_VERIFY(listview->currentItem() != oldCurrent);
+
+ listview->setContentY(20); // That's the top now
+ // let transitions settle.
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QTest::qWait(300);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(),20+i*20.0);
+ }
+
+ // remove current item beyond visible items.
+ listview->setCurrentIndex(20);
+ listview->setContentY(40);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ model.removeItem(20);
+ QTRY_COMPARE(listview->currentIndex(), 20);
+ QTRY_VERIFY(listview->currentItem() != 0);
+
+ // remove item before current, but visible
+ listview->setCurrentIndex(8);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ oldCurrent = listview->currentItem();
+ model.removeItem(6);
+
+ QTRY_COMPARE(listview->currentIndex(), 7);
+ QTRY_VERIFY(listview->currentItem() == oldCurrent);
+
+ listview->setContentY(80);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QTest::qWait(300);
+
+ // remove all visible items
+ model.removeItems(1, 18);
+ QTRY_COMPARE(listview->count() , model.count());
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i+1);
+ if (!item) qWarning() << "Item" << i+1 << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(),80+i*20.0);
+ }
+
+ model.removeItems(1, 17);
+ QTRY_COMPARE(listview->count() , model.count());
+
+ model.removeItems(2, 1);
+ QTRY_COMPARE(listview->count() , model.count());
+
+ model.addItem("New", "1");
+ QTRY_COMPARE(listview->count() , model.count());
+
+ QTRY_VERIFY(name = findItem<QQuickText>(contentItem, "textName", model.count()-1));
+ QCOMPARE(name->text(), QString("New"));
+
+ // Add some more items so that we don't run out
+ model.clear();
+ for (int i = 0; i < 50; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ // QTBUG-QTBUG-20575
+ listview->setCurrentIndex(0);
+ listview->setContentY(30);
+ model.removeItem(0);
+ QTRY_VERIFY(name = findItem<QQuickText>(contentItem, "textName", 0));
+
+ // QTBUG-19198 move to end and remove all visible items one at a time.
+ listview->positionViewAtEnd();
+ for (int i = 0; i < 18; ++i)
+ model.removeItems(model.count() - 1, 1);
+ QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() > 16);
+
+ delete canvas;
+ delete testObject;
+}
+
+template <class T>
+void tst_QQuickListView::removed_more(const QUrl &source)
+{
+ QFETCH(qreal, contentY);
+ QFETCH(int, removeIndex);
+ QFETCH(int, removeCount);
+ QFETCH(qreal, itemsOffsetAfterMove);
+
+ QQuickText *name;
+ QQuickText *number;
+ QQuickView *canvas = createView();
+
+ T model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(source);
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ listview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // wait for refill (after refill, items above the firstVisibleIndex-1 should not be rendered)
+ int firstVisibleIndex = contentY / 20;
+ if (firstVisibleIndex - 2 >= 0)
+ QTRY_VERIFY(!findItem<QQuickText>(contentItem, "textName", firstVisibleIndex - 2));
+
+ model.removeItems(removeIndex, removeCount);
+ QTRY_COMPARE(listview->property("count").toInt(), model.count());
+
+ // check visibleItems.first() is in correct position
+ QQuickItem *item0 = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item0);
+ QCOMPARE(item0->y(), itemsOffsetAfterMove);
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QVERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::removed_more_data()
+{
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<int>("removeIndex");
+ QTest::addColumn<int>("removeCount");
+ QTest::addColumn<qreal>("itemsOffsetAfterMove");
+
+ QTest::newRow("remove 1, before visible items")
+ << 80.0 // show 4-19
+ << 3 << 1
+ << 20.0; // visible items slide down by 1 item so that first visible does not move
+
+ QTest::newRow("remove multiple, all before visible items")
+ << 80.0
+ << 1 << 3
+ << 20.0 * 3;
+
+ QTest::newRow("remove multiple, all before visible items, remove item 0")
+ << 80.0
+ << 0 << 4
+ << 20.0 * 4;
+
+ // remove 1,2,3 before the visible pos, 0 moves down to just before the visible pos,
+ // items 4,5 are removed from view, item 6 slides up to original pos of item 4 (80px)
+ QTest::newRow("remove multiple, mix of items from before and within visible items")
+ << 80.0
+ << 1 << 5
+ << 20.0 * 3; // adjust for the 3 items removed before the visible
+
+ QTest::newRow("remove multiple, mix of items from before and within visible items, remove item 0")
+ << 80.0
+ << 0 << 6
+ << 20.0 * 4; // adjust for the 3 items removed before the visible
+
+
+ QTest::newRow("remove 1, from start of visible, content at start")
+ << 0.0
+ << 0 << 1
+ << 0.0;
+
+ QTest::newRow("remove multiple, from start of visible, content at start")
+ << 0.0
+ << 0 << 3
+ << 0.0;
+
+ QTest::newRow("remove 1, from start of visible, content not at start")
+ << 80.0 // show 4-19
+ << 4 << 1
+ << 0.0;
+
+ QTest::newRow("remove multiple, from start of visible, content not at start")
+ << 80.0 // show 4-19
+ << 4 << 3
+ << 0.0;
+
+
+ QTest::newRow("remove 1, from middle of visible, content at start")
+ << 0.0
+ << 10 << 1
+ << 0.0;
+
+ QTest::newRow("remove multiple, from middle of visible, content at start")
+ << 0.0
+ << 10 << 5
+ << 0.0;
+
+ QTest::newRow("remove 1, from middle of visible, content not at start")
+ << 80.0 // show 4-19
+ << 10 << 1
+ << 0.0;
+
+ QTest::newRow("remove multiple, from middle of visible, content not at start")
+ << 80.0 // show 4-19
+ << 10 << 5
+ << 0.0;
+
+
+ QTest::newRow("remove 1, after visible, content at start")
+ << 0.0
+ << 16 << 1
+ << 0.0;
+
+ QTest::newRow("remove multiple, after visible, content at start")
+ << 0.0
+ << 16 << 5
+ << 0.0;
+
+ QTest::newRow("remove 1, after visible, content not at middle")
+ << 80.0 // show 4-19
+ << 16+4 << 1
+ << 0.0;
+
+ QTest::newRow("remove multiple, after visible, content not at start")
+ << 80.0 // show 4-19
+ << 16+4 << 5
+ << 0.0;
+
+ QTest::newRow("remove multiple, mix of items from within and after visible items")
+ << 80.0
+ << 18 << 5
+ << 0.0;
+}
+
+template <class T>
+void tst_QQuickListView::clear(const QUrl &source)
+{
+ QQuickView *canvas = createView();
+
+ T model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(source);
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ model.clear();
+
+ QTRY_VERIFY(listview->count() == 0);
+ QTRY_VERIFY(listview->currentItem() == 0);
+ QTRY_VERIFY(listview->contentY() == 0);
+ QVERIFY(listview->currentIndex() == -1);
+
+ // confirm sanity when adding an item to cleared list
+ model.addItem("New", "1");
+ QTRY_VERIFY(listview->count() == 1);
+ QVERIFY(listview->currentItem() != 0);
+ QVERIFY(listview->currentIndex() == 0);
+
+ delete canvas;
+ delete testObject;
+}
+
+template <class T>
+void tst_QQuickListView::moved(const QUrl &source)
+{
+ QFETCH(qreal, contentY);
+ QFETCH(int, from);
+ QFETCH(int, to);
+ QFETCH(int, count);
+ QFETCH(qreal, itemsOffsetAfterMove);
+
+ QQuickText *name;
+ QQuickText *number;
+ QQuickView *canvas = createView();
+
+ T model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(source);
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickItem *currentItem = listview->currentItem();
+ QTRY_VERIFY(currentItem != 0);
+
+ if (contentY != 0) {
+ listview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ }
+
+ model.moveItems(from, to, count);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // Confirm items positioned correctly and indexes correct
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ if (i >= firstVisibleIndex + 16) // index has moved out of view
+ continue;
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QVERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+
+ // current index should have been updated
+ if (item == currentItem)
+ QTRY_COMPARE(listview->currentIndex(), i);
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::moved_data()
+{
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<int>("from");
+ QTest::addColumn<int>("to");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<qreal>("itemsOffsetAfterMove");
+
+ // model starts with 30 items, each 20px high, in area 320px high
+ // 16 items should be visible at a time
+ // itemsOffsetAfterMove should be > 0 whenever items above the visible pos have moved
+
+ QTest::newRow("move 1 forwards, within visible items")
+ << 0.0
+ << 1 << 4 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 forwards, from non-visible -> visible")
+ << 80.0 // show 4-19
+ << 1 << 18 << 1
+ << 20.0; // removed 1 item above the first visible, so item 0 should drop down by 1 to minimize movement
+
+ QTest::newRow("move 1 forwards, from non-visible -> visible (move first item)")
+ << 80.0 // show 4-19
+ << 0 << 4 << 1
+ << 20.0; // first item has moved to below item4, everything drops down by size of 1 item
+
+ QTest::newRow("move 1 forwards, from visible -> non-visible")
+ << 0.0
+ << 1 << 16 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 forwards, from visible -> non-visible (move first item)")
+ << 0.0
+ << 0 << 16 << 1
+ << 0.0;
+
+
+ QTest::newRow("move 1 backwards, within visible items")
+ << 0.0
+ << 4 << 1 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 backwards, within visible items (to first index)")
+ << 0.0
+ << 4 << 0 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 backwards, from non-visible -> visible")
+ << 0.0
+ << 20 << 4 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 backwards, from non-visible -> visible (move last item)")
+ << 0.0
+ << 29 << 15 << 1
+ << 0.0;
+
+ QTest::newRow("move 1 backwards, from visible -> non-visible")
+ << 80.0 // show 4-19
+ << 16 << 1 << 1
+ << -20.0; // to minimize movement, item 0 moves to -20, and other items do not move
+
+ QTest::newRow("move 1 backwards, from visible -> non-visible (move first item)")
+ << 80.0 // show 4-19
+ << 16 << 0 << 1
+ << -20.0; // to minimize movement, item 16 (now at 0) moves to -20, and other items do not move
+
+
+ QTest::newRow("move multiple forwards, within visible items")
+ << 0.0
+ << 0 << 5 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, before visible items")
+ << 140.0 // show 7-22
+ << 4 << 5 << 3 // 4,5,6 move to below 7
+ << 20.0 * 3; // 4,5,6 moved down
+
+ QTest::newRow("move multiple forwards, from non-visible -> visible")
+ << 80.0 // show 4-19
+ << 1 << 5 << 3
+ << 20.0 * 3; // moving 3 from above the content y should adjust y positions accordingly
+
+ QTest::newRow("move multiple forwards, from non-visible -> visible (move first item)")
+ << 80.0 // show 4-19
+ << 0 << 5 << 3
+ << 20.0 * 3; // moving 3 from above the content y should adjust y positions accordingly
+
+ QTest::newRow("move multiple forwards, mix of non-visible/visible")
+ << 40.0
+ << 1 << 16 << 2
+ << 20.0; // item 1,2 are removed, item 3 is now first visible
+
+ QTest::newRow("move multiple forwards, to bottom of view")
+ << 0.0
+ << 5 << 13 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, to bottom of view, first->last")
+ << 0.0
+ << 0 << 13 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, to bottom of view, content y not 0")
+ << 80.0
+ << 5+4 << 13+4 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, from visible -> non-visible")
+ << 0.0
+ << 1 << 16 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple forwards, from visible -> non-visible (move first item)")
+ << 0.0
+ << 0 << 16 << 3
+ << 0.0;
+
+
+ QTest::newRow("move multiple backwards, within visible items")
+ << 0.0
+ << 4 << 1 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple backwards, within visible items (move first item)")
+ << 0.0
+ << 10 << 0 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple backwards, from non-visible -> visible")
+ << 0.0
+ << 20 << 4 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple backwards, from non-visible -> visible (move last item)")
+ << 0.0
+ << 27 << 10 << 3
+ << 0.0;
+
+ QTest::newRow("move multiple backwards, from visible -> non-visible")
+ << 80.0 // show 4-19
+ << 16 << 1 << 3
+ << -20.0 * 3; // to minimize movement, 0 moves by -60, and other items do not move
+
+ QTest::newRow("move multiple backwards, from visible -> non-visible (move first item)")
+ << 80.0 // show 4-19
+ << 16 << 0 << 3
+ << -20.0 * 3; // to minimize movement, 16,17,18 move to above item 0, and other items do not move
+}
+
+void tst_QQuickListView::multipleChanges()
+{
+ QFETCH(int, startCount);
+ QFETCH(QList<ListChange>, changes);
+ QFETCH(int, newCount);
+ QFETCH(int, newCurrentIndex);
+
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < startCount; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ for (int i=0; i<changes.count(); i++) {
+ switch (changes[i].type) {
+ case ListChange::Inserted:
+ {
+ QList<QPair<QString, QString> > items;
+ for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
+ items << qMakePair(QString("new item %1").arg(j), QString::number(j));
+ model.insertItems(changes[i].index, items);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ break;
+ }
+ case ListChange::Removed:
+ model.removeItems(changes[i].index, changes[i].count);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ break;
+ case ListChange::Moved:
+ model.moveItems(changes[i].index, changes[i].to, changes[i].count);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ break;
+ case ListChange::SetCurrent:
+ listview->setCurrentIndex(changes[i].index);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ break;
+ case ListChange::SetContentY:
+ listview->setContentY(changes[i].pos);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ break;
+ }
+ }
+
+ QTRY_COMPARE(listview->count(), newCount);
+ QCOMPARE(listview->count(), model.count());
+ QTRY_COMPARE(listview->currentIndex(), newCurrentIndex);
+
+ QQuickText *name;
+ QQuickText *number;
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i=0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ number = findItem<QQuickText>(contentItem, "textNumber", i);
+ QVERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(i));
+ }
+
+ delete testObject;
+ delete canvas;
+}
+
+void tst_QQuickListView::multipleChanges_data()
+{
+ QTest::addColumn<int>("startCount");
+ QTest::addColumn<QList<ListChange> >("changes");
+ QTest::addColumn<int>("newCount");
+ QTest::addColumn<int>("newCurrentIndex");
+
+ QList<ListChange> changes;
+
+ for (int i=1; i<30; i++)
+ changes << ListChange::remove(0);
+ QTest::newRow("remove all but 1, first->last") << 30 << changes << 1 << 0;
+
+ changes << ListChange::remove(0);
+ QTest::newRow("remove all") << 30 << changes << 0 << -1;
+
+ changes.clear();
+ changes << ListChange::setCurrent(29);
+ for (int i=29; i>0; i--)
+ changes << ListChange::remove(i);
+ QTest::newRow("remove last (current) -> first") << 30 << changes << 1 << 0;
+
+ QTest::newRow("remove then insert at 0") << 10 << (QList<ListChange>()
+ << ListChange::remove(0, 1)
+ << ListChange::insert(0, 1)
+ ) << 10 << 1;
+
+ QTest::newRow("remove then insert at non-zero index") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(2)
+ << ListChange::remove(2, 1)
+ << ListChange::insert(2, 1)
+ ) << 10 << 3;
+
+ QTest::newRow("remove current then insert below it") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(1)
+ << ListChange::remove(1, 3)
+ << ListChange::insert(2, 2)
+ ) << 9 << 1;
+
+ QTest::newRow("remove current index then move it down") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(2)
+ << ListChange::remove(1, 3)
+ << ListChange::move(1, 5, 1)
+ ) << 7 << 5;
+
+ QTest::newRow("remove current index then move it up") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(5)
+ << ListChange::remove(4, 3)
+ << ListChange::move(4, 1, 1)
+ ) << 7 << 1;
+
+
+ QTest::newRow("insert multiple times") << 0 << (QList<ListChange>()
+ << ListChange::insert(0, 2)
+ << ListChange::insert(0, 4)
+ << ListChange::insert(0, 6)
+ ) << 12 << 10;
+
+ QTest::newRow("insert multiple times with current index changes") << 0 << (QList<ListChange>()
+ << ListChange::insert(0, 2)
+ << ListChange::insert(0, 4)
+ << ListChange::insert(0, 6)
+ << ListChange::setCurrent(3)
+ << ListChange::insert(3, 2)
+ ) << 14 << 5;
+
+ QTest::newRow("insert and remove all") << 0 << (QList<ListChange>()
+ << ListChange::insert(0, 30)
+ << ListChange::remove(0, 30)
+ ) << 0 << -1;
+
+ QTest::newRow("insert and remove current") << 30 << (QList<ListChange>()
+ << ListChange::insert(1)
+ << ListChange::setCurrent(1)
+ << ListChange::remove(1)
+ ) << 30 << 1;
+
+ QTest::newRow("insert before 0, then remove cross section of new and old items") << 10 << (QList<ListChange>()
+ << ListChange::insert(0, 10)
+ << ListChange::remove(5, 10)
+ ) << 10 << 5;
+
+ QTest::newRow("insert multiple, then move new items to end") << 10 << (QList<ListChange>()
+ << ListChange::insert(0, 3)
+ << ListChange::move(0, 10, 3)
+ ) << 13 << 0;
+
+ QTest::newRow("insert multiple, then move new and some old items to end") << 10 << (QList<ListChange>()
+ << ListChange::insert(0, 3)
+ << ListChange::move(0, 8, 5)
+ ) << 13 << 11;
+
+ QTest::newRow("insert multiple at end, then move new and some old items to start") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(9)
+ << ListChange::insert(10, 3)
+ << ListChange::move(8, 0, 5)
+ ) << 13 << 1;
+
+
+ QTest::newRow("move back and forth to same index") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(1)
+ << ListChange::move(1, 2, 2)
+ << ListChange::move(2, 1, 2)
+ ) << 10 << 1;
+
+ QTest::newRow("move forwards then back") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(2)
+ << ListChange::move(1, 2, 3)
+ << ListChange::move(3, 0, 5)
+ ) << 10 << 0;
+
+ QTest::newRow("move current, then remove it") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(5)
+ << ListChange::move(5, 0, 1)
+ << ListChange::remove(0)
+ ) << 9 << 0;
+
+ QTest::newRow("move current, then insert before it") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(5)
+ << ListChange::move(5, 0, 1)
+ << ListChange::insert(0)
+ ) << 11 << 1;
+
+ QTest::newRow("move multiple, then remove them") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(1)
+ << ListChange::move(5, 1, 3)
+ << ListChange::remove(1, 3)
+ ) << 7 << 1;
+
+ QTest::newRow("move multiple, then insert before them") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(5)
+ << ListChange::move(5, 1, 3)
+ << ListChange::insert(1, 5)
+ ) << 15 << 6;
+
+ QTest::newRow("move multiple, then insert after them") << 10 << (QList<ListChange>()
+ << ListChange::setCurrent(3)
+ << ListChange::move(0, 1, 2)
+ << ListChange::insert(3, 5)
+ ) << 15 << 8;
+
+
+ QTest::newRow("clear current") << 0 << (QList<ListChange>()
+ << ListChange::insert(0, 5)
+ << ListChange::setCurrent(-1)
+ << ListChange::remove(0, 5)
+ << ListChange::insert(0, 5)
+ ) << 5 << -1;
+}
+
+void tst_QQuickListView::swapWithFirstItem()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // ensure content position is stable
+ listview->setContentY(0);
+ model.moveItem(1, 0);
+ QTRY_VERIFY(listview->contentY() == 0);
+
+ delete testObject;
+ delete canvas;
+}
+
+void tst_QQuickListView::enforceRange()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("listview-enforcerange.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QTRY_COMPARE(listview->preferredHighlightBegin(), 100.0);
+ QTRY_COMPARE(listview->preferredHighlightEnd(), 100.0);
+ QTRY_COMPARE(listview->highlightRangeMode(), QQuickListView::StrictlyEnforceRange);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // view should be positioned at the top of the range.
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(listview->contentY(), -100.0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", 0);
+ QTRY_VERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(0));
+ QQuickText *number = findItem<QQuickText>(contentItem, "textNumber", 0);
+ QTRY_VERIFY(number != 0);
+ QTRY_COMPARE(number->text(), model.number(0));
+
+ // Check currentIndex is updated when contentItem moves
+ listview->setContentY(20);
+
+ QTRY_COMPARE(listview->currentIndex(), 6);
+
+ // change model
+ QmlListModel model2;
+ for (int i = 0; i < 5; i++)
+ model2.addItem("Item" + QString::number(i), "");
+
+ ctxt->setContextProperty("testModel", &model2);
+ QCOMPARE(listview->count(), 5);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::enforceRange_withoutHighlight()
+{
+ // QTBUG-20287
+ // If no highlight is set but StrictlyEnforceRange is used, the content should still move
+ // to the correct position (i.e. to the next/previous item, not next/previous section)
+ // when moving up/down via incrementCurrentIndex() and decrementCurrentIndex()
+
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ model.addItem("Item 0", "a");
+ model.addItem("Item 1", "b");
+ model.addItem("Item 2", "b");
+ model.addItem("Item 3", "c");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("listview-enforcerange-nohighlight.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ qreal expectedPos = -100.0;
+
+ expectedPos += 10.0; // scroll past 1st section's delegate (10px height)
+ QTRY_COMPARE(listview->contentY(), expectedPos);
+
+ expectedPos += 20 + 10; // scroll past 1st section and section delegate of 2nd section
+ QTest::keyClick(canvas, Qt::Key_Down);
+
+ QTRY_COMPARE(listview->contentY(), expectedPos);
+
+ expectedPos += 20; // scroll past 1st item of 2nd section
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QTRY_COMPARE(listview->contentY(), expectedPos);
+
+ expectedPos += 20 + 10; // scroll past 2nd item of 2nd section and section delegate of 3rd section
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QTRY_COMPARE(listview->contentY(), expectedPos);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::spacing()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ listview->setSpacing(10);
+ QTRY_VERIFY(listview->spacing() == 10);
+
+ // Confirm items positioned correctly
+ QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() == 11);
+ for (int i = 0; i < 11; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*30);
+ }
+
+ listview->setSpacing(0);
+
+ // Confirm items positioned correctly
+ QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").count() >= 16);
+ for (int i = 0; i < 16; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.0);
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+template <typename T>
+void tst_QQuickListView::sections(const QUrl &source)
+{
+ QQuickView *canvas = createView();
+
+ T model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i/5));
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(source);
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20));
+ QQuickText *next = findItem<QQuickText>(item, "nextSection");
+ QCOMPARE(next->text().toInt(), (i+1)/5);
+ }
+
+ QSignalSpy currentSectionChangedSpy(listview, SIGNAL(currentSectionChanged()));
+
+ // Remove section boundary
+ model.removeItem(5);
+ QTRY_COMPARE(listview->count(), model.count());
+
+ // New section header created
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 5);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 40.0);
+
+ model.insertItem(3, "New Item", "0");
+ QTRY_COMPARE(listview->count(), model.count());
+
+ // Section header moved
+ item = findItem<QQuickItem>(contentItem, "wrapper", 5);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 20.0);
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 6);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 40.0);
+
+ // insert item which will become a section header
+ model.insertItem(6, "Replace header", "1");
+ QTRY_COMPARE(listview->count(), model.count());
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 6);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 40.0);
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 7);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 20.0);
+
+ QTRY_COMPARE(listview->currentSection(), QString("0"));
+
+ listview->setContentY(140);
+ QTRY_COMPARE(listview->currentSection(), QString("1"));
+
+ QTRY_COMPARE(currentSectionChangedSpy.count(), 1);
+
+ listview->setContentY(20);
+ QTRY_COMPARE(listview->currentSection(), QString("0"));
+
+ QTRY_COMPARE(currentSectionChangedSpy.count(), 2);
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 1);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 20.0);
+
+ // check that headers change when item changes
+ listview->setContentY(0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ model.modifyItem(0, "changed", "2");
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 1);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->height(), 40.0);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::sectionsDelegate()
+{
+ QSKIP("QTBUG-24395");
+
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i/5));
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("listview-sections_delegate.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20 + ((i+5)/5) * 20));
+ QQuickText *next = findItem<QQuickText>(item, "nextSection");
+ QCOMPARE(next->text().toInt(), (i+1)/5);
+ }
+
+ for (int i = 0; i < 3; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "sect_" + QString::number(i));
+ QVERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20*6));
+ }
+
+ // ensure section header is maintained in view
+ listview->setCurrentIndex(20);
+ QTRY_VERIFY(listview->contentY() >= 200.0);
+ listview->setCurrentIndex(0);
+ QTRY_COMPARE(listview->contentY(), 0.0);
+
+ // change section
+ model.modifyItem(0, "One", "aaa");
+ model.modifyItem(1, "Two", "aaa");
+ model.modifyItem(2, "Three", "aaa");
+ model.modifyItem(3, "Four", "aaa");
+ model.modifyItem(4, "Five", "aaa");
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ for (int i = 0; i < 3; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem,
+ "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
+ QVERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20*6));
+ }
+
+ // remove section boundary
+ model.removeItem(5);
+ QTRY_COMPARE(listview->count(), model.count());
+ for (int i = 0; i < 3; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem,
+ "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
+ QVERIFY(item);
+ }
+
+ // QTBUG-17606
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "sect_1");
+ QCOMPARE(items.count(), 1);
+
+ // QTBUG-17759
+ model.modifyItem(0, "One", "aaa");
+ model.modifyItem(1, "One", "aaa");
+ model.modifyItem(2, "One", "aaa");
+ model.modifyItem(3, "Four", "aaa");
+ model.modifyItem(4, "Four", "aaa");
+ model.modifyItem(5, "Four", "aaa");
+ model.modifyItem(6, "Five", "aaa");
+ model.modifyItem(7, "Five", "aaa");
+ model.modifyItem(8, "Five", "aaa");
+ model.modifyItem(9, "Two", "aaa");
+ model.modifyItem(10, "Two", "aaa");
+ model.modifyItem(11, "Two", "aaa");
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_aaa").count(), 1);
+ canvas->rootObject()->setProperty("sectionProperty", "name");
+ // ensure view has settled.
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_Four").count(), 1);
+ for (int i = 0; i < 4; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem,
+ "sect_" + model.name(i*3));
+ QVERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20*4));
+ }
+
+ // QTBUG-17769
+ model.removeItems(10, 20);
+ // ensure view has settled.
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 10);
+ // Drag view up beyond bounds
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(20,20));
+ {
+ QMouseEvent mv(QEvent::MouseMove, QPoint(20,0), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QGuiApplication::sendEvent(canvas, &mv);
+ }
+ {
+ QMouseEvent mv(QEvent::MouseMove, QPoint(20,-50), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QGuiApplication::sendEvent(canvas, &mv);
+ }
+ {
+ QMouseEvent mv(QEvent::MouseMove, QPoint(20,-200), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QGuiApplication::sendEvent(canvas, &mv);
+ }
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(20,-200));
+ // view should settle back at 0
+ QTRY_COMPARE(listview->contentY(), 0.0);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::sectionsPositioning()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i/5));
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("listview-sections_delegate.qml"));
+ canvas->show();
+ qApp->processEvents();
+ canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart | QQuickViewSection::NextLabelAtEnd)));
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ for (int i = 0; i < 3; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "sect_" + QString::number(i));
+ QVERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20*6));
+ }
+
+ QQuickItem *topItem = findVisibleChild(contentItem, "sect_0"); // section header
+ QVERIFY(topItem);
+ QCOMPARE(topItem->y(), 0.);
+
+ QQuickItem *bottomItem = findVisibleChild(contentItem, "sect_3"); // section footer
+ QVERIFY(bottomItem);
+ QCOMPARE(bottomItem->y(), 300.);
+
+ // move down a little and check that section header is at top
+ listview->setContentY(10);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QCOMPARE(topItem->y(), 0.);
+
+ // push the top header up
+ listview->setContentY(110);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ topItem = findVisibleChild(contentItem, "sect_0"); // section header
+ QVERIFY(topItem);
+ QCOMPARE(topItem->y(), 100.);
+
+ QQuickItem *item = findVisibleChild(contentItem, "sect_1");
+ QVERIFY(item);
+ QCOMPARE(item->y(), 120.);
+
+ bottomItem = findVisibleChild(contentItem, "sect_4"); // section footer
+ QVERIFY(bottomItem);
+ QCOMPARE(bottomItem->y(), 410.);
+
+ // Move past section 0
+ listview->setContentY(120);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ topItem = findVisibleChild(contentItem, "sect_0"); // section header
+ QVERIFY(!topItem);
+
+ // Push section footer down
+ listview->setContentY(70);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ bottomItem = findVisibleChild(contentItem, "sect_4"); // section footer
+ QVERIFY(bottomItem);
+ QCOMPARE(bottomItem->y(), 380.);
+
+ // Change current section
+ listview->setContentY(10);
+ model.modifyItem(0, "One", "aaa");
+ model.modifyItem(1, "Two", "aaa");
+ model.modifyItem(2, "Three", "aaa");
+ model.modifyItem(3, "Four", "aaa");
+ model.modifyItem(4, "Five", "aaa");
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QTRY_COMPARE(listview->currentSection(), QString("aaa"));
+
+ for (int i = 0; i < 3; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem,
+ "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
+ QVERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20*6));
+ }
+
+ QTRY_VERIFY(topItem = findVisibleChild(contentItem, "sect_aaa")); // section header
+ QCOMPARE(topItem->y(), 10.);
+
+ // remove section boundary
+ listview->setContentY(120);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ model.removeItem(5);
+ QTRY_COMPARE(listview->count(), model.count());
+ for (int i = 0; i < 3; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem,
+ "sect_" + (i == 0 ? QString("aaa") : QString::number(i)));
+ QVERIFY(item);
+ QTRY_COMPARE(item->y(), qreal(i*20*6));
+ }
+
+ QVERIFY(topItem = findVisibleChild(contentItem, "sect_1"));
+ QTRY_COMPARE(topItem->y(), 120.);
+
+ // Change the next section
+ listview->setContentY(0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ bottomItem = findVisibleChild(contentItem, "sect_3"); // section footer
+ QVERIFY(bottomItem);
+ QTRY_COMPARE(bottomItem->y(), 300.);
+
+ model.modifyItem(14, "New", "new");
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QTRY_VERIFY(bottomItem = findVisibleChild(contentItem, "sect_new")); // section footer
+ QTRY_COMPARE(bottomItem->y(), 300.);
+
+ // Turn sticky footer off
+ listview->setContentY(20);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart)));
+ QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_new")); // inline label restored
+ QCOMPARE(item->y(), 340.);
+
+ // Turn sticky header off
+ listview->setContentY(30);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels)));
+ QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_aaa")); // inline label restored
+ QCOMPARE(item->y(), 0.);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::currentIndex_delayedItemCreation()
+{
+ QFETCH(bool, setCurrentToZero);
+
+ QQuickView *canvas = createView();
+
+ // test currentIndexChanged() is emitted even if currentIndex = 0 on start up
+ // (since the currentItem will have changed and that shares the same index)
+ canvas->rootContext()->setContextProperty("setCurrentToZero", setCurrentToZero);
+
+ canvas->setSource(testFileUrl("fillModelOnComponentCompleted.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QSignalSpy spy(listview, SIGNAL(currentItemChanged()));
+ QCOMPARE(listview->currentIndex(), 0);
+ QTRY_COMPARE(spy.count(), 1);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::currentIndex_delayedItemCreation_data()
+{
+ QTest::addColumn<bool>("setCurrentToZero");
+
+ QTest::newRow("set to 0") << true;
+ QTest::newRow("don't set to 0") << false;
+}
+
+void tst_QQuickListView::currentIndex()
+{
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testWrap", QVariant(false));
+
+ QString filename(testFile("listview-initCurrent.qml"));
+ canvas->setSource(QUrl::fromLocalFile(filename));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // current item should be 20th item at startup
+ // and current item should be in view
+ QCOMPARE(listview->currentIndex(), 20);
+ QCOMPARE(listview->contentY(), 100.0);
+ QCOMPARE(listview->currentItem(), findItem<QQuickItem>(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);
+ listview->decrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), 0);
+
+ listview->decrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), 0);
+
+ // with wrap
+ ctxt->setContextProperty("testWrap", QVariant(true));
+ QVERIFY(listview->isWrapEnabled());
+
+ listview->decrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), model.count()-1);
+
+ QTRY_COMPARE(listview->contentY(), 280.0);
+
+ listview->incrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), 0);
+
+ QTRY_COMPARE(listview->contentY(), 0.0);
+
+
+ // footer should become visible if it is out of view, and then current index is set to count-1
+ canvas->rootObject()->setProperty("showFooter", true);
+ QTRY_VERIFY(listview->footerItem());
+ listview->setCurrentIndex(model.count()-2);
+ QTRY_VERIFY(listview->footerItem()->y() > listview->contentY() + listview->height());
+ listview->setCurrentIndex(model.count()-1);
+ QTRY_COMPARE(listview->contentY() + listview->height(), (20.0 * model.count()) + listview->footerItem()->height());
+ canvas->rootObject()->setProperty("showFooter", false);
+
+ // header should become visible if it is out of view, and then current index is set to 0
+ canvas->rootObject()->setProperty("showHeader", true);
+ QTRY_VERIFY(listview->headerItem());
+ listview->setCurrentIndex(1);
+ QTRY_VERIFY(listview->headerItem()->y() + listview->headerItem()->height() < listview->contentY());
+ listview->setCurrentIndex(0);
+ QTRY_COMPARE(listview->contentY(), -listview->headerItem()->height());
+ canvas->rootObject()->setProperty("showHeader", false);
+
+
+ // Test keys
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(qGuiApp->focusWindow() == canvas);
+
+ listview->setCurrentIndex(0);
+
+ QTest::keyClick(canvas, Qt::Key_Down);
+ QCOMPARE(listview->currentIndex(), 1);
+
+ QTest::keyClick(canvas, Qt::Key_Up);
+ QCOMPARE(listview->currentIndex(), 0);
+
+ // hold down Key_Down
+ for (int i=0; i<model.count()-1; i++) {
+ QTest::simulateEvent(canvas, true, Qt::Key_Down, Qt::NoModifier, "", true);
+ QTRY_COMPARE(listview->currentIndex(), i+1);
+ }
+ QTest::keyRelease(canvas, Qt::Key_Down);
+ QTRY_COMPARE(listview->currentIndex(), model.count()-1);
+ QTRY_COMPARE(listview->contentY(), 280.0);
+
+ // hold down Key_Up
+ for (int i=model.count()-1; i > 0; i--) {
+ QTest::simulateEvent(canvas, true, Qt::Key_Up, Qt::NoModifier, "", true);
+ QTRY_COMPARE(listview->currentIndex(), i-1);
+ }
+ QTest::keyRelease(canvas, Qt::Key_Up);
+ QTRY_COMPARE(listview->currentIndex(), 0);
+ QTRY_COMPARE(listview->contentY(), 0.0);
+
+
+ // turn off auto highlight
+ listview->setHighlightFollowsCurrentItem(false);
+ QVERIFY(listview->highlightFollowsCurrentItem() == false);
+
+ QVERIFY(listview->highlightItem());
+ qreal hlPos = listview->highlightItem()->y();
+
+ listview->setCurrentIndex(4);
+ QTRY_COMPARE(listview->highlightItem()->y(), hlPos);
+
+ // insert item before currentIndex
+ listview->setCurrentIndex(28);
+ model.insertItem(0, "Foo", "1111");
+ QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29);
+
+ // check removing highlight by setting currentIndex to -1;
+ listview->setCurrentIndex(-1);
+
+ QCOMPARE(listview->currentIndex(), -1);
+ QVERIFY(!listview->highlightItem());
+ QVERIFY(!listview->currentItem());
+
+ delete canvas;
+}
+
+void tst_QQuickListView::noCurrentIndex()
+{
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ QString filename(testFile("listview-noCurrent.qml"));
+ canvas->setSource(QUrl::fromLocalFile(filename));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // current index should be -1 at startup
+ // and we should not have a currentItem or highlightItem
+ QCOMPARE(listview->currentIndex(), -1);
+ QCOMPARE(listview->contentY(), 0.0);
+ QVERIFY(!listview->highlightItem());
+ QVERIFY(!listview->currentItem());
+
+ listview->setCurrentIndex(2);
+ QCOMPARE(listview->currentIndex(), 2);
+ QVERIFY(listview->highlightItem());
+ QVERIFY(listview->currentItem());
+
+ delete canvas;
+}
+
+void tst_QQuickListView::itemList()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("itemlist.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "view");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickVisualItemModel *model = canvas->rootObject()->findChild<QQuickVisualItemModel*>("itemModel");
+ QTRY_VERIFY(model != 0);
+
+ QTRY_VERIFY(model->count() == 3);
+ QTRY_COMPARE(listview->currentIndex(), 0);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "item1");
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), 0.0);
+ QCOMPARE(item->height(), listview->height());
+
+ QQuickText *text = findItem<QQuickText>(contentItem, "text1");
+ QTRY_VERIFY(text);
+ QTRY_COMPARE(text->text(), QLatin1String("index: 0"));
+
+ listview->setCurrentIndex(2);
+
+ item = findItem<QQuickItem>(contentItem, "item3");
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), 480.0);
+
+ text = findItem<QQuickText>(contentItem, "text3");
+ QTRY_VERIFY(text);
+ QTRY_COMPARE(text->text(), QLatin1String("index: 2"));
+
+ delete canvas;
+}
+
+void tst_QQuickListView::cacheBuffer()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 90; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_VERIFY(listview->delegate() != 0);
+ QTRY_VERIFY(listview->model() != 0);
+ QTRY_VERIFY(listview->highlight() != 0);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ QQmlIncubationController controller;
+ canvas->engine()->setIncubationController(&controller);
+
+ testObject->setCacheBuffer(200);
+ QTRY_VERIFY(listview->cacheBuffer() == 200);
+
+ // items will be created one at a time
+ for (int i = itemCount; i < qMin(itemCount+10,model.count()); ++i) {
+ QVERIFY(findItem<QQuickItem>(listview, "wrapper", i) == 0);
+ QQuickItem *item = 0;
+ while (!item) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ item = findItem<QQuickItem>(listview, "wrapper", i);
+ }
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ int newItemCount = 0;
+ newItemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+
+ // Confirm items positioned correctly
+ for (int i = 0; i < model.count() && i < newItemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ // move view and confirm items in view are visible immediately and outside are created async
+ listview->setContentY(300);
+
+ for (int i = 15; i < 32; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QVERIFY(item);
+ QVERIFY(item->y() == i*20);
+ }
+
+ QVERIFY(findItem<QQuickItem>(listview, "wrapper", 32) == 0);
+
+ // ensure buffered items are created
+ for (int i = 32; i < qMin(41,model.count()); ++i) {
+ QQuickItem *item = 0;
+ while (!item) {
+ qGuiApp->processEvents(); // allow refill to happen
+ bool b = false;
+ controller.incubateWhile(&b);
+ item = findItem<QQuickItem>(listview, "wrapper", i);
+ }
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::positionViewAtIndex()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+ canvas->show();
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
+ // Position on a currently visible item
+ listview->positionViewAtIndex(3, QQuickListView::Beginning);
+ QTRY_COMPARE(listview->contentY(), 60.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
+ // Position on an item beyond the visible items
+ listview->positionViewAtIndex(22, QQuickListView::Beginning);
+ QTRY_COMPARE(listview->contentY(), 440.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
+ // Position on an item that would leave empty space if positioned at the top
+ listview->positionViewAtIndex(28, QQuickListView::Beginning);
+ QTRY_COMPARE(listview->contentY(), 480.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
+ // Position at the beginning again
+ listview->positionViewAtIndex(0, QQuickListView::Beginning);
+ QTRY_COMPARE(listview->contentY(), 0.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
+ // Position at End using last index
+ listview->positionViewAtIndex(model.count()-1, QQuickListView::End);
+ QTRY_COMPARE(listview->contentY(), 480.);
+
+ // Confirm items positioned correctly
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 24; i < model.count(); ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ }
+
+ // Position at End
+ listview->positionViewAtIndex(20, QQuickListView::End);
+ QTRY_COMPARE(listview->contentY(), 100.);
+
+ // Position in Center
+ listview->positionViewAtIndex(15, QQuickListView::Center);
+ QTRY_COMPARE(listview->contentY(), 150.);
+
+ // Ensure at least partially visible
+ listview->positionViewAtIndex(15, QQuickListView::Visible);
+ QTRY_COMPARE(listview->contentY(), 150.);
+
+ listview->setContentY(302);
+ listview->positionViewAtIndex(15, QQuickListView::Visible);
+ QTRY_COMPARE(listview->contentY(), 302.);
+
+ listview->setContentY(320);
+ listview->positionViewAtIndex(15, QQuickListView::Visible);
+ QTRY_COMPARE(listview->contentY(), 300.);
+
+ listview->setContentY(85);
+ listview->positionViewAtIndex(20, QQuickListView::Visible);
+ QTRY_COMPARE(listview->contentY(), 85.);
+
+ listview->setContentY(75);
+ listview->positionViewAtIndex(20, QQuickListView::Visible);
+ QTRY_COMPARE(listview->contentY(), 100.);
+
+ // Ensure completely visible
+ listview->setContentY(120);
+ listview->positionViewAtIndex(20, QQuickListView::Contain);
+ QTRY_COMPARE(listview->contentY(), 120.);
+
+ listview->setContentY(302);
+ listview->positionViewAtIndex(15, QQuickListView::Contain);
+ QTRY_COMPARE(listview->contentY(), 300.);
+
+ listview->setContentY(85);
+ listview->positionViewAtIndex(20, QQuickListView::Contain);
+ QTRY_COMPARE(listview->contentY(), 100.);
+
+ // positionAtBeginnging
+ listview->positionViewAtBeginning();
+ QTRY_COMPARE(listview->contentY(), 0.);
+
+ listview->setContentY(80);
+ canvas->rootObject()->setProperty("showHeader", true);
+ listview->positionViewAtBeginning();
+ QTRY_COMPARE(listview->contentY(), -30.);
+
+ // positionAtEnd
+ listview->positionViewAtEnd();
+ QTRY_COMPARE(listview->contentY(), 480.); // 40*20 - 320
+
+ listview->setContentY(80);
+ canvas->rootObject()->setProperty("showFooter", true);
+ listview->positionViewAtEnd();
+ QTRY_COMPARE(listview->contentY(), 510.);
+
+ // set current item to outside visible view, position at beginning
+ // and ensure highlight moves to current item
+ listview->setCurrentIndex(1);
+ listview->positionViewAtBeginning();
+ QTRY_COMPARE(listview->contentY(), -30.);
+ QVERIFY(listview->highlightItem());
+ QCOMPARE(listview->highlightItem()->y(), 20.);
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::resetModel()
+{
+ QQuickView *canvas = createView();
+
+ QStringList strings;
+ strings << "one" << "two" << "three";
+ QStringListModel model(strings);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("displaylist.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QTRY_COMPARE(listview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QQuickText *display = findItem<QQuickText>(contentItem, "displayText", i);
+ QTRY_VERIFY(display != 0);
+ QTRY_COMPARE(display->text(), strings.at(i));
+ }
+
+ strings.clear();
+ strings << "four" << "five" << "six" << "seven";
+ model.setStringList(strings);
+
+ QTRY_COMPARE(listview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QQuickText *display = findItem<QQuickText>(contentItem, "displayText", i);
+ QTRY_VERIFY(display != 0);
+ QTRY_COMPARE(display->text(), strings.at(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickListView::propertyChanges()
+{
+ QQuickView *canvas = createView();
+ QTRY_VERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
+
+ QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView");
+ QTRY_VERIFY(listView);
+
+ QSignalSpy highlightFollowsCurrentItemSpy(listView, SIGNAL(highlightFollowsCurrentItemChanged()));
+ QSignalSpy preferredHighlightBeginSpy(listView, SIGNAL(preferredHighlightBeginChanged()));
+ QSignalSpy preferredHighlightEndSpy(listView, SIGNAL(preferredHighlightEndChanged()));
+ QSignalSpy highlightRangeModeSpy(listView, SIGNAL(highlightRangeModeChanged()));
+ QSignalSpy keyNavigationWrapsSpy(listView, SIGNAL(keyNavigationWrapsChanged()));
+ QSignalSpy cacheBufferSpy(listView, SIGNAL(cacheBufferChanged()));
+ QSignalSpy snapModeSpy(listView, SIGNAL(snapModeChanged()));
+
+ QTRY_COMPARE(listView->highlightFollowsCurrentItem(), true);
+ QTRY_COMPARE(listView->preferredHighlightBegin(), 0.0);
+ QTRY_COMPARE(listView->preferredHighlightEnd(), 0.0);
+ QTRY_COMPARE(listView->highlightRangeMode(), QQuickListView::ApplyRange);
+ QTRY_COMPARE(listView->isWrapEnabled(), true);
+ QTRY_COMPARE(listView->cacheBuffer(), 10);
+ QTRY_COMPARE(listView->snapMode(), QQuickListView::SnapToItem);
+
+ listView->setHighlightFollowsCurrentItem(false);
+ listView->setPreferredHighlightBegin(1.0);
+ listView->setPreferredHighlightEnd(1.0);
+ listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange);
+ listView->setWrapEnabled(false);
+ listView->setCacheBuffer(3);
+ listView->setSnapMode(QQuickListView::SnapOneItem);
+
+ QTRY_COMPARE(listView->highlightFollowsCurrentItem(), false);
+ QTRY_COMPARE(listView->preferredHighlightBegin(), 1.0);
+ QTRY_COMPARE(listView->preferredHighlightEnd(), 1.0);
+ QTRY_COMPARE(listView->highlightRangeMode(), QQuickListView::StrictlyEnforceRange);
+ QTRY_COMPARE(listView->isWrapEnabled(), false);
+ QTRY_COMPARE(listView->cacheBuffer(), 3);
+ QTRY_COMPARE(listView->snapMode(), QQuickListView::SnapOneItem);
+
+ QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1);
+ QTRY_COMPARE(preferredHighlightBeginSpy.count(),1);
+ QTRY_COMPARE(preferredHighlightEndSpy.count(),1);
+ QTRY_COMPARE(highlightRangeModeSpy.count(),1);
+ QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
+ QTRY_COMPARE(cacheBufferSpy.count(),1);
+ QTRY_COMPARE(snapModeSpy.count(),1);
+
+ listView->setHighlightFollowsCurrentItem(false);
+ listView->setPreferredHighlightBegin(1.0);
+ listView->setPreferredHighlightEnd(1.0);
+ listView->setHighlightRangeMode(QQuickListView::StrictlyEnforceRange);
+ listView->setWrapEnabled(false);
+ listView->setCacheBuffer(3);
+ listView->setSnapMode(QQuickListView::SnapOneItem);
+
+ QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1);
+ QTRY_COMPARE(preferredHighlightBeginSpy.count(),1);
+ QTRY_COMPARE(preferredHighlightEndSpy.count(),1);
+ QTRY_COMPARE(highlightRangeModeSpy.count(),1);
+ QTRY_COMPARE(keyNavigationWrapsSpy.count(),1);
+ QTRY_COMPARE(cacheBufferSpy.count(),1);
+ QTRY_COMPARE(snapModeSpy.count(),1);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::componentChanges()
+{
+ QQuickView *canvas = createView();
+ QTRY_VERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
+
+ QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView");
+ QTRY_VERIFY(listView);
+
+ QQmlComponent component(canvas->engine());
+ component.setData("import QtQuick 2.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile(""));
+
+ QQmlComponent delegateComponent(canvas->engine());
+ delegateComponent.setData("import QtQuick 2.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
+
+ QSignalSpy highlightSpy(listView, SIGNAL(highlightChanged()));
+ QSignalSpy delegateSpy(listView, SIGNAL(delegateChanged()));
+ QSignalSpy headerSpy(listView, SIGNAL(headerChanged()));
+ QSignalSpy footerSpy(listView, SIGNAL(footerChanged()));
+
+ listView->setHighlight(&component);
+ listView->setHeader(&component);
+ listView->setFooter(&component);
+ listView->setDelegate(&delegateComponent);
+
+ QTRY_COMPARE(listView->highlight(), &component);
+ QTRY_COMPARE(listView->header(), &component);
+ QTRY_COMPARE(listView->footer(), &component);
+ QTRY_COMPARE(listView->delegate(), &delegateComponent);
+
+ QTRY_COMPARE(highlightSpy.count(),1);
+ QTRY_COMPARE(delegateSpy.count(),1);
+ QTRY_COMPARE(headerSpy.count(),1);
+ QTRY_COMPARE(footerSpy.count(),1);
+
+ listView->setHighlight(&component);
+ listView->setHeader(&component);
+ listView->setFooter(&component);
+ listView->setDelegate(&delegateComponent);
+
+ QTRY_COMPARE(highlightSpy.count(),1);
+ QTRY_COMPARE(delegateSpy.count(),1);
+ QTRY_COMPARE(headerSpy.count(),1);
+ QTRY_COMPARE(footerSpy.count(),1);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::modelChanges()
+{
+ QQuickView *canvas = createView();
+ QTRY_VERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
+
+ QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView");
+ QTRY_VERIFY(listView);
+
+ QQuickListModel *alternateModel = canvas->rootObject()->findChild<QQuickListModel*>("alternateModel");
+ QTRY_VERIFY(alternateModel);
+ QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
+ QSignalSpy modelSpy(listView, SIGNAL(modelChanged()));
+
+ listView->setModel(modelVariant);
+ QTRY_COMPARE(listView->model(), modelVariant);
+ QTRY_COMPARE(modelSpy.count(),1);
+
+ listView->setModel(modelVariant);
+ QTRY_COMPARE(modelSpy.count(),1);
+
+ listView->setModel(QVariant());
+ QTRY_COMPARE(modelSpy.count(),2);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::QTBUG_9791()
+{
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("strictlyenforcerange.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_VERIFY(listview->delegate() != 0);
+ QTRY_VERIFY(listview->model() != 0);
+
+ QMetaObject::invokeMethod(listview, "fillModel");
+ qApp->processEvents();
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+ QCOMPARE(itemCount, 3);
+
+ for (int i = 0; i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), i*300.0);
+ }
+
+ // check that view is positioned correctly
+ QTRY_COMPARE(listview->contentX(), 590.0);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::manualHighlight()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+
+ QString filename(testFile("manual-highlight.qml"));
+ canvas->setSource(QUrl::fromLocalFile(filename));
+
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(listview->currentIndex(), 0);
+ QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 0));
+ QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
+
+ listview->setCurrentIndex(2);
+
+ QTRY_COMPARE(listview->currentIndex(), 2);
+ QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
+ QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
+
+ // QTBUG-15972
+ listview->positionViewAtIndex(3, QQuickListView::Contain);
+
+ QTRY_COMPARE(listview->currentIndex(), 2);
+ QTRY_COMPARE(listview->currentItem(), findItem<QQuickItem>(contentItem, "wrapper", 2));
+ QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y());
+
+ delete canvas;
+}
+
+void tst_QQuickListView::QTBUG_11105()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_VERIFY(item->y() == i*20);
+ }
+
+ listview->positionViewAtIndex(20, QQuickListView::Beginning);
+ QCOMPARE(listview->contentY(), 280.);
+
+ QmlListModel model2;
+ for (int i = 0; i < 5; i++)
+ model2.addItem("Item" + QString::number(i), "");
+
+ ctxt->setContextProperty("testModel", &model2);
+
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ QCOMPARE(itemCount, 5);
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::header()
+{
+ QFETCH(QQuickListView::Orientation, orientation);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(QPointF, initialHeaderPos);
+ QFETCH(QPointF, firstDelegatePos);
+ QFETCH(QPointF, initialContentPos);
+ QFETCH(QPointF, changedHeaderPos);
+ QFETCH(QPointF, changedContentPos);
+ QFETCH(QPointF, resizeContentPos);
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQuickView *canvas = createView();
+ canvas->rootContext()->setContextProperty("testModel", &model);
+ canvas->rootContext()->setContextProperty("initialViewWidth", 240);
+ canvas->rootContext()->setContextProperty("initialViewHeight", 320);
+ canvas->setSource(testFileUrl("header.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ listview->setOrientation(orientation);
+ listview->setLayoutDirection(layoutDirection);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickText *header = 0;
+ QTRY_VERIFY(header = findItem<QQuickText>(contentItem, "header"));
+ QVERIFY(header == listview->headerItem());
+
+ QCOMPARE(header->width(), 100.);
+ QCOMPARE(header->height(), 30.);
+ QCOMPARE(header->pos(), initialHeaderPos);
+ QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->pos(), firstDelegatePos);
+
+ model.clear();
+ QTRY_COMPARE(listview->count(), model.count());
+ QCOMPARE(header->pos(), initialHeaderPos); // header should stay where it is
+
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QSignalSpy headerItemSpy(listview, SIGNAL(headerItemChanged()));
+ QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader");
+
+ QCOMPARE(headerItemSpy.count(), 1);
+
+ header = findItem<QQuickText>(contentItem, "header");
+ QVERIFY(!header);
+ header = findItem<QQuickText>(contentItem, "header2");
+ QVERIFY(header);
+
+ QVERIFY(header == listview->headerItem());
+
+ QCOMPARE(header->pos(), changedHeaderPos);
+ QCOMPARE(header->width(), 50.);
+ QCOMPARE(header->height(), 20.);
+ QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), changedContentPos);
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->pos(), firstDelegatePos);
+
+ delete canvas;
+
+
+ // QTBUG-21207 header should become visible if view resizes from initial empty size
+
+ canvas = createView();
+ canvas->rootContext()->setContextProperty("testModel", &model);
+ canvas->rootContext()->setContextProperty("initialViewWidth", 0.0);
+ canvas->rootContext()->setContextProperty("initialViewHeight", 0.0);
+ canvas->setSource(testFileUrl("header.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ listview->setOrientation(orientation);
+ listview->setLayoutDirection(layoutDirection);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ listview->setWidth(240);
+ listview->setHeight(320);
+ QTRY_COMPARE(listview->headerItem()->pos(), initialHeaderPos);
+ QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos);
+
+
+ delete canvas;
+}
+
+void tst_QQuickListView::header_data()
+{
+ QTest::addColumn<QQuickListView::Orientation>("orientation");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<QPointF>("initialHeaderPos");
+ QTest::addColumn<QPointF>("changedHeaderPos");
+ QTest::addColumn<QPointF>("initialContentPos");
+ QTest::addColumn<QPointF>("changedContentPos");
+ QTest::addColumn<QPointF>("firstDelegatePos");
+ QTest::addColumn<QPointF>("resizeContentPos");
+
+ // header1 = 100 x 30
+ // header2 = 50 x 20
+ // delegates = 240 x 20
+ // view width = 240
+
+ // header above items, top left
+ QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight
+ << QPointF(0, -30)
+ << QPointF(0, -20)
+ << QPointF(0, -30)
+ << QPointF(0, -20)
+ << QPointF(0, 0)
+ << QPointF(0, -10);
+
+ // header above items, top right
+ QTest::newRow("vertical, layout right to left") << QQuickListView::Vertical << Qt::RightToLeft
+ << QPointF(0, -30)
+ << QPointF(0, -20)
+ << QPointF(0, -30)
+ << QPointF(0, -20)
+ << QPointF(0, 0)
+ << QPointF(0, -10);
+
+ // header to left of items
+ QTest::newRow("horizontal, layout left to right") << QQuickListView::Horizontal << Qt::LeftToRight
+ << QPointF(-100, 0)
+ << QPointF(-50, 0)
+ << QPointF(-100, 0)
+ << QPointF(-50, 0)
+ << QPointF(0, 0)
+ << QPointF(-40, 0);
+
+ // header to right of items
+ QTest::newRow("horizontal, layout right to left") << QQuickListView::Horizontal << Qt::RightToLeft
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(-240 + 100, 0)
+ << QPointF(-240 + 50, 0)
+ << QPointF(-240, 0)
+ << QPointF(-240 + 40, 0);
+}
+
+void tst_QQuickListView::header_delayItemCreation()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+
+ canvas->rootContext()->setContextProperty("setCurrentToZero", QVariant(false));
+ canvas->setSource(testFileUrl("fillModelOnComponentCompleted.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickText *header = findItem<QQuickText>(contentItem, "header");
+ QVERIFY(header);
+ QCOMPARE(header->y(), -header->height());
+
+ QCOMPARE(listview->contentY(), -header->height());
+
+ model.clear();
+ QTRY_COMPARE(header->y(), -header->height());
+
+ delete canvas;
+}
+
+void tst_QQuickListView::footer()
+{
+ QFETCH(QQuickListView::Orientation, orientation);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(QPointF, initialFooterPos);
+ QFETCH(QPointF, firstDelegatePos);
+ QFETCH(QPointF, initialContentPos);
+ QFETCH(QPointF, changedFooterPos);
+ QFETCH(QPointF, changedContentPos);
+ QFETCH(QPointF, resizeContentPos);
+
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 3; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("footer.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ listview->setOrientation(orientation);
+ listview->setLayoutDirection(layoutDirection);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickText *footer = findItem<QQuickText>(contentItem, "footer");
+ QVERIFY(footer);
+
+ QVERIFY(footer == listview->footerItem());
+
+ QCOMPARE(footer->pos(), initialFooterPos);
+ QCOMPARE(footer->width(), 100.);
+ QCOMPARE(footer->height(), 30.);
+ QCOMPARE(QPointF(listview->contentX(), listview->contentY()), initialContentPos);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->pos(), firstDelegatePos);
+
+ // remove one item
+ model.removeItem(1);
+
+ if (orientation == QQuickListView::Vertical) {
+ QTRY_COMPARE(footer->y(), initialFooterPos.y() - 20); // delegate height = 20
+ } else {
+ QTRY_COMPARE(footer->x(), layoutDirection == Qt::LeftToRight ?
+ initialFooterPos.x() - 40 : initialFooterPos.x() + 40); // delegate width = 40
+ }
+
+ // remove all items
+ model.clear();
+
+ QPointF posWhenNoItems(0, 0);
+ if (orientation == QQuickListView::Horizontal && layoutDirection == Qt::RightToLeft)
+ posWhenNoItems.setX(-100);
+ QTRY_COMPARE(footer->pos(), posWhenNoItems);
+
+ // if header is present, it's at a negative pos, so the footer should not move
+ canvas->rootObject()->setProperty("showHeader", true);
+ QTRY_COMPARE(footer->pos(), posWhenNoItems);
+ canvas->rootObject()->setProperty("showHeader", false);
+
+ // add 30 items
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QSignalSpy footerItemSpy(listview, SIGNAL(footerItemChanged()));
+ QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter");
+
+ QCOMPARE(footerItemSpy.count(), 1);
+
+ footer = findItem<QQuickText>(contentItem, "footer");
+ QVERIFY(!footer);
+ footer = findItem<QQuickText>(contentItem, "footer2");
+ QVERIFY(footer);
+
+ QVERIFY(footer == listview->footerItem());
+
+ QCOMPARE(footer->pos(), changedFooterPos);
+ QCOMPARE(footer->width(), 50.);
+ QCOMPARE(footer->height(), 20.);
+ QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), changedContentPos);
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->pos(), firstDelegatePos);
+
+ listview->positionViewAtEnd();
+ footer->setHeight(10);
+ footer->setWidth(40);
+ QTRY_COMPARE(QPointF(listview->contentX(), listview->contentY()), resizeContentPos);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::footer_data()
+{
+ QTest::addColumn<QQuickListView::Orientation>("orientation");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<QPointF>("initialFooterPos");
+ QTest::addColumn<QPointF>("changedFooterPos");
+ QTest::addColumn<QPointF>("initialContentPos");
+ QTest::addColumn<QPointF>("changedContentPos");
+ QTest::addColumn<QPointF>("firstDelegatePos");
+ QTest::addColumn<QPointF>("resizeContentPos");
+
+ // footer1 = 100 x 30
+ // footer2 = 50 x 20
+ // delegates = 40 x 20
+ // view width = 240
+ // view height = 320
+
+ // footer below items, bottom left
+ QTest::newRow("vertical, layout left to right") << QQuickListView::Vertical << Qt::LeftToRight
+ << QPointF(0, 3 * 20)
+ << QPointF(0, 30 * 20) // added 30 items
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 30 * 20 - 320 + 10);
+
+ // footer below items, bottom right
+ QTest::newRow("vertical, layout right to left") << QQuickListView::Vertical << Qt::RightToLeft
+ << QPointF(0, 3 * 20)
+ << QPointF(0, 30 * 20)
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 30 * 20 - 320 + 10);
+
+ // footer to right of items
+ QTest::newRow("horizontal, layout left to right") << QQuickListView::Horizontal << Qt::LeftToRight
+ << QPointF(40 * 3, 0)
+ << QPointF(40 * 30, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(0, 0)
+ << QPointF(40 * 30 - 240 + 40, 0);
+
+ // footer to left of items
+ QTest::newRow("horizontal, layout right to left") << QQuickListView::Horizontal << Qt::RightToLeft
+ << QPointF(-(40 * 3) - 100, 0)
+ << QPointF(-(40 * 30) - 50, 0) // 50 = new footer width
+ << QPointF(-240, 0)
+ << QPointF(-240, 0)
+ << QPointF(-40, 0)
+ << QPointF(-(40 * 30) - 40, 0);
+}
+
+class LVAccessor : public QQuickListView
+{
+public:
+ qreal minY() const { return minYExtent(); }
+ qreal maxY() const { return maxYExtent(); }
+ qreal minX() const { return minXExtent(); }
+ qreal maxX() const { return maxXExtent(); }
+};
+
+void tst_QQuickListView::headerFooter()
+{
+ {
+ // Vertical
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("headerfooter.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickItem *header = findItem<QQuickItem>(contentItem, "header");
+ QVERIFY(header);
+ QCOMPARE(header->y(), -header->height());
+
+ QQuickItem *footer = findItem<QQuickItem>(contentItem, "footer");
+ QVERIFY(footer);
+ QCOMPARE(footer->y(), 0.);
+
+ QCOMPARE(static_cast<LVAccessor*>(listview)->minY(), header->height());
+ QCOMPARE(static_cast<LVAccessor*>(listview)->maxY(), header->height());
+
+ delete canvas;
+ }
+ {
+ // Horizontal
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("headerfooter.qml"));
+ canvas->rootObject()->setProperty("horizontal", true);
+ qApp->processEvents();
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickItem *header = findItem<QQuickItem>(contentItem, "header");
+ QVERIFY(header);
+ QCOMPARE(header->x(), -header->width());
+
+ QQuickItem *footer = findItem<QQuickItem>(contentItem, "footer");
+ QVERIFY(footer);
+ QCOMPARE(footer->x(), 0.);
+
+ QCOMPARE(static_cast<LVAccessor*>(listview)->minX(), header->width());
+ QCOMPARE(static_cast<LVAccessor*>(listview)->maxX(), header->width());
+
+ delete canvas;
+ }
+ {
+ // Horizontal RTL
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("headerfooter.qml"));
+ canvas->rootObject()->setProperty("horizontal", true);
+ canvas->rootObject()->setProperty("rtl", true);
+ qApp->processEvents();
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QQuickItem *header = findItem<QQuickItem>(contentItem, "header");
+ QVERIFY(header);
+ QCOMPARE(header->x(), 0.);
+
+ QQuickItem *footer = findItem<QQuickItem>(contentItem, "footer");
+ QVERIFY(footer);
+ QCOMPARE(footer->x(), -footer->width());
+
+ QCOMPARE(static_cast<LVAccessor*>(listview)->minX(), 240. - header->width());
+ QCOMPARE(static_cast<LVAccessor*>(listview)->maxX(), 240. - header->width());
+
+ delete canvas;
+ }
+}
+
+void tst_QQuickListView::resizeView()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(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);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio));
+ QCOMPARE(heightRatio.toReal(), 0.25);
+
+ // Ensure we handle -ve sizes
+ listview->setHeight(-100);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 1);
+
+ listview->setCacheBuffer(200);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 11);
+
+ // ensure items in cache become visible
+ listview->setHeight(200);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 21);
+
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ QCOMPARE(item->isVisible(), i < 11); // inside view visible, outside not visible
+ }
+
+ // ensure items outside view become invisible
+ listview->setHeight(100);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper", false).count(), 16);
+
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper", false).count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*20.);
+ QCOMPARE(item->isVisible(), i < 6); // inside view visible, outside not visible
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::resizeViewAndRepaint()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 40; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("initialHeight", 100);
+
+ canvas->setSource(testFileUrl("resizeview.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // item at index 10 should not be currently visible
+ QVERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
+
+ listview->setHeight(320);
+
+ QTRY_VERIFY(findItem<QQuickItem>(contentItem, "wrapper", 10));
+
+ listview->setHeight(100);
+ QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10));
+
+ delete canvas;
+}
+
+void tst_QQuickListView::sizeLessThan1()
+{
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("sizelessthan1.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // Confirm items positioned correctly
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i = 0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ if (!item) qWarning() << "Item" << i << "not found";
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->y(), i*0.5);
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::QTBUG_14821()
+{
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("qtbug14821.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ listview->decrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), 99);
+
+ listview->incrementCurrentIndex();
+ QCOMPARE(listview->currentIndex(), 0);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::resizeDelegate()
+{
+ QQuickView *canvas = createView();
+
+ QStringList strings;
+ for (int i = 0; i < 30; ++i)
+ strings << QString::number(i);
+ QStringListModel model(strings);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("displaylist.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QCOMPARE(listview->count(), model.rowCount());
+
+ listview->setCurrentIndex(25);
+ listview->setContentY(0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ for (int i = 0; i < 16; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QCOMPARE(item->y(), i*20.0);
+ }
+
+ QCOMPARE(listview->currentItem()->y(), 500.0);
+ QTRY_COMPARE(listview->highlightItem()->y(), 500.0);
+
+ canvas->rootObject()->setProperty("delegateHeight", 30);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ for (int i = 0; i < 11; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QTRY_COMPARE(item->y(), i*30.0);
+ }
+
+ QTRY_COMPARE(listview->currentItem()->y(), 750.0);
+ QTRY_COMPARE(listview->highlightItem()->y(), 750.0);
+
+ listview->setCurrentIndex(1);
+ listview->positionViewAtIndex(25, QQuickListView::Beginning);
+ listview->positionViewAtIndex(5, QQuickListView::Beginning);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ for (int i = 5; i < 16; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QCOMPARE(item->y(), i*30.0);
+ }
+
+ QTRY_COMPARE(listview->currentItem()->y(), 30.0);
+ QTRY_COMPARE(listview->highlightItem()->y(), 30.0);
+
+ canvas->rootObject()->setProperty("delegateHeight", 20);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ for (int i = 5; i < 11; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QTRY_COMPARE(item->y(), 150 + (i-5)*20.0);
+ }
+
+ QTRY_COMPARE(listview->currentItem()->y(), 70.0);
+ QTRY_COMPARE(listview->highlightItem()->y(), 70.0);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::resizeFirstDelegate()
+{
+ // QTBUG-20712: Content Y jumps constantly if first delegate height == 0
+ // and other delegates have height > 0
+
+ QQuickView *canvas = createView();
+
+ // bug only occurs when all items in the model are visible
+ QmlListModel model;
+ for (int i = 0; i < 10; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QVERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickItem *item = 0;
+ for (int i = 0; i < model.count(); ++i) {
+ item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QCOMPARE(item->y(), i*20.0);
+ }
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 0);
+ item->setHeight(0);
+
+ // check the content y has not jumped up and down
+ QCOMPARE(listview->contentY(), 0.0);
+ QSignalSpy spy(listview, SIGNAL(contentYChanged()));
+ QTest::qWait(100);
+ QCOMPARE(spy.count(), 0);
+
+ for (int i = 1; i < model.count(); ++i) {
+ item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY(item != 0);
+ QTRY_COMPARE(item->y(), (i-1)*20.0);
+ }
+
+
+ // QTBUG-22014: refill doesn't clear items scrolling off the top of the
+ // list if they follow a zero-sized delegate
+
+ for (int i = 0; i < 10; i++)
+ model.addItem("Item" + QString::number(i), "");
+ QTRY_COMPARE(listview->count(), model.count());
+
+ item = findItem<QQuickItem>(contentItem, "wrapper", 1);
+ QVERIFY(item);
+ item->setHeight(0);
+
+ listview->setCurrentIndex(19);
+ qApp->processEvents();
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // items 0-2 should have been deleted
+ for (int i=0; i<3; i++) {
+ QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", i));
+ }
+
+ delete testObject;
+ delete canvas;
+}
+
+void tst_QQuickListView::QTBUG_16037()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ canvas->setSource(testFileUrl("qtbug16037.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "listview");
+ QTRY_VERIFY(listview != 0);
+
+ QVERIFY(listview->contentHeight() <= 0.0);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "setModel");
+
+ QTRY_COMPARE(listview->contentHeight(), 80.0);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::indexAt_itemAt_data()
+{
+ QTest::addColumn<qreal>("x");
+ QTest::addColumn<qreal>("y");
+ QTest::addColumn<int>("index");
+
+ QTest::newRow("Item 0 - 0, 0") << 0. << 0. << 0;
+ QTest::newRow("Item 0 - 0, 19") << 0. << 19. << 0;
+ QTest::newRow("Item 0 - 239, 19") << 239. << 19. << 0;
+ QTest::newRow("Item 1 - 0, 20") << 0. << 20. << 1;
+ QTest::newRow("No Item - 240, 20") << 240. << 20. << -1;
+}
+
+void tst_QQuickListView::indexAt_itemAt()
+{
+ QFETCH(qreal, x);
+ QFETCH(qreal, y);
+ QFETCH(int, index);
+
+ QQuickView *canvas = createView();
+
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("listviewtest.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickItem *item = 0;
+ if (index >= 0) {
+ item = findItem<QQuickItem>(contentItem, "wrapper", index);
+ QVERIFY(item);
+ }
+ QCOMPARE(listview->indexAt(x,y), index);
+ QVERIFY(listview->itemAt(x,y) == item);
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::incrementalModel()
+{
+ QQuickView *canvas = createView();
+
+ IncrementalModel model;
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("displaylist.qml"));
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(listview->count(), 20);
+
+ listview->positionViewAtIndex(10, QQuickListView::Beginning);
+
+ QTRY_COMPARE(listview->count(), 25);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::onAdd()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(int, itemsToAdd);
+
+ const int delegateHeight = 10;
+ QaimModel model;
+
+ // these initial items should not trigger ListView.onAdd
+ for (int i=0; i<initialItemCount; i++)
+ model.addItem("dummy value", "dummy value");
+
+ QQuickView *canvas = createView();
+ canvas->setGeometry(0,0,200, delegateHeight * (initialItemCount + itemsToAdd));
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("delegateHeight", delegateHeight);
+ canvas->setSource(testFileUrl("attachedSignals.qml"));
+
+ QObject *object = canvas->rootObject();
+ object->setProperty("width", canvas->width());
+ object->setProperty("height", canvas->height());
+ qApp->processEvents();
+
+ QList<QPair<QString, QString> > items;
+ for (int i=0; i<itemsToAdd; i++)
+ items << qMakePair(QString("value %1").arg(i), QString::number(i));
+ model.addItems(items);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ QVariantList result = object->property("addedDelegates").toList();
+ QCOMPARE(result.count(), items.count());
+ for (int i=0; i<items.count(); i++)
+ QCOMPARE(result[i].toString(), items[i].first);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::onAdd_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<int>("itemsToAdd");
+
+ QTest::newRow("0, add 1") << 0 << 1;
+ QTest::newRow("0, add 2") << 0 << 2;
+ QTest::newRow("0, add 10") << 0 << 10;
+
+ QTest::newRow("1, add 1") << 1 << 1;
+ QTest::newRow("1, add 2") << 1 << 2;
+ QTest::newRow("1, add 10") << 1 << 10;
+
+ QTest::newRow("5, add 1") << 5 << 1;
+ QTest::newRow("5, add 2") << 5 << 2;
+ QTest::newRow("5, add 10") << 5 << 10;
+}
+
+void tst_QQuickListView::onRemove()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(int, indexToRemove);
+ QFETCH(int, removeCount);
+
+ const int delegateHeight = 10;
+ QaimModel model;
+ for (int i=0; i<initialItemCount; i++)
+ model.addItem(QString("value %1").arg(i), "dummy value");
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("delegateHeight", delegateHeight);
+ canvas->setSource(testFileUrl("attachedSignals.qml"));
+
+ QObject *object = canvas->rootObject();
+
+ model.removeItems(indexToRemove, removeCount);
+ QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+
+ QCOMPARE(object->property("removedDelegateCount"), QVariant(removeCount));
+
+ delete canvas;
+}
+
+void tst_QQuickListView::onRemove_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<int>("indexToRemove");
+ QTest::addColumn<int>("removeCount");
+
+ QTest::newRow("remove first") << 1 << 0 << 1;
+ QTest::newRow("two items, remove first") << 2 << 0 << 1;
+ QTest::newRow("two items, remove last") << 2 << 1 << 1;
+ QTest::newRow("two items, remove all") << 2 << 0 << 2;
+
+ QTest::newRow("four items, remove first") << 4 << 0 << 1;
+ QTest::newRow("four items, remove 0-2") << 4 << 0 << 2;
+ QTest::newRow("four items, remove 1-3") << 4 << 1 << 2;
+ QTest::newRow("four items, remove 2-4") << 4 << 2 << 2;
+ QTest::newRow("four items, remove last") << 4 << 3 << 1;
+ QTest::newRow("four items, remove all") << 4 << 0 << 4;
+
+ QTest::newRow("ten items, remove 1-8") << 10 << 0 << 8;
+ QTest::newRow("ten items, remove 2-7") << 10 << 2 << 5;
+ QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6;
+}
+
+void tst_QQuickListView::rightToLeft()
+{
+ QQuickView *canvas = createView();
+ canvas->setGeometry(0,0,640,320);
+ canvas->setSource(testFileUrl("rightToLeft.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QVERIFY(canvas->rootObject() != 0);
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "view");
+ QTRY_VERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickVisualItemModel *model = canvas->rootObject()->findChild<QQuickVisualItemModel*>("itemModel");
+ QTRY_VERIFY(model != 0);
+
+ QTRY_VERIFY(model->count() == 3);
+ QTRY_COMPARE(listview->currentIndex(), 0);
+
+ // initial position at first item, right edge aligned
+ QCOMPARE(listview->contentX(), -640.);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "item1");
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), -100.0);
+ QCOMPARE(item->height(), listview->height());
+
+ QQuickText *text = findItem<QQuickText>(contentItem, "text1");
+ QTRY_VERIFY(text);
+ QTRY_COMPARE(text->text(), QLatin1String("index: 0"));
+
+ listview->setCurrentIndex(2);
+
+ item = findItem<QQuickItem>(contentItem, "item3");
+ QTRY_VERIFY(item);
+ QTRY_COMPARE(item->x(), -540.0);
+
+ text = findItem<QQuickText>(contentItem, "text3");
+ QTRY_VERIFY(text);
+ QTRY_COMPARE(text->text(), QLatin1String("index: 2"));
+
+ QCOMPARE(listview->contentX(), -640.);
+
+ // Ensure resizing maintains position relative to right edge
+ qobject_cast<QQuickItem*>(canvas->rootObject())->setWidth(600);
+ QTRY_COMPARE(listview->contentX(), -600.);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::test_mirroring()
+{
+ QQuickView *canvasA = createView();
+ canvasA->setSource(testFileUrl("rightToLeft.qml"));
+ QQuickListView *listviewA = findItem<QQuickListView>(canvasA->rootObject(), "view");
+ QTRY_VERIFY(listviewA != 0);
+
+ QQuickView *canvasB = createView();
+ canvasB->setSource(testFileUrl("rightToLeft.qml"));
+ QQuickListView *listviewB = findItem<QQuickListView>(canvasB->rootObject(), "view");
+ QTRY_VERIFY(listviewA != 0);
+ qApp->processEvents();
+
+ QList<QString> objectNames;
+ objectNames << "item1" << "item2"; // << "item3"
+
+ listviewA->setProperty("layoutDirection", Qt::LeftToRight);
+ listviewB->setProperty("layoutDirection", Qt::RightToLeft);
+ QCOMPARE(listviewA->layoutDirection(), listviewA->effectiveLayoutDirection());
+
+ // LTR != RTL
+ foreach (const QString objectName, objectNames)
+ QVERIFY(findItem<QQuickItem>(listviewA, objectName)->x() != findItem<QQuickItem>(listviewB, objectName)->x());
+
+ listviewA->setProperty("layoutDirection", Qt::LeftToRight);
+ listviewB->setProperty("layoutDirection", Qt::LeftToRight);
+
+ // LTR == LTR
+ foreach (const QString objectName, objectNames)
+ QCOMPARE(findItem<QQuickItem>(listviewA, objectName)->x(), findItem<QQuickItem>(listviewB, objectName)->x());
+
+ QVERIFY(listviewB->layoutDirection() == listviewB->effectiveLayoutDirection());
+ QQuickItemPrivate::get(listviewB)->setLayoutMirror(true);
+ QVERIFY(listviewB->layoutDirection() != listviewB->effectiveLayoutDirection());
+
+ // LTR != LTR+mirror
+ foreach (const QString objectName, objectNames)
+ QVERIFY(findItem<QQuickItem>(listviewA, objectName)->x() != findItem<QQuickItem>(listviewB, objectName)->x());
+
+ listviewA->setProperty("layoutDirection", Qt::RightToLeft);
+
+ // RTL == LTR+mirror
+ foreach (const QString objectName, objectNames)
+ QCOMPARE(findItem<QQuickItem>(listviewA, objectName)->x(), findItem<QQuickItem>(listviewB, objectName)->x());
+
+ listviewB->setProperty("layoutDirection", Qt::RightToLeft);
+
+ // RTL != RTL+mirror
+ foreach (const QString objectName, objectNames)
+ QVERIFY(findItem<QQuickItem>(listviewA, objectName)->x() != findItem<QQuickItem>(listviewB, objectName)->x());
+
+ listviewA->setProperty("layoutDirection", Qt::LeftToRight);
+
+ // LTR == RTL+mirror
+ foreach (const QString objectName, objectNames)
+ QCOMPARE(findItem<QQuickItem>(listviewA, objectName)->x(), findItem<QQuickItem>(listviewB, objectName)->x());
+
+ delete canvasA;
+ delete canvasB;
+}
+
+void tst_QQuickListView::margins()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ for (int i = 0; i < 50; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("margins.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QCOMPARE(listview->contentY(), -30.);
+ QCOMPARE(listview->yOrigin(), 0.);
+
+ // check end bound
+ listview->positionViewAtEnd();
+ qreal pos = listview->contentY();
+ listview->setContentY(pos + 80);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ listview->returnToBounds();
+ QTRY_COMPARE(listview->contentY(), pos + 50);
+
+ // remove item before visible and check that top margin is maintained
+ // and yOrigin is updated
+ listview->setContentY(100);
+ model.removeItem(1);
+ QTRY_COMPARE(listview->count(), model.count());
+ listview->setContentY(-50);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ listview->returnToBounds();
+ QCOMPARE(listview->yOrigin(), 20.);
+ QTRY_COMPARE(listview->contentY(), -10.);
+
+ // reduce top margin
+ listview->setTopMargin(20);
+ QCOMPARE(listview->yOrigin(), 20.);
+ QTRY_COMPARE(listview->contentY(), 0.);
+
+ // check end bound
+ listview->positionViewAtEnd();
+ pos = listview->contentY();
+ listview->setContentY(pos + 80);
+ listview->returnToBounds();
+ QTRY_COMPARE(listview->contentY(), pos + 50);
+
+ // reduce bottom margin
+ pos = listview->contentY();
+ listview->setBottomMargin(40);
+ QCOMPARE(listview->yOrigin(), 20.);
+ QTRY_COMPARE(listview->contentY(), pos-10);
+
+ delete canvas;
+}
+
+// QTBUG-24028
+void tst_QQuickListView::marginsResize()
+{
+ QFETCH(QQuickListView::Orientation, orientation);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(qreal, start);
+ QFETCH(qreal, end);
+
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("margins2.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "listview");
+ QTRY_VERIFY(listview != 0);
+
+ listview->setOrientation(orientation);
+ listview->setLayoutDirection(layoutDirection);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ // view is resized after componentCompleted - top margin should still be visible
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(listview->contentY(), start);
+ else
+ QCOMPARE(listview->contentX(), start);
+
+ // move to last index and ensure bottom margin is visible.
+ listview->setCurrentIndex(19);
+ if (orientation == QQuickListView::Vertical)
+ QTRY_COMPARE(listview->contentY(), end);
+ else
+ QTRY_COMPARE(listview->contentX(), end);
+
+ // back to top - top margin should be visible.
+ listview->setCurrentIndex(0);
+ if (orientation == QQuickListView::Vertical)
+ QTRY_COMPARE(listview->contentY(), start);
+ else
+ QTRY_COMPARE(listview->contentX(), start);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::marginsResize_data()
+{
+ QTest::addColumn<QQuickListView::Orientation>("orientation");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<qreal>("start");
+ QTest::addColumn<qreal>("end");
+
+ QTest::newRow("vertical") << QQuickListView::Vertical << Qt::LeftToRight << -20.0 << 1020.0;
+ QTest::newRow("horizontal") << QQuickListView::Horizontal << Qt::LeftToRight << -20.0 << 1020.0;
+ QTest::newRow("horizontal, rtl") << QQuickListView::Horizontal << Qt::RightToLeft << -180.0 << -1220.0;
+}
+
+void tst_QQuickListView::snapToItem_data()
+{
+ QTest::addColumn<QQuickListView::Orientation>("orientation");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<int>("highlightRangeMode");
+ QTest::addColumn<QPoint>("flickStart");
+ QTest::addColumn<QPoint>("flickEnd");
+ QTest::addColumn<qreal>("snapAlignment");
+ QTest::addColumn<qreal>("endExtent");
+ QTest::addColumn<qreal>("startExtent");
+
+ QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
+
+ QTest::newRow("horizontal, left to right") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1200.0 << 0.0;
+
+ QTest::newRow("horizontal, right to left") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 << -240.0;
+
+ QTest::newRow("vertical, left to right, enforce range") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 200) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
+
+ QTest::newRow("horizontal, left to right, enforce range") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(200, 20) << QPoint(20, 20) << 60.0 << 1340.0 << -20.0;
+
+ QTest::newRow("horizontal, right to left, enforce range") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 20) << QPoint(200, 20) << -60.0 << -1200.0 - 240.0 - 140.0 << -220.0;
+}
+
+void tst_QQuickListView::snapToItem()
+{
+ QFETCH(QQuickListView::Orientation, orientation);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(int, highlightRangeMode);
+ QFETCH(QPoint, flickStart);
+ QFETCH(QPoint, flickEnd);
+ QFETCH(qreal, snapAlignment);
+ QFETCH(qreal, endExtent);
+ QFETCH(qreal, startExtent);
+
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("snapToItem.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ listview->setOrientation(orientation);
+ listview->setLayoutDirection(layoutDirection);
+ listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ // confirm that a flick hits an item boundary
+ flick(canvas, flickStart, flickEnd, 180);
+ QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(qreal(fmod(listview->contentY(),80.0)), snapAlignment);
+ else
+ QCOMPARE(qreal(fmod(listview->contentX(),80.0)), snapAlignment);
+
+ // flick to end
+ do {
+ flick(canvas, flickStart, flickEnd, 180);
+ QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
+ } while (orientation == QQuickListView::Vertical
+ ? !listview->isAtYEnd()
+ : layoutDirection == Qt::LeftToRight ? !listview->isAtXEnd() : !listview->isAtXBeginning());
+
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(listview->contentY(), endExtent);
+ else
+ QCOMPARE(listview->contentX(), endExtent);
+
+ // flick to start
+ do {
+ flick(canvas, flickEnd, flickStart, 180);
+ QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
+ } while (orientation == QQuickListView::Vertical
+ ? !listview->isAtYBeginning()
+ : layoutDirection == Qt::LeftToRight ? !listview->isAtXBeginning() : !listview->isAtXEnd());
+
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(listview->contentY(), startExtent);
+ else
+ QCOMPARE(listview->contentX(), startExtent);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::qListModelInterface_items()
+{
+ items<QmlListModel>(testFileUrl("listviewtest.qml"), false);
+}
+
+void tst_QQuickListView::qListModelInterface_package_items()
+{
+ items<QmlListModel>(testFileUrl("listviewtest-package.qml"), true);
+}
+
+void tst_QQuickListView::qAbstractItemModel_items()
+{
+ items<QaimModel>(testFileUrl("listviewtest.qml"), false);
+}
+
+void tst_QQuickListView::qListModelInterface_changed()
+{
+ changed<QmlListModel>(testFileUrl("listviewtest.qml"), false);
+}
+
+void tst_QQuickListView::qListModelInterface_package_changed()
+{
+ changed<QmlListModel>(testFileUrl("listviewtest-package.qml"), true);
+}
+
+void tst_QQuickListView::qAbstractItemModel_changed()
+{
+ changed<QaimModel>(testFileUrl("listviewtest.qml"), false);
+}
+
+void tst_QQuickListView::qListModelInterface_inserted()
+{
+ inserted<QmlListModel>(testFileUrl("listviewtest.qml"));
+}
+
+void tst_QQuickListView::qListModelInterface_package_inserted()
+{
+ inserted<QmlListModel>(testFileUrl("listviewtest-package.qml"));
+}
+
+void tst_QQuickListView::qListModelInterface_inserted_more()
+{
+ inserted_more<QmlListModel>();
+}
+
+void tst_QQuickListView::qListModelInterface_inserted_more_data()
+{
+ inserted_more_data();
+}
+
+void tst_QQuickListView::qAbstractItemModel_inserted()
+{
+ inserted<QaimModel>(testFileUrl("listviewtest.qml"));
+}
+
+void tst_QQuickListView::qAbstractItemModel_inserted_more()
+{
+ inserted_more<QaimModel>();
+}
+
+void tst_QQuickListView::qAbstractItemModel_inserted_more_data()
+{
+ inserted_more_data();
+}
+
+void tst_QQuickListView::qListModelInterface_removed()
+{
+ removed<QmlListModel>(testFileUrl("listviewtest.qml"), false);
+ removed<QmlListModel>(testFileUrl("listviewtest.qml"), true);
+}
+
+void tst_QQuickListView::qListModelInterface_removed_more()
+{
+ removed_more<QmlListModel>(testFileUrl("listviewtest.qml"));
+}
+
+void tst_QQuickListView::qListModelInterface_removed_more_data()
+{
+ removed_more_data();
+}
+
+void tst_QQuickListView::qListModelInterface_package_removed()
+{
+ removed<QmlListModel>(testFileUrl("listviewtest-package.qml"), false);
+ removed<QmlListModel>(testFileUrl("listviewtest-package.qml"), true);
+}
+
+void tst_QQuickListView::qAbstractItemModel_removed()
+{
+ removed<QaimModel>(testFileUrl("listviewtest.qml"), false);
+ removed<QaimModel>(testFileUrl("listviewtest.qml"), true);
+}
+
+void tst_QQuickListView::qAbstractItemModel_removed_more()
+{
+ removed_more<QaimModel>(testFileUrl("listviewtest.qml"));
+}
+
+void tst_QQuickListView::qAbstractItemModel_removed_more_data()
+{
+ removed_more_data();
+}
+
+void tst_QQuickListView::qListModelInterface_moved()
+{
+ moved<QmlListModel>(testFileUrl("listviewtest.qml"));
+}
+
+void tst_QQuickListView::qListModelInterface_moved_data()
+{
+ moved_data();
+}
+
+void tst_QQuickListView::qListModelInterface_package_moved()
+{
+ moved<QmlListModel>(testFileUrl("listviewtest-package.qml"));
+}
+
+void tst_QQuickListView::qListModelInterface_package_moved_data()
+{
+ moved_data();
+}
+
+void tst_QQuickListView::qAbstractItemModel_moved()
+{
+ moved<QaimModel>(testFileUrl("listviewtest.qml"));
+}
+
+void tst_QQuickListView::qAbstractItemModel_moved_data()
+{
+ moved_data();
+}
+
+void tst_QQuickListView::qListModelInterface_clear()
+{
+ clear<QmlListModel>(testFileUrl("listviewtest.qml"));
+}
+
+void tst_QQuickListView::qListModelInterface_package_clear()
+{
+ clear<QmlListModel>(testFileUrl("listviewtest-package.qml"));
+}
+
+void tst_QQuickListView::qAbstractItemModel_clear()
+{
+ clear<QaimModel>(testFileUrl("listviewtest.qml"));
+}
+
+void tst_QQuickListView::qListModelInterface_sections()
+{
+ sections<QmlListModel>(testFileUrl("listview-sections.qml"));
+}
+
+void tst_QQuickListView::qListModelInterface_package_sections()
+{
+ sections<QmlListModel>(testFileUrl("listview-sections-package.qml"));
+}
+
+void tst_QQuickListView::qAbstractItemModel_sections()
+{
+ sections<QaimModel>(testFileUrl("listview-sections.qml"));
+}
+
+void tst_QQuickListView::creationContext()
+{
+ QQuickView canvas;
+ canvas.setGeometry(0,0,240,320);
+ canvas.setSource(testFileUrl("creationContext.qml"));
+ qApp->processEvents();
+
+ QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
+ QVERIFY(rootItem);
+ QVERIFY(rootItem->property("count").toInt() > 0);
+
+ QQuickItem *item;
+ QVERIFY(item = rootItem->findChild<QQuickItem *>("listItem"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QQuickItem *>("header"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QQuickItem *>("footer"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+ QVERIFY(item = rootItem->findChild<QQuickItem *>("section"));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+}
+
+void tst_QQuickListView::QTBUG_21742()
+{
+ QQuickView canvas;
+ canvas.setGeometry(0,0,200,200);
+ canvas.setSource(testFileUrl("qtbug-21742.qml"));
+ qApp->processEvents();
+
+ QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
+ QVERIFY(rootItem);
+ QCOMPARE(rootItem->property("count").toInt(), 1);
+}
+
+void tst_QQuickListView::asynchronous()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+ QQmlIncubationController controller;
+ canvas->engine()->setIncubationController(&controller);
+
+ canvas->setSource(testFileUrl("asyncloader.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootObject);
+
+ QQuickListView *listview = 0;
+ while (!listview) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ listview = rootObject->findChild<QQuickListView*>("view");
+ }
+
+ // items will be created one at a time
+ for (int i = 0; i < 8; ++i) {
+ QVERIFY(findItem<QQuickItem>(listview, "wrapper", i) == 0);
+ QQuickItem *item = 0;
+ while (!item) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ item = findItem<QQuickItem>(listview, "wrapper", i);
+ }
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ // verify positioning
+ QQuickItem *contentItem = listview->contentItem();
+ for (int i = 0; i < 8; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QTRY_COMPARE(item->y(), i*50.0);
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickListView::snapOneItem_data()
+{
+ QTest::addColumn<QQuickListView::Orientation>("orientation");
+ QTest::addColumn<Qt::LayoutDirection>("layoutDirection");
+ QTest::addColumn<int>("highlightRangeMode");
+ QTest::addColumn<QPoint>("flickStart");
+ QTest::addColumn<QPoint>("flickEnd");
+ QTest::addColumn<qreal>("snapAlignment");
+ QTest::addColumn<qreal>("endExtent");
+ QTest::addColumn<qreal>("startExtent");
+
+ QTest::newRow("vertical, left to right") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 560.0 << 0.0;
+
+ QTest::newRow("horizontal, left to right") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::NoHighlightRange)
+ << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 560.0 << 0.0;
+
+ QTest::newRow("horizontal, right to left") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::NoHighlightRange)
+ << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -560.0 - 240.0 << -240.0;
+
+ QTest::newRow("vertical, left to right, enforce range") << QQuickListView::Vertical << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 200) << QPoint(20, 20) << 180.0 << 580.0 << -20.0;
+
+ QTest::newRow("horizontal, left to right, enforce range") << QQuickListView::Horizontal << Qt::LeftToRight << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(200, 20) << QPoint(20, 20) << 180.0 << 580.0 << -20.0;
+
+ QTest::newRow("horizontal, right to left, enforce range") << QQuickListView::Horizontal << Qt::RightToLeft << int(QQuickItemView::StrictlyEnforceRange)
+ << QPoint(20, 20) << QPoint(200, 20) << -420.0 << -580.0 - 240.0 << -220.0;
+}
+
+void tst_QQuickListView::snapOneItem()
+{
+ QFETCH(QQuickListView::Orientation, orientation);
+ QFETCH(Qt::LayoutDirection, layoutDirection);
+ QFETCH(int, highlightRangeMode);
+ QFETCH(QPoint, flickStart);
+ QFETCH(QPoint, flickEnd);
+ QFETCH(qreal, snapAlignment);
+ QFETCH(qreal, endExtent);
+ QFETCH(qreal, startExtent);
+
+#ifdef Q_OS_MAC
+ // This test seems to be unreliable - different test data fails on different runs
+ QSKIP("QTBUG-24338");
+#endif
+
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("snapOneItem.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+
+ listview->setOrientation(orientation);
+ listview->setLayoutDirection(layoutDirection);
+ listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode));
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged()));
+
+ // confirm that a flick hits the next item boundary
+ flick(canvas, flickStart, flickEnd, 180);
+ QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(listview->contentY(), snapAlignment);
+ else
+ QCOMPARE(listview->contentX(), snapAlignment);
+
+ if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
+ QCOMPARE(listview->currentIndex(), 1);
+ QCOMPARE(currentIndexSpy.count(), 1);
+ }
+
+ // flick to end
+ do {
+ flick(canvas, flickStart, flickEnd, 180);
+ QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
+ } while (orientation == QQuickListView::Vertical
+ ? !listview->isAtYEnd()
+ : layoutDirection == Qt::LeftToRight ? !listview->isAtXEnd() : !listview->isAtXBeginning());
+
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(listview->contentY(), endExtent);
+ else
+ QCOMPARE(listview->contentX(), endExtent);
+
+ if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
+ QCOMPARE(listview->currentIndex(), 3);
+ QCOMPARE(currentIndexSpy.count(), 3);
+ }
+
+ // flick to start
+ do {
+ flick(canvas, flickEnd, flickStart, 180);
+ QTRY_VERIFY(listview->isMoving() == false); // wait until it stops
+ } while (orientation == QQuickListView::Vertical
+ ? !listview->isAtYBeginning()
+ : layoutDirection == Qt::LeftToRight ? !listview->isAtXBeginning() : !listview->isAtXEnd());
+
+ if (orientation == QQuickListView::Vertical)
+ QCOMPARE(listview->contentY(), startExtent);
+ else
+ QCOMPARE(listview->contentX(), startExtent);
+
+ if (QQuickItemView::HighlightRangeMode(highlightRangeMode) == QQuickItemView::StrictlyEnforceRange) {
+ QCOMPARE(listview->currentIndex(), 0);
+ QCOMPARE(currentIndexSpy.count(), 6);
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickListView::unrequestedVisibility()
+{
+ QmlListModel model;
+ for (int i = 0; i < 30; i++)
+ model.addItem("Item" + QString::number(i), QString::number(i));
+
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testWrap", QVariant(false));
+
+ canvas->setSource(testFileUrl("unrequestedItems.qml"));
+ canvas->show();
+ qApp->processEvents();
+
+ QQuickListView *leftview = findItem<QQuickListView>(canvas->rootObject(), "leftList");
+ QTRY_VERIFY(leftview != 0);
+
+ QQuickListView *rightview = findItem<QQuickListView>(canvas->rootObject(), "rightList");
+ QTRY_VERIFY(rightview != 0);
+
+ QQuickItem *leftContent = leftview->contentItem();
+ QTRY_VERIFY(leftContent != 0);
+
+ QQuickItem *rightContent = rightview->contentItem();
+ QTRY_VERIFY(rightContent != 0);
+
+ rightview->setCurrentIndex(20);
+
+ QTRY_COMPARE(leftview->contentY(), 0.0);
+ QTRY_COMPARE(rightview->contentY(), 100.0);
+
+ QQuickItem *item;
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19));
+ QCOMPARE(item->isVisible(), true);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 16));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 17));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 4));
+ QCOMPARE(item->isVisible(), true);
+
+ rightview->setCurrentIndex(0);
+
+ QTRY_COMPARE(leftview->contentY(), 0.0);
+ QTRY_COMPARE(rightview->contentY(), 0.0);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ QTRY_COMPARE(item->isVisible(), true);
+
+ QVERIFY(!findItem<QQuickItem>(leftContent, "wrapper", 19));
+ QVERIFY(!findItem<QQuickItem>(rightContent, "wrapper", 19));
+
+ leftview->setCurrentIndex(20);
+
+ QTRY_COMPARE(leftview->contentY(), 100.0);
+ QTRY_COMPARE(rightview->contentY(), 0.0);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QTRY_COMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), true);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19));
+ QCOMPARE(item->isVisible(), false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ QCOMPARE(item->isVisible(), false);
+
+ model.moveItems(19, 1, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QTRY_VERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 1));
+ QCOMPARE(item->isVisible(), true);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 19));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 19));
+ QCOMPARE(item->isVisible(), false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ QCOMPARE(item->isVisible(), false);
+
+ model.moveItems(3, 4, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ QCOMPARE(item->isVisible(), false);
+
+ model.moveItems(4, 3, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ QCOMPARE(item->isVisible(), false);
+
+ model.moveItems(16, 17, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ QCOMPARE(item->isVisible(), false);
+
+ model.moveItems(17, 16, 1);
+ QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false);
+
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 4));
+ QCOMPARE(item->isVisible(), false);
+ QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 5));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 16));
+ QCOMPARE(item->isVisible(), true);
+ QVERIFY(item = findItem<QQuickItem>(rightContent, "wrapper", 17));
+ QCOMPARE(item->isVisible(), false);
+
+ delete canvas;
+}
+
+void tst_QQuickListView::populateTransitions()
+{
+ QFETCH(bool, staticallyPopulate);
+ QFETCH(bool, dynamicallyPopulate);
+ QFETCH(bool, usePopulateTransition);
+
+ QPointF transitionFrom(-50, -50);
+ QPointF transitionVia(100, 100);
+ QaimModel model_transitionFrom;
+ QaimModel model_transitionVia;
+
+ QaimModel model;
+ if (staticallyPopulate) {
+ for (int i = 0; i < 30; i++)
+ model.addItem("item" + QString::number(i), "");
+ }
+
+ QQuickView *canvas = createView();
+ canvas->rootContext()->setContextProperty("testModel", &model);
+ canvas->rootContext()->setContextProperty("testObject", new TestObject(canvas->rootContext()));
+ canvas->rootContext()->setContextProperty("usePopulateTransition", usePopulateTransition);
+ canvas->rootContext()->setContextProperty("dynamicallyPopulate", dynamicallyPopulate);
+ canvas->rootContext()->setContextProperty("transitionFrom", transitionFrom);
+ canvas->rootContext()->setContextProperty("transitionVia", transitionVia);
+ canvas->rootContext()->setContextProperty("model_transitionFrom", &model_transitionFrom);
+ canvas->rootContext()->setContextProperty("model_transitionVia", &model_transitionVia);
+ canvas->setSource(testFileUrl("populateTransitions.qml"));
+ canvas->show();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QVERIFY(listview);
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem);
+
+ if (staticallyPopulate || dynamicallyPopulate) {
+ // check the populate transition is run
+ if (usePopulateTransition) {
+ QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), 17);
+ } else {
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), 0);
+ }
+ QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0);
+ } else {
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ }
+
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ if (usePopulateTransition)
+ QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt());
+ for (int i=0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->x(), 0.0);
+ QTRY_COMPARE(item->y(), i*20.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ // add an item and check this is done with add trantion, not populate
+ model.insertItem(0, "another item", "");
+ QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 1);
+ QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(),
+ (usePopulateTransition && (staticallyPopulate || dynamicallyPopulate)) ? 17 : 0);
+
+ // clear the model
+ canvas->rootContext()->setContextProperty("testModel", QVariant());
+ QTRY_COMPARE(listview->count(), 0);
+ QTRY_COMPARE(findItems<QQuickItem>(contentItem, "wrapper").count(), 0);
+ listview->setProperty("countPopulateTransitions", 0);
+ listview->setProperty("countAddTransitions", 0);
+
+ // set to a valid model and check populate transition is run a second time
+ model.clear();
+ for (int i = 0; i < 30; i++)
+ model.addItem("item" + QString::number(i), "");
+ canvas->rootContext()->setContextProperty("testModel", &model);
+ QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 17 : 0);
+ QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0);
+
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ if (usePopulateTransition)
+ QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt());
+ for (int i=0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->x(), 0.0);
+ QTRY_COMPARE(item->y(), i*20.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ // reset model and check populate transition is run again
+ listview->setProperty("countPopulateTransitions", 0);
+ listview->setProperty("countAddTransitions", 0);
+ model.reset();
+ QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 17 : 0);
+ QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 0);
+
+ itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ if (usePopulateTransition)
+ QCOMPARE(itemCount, listview->property("countPopulateTransitions").toInt());
+ for (int i=0; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->x(), 0.0);
+ QTRY_COMPARE(item->y(), i*20.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickListView::populateTransitions_data()
+{
+ QTest::addColumn<bool>("staticallyPopulate");
+ QTest::addColumn<bool>("dynamicallyPopulate");
+ QTest::addColumn<bool>("usePopulateTransition");
+
+ QTest::newRow("static") << true << false << true;
+ QTest::newRow("static, no populate") << true << false << false;
+
+ QTest::newRow("dynamic") << false << true << true;
+ QTest::newRow("dynamic, no populate") << false << true << false;
+
+ QTest::newRow("empty to start with") << false << false << true;
+ QTest::newRow("empty to start with, no populate") << false << false << false;
+}
+
+void tst_QQuickListView::addTransitions()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(bool, shouldAnimateTargets);
+ QFETCH(qreal, contentY);
+ QFETCH(int, insertionIndex);
+ QFETCH(int, insertionCount);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ // added items should start here
+ QPointF targetItems_transitionFrom(-50, -50);
+
+ // displaced items should pass through this point
+ QPointF displacedItems_transitionVia(100, 100);
+
+ QaimModel model;
+ for (int i = 0; i < initialItemCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_targetItems_transitionFrom;
+ QaimModel model_displacedItems_transitionVia;
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("model_targetItems_transitionFrom", &model_targetItems_transitionFrom);
+ ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
+ ctxt->setContextProperty("targetItems_transitionFrom", targetItems_transitionFrom);
+ ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ ctxt->setContextProperty("testObject", testObject);
+ canvas->setSource(testFileUrl("addTransitions.qml"));
+ canvas->show();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ if (contentY != 0) {
+ listview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ }
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+
+ // only target items that will become visible should be animated
+ QList<QPair<QString, QString> > newData;
+ QList<QPair<QString, QString> > expectedTargetData;
+ QList<int> targetIndexes;
+ if (shouldAnimateTargets) {
+ for (int i=insertionIndex; i<insertionIndex+insertionCount; i++) {
+ newData << qMakePair(QString("New item %1").arg(i), QString(""));
+
+ if (i >= contentY / 20 && i < (contentY + listview->height()) / 20) { // only grab visible items
+ expectedTargetData << newData.last();
+ targetIndexes << i;
+ }
+ }
+ QVERIFY(expectedTargetData.count() > 0);
+ }
+
+ // start animation
+ if (!newData.isEmpty()) {
+ model.insertItems(insertionIndex, newData);
+ QTRY_COMPARE(model.count(), listview->count());
+ }
+
+ QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
+
+ if (shouldAnimateTargets) {
+ QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(),
+ expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
+
+ // check the target and displaced items were animated
+ model_targetItems_transitionFrom.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
+ model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
+
+ // check attached properties
+ matchItemsAndIndexes(listview->property("targetTrans_items").toMap(), model, targetIndexes);
+ matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems);
+ if (expectedDisplacedIndexes.isValid()) {
+ // adjust expectedDisplacedIndexes to their final values after the move
+ QList<int> displacedIndexes = adjustIndexesForAddDisplaced(expectedDisplacedIndexes.indexes, insertionIndex, insertionCount);
+ matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes);
+ matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems);
+ }
+
+ } else {
+ QTRY_COMPARE(model_targetItems_transitionFrom.count(), 0);
+ QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0);
+ }
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ int itemCount = items.count();
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // verify all items moved to the correct final positions
+ for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->y(), i*20.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::addTransitions_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<bool>("shouldAnimateTargets");
+ QTest::addColumn<int>("insertionIndex");
+ QTest::addColumn<int>("insertionCount");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ // if inserting before visible index, items should not appear or animate in, even if there are > 1 new items
+ QTest::newRow("insert 1, just before start")
+ << 30 << 20.0 << false
+ << 0 << 1 << ListRange();
+ QTest::newRow("insert 1, way before start")
+ << 30 << 20.0 << false
+ << 0 << 1 << ListRange();
+ QTest::newRow("insert multiple, just before start")
+ << 30 << 100.0 << false
+ << 0 << 3 << ListRange();
+ QTest::newRow("insert multiple, way before start")
+ << 30 << 100.0 << false
+ << 0 << 3 << ListRange();
+
+ QTest::newRow("insert 1 at start")
+ << 30 << 0.0 << true
+ << 0 << 1 << ListRange(0, 15);
+ QTest::newRow("insert multiple at start")
+ << 30 << 0.0 << true
+ << 0 << 3 << ListRange(0, 15);
+ QTest::newRow("insert 1 at start, content y not 0")
+ << 30 << 40.0 << true // first visible is index 2, so translate the displaced indexes by 2
+ << 2 << 1 << ListRange(0 + 2, 15 + 2);
+ QTest::newRow("insert multiple at start, content y not 0")
+ << 30 << 40.0 << true // first visible is index 2
+ << 2 << 3 << ListRange(0 + 2, 15 + 2);
+
+ QTest::newRow("insert 1 at start, to empty list")
+ << 0 << 0.0 << true
+ << 0 << 1 << ListRange();
+ QTest::newRow("insert multiple at start, to empty list")
+ << 0 << 0.0 << true
+ << 0 << 3 << ListRange();
+
+ QTest::newRow("insert 1 at middle")
+ << 30 << 0.0 << true
+ << 5 << 1 << ListRange(5, 15);
+ QTest::newRow("insert multiple at middle")
+ << 30 << 0.0 << true
+ << 5 << 3 << ListRange(5, 15);
+
+ QTest::newRow("insert 1 at bottom")
+ << 30 << 0.0 << true
+ << 15 << 1 << ListRange(15, 15);
+ QTest::newRow("insert multiple at bottom")
+ << 30 << 0.0 << true
+ << 15 << 3 << ListRange(15, 15);
+ QTest::newRow("insert 1 at bottom, content y not 0")
+ << 30 << 20.0 * 3 << true
+ << 15 + 3 << 1 << ListRange(15 + 3, 15 + 3);
+ QTest::newRow("insert multiple at bottom, content y not 0")
+ << 30 << 20.0 * 3 << true
+ << 15 + 3 << 3 << ListRange(15 + 3, 15 + 3);
+
+ // items added after the last visible will not be animated in, since they
+ // do not appear in the final view
+ QTest::newRow("insert 1 after end")
+ << 30 << 0.0 << false
+ << 17 << 1 << ListRange();
+ QTest::newRow("insert multiple after end")
+ << 30 << 0.0 << false
+ << 17 << 3 << ListRange();
+}
+
+void tst_QQuickListView::moveTransitions()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(qreal, contentY);
+ QFETCH(qreal, itemsOffsetAfterMove);
+ QFETCH(int, moveFrom);
+ QFETCH(int, moveTo);
+ QFETCH(int, moveCount);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ // target and displaced items should pass through these points
+ QPointF targetItems_transitionVia(-50, 50);
+ QPointF displacedItems_transitionVia(100, 100);
+
+ QaimModel model;
+ for (int i = 0; i < initialItemCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_targetItems_transitionVia;
+ QaimModel model_displacedItems_transitionVia;
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("model_targetItems_transitionVia", &model_targetItems_transitionVia);
+ ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
+ ctxt->setContextProperty("targetItems_transitionVia", targetItems_transitionVia);
+ ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ ctxt->setContextProperty("testObject", testObject);
+ canvas->setSource(testFileUrl("moveTransitions.qml"));
+ canvas->show();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+ QQuickText *name;
+
+ if (contentY != 0) {
+ listview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ }
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+
+ // Items moving to *or* from visible positions should be animated.
+ // Otherwise, they should not be animated.
+ QList<QPair<QString, QString> > expectedTargetData;
+ QList<int> targetIndexes;
+ for (int i=moveFrom; i<moveFrom+moveCount; i++) {
+ int toIndex = moveTo + (i - moveFrom);
+ if (i <= (contentY + listview->height()) / 20
+ || toIndex < (contentY + listview->height()) / 20) {
+ expectedTargetData << qMakePair(model.name(i), model.number(i));
+ targetIndexes << i;
+ }
+ }
+ // ViewTransition.index provides the indices that items are moving to, not from
+ targetIndexes = adjustIndexesForMove(targetIndexes, moveFrom, moveTo, moveCount);
+
+ // start animation
+ model.moveItems(moveFrom, moveTo, moveCount);
+
+ QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(),
+ expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
+
+ QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
+
+ // check the target and displaced items were animated
+ model_targetItems_transitionVia.matchAgainst(expectedTargetData, "wasn't animated from target 'from' pos", "shouldn't have been animated from target 'from' pos");
+ model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
+
+ // check attached properties
+ matchItemsAndIndexes(listview->property("targetTrans_items").toMap(), model, targetIndexes);
+ matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems);
+ if (expectedDisplacedIndexes.isValid()) {
+ // adjust expectedDisplacedIndexes to their final values after the move
+ QList<int> displacedIndexes = adjustIndexesForMove(expectedDisplacedIndexes.indexes, moveFrom, moveTo, moveCount);
+ matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes);
+ matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems);
+ }
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // verify all items moved to the correct final positions
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->y(), i*20.0 + itemsOffsetAfterMove);
+ name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::moveTransitions_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<qreal>("itemsOffsetAfterMove");
+ QTest::addColumn<int>("moveFrom");
+ QTest::addColumn<int>("moveTo");
+ QTest::addColumn<int>("moveCount");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ // when removing from above the visible, all items shift down depending on how many
+ // items have been removed from above the visible
+ QTest::newRow("move from above view, outside visible items, move 1") << 30 << 4*20.0 << 20.0
+ << 1 << 10 << 1 << ListRange(11, 15+4);
+ QTest::newRow("move from above view, outside visible items, move 1 (first item)") << 30 << 4*20.0 << 20.0
+ << 0 << 10 << 1 << ListRange(11, 15+4);
+ QTest::newRow("move from above view, outside visible items, move multiple") << 30 << 4*20.0 << 2*20.0
+ << 1 << 10 << 2 << ListRange(12, 15+4);
+ QTest::newRow("move from above view, outside visible items, move multiple (first item)") << 30 << 4*20.0 << 3*20.0
+ << 0 << 10 << 3 << ListRange(13, 15+4);
+ QTest::newRow("move from above view, mix of visible/non-visible") << 30 << 4*20.0 << 3*20.0
+ << 1 << 10 << 5 << ListRange(6, 14) + ListRange(15, 15+4);
+ QTest::newRow("move from above view, mix of visible/non-visible (move first)") << 30 << 4*20.0 << 4*20.0
+ << 0 << 10 << 5 << ListRange(5, 14) + ListRange(15, 15+4);
+
+ QTest::newRow("move within view, move 1 down") << 30 << 0.0 << 0.0
+ << 1 << 10 << 1 << ListRange(2, 10);
+ QTest::newRow("move within view, move 1 down, move first item") << 30 << 0.0 << 0.0
+ << 0 << 10 << 1 << ListRange(1, 10);
+ QTest::newRow("move within view, move 1 down, move first item, contentY not 0") << 30 << 4*20.0 << 0.0
+ << 0+4 << 10+4 << 1 << ListRange(1+4, 10+4);
+ QTest::newRow("move within view, move 1 down, to last item") << 30 << 0.0 << 0.0
+ << 10 << 15 << 1 << ListRange(11, 15);
+ QTest::newRow("move within view, move first->last") << 30 << 0.0 << 0.0
+ << 0 << 15 << 1 << ListRange(1, 15);
+
+ QTest::newRow("move within view, move multiple down") << 30 << 0.0 << 0.0
+ << 1 << 10 << 3 << ListRange(4, 12);
+ QTest::newRow("move within view, move multiple down, move first item") << 30 << 0.0 << 0.0
+ << 0 << 10 << 3 << ListRange(3, 12);
+ QTest::newRow("move within view, move multiple down, move first item, contentY not 0") << 30 << 4*20.0 << 0.0
+ << 0+4 << 10+4 << 3 << ListRange(3+4, 12+4);
+ QTest::newRow("move within view, move multiple down, displace last item") << 30 << 0.0 << 0.0
+ << 5 << 13 << 3 << ListRange(8, 15);
+ QTest::newRow("move within view, move multiple down, move first->last") << 30 << 0.0 << 0.0
+ << 0 << 13 << 3 << ListRange(3, 15);
+
+ QTest::newRow("move within view, move 1 up") << 30 << 0.0 << 0.0
+ << 10 << 1 << 1 << ListRange(1, 9);
+ QTest::newRow("move within view, move 1 up, move to first index") << 30 << 0.0 << 0.0
+ << 10 << 0 << 1 << ListRange(0, 9);
+ QTest::newRow("move within view, move 1 up, move to first index, contentY not 0") << 30 << 4*20.0 << 0.0
+ << 10+4 << 0+4 << 1 << ListRange(0+4, 9+4);
+ QTest::newRow("move within view, move 1 up, move to first index, contentY not on item border") << 30 << 4*20.0 - 10 << 0.0
+ << 10+4 << 0+4 << 1 << ListRange(0+4, 9+4);
+ QTest::newRow("move within view, move 1 up, move last item") << 30 << 0.0 << 0.0
+ << 15 << 10 << 1 << ListRange(10, 14);
+ QTest::newRow("move within view, move 1 up, move last->first") << 30 << 0.0 << 0.0
+ << 15 << 0 << 1 << ListRange(0, 14);
+
+ QTest::newRow("move within view, move multiple up") << 30 << 0.0 << 0.0
+ << 10 << 1 << 3 << ListRange(1, 9);
+ QTest::newRow("move within view, move multiple up, move to first index") << 30 << 0.0 << 0.0
+ << 10 << 0 << 3 << ListRange(0, 9);
+ QTest::newRow("move within view, move multiple up, move to first index, contentY not 0") << 30 << 4*20.0 << 0.0
+ << 10+4 << 0+4 << 3 << ListRange(0+4, 9+4);
+ QTest::newRow("move within view, move multiple up, move last item") << 30 << 0.0 << 0.0
+ << 13 << 5 << 3 << ListRange(5, 12);
+ QTest::newRow("move within view, move multiple up, move last->first") << 30 << 0.0 << 0.0
+ << 13 << 0 << 3 << ListRange(0, 12);
+
+ QTest::newRow("move from below view, move 1 up, move to top") << 30 << 0.0 << 0.0
+ << 20 << 0 << 1 << ListRange(0, 15);
+ QTest::newRow("move from below view, move 1 up, move to top, contentY not 0") << 30 << 4*20.0 << 0.0
+ << 25 << 4 << 1 << ListRange(0+4, 15+4);
+ QTest::newRow("move from below view, move multiple up, move to top") << 30 << 0.0 << 0.0
+ << 20 << 0 << 3 << ListRange(0, 15);
+ QTest::newRow("move from below view, move multiple up, move to top, contentY not 0") << 30 << 4*20.0 << 0.0
+ << 25 << 4 << 3 << ListRange(0+4, 15+4);
+
+ QTest::newRow("move from below view, move 1 up, move to bottom") << 30 << 0.0 << 0.0
+ << 20 << 15 << 1 << ListRange(15, 15);
+ QTest::newRow("move from below view, move 1 up, move to bottom, contentY not 0") << 30 << 4*20.0 << 0.0
+ << 25 << 15+4 << 1 << ListRange(15+4, 15+4);
+ QTest::newRow("move from below view, move multiple up, move to to bottom") << 30 << 0.0 << 0.0
+ << 20 << 15 << 3 << ListRange(15, 15);
+ QTest::newRow("move from below view, move multiple up, move to bottom, contentY not 0") << 30 << 4*20.0 << 0.0
+ << 25 << 15+4 << 3 << ListRange(15+4, 15+4);
+}
+
+void tst_QQuickListView::removeTransitions()
+{
+ QFETCH(int, initialItemCount);
+ QFETCH(bool, shouldAnimateTargets);
+ QFETCH(qreal, contentY);
+ QFETCH(int, removalIndex);
+ QFETCH(int, removalCount);
+ QFETCH(ListRange, expectedDisplacedIndexes);
+
+ // added items should end here
+ QPointF targetItems_transitionTo(-50, -50);
+
+ // displaced items should pass through this points
+ QPointF displacedItems_transitionVia(100, 100);
+
+ QaimModel model;
+ for (int i = 0; i < initialItemCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+ QaimModel model_targetItems_transitionTo;
+ QaimModel model_displacedItems_transitionVia;
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("model_targetItems_transitionTo", &model_targetItems_transitionTo);
+ ctxt->setContextProperty("model_displacedItems_transitionVia", &model_displacedItems_transitionVia);
+ ctxt->setContextProperty("targetItems_transitionTo", targetItems_transitionTo);
+ ctxt->setContextProperty("displacedItems_transitionVia", displacedItems_transitionVia);
+ ctxt->setContextProperty("testObject", testObject);
+ canvas->setSource(testFileUrl("removeTransitions.qml"));
+ canvas->show();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ if (contentY != 0) {
+ listview->setContentY(contentY);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ }
+
+ QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model);
+
+ // only target items that are visible should be animated
+ QList<QPair<QString, QString> > expectedTargetData;
+ QList<int> targetIndexes;
+ if (shouldAnimateTargets) {
+ for (int i=removalIndex; i<removalIndex+removalCount; i++) {
+ if (i >= contentY / 20 && i < (contentY + listview->height()) / 20) {
+ expectedTargetData << qMakePair(model.name(i), model.number(i));
+ targetIndexes << i;
+ }
+ }
+ QVERIFY(expectedTargetData.count() > 0);
+ }
+
+ // calculate targetItems and expectedTargets before model changes
+ QList<QQuickItem *> targetItems = findItems<QQuickItem>(contentItem, "wrapper", targetIndexes);
+ QVariantMap expectedTargets;
+ for (int i=0; i<targetIndexes.count(); i++)
+ expectedTargets[model.name(targetIndexes[i])] = targetIndexes[i];
+
+ // start animation
+ model.removeItems(removalIndex, removalCount);
+ QTRY_COMPARE(model.count(), listview->count());
+
+ if (shouldAnimateTargets) {
+ QTRY_COMPARE(listview->property("targetTransitionsDone").toInt(), expectedTargetData.count());
+ QTRY_COMPARE(listview->property("displaceTransitionsDone").toInt(),
+ expectedDisplacedIndexes.isValid() ? expectedDisplacedIndexes.count() : 0);
+
+ // check the target and displaced items were animated
+ model_targetItems_transitionTo.matchAgainst(expectedTargetData, "wasn't animated to target 'to' pos", "shouldn't have been animated to target 'to' pos");
+ model_displacedItems_transitionVia.matchAgainst(expectedDisplacedValues, "wasn't animated with displaced anim", "shouldn't have been animated with displaced anim");
+
+ // check attached properties
+ QCOMPARE(listview->property("targetTrans_items").toMap(), expectedTargets);
+ matchIndexLists(listview->property("targetTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(listview->property("targetTrans_targetItems").toList(), targetItems);
+ if (expectedDisplacedIndexes.isValid()) {
+ // adjust expectedDisplacedIndexes to their final values after the move
+ QList<int> displacedIndexes = adjustIndexesForRemoveDisplaced(expectedDisplacedIndexes.indexes, removalIndex, removalCount);
+ matchItemsAndIndexes(listview->property("displacedTrans_items").toMap(), model, displacedIndexes);
+ matchIndexLists(listview->property("displacedTrans_targetIndexes").toList(), targetIndexes);
+ matchItemLists(listview->property("displacedTrans_targetItems").toList(), targetItems);
+ }
+ } else {
+ QTRY_COMPARE(model_targetItems_transitionTo.count(), 0);
+ QTRY_COMPARE(model_displacedItems_transitionVia.count(), 0);
+ }
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ int itemCount = items.count();
+
+ for (int i=0; i<items.count(); i++) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ int index = e.evaluate().toInt();
+ if (firstVisibleIndex < 0 && items[i]->y() >= contentY)
+ firstVisibleIndex = index;
+ if (index < 0)
+ itemCount--; // exclude deleted items
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // verify all items moved to the correct final positions
+ for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QCOMPARE(item->x(), 0.0);
+ QCOMPARE(item->y(), contentY + (i-firstVisibleIndex) * 20.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::removeTransitions_data()
+{
+ QTest::addColumn<int>("initialItemCount");
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<bool>("shouldAnimateTargets");
+ QTest::addColumn<int>("removalIndex");
+ QTest::addColumn<int>("removalCount");
+ QTest::addColumn<ListRange>("expectedDisplacedIndexes");
+
+ // All items that are visible following the remove operation should be animated.
+ // Remove targets that are outside of the view should not be animated.
+
+ QTest::newRow("remove 1 before start")
+ << 30 << 20.0 * 3 << false
+ << 2 << 1 << ListRange();
+ QTest::newRow("remove multiple, all before start")
+ << 30 << 20.0 * 3 << false
+ << 0 << 3 << ListRange();
+ QTest::newRow("remove mix of before and after start")
+ << 30 << 20.0 * 3 << true
+ << 2 << 3 << ListRange(5, 20); // 5-20 are visible after the remove
+
+ QTest::newRow("remove 1 from start")
+ << 30 << 0.0 << true
+ << 0 << 1 << ListRange(1, 16); // 1-16 are visible after the remove
+ QTest::newRow("remove multiple from start")
+ << 30 << 0.0 << true
+ << 0 << 3 << ListRange(3, 18); // 3-18 are visible after the remove
+ QTest::newRow("remove 1 from start, content y not 0")
+ << 30 << 20.0 * 2 << true // first visible is index 2, so translate the displaced indexes by 2
+ << 2 << 1 << ListRange(1 + 2, 16 + 2);
+ QTest::newRow("remove multiple from start, content y not 0")
+ << 30 << 20.0 * 2 << true // first visible is index 2
+ << 2 << 3 << ListRange(3 + 2, 18 + 2);
+
+ QTest::newRow("remove 1 from middle")
+ << 30 << 0.0 << true
+ << 5 << 1 << ListRange(6, 16);
+ QTest::newRow("remove multiple from middle")
+ << 30 << 0.0 << true
+ << 5 << 3 << ListRange(8, 18);
+
+
+ QTest::newRow("remove 1 from bottom")
+ << 30 << 0.0 << true
+ << 15 << 1 << ListRange(16, 16);
+
+ // remove 15, 16, 17
+ // 15 will animate as the target item, 16 & 17 won't be animated since they are outside
+ // the view, and 18 will be animated as the displaced item to replace the last item
+ QTest::newRow("remove multiple from bottom")
+ << 30 << 0.0 << true
+ << 15 << 3 << ListRange(18, 18);
+
+ QTest::newRow("remove 1 from bottom, content y not 0")
+ << 30 << 20.0 * 2 << true
+ << 15 + 2 << 1 << ListRange(16 + 2, 16 + 2);
+ QTest::newRow("remove multiple from bottom, content y not 0")
+ << 30 << 20.0 * 2 << true
+ << 15 + 2 << 3 << ListRange(18 + 2, 18 + 2);
+
+
+ QTest::newRow("remove 1 after end")
+ << 30 << 0.0 << false
+ << 17 << 1 << ListRange();
+ QTest::newRow("remove multiple after end")
+ << 30 << 0.0 << false
+ << 17 << 3 << ListRange();
+}
+
+void tst_QQuickListView::multipleTransitions()
+{
+ // Tests that if you interrupt a transition in progress with another action that
+ // cancels the previous transition, the resulting items are still placed correctly.
+
+ QFETCH(int, initialCount);
+ QFETCH(qreal, contentY);
+ QFETCH(QList<ListChange>, changes);
+
+ // add transitions on the left, moves on the right
+ QPointF addTargets_transitionFrom(-50, -50);
+ QPointF addDisplaced_transitionFrom(-50, 50);
+ QPointF moveTargets_transitionFrom(50, -50);
+ QPointF moveDisplaced_transitionFrom(50, 50);
+
+ QmlListModel model;
+ for (int i = 0; i < initialCount; i++)
+ model.addItem("Original item" + QString::number(i), "");
+
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testModel", &model);
+ ctxt->setContextProperty("testObject", testObject);
+ ctxt->setContextProperty("addTargets_transitionFrom", addTargets_transitionFrom);
+ ctxt->setContextProperty("addDisplaced_transitionFrom", addDisplaced_transitionFrom);
+ ctxt->setContextProperty("moveTargets_transitionFrom", moveTargets_transitionFrom);
+ ctxt->setContextProperty("moveDisplaced_transitionFrom", moveDisplaced_transitionFrom);
+ canvas->setSource(testFileUrl("multipleTransitions.qml"));
+ canvas->show();
+
+ QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
+ QTRY_VERIFY(listview != 0);
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+
+ int timeBetweenActions = canvas->rootObject()->property("timeBetweenActions").toInt();
+
+ QList<QPair<QString, QString> > targetItems;
+ for (int i=0; i<changes.count(); i++) {
+ switch (changes[i].type) {
+ case ListChange::Inserted:
+ {
+ for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
+ targetItems << qMakePair(QString("new item %1").arg(j), QString::number(j));
+ model.insertItems(changes[i].index, targetItems);
+ QTRY_COMPARE(model.count(), listview->count());
+ QTRY_VERIFY(listview->property("runningAddTargets").toBool());
+ QTRY_VERIFY(listview->property("runningAddDisplaced").toBool());
+ if (i == changes.count() - 1) {
+ QTRY_VERIFY(!listview->property("runningAddTargets").toBool());
+ QTRY_VERIFY(!listview->property("runningAddDisplaced").toBool());
+ } else {
+ QTest::qWait(timeBetweenActions);
+ }
+ break;
+ }
+ case ListChange::Removed:
+ for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
+ targetItems << qMakePair(model.name(i), model.number(i));
+ model.removeItems(changes[i].index, changes[i].count);
+ QTRY_COMPARE(model.count(), listview->count());
+ QTRY_VERIFY(listview->property("runningRemoveTargets").toBool());
+ QTRY_VERIFY(listview->property("runningRemoveDisplaced").toBool());
+ if (i == changes.count() - 1) {
+ QTRY_VERIFY(!listview->property("runningRemoveTargets").toBool());
+ QTRY_VERIFY(!listview->property("runningRemoveDisplaced").toBool());
+ } else {
+ QTest::qWait(timeBetweenActions);
+ }
+ break;
+ case ListChange::Moved:
+ for (int j=changes[i].index; j<changes[i].index + changes[i].count; ++j)
+ targetItems << qMakePair(model.name(i), model.number(i));
+ model.moveItems(changes[i].index, changes[i].to, changes[i].count);
+ QTRY_VERIFY(listview->property("runningMoveTargets").toBool());
+ QTRY_VERIFY(listview->property("runningMoveDisplaced").toBool());
+ if (i == changes.count() - 1) {
+ QTRY_VERIFY(!listview->property("runningMoveTargets").toBool());
+ QTRY_VERIFY(!listview->property("runningMoveDisplaced").toBool());
+ } else {
+ QTest::qWait(timeBetweenActions);
+ }
+ break;
+ case ListChange::SetCurrent:
+ listview->setCurrentIndex(changes[i].index);
+ break;
+ case ListChange::SetContentY:
+ listview->setContentY(changes[i].pos);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
+ break;
+ }
+ }
+ QCOMPARE(listview->count(), model.count());
+
+ QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper");
+ int firstVisibleIndex = -1;
+ for (int i=0; i<items.count(); i++) {
+ if (items[i]->y() >= contentY) {
+ QQmlExpression e(qmlContext(items[i]), items[i], "index");
+ firstVisibleIndex = e.evaluate().toInt();
+ break;
+ }
+ }
+ QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex));
+
+ // verify all items moved to the correct final positions
+ int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
+ for (int i=firstVisibleIndex; i < model.count() && i < itemCount; ++i) {
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i);
+ QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i)));
+ QTRY_COMPARE(item->x(), 0.0);
+ QTRY_COMPARE(item->y(), i*20.0);
+ QQuickText *name = findItem<QQuickText>(contentItem, "textName", i);
+ QVERIFY(name != 0);
+ QTRY_COMPARE(name->text(), model.name(i));
+ }
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickListView::multipleTransitions_data()
+{
+ QTest::addColumn<int>("initialCount");
+ QTest::addColumn<qreal>("contentY");
+ QTest::addColumn<QList<ListChange> >("changes");
+
+ // the added item and displaced items should move to final dest correctly
+ QTest::newRow("add item, then move it immediately") << 10 << 0.0 << (QList<ListChange>()
+ << ListChange::insert(0, 1)
+ << ListChange::move(0, 3, 1)
+ );
+
+ // items affected by the add should change from move to add transition
+ QTest::newRow("move, then insert item before the moved item") << 20 << 0.0 << (QList<ListChange>()
+ << ListChange::move(1, 10, 3)
+ << ListChange::insert(0, 1)
+ );
+
+ // items should be placed correctly if you trigger a transition then refill for that index
+ QTest::newRow("add at 0, flick down, flick back to top and add at 0 again") << 20 << 0.0 << (QList<ListChange>()
+ << ListChange::insert(0, 1)
+ << ListChange::setContentY(80.0)
+ << ListChange::setContentY(0.0)
+ << ListChange::insert(0, 1)
+ );
+}
+
+QList<int> tst_QQuickListView::toIntList(const QVariantList &list)
+{
+ QList<int> ret;
+ bool ok = true;
+ for (int i=0; i<list.count(); i++) {
+ ret << list[i].toInt(&ok);
+ if (!ok)
+ qWarning() << "tst_QQuickListView::toIntList(): not a number:" << list[i];
+ }
+
+ return ret;
+}
+
+void tst_QQuickListView::matchIndexLists(const QVariantList &indexLists, const QList<int> &expectedIndexes)
+{
+ for (int i=0; i<indexLists.count(); i++) {
+ QSet<int> current = indexLists[i].value<QList<int> >().toSet();
+ if (current != expectedIndexes.toSet())
+ qDebug() << "Cannot match actual targets" << current << "with expected" << expectedIndexes;
+ QCOMPARE(current, expectedIndexes.toSet());
+ }
+}
+
+void tst_QQuickListView::matchItemsAndIndexes(const QVariantMap &items, const QaimModel &model, const QList<int> &expectedIndexes)
+{
+ for (QVariantMap::const_iterator it = items.begin(); it != items.end(); ++it) {
+ QVERIFY(it.value().type() == QVariant::Int);
+ QString name = it.key();
+ int itemIndex = it.value().toInt();
+ QVERIFY2(expectedIndexes.contains(itemIndex), QTest::toString(QString("Index %1 not found in expectedIndexes").arg(itemIndex)));
+ if (model.name(itemIndex) != name)
+ qDebug() << itemIndex;
+ QCOMPARE(model.name(itemIndex), name);
+ }
+ QCOMPARE(items.count(), expectedIndexes.count());
+}
+
+void tst_QQuickListView::matchItemLists(const QVariantList &itemLists, const QList<QQuickItem *> &expectedItems)
+{
+ for (int i=0; i<itemLists.count(); i++) {
+ QVERIFY(itemLists[i].type() == QVariant::List);
+ QVariantList current = itemLists[i].toList();
+ for (int j=0; j<current.count(); j++) {
+ QQuickItem *o = qobject_cast<QQuickItem*>(current[j].value<QObject*>());
+ QVERIFY2(o, QTest::toString(QString("Invalid actual item at %1").arg(j)));
+ QVERIFY2(expectedItems.contains(o), QTest::toString(QString("Cannot match item %1").arg(j)));
+ }
+ QCOMPARE(current.count(), expectedItems.count());
+ }
+}
+
+
+QTEST_MAIN(tst_QQuickListView)
+
+#include "tst_qquicklistview.moc"
+
diff --git a/tests/auto/qtquick2/qquickloader/data/ActiveComponent.qml b/tests/auto/quick/qquickloader/data/ActiveComponent.qml
index 24c6f7ad91..24c6f7ad91 100644
--- a/tests/auto/qtquick2/qquickloader/data/ActiveComponent.qml
+++ b/tests/auto/quick/qquickloader/data/ActiveComponent.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/AnchoredLoader.qml b/tests/auto/quick/qquickloader/data/AnchoredLoader.qml
index 1a2a620d7f..1a2a620d7f 100644
--- a/tests/auto/qtquick2/qquickloader/data/AnchoredLoader.qml
+++ b/tests/auto/quick/qquickloader/data/AnchoredLoader.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/BigComponent.qml b/tests/auto/quick/qquickloader/data/BigComponent.qml
index df92532c43..df92532c43 100644
--- a/tests/auto/qtquick2/qquickloader/data/BigComponent.qml
+++ b/tests/auto/quick/qquickloader/data/BigComponent.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/BlueRect.qml b/tests/auto/quick/qquickloader/data/BlueRect.qml
index e96ac00f21..e96ac00f21 100644
--- a/tests/auto/qtquick2/qquickloader/data/BlueRect.qml
+++ b/tests/auto/quick/qquickloader/data/BlueRect.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/CreationContextLoader.qml b/tests/auto/quick/qquickloader/data/CreationContextLoader.qml
index 4dd73e797c..4dd73e797c 100644
--- a/tests/auto/qtquick2/qquickloader/data/CreationContextLoader.qml
+++ b/tests/auto/quick/qquickloader/data/CreationContextLoader.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/GraphicsWidget250x250.qml b/tests/auto/quick/qquickloader/data/GraphicsWidget250x250.qml
index dae8e3fbbb..dae8e3fbbb 100644
--- a/tests/auto/qtquick2/qquickloader/data/GraphicsWidget250x250.qml
+++ b/tests/auto/quick/qquickloader/data/GraphicsWidget250x250.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/GreenRect.qml b/tests/auto/quick/qquickloader/data/GreenRect.qml
index 99cefaf176..99cefaf176 100644
--- a/tests/auto/qtquick2/qquickloader/data/GreenRect.qml
+++ b/tests/auto/quick/qquickloader/data/GreenRect.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/InitialPropertyValuesComponent.qml b/tests/auto/quick/qquickloader/data/InitialPropertyValuesComponent.qml
index 24c6f7ad91..24c6f7ad91 100644
--- a/tests/auto/qtquick2/qquickloader/data/InitialPropertyValuesComponent.qml
+++ b/tests/auto/quick/qquickloader/data/InitialPropertyValuesComponent.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/InvalidSourceComponent.qml b/tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml
index 7efa4a5f61..7efa4a5f61 100644
--- a/tests/auto/qtquick2/qquickloader/data/InvalidSourceComponent.qml
+++ b/tests/auto/quick/qquickloader/data/InvalidSourceComponent.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/NoResize.qml b/tests/auto/quick/qquickloader/data/NoResize.qml
index 9b3ea6410b..9b3ea6410b 100644
--- a/tests/auto/qtquick2/qquickloader/data/NoResize.qml
+++ b/tests/auto/quick/qquickloader/data/NoResize.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/NoResizeGraphicsWidget.qml b/tests/auto/quick/qquickloader/data/NoResizeGraphicsWidget.qml
index c0f51d8c35..c0f51d8c35 100644
--- a/tests/auto/qtquick2/qquickloader/data/NoResizeGraphicsWidget.qml
+++ b/tests/auto/quick/qquickloader/data/NoResizeGraphicsWidget.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/QTBUG_16928.qml b/tests/auto/quick/qquickloader/data/QTBUG_16928.qml
index 903d7f0812..903d7f0812 100644
--- a/tests/auto/qtquick2/qquickloader/data/QTBUG_16928.qml
+++ b/tests/auto/quick/qquickloader/data/QTBUG_16928.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/QTBUG_17114.qml b/tests/auto/quick/qquickloader/data/QTBUG_17114.qml
index 7402037553..7402037553 100644
--- a/tests/auto/qtquick2/qquickloader/data/QTBUG_17114.qml
+++ b/tests/auto/quick/qquickloader/data/QTBUG_17114.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/Rect120x60.qml b/tests/auto/quick/qquickloader/data/Rect120x60.qml
index fc9e447e69..fc9e447e69 100644
--- a/tests/auto/qtquick2/qquickloader/data/Rect120x60.qml
+++ b/tests/auto/quick/qquickloader/data/Rect120x60.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/SetSourceComponent.qml b/tests/auto/quick/qquickloader/data/SetSourceComponent.qml
index 83cc358f7d..83cc358f7d 100644
--- a/tests/auto/qtquick2/qquickloader/data/SetSourceComponent.qml
+++ b/tests/auto/quick/qquickloader/data/SetSourceComponent.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/SizeGraphicsWidgetToLoader.qml b/tests/auto/quick/qquickloader/data/SizeGraphicsWidgetToLoader.qml
index 2a63b4d34f..2a63b4d34f 100644
--- a/tests/auto/qtquick2/qquickloader/data/SizeGraphicsWidgetToLoader.qml
+++ b/tests/auto/quick/qquickloader/data/SizeGraphicsWidgetToLoader.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/SizeLoaderToGraphicsWidget.qml b/tests/auto/quick/qquickloader/data/SizeLoaderToGraphicsWidget.qml
index a9875d8e21..a9875d8e21 100644
--- a/tests/auto/qtquick2/qquickloader/data/SizeLoaderToGraphicsWidget.qml
+++ b/tests/auto/quick/qquickloader/data/SizeLoaderToGraphicsWidget.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/SizeToItem.qml b/tests/auto/quick/qquickloader/data/SizeToItem.qml
index 866365754f..866365754f 100644
--- a/tests/auto/qtquick2/qquickloader/data/SizeToItem.qml
+++ b/tests/auto/quick/qquickloader/data/SizeToItem.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/SizeToLoader.qml b/tests/auto/quick/qquickloader/data/SizeToLoader.qml
index dad18c6939..dad18c6939 100644
--- a/tests/auto/qtquick2/qquickloader/data/SizeToLoader.qml
+++ b/tests/auto/quick/qquickloader/data/SizeToLoader.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/VmeError.qml b/tests/auto/quick/qquickloader/data/VmeError.qml
index 0443aa9054..0443aa9054 100644
--- a/tests/auto/qtquick2/qquickloader/data/VmeError.qml
+++ b/tests/auto/quick/qquickloader/data/VmeError.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/active.1.qml b/tests/auto/quick/qquickloader/data/active.1.qml
index 2dbd1a0887..2dbd1a0887 100644
--- a/tests/auto/qtquick2/qquickloader/data/active.1.qml
+++ b/tests/auto/quick/qquickloader/data/active.1.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/active.2.qml b/tests/auto/quick/qquickloader/data/active.2.qml
index e561744c63..e561744c63 100644
--- a/tests/auto/qtquick2/qquickloader/data/active.2.qml
+++ b/tests/auto/quick/qquickloader/data/active.2.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/active.3.qml b/tests/auto/quick/qquickloader/data/active.3.qml
index 0fbba959bb..0fbba959bb 100644
--- a/tests/auto/qtquick2/qquickloader/data/active.3.qml
+++ b/tests/auto/quick/qquickloader/data/active.3.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/active.4.qml b/tests/auto/quick/qquickloader/data/active.4.qml
index 63fd46e2da..63fd46e2da 100644
--- a/tests/auto/qtquick2/qquickloader/data/active.4.qml
+++ b/tests/auto/quick/qquickloader/data/active.4.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/active.5.qml b/tests/auto/quick/qquickloader/data/active.5.qml
index 903f458a41..903f458a41 100644
--- a/tests/auto/qtquick2/qquickloader/data/active.5.qml
+++ b/tests/auto/quick/qquickloader/data/active.5.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/active.6.qml b/tests/auto/quick/qquickloader/data/active.6.qml
index f769a4e184..f769a4e184 100644
--- a/tests/auto/qtquick2/qquickloader/data/active.6.qml
+++ b/tests/auto/quick/qquickloader/data/active.6.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/active.7.qml b/tests/auto/quick/qquickloader/data/active.7.qml
index a29e932f5e..a29e932f5e 100644
--- a/tests/auto/qtquick2/qquickloader/data/active.7.qml
+++ b/tests/auto/quick/qquickloader/data/active.7.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/active.8.qml b/tests/auto/quick/qquickloader/data/active.8.qml
index 3a66d3e99a..3a66d3e99a 100644
--- a/tests/auto/qtquick2/qquickloader/data/active.8.qml
+++ b/tests/auto/quick/qquickloader/data/active.8.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/asynchronous.qml b/tests/auto/quick/qquickloader/data/asynchronous.qml
index 29570525ad..29570525ad 100644
--- a/tests/auto/qtquick2/qquickloader/data/asynchronous.qml
+++ b/tests/auto/quick/qquickloader/data/asynchronous.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/crash.qml b/tests/auto/quick/qquickloader/data/crash.qml
index e6ddc33a10..e6ddc33a10 100644
--- a/tests/auto/qtquick2/qquickloader/data/crash.qml
+++ b/tests/auto/quick/qquickloader/data/crash.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/creationContext.qml b/tests/auto/quick/qquickloader/data/creationContext.qml
index 17a596cc74..17a596cc74 100644
--- a/tests/auto/qtquick2/qquickloader/data/creationContext.qml
+++ b/tests/auto/quick/qquickloader/data/creationContext.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/differentorigin.qml b/tests/auto/quick/qquickloader/data/differentorigin.qml
index 56a3034fe0..56a3034fe0 100644
--- a/tests/auto/qtquick2/qquickloader/data/differentorigin.qml
+++ b/tests/auto/quick/qquickloader/data/differentorigin.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/implicitSize.qml b/tests/auto/quick/qquickloader/data/implicitSize.qml
index 5c8c8348ed..5c8c8348ed 100644
--- a/tests/auto/qtquick2/qquickloader/data/implicitSize.qml
+++ b/tests/auto/quick/qquickloader/data/implicitSize.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.1.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.1.qml
index ae371797ce..ae371797ce 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.1.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.1.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.2.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.2.qml
index 76c7bc2fd6..76c7bc2fd6 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.2.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.2.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.3.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.3.qml
index 3b08e6ee42..3b08e6ee42 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.3.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.3.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.4.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.4.qml
index e8310044e8..e8310044e8 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.4.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.4.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.5.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.5.qml
index 03ee599aba..03ee599aba 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.5.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.5.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.6.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.6.qml
index 66452b512b..66452b512b 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.6.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.6.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.7.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.7.qml
index 02349f7ddf..02349f7ddf 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.7.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.7.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.8.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.8.qml
index 79e9264d4a..79e9264d4a 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.8.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.8.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.binding.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.binding.qml
index e0df50a74a..e0df50a74a 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.binding.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.binding.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.1.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.1.qml
index f324dbddac..f324dbddac 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.1.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.1.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.2.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.2.qml
index 89aba313c7..89aba313c7 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.2.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.2.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.3.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.3.qml
index c862007402..c862007402 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.3.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.3.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.4.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.4.qml
index 9a80b2156d..9a80b2156d 100644
--- a/tests/auto/qtquick2/qquickloader/data/initialPropertyValues.error.4.qml
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.error.4.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/nonItem.qml b/tests/auto/quick/qquickloader/data/nonItem.qml
index 8cfa0d8efb..8cfa0d8efb 100644
--- a/tests/auto/qtquick2/qquickloader/data/nonItem.qml
+++ b/tests/auto/quick/qquickloader/data/nonItem.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/parented.qml b/tests/auto/quick/qquickloader/data/parented.qml
index 1c19d4d1a5..1c19d4d1a5 100644
--- a/tests/auto/qtquick2/qquickloader/data/parented.qml
+++ b/tests/auto/quick/qquickloader/data/parented.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/qmldir b/tests/auto/quick/qquickloader/data/qmldir
index bf42b507c0..bf42b507c0 100644
--- a/tests/auto/qtquick2/qquickloader/data/qmldir
+++ b/tests/auto/quick/qquickloader/data/qmldir
diff --git a/tests/auto/qtquick2/qquickloader/data/sameorigin-load.qml b/tests/auto/quick/qquickloader/data/sameorigin-load.qml
index 3332500be6..3332500be6 100644
--- a/tests/auto/qtquick2/qquickloader/data/sameorigin-load.qml
+++ b/tests/auto/quick/qquickloader/data/sameorigin-load.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/sameorigin.qml b/tests/auto/quick/qquickloader/data/sameorigin.qml
index 84846b6aba..84846b6aba 100644
--- a/tests/auto/qtquick2/qquickloader/data/sameorigin.qml
+++ b/tests/auto/quick/qquickloader/data/sameorigin.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/sizebound.qml b/tests/auto/quick/qquickloader/data/sizebound.qml
index 09cf32426a..09cf32426a 100644
--- a/tests/auto/qtquick2/qquickloader/data/sizebound.qml
+++ b/tests/auto/quick/qquickloader/data/sizebound.qml
diff --git a/tests/auto/qtquick2/qquickloader/data/vmeErrors.qml b/tests/auto/quick/qquickloader/data/vmeErrors.qml
index 8e6c89dc8e..8e6c89dc8e 100644
--- a/tests/auto/qtquick2/qquickloader/data/vmeErrors.qml
+++ b/tests/auto/quick/qquickloader/data/vmeErrors.qml
diff --git a/tests/auto/quick/qquickloader/qquickloader.pro b/tests/auto/quick/qquickloader/qquickloader.pro
new file mode 100644
index 0000000000..fd525351ab
--- /dev/null
+++ b/tests/auto/quick/qquickloader/qquickloader.pro
@@ -0,0 +1,19 @@
+CONFIG += testcase
+TARGET = tst_qquickloader
+macx:CONFIG -= app_bundle
+
+INCLUDEPATH += ../../shared/
+HEADERS += ../../shared/testhttpserver.h
+
+SOURCES += tst_qquickloader.cpp \
+ ../../shared/testhttpserver.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
new file mode 100644
index 0000000000..77d0c29220
--- /dev/null
+++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
@@ -0,0 +1,987 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+
+#include <QSignalSpy>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlincubator.h>
+#include <private/qquickloader_p.h>
+#include "testhttpserver.h"
+#include "../../shared/util.h"
+
+#define SERVER_PORT 14450
+
+class PeriodicIncubationController : public QObject,
+ public QQmlIncubationController
+{
+public:
+ PeriodicIncubationController() {
+ startTimer(16);
+ }
+
+protected:
+ virtual void timerEvent(QTimerEvent *) {
+ incubateFor(15);
+ }
+};
+
+class tst_QQuickLoader : public QQmlDataTest
+
+{
+ Q_OBJECT
+public:
+ tst_QQuickLoader();
+
+private slots:
+ void sourceOrComponent();
+ void sourceOrComponent_data();
+ void clear();
+ void urlToComponent();
+ void componentToUrl();
+ void anchoredLoader();
+ void sizeLoaderToItem();
+ void sizeItemToLoader();
+ void noResize();
+ void networkRequestUrl();
+ void failNetworkRequest();
+// void networkComponent();
+ void active();
+ void initialPropertyValues_data();
+ void initialPropertyValues();
+ void initialPropertyValuesBinding();
+ void initialPropertyValuesError_data();
+ void initialPropertyValuesError();
+
+ void deleteComponentCrash();
+ void nonItem();
+ void vmeErrors();
+ void creationContext();
+ void QTBUG_16928();
+ void implicitSize();
+ void QTBUG_17114();
+ void asynchronous_data();
+ void asynchronous();
+ void asynchronous_clear();
+
+ void parented();
+ void sizeBound();
+
+private:
+ QQmlEngine engine;
+};
+
+
+tst_QQuickLoader::tst_QQuickLoader()
+{
+}
+
+void tst_QQuickLoader::sourceOrComponent()
+{
+ QFETCH(QString, sourceOrComponent);
+ QFETCH(QString, sourceDefinition);
+ QFETCH(QUrl, sourceUrl);
+ QFETCH(QString, errorString);
+
+ bool error = !errorString.isEmpty();
+ if (error)
+ QTest::ignoreMessage(QtWarningMsg, errorString.toUtf8().constData());
+
+ QQmlComponent component(&engine);
+ component.setData(QByteArray(
+ "import QtQuick 2.0\n"
+ "Loader {\n"
+ " property int onItemChangedCount: 0\n"
+ " property int onSourceChangedCount: 0\n"
+ " property int onSourceComponentChangedCount: 0\n"
+ " property int onStatusChangedCount: 0\n"
+ " property int onProgressChangedCount: 0\n"
+ " property int onLoadedCount: 0\n")
+ + sourceDefinition.toUtf8()
+ + QByteArray(
+ " onItemChanged: onItemChangedCount += 1\n"
+ " onSourceChanged: onSourceChangedCount += 1\n"
+ " onSourceComponentChanged: onSourceComponentChangedCount += 1\n"
+ " onStatusChanged: onStatusChangedCount += 1\n"
+ " onProgressChanged: onProgressChangedCount += 1\n"
+ " onLoaded: onLoadedCount += 1\n"
+ "}")
+ , dataDirectoryUrl());
+
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QCOMPARE(loader->item() == 0, error);
+ QCOMPARE(loader->source(), sourceUrl);
+ QCOMPARE(loader->progress(), 1.0);
+
+ QCOMPARE(loader->status(), error ? QQuickLoader::Error : QQuickLoader::Ready);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), error ? 0: 1);
+
+ if (!error) {
+ bool sourceComponentIsChildOfLoader = false;
+ for (int ii = 0; ii < loader->children().size(); ++ii) {
+ QQmlComponent *c = qobject_cast<QQmlComponent*>(loader->children().at(ii));
+ if (c && c == loader->sourceComponent()) {
+ sourceComponentIsChildOfLoader = true;
+ }
+ }
+ QVERIFY(sourceComponentIsChildOfLoader);
+ }
+
+ if (sourceOrComponent == "component") {
+ QCOMPARE(loader->property("onSourceComponentChangedCount").toInt(), 1);
+ QCOMPARE(loader->property("onSourceChangedCount").toInt(), 0);
+ } else {
+ QCOMPARE(loader->property("onSourceComponentChangedCount").toInt(), 0);
+ QCOMPARE(loader->property("onSourceChangedCount").toInt(), 1);
+ }
+ QCOMPARE(loader->property("onStatusChangedCount").toInt(), 1);
+ QCOMPARE(loader->property("onProgressChangedCount").toInt(), 1);
+
+ QCOMPARE(loader->property("onItemChangedCount").toInt(), error ? 0 : 1);
+ QCOMPARE(loader->property("onLoadedCount").toInt(), error ? 0 : 1);
+
+ delete loader;
+}
+
+void tst_QQuickLoader::sourceOrComponent_data()
+{
+ QTest::addColumn<QString>("sourceOrComponent");
+ QTest::addColumn<QString>("sourceDefinition");
+ QTest::addColumn<QUrl>("sourceUrl");
+ QTest::addColumn<QString>("errorString");
+
+ QTest::newRow("source") << "source" << "source: 'Rect120x60.qml'\n" << testFileUrl("Rect120x60.qml") << "";
+ QTest::newRow("sourceComponent") << "component" << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << "";
+ QTest::newRow("invalid source") << "source" << "source: 'IDontExist.qml'\n" << testFileUrl("IDontExist.qml")
+ << QString(testFileUrl("IDontExist.qml").toString() + ": File not found");
+}
+
+void tst_QQuickLoader::clear()
+{
+ {
+ QQmlComponent component(&engine);
+ component.setData(QByteArray(
+ "import QtQuick 2.0\n"
+ " Loader { id: loader\n"
+ " source: 'Rect120x60.qml'\n"
+ " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n"
+ " }")
+ , dataDirectoryUrl());
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+
+ QTRY_VERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 0.0);
+ QCOMPARE(loader->status(), QQuickLoader::Null);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
+
+ delete loader;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::childItems().at(0));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+
+ loader->setSourceComponent(0);
+
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 0.0);
+ QCOMPARE(loader->status(), QQuickLoader::Null);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
+
+ delete item;
+ }
+ {
+ QQmlComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::childItems().at(0));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+
+ QMetaObject::invokeMethod(item, "clear");
+
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 0.0);
+ QCOMPARE(loader->status(), QQuickLoader::Null);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
+
+ delete item;
+ }
+}
+
+void tst_QQuickLoader::urlToComponent()
+{
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\n"
+ "Loader {\n"
+ " id: loader\n"
+ " Component { id: myComp; Rectangle { width: 10; height: 10 } }\n"
+ " source: \"Rect120x60.qml\"\n"
+ " Timer { interval: 100; running: true; onTriggered: loader.sourceComponent = myComp }\n"
+ "}" )
+ , dataDirectoryUrl());
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QTest::qWait(200);
+ QTRY_VERIFY(loader != 0);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+ QCOMPARE(loader->width(), 10.0);
+ QCOMPARE(loader->height(), 10.0);
+
+ delete loader;
+}
+
+void tst_QQuickLoader::componentToUrl()
+{
+ QQmlComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::childItems().at(0));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+
+ loader->setSource(testFileUrl("/Rect120x60.qml"));
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+ QCOMPARE(loader->width(), 120.0);
+ QCOMPARE(loader->height(), 60.0);
+
+ delete item;
+}
+
+void tst_QQuickLoader::anchoredLoader()
+{
+ QQmlComponent component(&engine, testFileUrl("/AnchoredLoader.qml"));
+ QQuickItem *rootItem = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(rootItem != 0);
+ QQuickItem *loader = rootItem->findChild<QQuickItem*>("loader");
+ QQuickItem *sourceElement = rootItem->findChild<QQuickItem*>("sourceElement");
+
+ QVERIFY(loader != 0);
+ QVERIFY(sourceElement != 0);
+
+ QCOMPARE(rootItem->width(), 300.0);
+ QCOMPARE(rootItem->height(), 200.0);
+
+ QCOMPARE(loader->width(), 300.0);
+ QCOMPARE(loader->height(), 200.0);
+
+ QCOMPARE(sourceElement->width(), 300.0);
+ QCOMPARE(sourceElement->height(), 200.0);
+}
+
+void tst_QQuickLoader::sizeLoaderToItem()
+{
+ QQmlComponent component(&engine, testFileUrl("/SizeToItem.qml"));
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QCOMPARE(loader->width(), 120.0);
+ QCOMPARE(loader->height(), 60.0);
+
+ // Check resize
+ QQuickItem *rect = qobject_cast<QQuickItem*>(loader->item());
+ QVERIFY(rect);
+ rect->setWidth(150);
+ rect->setHeight(45);
+ QCOMPARE(loader->width(), 150.0);
+ QCOMPARE(loader->height(), 45.0);
+
+ // Check explicit width
+ loader->setWidth(200.0);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(rect->width(), 200.0);
+ rect->setWidth(100.0); // when rect changes ...
+ QCOMPARE(rect->width(), 100.0); // ... it changes
+ QCOMPARE(loader->width(), 200.0); // ... but loader stays the same
+
+ // Check explicit height
+ loader->setHeight(200.0);
+ QCOMPARE(loader->height(), 200.0);
+ QCOMPARE(rect->height(), 200.0);
+ rect->setHeight(100.0); // when rect changes ...
+ QCOMPARE(rect->height(), 100.0); // ... it changes
+ QCOMPARE(loader->height(), 200.0); // ... but loader stays the same
+
+ // Switch mode
+ loader->setWidth(180);
+ loader->setHeight(30);
+ QCOMPARE(rect->width(), 180.0);
+ QCOMPARE(rect->height(), 30.0);
+
+ delete loader;
+}
+
+void tst_QQuickLoader::sizeItemToLoader()
+{
+ QQmlComponent component(&engine, testFileUrl("/SizeToLoader.qml"));
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QVERIFY(loader != 0);
+ QCOMPARE(loader->width(), 200.0);
+ QCOMPARE(loader->height(), 80.0);
+
+ QQuickItem *rect = qobject_cast<QQuickItem*>(loader->item());
+ QVERIFY(rect);
+ QCOMPARE(rect->width(), 200.0);
+ QCOMPARE(rect->height(), 80.0);
+
+ // Check resize
+ loader->setWidth(180);
+ loader->setHeight(30);
+ QCOMPARE(rect->width(), 180.0);
+ QCOMPARE(rect->height(), 30.0);
+
+ // Switch mode
+ loader->resetWidth(); // reset explicit size
+ loader->resetHeight();
+ rect->setWidth(160);
+ rect->setHeight(45);
+ QCOMPARE(loader->width(), 160.0);
+ QCOMPARE(loader->height(), 45.0);
+
+ delete loader;
+}
+
+void tst_QQuickLoader::noResize()
+{
+ QQmlComponent component(&engine, testFileUrl("/NoResize.qml"));
+ QQuickItem* item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item != 0);
+ QCOMPARE(item->width(), 200.0);
+ QCOMPARE(item->height(), 80.0);
+
+ delete item;
+}
+
+void tst_QQuickLoader::networkRequestUrl()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), testFileUrl("../dummy.qml"));
+ if (component.isError())
+ qDebug() << component.errors();
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QVERIFY(loader != 0);
+
+ QTRY_VERIFY(loader->status() == QQuickLoader::Ready);
+
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->property("signalCount").toInt(), 1);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+
+ delete loader;
+}
+
+/* XXX Component waits until all dependencies are loaded. Is this actually possible?
+void tst_QQuickLoader::networkComponent()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory("slowdata", TestHTTPServer::Delay);
+
+ QQmlComponent component(&engine);
+ component.setData(QByteArray(
+ "import QtQuick 2.0\n"
+ "import \"http://127.0.0.1:14450/\" as NW\n"
+ "Item {\n"
+ " Component { id: comp; NW.SlowRect {} }\n"
+ " Loader { sourceComponent: comp } }")
+ , dataDirectoryUrl());
+
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::children().at(1));
+ QVERIFY(loader);
+ QTRY_VERIFY(loader->status() == QQuickLoader::Ready);
+
+ QVERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QQuickLoader::Ready);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->children().count(), 1);
+
+ delete loader;
+}
+*/
+
+void tst_QQuickLoader::failNetworkRequest()
+{
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+
+ QTest::ignoreMessage(QtWarningMsg, "http://127.0.0.1:14450/IDontExist.qml: File not found");
+
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\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"));
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QVERIFY(loader != 0);
+
+ QTRY_VERIFY(loader->status() == QQuickLoader::Error);
+
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->progress(), 0.0);
+ QCOMPARE(loader->property("did_load").toInt(), 123);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
+
+ delete loader;
+}
+
+void tst_QQuickLoader::active()
+{
+ // check that the item isn't instantiated until active is set to true
+ {
+ QQmlComponent component(&engine, testFileUrl("active.1.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
+
+ QVERIFY(loader->active() == false); // set manually to false
+ QVERIFY(loader->item() == 0);
+ QMetaObject::invokeMethod(object, "doSetSourceComponent");
+ QVERIFY(loader->item() == 0);
+ QMetaObject::invokeMethod(object, "doSetSource");
+ QVERIFY(loader->item() == 0);
+ QMetaObject::invokeMethod(object, "doSetActive");
+ QVERIFY(loader->item() != 0);
+
+ delete object;
+ }
+
+ // check that the status is Null if active is set to false
+ {
+ QQmlComponent component(&engine, testFileUrl("active.2.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
+
+ QVERIFY(loader->active() == true); // active is true by default
+ QCOMPARE(loader->status(), QQuickLoader::Ready);
+ int currStatusChangedCount = loader->property("statusChangedCount").toInt();
+ QMetaObject::invokeMethod(object, "doSetInactive");
+ QCOMPARE(loader->status(), QQuickLoader::Null);
+ QCOMPARE(loader->property("statusChangedCount").toInt(), (currStatusChangedCount+1));
+
+ delete object;
+ }
+
+ // check that the source is not cleared if active is set to false
+ {
+ QQmlComponent component(&engine, testFileUrl("active.3.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
+
+ QVERIFY(loader->active() == true); // active is true by default
+ QVERIFY(!loader->source().isEmpty());
+ int currSourceChangedCount = loader->property("sourceChangedCount").toInt();
+ QMetaObject::invokeMethod(object, "doSetInactive");
+ QVERIFY(!loader->source().isEmpty());
+ QCOMPARE(loader->property("sourceChangedCount").toInt(), currSourceChangedCount);
+
+ delete object;
+ }
+
+ // check that the sourceComponent is not cleared if active is set to false
+ {
+ QQmlComponent component(&engine, testFileUrl("active.4.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
+
+ QVERIFY(loader->active() == true); // active is true by default
+ QVERIFY(loader->sourceComponent() != 0);
+ int currSourceComponentChangedCount = loader->property("sourceComponentChangedCount").toInt();
+ QMetaObject::invokeMethod(object, "doSetInactive");
+ QVERIFY(loader->sourceComponent() != 0);
+ QCOMPARE(loader->property("sourceComponentChangedCount").toInt(), currSourceComponentChangedCount);
+
+ delete object;
+ }
+
+ // check that the item is released if active is set to false
+ {
+ QQmlComponent component(&engine, testFileUrl("active.5.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
+
+ QVERIFY(loader->active() == true); // active is true by default
+ QVERIFY(loader->item() != 0);
+ int currItemChangedCount = loader->property("itemChangedCount").toInt();
+ QMetaObject::invokeMethod(object, "doSetInactive");
+ QVERIFY(loader->item() == 0);
+ QCOMPARE(loader->property("itemChangedCount").toInt(), (currItemChangedCount+1));
+
+ delete object;
+ }
+
+ // check that the activeChanged signal is emitted correctly
+ {
+ QQmlComponent component(&engine, testFileUrl("active.6.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
+
+ QVERIFY(loader->active() == true); // active is true by default
+ loader->setActive(true); // no effect
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 0);
+ loader->setActive(false); // change signal should be emitted
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 1);
+ loader->setActive(false); // no effect
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 1);
+ loader->setActive(true); // change signal should be emitted
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 2);
+ loader->setActive(false); // change signal should be emitted
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 3);
+ QMetaObject::invokeMethod(object, "doSetActive");
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 4);
+ QMetaObject::invokeMethod(object, "doSetActive");
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 4);
+ QMetaObject::invokeMethod(object, "doSetInactive");
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 5);
+ loader->setActive(true); // change signal should be emitted
+ QCOMPARE(loader->property("activeChangedCount").toInt(), 6);
+
+ delete object;
+ }
+
+ // check that the component isn't loaded until active is set to true
+ {
+ QQmlComponent component(&engine, testFileUrl("active.7.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("success").toBool(), true);
+ delete object;
+ }
+
+ // check that the component is loaded if active is not set (true by default)
+ {
+ QQmlComponent component(&engine, testFileUrl("active.8.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("success").toBool(), true);
+ delete object;
+ }
+}
+
+void tst_QQuickLoader::initialPropertyValues_data()
+{
+ QTest::addColumn<QUrl>("qmlFile");
+ QTest::addColumn<QStringList>("expectedWarnings");
+ QTest::addColumn<QStringList>("propertyNames");
+ QTest::addColumn<QVariantList>("propertyValues");
+
+ QTest::newRow("source url with value set in onLoaded, initially active = true") << testFileUrl("initialPropertyValues.1.qml")
+ << QStringList()
+ << (QStringList() << "initialValue" << "behaviorCount")
+ << (QVariantList() << 1 << 1);
+
+ QTest::newRow("set source with initial property values specified, active = true") << testFileUrl("initialPropertyValues.2.qml")
+ << QStringList()
+ << (QStringList() << "initialValue" << "behaviorCount")
+ << (QVariantList() << 2 << 0);
+
+ QTest::newRow("set source with initial property values specified, active = false") << testFileUrl("initialPropertyValues.3.qml")
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("initialPropertyValues.3.qml").toLocalFile() + QLatin1String(":16: TypeError: Cannot read property 'canary' of null")))
+ << (QStringList())
+ << (QVariantList());
+
+ QTest::newRow("set source with initial property values specified, active = false, with active set true later") << testFileUrl("initialPropertyValues.4.qml")
+ << QStringList()
+ << (QStringList() << "initialValue" << "behaviorCount")
+ << (QVariantList() << 4 << 0);
+
+ QTest::newRow("set source without initial property values specified, active = true") << testFileUrl("initialPropertyValues.5.qml")
+ << QStringList()
+ << (QStringList() << "initialValue" << "behaviorCount")
+ << (QVariantList() << 0 << 0);
+
+ QTest::newRow("set source with initial property values specified with binding, active = true") << testFileUrl("initialPropertyValues.6.qml")
+ << QStringList()
+ << (QStringList() << "initialValue" << "behaviorCount")
+ << (QVariantList() << 6 << 0);
+
+ QTest::newRow("ensure initial property value semantics mimic createObject") << testFileUrl("initialPropertyValues.7.qml")
+ << QStringList()
+ << (QStringList() << "loaderValue" << "createObjectValue")
+ << (QVariantList() << 1 << 1);
+
+ QTest::newRow("ensure initial property values aren't disposed prior to component completion") << testFileUrl("initialPropertyValues.8.qml")
+ << QStringList()
+ << (QStringList() << "initialValue")
+ << (QVariantList() << 6);
+}
+
+void tst_QQuickLoader::initialPropertyValues()
+{
+ QFETCH(QUrl, qmlFile);
+ QFETCH(QStringList, expectedWarnings);
+ QFETCH(QStringList, propertyNames);
+ QFETCH(QVariantList, propertyValues);
+
+ TestHTTPServer server(SERVER_PORT);
+ QVERIFY(server.isValid());
+ server.serveDirectory(dataDirectory());
+
+ foreach (const QString &warning, expectedWarnings)
+ QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
+
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ qApp->processEvents();
+ QTest::qWait(50);
+
+ for (int i = 0; i < propertyNames.size(); ++i)
+ QCOMPARE(object->property(propertyNames.at(i).toAscii().constData()), propertyValues.at(i));
+
+ delete object;
+}
+
+void tst_QQuickLoader::initialPropertyValuesBinding()
+{
+ QQmlComponent component(&engine, testFileUrl("initialPropertyValues.binding.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(object->setProperty("bindable", QVariant(8)));
+ QCOMPARE(object->property("canaryValue").toInt(), 8);
+
+ delete object;
+}
+
+void tst_QQuickLoader::initialPropertyValuesError_data()
+{
+ QTest::addColumn<QUrl>("qmlFile");
+ QTest::addColumn<QStringList>("expectedWarnings");
+
+ QTest::newRow("invalid initial property values object") << testFileUrl("initialPropertyValues.error.1.qml")
+ << (QStringList() << QString(testFileUrl("initialPropertyValues.error.1.qml").toString() + ":6:5: QML Loader: setSource: value is not an object"));
+
+ QTest::newRow("nonexistent source url") << testFileUrl("initialPropertyValues.error.2.qml")
+ << (QStringList() << QString(testFileUrl("NonexistentSourceComponent.qml").toString() + ": File not found"));
+
+ QTest::newRow("invalid source url") << testFileUrl("initialPropertyValues.error.3.qml")
+ << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error"));
+
+ QTest::newRow("invalid initial property values object with invalid property access") << testFileUrl("initialPropertyValues.error.4.qml")
+ << (QStringList() << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":7:5: QML Loader: setSource: value is not an object")
+ << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":5: TypeError: Cannot read property 'canary' of null"));
+}
+
+void tst_QQuickLoader::initialPropertyValuesError()
+{
+ QFETCH(QUrl, qmlFile);
+ QFETCH(QStringList, expectedWarnings);
+
+ foreach (const QString &warning, expectedWarnings)
+ QTest::ignoreMessage(QtWarningMsg, warning.toUtf8().constData());
+
+ QQmlComponent component(&engine, qmlFile);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
+ QVERIFY(loader != 0);
+ QVERIFY(loader->item() == 0);
+ delete object;
+}
+
+// QTBUG-9241
+void tst_QQuickLoader::deleteComponentCrash()
+{
+ QQmlComponent component(&engine, testFileUrl("crash.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+
+ item->metaObject()->invokeMethod(item, "setLoaderSource");
+
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(item->QQuickItem::childItems().at(0));
+ QVERIFY(loader);
+ QVERIFY(loader->item());
+ QCOMPARE(loader->item()->objectName(), QLatin1String("blue"));
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QQuickLoader::Ready);
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ QTRY_COMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+ QVERIFY(loader->source() == testFileUrl("BlueRect.qml"));
+
+ delete item;
+}
+
+void tst_QQuickLoader::nonItem()
+{
+ QQmlComponent component(&engine, testFileUrl("nonItem.qml"));
+ QString err = testFileUrl("nonItem.qml").toString() + ":3:1: QML Loader: Loader does not support loading non-visual elements.";
+
+ QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData());
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QVERIFY(loader);
+ QVERIFY(loader->item() == 0);
+
+ delete loader;
+}
+
+void tst_QQuickLoader::vmeErrors()
+{
+ QQmlComponent component(&engine, testFileUrl("vmeErrors.qml"));
+ QString err = testFileUrl("VmeError.qml").toString() + ":6: Cannot assign object type QObject with no default method";
+ QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData());
+ QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
+ QVERIFY(loader);
+ QVERIFY(loader->item() == 0);
+
+ delete loader;
+}
+
+// QTBUG-13481
+void tst_QQuickLoader::creationContext()
+{
+ QQmlComponent component(&engine, testFileUrl("creationContext.qml"));
+
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toBool(), true);
+
+ delete o;
+}
+
+void tst_QQuickLoader::QTBUG_16928()
+{
+ QQmlComponent component(&engine, testFileUrl("QTBUG_16928.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+
+ QCOMPARE(item->width(), 250.);
+ QCOMPARE(item->height(), 250.);
+
+ delete item;
+}
+
+void tst_QQuickLoader::implicitSize()
+{
+ QQmlComponent component(&engine, testFileUrl("implicitSize.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+
+ QCOMPARE(item->width(), 150.);
+ QCOMPARE(item->height(), 150.);
+
+ QCOMPARE(item->property("implHeight").toReal(), 100.);
+ QCOMPARE(item->property("implWidth").toReal(), 100.);
+
+ delete item;
+}
+
+void tst_QQuickLoader::QTBUG_17114()
+{
+ QQmlComponent component(&engine, testFileUrl("QTBUG_17114.qml"));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+
+ QCOMPARE(item->property("loaderWidth").toReal(), 32.);
+ QCOMPARE(item->property("loaderHeight").toReal(), 32.);
+
+ delete item;
+}
+
+void tst_QQuickLoader::asynchronous_data()
+{
+ QTest::addColumn<QUrl>("qmlFile");
+ QTest::addColumn<QStringList>("expectedWarnings");
+
+ QTest::newRow("Valid component") << testFileUrl("BigComponent.qml")
+ << QStringList();
+
+ QTest::newRow("Non-existant component") << testFileUrl("IDoNotExist.qml")
+ << (QStringList() << QString(testFileUrl("IDoNotExist.qml").toString() + ": File not found"));
+
+ QTest::newRow("Invalid component") << testFileUrl("InvalidSourceComponent.qml")
+ << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error"));
+}
+
+void tst_QQuickLoader::asynchronous()
+{
+ QFETCH(QUrl, qmlFile);
+ QFETCH(QStringList, expectedWarnings);
+
+ if (!engine.incubationController())
+ engine.setIncubationController(new PeriodicIncubationController);
+ QQmlComponent component(&engine, testFileUrl("asynchronous.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(root);
+
+ QQuickLoader *loader = root->findChild<QQuickLoader*>("loader");
+ QVERIFY(loader);
+
+ foreach (const QString &warning, expectedWarnings)
+ QTest::ignoreMessage(QtWarningMsg, warning.toUtf8().constData());
+
+ QVERIFY(!loader->item());
+ root->setProperty("comp", qmlFile.toString());
+ QMetaObject::invokeMethod(root, "loadComponent");
+ QVERIFY(!loader->item());
+
+ if (expectedWarnings.isEmpty()) {
+ QCOMPARE(loader->status(), QQuickLoader::Loading);
+ QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1);
+
+ QTRY_VERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QQuickLoader::Ready);
+ } else {
+ QCOMPARE(loader->progress(), 1.0);
+ QTRY_COMPARE(loader->status(), QQuickLoader::Error);
+ }
+
+ delete root;
+}
+
+void tst_QQuickLoader::asynchronous_clear()
+{
+ if (!engine.incubationController())
+ engine.setIncubationController(new PeriodicIncubationController);
+ QQmlComponent component(&engine, testFileUrl("asynchronous.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(root);
+
+ QQuickLoader *loader = root->findChild<QQuickLoader*>("loader");
+ QVERIFY(loader);
+
+ QVERIFY(!loader->item());
+ root->setProperty("comp", "BigComponent.qml");
+ QMetaObject::invokeMethod(root, "loadComponent");
+ QVERIFY(!loader->item());
+
+ QCOMPARE(loader->status(), QQuickLoader::Loading);
+ QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1);
+
+ // clear before component created
+ root->setProperty("comp", "");
+ QMetaObject::invokeMethod(root, "loadComponent");
+ QVERIFY(!loader->item());
+ QCOMPARE(engine.incubationController()->incubatingObjectCount(), 0);
+
+ QCOMPARE(loader->progress(), 0.0);
+ QCOMPARE(loader->status(), QQuickLoader::Null);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 0);
+
+ // check loading component
+ root->setProperty("comp", "Rect120x60.qml");
+ QMetaObject::invokeMethod(root, "loadComponent");
+ QVERIFY(!loader->item());
+
+ QCOMPARE(loader->status(), QQuickLoader::Loading);
+ QCOMPARE(engine.incubationController()->incubatingObjectCount(), 1);
+
+ QTRY_VERIFY(loader->item());
+ QCOMPARE(loader->progress(), 1.0);
+ QCOMPARE(loader->status(), QQuickLoader::Ready);
+ QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
+}
+
+void tst_QQuickLoader::parented()
+{
+ QQmlComponent component(&engine, testFileUrl("parented.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(root);
+
+ QQuickItem *item = root->findChild<QQuickItem*>("comp");
+ QVERIFY(item);
+
+ QVERIFY(item->parentItem() == root);
+
+ QCOMPARE(item->width(), 300.);
+ QCOMPARE(item->height(), 300.);
+
+ delete root;
+}
+
+void tst_QQuickLoader::sizeBound()
+{
+ QQmlComponent component(&engine, testFileUrl("sizebound.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(root);
+ QQuickLoader *loader = root->findChild<QQuickLoader*>("loader");
+ QVERIFY(loader != 0);
+
+ QVERIFY(loader->item());
+
+ QCOMPARE(loader->width(), 50.0);
+ QCOMPARE(loader->height(), 60.0);
+
+ QMetaObject::invokeMethod(root, "switchComponent");
+
+ QCOMPARE(loader->width(), 80.0);
+ QCOMPARE(loader->height(), 90.0);
+
+ delete root;
+}
+
+
+QTEST_MAIN(tst_QQuickLoader)
+
+#include "tst_qquickloader.moc"
diff --git a/tests/auto/qtquick2/qquickmousearea/data/clickThrough.qml b/tests/auto/quick/qquickmousearea/data/clickThrough.qml
index 3c03161faa..3c03161faa 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/clickThrough.qml
+++ b/tests/auto/quick/qquickmousearea/data/clickThrough.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/clickThrough2.qml b/tests/auto/quick/qquickmousearea/data/clickThrough2.qml
index 2624108225..2624108225 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/clickThrough2.qml
+++ b/tests/auto/quick/qquickmousearea/data/clickThrough2.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/clickandhold.qml b/tests/auto/quick/qquickmousearea/data/clickandhold.qml
index 5e4e48f6db..5e4e48f6db 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/clickandhold.qml
+++ b/tests/auto/quick/qquickmousearea/data/clickandhold.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/clicktwice.qml b/tests/auto/quick/qquickmousearea/data/clicktwice.qml
index 002d1b9047..002d1b9047 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/clicktwice.qml
+++ b/tests/auto/quick/qquickmousearea/data/clicktwice.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/doubleclick.qml b/tests/auto/quick/qquickmousearea/data/doubleclick.qml
index 1030d0c33e..1030d0c33e 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/doubleclick.qml
+++ b/tests/auto/quick/qquickmousearea/data/doubleclick.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/dragging.qml b/tests/auto/quick/qquickmousearea/data/dragging.qml
index d9b6ac4083..d9b6ac4083 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/dragging.qml
+++ b/tests/auto/quick/qquickmousearea/data/dragging.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/dragproperties.qml b/tests/auto/quick/qquickmousearea/data/dragproperties.qml
index 421dfe26b7..421dfe26b7 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/dragproperties.qml
+++ b/tests/auto/quick/qquickmousearea/data/dragproperties.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/dragreset.qml b/tests/auto/quick/qquickmousearea/data/dragreset.qml
index d7949f9139..d7949f9139 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/dragreset.qml
+++ b/tests/auto/quick/qquickmousearea/data/dragreset.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/hoverPosition.qml b/tests/auto/quick/qquickmousearea/data/hoverPosition.qml
index 834f91ff29..834f91ff29 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/hoverPosition.qml
+++ b/tests/auto/quick/qquickmousearea/data/hoverPosition.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/hoverPropagation.qml b/tests/auto/quick/qquickmousearea/data/hoverPropagation.qml
index c47c794132..c47c794132 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/hoverPropagation.qml
+++ b/tests/auto/quick/qquickmousearea/data/hoverPropagation.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/hoverVisible.qml b/tests/auto/quick/qquickmousearea/data/hoverVisible.qml
index 2d65b5573e..2d65b5573e 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/hoverVisible.qml
+++ b/tests/auto/quick/qquickmousearea/data/hoverVisible.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/noclickandhold.qml b/tests/auto/quick/qquickmousearea/data/noclickandhold.qml
index 6647de001d..6647de001d 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/noclickandhold.qml
+++ b/tests/auto/quick/qquickmousearea/data/noclickandhold.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/pressedCanceled.qml b/tests/auto/quick/qquickmousearea/data/pressedCanceled.qml
index 231436d0f2..231436d0f2 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/pressedCanceled.qml
+++ b/tests/auto/quick/qquickmousearea/data/pressedCanceled.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/pressedOrdering.qml b/tests/auto/quick/qquickmousearea/data/pressedOrdering.qml
index 7aa3098100..7aa3098100 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/pressedOrdering.qml
+++ b/tests/auto/quick/qquickmousearea/data/pressedOrdering.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/preventstealing.qml b/tests/auto/quick/qquickmousearea/data/preventstealing.qml
index fb0d6955c1..fb0d6955c1 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/preventstealing.qml
+++ b/tests/auto/quick/qquickmousearea/data/preventstealing.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/rejectEvent.qml b/tests/auto/quick/qquickmousearea/data/rejectEvent.qml
index 816fc76fac..816fc76fac 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/rejectEvent.qml
+++ b/tests/auto/quick/qquickmousearea/data/rejectEvent.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnClick.qml b/tests/auto/quick/qquickmousearea/data/updateMousePosOnClick.qml
index 7377a2e86c..7377a2e86c 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnClick.qml
+++ b/tests/auto/quick/qquickmousearea/data/updateMousePosOnClick.qml
diff --git a/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnResize.qml b/tests/auto/quick/qquickmousearea/data/updateMousePosOnResize.qml
index 55af864060..55af864060 100644
--- a/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnResize.qml
+++ b/tests/auto/quick/qquickmousearea/data/updateMousePosOnResize.qml
diff --git a/tests/auto/quick/qquickmousearea/qquickmousearea.pro b/tests/auto/quick/qquickmousearea/qquickmousearea.pro
new file mode 100644
index 0000000000..c75db5ea55
--- /dev/null
+++ b/tests/auto/quick/qquickmousearea/qquickmousearea.pro
@@ -0,0 +1,17 @@
+CONFIG += testcase
+TARGET = tst_qquickmousearea
+macx:CONFIG -= app_bundle
+
+HEADERS += ../../shared/testhttpserver.h
+SOURCES += tst_qquickmousearea.cpp \
+ ../../shared/testhttpserver.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
new file mode 100644
index 0000000000..0fb82a66bc
--- /dev/null
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -0,0 +1,806 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <QtQuick/private/qquickmousearea_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <private/qquickflickable_p.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlengine.h>
+#include <QtOpenGL/QGLShaderProgram>
+#include "../../shared/util.h"
+
+//#define OLDWAY
+
+class tst_QQuickMouseArea: public QQmlDataTest
+{
+ Q_OBJECT
+private slots:
+ void dragProperties();
+ void resetDrag();
+ void dragging();
+ void updateMouseAreaPosOnClick();
+ void updateMouseAreaPosOnResize();
+ void noOnClickedWithPressAndHold();
+ void onMousePressRejected();
+ void pressedCanceledOnWindowDeactivate();
+ void doubleClick();
+ void clickTwice();
+ void pressedOrdering();
+ void preventStealing();
+ void clickThrough();
+ void hoverPosition();
+ void hoverPropagation();
+ void hoverVisible();
+
+private:
+ QQuickView *createView();
+};
+
+void tst_QQuickMouseArea::dragProperties()
+{
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("dragproperties.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QQuickDrag *drag = mouseRegion->drag();
+ QVERIFY(mouseRegion != 0);
+ QVERIFY(drag != 0);
+
+ // target
+ QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+ QVERIFY(blackRect == drag->target());
+ QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootItem != 0);
+ QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
+ drag->setTarget(rootItem);
+ QCOMPARE(targetSpy.count(),1);
+ drag->setTarget(rootItem);
+ QCOMPARE(targetSpy.count(),1);
+
+ // axis
+ QCOMPARE(drag->axis(), QQuickDrag::XandYAxis);
+ QSignalSpy axisSpy(drag, SIGNAL(axisChanged()));
+ drag->setAxis(QQuickDrag::XAxis);
+ QCOMPARE(drag->axis(), QQuickDrag::XAxis);
+ QCOMPARE(axisSpy.count(),1);
+ drag->setAxis(QQuickDrag::XAxis);
+ QCOMPARE(axisSpy.count(),1);
+
+ // minimum and maximum properties
+ QSignalSpy xminSpy(drag, SIGNAL(minimumXChanged()));
+ QSignalSpy xmaxSpy(drag, SIGNAL(maximumXChanged()));
+ QSignalSpy yminSpy(drag, SIGNAL(minimumYChanged()));
+ QSignalSpy ymaxSpy(drag, SIGNAL(maximumYChanged()));
+
+ QCOMPARE(drag->xmin(), 0.0);
+ QCOMPARE(drag->xmax(), rootItem->width()-blackRect->width());
+ QCOMPARE(drag->ymin(), 0.0);
+ QCOMPARE(drag->ymax(), rootItem->height()-blackRect->height());
+
+ drag->setXmin(10);
+ drag->setXmax(10);
+ drag->setYmin(10);
+ drag->setYmax(10);
+
+ QCOMPARE(drag->xmin(), 10.0);
+ QCOMPARE(drag->xmax(), 10.0);
+ QCOMPARE(drag->ymin(), 10.0);
+ QCOMPARE(drag->ymax(), 10.0);
+
+ QCOMPARE(xminSpy.count(),1);
+ QCOMPARE(xmaxSpy.count(),1);
+ QCOMPARE(yminSpy.count(),1);
+ QCOMPARE(ymaxSpy.count(),1);
+
+ drag->setXmin(10);
+ drag->setXmax(10);
+ drag->setYmin(10);
+ drag->setYmax(10);
+
+ QCOMPARE(xminSpy.count(),1);
+ QCOMPARE(xmaxSpy.count(),1);
+ QCOMPARE(yminSpy.count(),1);
+ QCOMPARE(ymaxSpy.count(),1);
+
+ // filterChildren
+ QSignalSpy filterChildrenSpy(drag, SIGNAL(filterChildrenChanged()));
+
+ drag->setFilterChildren(true);
+
+ QVERIFY(drag->filterChildren());
+ QCOMPARE(filterChildrenSpy.count(), 1);
+
+ drag->setFilterChildren(true);
+ QCOMPARE(filterChildrenSpy.count(), 1);
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::resetDrag()
+{
+ QQuickView *canvas = createView();
+
+ canvas->rootContext()->setContextProperty("haveTarget", QVariant(true));
+ canvas->setSource(testFileUrl("dragreset.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QQuickDrag *drag = mouseRegion->drag();
+ QVERIFY(mouseRegion != 0);
+ QVERIFY(drag != 0);
+
+ // target
+ QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+ QVERIFY(blackRect == drag->target());
+ QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootItem != 0);
+ QSignalSpy targetSpy(drag, SIGNAL(targetChanged()));
+ QVERIFY(drag->target() != 0);
+ canvas->rootContext()->setContextProperty("haveTarget", QVariant(false));
+ QCOMPARE(targetSpy.count(),1);
+ QVERIFY(drag->target() == 0);
+
+ delete canvas;
+}
+
+
+void tst_QQuickMouseArea::dragging()
+{
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("dragging.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWait(20);
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QQuickDrag *drag = mouseRegion->drag();
+ QVERIFY(mouseRegion != 0);
+ QVERIFY(drag != 0);
+
+ // target
+ QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+ QVERIFY(blackRect == drag->target());
+
+ QVERIFY(!drag->active());
+
+#ifdef OLDWAY
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+#else
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+#endif
+
+ QVERIFY(!drag->active());
+ QCOMPARE(blackRect->x(), 50.0);
+ QCOMPARE(blackRect->y(), 50.0);
+
+ // First move event triggers drag, second is acted upon.
+ // This is due to possibility of higher stacked area taking precedence.
+
+ QTest::mouseMove(canvas, QPoint(111,111));
+ QTest::qWait(50);
+ QTest::mouseMove(canvas, QPoint(122,122));
+ QTest::qWait(50);
+
+ QVERIFY(drag->active());
+ QCOMPARE(blackRect->x(), 72.0);
+ QCOMPARE(blackRect->y(), 72.0);
+
+#ifdef OLDWAY
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+#else
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(122,122));
+ QTest::qWait(50);
+#endif
+
+ QVERIFY(!drag->active());
+ QCOMPARE(blackRect->x(), 72.0);
+ QCOMPARE(blackRect->y(), 72.0);
+
+ delete canvas;
+}
+
+QQuickView *tst_QQuickMouseArea::createView()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setBaseSize(QSize(240,320));
+
+ return canvas;
+}
+
+void tst_QQuickMouseArea::updateMouseAreaPosOnClick()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("updateMousePosOnClick.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QVERIFY(mouseRegion != 0);
+
+ QQuickRectangle *rect = canvas->rootObject()->findChild<QQuickRectangle*>("ball");
+ QVERIFY(rect != 0);
+
+ QCOMPARE(mouseRegion->mouseX(), rect->x());
+ QCOMPARE(mouseRegion->mouseY(), rect->y());
+
+ QMouseEvent event(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &event);
+
+ QCOMPARE(mouseRegion->mouseX(), 100.0);
+ QCOMPARE(mouseRegion->mouseY(), 100.0);
+
+ QCOMPARE(mouseRegion->mouseX(), rect->x());
+ QCOMPARE(mouseRegion->mouseY(), rect->y());
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::updateMouseAreaPosOnResize()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("updateMousePosOnResize.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion");
+ QVERIFY(mouseRegion != 0);
+
+ QQuickRectangle *rect = canvas->rootObject()->findChild<QQuickRectangle*>("brother");
+ QVERIFY(rect != 0);
+
+ QCOMPARE(mouseRegion->mouseX(), 0.0);
+ QCOMPARE(mouseRegion->mouseY(), 0.0);
+
+ QMouseEvent event(QEvent::MouseButtonPress, rect->pos().toPoint(), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &event);
+
+ QVERIFY(!mouseRegion->property("emitPositionChanged").toBool());
+ QVERIFY(mouseRegion->property("mouseMatchesPos").toBool());
+
+ QCOMPARE(mouseRegion->property("x1").toReal(), 0.0);
+ QCOMPARE(mouseRegion->property("y1").toReal(), 0.0);
+
+ QCOMPARE(mouseRegion->property("x2").toReal(), rect->x());
+ QCOMPARE(mouseRegion->property("y2").toReal(), rect->y());
+
+ QCOMPARE(mouseRegion->mouseX(), rect->x());
+ QCOMPARE(mouseRegion->mouseY(), rect->y());
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::noOnClickedWithPressAndHold()
+{
+ {
+ // We handle onPressAndHold, therefore no onClicked
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("clickandhold.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QVERIFY(!canvas->rootObject()->property("clicked").toBool());
+ QVERIFY(!canvas->rootObject()->property("held").toBool());
+
+ QTest::qWait(1000);
+
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+
+ QVERIFY(!canvas->rootObject()->property("clicked").toBool());
+ QVERIFY(canvas->rootObject()->property("held").toBool());
+
+ delete canvas;
+ }
+
+ {
+ // We do not handle onPressAndHold, therefore we get onClicked
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("noclickandhold.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QVERIFY(!canvas->rootObject()->property("clicked").toBool());
+
+ QTest::qWait(1000);
+
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+
+ QVERIFY(canvas->rootObject()->property("clicked").toBool());
+
+ delete canvas;
+ }
+}
+
+void tst_QQuickMouseArea::onMousePressRejected()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("rejectEvent.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+ QVERIFY(canvas->rootObject()->property("enabled").toBool());
+
+ QVERIFY(!canvas->rootObject()->property("mr1_pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr1_released").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr2_pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr2_canceled").toBool());
+
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QVERIFY(canvas->rootObject()->property("mr1_pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr1_released").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
+ QVERIFY(canvas->rootObject()->property("mr2_pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
+ QVERIFY(canvas->rootObject()->property("mr2_canceled").toBool());
+
+ QTest::qWait(200);
+
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+
+ QVERIFY(canvas->rootObject()->property("mr1_released").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool());
+ QVERIFY(!canvas->rootObject()->property("mr2_released").toBool());
+
+ delete canvas;
+}
+void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("pressedCanceled.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+ QVERIFY(!canvas->rootObject()->property("pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("canceled").toBool());
+ QVERIFY(!canvas->rootObject()->property("released").toBool());
+
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QVERIFY(canvas->rootObject()->property("pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("canceled").toBool());
+ QVERIFY(!canvas->rootObject()->property("released").toBool());
+
+ QTest::qWait(200);
+
+ QEvent windowDeactivateEvent(QEvent::WindowDeactivate);
+ QGuiApplication::sendEvent(canvas, &windowDeactivateEvent);
+ QVERIFY(!canvas->rootObject()->property("pressed").toBool());
+ QVERIFY(canvas->rootObject()->property("canceled").toBool());
+ QVERIFY(!canvas->rootObject()->property("released").toBool());
+
+ QTest::qWait(200);
+
+ //press again
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+ QVERIFY(canvas->rootObject()->property("pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("canceled").toBool());
+ QVERIFY(!canvas->rootObject()->property("released").toBool());
+
+ QTest::qWait(200);
+
+ //release
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+ QVERIFY(!canvas->rootObject()->property("pressed").toBool());
+ QVERIFY(!canvas->rootObject()->property("canceled").toBool());
+ QVERIFY(canvas->rootObject()->property("released").toBool());
+
+ delete canvas;
+}
+void tst_QQuickMouseArea::doubleClick()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("doubleclick.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+
+ QCOMPARE(canvas->rootObject()->property("released").toInt(), 1);
+
+ pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+
+ QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("doubleClicked").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("released").toInt(), 2);
+
+ delete canvas;
+}
+
+// QTBUG-14832
+void tst_QQuickMouseArea::clickTwice()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("clicktwice.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+
+ QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("released").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1);
+
+ pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+
+ QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 2);
+ QCOMPARE(canvas->rootObject()->property("released").toInt(), 2);
+ QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 2);
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::pressedOrdering()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("pressedOrdering.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("base"));
+
+ QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed"));
+
+ QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0);
+ QGuiApplication::sendEvent(canvas, &releaseEvent);
+
+ QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("toggled"));
+
+ QGuiApplication::sendEvent(canvas, &pressEvent);
+
+ QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed"));
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::preventStealing()
+{
+ QQuickView *canvas = createView();
+
+ canvas->setSource(testFileUrl("preventstealing.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(canvas->rootObject());
+ QVERIFY(flickable != 0);
+
+ QQuickMouseArea *mouseArea = canvas->rootObject()->findChild<QQuickMouseArea*>("mousearea");
+ QVERIFY(mouseArea != 0);
+
+ QSignalSpy mousePositionSpy(mouseArea, SIGNAL(positionChanged(QQuickMouseEvent*)));
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(80, 80));
+
+ // Without preventStealing, mouse movement over MouseArea would
+ // cause the Flickable to steal mouse and trigger content movement.
+
+ QTest::mouseMove(canvas,QPoint(69,69));
+ QTest::mouseMove(canvas,QPoint(58,58));
+ QTest::mouseMove(canvas,QPoint(47,47));
+
+ // We should have received all three move events
+ QCOMPARE(mousePositionSpy.count(), 3);
+ QVERIFY(mouseArea->pressed());
+
+ // Flickable content should not have moved.
+ QCOMPARE(flickable->contentX(), 0.);
+ QCOMPARE(flickable->contentY(), 0.);
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(47, 47));
+
+ // Now allow stealing and confirm Flickable does its thing.
+ canvas->rootObject()->setProperty("stealing", false);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(80, 80));
+
+ // Without preventStealing, mouse movement over MouseArea would
+ // cause the Flickable to steal mouse and trigger content movement.
+
+ QTest::mouseMove(canvas,QPoint(69,69));
+ QTest::mouseMove(canvas,QPoint(58,58));
+ QTest::mouseMove(canvas,QPoint(47,47));
+
+ // We should only have received the first move event
+ QCOMPARE(mousePositionSpy.count(), 4);
+ // Our press should be taken away
+ QVERIFY(!mouseArea->pressed());
+
+ // Flickable content should have moved.
+
+ QCOMPARE(flickable->contentX(), 11.);
+ QCOMPARE(flickable->contentY(), 11.);
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 50));
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::clickThrough()
+{
+ QSKIP("QTBUG-23976 Unstable");
+ //With no handlers defined click, doubleClick and PressAndHold should propagate to those with handlers
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("clickThrough.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
+
+ QTRY_COMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1);
+
+ QTest::qWait(800); // to avoid generating a double click.
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(1000);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
+
+ QTRY_COMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1);
+ QTRY_COMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
+
+ QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(100);
+
+ QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2);
+ QTRY_COMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
+
+ delete canvas;
+
+ //With handlers defined click, doubleClick and PressAndHold should propagate only when explicitly ignored
+ canvas = createView();
+ canvas->setSource(testFileUrl("clickThrough2.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
+
+ QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0);
+
+ QTest::qWait(800); // to avoid generating a double click.
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(1000);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(100);
+
+ QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 0);
+
+ QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(100);
+
+ QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 0);
+
+ canvas->rootObject()->setProperty("letThrough", QVariant(true));
+
+ QTest::qWait(800); // to avoid generating a double click.
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
+
+ QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1);
+
+ QTest::qWait(800); // to avoid generating a double click.
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(1000);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(100);
+
+ QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
+
+ QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(100);
+
+ QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2);
+ QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
+
+ canvas->rootObject()->setProperty("noPropagation", QVariant(true));
+
+ QTest::qWait(800); // to avoid generating a double click.
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
+
+ QTest::qWait(800); // to avoid generating a double click.
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(1000);
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(100);
+
+ QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100));
+ QTest::qWait(100);
+
+ QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0);
+ QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2);
+ QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1);
+ QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1);
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::hoverPosition()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("hoverPosition.qml"));
+
+ QQuickItem *root = canvas->rootObject();
+ QVERIFY(root != 0);
+
+ QCOMPARE(root->property("mouseX").toReal(), qreal(0));
+ QCOMPARE(root->property("mouseY").toReal(), qreal(0));
+
+ QTest::mouseMove(canvas,QPoint(10,32));
+
+
+ QCOMPARE(root->property("mouseX").toReal(), qreal(10));
+ QCOMPARE(root->property("mouseY").toReal(), qreal(32));
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::hoverPropagation()
+{
+ //QTBUG-18175, to behave like GV did.
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("hoverPropagation.qml"));
+
+ QQuickItem *root = canvas->rootObject();
+ QVERIFY(root != 0);
+
+ QCOMPARE(root->property("point1").toBool(), false);
+ QCOMPARE(root->property("point2").toBool(), false);
+
+ QMouseEvent moveEvent(QEvent::MouseMove, QPoint(32, 32), Qt::NoButton, Qt::NoButton, 0);
+ QGuiApplication::sendEvent(canvas, &moveEvent);
+
+ QCOMPARE(root->property("point1").toBool(), true);
+ QCOMPARE(root->property("point2").toBool(), false);
+
+ QMouseEvent moveEvent2(QEvent::MouseMove, QPoint(232, 32), Qt::NoButton, Qt::NoButton, 0);
+ QGuiApplication::sendEvent(canvas, &moveEvent2);
+ QCOMPARE(root->property("point1").toBool(), false);
+ QCOMPARE(root->property("point2").toBool(), true);
+
+ delete canvas;
+}
+
+void tst_QQuickMouseArea::hoverVisible()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("hoverVisible.qml"));
+
+ QQuickItem *root = canvas->rootObject();
+ QVERIFY(root != 0);
+
+ QQuickMouseArea *mouseTracker = canvas->rootObject()->findChild<QQuickMouseArea*>("mousetracker");
+ QVERIFY(mouseTracker != 0);
+
+ QSignalSpy enteredSpy(mouseTracker, SIGNAL(entered()));
+
+ QTest::mouseMove(canvas,QPoint(10,32));
+
+ QCOMPARE(mouseTracker->hovered(), false);
+ QCOMPARE(enteredSpy.count(), 0);
+
+ mouseTracker->setVisible(true);
+
+ QCOMPARE(mouseTracker->hovered(), true);
+ QCOMPARE(enteredSpy.count(), 1);
+
+ QEXPECT_FAIL("", "QTBUG-24282", Continue);
+ QCOMPARE(QPointF(mouseTracker->mouseX(), mouseTracker->mouseY()), QPointF(10,32));
+
+ delete canvas;
+}
+
+QTEST_MAIN(tst_QQuickMouseArea)
+
+#include "tst_qquickmousearea.moc"
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/basic.qml b/tests/auto/quick/qquickmultipointtoucharea/data/basic.qml
index cd6ce8146f..cd6ce8146f 100644
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/basic.qml
+++ b/tests/auto/quick/qquickmultipointtoucharea/data/basic.qml
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/inFlickable.qml b/tests/auto/quick/qquickmultipointtoucharea/data/inFlickable.qml
index 9c9132d0b0..9c9132d0b0 100644
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/inFlickable.qml
+++ b/tests/auto/quick/qquickmultipointtoucharea/data/inFlickable.qml
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/nested.qml b/tests/auto/quick/qquickmultipointtoucharea/data/nested.qml
index 37b8820aa0..37b8820aa0 100644
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/nested.qml
+++ b/tests/auto/quick/qquickmultipointtoucharea/data/nested.qml
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/nonOverlapping.qml b/tests/auto/quick/qquickmultipointtoucharea/data/nonOverlapping.qml
index 039607e26c..039607e26c 100644
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/nonOverlapping.qml
+++ b/tests/auto/quick/qquickmultipointtoucharea/data/nonOverlapping.qml
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/properties.qml b/tests/auto/quick/qquickmultipointtoucharea/data/properties.qml
index 98ef1a9cbe..98ef1a9cbe 100644
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/properties.qml
+++ b/tests/auto/quick/qquickmultipointtoucharea/data/properties.qml
diff --git a/tests/auto/qtquick2/qquickmultipointtoucharea/data/signalTest.qml b/tests/auto/quick/qquickmultipointtoucharea/data/signalTest.qml
index 54b160c182..54b160c182 100644
--- a/tests/auto/qtquick2/qquickmultipointtoucharea/data/signalTest.qml
+++ b/tests/auto/quick/qquickmultipointtoucharea/data/signalTest.qml
diff --git a/tests/auto/quick/qquickmultipointtoucharea/qquickmultipointtoucharea.pro b/tests/auto/quick/qquickmultipointtoucharea/qquickmultipointtoucharea.pro
new file mode 100644
index 0000000000..3c6f304284
--- /dev/null
+++ b/tests/auto/quick/qquickmultipointtoucharea/qquickmultipointtoucharea.pro
@@ -0,0 +1,11 @@
+TARGET = tst_qquickmultipointtoucharea
+CONFIG += testcase
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickmultipointtoucharea.cpp
+
+importFiles.files = data
+importFiles.path = .
+DEPLOYMENT += importFiles
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
new file mode 100644
index 0000000000..507612f8ce
--- /dev/null
+++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp
@@ -0,0 +1,727 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <private/qquickmultipointtoucharea_p.h>
+#include <private/qquickflickable_p.h>
+#include <QtQuick/qquickview.h>
+
+class tst_QQuickMultiPointTouchArea: public QObject
+{
+ Q_OBJECT
+public:
+ tst_QQuickMultiPointTouchArea() : device(0) { }
+private slots:
+ void initTestCase() {
+ if (!device) {
+ device = new QTouchDevice;
+ device->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(device);
+ }
+ }
+ void cleanupTestCase() {}
+
+ void properties();
+ void signalTest();
+ void release();
+ void reuse();
+ void nonOverlapping();
+ void nested();
+ void inFlickable();
+ void invisible();
+
+private:
+ QQuickView *createAndShowView(const QString &file);
+ QTouchDevice *device;
+};
+
+void tst_QQuickMultiPointTouchArea::properties()
+{
+ QQuickView *canvas = createAndShowView("properties.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickMultiPointTouchArea *area = qobject_cast<QQuickMultiPointTouchArea *>(canvas->rootObject());
+ QVERIFY(area != 0);
+
+ QCOMPARE(area->minimumTouchPoints(), 2);
+ QCOMPARE(area->maximumTouchPoints(), 4);
+
+ QQmlListReference ref(area, "touchPoints");
+ QCOMPARE(ref.count(), 4);
+
+ delete canvas;
+}
+
+void tst_QQuickMultiPointTouchArea::signalTest()
+{
+ QQuickView *canvas = createAndShowView("signalTest.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickMultiPointTouchArea *area = qobject_cast<QQuickMultiPointTouchArea *>(canvas->rootObject());
+ QVERIFY(area != 0);
+
+ QPoint p1(20,100);
+ QPoint p2(40,100);
+ QPoint p3(60,100);
+ QPoint p4(80,100);
+ QPoint p5(100,100);
+
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
+
+ sequence.press(0, p1).press(1, p2).commit();
+
+ QCOMPARE(area->property("touchPointPressCount").toInt(), 2);
+ QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
+ QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
+ QCOMPARE(area->property("touchCount").toInt(), 2);
+ QMetaObject::invokeMethod(area, "clearCounts");
+
+ sequence.stationary(0).stationary(1).press(2, p3).commit();
+
+ QCOMPARE(area->property("touchPointPressCount").toInt(), 1);
+ QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
+ QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
+ QCOMPARE(area->property("touchCount").toInt(), 3);
+ QMetaObject::invokeMethod(area, "clearCounts");
+
+ p1 -= QPoint(10,10);
+ p2 += QPoint(10,10);
+ sequence.move(0, p1).move(1, p2).stationary(2).commit();
+
+ QCOMPARE(area->property("touchPointPressCount").toInt(), 0);
+ QCOMPARE(area->property("touchPointUpdateCount").toInt(), 2);
+ QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
+ QCOMPARE(area->property("touchCount").toInt(), 3);
+ QMetaObject::invokeMethod(area, "clearCounts");
+
+ p3 += QPoint(10,10);
+ sequence.release(0, p1).release(1, p2)
+ .move(2, p3).press(3, p4).press(4, p5).commit();
+
+ QCOMPARE(area->property("touchPointPressCount").toInt(), 2);
+ QCOMPARE(area->property("touchPointUpdateCount").toInt(), 1);
+ QCOMPARE(area->property("touchPointReleaseCount").toInt(), 2);
+ QCOMPARE(area->property("touchCount").toInt(), 3);
+ QMetaObject::invokeMethod(area, "clearCounts");
+
+ sequence.release(2, p3).release(3, p4).release(4, p5).commit();
+
+ QCOMPARE(area->property("touchPointPressCount").toInt(), 0);
+ QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
+ QCOMPARE(area->property("touchPointReleaseCount").toInt(), 3);
+ QCOMPARE(area->property("touchCount").toInt(), 0);
+ QCOMPARE(area->property("touchUpdatedHandled").toBool(), true);
+ QMetaObject::invokeMethod(area, "clearCounts");
+
+ delete canvas;
+}
+
+void tst_QQuickMultiPointTouchArea::release()
+{
+ QQuickView *canvas = createAndShowView("basic.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickTouchPoint *point1 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point1");
+
+ QCOMPARE(point1->pressed(), false);
+
+ QPoint p1(20,100);
+
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
+
+ sequence.press(0, p1).commit();
+
+ QCOMPARE(point1->pressed(), true);
+
+ p1 += QPoint(0,10);
+
+ sequence.move(0, p1).commit();
+
+ QCOMPARE(point1->pressed(), true);
+ QCOMPARE(point1->x(), qreal(20)); QCOMPARE(point1->y(), qreal(110));
+
+ p1 += QPoint(4,10);
+
+ sequence.release(0, p1).commit();
+
+ //test that a release without a prior move to the release position successfully updates the point's position
+ QCOMPARE(point1->pressed(), false);
+ QCOMPARE(point1->x(), qreal(24)); QCOMPARE(point1->y(), qreal(120));
+
+ delete canvas;
+}
+
+void tst_QQuickMultiPointTouchArea::reuse()
+{
+ QQuickView *canvas = createAndShowView("basic.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickTouchPoint *point1 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point1");
+ QQuickTouchPoint *point2 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point2");
+ QQuickTouchPoint *point3 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point3");
+
+ QCOMPARE(point1->pressed(), false);
+ QCOMPARE(point2->pressed(), false);
+
+ QPoint p1(20,100);
+ QPoint p2(40,100);
+ QPoint p3(60,100);
+ QPoint p4(80,100);
+
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
+
+ sequence.press(0, p1).press(1, p2).commit();
+
+ QCOMPARE(point1->pressed(), true);
+ QCOMPARE(point2->pressed(), true);
+ QCOMPARE(point3->pressed(), false);
+
+ sequence.release(0, p1).stationary(1).press(2, p3).commit();
+
+ //we shouldn't reuse point 1 yet
+ QCOMPARE(point1->pressed(), false);
+ QCOMPARE(point2->pressed(), true);
+ QCOMPARE(point3->pressed(), true);
+
+ //back to base state (no touches)
+ sequence.release(1, p2).release(2, p3).commit();
+
+ QCOMPARE(point1->pressed(), false);
+ QCOMPARE(point2->pressed(), false);
+ QCOMPARE(point3->pressed(), false);
+
+ sequence.press(0, p1).press(1, p2).commit();
+
+ QCOMPARE(point1->pressed(), true);
+ QCOMPARE(point2->pressed(), true);
+ QCOMPARE(point3->pressed(), false);
+
+ sequence.release(0, p1).stationary(1).commit();
+
+ QCOMPARE(point1->pressed(), false);
+ QCOMPARE(point2->pressed(), true);
+ QCOMPARE(point3->pressed(), false);
+
+ sequence.press(4, p4).stationary(1).commit();
+
+ //the new touch point should reuse point 1
+ QCOMPARE(point1->pressed(), true);
+ QCOMPARE(point2->pressed(), true);
+ QCOMPARE(point3->pressed(), false);
+
+ QCOMPARE(point1->x(), qreal(80)); QCOMPARE(point1->y(), qreal(100));
+
+ delete canvas;
+}
+
+void tst_QQuickMultiPointTouchArea::nonOverlapping()
+{
+ QQuickView *canvas = createAndShowView("nonOverlapping.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickTouchPoint *point11 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point11");
+ QQuickTouchPoint *point12 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point12");
+ QQuickTouchPoint *point21 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point21");
+ QQuickTouchPoint *point22 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point22");
+ QQuickTouchPoint *point23 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point23");
+
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ QPoint p1(20,100);
+ QPoint p2(40,100);
+ QPoint p3(60,180);
+ QPoint p4(80,180);
+ QPoint p5(100,180);
+
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
+
+ sequence.press(0, p1).commit();
+
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ sequence.stationary(0).press(1, p2).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(100));
+ QCOMPARE(point12->x(), qreal(40)); QCOMPARE(point12->y(), qreal(100));
+
+ p1 += QPoint(0,10);
+ p2 += QPoint(5,0);
+ sequence.move(0, p1).move(1, p2).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
+ QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
+
+ sequence.stationary(0).stationary(1).press(2, p3).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ sequence.stationary(0).stationary(1).stationary(2).press(3, p4).press(4, p5).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
+ QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
+ QCOMPARE(point21->x(), qreal(60)); QCOMPARE(point21->y(), qreal(20));
+ QCOMPARE(point22->x(), qreal(80)); QCOMPARE(point22->y(), qreal(20));
+ QCOMPARE(point23->x(), qreal(100)); QCOMPARE(point23->y(), qreal(20));
+
+ p1 += QPoint(4,10);
+ p2 += QPoint(17,17);
+ p3 += QPoint(3,0);
+ p4 += QPoint(1,-1);
+ p5 += QPoint(-7,10);
+ sequence.move(0, p1).move(1, p2).move(2, p3).move(3, p4).move(4, p5).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ QCOMPARE(point11->x(), qreal(24)); QCOMPARE(point11->y(), qreal(120));
+ QCOMPARE(point12->x(), qreal(62)); QCOMPARE(point12->y(), qreal(117));
+ QCOMPARE(point21->x(), qreal(63)); QCOMPARE(point21->y(), qreal(20));
+ QCOMPARE(point22->x(), qreal(81)); QCOMPARE(point22->y(), qreal(19));
+ QCOMPARE(point23->x(), qreal(93)); QCOMPARE(point23->y(), qreal(30));
+
+ sequence.release(0, p1).release(1, p2).release(2, p3).release(3, p4).release(4, p5).commit();
+
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ delete canvas;
+}
+
+void tst_QQuickMultiPointTouchArea::nested()
+{
+ QQuickView *canvas = createAndShowView("nested.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickTouchPoint *point11 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point11");
+ QQuickTouchPoint *point12 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point12");
+ QQuickTouchPoint *point21 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point21");
+ QQuickTouchPoint *point22 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point22");
+ QQuickTouchPoint *point23 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point23");
+
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ QPoint p1(20,100);
+ QPoint p2(40,100);
+ QPoint p3(60,180);
+
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
+
+ sequence.press(0, p1).commit();
+
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ sequence.stationary(0).press(1, p2).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(100));
+ QCOMPARE(point12->x(), qreal(40)); QCOMPARE(point12->y(), qreal(100));
+
+ p1 += QPoint(0,10);
+ p2 += QPoint(5,0);
+ sequence.move(0, p1).move(1, p2).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
+ QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
+
+ sequence.stationary(0).stationary(1).press(2, p3).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ //point11 should be same as point21, point12 same as point22
+ QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
+ QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
+ QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110));
+ QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100));
+ QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180));
+
+ sequence.stationary(0).stationary(1).stationary(2).press(3, QPoint(80,180)).press(4, QPoint(100,180)).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ //new touch points should be ignored (have no impact on our existing touch points)
+ QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
+ QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
+ QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110));
+ QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100));
+ QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180));
+
+ sequence.stationary(0).stationary(1).stationary(2).release(3, QPoint(80,180)).release(4, QPoint(100,180)).commit();
+
+ p1 += QPoint(4,10);
+ p2 += QPoint(17,17);
+ p3 += QPoint(3,0);
+ sequence.move(0, p1).move(1, p2).move(2, p3).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120));
+ QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117));
+ QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120));
+ QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117));
+ QCOMPARE(point23->x(), qreal(63)); QCOMPARE(point23->y(), qreal(180));
+
+ p1 += QPoint(4,10);
+ p2 += QPoint(17,17);
+ p3 += QPoint(3,0);
+ sequence.move(0, p1).move(1, p2).move(2, p3).commit();
+
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ //first two remain the same (touches now grabbed by inner touch area)
+ QCOMPARE(point11->x(), qreal(24)); QCOMPARE(point11->y(), qreal(120));
+ QCOMPARE(point12->x(), qreal(62)); QCOMPARE(point12->y(), qreal(117));
+ QCOMPARE(point21->x(), qreal(28)); QCOMPARE(point21->y(), qreal(130));
+ QCOMPARE(point22->x(), qreal(79)); QCOMPARE(point22->y(), qreal(134));
+ QCOMPARE(point23->x(), qreal(66)); QCOMPARE(point23->y(), qreal(180));
+
+ sequence.release(0, p1).release(1, p2).release(2, p3).commit();
+
+ sequence.press(0, p1).commit();
+
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+ QCOMPARE(point21->pressed(), false);
+ QCOMPARE(point22->pressed(), false);
+ QCOMPARE(point23->pressed(), false);
+
+ sequence.release(0, p1).commit();
+
+ //test with grabbing turned off
+ canvas->rootObject()->setProperty("grabInnerArea", false);
+
+ sequence.press(0, p1).press(1, p2).press(2, p3).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ p1 -= QPoint(4,10);
+ p2 -= QPoint(17,17);
+ p3 -= QPoint(3,0);
+ sequence.move(0, p1).move(1, p2).move(2, p3).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120));
+ QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117));
+ QCOMPARE(point21->x(), qreal(24)); QCOMPARE(point21->y(), qreal(120));
+ QCOMPARE(point22->x(), qreal(62)); QCOMPARE(point22->y(), qreal(117));
+ QCOMPARE(point23->x(), qreal(63)); QCOMPARE(point23->y(), qreal(180));
+
+ p1 -= QPoint(4,10);
+ p2 -= QPoint(17,17);
+ p3 -= QPoint(3,0);
+ sequence.move(0, p1).move(1, p2).move(2, p3).commit();
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(point21->pressed(), true);
+ QCOMPARE(point22->pressed(), true);
+ QCOMPARE(point23->pressed(), true);
+
+ //all change (touches not grabbed by inner touch area)
+ QCOMPARE(point11->x(), qreal(20)); QCOMPARE(point11->y(), qreal(110));
+ QCOMPARE(point12->x(), qreal(45)); QCOMPARE(point12->y(), qreal(100));
+ QCOMPARE(point21->x(), qreal(20)); QCOMPARE(point21->y(), qreal(110));
+ QCOMPARE(point22->x(), qreal(45)); QCOMPARE(point22->y(), qreal(100));
+ QCOMPARE(point23->x(), qreal(60)); QCOMPARE(point23->y(), qreal(180));
+
+ sequence.release(0, p1).release(1, p2).release(2, p3).commit();
+
+ delete canvas;
+}
+
+void tst_QQuickMultiPointTouchArea::inFlickable()
+{
+ QQuickView *canvas = createAndShowView("inFlickable.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable *>(canvas->rootObject());
+ QVERIFY(flickable != 0);
+
+ QQuickTouchPoint *point11 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point1");
+ QQuickTouchPoint *point12 = canvas->rootObject()->findChild<QQuickTouchPoint*>("point2");
+
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+
+ QPoint p1(20,100);
+ QPoint p2(40,100);
+
+ //moving one point vertically
+ QTest::touchEvent(canvas, device).press(0, p1);
+ QTest::mousePress(canvas, Qt::LeftButton, 0, p1);
+
+ p1 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1);
+ QTest::mouseMove(canvas, p1);
+
+ QVERIFY(flickable->contentY() < 0);
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+
+ QTest::touchEvent(canvas, device).release(0, p1);
+ QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1);
+ QTest::qWait(50);
+
+ QTRY_VERIFY(!flickable->isMoving());
+
+ //moving two points vertically
+ p1 = QPoint(20,100);
+ QTest::touchEvent(canvas, device).press(0, p1).press(1, p2);
+ QTest::mousePress(canvas, Qt::LeftButton, 0, p1);
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+ QCOMPARE(flickable->property("cancelCount").toInt(), 0);
+ QCOMPARE(flickable->property("touchCount").toInt(), 2);
+
+ p1 += QPoint(0,15); p2 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15); p2 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15); p2 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15); p2 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ QVERIFY(flickable->contentY() < 0);
+ QCOMPARE(point11->pressed(), false);
+ QCOMPARE(point12->pressed(), false);
+ QCOMPARE(flickable->property("cancelCount").toInt(), 2);
+ QCOMPARE(flickable->property("touchCount").toInt(), 0);
+
+ QTest::touchEvent(canvas, device).release(0, p1).release(1, p2);
+ QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1);
+ QTest::qWait(50);
+
+ QTRY_VERIFY(!flickable->isMoving());
+
+ //moving two points horizontally, then one point vertically
+ p1 = QPoint(20,100);
+ p2 = QPoint(40,100);
+ QTest::touchEvent(canvas, device).press(0, p1).press(1, p2);
+ QTest::mousePress(canvas, Qt::LeftButton, 0, p1);
+
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+
+ p1 += QPoint(15,0); p2 += QPoint(15,0);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(15,0); p2 += QPoint(15,0);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(15,0); p2 += QPoint(15,0);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(15,0); p2 += QPoint(15,0);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15); p2 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15); p2 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15); p2 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ p1 += QPoint(0,15); p2 += QPoint(0,15);
+ QTest::touchEvent(canvas, device).move(0, p1).move(1, p2);
+ QTest::mouseMove(canvas, p1);
+
+ QVERIFY(flickable->contentY() == 0);
+ QCOMPARE(point11->pressed(), true);
+ QCOMPARE(point12->pressed(), true);
+
+ QTest::touchEvent(canvas, device).release(0, p1).release(1, p2);
+ QTest::mouseRelease(canvas,Qt::LeftButton, 0, p1);
+ QTest::qWait(50);
+
+ delete canvas;
+}
+
+// QTBUG-23327
+void tst_QQuickMultiPointTouchArea::invisible()
+{
+ QQuickView *canvas = createAndShowView("signalTest.qml");
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickMultiPointTouchArea *area = qobject_cast<QQuickMultiPointTouchArea *>(canvas->rootObject());
+ QVERIFY(area != 0);
+
+ area->setVisible(false);
+
+ QPoint p1(20,100);
+ QPoint p2(40,100);
+
+ QTest::QTouchEventSequence sequence = QTest::touchEvent(canvas, device);
+
+ sequence.press(0, p1).press(1, p2).commit();
+
+ QCOMPARE(area->property("touchPointPressCount").toInt(), 0);
+ QCOMPARE(area->property("touchPointUpdateCount").toInt(), 0);
+ QCOMPARE(area->property("touchPointReleaseCount").toInt(), 0);
+ QCOMPARE(area->property("touchCount").toInt(), 0);
+
+ delete canvas;
+}
+
+
+QQuickView *tst_QQuickMultiPointTouchArea::createAndShowView(const QString &file)
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setSource(QUrl::fromLocalFile(QCoreApplication::applicationDirPath() + QLatin1String("/data/") + file));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+
+ return canvas;
+}
+
+QTEST_MAIN(tst_QQuickMultiPointTouchArea)
+
+#include "tst_qquickmultipointtoucharea.moc"
diff --git a/tests/auto/qtquick2/qdeclarativepath/data/arc.qml b/tests/auto/quick/qquickpath/data/arc.qml
index 000221c784..000221c784 100644
--- a/tests/auto/qtquick2/qdeclarativepath/data/arc.qml
+++ b/tests/auto/quick/qquickpath/data/arc.qml
diff --git a/tests/auto/qtquick2/qdeclarativepath/data/closedcurve.qml b/tests/auto/quick/qquickpath/data/closedcurve.qml
index bb4a715e28..bb4a715e28 100644
--- a/tests/auto/qtquick2/qdeclarativepath/data/closedcurve.qml
+++ b/tests/auto/quick/qquickpath/data/closedcurve.qml
diff --git a/tests/auto/qtquick2/qdeclarativepath/data/curve.qml b/tests/auto/quick/qquickpath/data/curve.qml
index c571186496..c571186496 100644
--- a/tests/auto/qtquick2/qdeclarativepath/data/curve.qml
+++ b/tests/auto/quick/qquickpath/data/curve.qml
diff --git a/tests/auto/qtquick2/qdeclarativepath/data/svg.qml b/tests/auto/quick/qquickpath/data/svg.qml
index cec0f75061..cec0f75061 100644
--- a/tests/auto/qtquick2/qdeclarativepath/data/svg.qml
+++ b/tests/auto/quick/qquickpath/data/svg.qml
diff --git a/tests/auto/quick/qquickpath/qquickpath.pro b/tests/auto/quick/qquickpath/qquickpath.pro
new file mode 100644
index 0000000000..e1f0f7b278
--- /dev/null
+++ b/tests/auto/quick/qquickpath/qquickpath.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickpath
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickpath.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickpath/tst_qquickpath.cpp b/tests/auto/quick/qquickpath/tst_qquickpath.cpp
new file mode 100644
index 0000000000..73e7e6ea38
--- /dev/null
+++ b/tests/auto/quick/qquickpath/tst_qquickpath.cpp
@@ -0,0 +1,199 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/private/qquickpath_p.h>
+
+#include "../../shared/util.h"
+
+class tst_QuickPath : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QuickPath() {}
+
+private slots:
+ void arc();
+ void catmullromCurve();
+ void closedCatmullromCurve();
+ void svg();
+};
+
+void tst_QuickPath::arc()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("arc.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->startX(), 0.);
+ QCOMPARE(obj->startY(), 0.);
+
+ QQmlListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 1);
+
+ QQuickPathArc* arc = qobject_cast<QQuickPathArc*>(list.at(0));
+ QVERIFY(arc != 0);
+ QCOMPARE(arc->x(), 100.);
+ QCOMPARE(arc->y(), 100.);
+ QCOMPARE(arc->radiusX(), 100.);
+ QCOMPARE(arc->radiusY(), 100.);
+ QCOMPARE(arc->useLargeArc(), false);
+ QCOMPARE(arc->direction(), QQuickPathArc::Clockwise);
+
+ QPainterPath path = obj->path();
+ QVERIFY(path != QPainterPath());
+
+ QPointF pos = obj->pointAt(0);
+ QCOMPARE(pos, QPointF(0,0));
+ pos = obj->pointAt(.25);
+ QCOMPARE(pos.toPoint(), QPoint(39,8)); //fuzzy compare
+ pos = obj->pointAt(.75);
+ QCOMPARE(pos.toPoint(), QPoint(92,61)); //fuzzy compare
+ pos = obj->pointAt(1);
+ QCOMPARE(pos, QPointF(100,100));
+}
+
+void tst_QuickPath::catmullromCurve()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("curve.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->startX(), 0.);
+ QCOMPARE(obj->startY(), 0.);
+
+ QQmlListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 3);
+
+ QQuickPathCatmullRomCurve* curve = qobject_cast<QQuickPathCatmullRomCurve*>(list.at(0));
+ QVERIFY(curve != 0);
+ QCOMPARE(curve->x(), 100.);
+ QCOMPARE(curve->y(), 50.);
+
+ curve = qobject_cast<QQuickPathCatmullRomCurve*>(list.at(2));
+ QVERIFY(curve != 0);
+ QCOMPARE(curve->x(), 100.);
+ QCOMPARE(curve->y(), 150.);
+
+ QPainterPath path = obj->path();
+ QVERIFY(path != QPainterPath());
+
+ QPointF pos = obj->pointAt(0);
+ QCOMPARE(pos, QPointF(0,0));
+ pos = obj->pointAt(.25);
+ QCOMPARE(pos.toPoint(), QPoint(63,26)); //fuzzy compare
+ pos = obj->pointAt(.75);
+ QCOMPARE(pos.toPoint(), QPoint(51,105)); //fuzzy compare
+ pos = obj->pointAt(1);
+ QCOMPARE(pos, QPointF(100,150));
+}
+
+void tst_QuickPath::closedCatmullromCurve()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("closedcurve.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->startX(), 50.);
+ QCOMPARE(obj->startY(), 50.);
+
+ QQmlListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 3);
+
+ QQuickPathCatmullRomCurve* curve = qobject_cast<QQuickPathCatmullRomCurve*>(list.at(2));
+ QVERIFY(curve != 0);
+ QCOMPARE(curve->x(), 50.);
+ QCOMPARE(curve->y(), 50.);
+
+ QVERIFY(obj->isClosed());
+
+ QPainterPath path = obj->path();
+ QVERIFY(path != QPainterPath());
+
+ QPointF pos = obj->pointAt(0);
+ QCOMPARE(pos, QPointF(50,50));
+ pos = obj->pointAt(.1);
+ QCOMPARE(pos.toPoint(), QPoint(67,56)); //fuzzy compare
+ pos = obj->pointAt(.75);
+ QCOMPARE(pos.toPoint(), QPoint(44,116)); //fuzzy compare
+ pos = obj->pointAt(1);
+ QCOMPARE(pos, QPointF(50,50));
+}
+
+void tst_QuickPath::svg()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("svg.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->startX(), 0.);
+ QCOMPARE(obj->startY(), 0.);
+
+ QQmlListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 1);
+
+ QQuickPathSvg* svg = qobject_cast<QQuickPathSvg*>(list.at(0));
+ QVERIFY(svg != 0);
+ QCOMPARE(svg->path(), QLatin1String("M200,300 Q400,50 600,300 T1000,300"));
+
+ QPainterPath path = obj->path();
+ QVERIFY(path != QPainterPath());
+
+ QPointF pos = obj->pointAt(0);
+ QCOMPARE(pos, QPointF(200,300));
+ pos = obj->pointAt(.25);
+ QCOMPARE(pos.toPoint(), QPoint(400,175)); //fuzzy compare
+ pos = obj->pointAt(.75);
+ QCOMPARE(pos.toPoint(), QPoint(800,425)); //fuzzy compare
+ pos = obj->pointAt(1);
+ QCOMPARE(pos, QPointF(1000,300));
+}
+
+
+QTEST_MAIN(tst_QuickPath)
+
+#include "tst_qquickpath.moc"
diff --git a/tests/auto/qtquick2/qquickpathview/data/ComponentView.qml b/tests/auto/quick/qquickpathview/data/ComponentView.qml
index b61033d375..b61033d375 100644
--- a/tests/auto/qtquick2/qquickpathview/data/ComponentView.qml
+++ b/tests/auto/quick/qquickpathview/data/ComponentView.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/asyncloader.qml b/tests/auto/quick/qquickpathview/data/asyncloader.qml
index 94f560f3e7..94f560f3e7 100644
--- a/tests/auto/qtquick2/qquickpathview/data/asyncloader.qml
+++ b/tests/auto/quick/qquickpathview/data/asyncloader.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/closedPath.qml b/tests/auto/quick/qquickpathview/data/closedPath.qml
index 3ca34056c8..3ca34056c8 100644
--- a/tests/auto/qtquick2/qquickpathview/data/closedPath.qml
+++ b/tests/auto/quick/qquickpathview/data/closedPath.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/creationContext.qml b/tests/auto/quick/qquickpathview/data/creationContext.qml
index 79a682788b..79a682788b 100644
--- a/tests/auto/qtquick2/qquickpathview/data/creationContext.qml
+++ b/tests/auto/quick/qquickpathview/data/creationContext.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/datamodel.qml b/tests/auto/quick/qquickpathview/data/datamodel.qml
index 44f2aecc0a..44f2aecc0a 100644
--- a/tests/auto/qtquick2/qquickpathview/data/datamodel.qml
+++ b/tests/auto/quick/qquickpathview/data/datamodel.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/displaypath.qml b/tests/auto/quick/qquickpathview/data/displaypath.qml
index af0f381fc4..af0f381fc4 100644
--- a/tests/auto/qtquick2/qquickpathview/data/displaypath.qml
+++ b/tests/auto/quick/qquickpathview/data/displaypath.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/dragpath.qml b/tests/auto/quick/qquickpathview/data/dragpath.qml
index f9c6615b04..f9c6615b04 100644
--- a/tests/auto/qtquick2/qquickpathview/data/dragpath.qml
+++ b/tests/auto/quick/qquickpathview/data/dragpath.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/emptymodel.qml b/tests/auto/quick/qquickpathview/data/emptymodel.qml
index eb4d3006f4..eb4d3006f4 100644
--- a/tests/auto/qtquick2/qquickpathview/data/emptymodel.qml
+++ b/tests/auto/quick/qquickpathview/data/emptymodel.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/missingPercent.qml b/tests/auto/quick/qquickpathview/data/missingPercent.qml
index 97af8e8982..97af8e8982 100644
--- a/tests/auto/qtquick2/qquickpathview/data/missingPercent.qml
+++ b/tests/auto/quick/qquickpathview/data/missingPercent.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/openPath.qml b/tests/auto/quick/qquickpathview/data/openPath.qml
index 1bd8375d9e..1bd8375d9e 100644
--- a/tests/auto/qtquick2/qquickpathview/data/openPath.qml
+++ b/tests/auto/quick/qquickpathview/data/openPath.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathUpdate.qml b/tests/auto/quick/qquickpathview/data/pathUpdate.qml
index e729291025..e729291025 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathUpdate.qml
+++ b/tests/auto/quick/qquickpathview/data/pathUpdate.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathUpdateOnStartChanged.qml b/tests/auto/quick/qquickpathview/data/pathUpdateOnStartChanged.qml
index 89084b2a37..89084b2a37 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathUpdateOnStartChanged.qml
+++ b/tests/auto/quick/qquickpathview/data/pathUpdateOnStartChanged.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathline.qml b/tests/auto/quick/qquickpathview/data/pathline.qml
index 4c1c785bce..4c1c785bce 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathline.qml
+++ b/tests/auto/quick/qquickpathview/data/pathline.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathtest.qml b/tests/auto/quick/qquickpathview/data/pathtest.qml
index 736d58d2a9..736d58d2a9 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathtest.qml
+++ b/tests/auto/quick/qquickpathview/data/pathtest.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathview0.qml b/tests/auto/quick/qquickpathview/data/pathview0.qml
index 8b9378163f..8b9378163f 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathview0.qml
+++ b/tests/auto/quick/qquickpathview/data/pathview0.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathview1.qml b/tests/auto/quick/qquickpathview/data/pathview1.qml
index 53d375e596..53d375e596 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathview1.qml
+++ b/tests/auto/quick/qquickpathview/data/pathview1.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathview2.qml b/tests/auto/quick/qquickpathview/data/pathview2.qml
index 1d279c42a0..1d279c42a0 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathview2.qml
+++ b/tests/auto/quick/qquickpathview/data/pathview2.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathview3.qml b/tests/auto/quick/qquickpathview/data/pathview3.qml
index ded5a3911c..ded5a3911c 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathview3.qml
+++ b/tests/auto/quick/qquickpathview/data/pathview3.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/pathview_package.qml b/tests/auto/quick/qquickpathview/data/pathview_package.qml
index 2af57e6bb1..2af57e6bb1 100644
--- a/tests/auto/qtquick2/qquickpathview/data/pathview_package.qml
+++ b/tests/auto/quick/qquickpathview/data/pathview_package.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/propertychanges.qml b/tests/auto/quick/qquickpathview/data/propertychanges.qml
index 09b309f86f..09b309f86f 100644
--- a/tests/auto/qtquick2/qquickpathview/data/propertychanges.qml
+++ b/tests/auto/quick/qquickpathview/data/propertychanges.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/treemodel.qml b/tests/auto/quick/qquickpathview/data/treemodel.qml
index fcf6922d00..fcf6922d00 100644
--- a/tests/auto/qtquick2/qquickpathview/data/treemodel.qml
+++ b/tests/auto/quick/qquickpathview/data/treemodel.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/undefinedpath.qml b/tests/auto/quick/qquickpathview/data/undefinedpath.qml
index 674e7cca8d..674e7cca8d 100644
--- a/tests/auto/qtquick2/qquickpathview/data/undefinedpath.qml
+++ b/tests/auto/quick/qquickpathview/data/undefinedpath.qml
diff --git a/tests/auto/qtquick2/qquickpathview/data/vdm.qml b/tests/auto/quick/qquickpathview/data/vdm.qml
index 839393d9bd..839393d9bd 100644
--- a/tests/auto/qtquick2/qquickpathview/data/vdm.qml
+++ b/tests/auto/quick/qquickpathview/data/vdm.qml
diff --git a/tests/auto/quick/qquickpathview/qquickpathview.pro b/tests/auto/quick/qquickpathview/qquickpathview.pro
new file mode 100644
index 0000000000..52f00ce3f8
--- /dev/null
+++ b/tests/auto/quick/qquickpathview/qquickpathview.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickpathview
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickpathview.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private quick-private widgets testlib
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
new file mode 100644
index 0000000000..8866cafd80
--- /dev/null
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -0,0 +1,1458 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlincubator.h>
+#include <QtQuick/private/qquickpathview_p.h>
+#include <QtQuick/private/qquickpath_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQml/private/qquicklistmodel_p.h>
+#include <QtQml/private/qqmlvaluetype_p.h>
+#include <QStringListModel>
+#include <QStandardItemModel>
+#include <QFile>
+
+#include "../../shared/util.h"
+#include "../shared/viewtestutil.h"
+#include "../shared/visualtestutil.h"
+
+using namespace QQuickViewTestUtil;
+using namespace QQuickVisualTestUtil;
+
+
+static void initStandardTreeModel(QStandardItemModel *model)
+{
+ QStandardItem *item;
+ item = new QStandardItem(QLatin1String("Row 1 Item"));
+ model->insertRow(0, item);
+
+ item = new QStandardItem(QLatin1String("Row 2 Item"));
+ item->setCheckable(true);
+ model->insertRow(1, item);
+
+ QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item"));
+ item->setChild(0, childItem);
+
+ item = new QStandardItem(QLatin1String("Row 3 Item"));
+ item->setIcon(QIcon());
+ model->insertRow(2, item);
+}
+
+
+class tst_QQuickPathView : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickPathView();
+
+private slots:
+ void initValues();
+ void items();
+ void dataModel();
+ void pathview2();
+ void pathview3();
+ void insertModel_data();
+ void insertModel();
+ void removeModel_data();
+ void removeModel();
+ void moveModel_data();
+ void moveModel();
+ void path();
+ void pathMoved();
+ void setCurrentIndex();
+ void resetModel();
+ void propertyChanges();
+ void pathChanges();
+ void componentChanges();
+ void modelChanges();
+ void pathUpdateOnStartChanged();
+ void package();
+ void emptyModel();
+ void closed();
+ void pathUpdate();
+ void visualDataModel();
+ void undefinedPath();
+ void mouseDrag();
+ void treeModel();
+ void changePreferredHighlight();
+ void missingPercent();
+ void creationContext();
+ void currentOffsetOnInsertion();
+ void asynchronous();
+};
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool error READ error WRITE setError)
+ Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged)
+ Q_PROPERTY(int pathItemCount READ pathItemCount NOTIFY pathItemCountChanged)
+
+public:
+ TestObject() : QObject(), mError(true), mUseModel(true), mPathItemCount(-1) {}
+
+ bool error() const { return mError; }
+ void setError(bool err) { mError = err; }
+
+ bool useModel() const { return mUseModel; }
+ void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); }
+
+ int pathItemCount() const { return mPathItemCount; }
+ void setPathItemCount(int count) { mPathItemCount = count; emit pathItemCountChanged(); }
+
+signals:
+ void useModelChanged();
+ void pathItemCountChanged();
+
+private:
+ bool mError;
+ bool mUseModel;
+ int mPathItemCount;
+};
+
+tst_QQuickPathView::tst_QQuickPathView()
+{
+}
+
+void tst_QQuickPathView::initValues()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathview1.qml"));
+ QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->path() == 0);
+ QVERIFY(obj->delegate() == 0);
+ QCOMPARE(obj->model(), QVariant());
+ QCOMPARE(obj->currentIndex(), 0);
+ QCOMPARE(obj->offset(), 0.);
+ QCOMPARE(obj->preferredHighlightBegin(), 0.);
+ QCOMPARE(obj->dragMargin(), 0.);
+ QCOMPARE(obj->count(), 0);
+ QCOMPARE(obj->pathItemCount(), -1);
+
+ delete obj;
+}
+
+void tst_QQuickPathView::items()
+{
+ QQuickView *canvas = createView();
+
+ QaimModel model;
+ model.addItem("Fred", "12345");
+ model.addItem("John", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Bill", "4321");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("pathview0.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QCOMPARE(pathview->count(), model.count());
+ QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count());
+ QCOMPARE(pathview->childItems().count(), model.count()+1); // assumes all are visible, including highlight
+
+ for (int i = 0; i < model.count(); ++i) {
+ QQuickText *name = findItem<QQuickText>(pathview, "textName", i);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), model.name(i));
+ QQuickText *number = findItem<QQuickText>(pathview, "textNumber", i);
+ QVERIFY(number != 0);
+ QCOMPARE(number->text(), model.number(i));
+ }
+
+ QQuickPath *path = qobject_cast<QQuickPath*>(pathview->path());
+ QVERIFY(path);
+
+ QVERIFY(pathview->highlightItem());
+ QPointF start = path->pointAt(0.0);
+ QPointF offset;
+ offset.setX(pathview->highlightItem()->width()/2);
+ offset.setY(pathview->highlightItem()->height()/2);
+ QCOMPARE(pathview->highlightItem()->pos() + offset, start);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::pathview2()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathview2.qml"));
+ QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->path() != 0);
+ QVERIFY(obj->delegate() != 0);
+ QVERIFY(obj->model() != QVariant());
+ QCOMPARE(obj->currentIndex(), 0);
+ QCOMPARE(obj->offset(), 0.);
+ QCOMPARE(obj->preferredHighlightBegin(), 0.);
+ QCOMPARE(obj->dragMargin(), 0.);
+ QCOMPARE(obj->count(), 8);
+ QCOMPARE(obj->pathItemCount(), 10);
+
+ delete obj;
+}
+
+void tst_QQuickPathView::pathview3()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathview3.qml"));
+ QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->path() != 0);
+ QVERIFY(obj->delegate() != 0);
+ QVERIFY(obj->model() != QVariant());
+ QCOMPARE(obj->currentIndex(), 0);
+ QCOMPARE(obj->offset(), 1.0);
+ QCOMPARE(obj->preferredHighlightBegin(), 0.5);
+ QCOMPARE(obj->dragMargin(), 24.);
+ QCOMPARE(obj->count(), 8);
+ QCOMPARE(obj->pathItemCount(), 4);
+
+ delete obj;
+}
+
+void tst_QQuickPathView::insertModel_data()
+{
+ QTest::addColumn<int>("mode");
+ QTest::addColumn<int>("idx");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<qreal>("offset");
+
+ // We have 8 items, with currentIndex == 4
+ QTest::newRow("insert after current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << 5.;
+ QTest::newRow("insert before current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << 4.;
+ QTest::newRow("insert multiple after current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << 6.;
+ QTest::newRow("insert multiple before current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << 4.;
+ QTest::newRow("insert at end")
+ << int(QQuickPathView::StrictlyEnforceRange) << 8 << 1 << 5.;
+ QTest::newRow("insert at beginning")
+ << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 4.;
+ QTest::newRow("insert at current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << 4.;
+
+ QTest::newRow("no range - insert after current")
+ << int(QQuickPathView::NoHighlightRange) << 6 << 1 << 5.;
+ QTest::newRow("no range - insert before current")
+ << int(QQuickPathView::NoHighlightRange) << 2 << 1 << 4.;
+ QTest::newRow("no range - insert multiple after current")
+ << int(QQuickPathView::NoHighlightRange) << 5 << 2 << 6.;
+ QTest::newRow("no range - insert multiple before current")
+ << int(QQuickPathView::NoHighlightRange) << 1 << 2 << 4.;
+ QTest::newRow("no range - insert at end")
+ << int(QQuickPathView::NoHighlightRange) << 8 << 1 << 5.;
+ QTest::newRow("no range - insert at beginning")
+ << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 4.;
+ QTest::newRow("no range - insert at current")
+ << int(QQuickPathView::NoHighlightRange) << 4 << 1 << 4.;
+}
+
+void tst_QQuickPathView::insertModel()
+{
+ QFETCH(int, mode);
+ QFETCH(int, idx);
+ QFETCH(int, count);
+ QFETCH(qreal, offset);
+
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ model.addItem("Ben", "12345");
+ model.addItem("Bohn", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Bill", "4321");
+ model.addItem("Jinny", "679");
+ model.addItem("Milly", "73378");
+ model.addItem("Jimmy", "3535");
+ model.addItem("Barb", "9039");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("pathview0.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode);
+
+ pathview->setCurrentIndex(4);
+ if (mode == QQuickPathView::StrictlyEnforceRange)
+ QTRY_COMPARE(pathview->offset(), 4.0);
+ else
+ pathview->setOffset(4);
+
+ QList<QPair<QString, QString> > items;
+ for (int i = 0; i < count; ++i)
+ items.append(qMakePair(QString("New"), QString::number(i)));
+
+ model.insertItems(idx, items);
+ QTRY_COMPARE(pathview->offset(), offset);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::removeModel_data()
+{
+ QTest::addColumn<int>("mode");
+ QTest::addColumn<int>("idx");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<qreal>("offset");
+
+ // We have 8 items, with currentIndex == 4
+ QTest::newRow("remove after current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 6 << 1 << 3.;
+ QTest::newRow("remove before current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 2 << 1 << 4.;
+ QTest::newRow("remove multiple after current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 5 << 2 << 2.;
+ QTest::newRow("remove multiple before current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 1 << 2 << 4.;
+ QTest::newRow("remove last")
+ << int(QQuickPathView::StrictlyEnforceRange) << 7 << 1 << 3.;
+ QTest::newRow("remove first")
+ << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 4.;
+ QTest::newRow("remove current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 4 << 1 << 3.;
+
+ QTest::newRow("no range - remove after current")
+ << int(QQuickPathView::NoHighlightRange) << 6 << 1 << 3.;
+ QTest::newRow("no range - remove before current")
+ << int(QQuickPathView::NoHighlightRange) << 2 << 1 << 4.;
+ QTest::newRow("no range - remove multiple after current")
+ << int(QQuickPathView::NoHighlightRange) << 5 << 2 << 2.;
+ QTest::newRow("no range - remove multiple before current")
+ << int(QQuickPathView::NoHighlightRange) << 1 << 2 << 4.;
+ QTest::newRow("no range - remove last")
+ << int(QQuickPathView::NoHighlightRange) << 7 << 1 << 3.;
+ QTest::newRow("no range - remove first")
+ << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 4.;
+ QTest::newRow("no range - remove current offset")
+ << int(QQuickPathView::NoHighlightRange) << 4 << 1 << 4.;
+}
+
+void tst_QQuickPathView::removeModel()
+{
+ QFETCH(int, mode);
+ QFETCH(int, idx);
+ QFETCH(int, count);
+ QFETCH(qreal, offset);
+
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ model.addItem("Ben", "12345");
+ model.addItem("Bohn", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Bill", "4321");
+ model.addItem("Jinny", "679");
+ model.addItem("Milly", "73378");
+ model.addItem("Jimmy", "3535");
+ model.addItem("Barb", "9039");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("pathview0.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode);
+
+ pathview->setCurrentIndex(4);
+ if (mode == QQuickPathView::StrictlyEnforceRange)
+ QTRY_COMPARE(pathview->offset(), 4.0);
+ else
+ pathview->setOffset(4);
+
+ model.removeItems(idx, count);
+ QTRY_COMPARE(pathview->offset(), offset);
+
+ delete canvas;
+}
+
+
+void tst_QQuickPathView::moveModel_data()
+{
+ QTest::addColumn<int>("mode");
+ QTest::addColumn<int>("from");
+ QTest::addColumn<int>("to");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<qreal>("offset");
+
+ // We have 8 items, with currentIndex == 4
+ QTest::newRow("move after current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 1 << 4.;
+ QTest::newRow("move before current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 2 << 3 << 1 << 4.;
+ QTest::newRow("move before current to after")
+ << int(QQuickPathView::StrictlyEnforceRange) << 2 << 6 << 1 << 5.;
+ QTest::newRow("move multiple after current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 5 << 6 << 2 << 4.;
+ QTest::newRow("move multiple before current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 0 << 1 << 2 << 4.;
+ QTest::newRow("move before current to end")
+ << int(QQuickPathView::StrictlyEnforceRange) << 2 << 7 << 1 << 5.;
+ QTest::newRow("move last to beginning")
+ << int(QQuickPathView::StrictlyEnforceRange) << 7 << 0 << 1 << 3.;
+ QTest::newRow("move current")
+ << int(QQuickPathView::StrictlyEnforceRange) << 4 << 6 << 1 << 2.;
+
+ QTest::newRow("no range - move after current")
+ << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 1 << 4.;
+ QTest::newRow("no range - move before current")
+ << int(QQuickPathView::NoHighlightRange) << 2 << 3 << 1 << 4.;
+ QTest::newRow("no range - move before current to after")
+ << int(QQuickPathView::NoHighlightRange) << 2 << 6 << 1 << 5.;
+ QTest::newRow("no range - move multiple after current")
+ << int(QQuickPathView::NoHighlightRange) << 5 << 6 << 2 << 4.;
+ QTest::newRow("no range - move multiple before current")
+ << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 2 << 4.;
+ QTest::newRow("no range - move before current to end")
+ << int(QQuickPathView::NoHighlightRange) << 2 << 7 << 1 << 5.;
+ QTest::newRow("no range - move last to beginning")
+ << int(QQuickPathView::NoHighlightRange) << 7 << 0 << 1 << 3.;
+ QTest::newRow("no range - move current")
+ << int(QQuickPathView::NoHighlightRange) << 4 << 6 << 1 << 4.;
+ QTest::newRow("no range - move multiple incl. current")
+ << int(QQuickPathView::NoHighlightRange) << 0 << 1 << 5 << 4.;
+}
+
+void tst_QQuickPathView::moveModel()
+{
+ QFETCH(int, mode);
+ QFETCH(int, from);
+ QFETCH(int, to);
+ QFETCH(int, count);
+ QFETCH(qreal, offset);
+
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ model.addItem("Ben", "12345");
+ model.addItem("Bohn", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Bill", "4321");
+ model.addItem("Jinny", "679");
+ model.addItem("Milly", "73378");
+ model.addItem("Jimmy", "3535");
+ model.addItem("Barb", "9039");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("pathview0.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ pathview->setHighlightRangeMode((QQuickPathView::HighlightRangeMode)mode);
+
+ pathview->setCurrentIndex(4);
+ if (mode == QQuickPathView::StrictlyEnforceRange)
+ QTRY_COMPARE(pathview->offset(), 4.0);
+ else
+ pathview->setOffset(4);
+
+ model.moveItems(from, to, count);
+ QTRY_COMPARE(pathview->offset(), offset);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::path()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("pathtest.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->startX(), 120.);
+ QCOMPARE(obj->startY(), 100.);
+ QVERIFY(obj->path() != QPainterPath());
+
+ QQmlListReference list(obj, "pathElements");
+ QCOMPARE(list.count(), 5);
+
+ QQuickPathAttribute* attr = qobject_cast<QQuickPathAttribute*>(list.at(0));
+ QVERIFY(attr != 0);
+ QCOMPARE(attr->name(), QString("scale"));
+ QCOMPARE(attr->value(), 1.0);
+
+ QQuickPathQuad* quad = qobject_cast<QQuickPathQuad*>(list.at(1));
+ QVERIFY(quad != 0);
+ QCOMPARE(quad->x(), 120.);
+ QCOMPARE(quad->y(), 25.);
+ QCOMPARE(quad->controlX(), 260.);
+ QCOMPARE(quad->controlY(), 75.);
+
+ QQuickPathPercent* perc = qobject_cast<QQuickPathPercent*>(list.at(2));
+ QVERIFY(perc != 0);
+ QCOMPARE(perc->value(), 0.3);
+
+ QQuickPathLine* line = qobject_cast<QQuickPathLine*>(list.at(3));
+ QVERIFY(line != 0);
+ QCOMPARE(line->x(), 120.);
+ QCOMPARE(line->y(), 100.);
+
+ QQuickPathCubic* cubic = qobject_cast<QQuickPathCubic*>(list.at(4));
+ QVERIFY(cubic != 0);
+ QCOMPARE(cubic->x(), 180.);
+ QCOMPARE(cubic->y(), 0.);
+ QCOMPARE(cubic->control1X(), -10.);
+ QCOMPARE(cubic->control1Y(), 90.);
+ QCOMPARE(cubic->control2X(), 210.);
+ QCOMPARE(cubic->control2Y(), 90.);
+
+ delete obj;
+}
+
+void tst_QQuickPathView::dataModel()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ QaimModel model;
+ model.addItem("red", "1");
+ model.addItem("green", "2");
+ model.addItem("blue", "3");
+ model.addItem("purple", "4");
+ model.addItem("gray", "5");
+ model.addItem("brown", "6");
+ model.addItem("yellow", "7");
+ model.addItem("thistle", "8");
+ model.addItem("cyan", "9");
+ model.addItem("peachpuff", "10");
+ model.addItem("powderblue", "11");
+ model.addItem("gold", "12");
+ model.addItem("sandybrown", "13");
+
+ ctxt->setContextProperty("testData", &model);
+
+ canvas->setSource(testFileUrl("datamodel.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ QQuickItem *item = findItem<QQuickItem>(pathview, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->x(), 110.0);
+ QCOMPARE(item->y(), 10.0);
+
+ model.insertItem(4, "orange", "10");
+ QTest::qWait(100);
+
+ QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count());
+ QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 14);
+
+ QVERIFY(pathview->currentIndex() == 0);
+ QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 0));
+
+ QQuickText *text = findItem<QQuickText>(pathview, "myText", 4);
+ QVERIFY(text);
+ QCOMPARE(text->text(), model.name(4));
+
+ model.removeItem(2);
+ QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count());
+ text = findItem<QQuickText>(pathview, "myText", 2);
+ QVERIFY(text);
+ QCOMPARE(text->text(), model.name(2));
+ QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 0));
+
+ testObject->setPathItemCount(5);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
+
+ QQuickRectangle *testItem = findItem<QQuickRectangle>(pathview, "wrapper", 4);
+ QVERIFY(testItem != 0);
+ testItem = findItem<QQuickRectangle>(pathview, "wrapper", 5);
+ QVERIFY(testItem == 0);
+
+ pathview->setCurrentIndex(1);
+ QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
+ QTest::qWait(100);
+
+ model.insertItem(2, "pink", "2");
+ QTest::qWait(100);
+
+ QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
+ QVERIFY(pathview->currentIndex() == 1);
+ QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
+
+ text = findItem<QQuickText>(pathview, "myText", 2);
+ QVERIFY(text);
+ QCOMPARE(text->text(), model.name(2));
+
+ model.removeItem(3);
+ QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
+ text = findItem<QQuickText>(pathview, "myText", 3);
+ QVERIFY(text);
+ QCOMPARE(text->text(), model.name(3));
+ QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
+
+ model.moveItem(3, 5);
+ QTRY_COMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
+ QList<QQuickItem*> items = findItems<QQuickItem>(pathview, "wrapper");
+ foreach (QQuickItem *item, items) {
+ QVERIFY(item->property("onPath").toBool());
+ }
+ QCOMPARE(pathview->currentItem(), findItem<QQuickItem>(pathview, "wrapper", 1));
+
+ // QTBUG-14199
+ pathview->setOffset(7);
+ pathview->setOffset(0);
+ QCOMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), 5);
+
+ pathview->setCurrentIndex(model.count()-1);
+ model.removeItem(model.count()-1);
+ QCOMPARE(pathview->currentIndex(), model.count()-1);
+
+ delete canvas;
+ delete testObject;
+}
+
+void tst_QQuickPathView::pathMoved()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ model.addItem("Ben", "12345");
+ model.addItem("Bohn", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Bill", "4321");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("pathview0.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QQuickRectangle *firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QQuickPath *path = qobject_cast<QQuickPath*>(pathview->path());
+ QVERIFY(path);
+ QPointF start = path->pointAt(0.0);
+ QPointF offset;//Center of item is at point, but pos is from corner
+ offset.setX(firstItem->width()/2);
+ offset.setY(firstItem->height()/2);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ pathview->setOffset(1.0);
+
+ for (int i=0; i<model.count(); i++) {
+ QQuickRectangle *curItem = findItem<QQuickRectangle>(pathview, "wrapper", i);
+ QPointF itemPos(path->pointAt(0.25 + i*0.25));
+ QCOMPARE(curItem->pos() + offset, QPointF(itemPos.x(), itemPos.y()));
+ }
+
+ pathview->setOffset(0.0);
+ QCOMPARE(firstItem->pos() + offset, start);
+
+ // Change delegate size
+ pathview->setOffset(0.1);
+ pathview->setOffset(0.0);
+ canvas->rootObject()->setProperty("delegateWidth", 30);
+ QCOMPARE(firstItem->width(), 30.0);
+ offset.setX(firstItem->width()/2);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+
+ // Change delegate scale
+ pathview->setOffset(0.1);
+ pathview->setOffset(0.0);
+ canvas->rootObject()->setProperty("delegateScale", 1.2);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::setCurrentIndex()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+ model.addItem("Ben", "12345");
+ model.addItem("Bohn", "2345");
+ model.addItem("Bob", "54321");
+ model.addItem("Bill", "4321");
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("pathview0.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QQuickRectangle *firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QQuickPath *path = qobject_cast<QQuickPath*>(pathview->path());
+ QVERIFY(path);
+ QPointF start = path->pointAt(0.0);
+ QPointF offset;//Center of item is at point, but pos is from corner
+ offset.setX(firstItem->width()/2);
+ offset.setY(firstItem->height()/2);
+ QCOMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 0);
+ QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 0);
+
+ pathview->setCurrentIndex(2);
+
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 2);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 2);
+ QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 2);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ pathview->decrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 1);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 1);
+ QVERIFY(firstItem);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ pathview->decrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 0);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ pathview->decrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 3);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 3);
+ QVERIFY(firstItem);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ pathview->incrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 0);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ // move an item, set move duration to 0, and change currentIndex to moved item. QTBUG-22786
+ model.moveItem(0, 3);
+ pathview->setHighlightMoveDuration(0);
+ pathview->setCurrentIndex(3);
+ QCOMPARE(pathview->currentIndex(), 3);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 3);
+ QVERIFY(firstItem);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ model.moveItem(3, 0);
+ pathview->setCurrentIndex(0);
+ pathview->setHighlightMoveDuration(300);
+
+ // Check the current item is still created when outside the bounds of pathItemCount.
+ pathview->setPathItemCount(2);
+ pathview->setHighlightRangeMode(QQuickPathView::NoHighlightRange);
+ QVERIFY(findItem<QQuickRectangle>(pathview, "wrapper", 0));
+ QVERIFY(findItem<QQuickRectangle>(pathview, "wrapper", 1));
+ QVERIFY(!findItem<QQuickRectangle>(pathview, "wrapper", 2));
+ QVERIFY(!findItem<QQuickRectangle>(pathview, "wrapper", 3));
+
+ pathview->setCurrentIndex(2);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 2);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(false));
+
+ pathview->decrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 1);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 1);
+ QVERIFY(firstItem);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ pathview->decrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 0);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ pathview->decrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 3);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 3);
+ QVERIFY(firstItem);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(false));
+
+ pathview->incrementCurrentIndex();
+ QTRY_COMPARE(pathview->currentIndex(), 0);
+ firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QCOMPARE(pathview->currentItem(), firstItem);
+ QCOMPARE(firstItem->property("onPath"), QVariant(true));
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::resetModel()
+{
+ QQuickView *canvas = createView();
+
+ QStringList strings;
+ strings << "one" << "two" << "three";
+ QStringListModel model(strings);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("displaypath.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ QCOMPARE(pathview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QQuickText *display = findItem<QQuickText>(pathview, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+
+ strings.clear();
+ strings << "four" << "five" << "six" << "seven";
+ model.setStringList(strings);
+
+ QCOMPARE(pathview->count(), model.rowCount());
+
+ for (int i = 0; i < model.rowCount(); ++i) {
+ QQuickText *display = findItem<QQuickText>(pathview, "displayText", i);
+ QVERIFY(display != 0);
+ QCOMPARE(display->text(), strings.at(i));
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::propertyChanges()
+{
+ QQuickView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychanges.qml"));
+
+ QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
+ QVERIFY(pathView);
+
+ QSignalSpy snapPositionSpy(pathView, SIGNAL(preferredHighlightBeginChanged()));
+ QSignalSpy dragMarginSpy(pathView, SIGNAL(dragMarginChanged()));
+
+ QCOMPARE(pathView->preferredHighlightBegin(), 0.1);
+ QCOMPARE(pathView->dragMargin(), 5.0);
+
+ pathView->setPreferredHighlightBegin(0.4);
+ pathView->setPreferredHighlightEnd(0.4);
+ pathView->setDragMargin(20.0);
+
+ QCOMPARE(pathView->preferredHighlightBegin(), 0.4);
+ QCOMPARE(pathView->preferredHighlightEnd(), 0.4);
+ QCOMPARE(pathView->dragMargin(), 20.0);
+
+ QCOMPARE(snapPositionSpy.count(), 1);
+ QCOMPARE(dragMarginSpy.count(), 1);
+
+ pathView->setPreferredHighlightBegin(0.4);
+ pathView->setPreferredHighlightEnd(0.4);
+ pathView->setDragMargin(20.0);
+
+ QCOMPARE(snapPositionSpy.count(), 1);
+ QCOMPARE(dragMarginSpy.count(), 1);
+ delete canvas;
+}
+
+void tst_QQuickPathView::pathChanges()
+{
+ QQuickView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychanges.qml"));
+
+ QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
+ QVERIFY(pathView);
+
+ QQuickPath *path = canvas->rootObject()->findChild<QQuickPath*>("path");
+ QVERIFY(path);
+
+ QSignalSpy startXSpy(path, SIGNAL(startXChanged()));
+ QSignalSpy startYSpy(path, SIGNAL(startYChanged()));
+
+ QCOMPARE(path->startX(), 220.0);
+ QCOMPARE(path->startY(), 200.0);
+
+ path->setStartX(240.0);
+ path->setStartY(220.0);
+
+ QCOMPARE(path->startX(), 240.0);
+ QCOMPARE(path->startY(), 220.0);
+
+ QCOMPARE(startXSpy.count(),1);
+ QCOMPARE(startYSpy.count(),1);
+
+ path->setStartX(240);
+ path->setStartY(220);
+
+ QCOMPARE(startXSpy.count(),1);
+ QCOMPARE(startYSpy.count(),1);
+
+ QQuickPath *alternatePath = canvas->rootObject()->findChild<QQuickPath*>("alternatePath");
+ QVERIFY(alternatePath);
+
+ QSignalSpy pathSpy(pathView, SIGNAL(pathChanged()));
+
+ QCOMPARE(pathView->path(), path);
+
+ pathView->setPath(alternatePath);
+ QCOMPARE(pathView->path(), alternatePath);
+ QCOMPARE(pathSpy.count(),1);
+
+ pathView->setPath(alternatePath);
+ QCOMPARE(pathSpy.count(),1);
+
+ QQuickPathAttribute *pathAttribute = canvas->rootObject()->findChild<QQuickPathAttribute*>("pathAttribute");
+ QVERIFY(pathAttribute);
+
+ QSignalSpy nameSpy(pathAttribute, SIGNAL(nameChanged()));
+ QCOMPARE(pathAttribute->name(), QString("opacity"));
+
+ pathAttribute->setName("scale");
+ QCOMPARE(pathAttribute->name(), QString("scale"));
+ QCOMPARE(nameSpy.count(),1);
+
+ pathAttribute->setName("scale");
+ QCOMPARE(nameSpy.count(),1);
+ delete canvas;
+}
+
+void tst_QQuickPathView::componentChanges()
+{
+ QQuickView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychanges.qml"));
+
+ QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
+ QVERIFY(pathView);
+
+ QQmlComponent delegateComponent(canvas->engine());
+ delegateComponent.setData("import QtQuick 2.0; Text { text: '<b>Name:</b> ' + name }", QUrl::fromLocalFile(""));
+
+ QSignalSpy delegateSpy(pathView, SIGNAL(delegateChanged()));
+
+ pathView->setDelegate(&delegateComponent);
+ QCOMPARE(pathView->delegate(), &delegateComponent);
+ QCOMPARE(delegateSpy.count(),1);
+
+ pathView->setDelegate(&delegateComponent);
+ QCOMPARE(delegateSpy.count(),1);
+ delete canvas;
+}
+
+void tst_QQuickPathView::modelChanges()
+{
+ QQuickView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(testFileUrl("propertychanges.qml"));
+
+ QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
+ QVERIFY(pathView);
+
+ QQuickListModel *alternateModel = canvas->rootObject()->findChild<QQuickListModel*>("alternateModel");
+ QVERIFY(alternateModel);
+ QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel);
+ QSignalSpy modelSpy(pathView, SIGNAL(modelChanged()));
+
+ pathView->setModel(modelVariant);
+ QCOMPARE(pathView->model(), modelVariant);
+ QCOMPARE(modelSpy.count(),1);
+
+ pathView->setModel(modelVariant);
+ QCOMPARE(modelSpy.count(),1);
+
+ pathView->setModel(QVariant());
+ QCOMPARE(modelSpy.count(),2);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::pathUpdateOnStartChanged()
+{
+ QQuickView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(testFileUrl("pathUpdateOnStartChanged.qml"));
+
+ QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
+ QVERIFY(pathView);
+
+ QQuickPath *path = canvas->rootObject()->findChild<QQuickPath*>("path");
+ QVERIFY(path);
+ QCOMPARE(path->startX(), 400.0);
+ QCOMPARE(path->startY(), 300.0);
+
+ QQuickItem *item = findItem<QQuickItem>(pathView, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->x(), path->startX() - item->width() / 2.0);
+ QCOMPARE(item->y(), path->startY() - item->height() / 2.0);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::package()
+{
+ QQuickView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(testFileUrl("pathview_package.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("photoPathView");
+ QVERIFY(pathView);
+
+#ifdef Q_OS_MAC
+ QSKIP("QTBUG-21590 view does not reliably receive polish without a running animation");
+#endif
+
+ QQuickItem *item = findItem<QQuickItem>(pathView, "pathItem");
+ QVERIFY(item);
+ QVERIFY(item->scale() != 1.0);
+
+ delete canvas;
+}
+
+//QTBUG-13017
+void tst_QQuickPathView::emptyModel()
+{
+ QQuickView *canvas = createView();
+
+ QStringListModel model;
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("emptyModel", &model);
+
+ canvas->setSource(testFileUrl("emptymodel.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+
+ QCOMPARE(pathview->offset(), qreal(0.0));
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::closed()
+{
+ QQmlEngine engine;
+
+ {
+ QQmlComponent c(&engine, testFileUrl("openPath.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj);
+ QCOMPARE(obj->isClosed(), false);
+ delete obj;
+ }
+
+ {
+ QQmlComponent c(&engine, testFileUrl("closedPath.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj);
+ QCOMPARE(obj->isClosed(), true);
+ delete obj;
+ }
+}
+
+// QTBUG-14239
+void tst_QQuickPathView::pathUpdate()
+{
+ QQuickView *canvas = createView();
+ QVERIFY(canvas);
+ canvas->setSource(testFileUrl("pathUpdate.qml"));
+
+ QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
+ QVERIFY(pathView);
+
+ QQuickItem *item = findItem<QQuickItem>(pathView, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->x(), 150.0);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::visualDataModel()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("vdm.qml"));
+
+ QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->count(), 3);
+
+ delete obj;
+}
+
+void tst_QQuickPathView::undefinedPath()
+{
+ QQmlEngine engine;
+
+ // QPainterPath warnings are only received if QT_NO_DEBUG is not defined
+ if (QLibraryInfo::isDebugBuild()) {
+ QString warning1("QPainterPath::moveTo: Adding point where x or y is NaN or Inf, ignoring call");
+ QTest::ignoreMessage(QtWarningMsg,qPrintable(warning1));
+
+ QString warning2("QPainterPath::lineTo: Adding point where x or y is NaN or Inf, ignoring call");
+ QTest::ignoreMessage(QtWarningMsg,qPrintable(warning2));
+ }
+
+ QQmlComponent c(&engine, testFileUrl("undefinedpath.qml"));
+
+ QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->count(), 3);
+
+ delete obj;
+}
+
+void tst_QQuickPathView::mouseDrag()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("dragpath.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(canvas, qGuiApp->focusWindow());
+
+ QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+
+ int current = pathview->currentIndex();
+
+ QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(10,100));
+ QTest::qWait(100);
+
+ {
+ QMouseEvent mv(QEvent::MouseMove, QPoint(30,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QGuiApplication::sendEvent(canvas, &mv);
+ }
+ {
+ QMouseEvent mv(QEvent::MouseMove, QPoint(90,100), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QGuiApplication::sendEvent(canvas, &mv);
+ }
+
+ QVERIFY(pathview->currentIndex() != current);
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(40,100));
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::treeModel()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+ canvas->engine()->rootContext()->setContextProperty("myModel", &model);
+
+ canvas->setSource(testFileUrl("treemodel.qml"));
+
+ QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+ QCOMPARE(pathview->count(), 3);
+
+ QQuickText *item = findItem<QQuickText>(pathview, "wrapper", 0);
+ QVERIFY(item);
+ QCOMPARE(item->text(), QLatin1String("Row 1 Item"));
+
+ QVERIFY(QMetaObject::invokeMethod(pathview, "setRoot", Q_ARG(QVariant, 1)));
+ QCOMPARE(pathview->count(), 1);
+
+ QTRY_VERIFY(item = findItem<QQuickText>(pathview, "wrapper", 0));
+ QTRY_COMPARE(item->text(), QLatin1String("Row 2 Child Item"));
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::changePreferredHighlight()
+{
+ QQuickView *canvas = createView();
+ canvas->setGeometry(0,0,400,200);
+ canvas->setSource(testFileUrl("dragpath.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(canvas, qGuiApp->focusWindow());
+
+ QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
+ QVERIFY(pathview != 0);
+
+ int current = pathview->currentIndex();
+ QCOMPARE(current, 0);
+
+ QQuickRectangle *firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QQuickPath *path = qobject_cast<QQuickPath*>(pathview->path());
+ QVERIFY(path);
+ QPointF start = path->pointAt(0.5);
+ QPointF offset;//Center of item is at point, but pos is from corner
+ offset.setX(firstItem->width()/2);
+ offset.setY(firstItem->height()/2);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+
+ pathview->setPreferredHighlightBegin(0.8);
+ pathview->setPreferredHighlightEnd(0.8);
+ start = path->pointAt(0.8);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ QCOMPARE(pathview->currentIndex(), 0);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::creationContext()
+{
+ QQuickView canvas;
+ canvas.setGeometry(0,0,240,320);
+ canvas.setSource(testFileUrl("creationContext.qml"));
+
+ QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
+ QVERIFY(rootItem);
+ QVERIFY(rootItem->property("count").toInt() > 0);
+
+ QQuickItem *item;
+ QVERIFY(item = findItem<QQuickItem>(rootItem, "listItem", 0));
+ QCOMPARE(item->property("text").toString(), QString("Hello!"));
+}
+
+// QTBUG-21320
+void tst_QQuickPathView::currentOffsetOnInsertion()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+
+ QaimModel model;
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(testFileUrl("pathline.qml"));
+ qApp->processEvents();
+
+ QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
+ QVERIFY(pathview != 0);
+
+ pathview->setPreferredHighlightBegin(0.5);
+ pathview->setPreferredHighlightEnd(0.5);
+
+ QCOMPARE(pathview->count(), model.count());
+
+ model.addItem("item0", "0");
+
+ QCOMPARE(pathview->count(), model.count());
+
+ QQuickRectangle *item = 0;
+ QTRY_VERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 0));
+
+ QQuickPath *path = qobject_cast<QQuickPath*>(pathview->path());
+ QVERIFY(path);
+
+ QPointF start = path->pointAt(0.5);
+ QPointF offset;//Center of item is at point, but pos is from corner
+ offset.setX(item->width()/2);
+ offset.setY(item->height()/2);
+ QCOMPARE(item->pos() + offset, start);
+
+ QSignalSpy currentIndexSpy(pathview, SIGNAL(currentIndexChanged()));
+
+ // insert an item at the beginning
+ model.insertItem(0, "item1", "1");
+ qApp->processEvents();
+
+ QCOMPARE(currentIndexSpy.count(), 1);
+
+ // currentIndex is now 1
+ QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 1));
+
+ // verify that current item (item 1) is still at offset 0.5
+ QCOMPARE(item->pos() + offset, start);
+
+ // insert another item at the beginning
+ model.insertItem(0, "item2", "2");
+ qApp->processEvents();
+
+ QCOMPARE(currentIndexSpy.count(), 2);
+
+ // currentIndex is now 2
+ QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 2));
+
+ // verify that current item (item 2) is still at offset 0.5
+ QCOMPARE(item->pos() + offset, start);
+
+ // verify that remove before current maintains current item
+ model.removeItem(0);
+ qApp->processEvents();
+
+ QCOMPARE(currentIndexSpy.count(), 3);
+
+ // currentIndex is now 1
+ QVERIFY(item = findItem<QQuickRectangle>(pathview, "wrapper", 1));
+
+ // verify that current item (item 1) is still at offset 0.5
+ QCOMPARE(item->pos() + offset, start);
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::asynchronous()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+ QQmlIncubationController controller;
+ canvas->engine()->setIncubationController(&controller);
+
+ canvas->setSource(testFileUrl("asyncloader.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootObject);
+
+ QQuickPathView *pathview = 0;
+ while (!pathview) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ pathview = rootObject->findChild<QQuickPathView*>("view");
+ }
+
+ // items will be created one at a time
+ for (int i = 0; i < 5; ++i) {
+ QVERIFY(findItem<QQuickItem>(pathview, "wrapper", i) == 0);
+ QQuickItem *item = 0;
+ while (!item) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ item = findItem<QQuickItem>(pathview, "wrapper", i);
+ }
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ // verify positioning
+ QQuickRectangle *firstItem = findItem<QQuickRectangle>(pathview, "wrapper", 0);
+ QVERIFY(firstItem);
+ QQuickPath *path = qobject_cast<QQuickPath*>(pathview->path());
+ QVERIFY(path);
+ QPointF start = path->pointAt(0.0);
+ QPointF offset;//Center of item is at point, but pos is from corner
+ offset.setX(firstItem->width()/2);
+ offset.setY(firstItem->height()/2);
+ QTRY_COMPARE(firstItem->pos() + offset, start);
+ pathview->setOffset(1.0);
+
+ for (int i=0; i<5; i++) {
+ QQuickItem *curItem = findItem<QQuickItem>(pathview, "wrapper", i);
+ QPointF itemPos(path->pointAt(0.2 + i*0.2));
+ QCOMPARE(curItem->pos() + offset, itemPos);
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickPathView::missingPercent()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("missingPercent.qml"));
+ QQuickPath *obj = qobject_cast<QQuickPath*>(c.create());
+ QVERIFY(obj);
+ QCOMPARE(obj->attributeAt("_qfx_percent", 1.0), qreal(1.0));
+ delete obj;
+}
+
+QTEST_MAIN(tst_QQuickPathView)
+
+#include "tst_qquickpathview.moc"
diff --git a/tests/auto/qtquick2/qquickpincharea/data/pinchproperties.qml b/tests/auto/quick/qquickpincharea/data/pinchproperties.qml
index 44d116184e..44d116184e 100644
--- a/tests/auto/qtquick2/qquickpincharea/data/pinchproperties.qml
+++ b/tests/auto/quick/qquickpincharea/data/pinchproperties.qml
diff --git a/tests/auto/quick/qquickpincharea/qquickpincharea.pro b/tests/auto/quick/qquickpincharea/qquickpincharea.pro
new file mode 100644
index 0000000000..514dd25a5a
--- /dev/null
+++ b/tests/auto/quick/qquickpincharea/qquickpincharea.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickpincharea
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickpincharea.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
new file mode 100644
index 0000000000..6e83d41c4e
--- /dev/null
+++ b/tests/auto/quick/qquickpincharea/tst_qquickpincharea.cpp
@@ -0,0 +1,404 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <private/qquickpincharea_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlcontext.h>
+#include "../../shared/util.h"
+
+class tst_QQuickPinchArea: public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickPinchArea() : device(0) { }
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void pinchProperties();
+ void scale();
+ void pan();
+ void retouch();
+
+private:
+ QQuickView *createView();
+ QTouchDevice *device;
+};
+void tst_QQuickPinchArea::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ if (!device) {
+ device = new QTouchDevice;
+ device->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(device);
+ }
+}
+
+void tst_QQuickPinchArea::cleanupTestCase()
+{
+
+}
+void tst_QQuickPinchArea::pinchProperties()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("pinchproperties.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pincharea");
+ QQuickPinch *pinch = pinchArea->pinch();
+ QVERIFY(pinchArea != 0);
+ QVERIFY(pinch != 0);
+
+ // target
+ QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+ QVERIFY(blackRect == pinch->target());
+ QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootItem != 0);
+ QSignalSpy targetSpy(pinch, SIGNAL(targetChanged()));
+ pinch->setTarget(rootItem);
+ QCOMPARE(targetSpy.count(),1);
+ pinch->setTarget(rootItem);
+ QCOMPARE(targetSpy.count(),1);
+
+ // axis
+ QCOMPARE(pinch->axis(), QQuickPinch::XandYAxis);
+ QSignalSpy axisSpy(pinch, SIGNAL(dragAxisChanged()));
+ pinch->setAxis(QQuickPinch::XAxis);
+ QCOMPARE(pinch->axis(), QQuickPinch::XAxis);
+ QCOMPARE(axisSpy.count(),1);
+ pinch->setAxis(QQuickPinch::XAxis);
+ QCOMPARE(axisSpy.count(),1);
+
+ // minimum and maximum drag properties
+ QSignalSpy xminSpy(pinch, SIGNAL(minimumXChanged()));
+ QSignalSpy xmaxSpy(pinch, SIGNAL(maximumXChanged()));
+ QSignalSpy yminSpy(pinch, SIGNAL(minimumYChanged()));
+ QSignalSpy ymaxSpy(pinch, SIGNAL(maximumYChanged()));
+
+ QCOMPARE(pinch->xmin(), 0.0);
+ QCOMPARE(pinch->xmax(), rootItem->width()-blackRect->width());
+ QCOMPARE(pinch->ymin(), 0.0);
+ QCOMPARE(pinch->ymax(), rootItem->height()-blackRect->height());
+
+ pinch->setXmin(10);
+ pinch->setXmax(10);
+ pinch->setYmin(10);
+ pinch->setYmax(10);
+
+ QCOMPARE(pinch->xmin(), 10.0);
+ QCOMPARE(pinch->xmax(), 10.0);
+ QCOMPARE(pinch->ymin(), 10.0);
+ QCOMPARE(pinch->ymax(), 10.0);
+
+ QCOMPARE(xminSpy.count(),1);
+ QCOMPARE(xmaxSpy.count(),1);
+ QCOMPARE(yminSpy.count(),1);
+ QCOMPARE(ymaxSpy.count(),1);
+
+ pinch->setXmin(10);
+ pinch->setXmax(10);
+ pinch->setYmin(10);
+ pinch->setYmax(10);
+
+ QCOMPARE(xminSpy.count(),1);
+ QCOMPARE(xmaxSpy.count(),1);
+ QCOMPARE(yminSpy.count(),1);
+ QCOMPARE(ymaxSpy.count(),1);
+
+ // minimum and maximum scale properties
+ QSignalSpy scaleMinSpy(pinch, SIGNAL(minimumScaleChanged()));
+ QSignalSpy scaleMaxSpy(pinch, SIGNAL(maximumScaleChanged()));
+
+ QCOMPARE(pinch->minimumScale(), 1.0);
+ QCOMPARE(pinch->maximumScale(), 2.0);
+
+ pinch->setMinimumScale(0.5);
+ pinch->setMaximumScale(1.5);
+
+ QCOMPARE(pinch->minimumScale(), 0.5);
+ QCOMPARE(pinch->maximumScale(), 1.5);
+
+ QCOMPARE(scaleMinSpy.count(),1);
+ QCOMPARE(scaleMaxSpy.count(),1);
+
+ pinch->setMinimumScale(0.5);
+ pinch->setMaximumScale(1.5);
+
+ QCOMPARE(scaleMinSpy.count(),1);
+ QCOMPARE(scaleMaxSpy.count(),1);
+
+ // minimum and maximum rotation properties
+ QSignalSpy rotMinSpy(pinch, SIGNAL(minimumRotationChanged()));
+ QSignalSpy rotMaxSpy(pinch, SIGNAL(maximumRotationChanged()));
+
+ QCOMPARE(pinch->minimumRotation(), 0.0);
+ QCOMPARE(pinch->maximumRotation(), 90.0);
+
+ pinch->setMinimumRotation(-90.0);
+ pinch->setMaximumRotation(45.0);
+
+ QCOMPARE(pinch->minimumRotation(), -90.0);
+ QCOMPARE(pinch->maximumRotation(), 45.0);
+
+ QCOMPARE(rotMinSpy.count(),1);
+ QCOMPARE(rotMaxSpy.count(),1);
+
+ pinch->setMinimumRotation(-90.0);
+ pinch->setMaximumRotation(45.0);
+
+ QCOMPARE(rotMinSpy.count(),1);
+ QCOMPARE(rotMaxSpy.count(),1);
+
+ delete canvas;
+}
+
+QTouchEvent::TouchPoint makeTouchPoint(int id, QPoint p, QQuickView *v, QQuickItem *i)
+{
+ QTouchEvent::TouchPoint touchPoint(id);
+ touchPoint.setPos(i->mapFromScene(p));
+ touchPoint.setScreenPos(v->mapToGlobal(p));
+ touchPoint.setScenePos(p);
+ return touchPoint;
+}
+
+void tst_QQuickPinchArea::scale()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("pinchproperties.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QVERIFY(canvas->rootObject() != 0);
+ qApp->processEvents();
+
+ QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pincharea");
+ QQuickPinch *pinch = pinchArea->pinch();
+ QVERIFY(pinchArea != 0);
+ QVERIFY(pinch != 0);
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root != 0);
+
+ // target
+ QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+
+ QPoint p1(80, 80);
+ QPoint p2(100, 100);
+
+ QTest::touchEvent(canvas, device).press(0, p1, canvas);
+ QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
+ p1 -= QPoint(10,10);
+ p2 += QPoint(10,10);
+ QTest::touchEvent(canvas, device).move(0, p1,canvas).move(1, p2,canvas);
+
+ QCOMPARE(root->property("scale").toReal(), 1.0);
+
+ p1 -= QPoint(10,10);
+ p2 += QPoint(10,10);
+ QTest::touchEvent(canvas, device).move(0, p1,canvas).move(1, p2,canvas);
+
+ QCOMPARE(root->property("scale").toReal(), 1.5);
+ QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50
+ QCOMPARE(blackRect->scale(), 1.5);
+
+ // scale beyond bound
+ p1 -= QPoint(50,50);
+ p2 += QPoint(50,50);
+ QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
+
+ QCOMPARE(blackRect->scale(), 2.0);
+
+ QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas);
+
+ delete canvas;
+}
+
+void tst_QQuickPinchArea::pan()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("pinchproperties.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QVERIFY(canvas->rootObject() != 0);
+ qApp->processEvents();
+
+ QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pincharea");
+ QQuickPinch *pinch = pinchArea->pinch();
+ QVERIFY(pinchArea != 0);
+ QVERIFY(pinch != 0);
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root != 0);
+
+ // target
+ QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+
+ QPoint p1(80, 80);
+ QPoint p2(100, 100);
+
+ QTest::touchEvent(canvas, device).press(0, p1, canvas);
+ QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
+ p1 += QPoint(10,10);
+ p2 += QPoint(10,10);
+ QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
+
+ QCOMPARE(root->property("scale").toReal(), 1.0);
+
+ p1 += QPoint(10,10);
+ p2 += QPoint(10,10);
+ QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
+
+ QCOMPARE(root->property("center").toPointF(), QPointF(60, 60)); // blackrect is at 50,50
+
+ QCOMPARE(blackRect->x(), 60.0);
+ QCOMPARE(blackRect->y(), 60.0);
+
+ // pan x beyond bound
+ p1 += QPoint(100,100);
+ p2 += QPoint(100,100);
+ QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
+
+ QCOMPARE(blackRect->x(), 140.0);
+ QCOMPARE(blackRect->y(), 160.0);
+
+ QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas);
+
+ delete canvas;
+}
+
+// test pinch, release one point, touch again to continue pinch
+void tst_QQuickPinchArea::retouch()
+{
+ QQuickView *canvas = createView();
+ canvas->setSource(testFileUrl("pinchproperties.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QVERIFY(canvas->rootObject() != 0);
+ qApp->processEvents();
+
+ QQuickPinchArea *pinchArea = canvas->rootObject()->findChild<QQuickPinchArea*>("pincharea");
+ QQuickPinch *pinch = pinchArea->pinch();
+ QVERIFY(pinchArea != 0);
+ QVERIFY(pinch != 0);
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root != 0);
+
+ QSignalSpy startedSpy(pinchArea, SIGNAL(pinchStarted(QQuickPinchEvent *)));
+ QSignalSpy finishedSpy(pinchArea, SIGNAL(pinchFinished(QQuickPinchEvent *)));
+
+ // target
+ QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect");
+ QVERIFY(blackRect != 0);
+
+ QPoint p1(80, 80);
+ QPoint p2(100, 100);
+
+ QTest::touchEvent(canvas, device).press(0, p1, canvas);
+ QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
+ p1 -= QPoint(10,10);
+ p2 += QPoint(10,10);
+ QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
+
+ QCOMPARE(root->property("scale").toReal(), 1.0);
+
+ p1 -= QPoint(10,10);
+ p2 += QPoint(10,10);
+ QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
+
+ QCOMPARE(startedSpy.count(), 1);
+
+ QCOMPARE(root->property("scale").toReal(), 1.5);
+ QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50
+ QCOMPARE(blackRect->scale(), 1.5);
+
+ QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 2);
+
+ QCOMPARE(startedSpy.count(), 1);
+ QCOMPARE(finishedSpy.count(), 0);
+
+ QTest::touchEvent(canvas, device).stationary(0).release(1, p2, canvas);
+
+ QCOMPARE(startedSpy.count(), 1);
+ QCOMPARE(finishedSpy.count(), 0);
+
+ QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 1);
+
+ QTest::touchEvent(canvas, device).stationary(0).press(1, p2, canvas);
+ p1 -= QPoint(10,10);
+ p2 += QPoint(10,10);
+ QTest::touchEvent(canvas, device).move(0, p1, canvas).move(1, p2, canvas);
+
+ // Lifting and retouching results in onPinchStarted being called again
+ QCOMPARE(startedSpy.count(), 2);
+ QCOMPARE(finishedSpy.count(), 0);
+
+ QCOMPARE(canvas->rootObject()->property("pointCount").toInt(), 2);
+
+ QTest::touchEvent(canvas, device).release(0, p1, canvas).release(1, p2, canvas);
+
+ QCOMPARE(startedSpy.count(), 2);
+ QCOMPARE(finishedSpy.count(), 1);
+
+ delete canvas;
+}
+
+
+QQuickView *tst_QQuickPinchArea::createView()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+
+ return canvas;
+}
+
+QTEST_MAIN(tst_QQuickPinchArea)
+
+#include "tst_qquickpincharea.moc"
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists.png b/tests/auto/quick/qquickpixmapcache/data/exists.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists.png
+++ b/tests/auto/quick/qquickpixmapcache/data/exists.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists1.png b/tests/auto/quick/qquickpixmapcache/data/exists1.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists1.png
+++ b/tests/auto/quick/qquickpixmapcache/data/exists1.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists2.png b/tests/auto/quick/qquickpixmapcache/data/exists2.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/exists2.png
+++ b/tests/auto/quick/qquickpixmapcache/data/exists2.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists.png b/tests/auto/quick/qquickpixmapcache/data/http/exists.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists1.png b/tests/auto/quick/qquickpixmapcache/data/http/exists1.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists1.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists1.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists2.png b/tests/auto/quick/qquickpixmapcache/data/http/exists2.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists2.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists2.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists3.png b/tests/auto/quick/qquickpixmapcache/data/http/exists3.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists3.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists3.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists4.png b/tests/auto/quick/qquickpixmapcache/data/http/exists4.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists4.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists4.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists5.png b/tests/auto/quick/qquickpixmapcache/data/http/exists5.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists5.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists5.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists6.png b/tests/auto/quick/qquickpixmapcache/data/http/exists6.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists6.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists6.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists7.png b/tests/auto/quick/qquickpixmapcache/data/http/exists7.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists7.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists7.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists8.png b/tests/auto/quick/qquickpixmapcache/data/http/exists8.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/http/exists8.png
+++ b/tests/auto/quick/qquickpixmapcache/data/http/exists8.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativepixmapcache/data/massive.png b/tests/auto/quick/qquickpixmapcache/data/massive.png
index bc6cc9e6ca..bc6cc9e6ca 100644
--- a/tests/auto/qtquick2/qdeclarativepixmapcache/data/massive.png
+++ b/tests/auto/quick/qquickpixmapcache/data/massive.png
Binary files differ
diff --git a/tests/auto/quick/qquickpixmapcache/qquickpixmapcache.pro b/tests/auto/quick/qquickpixmapcache/qquickpixmapcache.pro
new file mode 100644
index 0000000000..7611e37b49
--- /dev/null
+++ b/tests/auto/quick/qquickpixmapcache/qquickpixmapcache.pro
@@ -0,0 +1,21 @@
+CONFIG += testcase
+TARGET = tst_qquickpixmapcache
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickpixmapcache.cpp \
+ ../../shared/testhttpserver.cpp
+HEADERS += ../../shared/testhttpserver.h
+INCLUDEPATH += ../../shared/
+
+include (../../shared/util.pri)
+
+importFiles.files = data
+importFiles.path = .
+DEPLOYMENT += importFiles
+
+# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
+# LIBS += -lgcov
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib concurrent
diff --git a/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
new file mode 100644
index 0000000000..855322e376
--- /dev/null
+++ b/tests/auto/quick/qquickpixmapcache/tst_qquickpixmapcache.cpp
@@ -0,0 +1,467 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QtTest>
+#include <QtQuick/private/qquickpixmapcache_p.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlimageprovider.h>
+#include <QNetworkReply>
+#include "../../shared/util.h"
+#include "testhttpserver.h"
+
+#ifndef QT_NO_CONCURRENT
+#include <qtconcurrentrun.h>
+#include <qfuture.h>
+#endif
+
+#define PIXMAP_DATA_LEAK_TEST 0
+
+class tst_qquickpixmapcache : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickpixmapcache() : server(14452) {}
+
+private slots:
+ void initTestCase();
+ void single();
+ void single_data();
+ void parallel();
+ void parallel_data();
+ void massive();
+ void cancelcrash();
+ void shrinkcache();
+#ifndef QT_NO_CONCURRENT
+ void networkCrash();
+#endif
+ void lockingCrash();
+#if PIXMAP_DATA_LEAK_TEST
+ void dataLeak();
+#endif
+private:
+ QQmlEngine engine;
+ TestHTTPServer server;
+};
+
+static int slotters=0;
+
+class Slotter : public QObject
+{
+ Q_OBJECT
+public:
+ Slotter()
+ {
+ gotslot = false;
+ slotters++;
+ }
+ bool gotslot;
+
+public slots:
+ void got()
+ {
+ gotslot = true;
+ --slotters;
+ if (slotters==0)
+ QTestEventLoop::instance().exitLoop();
+ }
+};
+
+#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
+static const bool localfile_optimized = true;
+#else
+static const bool localfile_optimized = false;
+#endif
+
+
+void tst_qquickpixmapcache::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ server.serveDirectory(testFile("http"));
+}
+
+void tst_qquickpixmapcache::single_data()
+{
+ // Note, since QQuickPixmapCache is shared, tests affect each other!
+ // so use different files fore all test functions.
+
+ QTest::addColumn<QUrl>("target");
+ QTest::addColumn<bool>("incache");
+ QTest::addColumn<bool>("exists");
+ QTest::addColumn<bool>("neterror");
+
+ // File URLs are optimized
+ QTest::newRow("local") << testFileUrl("exists.png") << localfile_optimized << true << false;
+ QTest::newRow("local") << testFileUrl("notexists.png") << localfile_optimized << false << false;
+ QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/exists.png") << false << true << false;
+ QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/notexists.png") << false << false << true;
+}
+
+void tst_qquickpixmapcache::single()
+{
+ QFETCH(QUrl, target);
+ QFETCH(bool, incache);
+ QFETCH(bool, exists);
+ QFETCH(bool, neterror);
+
+ QString expectedError;
+ if (neterror) {
+ expectedError = "Error downloading " + target.toString() + " - server replied: Not found";
+ } else if (!exists) {
+ expectedError = "Cannot open: " + target.toString();
+ }
+
+ QQuickPixmap pixmap;
+ QVERIFY(pixmap.width() <= 0); // Check Qt assumption
+
+ pixmap.load(&engine, target);
+
+ if (incache) {
+ QCOMPARE(pixmap.error(), expectedError);
+ if (exists) {
+ QVERIFY(pixmap.status() == QQuickPixmap::Ready);
+ QVERIFY(pixmap.width() > 0);
+ } else {
+ QVERIFY(pixmap.status() == QQuickPixmap::Error);
+ QVERIFY(pixmap.width() <= 0);
+ }
+ } else {
+ QVERIFY(pixmap.width() <= 0);
+
+ Slotter getter;
+ pixmap.connectFinished(&getter, SLOT(got()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ QVERIFY(getter.gotslot);
+ if (exists) {
+ QVERIFY(pixmap.status() == QQuickPixmap::Ready);
+ QVERIFY(pixmap.width() > 0);
+ } else {
+ QVERIFY(pixmap.status() == QQuickPixmap::Error);
+ QVERIFY(pixmap.width() <= 0);
+ }
+ QCOMPARE(pixmap.error(), expectedError);
+ }
+}
+
+void tst_qquickpixmapcache::parallel_data()
+{
+ // Note, since QQuickPixmapCache is shared, tests affect each other!
+ // so use different files fore all test functions.
+
+ QTest::addColumn<QUrl>("target1");
+ QTest::addColumn<QUrl>("target2");
+ QTest::addColumn<int>("incache");
+ QTest::addColumn<int>("cancel"); // which one to cancel
+
+ QTest::newRow("local")
+ << testFileUrl("exists1.png")
+ << testFileUrl("exists2.png")
+ << (localfile_optimized ? 2 : 0)
+ << -1;
+
+ QTest::newRow("remote")
+ << QUrl("http://127.0.0.1:14452/exists2.png")
+ << QUrl("http://127.0.0.1:14452/exists3.png")
+ << 0
+ << -1;
+
+ QTest::newRow("remoteagain")
+ << QUrl("http://127.0.0.1:14452/exists2.png")
+ << QUrl("http://127.0.0.1:14452/exists3.png")
+ << 2
+ << -1;
+
+ QTest::newRow("remotecopy")
+ << QUrl("http://127.0.0.1:14452/exists4.png")
+ << QUrl("http://127.0.0.1:14452/exists4.png")
+ << 0
+ << -1;
+
+ QTest::newRow("remotecopycancel")
+ << QUrl("http://127.0.0.1:14452/exists5.png")
+ << QUrl("http://127.0.0.1:14452/exists5.png")
+ << 0
+ << 0;
+}
+
+void tst_qquickpixmapcache::parallel()
+{
+ QFETCH(QUrl, target1);
+ QFETCH(QUrl, target2);
+ QFETCH(int, incache);
+ QFETCH(int, cancel);
+
+ QList<QUrl> targets;
+ targets << target1 << target2;
+
+ QList<QQuickPixmap *> pixmaps;
+ QList<bool> pending;
+ QList<Slotter*> getters;
+
+ for (int i=0; i<targets.count(); ++i) {
+ QUrl target = targets.at(i);
+ QQuickPixmap *pixmap = new QQuickPixmap;
+
+ pixmap->load(&engine, target);
+
+ QVERIFY(pixmap->status() != QQuickPixmap::Error);
+ pixmaps.append(pixmap);
+ if (pixmap->isReady()) {
+ QVERIFY(pixmap->width() > 0);
+ getters.append(0);
+ pending.append(false);
+ } else {
+ QVERIFY(pixmap->width() <= 0);
+ getters.append(new Slotter);
+ pixmap->connectFinished(getters[i], SLOT(got()));
+ pending.append(true);
+ }
+ }
+
+ QCOMPARE(incache+slotters, targets.count());
+
+ if (cancel >= 0) {
+ pixmaps.at(cancel)->clear(getters[cancel]);
+ slotters--;
+ }
+
+ if (slotters) {
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+ }
+
+ for (int i=0; i<targets.count(); ++i) {
+ QQuickPixmap *pixmap = pixmaps[i];
+
+ if (i == cancel) {
+ QVERIFY(!getters[i]->gotslot);
+ } else {
+ if (pending[i])
+ QVERIFY(getters[i]->gotslot);
+
+ QVERIFY(pixmap->isReady());
+ QVERIFY(pixmap->width() > 0);
+ delete getters[i];
+ }
+ }
+
+ qDeleteAll(pixmaps);
+}
+
+void tst_qquickpixmapcache::massive()
+{
+ QQmlEngine engine;
+ QUrl url = testFileUrl("massive.png");
+
+ // Confirm that massive images remain in the cache while they are
+ // in use by the application.
+ {
+ qint64 cachekey = 0;
+ QQuickPixmap p(&engine, url);
+ QVERIFY(p.isReady());
+ QVERIFY(p.image().size() == QSize(10000, 1000));
+ cachekey = p.image().cacheKey();
+
+ QQuickPixmap p2(&engine, url);
+ QVERIFY(p2.isReady());
+ QVERIFY(p2.image().size() == QSize(10000, 1000));
+
+ QVERIFY(p2.image().cacheKey() == cachekey);
+ }
+
+ // Confirm that massive images are removed from the cache when
+ // they become unused
+ {
+ qint64 cachekey = 0;
+ {
+ QQuickPixmap p(&engine, url);
+ QVERIFY(p.isReady());
+ QVERIFY(p.image().size() == QSize(10000, 1000));
+ cachekey = p.image().cacheKey();
+ }
+
+ QQuickPixmap p2(&engine, url);
+ QVERIFY(p2.isReady());
+ QVERIFY(p2.image().size() == QSize(10000, 1000));
+
+ QVERIFY(p2.image().cacheKey() != cachekey);
+ }
+}
+
+// QTBUG-12729
+void tst_qquickpixmapcache::cancelcrash()
+{
+ QUrl url("http://127.0.0.1:14452/cancelcrash_notexist.png");
+ for (int ii = 0; ii < 1000; ++ii) {
+ QQuickPixmap pix(&engine, url);
+ }
+}
+
+class MyPixmapProvider : public QQmlImageProvider
+{
+public:
+ MyPixmapProvider()
+ : QQmlImageProvider(Pixmap) {}
+
+ virtual QPixmap requestPixmap(const QString &d, QSize *, const QSize &) {
+ Q_UNUSED(d)
+ QPixmap pix(800, 600);
+ pix.fill(Qt::red);
+ return pix;
+ }
+};
+
+// QTBUG-13345
+void tst_qquickpixmapcache::shrinkcache()
+{
+ QQmlEngine engine;
+ engine.addImageProvider(QLatin1String("mypixmaps"), new MyPixmapProvider);
+
+ for (int ii = 0; ii < 4000; ++ii) {
+ QUrl url("image://mypixmaps/" + QString::number(ii));
+ QQuickPixmap p(&engine, url);
+ }
+}
+
+#ifndef QT_NO_CONCURRENT
+
+void createNetworkServer()
+{
+ QEventLoop eventLoop;
+ TestHTTPServer server(14453);
+ server.serveDirectory(QQmlDataTest::instance()->testFile("http"));
+ QTimer::singleShot(100, &eventLoop, SLOT(quit()));
+ eventLoop.exec();
+}
+
+#ifndef QT_NO_CONCURRENT
+// QT-3957
+void tst_qquickpixmapcache::networkCrash()
+{
+ QFuture<void> future = QtConcurrent::run(createNetworkServer);
+ QQmlEngine engine;
+ for (int ii = 0; ii < 100 ; ++ii) {
+ QQuickPixmap* pixmap = new QQuickPixmap;
+ pixmap->load(&engine, QUrl(QString("http://127.0.0.1:14453/exists.png")));
+ QTest::qSleep(1);
+ pixmap->clear();
+ delete pixmap;
+ }
+ future.cancel();
+}
+#endif
+
+#endif
+
+// QTBUG-22125
+void tst_qquickpixmapcache::lockingCrash()
+{
+ TestHTTPServer server(14453);
+ server.serveDirectory(testFile("http"), TestHTTPServer::Delay);
+
+ {
+ QQuickPixmap* p = new QQuickPixmap;
+ {
+ QQmlEngine e;
+ p->load(&e, QUrl(QString("http://127.0.0.1:14453/exists6.png")));
+ }
+ p->clear();
+ QVERIFY(p->isNull());
+ delete p;
+ }
+}
+
+
+#if PIXMAP_DATA_LEAK_TEST
+// This test should not be enabled by default as it
+// produces spurious output in the expected case.
+#include <QtQuick/QQuickView>
+class DataLeakView : public QQuickView
+{
+ Q_OBJECT
+
+public:
+ explicit DataLeakView() : QQuickView()
+ {
+ setSource(testFileUrl("dataLeak.qml"));
+ }
+
+ void showFor2Seconds()
+ {
+ showFullScreen();
+ QTimer::singleShot(2000, this, SIGNAL(ready()));
+ }
+
+signals:
+ void ready();
+};
+
+// QTBUG-22742
+Q_GLOBAL_STATIC(QQuickPixmap, dataLeakPixmap)
+void tst_qquickpixmapcache::dataLeak()
+{
+ // Should not leak cached QQuickPixmapData.
+ // Unfortunately, since the QQuickPixmapStore
+ // is a global static, and it releases the cache
+ // entries on dtor (application exit), we must use
+ // valgrind to determine whether it leaks or not.
+ QQuickPixmap *p1 = new QQuickPixmap;
+ QQuickPixmap *p2 = new QQuickPixmap;
+ {
+ QScopedPointer<DataLeakView> test(new DataLeakView);
+ test->showFor2Seconds();
+ dataLeakPixmap()->load(test->engine(), testFileUrl("exists.png"));
+ p1->load(test->engine(), testFileUrl("exists.png"));
+ p2->load(test->engine(), testFileUrl("exists2.png"));
+ QTest::qWait(2005); // 2 seconds + a few more millis.
+ }
+
+ // When the (global static) dataLeakPixmap is deleted, it
+ // shouldn't attempt to dereference a QQuickPixmapData
+ // which has been deleted by the QQuickPixmapStore
+ // destructor.
+}
+#endif
+#undef PIXMAP_DATA_LEAK_TEST
+
+QTEST_MAIN(tst_qquickpixmapcache)
+
+#include "tst_qquickpixmapcache.moc"
diff --git a/tests/auto/qtquick2/qquickpositioners/data/allInvisible.qml b/tests/auto/quick/qquickpositioners/data/allInvisible.qml
index 5894171434..5894171434 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/allInvisible.qml
+++ b/tests/auto/quick/qquickpositioners/data/allInvisible.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-column.qml b/tests/auto/quick/qquickpositioners/data/attachedproperties-column.qml
index 4c667aa205..4c667aa205 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-column.qml
+++ b/tests/auto/quick/qquickpositioners/data/attachedproperties-column.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-dynamic.qml b/tests/auto/quick/qquickpositioners/data/attachedproperties-dynamic.qml
index 894749dc16..894749dc16 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-dynamic.qml
+++ b/tests/auto/quick/qquickpositioners/data/attachedproperties-dynamic.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-flow.qml b/tests/auto/quick/qquickpositioners/data/attachedproperties-flow.qml
index e7f9a63e2a..e7f9a63e2a 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-flow.qml
+++ b/tests/auto/quick/qquickpositioners/data/attachedproperties-flow.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-grid.qml b/tests/auto/quick/qquickpositioners/data/attachedproperties-grid.qml
index 2094309b9f..2094309b9f 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-grid.qml
+++ b/tests/auto/quick/qquickpositioners/data/attachedproperties-grid.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-row.qml b/tests/auto/quick/qquickpositioners/data/attachedproperties-row.qml
index 212a26b431..212a26b431 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/attachedproperties-row.qml
+++ b/tests/auto/quick/qquickpositioners/data/attachedproperties-row.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/flow-testimplicitsize.qml b/tests/auto/quick/qquickpositioners/data/flow-testimplicitsize.qml
index c32b78676c..c32b78676c 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/flow-testimplicitsize.qml
+++ b/tests/auto/quick/qquickpositioners/data/flow-testimplicitsize.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/flowtest-toptobottom.qml b/tests/auto/quick/qquickpositioners/data/flowtest-toptobottom.qml
index a7d3ee13c7..a7d3ee13c7 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/flowtest-toptobottom.qml
+++ b/tests/auto/quick/qquickpositioners/data/flowtest-toptobottom.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/flowtest.qml b/tests/auto/quick/qquickpositioners/data/flowtest.qml
index 40b042dd79..40b042dd79 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/flowtest.qml
+++ b/tests/auto/quick/qquickpositioners/data/flowtest.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/grid-animated.qml b/tests/auto/quick/qquickpositioners/data/grid-animated.qml
index b8ee8f9a52..b8ee8f9a52 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/grid-animated.qml
+++ b/tests/auto/quick/qquickpositioners/data/grid-animated.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/grid-row-column-spacing.qml b/tests/auto/quick/qquickpositioners/data/grid-row-column-spacing.qml
index 49bbd337e7..49bbd337e7 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/grid-row-column-spacing.qml
+++ b/tests/auto/quick/qquickpositioners/data/grid-row-column-spacing.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/grid-spacing.qml b/tests/auto/quick/qquickpositioners/data/grid-spacing.qml
index 535a39037f..535a39037f 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/grid-spacing.qml
+++ b/tests/auto/quick/qquickpositioners/data/grid-spacing.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/grid-toptobottom.qml b/tests/auto/quick/qquickpositioners/data/grid-toptobottom.qml
index 45559aab5d..45559aab5d 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/grid-toptobottom.qml
+++ b/tests/auto/quick/qquickpositioners/data/grid-toptobottom.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/gridtest.qml b/tests/auto/quick/qquickpositioners/data/gridtest.qml
index 50bec1377b..50bec1377b 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/gridtest.qml
+++ b/tests/auto/quick/qquickpositioners/data/gridtest.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/gridzerocolumns.qml b/tests/auto/quick/qquickpositioners/data/gridzerocolumns.qml
index a252f279c3..a252f279c3 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/gridzerocolumns.qml
+++ b/tests/auto/quick/qquickpositioners/data/gridzerocolumns.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/horizontal-animated-disabled.qml b/tests/auto/quick/qquickpositioners/data/horizontal-animated-disabled.qml
index 8723ffc78f..8723ffc78f 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/horizontal-animated-disabled.qml
+++ b/tests/auto/quick/qquickpositioners/data/horizontal-animated-disabled.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/horizontal-animated.qml b/tests/auto/quick/qquickpositioners/data/horizontal-animated.qml
index a88c26b66c..a88c26b66c 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/horizontal-animated.qml
+++ b/tests/auto/quick/qquickpositioners/data/horizontal-animated.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/horizontal-spacing.qml b/tests/auto/quick/qquickpositioners/data/horizontal-spacing.qml
index c6ff75ac6b..c6ff75ac6b 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/horizontal-spacing.qml
+++ b/tests/auto/quick/qquickpositioners/data/horizontal-spacing.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/horizontal.qml b/tests/auto/quick/qquickpositioners/data/horizontal.qml
index 235ee78c9b..235ee78c9b 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/horizontal.qml
+++ b/tests/auto/quick/qquickpositioners/data/horizontal.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/propertychangestest.qml b/tests/auto/quick/qquickpositioners/data/propertychangestest.qml
index c9fd62b012..c9fd62b012 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/propertychangestest.qml
+++ b/tests/auto/quick/qquickpositioners/data/propertychangestest.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/rectangleComponent.qml b/tests/auto/quick/qquickpositioners/data/rectangleComponent.qml
index de1bb99593..de1bb99593 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/rectangleComponent.qml
+++ b/tests/auto/quick/qquickpositioners/data/rectangleComponent.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/repeatertest.qml b/tests/auto/quick/qquickpositioners/data/repeatertest.qml
index d90e1cf160..d90e1cf160 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/repeatertest.qml
+++ b/tests/auto/quick/qquickpositioners/data/repeatertest.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/vertical-animated.qml b/tests/auto/quick/qquickpositioners/data/vertical-animated.qml
index ecf593cd70..ecf593cd70 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/vertical-animated.qml
+++ b/tests/auto/quick/qquickpositioners/data/vertical-animated.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/vertical-spacing.qml b/tests/auto/quick/qquickpositioners/data/vertical-spacing.qml
index 7087961651..7087961651 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/vertical-spacing.qml
+++ b/tests/auto/quick/qquickpositioners/data/vertical-spacing.qml
diff --git a/tests/auto/qtquick2/qquickpositioners/data/vertical.qml b/tests/auto/quick/qquickpositioners/data/vertical.qml
index 0c3a81f008..0c3a81f008 100644
--- a/tests/auto/qtquick2/qquickpositioners/data/vertical.qml
+++ b/tests/auto/quick/qquickpositioners/data/vertical.qml
diff --git a/tests/auto/quick/qquickpositioners/qquickpositioners.pro b/tests/auto/quick/qquickpositioners/qquickpositioners.pro
new file mode 100644
index 0000000000..56fe465901
--- /dev/null
+++ b/tests/auto/quick/qquickpositioners/qquickpositioners.pro
@@ -0,0 +1,14 @@
+CONFIG += testcase
+TARGET = tst_qquickpositioners
+SOURCES += tst_qquickpositioners.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
new file mode 100644
index 0000000000..ecc4c80b2a
--- /dev/null
+++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp
@@ -0,0 +1,1472 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include <private/qlistmodelinterface_p.h>
+#include <QtQuick/qquickview.h>
+#include <qqmlengine.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <QtQuick/private/qquickpositioners_p.h>
+#include <QtQuick/private/qquicktransition_p.h>
+#include <private/qquickitem_p.h>
+#include <qqmlexpression.h>
+#include "../../shared/util.h"
+
+class tst_qquickpositioners : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickpositioners();
+
+private slots:
+ void test_horizontal();
+ void test_horizontal_rtl();
+ void test_horizontal_spacing();
+ void test_horizontal_spacing_rightToLeft();
+ void test_horizontal_animated();
+ void test_horizontal_animated_rightToLeft();
+ void test_horizontal_animated_disabled();
+ void test_vertical();
+ void test_vertical_spacing();
+ void test_vertical_animated();
+ void test_grid();
+ void test_grid_topToBottom();
+ void test_grid_rightToLeft();
+ void test_grid_spacing();
+ void test_grid_row_column_spacing();
+ void test_grid_animated();
+ void test_grid_animated_rightToLeft();
+ void test_grid_zero_columns();
+ void test_propertychanges();
+ void test_repeater();
+ void test_flow();
+ void test_flow_rightToLeft();
+ void test_flow_topToBottom();
+ void test_flow_resize();
+ void test_flow_resize_rightToLeft();
+ void test_flow_implicit_resize();
+ void test_conflictinganchors();
+ void test_mirroring();
+ void test_allInvisible();
+ void test_attachedproperties();
+ void test_attachedproperties_data();
+ void test_attachedproperties_dynamic();
+
+private:
+ QQuickView *createView(const QString &filename, bool wait=true);
+};
+
+tst_qquickpositioners::tst_qquickpositioners()
+{
+}
+
+void tst_qquickpositioners::test_horizontal()
+{
+ QQuickView *canvas = createView(testFile("horizontal.qml"));
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
+
+ QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
+ QCOMPARE(row->width(), 110.0);
+ QCOMPARE(row->height(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_horizontal_rtl()
+{
+ QQuickView *canvas = createView(testFile("horizontal.qml"));
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 60.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 40.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 0.0);
+
+ QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
+ QCOMPARE(row->width(), 110.0);
+ QCOMPARE(row->height(), 50.0);
+
+ // Change the width of the row and check that items stay to the right
+ row->setWidth(200);
+ QTRY_COMPARE(one->x(), 150.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 130.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 90.0);
+ QCOMPARE(three->y(), 0.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_horizontal_spacing()
+{
+ QQuickView *canvas = createView(testFile("horizontal-spacing.qml"));
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 60.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 90.0);
+ QCOMPARE(three->y(), 0.0);
+
+ QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
+ QCOMPARE(row->width(), 130.0);
+ QCOMPARE(row->height(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_horizontal_spacing_rightToLeft()
+{
+ QQuickView *canvas = createView(testFile("horizontal-spacing.qml"));
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 80.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 00.0);
+ QCOMPARE(three->y(), 0.0);
+
+ QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
+ QCOMPARE(row->width(), 130.0);
+ QCOMPARE(row->height(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_horizontal_animated()
+{
+ QQuickView *canvas = createView(testFile("horizontal-animated.qml"), false);
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ //Note that they animate in
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(three->x(), -100.0);
+
+ QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
+
+ QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
+ QVERIFY(row);
+ QCOMPARE(row->width(), 100.0);
+ QCOMPARE(row->height(), 50.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(two->isVisible(), false);
+ QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(three->x(), 50.0);
+ QTRY_COMPARE(three->y(), 0.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QTRY_COMPARE(two->isVisible(), true);
+ QTRY_COMPARE(row->width(), 150.0);
+ QTRY_COMPARE(row->height(), 50.0);
+
+ QTest::qWait(0);//Let the animation start
+ QVERIFY(two->x() >= -100.0 && two->x() < 50.0);
+ QVERIFY(three->x() >= 50.0 && three->x() < 100.0);
+
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(three->x(), 100.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_horizontal_animated_rightToLeft()
+{
+ QQuickView *canvas = createView(testFile("horizontal-animated.qml"), false);
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ //Note that they animate in
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(three->x(), -100.0);
+
+ QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
+
+ QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
+ QVERIFY(row);
+ QCOMPARE(row->width(), 100.0);
+ QCOMPARE(row->height(), 50.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->x(), 50.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(two->isVisible(), false);
+ QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(three->x(), 0.0);
+ QTRY_COMPARE(three->y(), 0.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QTRY_COMPARE(two->isVisible(), true);
+
+ // New size should propagate after visible change
+ QTRY_COMPARE(row->width(), 150.0);
+ QTRY_COMPARE(row->height(), 50.0);
+
+ QTest::qWait(0);//Let the animation start
+ QVERIFY(one->x() >= 50.0 && one->x() < 100);
+ QVERIFY(two->x() >= -100.0 && two->x() < 50.0);
+
+ QTRY_COMPARE(one->x(), 100.0);
+ QTRY_COMPARE(two->x(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_horizontal_animated_disabled()
+{
+ QQuickView *canvas = createView(testFile("horizontal-animated-disabled.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QQuickItem *row = canvas->rootObject()->findChild<QQuickItem*>("row");
+ QVERIFY(row);
+
+ qApp->processEvents();
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->isVisible(), false);
+ QCOMPARE(two->x(), -100.0);//Not 'in' yet
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 50.0);
+ QCOMPARE(three->y(), 0.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QCOMPARE(two->isVisible(), true);
+ QTRY_COMPARE(row->width(), 150.0);
+ QTRY_COMPARE(row->height(), 50.0);
+
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(three->x(), 100.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_vertical()
+{
+ QQuickView *canvas = createView(testFile("vertical.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("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);
+
+ QQuickItem *column = canvas->rootObject()->findChild<QQuickItem*>("column");
+ QVERIFY(column);
+ QCOMPARE(column->height(), 80.0);
+ QCOMPARE(column->width(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_vertical_spacing()
+{
+ QQuickView *canvas = createView(testFile("vertical-spacing.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 0.0);
+ QCOMPARE(two->y(), 60.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 80.0);
+
+ QQuickItem *column = canvas->rootObject()->findChild<QQuickItem*>("column");
+ QCOMPARE(column->height(), 100.0);
+ QCOMPARE(column->width(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_vertical_animated()
+{
+ QQuickView *canvas = createView(testFile("vertical-animated.qml"), false);
+
+ //Note that they animate in
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QCOMPARE(one->y(), -100.0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QCOMPARE(two->y(), -100.0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QCOMPARE(three->y(), -100.0);
+
+ QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
+
+ QQuickItem *column = canvas->rootObject()->findChild<QQuickItem*>("column");
+ QVERIFY(column);
+ QCOMPARE(column->height(), 100.0);
+ QCOMPARE(column->width(), 50.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(two->isVisible(), false);
+ QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet
+ QTRY_COMPARE(two->x(), 0.0);
+ QTRY_COMPARE(three->y(), 50.0);
+ QTRY_COMPARE(three->x(), 0.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QTRY_COMPARE(two->isVisible(), true);
+ QTRY_COMPARE(column->height(), 150.0);
+ QTRY_COMPARE(column->width(), 50.0);
+ QTest::qWait(0);//Let the animation start
+ QVERIFY(two->y() >= -100.0 && two->y() < 50.0);
+ QVERIFY(three->y() >= 50.0 && three->y() < 100.0);
+
+ QTRY_COMPARE(two->y(), 50.0);
+ QTRY_COMPARE(three->y(), 100.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_grid()
+{
+ QQuickView *canvas = createView(testFile("gridtest.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 50.0);
+ QCOMPARE(five->y(), 50.0);
+
+ QQuickGrid *grid = canvas->rootObject()->findChild<QQuickGrid*>("grid");
+ QCOMPARE(grid->flow(), QQuickGrid::LeftToRight);
+ QCOMPARE(grid->width(), 100.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_grid_topToBottom()
+{
+ QQuickView *canvas = createView(testFile("grid-toptobottom.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 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(), 100.0);
+ QCOMPARE(four->x(), 50.0);
+ QCOMPARE(four->y(), 0.0);
+ QCOMPARE(five->x(), 50.0);
+ QCOMPARE(five->y(), 50.0);
+
+ QQuickGrid *grid = canvas->rootObject()->findChild<QQuickGrid*>("grid");
+ QCOMPARE(grid->flow(), QQuickGrid::TopToBottom);
+ QCOMPARE(grid->width(), 100.0);
+ QCOMPARE(grid->height(), 120.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_grid_rightToLeft()
+{
+ QQuickView *canvas = createView(testFile("gridtest.qml"));
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 50.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 30.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 50.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 40.0);
+ QCOMPARE(five->y(), 50.0);
+
+ QQuickGrid *grid = canvas->rootObject()->findChild<QQuickGrid*>("grid");
+ QCOMPARE(grid->layoutDirection(), Qt::RightToLeft);
+ QCOMPARE(grid->width(), 100.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ // Change the width of the grid and check that items stay to the right
+ grid->setWidth(200);
+ QTRY_COMPARE(one->x(), 150.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 130.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 100.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 150.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 140.0);
+ QCOMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_grid_spacing()
+{
+ QQuickView *canvas = createView(testFile("grid-spacing.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 54.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 78.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 54.0);
+ QCOMPARE(five->x(), 54.0);
+ QCOMPARE(five->y(), 54.0);
+
+ QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
+ QCOMPARE(grid->width(), 128.0);
+ QCOMPARE(grid->height(), 104.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_grid_row_column_spacing()
+{
+ QQuickView *canvas = createView(testFile("grid-row-column-spacing.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 61.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 92.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 57.0);
+ QCOMPARE(five->x(), 61.0);
+ QCOMPARE(five->y(), 57.0);
+
+ QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
+ QCOMPARE(grid->width(), 142.0);
+ QCOMPARE(grid->height(), 107.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_grid_animated()
+{
+ QQuickView *canvas = createView(testFile("grid-animated.qml"), false);
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ //Note that all animate in
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(one->y(), -100.0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QCOMPARE(three->x(), -100.0);
+ QCOMPARE(three->y(), -100.0);
+
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QCOMPARE(four->x(), -100.0);
+ QCOMPARE(four->y(), -100.0);
+
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+ QCOMPARE(five->x(), -100.0);
+ QCOMPARE(five->y(), -100.0);
+
+ QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
+
+ QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
+ QVERIFY(grid);
+ QCOMPARE(grid->width(), 150.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(two->isVisible(), false);
+ QTRY_COMPARE(two->y(), -100.0);
+ QTRY_COMPARE(two->x(), -100.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(three->x(), 50.0);
+ QTRY_COMPARE(four->y(), 0.0);
+ QTRY_COMPARE(four->x(), 100.0);
+ QTRY_COMPARE(five->y(), 50.0);
+ QTRY_COMPARE(five->x(), 0.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QCOMPARE(two->isVisible(), true);
+ QCOMPARE(grid->width(), 150.0);
+ QCOMPARE(grid->height(), 100.0);
+ QTest::qWait(0);//Let the animation start
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(three->x(), 50.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 100.0);
+ QCOMPARE(four->y(), 0.0);
+ QCOMPARE(five->x(), 0.0);
+ QCOMPARE(five->y(), 50.0);
+ //Let the animation complete
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(three->x(), 100.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(four->x(), 0.0);
+ QTRY_COMPARE(four->y(), 50.0);
+ QTRY_COMPARE(five->x(), 50.0);
+ QTRY_COMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_grid_animated_rightToLeft()
+{
+ QQuickView *canvas = createView(testFile("grid-animated.qml"), false);
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ //Note that all animate in
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QCOMPARE(one->x(), -100.0);
+ QCOMPARE(one->y(), -100.0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QCOMPARE(three->x(), -100.0);
+ QCOMPARE(three->y(), -100.0);
+
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QCOMPARE(four->x(), -100.0);
+ QCOMPARE(four->y(), -100.0);
+
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+ QCOMPARE(five->x(), -100.0);
+ QCOMPARE(five->y(), -100.0);
+
+ QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
+
+ QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
+ QVERIFY(grid);
+ QCOMPARE(grid->width(), 150.0);
+ QCOMPARE(grid->height(), 100.0);
+
+ //QTRY_COMPARE used instead of waiting for the expected time of animation completion
+ //Note that this means the duration of the animation is NOT tested
+
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(one->x(), 100.0);
+ QTRY_COMPARE(two->isVisible(), false);
+ QTRY_COMPARE(two->y(), -100.0);
+ QTRY_COMPARE(two->x(), -100.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(three->x(), 50.0);
+ QTRY_COMPARE(four->y(), 0.0);
+ QTRY_COMPARE(four->x(), 0.0);
+ QTRY_COMPARE(five->y(), 50.0);
+ QTRY_COMPARE(five->x(), 100.0);
+
+ //Add 'two'
+ two->setVisible(true);
+ QCOMPARE(two->isVisible(), true);
+ QCOMPARE(grid->width(), 150.0);
+ QCOMPARE(grid->height(), 100.0);
+ QTest::qWait(0);//Let the animation start
+ QCOMPARE(two->x(), -100.0);
+ QCOMPARE(two->y(), -100.0);
+ QCOMPARE(one->x(), 100.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(three->x(), 50.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 0.0);
+ QCOMPARE(five->x(), 100.0);
+ QCOMPARE(five->y(), 50.0);
+ //Let the animation complete
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(one->x(), 100.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(three->x(), 0.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(four->x(), 100.0);
+ QTRY_COMPARE(four->y(), 50.0);
+ QTRY_COMPARE(five->x(), 50.0);
+ QTRY_COMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_grid_zero_columns()
+{
+ QQuickView *canvas = createView(testFile("gridzerocolumns.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 70.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 120.0);
+ QCOMPARE(four->y(), 0.0);
+ QCOMPARE(five->x(), 0.0);
+ QCOMPARE(five->y(), 50.0);
+
+ QQuickItem *grid = canvas->rootObject()->findChild<QQuickItem*>("grid");
+ QCOMPARE(grid->width(), 170.0);
+ QCOMPARE(grid->height(), 60.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_propertychanges()
+{
+ QQuickView *canvas = createView(testFile("propertychangestest.qml"));
+
+ QQuickGrid *grid = qobject_cast<QQuickGrid*>(canvas->rootObject());
+ QVERIFY(grid != 0);
+ QQuickTransition *rowTransition = canvas->rootObject()->findChild<QQuickTransition*>("rowTransition");
+ QQuickTransition *columnTransition = canvas->rootObject()->findChild<QQuickTransition*>("columnTransition");
+
+ QSignalSpy addSpy(grid, SIGNAL(addChanged()));
+ QSignalSpy moveSpy(grid, SIGNAL(moveChanged()));
+ QSignalSpy columnsSpy(grid, SIGNAL(columnsChanged()));
+ QSignalSpy rowsSpy(grid, SIGNAL(rowsChanged()));
+
+ QVERIFY(grid);
+ QVERIFY(rowTransition);
+ QVERIFY(columnTransition);
+ QCOMPARE(grid->add(), columnTransition);
+ QCOMPARE(grid->move(), columnTransition);
+ QCOMPARE(grid->columns(), 4);
+ QCOMPARE(grid->rows(), -1);
+
+ grid->setAdd(rowTransition);
+ grid->setMove(rowTransition);
+ QCOMPARE(grid->add(), rowTransition);
+ QCOMPARE(grid->move(), rowTransition);
+ QCOMPARE(addSpy.count(),1);
+ QCOMPARE(moveSpy.count(),1);
+
+ grid->setAdd(rowTransition);
+ grid->setMove(rowTransition);
+ QCOMPARE(addSpy.count(),1);
+ QCOMPARE(moveSpy.count(),1);
+
+ grid->setAdd(0);
+ grid->setMove(0);
+ QCOMPARE(addSpy.count(),2);
+ QCOMPARE(moveSpy.count(),2);
+
+ grid->setColumns(-1);
+ grid->setRows(3);
+ QCOMPARE(grid->columns(), -1);
+ QCOMPARE(grid->rows(), 3);
+ QCOMPARE(columnsSpy.count(),1);
+ QCOMPARE(rowsSpy.count(),1);
+
+ grid->setColumns(-1);
+ grid->setRows(3);
+ QCOMPARE(columnsSpy.count(),1);
+ QCOMPARE(rowsSpy.count(),1);
+
+ grid->setColumns(2);
+ grid->setRows(2);
+ QCOMPARE(columnsSpy.count(),2);
+ QCOMPARE(rowsSpy.count(),2);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_repeater()
+{
+ QQuickView *canvas = createView(testFile("repeatertest.qml"));
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 100.0);
+ QCOMPARE(three->y(), 0.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_flow()
+{
+ QQuickView *canvas = createView(testFile("flowtest.qml"));
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 0.0);
+ QCOMPARE(three->y(), 50.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 70.0);
+ QCOMPARE(five->x(), 50.0);
+ QCOMPARE(five->y(), 70.0);
+
+ QQuickItem *flow = canvas->rootObject()->findChild<QQuickItem*>("flow");
+ QVERIFY(flow);
+ QCOMPARE(flow->width(), 90.0);
+ QCOMPARE(flow->height(), 120.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_flow_rightToLeft()
+{
+ QQuickView *canvas = createView(testFile("flowtest.qml"));
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 40.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 20.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 40.0);
+ QCOMPARE(three->y(), 50.0);
+ QCOMPARE(four->x(), 40.0);
+ QCOMPARE(four->y(), 70.0);
+ QCOMPARE(five->x(), 30.0);
+ QCOMPARE(five->y(), 70.0);
+
+ QQuickItem *flow = canvas->rootObject()->findChild<QQuickItem*>("flow");
+ QVERIFY(flow);
+ QCOMPARE(flow->width(), 90.0);
+ QCOMPARE(flow->height(), 120.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_flow_topToBottom()
+{
+ QQuickView *canvas = createView(testFile("flowtest-toptobottom.qml"));
+
+ canvas->rootObject()->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 0.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 50.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 50.0);
+ QCOMPARE(three->y(), 50.0);
+ QCOMPARE(four->x(), 100.0);
+ QCOMPARE(four->y(), 00.0);
+ QCOMPARE(five->x(), 100.0);
+ QCOMPARE(five->y(), 50.0);
+
+ QQuickItem *flow = canvas->rootObject()->findChild<QQuickItem*>("flow");
+ QVERIFY(flow);
+ QCOMPARE(flow->height(), 90.0);
+ QCOMPARE(flow->width(), 150.0);
+
+ canvas->rootObject()->setProperty("testRightToLeft", true);
+
+ QVERIFY(flow);
+ QCOMPARE(flow->height(), 90.0);
+ QCOMPARE(flow->width(), 150.0);
+
+ QCOMPARE(one->x(), 100.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 80.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 50.0);
+ QCOMPARE(three->y(), 50.0);
+ QCOMPARE(four->x(), 0.0);
+ QCOMPARE(four->y(), 0.0);
+ QCOMPARE(five->x(), 40.0);
+ QCOMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_flow_resize()
+{
+ QQuickView *canvas = createView(testFile("flowtest.qml"));
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root);
+ root->setWidth(125);
+ root->setProperty("testRightToLeft", false);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QVERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QTRY_COMPARE(one->x(), 0.0);
+ QTRY_COMPARE(one->y(), 0.0);
+ QTRY_COMPARE(two->x(), 50.0);
+ QTRY_COMPARE(two->y(), 0.0);
+ QTRY_COMPARE(three->x(), 70.0);
+ QTRY_COMPARE(three->y(), 0.0);
+ QTRY_COMPARE(four->x(), 0.0);
+ QTRY_COMPARE(four->y(), 50.0);
+ QTRY_COMPARE(five->x(), 50.0);
+ QTRY_COMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_flow_resize_rightToLeft()
+{
+ QQuickView *canvas = createView(testFile("flowtest.qml"));
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root);
+ root->setWidth(125);
+ root->setProperty("testRightToLeft", true);
+
+ QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
+ QTRY_VERIFY(one != 0);
+ QQuickRectangle *two = canvas->rootObject()->findChild<QQuickRectangle*>("two");
+ QVERIFY(two != 0);
+ QQuickRectangle *three = canvas->rootObject()->findChild<QQuickRectangle*>("three");
+ QVERIFY(three != 0);
+ QQuickRectangle *four = canvas->rootObject()->findChild<QQuickRectangle*>("four");
+ QVERIFY(four != 0);
+ QQuickRectangle *five = canvas->rootObject()->findChild<QQuickRectangle*>("five");
+ QVERIFY(five != 0);
+
+ QCOMPARE(one->x(), 75.0);
+ QCOMPARE(one->y(), 0.0);
+ QCOMPARE(two->x(), 55.0);
+ QCOMPARE(two->y(), 0.0);
+ QCOMPARE(three->x(), 5.0);
+ QCOMPARE(three->y(), 0.0);
+ QCOMPARE(four->x(), 75.0);
+ QCOMPARE(four->y(), 50.0);
+ QCOMPARE(five->x(), 65.0);
+ QCOMPARE(five->y(), 50.0);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_flow_implicit_resize()
+{
+ QQuickView *canvas = createView(testFile("flow-testimplicitsize.qml"));
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickFlow *flow = canvas->rootObject()->findChild<QQuickFlow*>("flow");
+ QVERIFY(flow != 0);
+
+ QCOMPARE(flow->width(), 100.0);
+ QCOMPARE(flow->height(), 120.0);
+
+ canvas->rootObject()->setProperty("flowLayout", 0);
+ QCOMPARE(flow->flow(), QQuickFlow::LeftToRight);
+ QCOMPARE(flow->width(), 220.0);
+ QCOMPARE(flow->height(), 50.0);
+
+ canvas->rootObject()->setProperty("flowLayout", 1);
+ QCOMPARE(flow->flow(), QQuickFlow::TopToBottom);
+ QCOMPARE(flow->width(), 100.0);
+ QCOMPARE(flow->height(), 120.0);
+
+ canvas->rootObject()->setProperty("flowLayout", 2);
+ QCOMPARE(flow->layoutDirection(), Qt::RightToLeft);
+ QCOMPARE(flow->width(), 220.0);
+ QCOMPARE(flow->height(), 50.0);
+
+ delete canvas;
+}
+
+QString warningMessage;
+
+void interceptWarnings(QtMsgType type, const char *msg)
+{
+ Q_UNUSED( type );
+ warningMessage = msg;
+}
+
+void tst_qquickpositioners::test_conflictinganchors()
+{
+ QtMsgHandler oldMsgHandler = qInstallMsgHandler(interceptWarnings);
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+
+ component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; } }", QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ delete item;
+
+ component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ delete item;
+
+ component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ delete item;
+
+ component.setData("import QtQuick 2.0\nFlow { Item { width: 100; height: 100; } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ delete item;
+
+ component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.top: parent.top } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function."));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.centerIn: parent } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column. Column will not function."));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 2.0\nColumn { Item { width: 100; height: 100; anchors.left: parent.left } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; anchors.left: parent.left } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function."));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 2.0\nRow { width: 100; height: 100; Item { anchors.fill: parent } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function."));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 2.0\nRow { Item { width: 100; height: 100; anchors.top: parent.top } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QVERIFY(warningMessage.isEmpty());
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; anchors.horizontalCenter: parent.horizontalCenter } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function."));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 2.0\nGrid { Item { width: 100; height: 100; anchors.centerIn: parent } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid. Grid will not function."));
+ warningMessage.clear();
+ delete item;
+
+ component.setData("import QtQuick 2.0\nFlow { Item { width: 100; height: 100; anchors.verticalCenter: parent.verticalCenter } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function."));
+ delete item;
+
+ component.setData("import QtQuick 2.0\nFlow { width: 100; height: 100; Item { anchors.fill: parent } }", QUrl::fromLocalFile(""));
+ item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item);
+ QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow. Flow will not function."));
+ qInstallMsgHandler(oldMsgHandler);
+ delete item;
+}
+
+void tst_qquickpositioners::test_mirroring()
+{
+ QList<QString> qmlFiles;
+ qmlFiles << "horizontal.qml" << "gridtest.qml" << "flowtest.qml";
+ QList<QString> objectNames;
+ objectNames << "one" << "two" << "three" << "four" << "five";
+
+ foreach (const QString qmlFile, qmlFiles) {
+ QQuickView *canvasA = createView(testFile(qmlFile));
+ QQuickItem *rootA = qobject_cast<QQuickItem*>(canvasA->rootObject());
+
+ QQuickView *canvasB = createView(testFile(qmlFile));
+ QQuickItem *rootB = qobject_cast<QQuickItem*>(canvasB->rootObject());
+
+ rootA->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft
+
+ // LTR != RTL
+ foreach (const QString objectName, objectNames) {
+ // horizontal.qml only has three items
+ if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
+ break;
+ QQuickItem *itemA = rootA->findChild<QQuickItem*>(objectName);
+ QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName);
+ QTRY_VERIFY(itemA->x() != itemB->x());
+ }
+
+ QQmlProperty enabledProp(rootB, "LayoutMirroring.enabled", qmlContext(rootB));
+ enabledProp.write(true);
+ QQmlProperty inheritProp(rootB, "LayoutMirroring.childrenInherit", qmlContext(rootB));
+ inheritProp.write(true);
+
+ // RTL == mirror
+ foreach (const QString objectName, objectNames) {
+ // horizontal.qml only has three items
+ if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
+ break;
+ QQuickItem *itemA = rootA->findChild<QQuickItem*>(objectName);
+ QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName);
+ QTRY_COMPARE(itemA->x(), itemB->x());
+ }
+
+ rootA->setProperty("testRightToLeft", false); // layoutDirection: Qt.LeftToRight
+ rootB->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft
+
+ // LTR == RTL + mirror
+ foreach (const QString objectName, objectNames) {
+ // horizontal.qml only has three items
+ if (qmlFile == QString("horizontal.qml") && objectName == QString("four"))
+ break;
+ QQuickItem *itemA = rootA->findChild<QQuickItem*>(objectName);
+ QQuickItem *itemB = rootB->findChild<QQuickItem*>(objectName);
+ QTRY_COMPARE(itemA->x(), itemB->x());
+ }
+ delete canvasA;
+ delete canvasB;
+ }
+}
+
+void tst_qquickpositioners::test_allInvisible()
+{
+ //QTBUG-19361
+ QQuickView *canvas = createView(testFile("allInvisible.qml"));
+
+ QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(root);
+
+ QQuickRow *row = canvas->rootObject()->findChild<QQuickRow*>("row");
+ QVERIFY(row != 0);
+ QVERIFY(row->width() == 0);
+ QVERIFY(row->height() == 0);
+ QQuickColumn *column = canvas->rootObject()->findChild<QQuickColumn*>("column");
+ QVERIFY(column != 0);
+ QVERIFY(column->width() == 0);
+ QVERIFY(column->height() == 0);
+}
+
+void tst_qquickpositioners::test_attachedproperties()
+{
+ QFETCH(QString, filename);
+
+ QQuickView *canvas = createView(filename);
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickRectangle *greenRect = canvas->rootObject()->findChild<QQuickRectangle *>("greenRect");
+ QVERIFY(greenRect != 0);
+
+ int posIndex = greenRect->property("posIndex").toInt();
+ QVERIFY(posIndex == 0);
+ bool isFirst = greenRect->property("isFirstItem").toBool();
+ QVERIFY(isFirst == true);
+ bool isLast = greenRect->property("isLastItem").toBool();
+ QVERIFY(isLast == false);
+
+ QQuickRectangle *yellowRect = canvas->rootObject()->findChild<QQuickRectangle *>("yellowRect");
+ QVERIFY(yellowRect != 0);
+
+ posIndex = yellowRect->property("posIndex").toInt();
+ QVERIFY(posIndex == -1);
+ isFirst = yellowRect->property("isFirstItem").toBool();
+ QVERIFY(isFirst == false);
+ isLast = yellowRect->property("isLastItem").toBool();
+ QVERIFY(isLast == false);
+
+ yellowRect->metaObject()->invokeMethod(yellowRect, "onDemandPositioner");
+
+ posIndex = yellowRect->property("posIndex").toInt();
+ QVERIFY(posIndex == 1);
+ isFirst = yellowRect->property("isFirstItem").toBool();
+ QVERIFY(isFirst == false);
+ isLast = yellowRect->property("isLastItem").toBool();
+ QVERIFY(isLast == true);
+
+ delete canvas;
+}
+
+void tst_qquickpositioners::test_attachedproperties_data()
+{
+ QTest::addColumn<QString>("filename");
+
+ QTest::newRow("column") << testFile("attachedproperties-column.qml");
+ QTest::newRow("row") << testFile("attachedproperties-row.qml");
+ QTest::newRow("grid") << testFile("attachedproperties-grid.qml");
+ QTest::newRow("flow") << testFile("attachedproperties-flow.qml");
+}
+
+void tst_qquickpositioners::test_attachedproperties_dynamic()
+{
+ QQuickView *canvas = createView(testFile("attachedproperties-dynamic.qml"));
+ QVERIFY(canvas->rootObject() != 0);
+
+ QQuickRow *row = canvas->rootObject()->findChild<QQuickRow *>("pos");
+ QVERIFY(row != 0);
+
+ QQuickRectangle *rect0 = canvas->rootObject()->findChild<QQuickRectangle *>("rect0");
+ QVERIFY(rect0 != 0);
+
+ int posIndex = rect0->property("index").toInt();
+ QVERIFY(posIndex == 0);
+ bool isFirst = rect0->property("firstItem").toBool();
+ QVERIFY(isFirst == true);
+ bool isLast = rect0->property("lastItem").toBool();
+ QVERIFY(isLast == false);
+
+ QQuickRectangle *rect1 = canvas->rootObject()->findChild<QQuickRectangle *>("rect1");
+ QVERIFY(rect1 != 0);
+
+ posIndex = rect1->property("index").toInt();
+ QVERIFY(posIndex == 1);
+ isFirst = rect1->property("firstItem").toBool();
+ QVERIFY(isFirst == false);
+ isLast = rect1->property("lastItem").toBool();
+ QVERIFY(isLast == true);
+
+ row->metaObject()->invokeMethod(row, "createSubRect");
+
+ QTRY_VERIFY(rect1->property("index").toInt() == 1);
+ QTRY_VERIFY(rect1->property("firstItem").toBool() == false);
+ QTRY_VERIFY(rect1->property("lastItem").toBool() == false);
+
+ QQuickRectangle *rect2 = canvas->rootObject()->findChild<QQuickRectangle *>("rect2");
+ QVERIFY(rect2 != 0);
+
+ posIndex = rect2->property("index").toInt();
+ QVERIFY(posIndex == 2);
+ isFirst = rect2->property("firstItem").toBool();
+ QVERIFY(isFirst == false);
+ isLast = rect2->property("lastItem").toBool();
+ QVERIFY(isLast == true);
+
+ row->metaObject()->invokeMethod(row, "destroySubRect");
+
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+
+ QTRY_VERIFY(rect1->property("index").toInt() == 1);
+ QTRY_VERIFY(rect1->property("firstItem").toBool() == false);
+ QTRY_VERIFY(rect1->property("lastItem").toBool() == true);
+
+ delete canvas;
+}
+
+QQuickView *tst_qquickpositioners::createView(const QString &filename, bool wait)
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+ canvas->show();
+ if (wait)
+ QTest::qWaitForWindowShown(canvas); //It may not relayout until the next frame, so it needs to be drawn
+
+ return canvas;
+}
+
+
+QTEST_MAIN(tst_qquickpositioners)
+
+#include "tst_qquickpositioners.moc"
diff --git a/tests/auto/qtquick2/qquickrepeater/data/asyncloader.qml b/tests/auto/quick/qquickrepeater/data/asyncloader.qml
index 82094e2666..82094e2666 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/asyncloader.qml
+++ b/tests/auto/quick/qquickrepeater/data/asyncloader.qml
diff --git a/tests/auto/qtquick2/qquickrepeater/data/initparent.qml b/tests/auto/quick/qquickrepeater/data/initparent.qml
index e6571f09d3..e6571f09d3 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/initparent.qml
+++ b/tests/auto/quick/qquickrepeater/data/initparent.qml
diff --git a/tests/auto/qtquick2/qquickrepeater/data/intmodel.qml b/tests/auto/quick/qquickrepeater/data/intmodel.qml
index 30a650dd52..30a650dd52 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/intmodel.qml
+++ b/tests/auto/quick/qquickrepeater/data/intmodel.qml
diff --git a/tests/auto/qtquick2/qquickrepeater/data/itemlist.qml b/tests/auto/quick/qquickrepeater/data/itemlist.qml
index 174bfd4d18..174bfd4d18 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/itemlist.qml
+++ b/tests/auto/quick/qquickrepeater/data/itemlist.qml
diff --git a/tests/auto/qtquick2/qquickrepeater/data/modelChanged.qml b/tests/auto/quick/qquickrepeater/data/modelChanged.qml
index 23af127e79..23af127e79 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/modelChanged.qml
+++ b/tests/auto/quick/qquickrepeater/data/modelChanged.qml
diff --git a/tests/auto/qtquick2/qquickrepeater/data/objlist.qml b/tests/auto/quick/qquickrepeater/data/objlist.qml
index c49d5926e5..c49d5926e5 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/objlist.qml
+++ b/tests/auto/quick/qquickrepeater/data/objlist.qml
diff --git a/tests/auto/qtquick2/qquickrepeater/data/properties.qml b/tests/auto/quick/qquickrepeater/data/properties.qml
index 035431c784..035431c784 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/properties.qml
+++ b/tests/auto/quick/qquickrepeater/data/properties.qml
diff --git a/tests/auto/qtquick2/qquickrepeater/data/repeater1.qml b/tests/auto/quick/qquickrepeater/data/repeater1.qml
index 3e6f4071ff..3e6f4071ff 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/repeater1.qml
+++ b/tests/auto/quick/qquickrepeater/data/repeater1.qml
diff --git a/tests/auto/qtquick2/qquickrepeater/data/repeater2.qml b/tests/auto/quick/qquickrepeater/data/repeater2.qml
index 691fbda1e5..691fbda1e5 100644
--- a/tests/auto/qtquick2/qquickrepeater/data/repeater2.qml
+++ b/tests/auto/quick/qquickrepeater/data/repeater2.qml
diff --git a/tests/auto/quick/qquickrepeater/qquickrepeater.pro b/tests/auto/quick/qquickrepeater/qquickrepeater.pro
new file mode 100644
index 0000000000..c3d96ee6d5
--- /dev/null
+++ b/tests/auto/quick/qquickrepeater/qquickrepeater.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickrepeater
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickrepeater.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+testFiles.files = data
+testFiles.path = .
+DEPLOYMENT += testFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
new file mode 100644
index 0000000000..1b07a6e9f8
--- /dev/null
+++ b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
@@ -0,0 +1,644 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtTest/QSignalSpy>
+#include <private/qlistmodelinterface_p.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQuick/qquickview.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlincubator.h>
+#include <private/qquickrepeater_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+
+#include "../../shared/util.h"
+#include "../shared/viewtestutil.h"
+#include "../shared/visualtestutil.h"
+
+using namespace QQuickViewTestUtil;
+using namespace QQuickVisualTestUtil;
+
+
+class tst_QQuickRepeater : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickRepeater();
+
+private slots:
+ void numberModel();
+ void objectList();
+ void stringList();
+ void dataModel_adding();
+ void dataModel_removing();
+ void dataModel_changes();
+ void itemModel();
+ void resetModel();
+ void modelChanged();
+ void properties();
+ void asynchronous();
+ void initParent();
+};
+
+class TestObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool error READ error WRITE setError)
+ Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged)
+
+public:
+ TestObject() : QObject(), mError(true), mUseModel(false) {}
+
+ bool error() const { return mError; }
+ void setError(bool err) { mError = err; }
+
+ bool useModel() const { return mUseModel; }
+ void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); }
+
+signals:
+ void useModelChanged();
+
+private:
+ bool mError;
+ bool mUseModel;
+};
+
+tst_QQuickRepeater::tst_QQuickRepeater()
+{
+}
+
+void tst_QQuickRepeater::numberModel()
+{
+ QQuickView *canvas = createView();
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testData", 5);
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("intmodel.qml"));
+ qApp->processEvents();
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+ QCOMPARE(repeater->parentItem()->childItems().count(), 5+1);
+
+ QVERIFY(!repeater->itemAt(-1));
+ for (int i=0; i<repeater->count(); i++)
+ QCOMPARE(repeater->itemAt(i), repeater->parentItem()->childItems().at(i));
+ QVERIFY(!repeater->itemAt(repeater->count()));
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ delete testObject;
+ delete canvas;
+}
+
+class MyObject : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int idx READ idx CONSTANT)
+public:
+ MyObject(int i) : QObject(), m_idx(i) {}
+
+ int idx() const { return m_idx; }
+
+ int m_idx;
+};
+
+void tst_QQuickRepeater::objectList()
+{
+ QQuickView *canvas = createView();
+ QObjectList data;
+ for (int i=0; i<100; i++)
+ data << new MyObject(i);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testData", QVariant::fromValue(data));
+
+ canvas->setSource(testFileUrl("objlist.qml"));
+ qApp->processEvents();
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+ QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data
+ QCOMPARE(repeater->property("instantiated").toInt(), 100);
+
+ QVERIFY(!repeater->itemAt(-1));
+ for (int i=0; i<data.count(); i++)
+ QCOMPARE(repeater->itemAt(i), repeater->parentItem()->childItems().at(i));
+ QVERIFY(!repeater->itemAt(data.count()));
+
+ QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*)));
+ QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*)));
+ ctxt->setContextProperty("testData", QVariant::fromValue(data));
+ QCOMPARE(addedSpy.count(), data.count());
+ QCOMPARE(removedSpy.count(), data.count());
+
+ qDeleteAll(data);
+ delete canvas;
+}
+
+/*
+The Repeater element creates children at its own position in its parent's
+stacking order. In this test we insert a repeater between two other Text
+elements to test this.
+*/
+void tst_QQuickRepeater::stringList()
+{
+ QQuickView *canvas = createView();
+
+ QStringList data;
+ data << "One";
+ data << "Two";
+ data << "Three";
+ data << "Four";
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testData", data);
+
+ canvas->setSource(testFileUrl("repeater1.qml"));
+ qApp->processEvents();
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+
+ QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
+ QVERIFY(container != 0);
+
+ QCOMPARE(container->childItems().count(), data.count() + 3);
+
+ bool saw_repeater = false;
+ for (int i = 0; i < container->childItems().count(); ++i) {
+
+ if (i == 0) {
+ QQuickText *name = qobject_cast<QQuickText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QLatin1String("Zero"));
+ } else if (i == container->childItems().count() - 2) {
+ // The repeater itself
+ QQuickRepeater *rep = qobject_cast<QQuickRepeater*>(container->childItems().at(i));
+ QCOMPARE(rep, repeater);
+ saw_repeater = true;
+ continue;
+ } else if (i == container->childItems().count() - 1) {
+ QQuickText *name = qobject_cast<QQuickText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QLatin1String("Last"));
+ } else {
+ QQuickText *name = qobject_cast<QQuickText*>(container->childItems().at(i));
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), data.at(i-1));
+ }
+ }
+ QVERIFY(saw_repeater);
+
+ delete canvas;
+}
+
+void tst_QQuickRepeater::dataModel_adding()
+{
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ QaimModel testModel;
+ ctxt->setContextProperty("testData", &testModel);
+ canvas->setSource(testFileUrl("repeater2.qml"));
+ qApp->processEvents();
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+ QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
+ QVERIFY(container != 0);
+
+ QVERIFY(!repeater->itemAt(0));
+
+ QSignalSpy countSpy(repeater, SIGNAL(countChanged()));
+ QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*)));
+
+ // add to empty model
+ testModel.addItem("two", "2");
+ QCOMPARE(repeater->itemAt(0), container->childItems().at(0));
+ QCOMPARE(countSpy.count(), 1); countSpy.clear();
+ QCOMPARE(addedSpy.count(), 1);
+ QCOMPARE(addedSpy.at(0).at(0).toInt(), 0);
+ QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(0));
+ addedSpy.clear();
+
+ // insert at start
+ testModel.insertItem(0, "one", "1");
+ QCOMPARE(repeater->itemAt(0), container->childItems().at(0));
+ QCOMPARE(countSpy.count(), 1); countSpy.clear();
+ QCOMPARE(addedSpy.count(), 1);
+ QCOMPARE(addedSpy.at(0).at(0).toInt(), 0);
+ QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(0));
+ addedSpy.clear();
+
+ // insert at end
+ testModel.insertItem(2, "four", "4");
+ QCOMPARE(repeater->itemAt(2), container->childItems().at(2));
+ QCOMPARE(countSpy.count(), 1); countSpy.clear();
+ QCOMPARE(addedSpy.count(), 1);
+ QCOMPARE(addedSpy.at(0).at(0).toInt(), 2);
+ QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(2));
+ addedSpy.clear();
+
+ // insert in middle
+ testModel.insertItem(2, "three", "3");
+ QCOMPARE(repeater->itemAt(2), container->childItems().at(2));
+ QCOMPARE(countSpy.count(), 1); countSpy.clear();
+ QCOMPARE(addedSpy.count(), 1);
+ QCOMPARE(addedSpy.at(0).at(0).toInt(), 2);
+ QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(2));
+ addedSpy.clear();
+
+ delete testObject;
+ addedSpy.clear();
+ countSpy.clear();
+ delete canvas;
+}
+
+void tst_QQuickRepeater::dataModel_removing()
+{
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ QaimModel testModel;
+ testModel.addItem("one", "1");
+ testModel.addItem("two", "2");
+ testModel.addItem("three", "3");
+ testModel.addItem("four", "4");
+ testModel.addItem("five", "5");
+
+ ctxt->setContextProperty("testData", &testModel);
+ canvas->setSource(testFileUrl("repeater2.qml"));
+ qApp->processEvents();
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+ QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
+ QVERIFY(container != 0);
+ QCOMPARE(container->childItems().count(), repeater->count()+1);
+
+ QSignalSpy countSpy(repeater, SIGNAL(countChanged()));
+ QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*)));
+
+ // remove at start
+ QQuickItem *item = repeater->itemAt(0);
+ QCOMPARE(item, container->childItems().at(0));
+
+ testModel.removeItem(0);
+ QVERIFY(repeater->itemAt(0) != item);
+ QCOMPARE(countSpy.count(), 1); countSpy.clear();
+ QCOMPARE(removedSpy.count(), 1);
+ QCOMPARE(removedSpy.at(0).at(0).toInt(), 0);
+ QCOMPARE(removedSpy.at(0).at(1).value<QQuickItem*>(), item);
+ removedSpy.clear();
+
+ // remove at end
+ int lastIndex = testModel.count()-1;
+ item = repeater->itemAt(lastIndex);
+ QCOMPARE(item, container->childItems().at(lastIndex));
+
+ testModel.removeItem(lastIndex);
+ QVERIFY(repeater->itemAt(lastIndex) != item);
+ QCOMPARE(countSpy.count(), 1); countSpy.clear();
+ QCOMPARE(removedSpy.count(), 1);
+ QCOMPARE(removedSpy.at(0).at(0).toInt(), lastIndex);
+ QCOMPARE(removedSpy.at(0).at(1).value<QQuickItem*>(), item);
+ removedSpy.clear();
+
+ // remove from middle
+ item = repeater->itemAt(1);
+ QCOMPARE(item, container->childItems().at(1));
+
+ testModel.removeItem(1);
+ QVERIFY(repeater->itemAt(lastIndex) != item);
+ QCOMPARE(countSpy.count(), 1); countSpy.clear();
+ QCOMPARE(removedSpy.count(), 1);
+ QCOMPARE(removedSpy.at(0).at(0).toInt(), 1);
+ QCOMPARE(removedSpy.at(0).at(1).value<QQuickItem*>(), item);
+ removedSpy.clear();
+
+ delete testObject;
+ delete canvas;
+}
+
+void tst_QQuickRepeater::dataModel_changes()
+{
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ QaimModel testModel;
+ testModel.addItem("one", "1");
+ testModel.addItem("two", "2");
+ testModel.addItem("three", "3");
+
+ ctxt->setContextProperty("testData", &testModel);
+ canvas->setSource(testFileUrl("repeater2.qml"));
+ qApp->processEvents();
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+ QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
+ QVERIFY(container != 0);
+ QCOMPARE(container->childItems().count(), repeater->count()+1);
+
+ // Check that model changes are propagated
+ QQuickText *text = findItem<QQuickText>(canvas->rootObject(), "myName", 1);
+ QVERIFY(text);
+ QCOMPARE(text->text(), QString("two"));
+
+ testModel.modifyItem(1, "Item two", "_2");
+ text = findItem<QQuickText>(canvas->rootObject(), "myName", 1);
+ QVERIFY(text);
+ QCOMPARE(text->text(), QString("Item two"));
+
+ text = findItem<QQuickText>(canvas->rootObject(), "myNumber", 1);
+ QVERIFY(text);
+ QCOMPARE(text->text(), QString("_2"));
+
+ delete testObject;
+ delete canvas;
+}
+
+void tst_QQuickRepeater::itemModel()
+{
+ QQuickView *canvas = createView();
+ QQmlContext *ctxt = canvas->rootContext();
+ TestObject *testObject = new TestObject;
+ ctxt->setContextProperty("testObject", testObject);
+
+ canvas->setSource(testFileUrl("itemlist.qml"));
+ qApp->processEvents();
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+
+ QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
+ QVERIFY(container != 0);
+
+ QCOMPARE(container->childItems().count(), 1);
+
+ testObject->setUseModel(true);
+ QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+
+ QCOMPARE(container->childItems().count(), 4);
+ QVERIFY(qobject_cast<QObject*>(container->childItems().at(0))->objectName() == "item1");
+ QVERIFY(qobject_cast<QObject*>(container->childItems().at(1))->objectName() == "item2");
+ QVERIFY(qobject_cast<QObject*>(container->childItems().at(2))->objectName() == "item3");
+ QVERIFY(container->childItems().at(3) == repeater);
+
+ QMetaObject::invokeMethod(canvas->rootObject(), "switchModel");
+ QCOMPARE(container->childItems().count(), 3);
+ QVERIFY(qobject_cast<QObject*>(container->childItems().at(0))->objectName() == "item4");
+ QVERIFY(qobject_cast<QObject*>(container->childItems().at(1))->objectName() == "item5");
+ QVERIFY(container->childItems().at(2) == repeater);
+
+ testObject->setUseModel(false);
+ QCOMPARE(container->childItems().count(), 1);
+
+ delete testObject;
+ delete canvas;
+}
+
+void tst_QQuickRepeater::resetModel()
+{
+ QQuickView *canvas = createView();
+
+ QStringList dataA;
+ for (int i=0; i<10; i++)
+ dataA << QString::number(i);
+
+ QQmlContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testData", dataA);
+ canvas->setSource(testFileUrl("repeater1.qml"));
+ qApp->processEvents();
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
+ QVERIFY(repeater != 0);
+ QQuickItem *container = findItem<QQuickItem>(canvas->rootObject(), "container");
+ QVERIFY(container != 0);
+
+ QCOMPARE(repeater->count(), dataA.count());
+ for (int i=0; i<repeater->count(); i++)
+ QCOMPARE(repeater->itemAt(i), container->childItems().at(i+1)); // +1 to skip first Text object
+
+ QSignalSpy modelChangedSpy(repeater, SIGNAL(modelChanged()));
+ QSignalSpy countSpy(repeater, SIGNAL(countChanged()));
+ QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QQuickItem*)));
+ QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QQuickItem*)));
+
+ QStringList dataB;
+ for (int i=0; i<20; i++)
+ dataB << QString::number(i);
+
+ // reset context property
+ ctxt->setContextProperty("testData", dataB);
+ QCOMPARE(repeater->count(), dataB.count());
+
+ QCOMPARE(modelChangedSpy.count(), 1);
+ QCOMPARE(countSpy.count(), 1);
+ QCOMPARE(removedSpy.count(), dataA.count());
+ QCOMPARE(addedSpy.count(), dataB.count());
+ for (int i=0; i<dataB.count(); i++) {
+ QCOMPARE(addedSpy.at(i).at(0).toInt(), i);
+ QCOMPARE(addedSpy.at(i).at(1).value<QQuickItem*>(), repeater->itemAt(i));
+ }
+ modelChangedSpy.clear();
+ countSpy.clear();
+ removedSpy.clear();
+ addedSpy.clear();
+
+ // reset via setModel()
+ repeater->setModel(dataA);
+ QCOMPARE(repeater->count(), dataA.count());
+
+ QCOMPARE(modelChangedSpy.count(), 1);
+ QCOMPARE(countSpy.count(), 1);
+ QCOMPARE(removedSpy.count(), dataB.count());
+ QCOMPARE(addedSpy.count(), dataA.count());
+ for (int i=0; i<dataA.count(); i++) {
+ QCOMPARE(addedSpy.at(i).at(0).toInt(), i);
+ QCOMPARE(addedSpy.at(i).at(1).value<QQuickItem*>(), repeater->itemAt(i));
+ }
+
+ modelChangedSpy.clear();
+ countSpy.clear();
+ removedSpy.clear();
+ addedSpy.clear();
+
+ delete canvas;
+}
+
+// QTBUG-17156
+void tst_QQuickRepeater::modelChanged()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("modelChanged.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(rootObject);
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(rootObject, "repeater");
+ QVERIFY(repeater);
+
+ repeater->setModel(4);
+ QCOMPARE(repeater->count(), 4);
+ QCOMPARE(repeater->property("itemsCount").toInt(), 4);
+ QCOMPARE(repeater->property("itemsFound").toList().count(), 4);
+
+ repeater->setModel(10);
+ QCOMPARE(repeater->count(), 10);
+ QCOMPARE(repeater->property("itemsCount").toInt(), 10);
+ QCOMPARE(repeater->property("itemsFound").toList().count(), 10);
+
+ delete rootObject;
+}
+
+void tst_QQuickRepeater::properties()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("properties.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(rootObject);
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(rootObject, "repeater");
+ QVERIFY(repeater);
+
+ QSignalSpy modelSpy(repeater, SIGNAL(modelChanged()));
+ repeater->setModel(3);
+ QCOMPARE(modelSpy.count(),1);
+ repeater->setModel(3);
+ QCOMPARE(modelSpy.count(),1);
+
+ QSignalSpy delegateSpy(repeater, SIGNAL(delegateChanged()));
+
+ QQmlComponent rectComponent(&engine);
+ rectComponent.setData("import QtQuick 2.0; Rectangle {}", QUrl::fromLocalFile(""));
+
+ repeater->setDelegate(&rectComponent);
+ QCOMPARE(delegateSpy.count(),1);
+ repeater->setDelegate(&rectComponent);
+ QCOMPARE(delegateSpy.count(),1);
+
+ delete rootObject;
+}
+
+void tst_QQuickRepeater::asynchronous()
+{
+ QQuickView *canvas = createView();
+ canvas->show();
+ QQmlIncubationController controller;
+ canvas->engine()->setIncubationController(&controller);
+
+ canvas->setSource(testFileUrl("asyncloader.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(rootObject);
+
+ QQuickItem *container = findItem<QQuickItem>(rootObject, "container");
+ QVERIFY(!container);
+ while (!container) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ container = findItem<QQuickItem>(rootObject, "container");
+ }
+
+ QQuickRepeater *repeater = 0;
+ while (!repeater) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ repeater = findItem<QQuickRepeater>(rootObject, "repeater");
+ }
+
+ // items will be created one at a time
+ for (int i = 0; i < 10; ++i) {
+ QString name("delegate");
+ name += QString::number(i);
+ QVERIFY(findItem<QQuickItem>(container, name) == 0);
+ QQuickItem *item = 0;
+ while (!item) {
+ bool b = false;
+ controller.incubateWhile(&b);
+ item = findItem<QQuickItem>(container, name);
+ }
+ }
+
+ {
+ bool b = true;
+ controller.incubateWhile(&b);
+ }
+
+ // verify positioning
+ for (int i = 0; i < 10; ++i) {
+ QString name("delegate");
+ name += QString::number(i);
+ QQuickItem *item = findItem<QQuickItem>(container, name);
+ QTRY_COMPARE(item->y(), i * 50.0);
+ }
+
+ delete canvas;
+}
+
+void tst_QQuickRepeater::initParent()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("initparent.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(rootObject);
+
+ QCOMPARE(qvariant_cast<QQuickItem*>(rootObject->property("parentItem")), rootObject);
+}
+
+QTEST_MAIN(tst_QQuickRepeater)
+
+#include "tst_qquickrepeater.moc"
diff --git a/tests/auto/qtquick2/qquickscreen/data/screen.qml b/tests/auto/quick/qquickscreen/data/screen.qml
index 780b22f23d..780b22f23d 100644
--- a/tests/auto/qtquick2/qquickscreen/data/screen.qml
+++ b/tests/auto/quick/qquickscreen/data/screen.qml
diff --git a/tests/auto/quick/qquickscreen/qquickscreen.pro b/tests/auto/quick/qquickscreen/qquickscreen.pro
new file mode 100644
index 0000000000..00ec51ef33
--- /dev/null
+++ b/tests/auto/quick/qquickscreen/qquickscreen.pro
@@ -0,0 +1,10 @@
+CONFIG += testcase
+TARGET = tst_qquickscreen
+SOURCES += tst_qquickscreen.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private testlib quick-private
diff --git a/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp b/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp
new file mode 100644
index 0000000000..cbf9438f24
--- /dev/null
+++ b/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDebug>
+#include <QtQuick/QQuickItem>
+#include <QtQuick/QQuickView>
+#include <QtGui/QScreen>
+#include "../../shared/util.h"
+
+class tst_qquickscreen : public QQmlDataTest
+{
+ Q_OBJECT
+private slots:
+ void basicProperties();
+};
+
+void tst_qquickscreen::basicProperties()
+{
+ QQuickView view;
+ view.setSource(testFileUrl("screen.qml"));
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QQuickItem* root = view.rootObject();
+ QVERIFY(root);
+
+ QScreen* screen = view.screen();
+ QVERIFY(screen);
+
+ QCOMPARE(screen->size().width(), root->property("w").toInt());
+ QCOMPARE(screen->size().height(), root->property("h").toInt());
+ QCOMPARE(int(screen->orientation()), root->property("curOrientation").toInt());
+ QCOMPARE(int(screen->primaryOrientation()), root->property("priOrientation").toInt());
+}
+
+QTEST_MAIN(tst_qquickscreen)
+
+#include "tst_qquickscreen.moc"
diff --git a/tests/auto/quick/qquickshadereffect/qquickshadereffect.pro b/tests/auto/quick/qquickshadereffect/qquickshadereffect.pro
new file mode 100644
index 0000000000..6ff50a0553
--- /dev/null
+++ b/tests/auto/quick/qquickshadereffect/qquickshadereffect.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+TARGET = tst_qquickshadereffect
+SOURCES += tst_qquickshadereffect.cpp
+
+macx:CONFIG -= app_bundle
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private quick-private widgets testlib
diff --git a/tests/auto/qtquick2/qquickshadereffect/tst_qquickshadereffect.cpp b/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp
index 00ae8fc76d..00ae8fc76d 100644
--- a/tests/auto/qtquick2/qquickshadereffect/tst_qquickshadereffect.cpp
+++ b/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/deleteOnUpdate.qml b/tests/auto/quick/qquicksmoothedanimation/data/deleteOnUpdate.qml
index ff8dfaa846..ff8dfaa846 100644
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/deleteOnUpdate.qml
+++ b/tests/auto/quick/qquicksmoothedanimation/data/deleteOnUpdate.qml
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/simpleanimation.qml b/tests/auto/quick/qquicksmoothedanimation/data/simpleanimation.qml
index b2be63ec94..b2be63ec94 100644
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/simpleanimation.qml
+++ b/tests/auto/quick/qquicksmoothedanimation/data/simpleanimation.qml
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation1.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation1.qml
index 3631f971f0..3631f971f0 100644
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation1.qml
+++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation1.qml
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation2.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation2.qml
index b07120234a..b07120234a 100644
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation2.qml
+++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation2.qml
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation3.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation3.qml
index 8d5dc4a92b..8d5dc4a92b 100644
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimation3.qml
+++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimation3.qml
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationBehavior.qml
index 81d36bf015..81d36bf015 100644
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml
+++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationBehavior.qml
diff --git a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationValueSource.qml
index e136df84f6..e136df84f6 100644
--- a/tests/auto/qtquick2/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml
+++ b/tests/auto/quick/qquicksmoothedanimation/data/smoothedanimationValueSource.qml
diff --git a/tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro b/tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro
new file mode 100644
index 0000000000..0d5567da8d
--- /dev/null
+++ b/tests/auto/quick/qquicksmoothedanimation/qquicksmoothedanimation.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquicksmoothedanimation
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicksmoothedanimation.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp b/tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp
new file mode 100644
index 0000000000..a3e0e46f97
--- /dev/null
+++ b/tests/auto/quick/qquicksmoothedanimation/tst_qquicksmoothedanimation.cpp
@@ -0,0 +1,242 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/private/qquicksmoothedanimation_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <private/qqmlvaluetype_p.h>
+#include "../../shared/util.h"
+
+class tst_qquicksmoothedanimation : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquicksmoothedanimation();
+
+private slots:
+ void defaultValues();
+ void values();
+ void disabled();
+ void simpleAnimation();
+ void valueSource();
+ void behavior();
+ void deleteOnUpdate();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquicksmoothedanimation::tst_qquicksmoothedanimation()
+{
+}
+
+void tst_qquicksmoothedanimation::defaultValues()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("smoothedanimation1.qml"));
+ QQuickSmoothedAnimation *obj = qobject_cast<QQuickSmoothedAnimation*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->to(), 0.);
+ QCOMPARE(obj->velocity(), 200.);
+ QCOMPARE(obj->duration(), -1);
+ QCOMPARE(obj->maximumEasingTime(), -1);
+ QCOMPARE(obj->reversingMode(), QQuickSmoothedAnimation::Eased);
+
+ delete obj;
+}
+
+void tst_qquicksmoothedanimation::values()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("smoothedanimation2.qml"));
+ QQuickSmoothedAnimation *obj = qobject_cast<QQuickSmoothedAnimation*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->to(), 10.);
+ QCOMPARE(obj->velocity(), 200.);
+ QCOMPARE(obj->duration(), 300);
+ QCOMPARE(obj->maximumEasingTime(), -1);
+ QCOMPARE(obj->reversingMode(), QQuickSmoothedAnimation::Immediate);
+
+ delete obj;
+}
+
+void tst_qquicksmoothedanimation::disabled()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("smoothedanimation3.qml"));
+ QQuickSmoothedAnimation *obj = qobject_cast<QQuickSmoothedAnimation*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->to(), 10.);
+ QCOMPARE(obj->velocity(), 250.);
+ QCOMPARE(obj->maximumEasingTime(), 150);
+ QCOMPARE(obj->reversingMode(), QQuickSmoothedAnimation::Sync);
+
+ delete obj;
+}
+
+void tst_qquicksmoothedanimation::simpleAnimation()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("simpleanimation.qml"));
+ QObject *obj = c.create();
+ QVERIFY(obj);
+
+ QQuickRectangle *rect = obj->findChild<QQuickRectangle*>("rect");
+ QVERIFY(rect);
+
+ QQuickSmoothedAnimation *animation = obj->findChild<QQuickSmoothedAnimation*>("anim");
+ QVERIFY(animation);
+
+ animation->setTargetObject(rect);
+ animation->setProperty("x");
+ animation->setTo(200);
+ animation->setDuration(250);
+ QVERIFY(animation->target() == rect);
+ QVERIFY(animation->property() == "x");
+ QVERIFY(animation->to() == 200);
+ animation->start();
+ QVERIFY(animation->isRunning());
+ QTest::qWait(animation->duration());
+ QTRY_COMPARE(rect->x(), qreal(200));
+ QTest::qWait(100); //smoothed animation doesn't report stopped until delayed timer fires
+
+ QVERIFY(!animation->isRunning());
+ rect->setX(0);
+ animation->start();
+ QVERIFY(animation->isRunning());
+ animation->pause();
+ QVERIFY(animation->isRunning());
+ QVERIFY(animation->isPaused());
+ animation->setCurrentTime(125);
+ QVERIFY(animation->currentTime() == 125);
+ QCOMPARE(rect->x(), qreal(100));
+}
+
+void tst_qquicksmoothedanimation::valueSource()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("smoothedanimationValueSource.qml"));
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *theRect = rect->findChild<QQuickRectangle*>("theRect");
+ QVERIFY(theRect);
+
+ QQuickSmoothedAnimation *easeX = rect->findChild<QQuickSmoothedAnimation*>("easeX");
+ QVERIFY(easeX);
+ QVERIFY(easeX->isRunning());
+
+ QQuickSmoothedAnimation *easeY = rect->findChild<QQuickSmoothedAnimation*>("easeY");
+ QVERIFY(easeY);
+ QVERIFY(easeY->isRunning());
+
+ // XXX get the proper duration
+ QTest::qWait(100);
+
+ QTRY_VERIFY(!easeX->isRunning());
+ QTRY_VERIFY(!easeY->isRunning());
+
+ QTRY_COMPARE(theRect->x(), qreal(200));
+ QTRY_COMPARE(theRect->y(), qreal(200));
+
+ delete rect;
+}
+
+void tst_qquicksmoothedanimation::behavior()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("smoothedanimationBehavior.qml"));
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickRectangle *theRect = rect->findChild<QQuickRectangle*>("theRect");
+ QVERIFY(theRect);
+
+ QQuickSmoothedAnimation *easeX = rect->findChild<QQuickSmoothedAnimation*>("easeX");
+ QVERIFY(easeX);
+
+ QQuickSmoothedAnimation *easeY = rect->findChild<QQuickSmoothedAnimation*>("easeY");
+ QVERIFY(easeY);
+
+ // XXX get the proper duration
+ QTest::qWait(400);
+
+ QTRY_VERIFY(!easeX->isRunning());
+ QTRY_VERIFY(!easeY->isRunning());
+
+ QTRY_COMPARE(theRect->x(), qreal(200));
+ QTRY_COMPARE(theRect->y(), qreal(200));
+
+ delete rect;
+}
+
+void tst_qquicksmoothedanimation::deleteOnUpdate()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("deleteOnUpdate.qml"));
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QQuickSmoothedAnimation *anim = rect->findChild<QQuickSmoothedAnimation*>("anim");
+ QVERIFY(anim);
+
+ //don't crash
+ QTest::qWait(500);
+
+ delete rect;
+}
+
+QTEST_MAIN(tst_qquicksmoothedanimation)
+
+#include "tst_qquicksmoothedanimation.moc"
diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation1.qml b/tests/auto/quick/qquickspringanimation/data/springanimation1.qml
index 9f52aa56c1..9f52aa56c1 100644
--- a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation1.qml
+++ b/tests/auto/quick/qquickspringanimation/data/springanimation1.qml
diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation2.qml b/tests/auto/quick/qquickspringanimation/data/springanimation2.qml
index 9f72e51533..9f72e51533 100644
--- a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation2.qml
+++ b/tests/auto/quick/qquickspringanimation/data/springanimation2.qml
diff --git a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation3.qml b/tests/auto/quick/qquickspringanimation/data/springanimation3.qml
index f4dc121eb8..f4dc121eb8 100644
--- a/tests/auto/qtquick2/qdeclarativespringanimation/data/springanimation3.qml
+++ b/tests/auto/quick/qquickspringanimation/data/springanimation3.qml
diff --git a/tests/auto/quick/qquickspringanimation/qquickspringanimation.pro b/tests/auto/quick/qquickspringanimation/qquickspringanimation.pro
new file mode 100644
index 0000000000..8ad472f8cc
--- /dev/null
+++ b/tests/auto/quick/qquickspringanimation/qquickspringanimation.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickspringanimation
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickspringanimation.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickspringanimation/tst_qquickspringanimation.cpp b/tests/auto/quick/qquickspringanimation/tst_qquickspringanimation.cpp
new file mode 100644
index 0000000000..4fa512d9b6
--- /dev/null
+++ b/tests/auto/quick/qquickspringanimation/tst_qquickspringanimation.cpp
@@ -0,0 +1,133 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <private/qquickspringanimation_p.h>
+#include <private/qqmlvaluetype_p.h>
+#include "../../shared/util.h"
+
+class tst_qquickspringanimation : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickspringanimation();
+
+private slots:
+ void defaultValues();
+ void values();
+ void disabled();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquickspringanimation::tst_qquickspringanimation()
+{
+}
+
+void tst_qquickspringanimation::defaultValues()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("springanimation1.qml"));
+ QQuickSpringAnimation *obj = qobject_cast<QQuickSpringAnimation*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->to(), 0.);
+ QCOMPARE(obj->velocity(), 0.);
+ QCOMPARE(obj->spring(), 0.);
+ QCOMPARE(obj->damping(), 0.);
+ QCOMPARE(obj->epsilon(), 0.01);
+ QCOMPARE(obj->modulus(), 0.);
+ QCOMPARE(obj->mass(), 1.);
+ QCOMPARE(obj->isRunning(), false);
+
+ delete obj;
+}
+
+void tst_qquickspringanimation::values()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("springanimation2.qml"));
+ QObject *root = c.create();
+
+ QQuickSpringAnimation *obj = root->findChild<QQuickSpringAnimation*>();
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->to(), 1.44);
+ QCOMPARE(obj->velocity(), 0.9);
+ QCOMPARE(obj->spring(), 1.0);
+ QCOMPARE(obj->damping(), 0.5);
+ QCOMPARE(obj->epsilon(), 0.25);
+ QCOMPARE(obj->modulus(), 360.0);
+ QCOMPARE(obj->mass(), 2.0);
+ QCOMPARE(obj->isRunning(), true);
+
+ QTRY_COMPARE(obj->isRunning(), false);
+
+ delete obj;
+}
+
+void tst_qquickspringanimation::disabled()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("springanimation3.qml"));
+ QQuickSpringAnimation *obj = qobject_cast<QQuickSpringAnimation*>(c.create());
+
+ QVERIFY(obj != 0);
+
+ QCOMPARE(obj->to(), 1.44);
+ QCOMPARE(obj->velocity(), 0.9);
+ QCOMPARE(obj->spring(), 1.0);
+ QCOMPARE(obj->damping(), 0.5);
+ QCOMPARE(obj->epsilon(), 0.25);
+ QCOMPARE(obj->modulus(), 360.0);
+ QCOMPARE(obj->mass(), 2.0);
+ QCOMPARE(obj->isRunning(), false);
+
+ delete obj;
+}
+
+QTEST_MAIN(tst_qquickspringanimation)
+
+#include "tst_qquickspringanimation.moc"
diff --git a/tests/auto/qtquick2/qquickspriteimage/data/advance.qml b/tests/auto/quick/qquickspriteimage/data/advance.qml
index 46a49ca673..46a49ca673 100644
--- a/tests/auto/qtquick2/qquickspriteimage/data/advance.qml
+++ b/tests/auto/quick/qquickspriteimage/data/advance.qml
diff --git a/tests/auto/qtquick2/qquickspriteimage/data/basic.qml b/tests/auto/quick/qquickspriteimage/data/basic.qml
index 2f2b1c96fa..2f2b1c96fa 100644
--- a/tests/auto/qtquick2/qquickspriteimage/data/basic.qml
+++ b/tests/auto/quick/qquickspriteimage/data/basic.qml
diff --git a/tests/auto/qtquick2/qquickspriteimage/data/squarefacesprite.png b/tests/auto/quick/qquickspriteimage/data/squarefacesprite.png
index f9a5d5fcce..f9a5d5fcce 100644
--- a/tests/auto/qtquick2/qquickspriteimage/data/squarefacesprite.png
+++ b/tests/auto/quick/qquickspriteimage/data/squarefacesprite.png
Binary files differ
diff --git a/tests/auto/quick/qquickspriteimage/qquickspriteimage.pro b/tests/auto/quick/qquickspriteimage/qquickspriteimage.pro
new file mode 100644
index 0000000000..50613792de
--- /dev/null
+++ b/tests/auto/quick/qquickspriteimage/qquickspriteimage.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickspriteimage
+SOURCES += tst_qquickspriteimage.cpp
+
+include (../../shared/util.pri)
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickspriteimage/tst_qquickspriteimage.cpp b/tests/auto/quick/qquickspriteimage/tst_qquickspriteimage.cpp
new file mode 100644
index 0000000000..7aff77334d
--- /dev/null
+++ b/tests/auto/quick/qquickspriteimage/tst_qquickspriteimage.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+#include "../../shared/util.h"
+#include <QtQuick/qquickview.h>
+#include <private/qquickspriteimage_p.h>
+
+class tst_qquickspriteimage : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickspriteimage(){}
+
+private slots:
+ void test_properties();
+ void test_framerateAdvance();//Separate codepath for QQuickSpriteEngine
+};
+
+void tst_qquickspriteimage::test_properties()
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ canvas->setSource(testFileUrl("basic.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QVERIFY(canvas->rootObject());
+ QQuickSpriteImage* sprite = canvas->rootObject()->findChild<QQuickSpriteImage*>("sprite");
+ QVERIFY(sprite);
+
+ QVERIFY(sprite->running());
+ QVERIFY(sprite->interpolate());
+
+ sprite->setRunning(false);
+ QVERIFY(!sprite->running());
+ sprite->setInterpolate(false);
+ QVERIFY(!sprite->interpolate());
+
+ delete canvas;
+}
+
+void tst_qquickspriteimage::test_framerateAdvance()
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ canvas->setSource(testFileUrl("advance.qml"));
+ canvas->show();
+ QTest::qWaitForWindowShown(canvas);
+
+ QVERIFY(canvas->rootObject());
+ QQuickSpriteImage* sprite = canvas->rootObject()->findChild<QQuickSpriteImage*>("sprite");
+ QVERIFY(sprite);
+
+ QTRY_COMPARE(sprite->currentSprite(), QLatin1String("secondState"));
+ delete canvas;
+}
+
+QTEST_MAIN(tst_qquickspriteimage)
+
+#include "tst_qquickspriteimage.moc"
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/ExtendedRectangle.qml b/tests/auto/quick/qquickstates/data/ExtendedRectangle.qml
index 1ea346b841..1ea346b841 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/ExtendedRectangle.qml
+++ b/tests/auto/quick/qquickstates/data/ExtendedRectangle.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/Implementation/MyType.qml b/tests/auto/quick/qquickstates/data/Implementation/MyType.qml
index 01eb32cd4d..01eb32cd4d 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/Implementation/MyType.qml
+++ b/tests/auto/quick/qquickstates/data/Implementation/MyType.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/Implementation/images/qt-logo.png b/tests/auto/quick/qquickstates/data/Implementation/images/qt-logo.png
index 14ddf2a028..14ddf2a028 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/Implementation/images/qt-logo.png
+++ b/tests/auto/quick/qquickstates/data/Implementation/images/qt-logo.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/QTBUG-14830.qml b/tests/auto/quick/qquickstates/data/QTBUG-14830.qml
index 5ba7c3ad6f..5ba7c3ad6f 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/QTBUG-14830.qml
+++ b/tests/auto/quick/qquickstates/data/QTBUG-14830.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges1.qml b/tests/auto/quick/qquickstates/data/anchorChanges1.qml
index 378f5390f9..378f5390f9 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges1.qml
+++ b/tests/auto/quick/qquickstates/data/anchorChanges1.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges2.qml b/tests/auto/quick/qquickstates/data/anchorChanges2.qml
index dc7f8ef0d1..dc7f8ef0d1 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges2.qml
+++ b/tests/auto/quick/qquickstates/data/anchorChanges2.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges3.qml b/tests/auto/quick/qquickstates/data/anchorChanges3.qml
index af49575854..af49575854 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges3.qml
+++ b/tests/auto/quick/qquickstates/data/anchorChanges3.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges4.qml b/tests/auto/quick/qquickstates/data/anchorChanges4.qml
index 28b55818bd..28b55818bd 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges4.qml
+++ b/tests/auto/quick/qquickstates/data/anchorChanges4.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges5.qml b/tests/auto/quick/qquickstates/data/anchorChanges5.qml
index b1ca968fb9..b1ca968fb9 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChanges5.qml
+++ b/tests/auto/quick/qquickstates/data/anchorChanges5.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorChangesCrash.qml b/tests/auto/quick/qquickstates/data/anchorChangesCrash.qml
index 9af0e4645a..9af0e4645a 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/anchorChangesCrash.qml
+++ b/tests/auto/quick/qquickstates/data/anchorChangesCrash.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug.qml b/tests/auto/quick/qquickstates/data/anchorRewindBug.qml
index 60c537b1ed..60c537b1ed 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug.qml
+++ b/tests/auto/quick/qquickstates/data/anchorRewindBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug2.qml b/tests/auto/quick/qquickstates/data/anchorRewindBug2.qml
index 574ef473ce..574ef473ce 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/anchorRewindBug2.qml
+++ b/tests/auto/quick/qquickstates/data/anchorRewindBug2.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/attachedPropertyChanges.qml b/tests/auto/quick/qquickstates/data/attachedPropertyChanges.qml
index 413af2ee42..413af2ee42 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/attachedPropertyChanges.qml
+++ b/tests/auto/quick/qquickstates/data/attachedPropertyChanges.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml b/tests/auto/quick/qquickstates/data/autoStateAtStartupRestoreBug.qml
index 6cbf524ec2..6cbf524ec2 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml
+++ b/tests/auto/quick/qquickstates/data/autoStateAtStartupRestoreBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/avoidFastForward.qml b/tests/auto/quick/qquickstates/data/avoidFastForward.qml
index 519befc31e..519befc31e 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/avoidFastForward.qml
+++ b/tests/auto/quick/qquickstates/data/avoidFastForward.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding.qml b/tests/auto/quick/qquickstates/data/basicBinding.qml
index 59b67d0863..59b67d0863 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding.qml
+++ b/tests/auto/quick/qquickstates/data/basicBinding.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding2.qml b/tests/auto/quick/qquickstates/data/basicBinding2.qml
index 55f88120aa..55f88120aa 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding2.qml
+++ b/tests/auto/quick/qquickstates/data/basicBinding2.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding3.qml b/tests/auto/quick/qquickstates/data/basicBinding3.qml
index 361ab0b091..361ab0b091 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding3.qml
+++ b/tests/auto/quick/qquickstates/data/basicBinding3.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding4.qml b/tests/auto/quick/qquickstates/data/basicBinding4.qml
index b29f0fcf22..b29f0fcf22 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicBinding4.qml
+++ b/tests/auto/quick/qquickstates/data/basicBinding4.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges.qml b/tests/auto/quick/qquickstates/data/basicChanges.qml
index 3e2b73acde..3e2b73acde 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges.qml
+++ b/tests/auto/quick/qquickstates/data/basicChanges.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges2.qml b/tests/auto/quick/qquickstates/data/basicChanges2.qml
index 5ff46cc60c..5ff46cc60c 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges2.qml
+++ b/tests/auto/quick/qquickstates/data/basicChanges2.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges3.qml b/tests/auto/quick/qquickstates/data/basicChanges3.qml
index e46e98f75e..e46e98f75e 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges3.qml
+++ b/tests/auto/quick/qquickstates/data/basicChanges3.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges4.qml b/tests/auto/quick/qquickstates/data/basicChanges4.qml
index 7da1e0fb2e..7da1e0fb2e 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicChanges4.qml
+++ b/tests/auto/quick/qquickstates/data/basicChanges4.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/basicExtension.qml b/tests/auto/quick/qquickstates/data/basicExtension.qml
index 00f5fee287..00f5fee287 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/basicExtension.qml
+++ b/tests/auto/quick/qquickstates/data/basicExtension.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/deleting.qml b/tests/auto/quick/qquickstates/data/deleting.qml
index b8e8d33c17..b8e8d33c17 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/deleting.qml
+++ b/tests/auto/quick/qquickstates/data/deleting.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/deletingState.qml b/tests/auto/quick/qquickstates/data/deletingState.qml
index 68a9c2a24d..68a9c2a24d 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/deletingState.qml
+++ b/tests/auto/quick/qquickstates/data/deletingState.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/editProperties.qml b/tests/auto/quick/qquickstates/data/editProperties.qml
index 9bff3657ba..9bff3657ba 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/editProperties.qml
+++ b/tests/auto/quick/qquickstates/data/editProperties.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/explicit.qml b/tests/auto/quick/qquickstates/data/explicit.qml
index d09893a1db..d09893a1db 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/explicit.qml
+++ b/tests/auto/quick/qquickstates/data/explicit.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/extendsBug.qml b/tests/auto/quick/qquickstates/data/extendsBug.qml
index 573341520d..573341520d 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/extendsBug.qml
+++ b/tests/auto/quick/qquickstates/data/extendsBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/fakeExtension.qml b/tests/auto/quick/qquickstates/data/fakeExtension.qml
index 6a5c7003f6..6a5c7003f6 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/fakeExtension.qml
+++ b/tests/auto/quick/qquickstates/data/fakeExtension.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/illegalObj.qml b/tests/auto/quick/qquickstates/data/illegalObj.qml
index a2bbd5d32b..a2bbd5d32b 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/illegalObj.qml
+++ b/tests/auto/quick/qquickstates/data/illegalObj.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/illegalTempState.qml b/tests/auto/quick/qquickstates/data/illegalTempState.qml
index 9cb39c0728..9cb39c0728 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/illegalTempState.qml
+++ b/tests/auto/quick/qquickstates/data/illegalTempState.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/image.png b/tests/auto/quick/qquickstates/data/image.png
index ed1833c95b..ed1833c95b 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/image.png
+++ b/tests/auto/quick/qquickstates/data/image.png
Binary files differ
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/legalTempState.qml b/tests/auto/quick/qquickstates/data/legalTempState.qml
index a93860f5cc..a93860f5cc 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/legalTempState.qml
+++ b/tests/auto/quick/qquickstates/data/legalTempState.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/nonExistantProp.qml b/tests/auto/quick/qquickstates/data/nonExistantProp.qml
index ce502699bb..ce502699bb 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/nonExistantProp.qml
+++ b/tests/auto/quick/qquickstates/data/nonExistantProp.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/parentChange1.qml b/tests/auto/quick/qquickstates/data/parentChange1.qml
index 663ad1a264..663ad1a264 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange1.qml
+++ b/tests/auto/quick/qquickstates/data/parentChange1.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/parentChange2.qml b/tests/auto/quick/qquickstates/data/parentChange2.qml
index ae290e961e..ae290e961e 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange2.qml
+++ b/tests/auto/quick/qquickstates/data/parentChange2.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/parentChange3.qml b/tests/auto/quick/qquickstates/data/parentChange3.qml
index 46665cb4c8..46665cb4c8 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange3.qml
+++ b/tests/auto/quick/qquickstates/data/parentChange3.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/parentChange4.qml b/tests/auto/quick/qquickstates/data/parentChange4.qml
index 22de72f8c9..22de72f8c9 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange4.qml
+++ b/tests/auto/quick/qquickstates/data/parentChange4.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/parentChange5.qml b/tests/auto/quick/qquickstates/data/parentChange5.qml
index c353d2637f..c353d2637f 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange5.qml
+++ b/tests/auto/quick/qquickstates/data/parentChange5.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/parentChange6.qml b/tests/auto/quick/qquickstates/data/parentChange6.qml
index b373dbba20..b373dbba20 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/parentChange6.qml
+++ b/tests/auto/quick/qquickstates/data/parentChange6.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/propertyErrors.qml b/tests/auto/quick/qquickstates/data/propertyErrors.qml
index ddd636493d..ddd636493d 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/propertyErrors.qml
+++ b/tests/auto/quick/qquickstates/data/propertyErrors.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/reset.qml b/tests/auto/quick/qquickstates/data/reset.qml
index f0ecab0950..f0ecab0950 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/reset.qml
+++ b/tests/auto/quick/qquickstates/data/reset.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/restoreEntryValues.qml b/tests/auto/quick/qquickstates/data/restoreEntryValues.qml
index 950a522841..950a522841 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/restoreEntryValues.qml
+++ b/tests/auto/quick/qquickstates/data/restoreEntryValues.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/returnToBase.qml b/tests/auto/quick/qquickstates/data/returnToBase.qml
index 9a0ee82397..9a0ee82397 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/returnToBase.qml
+++ b/tests/auto/quick/qquickstates/data/returnToBase.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/revertListBug.qml b/tests/auto/quick/qquickstates/data/revertListBug.qml
index fbc4bc5ecc..fbc4bc5ecc 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/revertListBug.qml
+++ b/tests/auto/quick/qquickstates/data/revertListBug.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/script.qml b/tests/auto/quick/qquickstates/data/script.qml
index 218f0fae74..218f0fae74 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/script.qml
+++ b/tests/auto/quick/qquickstates/data/script.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/signalOverride.qml b/tests/auto/quick/qquickstates/data/signalOverride.qml
index 9ab8037e51..9ab8037e51 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/signalOverride.qml
+++ b/tests/auto/quick/qquickstates/data/signalOverride.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/signalOverride2.qml b/tests/auto/quick/qquickstates/data/signalOverride2.qml
index 4e5e335b8b..4e5e335b8b 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/signalOverride2.qml
+++ b/tests/auto/quick/qquickstates/data/signalOverride2.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash.qml b/tests/auto/quick/qquickstates/data/signalOverrideCrash.qml
index 3e2ae1e93d..3e2ae1e93d 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash.qml
+++ b/tests/auto/quick/qquickstates/data/signalOverrideCrash.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash2.qml b/tests/auto/quick/qquickstates/data/signalOverrideCrash2.qml
index 3937874aa2..3937874aa2 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash2.qml
+++ b/tests/auto/quick/qquickstates/data/signalOverrideCrash2.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash3.qml b/tests/auto/quick/qquickstates/data/signalOverrideCrash3.qml
index 98d4c57219..98d4c57219 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/signalOverrideCrash3.qml
+++ b/tests/auto/quick/qquickstates/data/signalOverrideCrash3.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/unnamedWhen.qml b/tests/auto/quick/qquickstates/data/unnamedWhen.qml
index 35eacff07b..35eacff07b 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/unnamedWhen.qml
+++ b/tests/auto/quick/qquickstates/data/unnamedWhen.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/urlResolution.qml b/tests/auto/quick/qquickstates/data/urlResolution.qml
index 516ac034d6..516ac034d6 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/urlResolution.qml
+++ b/tests/auto/quick/qquickstates/data/urlResolution.qml
diff --git a/tests/auto/qtquick2/qdeclarativestates/data/whenOrdering.qml b/tests/auto/quick/qquickstates/data/whenOrdering.qml
index 92025a2054..92025a2054 100644
--- a/tests/auto/qtquick2/qdeclarativestates/data/whenOrdering.qml
+++ b/tests/auto/quick/qquickstates/data/whenOrdering.qml
diff --git a/tests/auto/quick/qquickstates/qquickstates.pro b/tests/auto/quick/qquickstates/qquickstates.pro
new file mode 100644
index 0000000000..ec881680ea
--- /dev/null
+++ b/tests/auto/quick/qquickstates/qquickstates.pro
@@ -0,0 +1,14 @@
+CONFIG += testcase
+TARGET = tst_qquickstates
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickstates.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
new file mode 100644
index 0000000000..fc8194f6ca
--- /dev/null
+++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
@@ -0,0 +1,1608 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/qquickview.h>
+#include <private/qquickstateoperations_p.h>
+#include <private/qquickanchors_p_p.h>
+#include <QtQuick/private/qquickrectangle_p.h>
+#include <private/qquickimage_p.h>
+#include <QtQuick/private/qquickpropertychanges_p.h>
+#include <QtQuick/private/qquickstategroup_p.h>
+#include <private/qquickitem_p.h>
+#include <private/qqmlproperty_p.h>
+#include "../../shared/util.h"
+
+class MyAttached : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int foo READ foo WRITE setFoo)
+public:
+ MyAttached(QObject *parent) : QObject(parent), m_foo(13) {}
+
+ int foo() const { return m_foo; }
+ void setFoo(int f) { m_foo = f; }
+
+private:
+ int m_foo;
+};
+
+class MyRect : public QQuickRectangle
+{
+ Q_OBJECT
+ Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal)
+public:
+ MyRect() {}
+
+ void doSomething() { emit didSomething(); }
+
+ int propertyWithNotify() const { return m_prop; }
+ void setPropertyWithNotify(int i) { m_prop = i; emit oddlyNamedNotifySignal(); }
+
+ static MyAttached *qmlAttachedProperties(QObject *o) {
+ return new MyAttached(o);
+ }
+Q_SIGNALS:
+ void didSomething();
+ void oddlyNamedNotifySignal();
+
+private:
+ int m_prop;
+};
+
+QML_DECLARE_TYPE(MyRect)
+QML_DECLARE_TYPEINFO(MyRect, QML_HAS_ATTACHED_PROPERTIES)
+
+class tst_qquickstates : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickstates() {}
+
+private:
+ QByteArray fullDataPath(const QString &path) const;
+
+private slots:
+ void initTestCase();
+
+ void basicChanges();
+ void attachedPropertyChanges();
+ void basicExtension();
+ void basicBinding();
+ void signalOverride();
+ void signalOverrideCrash();
+ void signalOverrideCrash2();
+ void signalOverrideCrash3();
+ void parentChange();
+ void parentChangeErrors();
+ void anchorChanges();
+ void anchorChanges2();
+ void anchorChanges3();
+ void anchorChanges4();
+ void anchorChanges5();
+ void anchorChangesRTL();
+ void anchorChangesRTL2();
+ void anchorChangesRTL3();
+ void anchorChangesCrash();
+ void anchorRewindBug();
+ void anchorRewindBug2();
+ void script();
+ void restoreEntryValues();
+ void explicitChanges();
+ void propertyErrors();
+ void incorrectRestoreBug();
+ void autoStateAtStartupRestoreBug();
+ void deletingChange();
+ void deletingState();
+ void tempState();
+ void illegalTempState();
+ void nonExistantProperty();
+ void reset();
+ void illegalObjectCreation();
+ void whenOrdering();
+ void urlResolution();
+ void unnamedWhen();
+ void returnToBase();
+ void extendsBug();
+ void editProperties();
+ void QTBUG_14830();
+ void avoidFastForward();
+ void revertListBug();
+};
+
+void tst_qquickstates::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ qmlRegisterType<MyRect>("Qt.test", 1, 0, "MyRectangle");
+}
+
+QByteArray tst_qquickstates::fullDataPath(const QString &path) const
+{
+ return testFileUrl(path).toString().toUtf8();
+}
+
+void tst_qquickstates::basicChanges()
+{
+ QQmlEngine engine;
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("basicChanges.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("basicChanges2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("basicChanges3.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1.0);
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1.0);
+
+ rectPrivate->setState("bordered");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),2.0);
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1.0);
+ //### we should be checking that this is an implicit rather than explicit 1 (which currently fails)
+
+ rectPrivate->setState("bordered");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),2.0);
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1.0);
+
+ }
+
+ {
+ // Test basicChanges4.qml can magically connect to propertyWithNotify's notify
+ // signal using 'onPropertyWithNotifyChanged' even though the signal name is
+ // actually 'oddlyNamedNotifySignal'
+
+ QQmlComponent component(&engine, testFileUrl("basicChanges4.qml"));
+ QVERIFY(component.isReady());
+
+ MyRect *rect = qobject_cast<MyRect*>(component.create());
+ QVERIFY(rect != 0);
+
+ QMetaProperty prop = rect->metaObject()->property(rect->metaObject()->indexOfProperty("propertyWithNotify"));
+ QVERIFY(prop.hasNotifySignal());
+ QString notifySignal = QByteArray(prop.notifySignal().signature());
+ QVERIFY(!notifySignal.startsWith("propertyWithNotifyChanged("));
+
+ QCOMPARE(rect->color(), QColor(Qt::red));
+
+ rect->setPropertyWithNotify(100);
+ QCOMPARE(rect->color(), QColor(Qt::blue));
+ }
+}
+
+void tst_qquickstates::attachedPropertyChanges()
+{
+ QQmlEngine engine;
+
+ QQmlComponent component(&engine, testFileUrl("attachedPropertyChanges.qml"));
+ QVERIFY(component.isReady());
+
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item != 0);
+ QCOMPARE(item->width(), 50.0);
+
+ // Ensure attached property has been changed
+ QObject *attObj = qmlAttachedPropertiesObject<MyRect>(item, false);
+ QVERIFY(attObj);
+
+ MyAttached *att = qobject_cast<MyAttached*>(attObj);
+ QVERIFY(att);
+
+ QCOMPARE(att->foo(), 1);
+}
+
+void tst_qquickstates::basicExtension()
+{
+ QQmlEngine engine;
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("basicExtension.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1.0);
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1.0);
+
+ rectPrivate->setState("bordered");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),2.0);
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),1.0);
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1.0);
+
+ rectPrivate->setState("bordered");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->border()->width(),2.0);
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->border()->width(),1.0);
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("fakeExtension.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+ }
+}
+
+void tst_qquickstates::basicBinding()
+{
+ QQmlEngine engine;
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("basicBinding.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("yellow"));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("basicBinding2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("green"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("yellow"));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("basicBinding3.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("red"));
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor2", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor2", QColor("green"));
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("basicBinding4.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("yellow"));
+
+ rectPrivate->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+ rect->setProperty("sourceColor", QColor("purple"));
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("purple"));
+
+ rectPrivate->setState("green");
+ QCOMPARE(rect->color(),QColor("green"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ }
+}
+
+void tst_qquickstates::signalOverride()
+{
+ QQmlEngine engine;
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("signalOverride.qml"));
+ MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ QQuickItemPrivate::get(rect)->setState("green");
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("green"));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("signalOverride2.qml"));
+ MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("white"));
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("extendedRect"));
+ QQuickItemPrivate::get(innerRect)->setState("green");
+ rect->doSomething();
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(innerRect->color(),QColor("green"));
+ QCOMPARE(innerRect->property("extendedColor").value<QColor>(),QColor("green"));
+ }
+}
+
+void tst_qquickstates::signalOverrideCrash()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("signalOverrideCrash.qml"));
+ MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickItemPrivate::get(rect)->setState("overridden");
+ rect->doSomething();
+}
+
+void tst_qquickstates::signalOverrideCrash2()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("signalOverrideCrash2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickItemPrivate::get(rect)->setState("state1");
+ QQuickItemPrivate::get(rect)->setState("state2");
+ QQuickItemPrivate::get(rect)->setState("state1");
+
+ delete rect;
+}
+
+void tst_qquickstates::signalOverrideCrash3()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("signalOverrideCrash3.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickItemPrivate::get(rect)->setState("state1");
+ QQuickItemPrivate::get(rect)->setState("");
+ QQuickItemPrivate::get(rect)->setState("state2");
+ QQuickItemPrivate::get(rect)->setState("");
+
+ delete rect;
+}
+
+void tst_qquickstates::parentChange()
+{
+ QQmlEngine engine;
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("parentChange1.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QQmlListReference list(rect, "states");
+ QQuickState *state = qobject_cast<QQuickState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QQuickParentChange *pChange = qobject_cast<QQuickParentChange*>(state->operationAt(0));
+ QVERIFY(pChange != 0);
+ QQuickItem *nParent = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("NewParent"));
+ QVERIFY(nParent != 0);
+
+ QCOMPARE(pChange->parent(), nParent);
+
+ QQuickItemPrivate::get(rect)->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(0));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(-133));
+ QCOMPARE(innerRect->y(), qreal(-300));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("parentChange2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rectPrivate->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(15));
+ QCOMPARE(innerRect->scale(), qreal(.5));
+ QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-19.9075));
+ QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-8.73433));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("parentChange3.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rectPrivate->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(-37));
+ QCOMPARE(innerRect->scale(), qreal(.25));
+ QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-217.305));
+ QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-164.413));
+
+ rectPrivate->setState("");
+ QCOMPARE(innerRect->rotation(), qreal(0));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(5));
+ //do a non-qFuzzyCompare fuzzy compare
+ QVERIFY(innerRect->y() < qreal(0.00001) && innerRect->y() > qreal(-0.00001));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("parentChange6.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QQuickItemPrivate::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_qquickstates::parentChangeErrors()
+{
+ QQmlEngine engine;
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("parentChange4.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, fullDataPath("parentChange4.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under non-uniform scale");
+ QQuickItemPrivate::get(rect)->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(0));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(5));
+ QCOMPARE(innerRect->y(), qreal(5));
+ }
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("parentChange5.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QTest::ignoreMessage(QtWarningMsg, fullDataPath("parentChange5.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under complex transform");
+ QQuickItemPrivate::get(rect)->setState("reparented");
+ QCOMPARE(innerRect->rotation(), qreal(0));
+ QCOMPARE(innerRect->scale(), qreal(1));
+ QCOMPARE(innerRect->x(), qreal(5));
+ QCOMPARE(innerRect->y(), qreal(5));
+ }
+}
+
+void tst_qquickstates::anchorChanges()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges1.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QQmlListReference list(rect, "states");
+ QQuickState *state = qobject_cast<QQuickState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ QCOMPARE(aChanges->anchors()->left().script(), QLatin1String("undefined"));
+ QCOMPARE(aChanges->anchors()->right().script(), QLatin1String("container.right"));
+
+ rectPrivate->setState("right");
+ QCOMPARE(innerRect->x(), qreal(150));
+ QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
+
+ rectPrivate->setState("");
+ QCOMPARE(innerRect->x(), qreal(5));
+
+ delete rect;
+}
+
+void tst_qquickstates::anchorChanges2()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rectPrivate->setState("right");
+ QCOMPARE(innerRect->x(), qreal(150));
+
+ rectPrivate->setState("");
+ QCOMPARE(innerRect->x(), qreal(5));
+
+ delete rect;
+}
+
+void tst_qquickstates::anchorChanges3()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges3.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QQuickItem *leftGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QQuickItem *bottomGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QQmlListReference list(rect, "states");
+ QQuickState *state = qobject_cast<QQuickState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ QCOMPARE(aChanges->anchors()->top().script(), QLatin1String("container.top"));
+ QCOMPARE(aChanges->anchors()->bottom().script(), QLatin1String("bottomGuideline.bottom"));
+
+ rectPrivate->setState("reanchored");
+ QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().item, QQuickItemPrivate::get(leftGuideline)->left().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickItemPrivate::get(leftGuideline)->left().anchorLine);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().item, QQuickItemPrivate::get(bottomGuideline)->bottom().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QQuickItemPrivate::get(bottomGuideline)->bottom().anchorLine);
+
+ QCOMPARE(innerRect->x(), qreal(10));
+ QCOMPARE(innerRect->y(), qreal(0));
+ QCOMPARE(innerRect->width(), qreal(190));
+ QCOMPARE(innerRect->height(), qreal(150));
+
+ rectPrivate->setState("");
+ QCOMPARE(innerRect->x(), qreal(0));
+ QCOMPARE(innerRect->y(), qreal(10));
+ QCOMPARE(innerRect->width(), qreal(150));
+ QCOMPARE(innerRect->height(), qreal(190));
+
+ delete rect;
+}
+
+void tst_qquickstates::anchorChanges4()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges4.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QQuickItem *leftGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QQuickItem *bottomGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QQmlListReference list(rect, "states");
+ QQuickState *state = qobject_cast<QQuickState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ QCOMPARE(aChanges->anchors()->horizontalCenter().script(), QLatin1String("bottomGuideline.horizontalCenter"));
+ QCOMPARE(aChanges->anchors()->verticalCenter().script(), QLatin1String("leftGuideline.verticalCenter"));
+
+ QQuickItemPrivate::get(rect)->setState("reanchored");
+ QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->verticalCenter().item, QQuickItemPrivate::get(leftGuideline)->verticalCenter().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->verticalCenter().anchorLine, QQuickItemPrivate::get(leftGuideline)->verticalCenter().anchorLine);
+
+ delete rect;
+}
+
+void tst_qquickstates::anchorChanges5()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges5.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QQuickItem *leftGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QQuickItem *bottomGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QQmlListReference list(rect, "states");
+ QQuickState *state = qobject_cast<QQuickState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ QCOMPARE(aChanges->anchors()->baseline().script(), QLatin1String("leftGuideline.baseline"));
+
+ QQuickItemPrivate::get(rect)->setState("reanchored");
+ QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QQuickItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->baseline().item, QQuickItemPrivate::get(leftGuideline)->baseline().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->baseline().anchorLine, QQuickItemPrivate::get(leftGuideline)->baseline().anchorLine);
+
+ delete rect;
+}
+
+void mirrorAnchors(QQuickItem *item) {
+ QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
+ itemPrivate->setLayoutMirror(true);
+}
+
+qreal offsetRTL(QQuickItem *anchorItem, QQuickItem *item) {
+ return anchorItem->width()+2*anchorItem->x()-item->width();
+}
+
+void tst_qquickstates::anchorChangesRTL()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges1.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+ mirrorAnchors(innerRect);
+
+ QQmlListReference list(rect, "states");
+ QQuickState *state = qobject_cast<QQuickState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ rectPrivate->setState("right");
+ QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150));
+ QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickAnchorLine::Invalid); //### was reset (how do we distinguish from not set at all)
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
+
+ rectPrivate->setState("");
+ QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) -qreal(5));
+
+ delete rect;
+}
+
+void tst_qquickstates::anchorChangesRTL2()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+ mirrorAnchors(innerRect);
+
+ rectPrivate->setState("right");
+ QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150));
+
+ rectPrivate->setState("");
+ QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(5));
+
+ delete rect;
+}
+
+void tst_qquickstates::anchorChangesRTL3()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChanges3.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QQuickRectangle *innerRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+ mirrorAnchors(innerRect);
+
+ QQuickItem *leftGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QQuickItem *bottomGuideline = qobject_cast<QQuickItem*>(rect->findChild<QQuickItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QQmlListReference list(rect, "states");
+ QQuickState *state = qobject_cast<QQuickState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QQuickAnchorChanges *aChanges = qobject_cast<QQuickAnchorChanges*>(state->operationAt(0));
+ QVERIFY(aChanges != 0);
+
+ rectPrivate->setState("reanchored");
+ QCOMPARE(aChanges->object(), qobject_cast<QQuickItem*>(innerRect));
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().item, QQuickItemPrivate::get(leftGuideline)->left().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QQuickItemPrivate::get(leftGuideline)->left().anchorLine);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().item, QQuickItemPrivate::get(bottomGuideline)->bottom().item);
+ QCOMPARE(QQuickItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QQuickItemPrivate::get(bottomGuideline)->bottom().anchorLine);
+
+ QCOMPARE(innerRect->x(), offsetRTL(leftGuideline, innerRect) - qreal(10));
+ QCOMPARE(innerRect->y(), qreal(0));
+ // between left side of parent and leftGuideline.x: 10, which has width 0
+ QCOMPARE(innerRect->width(), qreal(10));
+ QCOMPARE(innerRect->height(), qreal(150));
+
+ rectPrivate->setState("");
+ QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(0));
+ QCOMPARE(innerRect->y(), qreal(10));
+ // between right side of parent and left side of rightGuideline.x: 150, which has width 0
+ QCOMPARE(innerRect->width(), qreal(50));
+ QCOMPARE(innerRect->height(), qreal(190));
+
+ delete rect;
+}
+
+//QTBUG-9609
+void tst_qquickstates::anchorChangesCrash()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorChangesCrash.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickItemPrivate::get(rect)->setState("reanchored");
+
+ delete rect;
+}
+
+// QTBUG-12273
+void tst_qquickstates::anchorRewindBug()
+{
+ QQuickView *view = new QQuickView;
+ view->setSource(testFileUrl("anchorRewindBug.qml"));
+
+ view->show();
+ view->requestActivateWindow();
+
+ QTest::qWaitForWindowShown(view);
+
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(view->rootObject());
+ QVERIFY(rect != 0);
+
+ QQuickItem * column = rect->findChild<QQuickItem*>("column");
+
+ QVERIFY(column != 0);
+ QVERIFY(!QQuickItemPrivate::get(column)->heightValid);
+ QVERIFY(!QQuickItemPrivate::get(column)->widthValid);
+ QCOMPARE(column->height(), 200.0);
+ QQuickItemPrivate::get(rect)->setState("reanchored");
+
+ // column height and width should stay implicit
+ // and column's implicit resizing should still work
+ QVERIFY(!QQuickItemPrivate::get(column)->heightValid);
+ QVERIFY(!QQuickItemPrivate::get(column)->widthValid);
+ QTRY_COMPARE(column->height(), 100.0);
+
+ QQuickItemPrivate::get(rect)->setState("");
+
+ // column height and width should stay implicit
+ // and column's implicit resizing should still work
+ QVERIFY(!QQuickItemPrivate::get(column)->heightValid);
+ QVERIFY(!QQuickItemPrivate::get(column)->widthValid);
+ QTRY_COMPARE(column->height(), 200.0);
+
+ delete view;
+}
+
+// QTBUG-11834
+void tst_qquickstates::anchorRewindBug2()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("anchorRewindBug2.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *mover = rect->findChild<QQuickRectangle*>("mover");
+
+ QVERIFY(mover != 0);
+ QCOMPARE(mover->y(), qreal(0.0));
+ QCOMPARE(mover->width(), qreal(50.0));
+
+ QQuickItemPrivate::get(rect)->setState("anchored");
+ QCOMPARE(mover->y(), qreal(250.0));
+ QCOMPARE(mover->width(), qreal(200.0));
+
+ QQuickItemPrivate::get(rect)->setState("");
+ QCOMPARE(mover->y(), qreal(0.0));
+ QCOMPARE(mover->width(), qreal(50.0));
+
+ delete rect;
+}
+
+void tst_qquickstates::script()
+{
+ QQmlEngine engine;
+
+ {
+ QQmlComponent rectComponent(&engine, testFileUrl("script.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted
+ }
+}
+
+void tst_qquickstates::restoreEntryValues()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("restoreEntryValues.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("blue"));
+}
+
+void tst_qquickstates::explicitChanges()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("explicit.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QQmlListReference list(rect, "states");
+ QQuickState *state = qobject_cast<QQuickState*>(list.at(0));
+ QVERIFY(state != 0);
+
+ qmlExecuteDeferred(state);
+ QQuickPropertyChanges *changes = qobject_cast<QQuickPropertyChanges*>(rect->findChild<QQuickPropertyChanges*>("changes"));
+ QVERIFY(changes != 0);
+ QVERIFY(changes->isExplicit());
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rect->setProperty("sourceColor", QColor("green"));
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ rect->setProperty("sourceColor", QColor("yellow"));
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("yellow"));
+}
+
+void tst_qquickstates::propertyErrors()
+{
+ QQmlEngine engine;
+ QQmlComponent rectComponent(&engine, testFileUrl("propertyErrors.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QCOMPARE(rect->color(),QColor("red"));
+
+ QTest::ignoreMessage(QtWarningMsg, fullDataPath("propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\"");
+ QTest::ignoreMessage(QtWarningMsg, fullDataPath("propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"activeFocus\"");
+ QQuickItemPrivate::get(rect)->setState("blue");
+}
+
+void tst_qquickstates::incorrectRestoreBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("basicChanges.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QCOMPARE(rect->color(),QColor("red"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ // make sure if we change the base state value, we then restore to it correctly
+ rect->setColor(QColor("green"));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("green"));
+}
+
+void tst_qquickstates::autoStateAtStartupRestoreBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent component(&engine, testFileUrl("autoStateAtStartupRestoreBug.qml"));
+ QObject *obj = component.create();
+
+ QVERIFY(obj != 0);
+ QCOMPARE(obj->property("test").toInt(), 3);
+
+ obj->setProperty("input", 2);
+
+ QCOMPARE(obj->property("test").toInt(), 9);
+
+ delete obj;
+}
+
+void tst_qquickstates::deletingChange()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("deleting.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+ QCOMPARE(rect->radius(),qreal(5));
+
+ rectPrivate->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->radius(),qreal(0));
+
+ QQuickPropertyChanges *pc = rect->findChild<QQuickPropertyChanges*>("pc1");
+ QVERIFY(pc != 0);
+ delete pc;
+
+ QQuickState *state = rect->findChild<QQuickState*>();
+ QVERIFY(state != 0);
+ qmlExecuteDeferred(state);
+ QCOMPARE(state->operationCount(), 1);
+
+ rectPrivate->setState("blue");
+ QCOMPARE(rect->color(),QColor("red"));
+ QCOMPARE(rect->radius(),qreal(5));
+
+ delete rect;
+}
+
+void tst_qquickstates::deletingState()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("deletingState.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QQuickStateGroup *sg = rect->findChild<QQuickStateGroup*>();
+ QVERIFY(sg != 0);
+ QVERIFY(sg->findState("blue") != 0);
+
+ sg->setState("blue");
+ QCOMPARE(rect->color(),QColor("blue"));
+
+ sg->setState("");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ QQuickState *state = rect->findChild<QQuickState*>();
+ QVERIFY(state != 0);
+ delete state;
+
+ QVERIFY(sg->findState("blue") == 0);
+
+ //### should we warn that state doesn't exist
+ sg->setState("blue");
+ QCOMPARE(rect->color(),QColor("red"));
+
+ delete rect;
+}
+
+void tst_qquickstates::tempState()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("legalTempState.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QTest::ignoreMessage(QtDebugMsg, "entering placed");
+ QTest::ignoreMessage(QtDebugMsg, "entering idle");
+ rectPrivate->setState("placed");
+ QCOMPARE(rectPrivate->state(), QLatin1String("idle"));
+}
+
+void tst_qquickstates::illegalTempState()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("illegalTempState.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML StateGroup: Can't apply a state change as part of a state definition.");
+ rectPrivate->setState("placed");
+ QCOMPARE(rectPrivate->state(), QLatin1String("placed"));
+}
+
+void tst_qquickstates::nonExistantProperty()
+{
+ QQmlEngine engine;
+
+ QQmlComponent rectComponent(&engine, testFileUrl("nonExistantProp.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QTest::ignoreMessage(QtWarningMsg, fullDataPath("nonExistantProp.qml") + ":9:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\"");
+ rectPrivate->setState("blue");
+ QCOMPARE(rectPrivate->state(), QLatin1String("blue"));
+}
+
+void tst_qquickstates::reset()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("reset.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickImage *image = rect->findChild<QQuickImage*>();
+ QVERIFY(image != 0);
+ QCOMPARE(image->width(), qreal(40.));
+ QCOMPARE(image->height(), qreal(20.));
+
+ QQuickItemPrivate::get(rect)->setState("state1");
+
+ QCOMPARE(image->width(), 20.0);
+ QCOMPARE(image->height(), qreal(20.));
+
+ delete rect;
+}
+
+void tst_qquickstates::illegalObjectCreation()
+{
+ QQmlEngine engine;
+
+ QQmlComponent component(&engine, testFileUrl("illegalObj.qml"));
+ QList<QQmlError> errors = component.errors();
+ QVERIFY(errors.count() == 1);
+ const QQmlError &error = errors.at(0);
+ QCOMPARE(error.line(), 9);
+ QCOMPARE(error.column(), 23);
+ QCOMPARE(error.description().toUtf8().constData(), "PropertyChanges does not support creating state-specific objects.");
+}
+
+void tst_qquickstates::whenOrdering()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("whenOrdering.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
+ rect->setProperty("condition2", true);
+ QCOMPARE(rectPrivate->state(), QLatin1String("state2"));
+ rect->setProperty("condition1", true);
+ QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
+ rect->setProperty("condition2", false);
+ QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
+ rect->setProperty("condition2", true);
+ QCOMPARE(rectPrivate->state(), QLatin1String("state1"));
+ rect->setProperty("condition1", false);
+ rect->setProperty("condition2", false);
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
+}
+
+void tst_qquickstates::urlResolution()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("urlResolution.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickItem *myType = rect->findChild<QQuickItem*>("MyType");
+ QQuickImage *image1 = rect->findChild<QQuickImage*>("image1");
+ QQuickImage *image2 = rect->findChild<QQuickImage*>("image2");
+ QQuickImage *image3 = rect->findChild<QQuickImage*>("image3");
+ QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0);
+
+ QQuickItemPrivate::get(myType)->setState("SetImageState");
+ QUrl resolved = testFileUrl("Implementation/images/qt-logo.png");
+ QCOMPARE(image1->source(), resolved);
+ QCOMPARE(image2->source(), resolved);
+ QCOMPARE(image3->source(), resolved);
+
+ delete rect;
+}
+
+void tst_qquickstates::unnamedWhen()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("unnamedWhen.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
+ rect->setProperty("triggerState", true);
+ QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1"));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState"));
+ rect->setProperty("triggerState", false);
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
+}
+
+void tst_qquickstates::returnToBase()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("returnToBase.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String(""));
+ rect->setProperty("triggerState", true);
+ QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1"));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState"));
+ rect->setProperty("triggerState", false);
+ QCOMPARE(rectPrivate->state(), QLatin1String(""));
+ QCOMPARE(rect->property("stateString").toString(), QLatin1String("originalState"));
+}
+
+//QTBUG-12559
+void tst_qquickstates::extendsBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("extendsBug.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ QQuickRectangle *greenRect = rect->findChild<QQuickRectangle*>("greenRect");
+
+ rectPrivate->setState("b");
+ QCOMPARE(greenRect->x(), qreal(100));
+ QCOMPARE(greenRect->y(), qreal(100));
+}
+
+void tst_qquickstates::editProperties()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("editProperties.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+
+ QQuickStateGroup *stateGroup = rectPrivate->_states();
+ QVERIFY(stateGroup != 0);
+ qmlExecuteDeferred(stateGroup);
+
+ QQuickState *blueState = stateGroup->findState("blue");
+ QVERIFY(blueState != 0);
+ qmlExecuteDeferred(blueState);
+
+ QQuickPropertyChanges *propertyChangesBlue = qobject_cast<QQuickPropertyChanges*>(blueState->operationAt(0));
+ QVERIFY(propertyChangesBlue != 0);
+
+ QQuickState *greenState = stateGroup->findState("green");
+ QVERIFY(greenState != 0);
+ qmlExecuteDeferred(greenState);
+
+ QQuickPropertyChanges *propertyChangesGreen = qobject_cast<QQuickPropertyChanges*>(greenState->operationAt(0));
+ QVERIFY(propertyChangesGreen != 0);
+
+ QQuickRectangle *childRect = rect->findChild<QQuickRectangle*>("rect2");
+ QVERIFY(childRect != 0);
+ QCOMPARE(childRect->width(), qreal(402));
+ QVERIFY(QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width")));
+ QCOMPARE(childRect->height(), qreal(200));
+
+ rectPrivate->setState("blue");
+ QCOMPARE(childRect->width(), qreal(50));
+ QCOMPARE(childRect->height(), qreal(40));
+ QVERIFY(!QQmlPropertyPrivate::binding(QQmlProperty(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(QQmlPropertyPrivate::binding(QQmlProperty(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(!QQmlPropertyPrivate::binding(QQmlProperty(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(QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width")));
+ QCOMPARE(childRect->width(), qreal(200));
+
+ propertyChangesBlue->changeValue("width", 50);
+ QCOMPARE(childRect->width(), qreal(50));
+
+ rectPrivate->setState("");
+ QCOMPARE(childRect->width(), qreal(402));
+ QVERIFY(QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width")));
+
+ QCOMPARE(propertyChangesGreen->actions().length(), 2);
+ rectPrivate->setState("green");
+ QCOMPARE(childRect->width(), qreal(200));
+ QCOMPARE(childRect->height(), qreal(100));
+ QVERIFY(QQmlPropertyPrivate::binding(QQmlProperty(childRect, "width")));
+ QVERIFY(greenState->bindingInRevertList(childRect, "width"));
+ QCOMPARE(propertyChangesGreen->actions().length(), 2);
+
+
+ propertyChangesGreen->removeProperty("height");
+ QVERIFY(!QQmlPropertyPrivate::binding(QQmlProperty(childRect, "height")));
+ QCOMPARE(childRect->height(), qreal(200));
+
+ QVERIFY(greenState->bindingInRevertList(childRect, "width"));
+ QVERIFY(greenState->containsPropertyInRevertList(childRect, "width"));
+ propertyChangesGreen->removeProperty("width");
+ QVERIFY(QQmlPropertyPrivate::binding(QQmlProperty(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));
+}
+
+void tst_qquickstates::QTBUG_14830()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("QTBUG-14830.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+ QQuickItem *item = rect->findChild<QQuickItem*>("area");
+
+ QCOMPARE(item->width(), qreal(171));
+}
+
+void tst_qquickstates::avoidFastForward()
+{
+ QQmlEngine engine;
+
+ //shouldn't fast forward if there isn't a transition
+ QQmlComponent c(&engine, testFileUrl("avoidFastForward.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ rectPrivate->setState("a");
+ QCOMPARE(rect->property("updateCount").toInt(), 1);
+}
+
+//QTBUG-22583
+void tst_qquickstates::revertListBug()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("revertListBug.qml"));
+ QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
+ QVERIFY(rect != 0);
+
+ QQuickRectangle *rect1 = rect->findChild<QQuickRectangle*>("rect1");
+ QQuickRectangle *rect2 = rect->findChild<QQuickRectangle*>("rect2");
+ QQuickItem *origParent1 = rect->findChild<QQuickItem*>("originalParent1");
+ QQuickItem *origParent2 = rect->findChild<QQuickItem*>("originalParent2");
+ QQuickItem *newParent = rect->findChild<QQuickItem*>("newParent");
+
+ QCOMPARE(rect1->parentItem(), origParent1);
+ QCOMPARE(rect2->parentItem(), origParent2);
+
+ QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
+ rectPrivate->setState("reparented");
+
+ QCOMPARE(rect1->parentItem(), newParent);
+ QCOMPARE(rect2->parentItem(), origParent2);
+
+ rectPrivate->setState("");
+
+ QCOMPARE(rect1->parentItem(), origParent1);
+ QCOMPARE(rect2->parentItem(), origParent2);
+
+ QMetaObject::invokeMethod(rect, "switchTargetItem");
+
+ rectPrivate->setState("reparented");
+
+ QCOMPARE(rect1->parentItem(), origParent1);
+ QCOMPARE(rect2->parentItem(), newParent);
+
+ rectPrivate->setState("");
+
+ QCOMPARE(rect1->parentItem(), origParent1);
+ QCOMPARE(rect2->parentItem(), origParent2); //QTBUG-22583 causes rect2's parent item to be origParent1
+}
+
+QTEST_MAIN(tst_qquickstates)
+
+#include "tst_qquickstates.moc"
diff --git a/tests/auto/quick/qquickstyledtext/qquickstyledtext.pro b/tests/auto/quick/qquickstyledtext/qquickstyledtext.pro
new file mode 100644
index 0000000000..bd367d5ce2
--- /dev/null
+++ b/tests/auto/quick/qquickstyledtext/qquickstyledtext.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+TARGET = tst_qquickstyledtext
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickstyledtext.cpp
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private quick-private network testlib
diff --git a/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp b/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp
new file mode 100644
index 0000000000..86874b84fd
--- /dev/null
+++ b/tests/auto/quick/qquickstyledtext/tst_qquickstyledtext.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QtTest>
+#include <QtGui/QTextLayout>
+#include <QtCore/QList>
+#include <QtQuick/private/qquickstyledtext_p.h>
+
+class tst_qquickstyledtext : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qquickstyledtext()
+ {
+ }
+
+ struct Format {
+ enum Type {
+ Bold = 0x01,
+ Underline = 0x02,
+ Italic = 0x04
+ };
+ Format(int t, int s, int l)
+ : type(t), start(s), length(l) {}
+ int type;
+ int start;
+ int length;
+ };
+ typedef QList<Format> FormatList;
+
+ static const QChar bullet;
+ static const QChar disc;
+ static const QChar square;
+
+private slots:
+ void textOutput();
+ void textOutput_data();
+};
+
+Q_DECLARE_METATYPE(tst_qquickstyledtext::FormatList);
+
+const QChar tst_qquickstyledtext::bullet(0x2022);
+const QChar tst_qquickstyledtext::disc(0x25e6);
+const QChar tst_qquickstyledtext::square(0x25a1);
+
+// For malformed input all we test is that we get the expected text and format out.
+//
+void tst_qquickstyledtext::textOutput_data()
+{
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<QString>("output");
+ QTest::addColumn<FormatList>("formats");
+
+ QTest::newRow("bold") << "<b>bold</b>" << "bold" << (FormatList() << Format(Format::Bold, 0, 4));
+ QTest::newRow("italic") << "<i>italic</i>" << "italic" << (FormatList() << Format(Format::Italic, 0, 6));
+ QTest::newRow("underline") << "<u>underline</u>" << "underline" << (FormatList() << Format(Format::Underline, 0, 9));
+ QTest::newRow("strong") << "<strong>strong</strong>" << "strong" << (FormatList() << Format(Format::Bold, 0, 6));
+ QTest::newRow("underline") << "<u>underline</u>" << "underline" << (FormatList() << Format(Format::Underline, 0, 9));
+ QTest::newRow("missing >") << "<b>text</b" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
+ QTest::newRow("missing b>") << "<b>text</" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
+ QTest::newRow("missing /b>") << "<b>text<" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
+ QTest::newRow("missing </b>") << "<b>text" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
+ QTest::newRow("nested") << "<b>text <i>italic</i> bold</b>" << "text italic bold" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6) << Format(Format::Bold, 11, 5));
+ QTest::newRow("bad nest") << "<b>text <i>italic</b></i>" << "text italic" << (FormatList() << Format(Format::Bold, 0, 5) << Format(Format::Bold | Format::Italic, 5, 6));
+ QTest::newRow("font color") << "<font color=\"red\">red text</font>" << "red text" << (FormatList() << Format(0, 0, 8));
+ QTest::newRow("font color: single quote") << "<font color='red'>red text</font>" << "red text" << (FormatList() << Format(0, 0, 8));
+ QTest::newRow("font size") << "<font size=\"1\">text</font>" << "text" << (FormatList() << Format(0, 0, 4));
+ QTest::newRow("font empty") << "<font>text</font>" << "text" << FormatList();
+ QTest::newRow("font bad 1") << "<font ezis=\"blah\">text</font>" << "text" << FormatList();
+ QTest::newRow("font bad 2") << "<font size=\"1>text</font>" << "" << FormatList();
+ QTest::newRow("extra close") << "<b>text</b></b>" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
+ QTest::newRow("extra space") << "<b >text</b>" << "text" << (FormatList() << Format(Format::Bold, 0, 4));
+ QTest::newRow("entities") << "&lt;b&gt;this &amp; that&lt;/b&gt;" << "<b>this & that</b>" << FormatList();
+ QTest::newRow("newline") << "text<br>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
+ QTest::newRow("paragraph") << "text<p>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
+ QTest::newRow("paragraph closed") << "text<p>more text</p>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
+ QTest::newRow("paragraph closed bold") << "<b>text<p>more text</p>more text</b>" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << (FormatList() << Format(Format::Bold, 0, 24));
+ QTest::newRow("self-closing newline") << "text<br/>more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
+ QTest::newRow("empty") << "" << "" << FormatList();
+ QTest::newRow("unknown tag") << "<a href='#'><foo>underline</foo></a> not" << "underline not" << (FormatList() << Format(Format::Underline, 0, 9));
+ QTest::newRow("ordered list") << "<ol><li>one<li>two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList();
+ QTest::newRow("ordered list closed") << "<ol><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
+ QTest::newRow("ordered list alpha") << "<ol type=\"a\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("a.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("b.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
+ QTest::newRow("ordered list upper alpha") << "<ol type=\"A\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("A.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("B.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
+ QTest::newRow("ordered list roman") << "<ol type=\"i\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("i.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("ii.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
+ QTest::newRow("ordered list upper roman") << "<ol type=\"I\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("I.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("II.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
+ QTest::newRow("ordered list bad") << "<ol type=\"z\"><li>one</li><li>two</li></ol>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("1.") + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + QLatin1String("2.") + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
+ QTest::newRow("unordered list") << "<ul><li>one<li>two" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") << FormatList();
+ QTest::newRow("unordered list closed") << "<ul><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
+ QTest::newRow("unordered list disc") << "<ul type=\"disc\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + disc + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
+ QTest::newRow("unordered list square") << "<ul type=\"square\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + square + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
+ QTest::newRow("unordered list bad") << "<ul type=\"bad\"><li>one</li><li>two</li></ul>" << QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("one") + QChar(QChar::LineSeparator) + QString(6, QChar::Nbsp) + bullet + QString(2, QChar::Nbsp) + QLatin1String("two") + QChar(QChar::LineSeparator) << FormatList();
+ QTest::newRow("header close") << "<h1>head</h1>more" << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) + QLatin1String("more") << (FormatList() << Format(Format::Bold, 0, 5));
+ QTest::newRow("h0") << "<h0>head" << "head" << FormatList();
+ QTest::newRow("h1") << "<h1>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
+ QTest::newRow("h2") << "<h2>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
+ QTest::newRow("h3") << "<h3>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
+ QTest::newRow("h4") << "<h4>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
+ QTest::newRow("h5") << "<h5>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
+ QTest::newRow("h6") << "<h6>head" << QChar(QChar::LineSeparator) + QLatin1String("head") << (FormatList() << Format(Format::Bold, 0, 5));
+ QTest::newRow("h7") << "<h7>head" << "head" << FormatList();
+ QTest::newRow("pre") << "normal<pre>pre text</pre>normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 9));
+ QTest::newRow("pre lb") << "normal<pre>pre\n text</pre>normal" << QLatin1String("normal") + QChar(QChar::LineSeparator) + QLatin1String("pre") + QChar(QChar::LineSeparator) + QChar(QChar::Nbsp) + QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("normal") << (FormatList() << Format(0, 6, 10));
+ QTest::newRow("line feed") << "line\nfeed" << "line feed" << FormatList();
+ QTest::newRow("leading whitespace") << " leading whitespace" << "leading whitespace" << FormatList();
+ QTest::newRow("trailing whitespace") << "trailing whitespace " << "trailing whitespace" << FormatList();
+ QTest::newRow("consecutive whitespace") << " consecutive \t \n whitespace" << "consecutive whitespace" << FormatList();
+ QTest::newRow("space after newline") << "text<br/> more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
+ QTest::newRow("space after paragraph") << "text<p> more text</p> more text" << QLatin1String("text") + QChar(QChar::LineSeparator) + QLatin1String("more text") + QChar(QChar::LineSeparator) + QLatin1String("more text") << FormatList();
+ QTest::newRow("space in header") << "<h1> head</h1> " << QChar(QChar::LineSeparator) + QLatin1String("head") + QChar(QChar::LineSeparator) << (FormatList() << Format(Format::Bold, 0, 5));
+ QTest::newRow("space before bold") << "this is <b>bold</b>" << "this is bold" << (FormatList() << Format(Format::Bold, 8, 4));
+ QTest::newRow("space leading bold") << "this is<b> bold</b>" << "this is bold" << (FormatList() << Format(Format::Bold, 7, 5));
+ QTest::newRow("space trailing bold") << "this is <b>bold </b>" << "this is bold " << (FormatList() << Format(Format::Bold, 8, 5));
+ QTest::newRow("img") << "a<img src=\"blah.png\"/>b" << "a b" << FormatList();
+}
+
+void tst_qquickstyledtext::textOutput()
+{
+ QFETCH(QString, input);
+ QFETCH(QString, output);
+ QFETCH(FormatList, formats);
+
+ QTextLayout layout;
+ QList<QQuickStyledTextImgTag*> imgTags;
+ QQuickStyledText::parse(input, layout, imgTags, QUrl(), 0, false);
+
+ QCOMPARE(layout.text(), output);
+
+ QList<QTextLayout::FormatRange> layoutFormats = layout.additionalFormats();
+
+ QCOMPARE(layoutFormats.count(), formats.count());
+ for (int i = 0; i < formats.count(); ++i) {
+ QCOMPARE(layoutFormats.at(i).start, formats.at(i).start);
+ QCOMPARE(layoutFormats.at(i).length, formats.at(i).length);
+ if (formats.at(i).type & Format::Bold)
+ QVERIFY(layoutFormats.at(i).format.fontWeight() == QFont::Bold);
+ else
+ QVERIFY(layoutFormats.at(i).format.fontWeight() == QFont::Normal);
+ QVERIFY(layoutFormats.at(i).format.fontItalic() == bool(formats.at(i).type & Format::Italic));
+ QVERIFY(layoutFormats.at(i).format.fontUnderline() == bool(formats.at(i).type & Format::Underline));
+ }
+}
+
+
+QTEST_MAIN(tst_qquickstyledtext)
+
+#include "tst_qquickstyledtext.moc"
diff --git a/tests/auto/quick/qquicksystempalette/qquicksystempalette.pro b/tests/auto/quick/qquicksystempalette/qquicksystempalette.pro
new file mode 100644
index 0000000000..c8825c07fb
--- /dev/null
+++ b/tests/auto/quick/qquicksystempalette/qquicksystempalette.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+TARGET = tst_qquicksystempalette
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicksystempalette.cpp
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private quick-private widgets testlib
diff --git a/tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp b/tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp
new file mode 100644
index 0000000000..3b74dfd0ed
--- /dev/null
+++ b/tests/auto/quick/qquicksystempalette/tst_qquicksystempalette.cpp
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+#include <QDebug>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/private/qquicksystempalette_p.h>
+#include <qpalette.h>
+
+class tst_qquicksystempalette : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qquicksystempalette();
+
+private slots:
+ void activePalette();
+ void inactivePalette();
+ void disabledPalette();
+ void paletteChanged();
+
+private:
+ QQmlEngine engine;
+};
+
+tst_qquicksystempalette::tst_qquicksystempalette()
+{
+}
+
+void tst_qquicksystempalette::activePalette()
+{
+ QString componentStr = "import QtQuick 2.0\nSystemPalette { }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickSystemPalette *object = qobject_cast<QQuickSystemPalette*>(component.create());
+
+ QVERIFY(object != 0);
+
+ QPalette palette;
+ palette.setCurrentColorGroup(QPalette::Active);
+ QCOMPARE(palette.window().color(), object->window());
+ QCOMPARE(palette.windowText().color(), object->windowText());
+ QCOMPARE(palette.base().color(), object->base());
+ QCOMPARE(palette.text().color(), object->text());
+ QCOMPARE(palette.alternateBase().color(), object->alternateBase());
+ QCOMPARE(palette.button().color(), object->button());
+ QCOMPARE(palette.buttonText().color(), object->buttonText());
+ QCOMPARE(palette.light().color(), object->light());
+ QCOMPARE(palette.midlight().color(), object->midlight());
+ QCOMPARE(palette.dark().color(), object->dark());
+ QCOMPARE(palette.mid().color(), object->mid());
+ QCOMPARE(palette.shadow().color(), object->shadow());
+ QCOMPARE(palette.highlight().color(), object->highlight());
+ QCOMPARE(palette.highlightedText().color(), object->highlightedText());
+
+ delete object;
+}
+
+void tst_qquicksystempalette::inactivePalette()
+{
+ QString componentStr = "import QtQuick 2.0\nSystemPalette { colorGroup: SystemPalette.Inactive }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickSystemPalette *object = qobject_cast<QQuickSystemPalette*>(component.create());
+
+ QVERIFY(object != 0);
+ QVERIFY(object->colorGroup() == QQuickSystemPalette::Inactive);
+
+ QPalette palette;
+ palette.setCurrentColorGroup(QPalette::Inactive);
+ QCOMPARE(palette.window().color(), object->window());
+ QCOMPARE(palette.windowText().color(), object->windowText());
+ QCOMPARE(palette.base().color(), object->base());
+ QCOMPARE(palette.text().color(), object->text());
+ QCOMPARE(palette.alternateBase().color(), object->alternateBase());
+ QCOMPARE(palette.button().color(), object->button());
+ QCOMPARE(palette.buttonText().color(), object->buttonText());
+ QCOMPARE(palette.light().color(), object->light());
+ QCOMPARE(palette.midlight().color(), object->midlight());
+ QCOMPARE(palette.dark().color(), object->dark());
+ QCOMPARE(palette.mid().color(), object->mid());
+ QCOMPARE(palette.shadow().color(), object->shadow());
+ QCOMPARE(palette.highlight().color(), object->highlight());
+ QCOMPARE(palette.highlightedText().color(), object->highlightedText());
+
+ delete object;
+}
+
+void tst_qquicksystempalette::disabledPalette()
+{
+ QString componentStr = "import QtQuick 2.0\nSystemPalette { colorGroup: SystemPalette.Disabled }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickSystemPalette *object = qobject_cast<QQuickSystemPalette*>(component.create());
+
+ QVERIFY(object != 0);
+ QVERIFY(object->colorGroup() == QQuickSystemPalette::Disabled);
+
+ QPalette palette;
+ palette.setCurrentColorGroup(QPalette::Disabled);
+ QCOMPARE(palette.window().color(), object->window());
+ QCOMPARE(palette.windowText().color(), object->windowText());
+ QCOMPARE(palette.base().color(), object->base());
+ QCOMPARE(palette.text().color(), object->text());
+ QCOMPARE(palette.alternateBase().color(), object->alternateBase());
+ QCOMPARE(palette.button().color(), object->button());
+ QCOMPARE(palette.buttonText().color(), object->buttonText());
+ QCOMPARE(palette.light().color(), object->light());
+ QCOMPARE(palette.midlight().color(), object->midlight());
+ QCOMPARE(palette.dark().color(), object->dark());
+ QCOMPARE(palette.mid().color(), object->mid());
+ QCOMPARE(palette.shadow().color(), object->shadow());
+ QCOMPARE(palette.highlight().color(), object->highlight());
+ QCOMPARE(palette.highlightedText().color(), object->highlightedText());
+
+ delete object;
+}
+
+void tst_qquicksystempalette::paletteChanged()
+{
+ QString componentStr = "import QtQuick 2.0\nSystemPalette { }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickSystemPalette *object = qobject_cast<QQuickSystemPalette*>(component.create());
+
+ QVERIFY(object != 0);
+
+ QPalette p;
+ p.setCurrentColorGroup(QPalette::Active);
+ p.setColor(QPalette::Active, QPalette::Text, QColor("red"));
+ p.setColor(QPalette::Active, QPalette::ButtonText, QColor("green"));
+ p.setColor(QPalette::Active, QPalette::WindowText, QColor("blue"));
+
+ qApp->setPalette(p);
+
+ object->setColorGroup(QQuickSystemPalette::Active);
+ QTRY_COMPARE(QColor("red"), object->text());
+ QTRY_COMPARE(QColor("green"), object->buttonText());
+ QTRY_COMPARE(QColor("blue"), object->windowText());
+
+ delete object;
+}
+
+QTEST_MAIN(tst_qquicksystempalette)
+
+#include "tst_qquicksystempalette.moc"
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments.qml b/tests/auto/quick/qquicktext/data/alignments.qml
index 9798d9c736..9798d9c736 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments.qml
+++ b/tests/auto/quick/qquicktext/data/alignments.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_cb.png b/tests/auto/quick/qquicktext/data/alignments_cb.png
index cf6199a418..cf6199a418 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_cb.png
+++ b/tests/auto/quick/qquicktext/data/alignments_cb.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_cc.png b/tests/auto/quick/qquicktext/data/alignments_cc.png
index f81ccb4238..f81ccb4238 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_cc.png
+++ b/tests/auto/quick/qquicktext/data/alignments_cc.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_ct.png b/tests/auto/quick/qquicktext/data/alignments_ct.png
index 9ba64125d5..9ba64125d5 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_ct.png
+++ b/tests/auto/quick/qquicktext/data/alignments_ct.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_lb.png b/tests/auto/quick/qquicktext/data/alignments_lb.png
index 1b50a81f3d..1b50a81f3d 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_lb.png
+++ b/tests/auto/quick/qquicktext/data/alignments_lb.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_lc.png b/tests/auto/quick/qquicktext/data/alignments_lc.png
index f041b868f8..f041b868f8 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_lc.png
+++ b/tests/auto/quick/qquicktext/data/alignments_lc.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_lt.png b/tests/auto/quick/qquicktext/data/alignments_lt.png
index c75e0d158e..c75e0d158e 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_lt.png
+++ b/tests/auto/quick/qquicktext/data/alignments_lt.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_rb.png b/tests/auto/quick/qquicktext/data/alignments_rb.png
index b06a5da715..b06a5da715 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_rb.png
+++ b/tests/auto/quick/qquicktext/data/alignments_rb.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_rc.png b/tests/auto/quick/qquicktext/data/alignments_rc.png
index e468857cd0..e468857cd0 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_rc.png
+++ b/tests/auto/quick/qquicktext/data/alignments_rc.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/alignments_rt.png b/tests/auto/quick/qquicktext/data/alignments_rt.png
index 576715ffce..576715ffce 100644
--- a/tests/auto/qtquick2/qquicktext/data/alignments_rt.png
+++ b/tests/auto/quick/qquicktext/data/alignments_rt.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocal.qml b/tests/auto/quick/qquicktext/data/embeddedImagesLocal.qml
index 74b2ab817a..74b2ab817a 100644
--- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocal.qml
+++ b/tests/auto/quick/qquicktext/data/embeddedImagesLocal.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalError.qml b/tests/auto/quick/qquicktext/data/embeddedImagesLocalError.qml
index a2f7e0c89f..a2f7e0c89f 100644
--- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalError.qml
+++ b/tests/auto/quick/qquicktext/data/embeddedImagesLocalError.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalRelative.qml b/tests/auto/quick/qquicktext/data/embeddedImagesLocalRelative.qml
index 8de7364d08..8de7364d08 100644
--- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesLocalRelative.qml
+++ b/tests/auto/quick/qquicktext/data/embeddedImagesLocalRelative.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemote.qml b/tests/auto/quick/qquicktext/data/embeddedImagesRemote.qml
index 702633c538..702633c538 100644
--- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemote.qml
+++ b/tests/auto/quick/qquicktext/data/embeddedImagesRemote.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteError.qml b/tests/auto/quick/qquicktext/data/embeddedImagesRemoteError.qml
index 5762f3e47d..5762f3e47d 100644
--- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteError.qml
+++ b/tests/auto/quick/qquicktext/data/embeddedImagesRemoteError.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteRelative.qml b/tests/auto/quick/qquicktext/data/embeddedImagesRemoteRelative.qml
index cee19740f9..cee19740f9 100644
--- a/tests/auto/qtquick2/qquicktext/data/embeddedImagesRemoteRelative.qml
+++ b/tests/auto/quick/qquicktext/data/embeddedImagesRemoteRelative.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml b/tests/auto/quick/qquicktext/data/fontSizeMode.qml
index 20f7535365..20f7535365 100644
--- a/tests/auto/qtquick2/qquicktext/data/fontSizeMode.qml
+++ b/tests/auto/quick/qquicktext/data/fontSizeMode.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/horizontalAlignment_RightToLeft.qml b/tests/auto/quick/qquicktext/data/horizontalAlignment_RightToLeft.qml
index 5ba4d35684..5ba4d35684 100644
--- a/tests/auto/qtquick2/qquicktext/data/horizontalAlignment_RightToLeft.qml
+++ b/tests/auto/quick/qquicktext/data/horizontalAlignment_RightToLeft.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/http/exists.png b/tests/auto/quick/qquicktext/data/http/exists.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qquicktext/data/http/exists.png
+++ b/tests/auto/quick/qquicktext/data/http/exists.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/images/face-sad.png b/tests/auto/quick/qquicktext/data/images/face-sad.png
index 24188b7985..24188b7985 100644
--- a/tests/auto/qtquick2/qquicktext/data/images/face-sad.png
+++ b/tests/auto/quick/qquicktext/data/images/face-sad.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/images/heart200.png b/tests/auto/quick/qquicktext/data/images/heart200.png
index cedd3ea608..cedd3ea608 100644
--- a/tests/auto/qtquick2/qquicktext/data/images/heart200.png
+++ b/tests/auto/quick/qquicktext/data/images/heart200.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/images/starfish_2.png b/tests/auto/quick/qquicktext/data/images/starfish_2.png
index 132c20ffd0..132c20ffd0 100644
--- a/tests/auto/qtquick2/qquicktext/data/images/starfish_2.png
+++ b/tests/auto/quick/qquicktext/data/images/starfish_2.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktext/data/imgTagsElide.qml b/tests/auto/quick/qquicktext/data/imgTagsElide.qml
index fbd64cc5bf..fbd64cc5bf 100644
--- a/tests/auto/qtquick2/qquicktext/data/imgTagsElide.qml
+++ b/tests/auto/quick/qquicktext/data/imgTagsElide.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/imgTagsUpdates.qml b/tests/auto/quick/qquicktext/data/imgTagsUpdates.qml
index baf5113e52..baf5113e52 100644
--- a/tests/auto/qtquick2/qquicktext/data/imgTagsUpdates.qml
+++ b/tests/auto/quick/qquicktext/data/imgTagsUpdates.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/lineCount.qml b/tests/auto/quick/qquicktext/data/lineCount.qml
index b672863684..b672863684 100644
--- a/tests/auto/qtquick2/qquicktext/data/lineCount.qml
+++ b/tests/auto/quick/qquicktext/data/lineCount.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/lineHeight.qml b/tests/auto/quick/qquicktext/data/lineHeight.qml
index c1f337aa05..c1f337aa05 100644
--- a/tests/auto/qtquick2/qquicktext/data/lineHeight.qml
+++ b/tests/auto/quick/qquicktext/data/lineHeight.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/lineLayout.qml b/tests/auto/quick/qquicktext/data/lineLayout.qml
index cb2474791e..cb2474791e 100644
--- a/tests/auto/qtquick2/qquicktext/data/lineLayout.qml
+++ b/tests/auto/quick/qquicktext/data/lineLayout.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml b/tests/auto/quick/qquicktext/data/multilengthStrings.qml
index d26576eacd..d26576eacd 100644
--- a/tests/auto/qtquick2/qquicktext/data/multilengthStrings.qml
+++ b/tests/auto/quick/qquicktext/data/multilengthStrings.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml b/tests/auto/quick/qquicktext/data/multilengthStringsWrapped.qml
index 0da9bc353a..0da9bc353a 100644
--- a/tests/auto/qtquick2/qquicktext/data/multilengthStringsWrapped.qml
+++ b/tests/auto/quick/qquicktext/data/multilengthStringsWrapped.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/multilineelide.qml b/tests/auto/quick/qquicktext/data/multilineelide.qml
index f3bb65775b..f3bb65775b 100644
--- a/tests/auto/qtquick2/qquicktext/data/multilineelide.qml
+++ b/tests/auto/quick/qquicktext/data/multilineelide.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/qtbug_14734.qml b/tests/auto/quick/qquicktext/data/qtbug_14734.qml
index e71a798421..e71a798421 100644
--- a/tests/auto/qtquick2/qquicktext/data/qtbug_14734.qml
+++ b/tests/auto/quick/qquicktext/data/qtbug_14734.qml
diff --git a/tests/auto/qtquick2/qquicktext/data/rotated.qml b/tests/auto/quick/qquicktext/data/rotated.qml
index fecf64b249..fecf64b249 100644
--- a/tests/auto/qtquick2/qquicktext/data/rotated.qml
+++ b/tests/auto/quick/qquicktext/data/rotated.qml
diff --git a/tests/auto/quick/qquicktext/qquicktext.pro b/tests/auto/quick/qquicktext/qquicktext.pro
new file mode 100644
index 0000000000..67e0b9fb90
--- /dev/null
+++ b/tests/auto/quick/qquicktext/qquicktext.pro
@@ -0,0 +1,19 @@
+CONFIG += testcase
+TARGET = tst_qquicktext
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicktext.cpp
+
+INCLUDEPATH += ../../shared/
+HEADERS += ../../shared/testhttpserver.h
+SOURCES += ../../shared/testhttpserver.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private widgets-private opengl-private network testlib
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
new file mode 100644
index 0000000000..754395dba1
--- /dev/null
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -0,0 +1,2432 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QTextDocument>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <private/qquicktext_p_p.h>
+#include <private/qqmlvaluetype_p.h>
+#include <QFontMetrics>
+#include <QGraphicsSceneMouseEvent>
+#include <qmath.h>
+#include <QtQuick/QQuickView>
+#include <private/qapplication_p.h>
+#include <limits.h>
+#include <QtGui/QMouseEvent>
+#include "../../shared/util.h"
+#include "testhttpserver.h"
+
+DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
+
+class tst_qquicktext : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquicktext();
+
+private slots:
+ void text();
+ void width();
+ void wrap();
+ void elide();
+ void multilineElide();
+ void textFormat();
+
+ void alignments_data();
+ void alignments();
+
+ void baseUrl();
+ void embeddedImages_data();
+ void embeddedImages();
+
+ void lineCount();
+ void lineHeight();
+
+ // ### these tests may be trivial
+ void horizontalAlignment();
+ void horizontalAlignment_RightToLeft();
+ void verticalAlignment();
+ void font();
+ void style();
+ void color();
+ void smooth();
+
+ // QQmlFontValueType
+ void weight();
+ void underline();
+ void overline();
+ void strikeout();
+ void capitalization();
+ void letterSpacing();
+ void wordSpacing();
+
+ void clickLink();
+
+ void implicitSize_data();
+ void implicitSize();
+ void contentSize();
+
+ void lineLaidOut();
+
+ void imgTagsBaseUrl_data();
+ void imgTagsBaseUrl();
+ void imgTagsAlign_data();
+ void imgTagsAlign();
+ void imgTagsMultipleImages();
+ void imgTagsElide();
+ void imgTagsUpdates();
+ void imgTagsError();
+ void fontSizeMode_data();
+ void fontSizeMode();
+ void fontSizeModeMultiline_data();
+ void fontSizeModeMultiline();
+ void multilengthStrings_data();
+ void multilengthStrings();
+
+private:
+ QStringList standard;
+ QStringList richText;
+
+ QStringList horizontalAlignmentmentStrings;
+ QStringList verticalAlignmentmentStrings;
+
+ QList<Qt::Alignment> verticalAlignmentments;
+ QList<Qt::Alignment> horizontalAlignmentments;
+
+ QStringList styleStrings;
+ QList<QQuickText::TextStyle> styles;
+
+ QStringList colorStrings;
+
+ QQmlEngine engine;
+
+ QQuickView *createView(const QString &filename);
+};
+
+tst_qquicktext::tst_qquicktext()
+{
+ standard << "the quick brown fox jumped over the lazy dog"
+ << "the quick brown fox\n jumped over the lazy dog";
+
+ richText << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a> jumped over the <b>lazy</b> dog</i>"
+ << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
+
+ horizontalAlignmentmentStrings << "AlignLeft"
+ << "AlignRight"
+ << "AlignHCenter";
+
+ verticalAlignmentmentStrings << "AlignTop"
+ << "AlignBottom"
+ << "AlignVCenter";
+
+ horizontalAlignmentments << Qt::AlignLeft
+ << Qt::AlignRight
+ << Qt::AlignHCenter;
+
+ verticalAlignmentments << Qt::AlignTop
+ << Qt::AlignBottom
+ << Qt::AlignVCenter;
+
+ styleStrings << "Normal"
+ << "Outline"
+ << "Raised"
+ << "Sunken";
+
+ styles << QQuickText::Normal
+ << QQuickText::Outline
+ << QQuickText::Raised
+ << QQuickText::Sunken;
+
+ colorStrings << "aliceblue"
+ << "antiquewhite"
+ << "aqua"
+ << "darkkhaki"
+ << "darkolivegreen"
+ << "dimgray"
+ << "palevioletred"
+ << "lightsteelblue"
+ << "#000000"
+ << "#AAAAAA"
+ << "#FFFFFF"
+ << "#2AC05F";
+ //
+ // need a different test to do alpha channel test
+ // << "#AA0011DD"
+ // << "#00F16B11";
+ //
+}
+
+QQuickView *tst_qquicktext::createView(const QString &filename)
+{
+ QQuickView *canvas = new QQuickView(0);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+ return canvas;
+}
+
+void tst_qquicktext::text()
+{
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nText { text: \"\" }", QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->text(), QString(""));
+ QVERIFY(textObject->width() == 0);
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->text(), standard.at(i));
+ QVERIFY(textObject->width() > 0);
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QString expected = richText.at(i);
+ QCOMPARE(textObject->text(), expected.replace("\\\"", "\""));
+ QVERIFY(textObject->width() > 0);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::width()
+{
+ // uses Font metrics to find the width for standard and document to find the width for rich
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nText { text: \"\" }", QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 0.);
+
+ delete textObject;
+ }
+
+ bool requiresUnhintedMetrics = !qmlDisableDistanceField();
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QVERIFY(!Qt::mightBeRichText(standard.at(i))); // self-test
+
+ QFont f;
+ qreal metricWidth = 0.0;
+
+ if (requiresUnhintedMetrics) {
+ QString s = standard.at(i);
+ s.replace(QLatin1Char('\n'), QChar::LineSeparator);
+
+ QTextLayout layout(s);
+ layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic);
+ {
+ QTextOption option;
+ option.setUseDesignMetrics(true);
+ layout.setTextOption(option);
+ }
+
+ layout.beginLayout();
+ forever {
+ QTextLine line = layout.createLine();
+ if (!line.isValid())
+ break;
+ }
+
+ layout.endLayout();
+
+ metricWidth = qCeil(layout.boundingRect().width());
+ } else {
+ QFontMetricsF fm(f);
+ qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width();
+ metricWidth = qCeil(metricWidth);
+ }
+
+ QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->boundingRect().width() > 0);
+ QCOMPARE(textObject->width(), qreal(metricWidth));
+ QVERIFY(textObject->textFormat() == QQuickText::AutoText); // setting text doesn't change format
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QVERIFY(Qt::mightBeRichText(richText.at(i))); // self-test
+
+ QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\"; textFormat: Text.RichText }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+ QVERIFY(textObject != 0);
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
+ QVERIFY(textPrivate != 0);
+
+ QTextDocument *doc = textPrivate->textDocument();
+ QVERIFY(doc != 0);
+
+ QCOMPARE(int(textObject->width()), int(doc->idealWidth()));
+ QVERIFY(textObject->textFormat() == QQuickText::RichText);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::wrap()
+{
+ int textHeight = 0;
+ // for specified width and wrap set true
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nText { text: \"Hello\"; wrapMode: Text.WordWrap; width: 300 }", QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+ textHeight = textObject->height();
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->wrapMode() == QQuickText::WordWrap);
+ QCOMPARE(textObject->width(), 300.);
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 30.);
+ QVERIFY(textObject->height() > textHeight);
+
+ int oldHeight = textObject->height();
+ textObject->setWidth(100);
+ QVERIFY(textObject->height() < oldHeight);
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 30.);
+ QVERIFY(textObject->height() > textHeight);
+
+ qreal oldHeight = textObject->height();
+ textObject->setWidth(100);
+ QVERIFY(textObject->height() < oldHeight);
+
+ delete textObject;
+ }
+
+ // richtext again with a fixed height
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { wrapMode: Text.WordWrap; width: 30; height: 50; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 30.);
+ QVERIFY(textObject->implicitHeight() > textHeight);
+
+ qreal oldHeight = textObject->implicitHeight();
+ textObject->setWidth(100);
+ QVERIFY(textObject->implicitHeight() < oldHeight);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::elide()
+{
+ for (QQuickText::TextElideMode m = QQuickText::ElideLeft; m<=QQuickText::ElideNone; m=QQuickText::TextElideMode(int(m)+1)) {
+ const char* elidename[]={"ElideLeft", "ElideRight", "ElideMiddle", "ElideNone"};
+ QString elide = "elide: Text." + QString(elidename[int(m)]) + ";";
+
+ // XXX Poor coverage.
+
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(("import QtQuick 2.0\nText { text: \"\"; "+elide+" width: 100 }").toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->elideMode(), m);
+ QCOMPARE(textObject->width(), 100.);
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { "+elide+" width: 100; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->elideMode(), m);
+ QCOMPARE(textObject->width(), 100.);
+
+ delete textObject;
+ }
+
+ // richtext - does nothing
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->elideMode(), m);
+ QCOMPARE(textObject->width(), 100.);
+
+ delete textObject;
+ }
+ }
+}
+
+void tst_qquicktext::multilineElide()
+{
+ QQuickView *canvas = createView(testFile("multilineelide.qml"));
+
+ QQuickText *myText = qobject_cast<QQuickText*>(canvas->rootObject());
+ QVERIFY(myText != 0);
+
+ QCOMPARE(myText->lineCount(), 3);
+ QCOMPARE(myText->truncated(), true);
+
+ qreal lineHeight = myText->contentHeight() / 3.;
+
+ // reduce size and ensure fewer lines are drawn
+ myText->setHeight(lineHeight * 2);
+ QCOMPARE(myText->lineCount(), 2);
+
+ myText->setHeight(lineHeight);
+ QCOMPARE(myText->lineCount(), 1);
+
+ myText->setHeight(5);
+ QCOMPARE(myText->lineCount(), 1);
+
+ myText->setHeight(lineHeight * 3);
+ QCOMPARE(myText->lineCount(), 3);
+
+ // remove max count and show all lines.
+ myText->setHeight(1000);
+ myText->resetMaximumLineCount();
+
+ QCOMPARE(myText->truncated(), false);
+
+ // reduce size again
+ myText->setHeight(lineHeight * 2);
+ QCOMPARE(myText->lineCount(), 2);
+ QCOMPARE(myText->truncated(), true);
+
+ // change line height
+ myText->setLineHeight(1.1);
+ QCOMPARE(myText->lineCount(), 1);
+
+ delete canvas;
+}
+
+void tst_qquicktext::textFormat()
+{
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nText { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QQuickText::RichText);
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
+ QVERIFY(textPrivate != 0);
+ QVERIFY(textPrivate->richText == true);
+
+ delete textObject;
+ }
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nText { text: \"<b>Hello</b>\" }", QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QQuickText::AutoText);
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
+ QVERIFY(textPrivate != 0);
+ QVERIFY(textPrivate->styledText == true);
+
+ delete textObject;
+ }
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nText { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QQuickText::PlainText);
+
+ delete textObject;
+ }
+}
+
+
+void tst_qquicktext::alignments_data()
+{
+ QTest::addColumn<int>("hAlign");
+ QTest::addColumn<int>("vAlign");
+ QTest::addColumn<QString>("expectfile");
+
+ QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << testFile("alignments_lt.png");
+ QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << testFile("alignments_rt.png");
+ QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << testFile("alignments_ct.png");
+
+ QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << testFile("alignments_lb.png");
+ QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << testFile("alignments_rb.png");
+ QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << testFile("alignments_cb.png");
+
+ QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << testFile("alignments_lc.png");
+ QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << testFile("alignments_rc.png");
+ QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << testFile("alignments_cc.png");
+}
+
+
+void tst_qquicktext::alignments()
+{
+ QSKIP("Text alignment pixmap comparison tests will not work with scenegraph");
+#if (0)// No widgets in scenegraph
+ QFETCH(int, hAlign);
+ QFETCH(int, vAlign);
+ QFETCH(QString, expectfile);
+
+ QQuickView *canvas = createView(testFile("alignments.qml"));
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWait(50);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QObject *ob = canvas->rootObject();
+ QVERIFY(ob != 0);
+ ob->setProperty("horizontalAlignment",hAlign);
+ ob->setProperty("verticalAlignment",vAlign);
+ QTRY_COMPARE(ob->property("running").toBool(),false);
+ QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32);
+ actual.fill(qRgb(255,255,255));
+ QPainter p(&actual);
+ canvas->render(&p);
+
+ QImage expect(expectfile);
+ if (QGuiApplicationPrivate::graphics_system_name == "raster" || QGuiApplicationPrivate::graphics_system_name == "") {
+ QCOMPARE(actual,expect);
+ }
+ delete canvas;
+#endif
+}
+
+//the alignment tests may be trivial o.oa
+void tst_qquicktext::horizontalAlignment()
+{
+ //test one align each, and then test if two align fails.
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
+
+ delete textObject;
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < horizontalAlignmentmentStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j));
+
+ delete textObject;
+ }
+ }
+
+}
+
+void tst_qquicktext::horizontalAlignment_RightToLeft()
+{
+ QQuickView *canvas = createView(testFile("horizontalAlignment_RightToLeft.qml"));
+ QQuickText *text = canvas->rootObject()->findChild<QQuickText*>("text");
+ QVERIFY(text != 0);
+ canvas->show();
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(text);
+ QVERIFY(textPrivate != 0);
+
+ QTRY_VERIFY(textPrivate->layout.lineCount());
+
+ // implicit alignment should follow the reading direction of RTL text
+ QCOMPARE(text->hAlign(), QQuickText::AlignRight);
+ QCOMPARE(text->effectiveHAlign(), text->hAlign());
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
+
+ // explicitly left aligned text
+ text->setHAlign(QQuickText::AlignLeft);
+ QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
+ QCOMPARE(text->effectiveHAlign(), text->hAlign());
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
+
+ // explicitly right aligned text
+ text->setHAlign(QQuickText::AlignRight);
+ QCOMPARE(text->hAlign(), QQuickText::AlignRight);
+ QCOMPARE(text->effectiveHAlign(), text->hAlign());
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
+
+ // change to rich text
+ QString textString = text->text();
+ text->setText(QString("<i>") + textString + QString("</i>"));
+ text->setTextFormat(QQuickText::RichText);
+ text->resetHAlign();
+
+ // implicitly aligned rich text should follow the reading direction of text
+ QCOMPARE(text->hAlign(), QQuickText::AlignRight);
+ QCOMPARE(text->effectiveHAlign(), text->hAlign());
+ QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft);
+
+ // explicitly left aligned rich text
+ text->setHAlign(QQuickText::AlignLeft);
+ QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
+ QCOMPARE(text->effectiveHAlign(), text->hAlign());
+ QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignRight);
+
+ // explicitly right aligned rich text
+ text->setHAlign(QQuickText::AlignRight);
+ QCOMPARE(text->hAlign(), QQuickText::AlignRight);
+ QCOMPARE(text->effectiveHAlign(), text->hAlign());
+ QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft);
+
+ text->setText(textString);
+ text->setTextFormat(QQuickText::PlainText);
+
+ // explicitly center aligned
+ text->setHAlign(QQuickText::AlignHCenter);
+ QCOMPARE(text->hAlign(), QQuickText::AlignHCenter);
+ QCOMPARE(text->effectiveHAlign(), text->hAlign());
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().right() > canvas->width()/2);
+
+ // reseted alignment should go back to following the text reading direction
+ text->resetHAlign();
+ QCOMPARE(text->hAlign(), QQuickText::AlignRight);
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
+
+ // mirror the text item
+ QQuickItemPrivate::get(text)->setLayoutMirror(true);
+
+ // mirrored implicit alignment should continue to follow the reading direction of the text
+ QCOMPARE(text->hAlign(), QQuickText::AlignRight);
+ QCOMPARE(text->effectiveHAlign(), QQuickText::AlignRight);
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
+
+ // mirrored explicitly right aligned behaves as left aligned
+ text->setHAlign(QQuickText::AlignRight);
+ QCOMPARE(text->hAlign(), QQuickText::AlignRight);
+ QCOMPARE(text->effectiveHAlign(), QQuickText::AlignLeft);
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
+
+ // mirrored explicitly left aligned behaves as right aligned
+ text->setHAlign(QQuickText::AlignLeft);
+ QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
+ QCOMPARE(text->effectiveHAlign(), QQuickText::AlignRight);
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2);
+
+ // disable mirroring
+ QQuickItemPrivate::get(text)->setLayoutMirror(false);
+ text->resetHAlign();
+
+ // English text should be implicitly left aligned
+ text->setText("Hello world!");
+ QCOMPARE(text->hAlign(), QQuickText::AlignLeft);
+ QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2);
+
+ // empty text with implicit alignment follows the system locale-based
+ // keyboard input direction from QInputMethod::inputDirection()
+ text->setText("");
+ QCOMPARE(text->hAlign(), qApp->inputMethod()->inputDirection() == Qt::LeftToRight ?
+ QQuickText::AlignLeft : QQuickText::AlignRight);
+ text->setHAlign(QQuickText::AlignRight);
+ QCOMPARE(text->hAlign(), QQuickText::AlignRight);
+
+ delete canvas;
+
+ // alignment of Text with no text set to it
+ QString componentStr = "import QtQuick 2.0\nText {}";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+ QCOMPARE(textObject->hAlign(), qApp->inputMethod()->inputDirection() == Qt::LeftToRight ?
+ QQuickText::AlignLeft : QQuickText::AlignRight);
+ delete textObject;
+}
+
+void tst_qquicktext::verticalAlignment()
+{
+ //test one align each, and then test if two align fails.
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
+
+ delete textObject;
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < verticalAlignmentmentStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j));
+
+ delete textObject;
+ }
+ }
+
+}
+
+void tst_qquicktext::font()
+{
+ //test size, then bold, then italic, then family
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.pointSize: 40; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().pointSize(), 40);
+ QCOMPARE(textObject->font().bold(), false);
+ QCOMPARE(textObject->font().italic(), false);
+
+ delete textObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.pixelSize: 40; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().pixelSize(), 40);
+ QCOMPARE(textObject->font().bold(), false);
+ QCOMPARE(textObject->font().italic(), false);
+
+ delete textObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.bold: true; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().bold(), true);
+ QCOMPARE(textObject->font().italic(), false);
+
+ delete textObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.italic: true; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().italic(), true);
+ QCOMPARE(textObject->font().bold(), false);
+
+ delete textObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textObject->font().bold(), false);
+ QCOMPARE(textObject->font().italic(), false);
+
+ delete textObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.family: \"\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->font().family(), QString(""));
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::style()
+{
+ //test style
+ for (int i = 0; i < styles.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { style: \"" + styleStrings.at(i) + "\"; styleColor: \"white\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE((int)textObject->style(), (int)styles.at(i));
+ QCOMPARE(textObject->styleColor(), QColor("white"));
+
+ delete textObject;
+ }
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QRectF brPre = textObject->boundingRect();
+ textObject->setStyle(QQuickText::Outline);
+ QRectF brPost = textObject->boundingRect();
+
+ QVERIFY(brPre.width() < brPost.width());
+ QVERIFY(brPre.height() < brPost.height());
+
+ delete textObject;
+}
+
+void tst_qquicktext::color()
+{
+ //test style
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
+ QCOMPARE(textObject->styleColor(), QColor("black"));
+ QCOMPARE(textObject->linkColor(), QColor("blue"));
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i)));
+ // default color to black?
+ QCOMPARE(textObject->color(), QColor("black"));
+ QCOMPARE(textObject->linkColor(), QColor("blue"));
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { linkColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->styleColor(), QColor("black"));
+ QCOMPARE(textObject->color(), QColor("black"));
+ QCOMPARE(textObject->linkColor(), QColor(colorStrings.at(i)));
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ for (int j = 0; j < colorStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nText { "
+ "color: \"" + colorStrings.at(i) + "\"; "
+ "styleColor: \"" + colorStrings.at(j) + "\"; "
+ "linkColor: \"" + colorStrings.at(j) + "\"; "
+ "text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->color(), QColor(colorStrings.at(i)));
+ QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(j)));
+ QCOMPARE(textObject->linkColor(), QColor(colorStrings.at(j)));
+
+ delete textObject;
+ }
+ }
+ {
+ QString colorStr = "#AA001234";
+ QColor testColor("#001234");
+ testColor.setAlpha(170);
+
+ QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QCOMPARE(textObject->color(), testColor);
+
+ delete textObject;
+ } {
+ QString colorStr = "#001234";
+ QColor testColor(colorStr);
+
+ QString componentStr = "import QtQuick 2.0\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> object(textComponent.create());
+ QQuickText *textObject = qobject_cast<QQuickText*>(object.data());
+
+ QSignalSpy spy(textObject, SIGNAL(colorChanged()));
+
+ QCOMPARE(textObject->color(), testColor);
+ textObject->setColor(testColor);
+ QCOMPARE(textObject->color(), testColor);
+ QCOMPARE(spy.count(), 0);
+
+ testColor = QColor("black");
+ textObject->setColor(testColor);
+ QCOMPARE(textObject->color(), testColor);
+ QCOMPARE(spy.count(), 1);
+ } {
+ QString colorStr = "#001234";
+ QColor testColor(colorStr);
+
+ QString componentStr = "import QtQuick 2.0\nText { styleColor: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> object(textComponent.create());
+ QQuickText *textObject = qobject_cast<QQuickText*>(object.data());
+
+ QSignalSpy spy(textObject, SIGNAL(styleColorChanged()));
+
+ QCOMPARE(textObject->styleColor(), testColor);
+ textObject->setStyleColor(testColor);
+ QCOMPARE(textObject->styleColor(), testColor);
+ QCOMPARE(spy.count(), 0);
+
+ testColor = QColor("black");
+ textObject->setStyleColor(testColor);
+ QCOMPARE(textObject->styleColor(), testColor);
+ QCOMPARE(spy.count(), 1);
+ } {
+ QString colorStr = "#001234";
+ QColor testColor(colorStr);
+
+ QString componentStr = "import QtQuick 2.0\nText { linkColor: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> object(textComponent.create());
+ QQuickText *textObject = qobject_cast<QQuickText*>(object.data());
+
+ QSignalSpy spy(textObject, SIGNAL(linkColorChanged()));
+
+ QCOMPARE(textObject->linkColor(), testColor);
+ textObject->setLinkColor(testColor);
+ QCOMPARE(textObject->linkColor(), testColor);
+ QCOMPARE(spy.count(), 0);
+
+ testColor = QColor("black");
+ textObject->setLinkColor(testColor);
+ QCOMPARE(textObject->linkColor(), testColor);
+ QCOMPARE(spy.count(), 1);
+ }
+}
+
+void tst_qquicktext::smooth()
+{
+ for (int i = 0; i < standard.size(); i++)
+ {
+ {
+ QString componentStr = "import QtQuick 2.0\nText { smooth: true; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+ QCOMPARE(textObject->smooth(), true);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+ QCOMPARE(textObject->smooth(), false);
+
+ delete textObject;
+ }
+ }
+ for (int i = 0; i < richText.size(); i++)
+ {
+ {
+ QString componentStr = "import QtQuick 2.0\nText { smooth: true; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+ QCOMPARE(textObject->smooth(), true);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"" + richText.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+ QCOMPARE(textObject->smooth(), false);
+
+ delete textObject;
+ }
+ }
+}
+
+void tst_qquicktext::weight()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().weight(), (int)QQmlFontValueType::Normal);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.weight: \"Bold\"; text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().weight(), (int)QQmlFontValueType::Bold);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::underline()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().underline(), false);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.underline: true; text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().underline(), true);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::overline()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().overline(), false);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.overline: true; text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().overline(), true);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::strikeout()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().strikeOut(), false);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { font.strikeout: true; text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().strikeOut(), true);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::capitalization()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QQmlFontValueType::MixedCase);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"AllUppercase\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QQmlFontValueType::AllUppercase);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"AllLowercase\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QQmlFontValueType::AllLowercase);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"SmallCaps\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QQmlFontValueType::SmallCaps);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.capitalization: \"Capitalize\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE((int)textObject->font().capitalization(), (int)QQmlFontValueType::Capitalize);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::letterSpacing()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().letterSpacing(), 0.0);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.letterSpacing: -2 }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().letterSpacing(), -2.);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.letterSpacing: 3 }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().letterSpacing(), 3.);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::wordSpacing()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().wordSpacing(), 0.0);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.wordSpacing: -50 }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().wordSpacing(), -50.);
+
+ delete textObject;
+ }
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"Hello world!\"; font.wordSpacing: 200 }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->font().wordSpacing(), 200.);
+
+ delete textObject;
+ }
+}
+
+
+
+
+class EventSender : public QQuickItem
+{
+public:
+ void sendEvent(QMouseEvent *event) {
+ if (event->type() == QEvent::MouseButtonPress)
+ mousePressEvent(event);
+ else if (event->type() == QEvent::MouseButtonRelease)
+ mouseReleaseEvent(event);
+ else
+ qWarning() << "Trying to send unsupported event type";
+ }
+};
+
+class LinkTest : public QObject
+{
+ Q_OBJECT
+public:
+ LinkTest() {}
+
+ QString link;
+
+public slots:
+ void linkClicked(QString l) { link = l; }
+};
+
+void tst_qquicktext::clickLink()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nText { text: \"<a href=\\\"http://qt.nokia.com\\\">Hello world!</a>\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+
+ LinkTest test;
+ QObject::connect(textObject, SIGNAL(linkActivated(QString)), &test, SLOT(linkClicked(QString)));
+
+ {
+ QMouseEvent me(QEvent::MouseButtonPress,QPointF(textObject->x()/2, textObject->y()/2), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
+ static_cast<EventSender*>(static_cast<QQuickItem*>(textObject))->sendEvent(&me);
+
+ }
+
+ {
+ QMouseEvent me(QEvent::MouseButtonRelease,QPointF(textObject->x()/2, textObject->y()/2), Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
+ static_cast<EventSender*>(static_cast<QQuickItem*>(textObject))->sendEvent(&me);
+
+ }
+
+
+ QCOMPARE(test.link, QLatin1String("http://qt.nokia.com"));
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktext::baseUrl()
+{
+ QUrl localUrl("file:///tests/text.qml");
+ QUrl remoteUrl("http://qt.nokia.com/test.qml");
+
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\n Text {}", localUrl);
+ QQuickText *textObject = qobject_cast<QQuickText *>(textComponent.create());
+
+ QCOMPARE(textObject->baseUrl(), localUrl);
+
+ QSignalSpy spy(textObject, SIGNAL(baseUrlChanged()));
+
+ textObject->setBaseUrl(localUrl);
+ QCOMPARE(textObject->baseUrl(), localUrl);
+ QCOMPARE(spy.count(), 0);
+
+ textObject->setBaseUrl(remoteUrl);
+ QCOMPARE(textObject->baseUrl(), remoteUrl);
+ QCOMPARE(spy.count(), 1);
+
+ textObject->resetBaseUrl();
+ QCOMPARE(textObject->baseUrl(), localUrl);
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktext::embeddedImages_data()
+{
+ QTest::addColumn<QUrl>("qmlfile");
+ QTest::addColumn<QString>("error");
+ QTest::newRow("local") << testFileUrl("embeddedImagesLocal.qml") << "";
+ QTest::newRow("local-error") << testFileUrl("embeddedImagesLocalError.qml")
+ << testFileUrl("embeddedImagesLocalError.qml").toString()+":3:1: QML Text: Cannot open: " + testFileUrl("http/notexists.png").toString();
+ QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << "";
+ QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << "";
+ QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml")
+ << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found";
+ QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << "";
+}
+
+void tst_qquicktext::embeddedImages()
+{
+ // Tests QTBUG-9900
+
+ QFETCH(QUrl, qmlfile);
+ QFETCH(QString, error);
+
+ TestHTTPServer server(14453);
+ server.serveDirectory(testFile("http"));
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
+
+ QQmlComponent textComponent(&engine, qmlfile);
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+
+ QTRY_COMPARE(textObject->resourcesLoading(), 0);
+
+ QPixmap pm(testFile("http/exists.png"));
+ if (error.isEmpty()) {
+ QCOMPARE(textObject->width(), double(pm.width()));
+ QCOMPARE(textObject->height(), double(pm.height()));
+ } else {
+ QVERIFY(16 != pm.width()); // check test is effective
+ QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon
+ QCOMPARE(textObject->height(), 16.0);
+ }
+
+ delete textObject;
+}
+
+void tst_qquicktext::lineCount()
+{
+ QQuickView *canvas = createView(testFile("lineCount.qml"));
+
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ QVERIFY(myText->lineCount() > 1);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->maximumLineCount(), INT_MAX);
+
+ myText->setMaximumLineCount(2);
+ QCOMPARE(myText->lineCount(), 2);
+ QCOMPARE(myText->truncated(), true);
+ QCOMPARE(myText->maximumLineCount(), 2);
+
+ myText->resetMaximumLineCount();
+ QCOMPARE(myText->maximumLineCount(), INT_MAX);
+ QCOMPARE(myText->truncated(), false);
+
+ myText->setElideMode(QQuickText::ElideRight);
+ myText->setMaximumLineCount(2);
+ QCOMPARE(myText->lineCount(), 2);
+ QCOMPARE(myText->truncated(), true);
+ QCOMPARE(myText->maximumLineCount(), 2);
+
+ delete canvas;
+}
+
+void tst_qquicktext::lineHeight()
+{
+ QQuickView *canvas = createView(testFile("lineHeight.qml"));
+
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ QVERIFY(myText->lineHeight() == 1);
+ QVERIFY(myText->lineHeightMode() == QQuickText::ProportionalHeight);
+
+ qreal h = myText->height();
+ myText->setLineHeight(1.5);
+ QCOMPARE(myText->height(), qreal(qCeil(h * 1.5)));
+
+ myText->setLineHeightMode(QQuickText::FixedHeight);
+ myText->setLineHeight(20);
+ QCOMPARE(myText->height(), myText->lineCount() * 20.0);
+
+ myText->setText("Lorem ipsum sit <b>amet</b>, consectetur adipiscing elit. Integer felis nisl, varius in pretium nec, venenatis non erat. Proin lobortis interdum dictum.");
+ myText->setLineHeightMode(QQuickText::ProportionalHeight);
+ myText->setLineHeight(1.0);
+
+ qreal h2 = myText->height();
+ myText->setLineHeight(2.0);
+ QVERIFY(myText->height() == h2 * 2.0);
+
+ myText->setLineHeightMode(QQuickText::FixedHeight);
+ myText->setLineHeight(10);
+ QCOMPARE(myText->height(), myText->lineCount() * 10.0);
+
+ delete canvas;
+}
+
+void tst_qquicktext::implicitSize_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("width");
+ QTest::addColumn<QString>("wrap");
+ QTest::addColumn<QString>("elide");
+ QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.NoWrap" << "Text.ElideNone";
+ QTest::newRow("richtext") << "<b>The quick red fox jumped over the lazy brown dog</b>" <<" 50" << "Text.NoWrap" << "Text.ElideNone";
+ QTest::newRow("plain, 0 width") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.NoWrap" << "Text.ElideNone";
+ QTest::newRow("plain, elide") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.NoWrap" << "Text.ElideRight";
+ QTest::newRow("plain, 0 width, elide") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.NoWrap" << "Text.ElideRight";
+ QTest::newRow("richtext, 0 width") << "<b>The quick red fox jumped over the lazy brown dog</b>" <<" 0" << "Text.NoWrap" << "Text.ElideNone";
+ QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.Wrap" << "Text.ElideNone";
+ QTest::newRow("richtext_wrap") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "50" << "Text.Wrap" << "Text.ElideNone";
+ QTest::newRow("plain_wrap, 0 width") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.Wrap" << "Text.ElideNone";
+ QTest::newRow("plain_wrap, elide") << "The quick red fox jumped over the lazy brown dog" << "50" << "Text.Wrap" << "Text.ElideRight";
+ QTest::newRow("plain_wrap, 0 width, elide") << "The quick red fox jumped over the lazy brown dog" << "0" << "Text.Wrap" << "Text.ElideRight";
+ QTest::newRow("richtext_wrap, 0 width") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "0" << "Text.Wrap" << "Text.ElideNone";
+}
+
+void tst_qquicktext::implicitSize()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, width);
+ QFETCH(QString, wrap);
+ QFETCH(QString, elide);
+ QString componentStr = "import QtQuick 2.0\nText { "
+ "text: \"" + text + "\"; "
+ "width: " + width + "; "
+ "wrapMode: " + wrap + "; "
+ "elide: " + elide + "; "
+ "maximumLineCount: 1 }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject->width() < textObject->implicitWidth());
+ QVERIFY(textObject->height() == textObject->implicitHeight());
+
+ textObject->resetWidth();
+ QVERIFY(textObject->width() == textObject->implicitWidth());
+ QVERIFY(textObject->height() == textObject->implicitHeight());
+
+ delete textObject;
+}
+
+void tst_qquicktext::contentSize()
+{
+ QString componentStr = "import QtQuick 2.0\nText { width: 75; height: 16; font.pixelSize: 10 }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> object(textComponent.create());
+ QQuickText *textObject = qobject_cast<QQuickText *>(object.data());
+
+ QSignalSpy spy(textObject, SIGNAL(contentSizeChanged()));
+
+ textObject->setText("The quick red fox jumped over the lazy brown dog");
+
+ QVERIFY(textObject->contentWidth() > textObject->width());
+ QVERIFY(textObject->contentHeight() < textObject->height());
+ QCOMPARE(spy.count(), 1);
+
+ textObject->setWrapMode(QQuickText::WordWrap);
+ QVERIFY(textObject->contentWidth() <= textObject->width());
+ QVERIFY(textObject->contentHeight() > textObject->height());
+ QCOMPARE(spy.count(), 2);
+
+ textObject->setElideMode(QQuickText::ElideRight);
+ QVERIFY(textObject->contentWidth() <= textObject->width());
+ QVERIFY(textObject->contentHeight() < textObject->height());
+ QCOMPARE(spy.count(), 3);
+ int spyCount = 3;
+ qreal elidedWidth = textObject->contentWidth();
+
+ textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
+ QVERIFY(textObject->contentWidth() <= textObject->width());
+ QVERIFY(textObject->contentHeight() < textObject->height());
+ // this text probably won't have the same elided width, but it's not guaranteed.
+ if (textObject->contentWidth() != elidedWidth)
+ QCOMPARE(spy.count(), ++spyCount);
+ else
+ QCOMPARE(spy.count(), spyCount);
+
+ textObject->setElideMode(QQuickText::ElideNone);
+ QVERIFY(textObject->contentWidth() > textObject->width());
+ QVERIFY(textObject->contentHeight() > textObject->height());
+ QCOMPARE(spy.count(), ++spyCount);
+}
+
+void tst_qquicktext::lineLaidOut()
+{
+ QQuickView *canvas = createView(testFile("lineLayout.qml"));
+
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
+ QVERIFY(textPrivate != 0);
+
+ QTextDocument *doc = textPrivate->textDocument();
+ QVERIFY(doc == 0);
+
+#if defined(Q_OS_MAC)
+ QVERIFY(myText->lineCount() == textPrivate->linesRects.count());
+#endif
+
+ for (int i = 0; i < textPrivate->layout.lineCount(); ++i) {
+ QRectF r = textPrivate->layout.lineAt(i).rect();
+ QVERIFY(r.width() == i * 15);
+ if (i >= 30)
+ QVERIFY(r.x() == r.width() + 30);
+ if (i >= 60) {
+ QVERIFY(r.x() == r.width() * 2 + 60);
+ QVERIFY(r.height() == 20);
+ }
+ }
+
+ delete canvas;
+}
+
+void tst_qquicktext::imgTagsBaseUrl_data()
+{
+ QTest::addColumn<QUrl>("src");
+ QTest::addColumn<QUrl>("baseUrl");
+ QTest::addColumn<QUrl>("contextUrl");
+ QTest::addColumn<qreal>("imgHeight");
+
+ QTest::newRow("absolute local")
+ << testFileUrl("images/heart200.png")
+ << QUrl()
+ << QUrl()
+ << 181.;
+ QTest::newRow("relative local context 1")
+ << QUrl("images/heart200.png")
+ << QUrl()
+ << testFileUrl("/app.qml")
+ << 181.;
+ QTest::newRow("relative local context 2")
+ << QUrl("heart200.png")
+ << QUrl()
+ << testFileUrl("images/app.qml")
+ << 181.;
+ QTest::newRow("relative local base 1")
+ << QUrl("images/heart200.png")
+ << testFileUrl("")
+ << testFileUrl("nonexistant/app.qml")
+ << 181.;
+ QTest::newRow("relative local base 2")
+ << QUrl("heart200.png")
+ << testFileUrl("images/")
+ << testFileUrl("nonexistant/app.qml")
+ << 181.;
+ QTest::newRow("base relative to local context")
+ << QUrl("heart200.png")
+ << testFileUrl("images/")
+ << testFileUrl("/app.qml")
+ << 181.;
+
+ QTest::newRow("absolute remote")
+ << QUrl("http://127.0.0.1:14453/images/heart200.png")
+ << QUrl()
+ << QUrl()
+ << 181.;
+ QTest::newRow("relative remote base 1")
+ << QUrl("images/heart200.png")
+ << QUrl("http://127.0.0.1:14453/")
+ << testFileUrl("nonexistant/app.qml")
+ << 181.;
+ QTest::newRow("relative remote base 2")
+ << QUrl("heart200.png")
+ << QUrl("http://127.0.0.1:14453/images/")
+ << testFileUrl("nonexistant/app.qml")
+ << 181.;
+}
+
+void tst_qquicktext::imgTagsBaseUrl()
+{
+ QFETCH(QUrl, src);
+ QFETCH(QUrl, baseUrl);
+ QFETCH(QUrl, contextUrl);
+ QFETCH(qreal, imgHeight);
+
+ TestHTTPServer server(14453);
+ server.serveDirectory(testFile(""));
+
+ QByteArray baseUrlFragment;
+ if (!baseUrl.isEmpty())
+ baseUrlFragment = "; baseUrl: \"" + baseUrl.toEncoded() + "\"";
+ QByteArray componentStr = "import QtQuick 2.0\nText { text: \"This is a test <img src=\\\"" + src.toEncoded() + "\\\">\"" + baseUrlFragment + " }";
+
+ QQmlComponent component(&engine);
+ component.setData(componentStr, contextUrl);
+ QScopedPointer<QObject> object(component.create());
+ QQuickText *textObject = qobject_cast<QQuickText *>(object.data());
+ QVERIFY(textObject);
+
+ QCoreApplication::processEvents();
+
+ QTRY_COMPARE(textObject->height(), imgHeight);
+}
+
+void tst_qquicktext::imgTagsAlign_data()
+{
+ QTest::addColumn<QString>("src");
+ QTest::addColumn<int>("imgHeight");
+ QTest::addColumn<QString>("align");
+ QTest::newRow("heart-bottom") << "data/images/heart200.png" << 181 << "bottom";
+ QTest::newRow("heart-middle") << "data/images/heart200.png" << 181 << "middle";
+ QTest::newRow("heart-top") << "data/images/heart200.png" << 181 << "top";
+ QTest::newRow("starfish-bottom") << "data/images/starfish_2.png" << 217 << "bottom";
+ QTest::newRow("starfish-middle") << "data/images/starfish_2.png" << 217 << "middle";
+ QTest::newRow("starfish-top") << "data/images/starfish_2.png" << 217 << "top";
+}
+
+void tst_qquicktext::imgTagsAlign()
+{
+ QFETCH(QString, src);
+ QFETCH(int, imgHeight);
+ QFETCH(QString, align);
+ QString componentStr = "import QtQuick 2.0\nText { text: \"This is a test <img src=\\\"" + src + "\\\" align=\\\"" + align + "\\\"> of image.\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->height() == imgHeight);
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
+ QVERIFY(textPrivate != 0);
+
+ QRectF br = textPrivate->layout.boundingRect();
+ if (align == "bottom")
+ QVERIFY(br.y() == imgHeight - br.height());
+ else if (align == "middle")
+ QVERIFY(br.y() == imgHeight / 2.0 - br.height() / 2.0);
+ else if (align == "top")
+ QVERIFY(br.y() == 0);
+
+ delete textObject;
+}
+
+void tst_qquicktext::imgTagsMultipleImages()
+{
+ QString componentStr = "import QtQuick 2.0\nText { text: \"This is a starfish<img src=\\\"data/images/starfish_2.png\\\" width=\\\"60\\\" height=\\\"60\\\" > and another one<img src=\\\"data/images/heart200.png\\\" width=\\\"85\\\" height=\\\"85\\\">.\" }";
+
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->height() == 85);
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(textObject);
+ QVERIFY(textPrivate != 0);
+ QVERIFY(textPrivate->visibleImgTags.count() == 2);
+
+ delete textObject;
+}
+
+void tst_qquicktext::imgTagsElide()
+{
+ QQuickView *canvas = createView(testFile("imgTagsElide.qml"));
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
+ QVERIFY(textPrivate != 0);
+ QVERIFY(textPrivate->visibleImgTags.count() == 0);
+ myText->setMaximumLineCount(20);
+ QTRY_VERIFY(textPrivate->visibleImgTags.count() == 1);
+
+ delete myText;
+ delete canvas;
+}
+
+void tst_qquicktext::imgTagsUpdates()
+{
+ QQuickView *canvas = createView(testFile("imgTagsUpdates.qml"));
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ QSignalSpy spy(myText, SIGNAL(contentSizeChanged()));
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
+ QVERIFY(textPrivate != 0);
+
+ myText->setText("This is a heart<img src=\"images/heart200.png\">.");
+ QVERIFY(textPrivate->visibleImgTags.count() == 1);
+ QVERIFY(spy.count() == 1);
+
+ myText->setMaximumLineCount(2);
+ myText->setText("This is another heart<img src=\"images/heart200.png\">.");
+ QTRY_VERIFY(textPrivate->visibleImgTags.count() == 1);
+
+ // if maximumLineCount is set and the img tag doesn't have an explicit size
+ // we relayout twice.
+ QVERIFY(spy.count() == 3);
+
+ delete myText;
+ delete canvas;
+}
+
+void tst_qquicktext::imgTagsError()
+{
+ QString componentStr = "import QtQuick 2.0\nText { text: \"This is a starfish<img src=\\\"data/images/starfish_2.pn\\\" width=\\\"60\\\" height=\\\"60\\\">.\" }";
+
+ QQmlComponent textComponent(&engine);
+ QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML Text: Cannot open: file:data/images/starfish_2.pn");
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickText *textObject = qobject_cast<QQuickText*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ delete textObject;
+}
+
+void tst_qquicktext::fontSizeMode_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<bool>("canElide");
+ QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << true;
+ QTest::newRow("richtext") << "<b>The quick red fox jumped over the lazy brown dog</b>" << false;
+}
+
+void tst_qquicktext::fontSizeMode()
+{
+ QFETCH(QString, text);
+ QFETCH(bool, canElide);
+
+ QQuickView *canvas = createView(testFile("fontSizeMode.qml"));
+ canvas->show();
+
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ myText->setText(text);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ qreal originalWidth = myText->contentWidth();
+ qreal originalHeight = myText->contentHeight();
+
+ // The original text unwrapped should exceed the width of the item.
+ QVERIFY(originalWidth > myText->width());
+ QVERIFY(originalHeight < myText->height());
+
+ QFont font = myText->font();
+ font.setPixelSize(64);
+
+ myText->setFont(font);
+ myText->setFontSizeMode(QQuickText::HorizontalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Font size reduced to fit within the width of the item.
+ qreal horizontalFitWidth = myText->contentWidth();
+ qreal horizontalFitHeight = myText->contentHeight();
+ QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding
+ QVERIFY(horizontalFitHeight <= myText->height() + 2);
+
+ if (canElide) {
+ // Elide won't affect the size with HorizontalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+
+ myText->setFontSizeMode(QQuickText::VerticalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Font size increased to fill the height of the item.
+ qreal verticalFitHeight = myText->contentHeight();
+ QVERIFY(myText->contentWidth() > myText->width());
+ QVERIFY(verticalFitHeight <= myText->height() + 2);
+ QVERIFY(verticalFitHeight > originalHeight);
+
+ if (canElide) {
+ // Elide won't affect the height of a single line with VerticalFit but will crop the width.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+
+ myText->setFontSizeMode(QQuickText::Fit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Should be the same as HorizontalFit with no wrapping.
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ if (canElide) {
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+
+ myText->setFontSizeMode(QQuickText::FixedSize);
+ myText->setWrapMode(QQuickText::Wrap);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ originalWidth = myText->contentWidth();
+ originalHeight = myText->contentHeight();
+
+ // The original text wrapped should exceed the height of the item.
+ QVERIFY(originalWidth <= myText->width() + 2);
+ QVERIFY(originalHeight > myText->height());
+
+ myText->setFontSizeMode(QQuickText::HorizontalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
+ // same size as without text wrapping.
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ if (canElide) {
+ // Elide won't affect the size with HorizontalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+
+ myText->setFontSizeMode(QQuickText::VerticalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // VerticalFit should reduce the size to the wrapped text within the vertical height.
+ verticalFitHeight = myText->contentHeight();
+ qreal verticalFitWidth = myText->contentWidth();
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(verticalFitHeight <= myText->height() + 2);
+ QVERIFY(verticalFitHeight < originalHeight);
+
+ if (canElide) {
+ // Elide won't affect the height or width of a wrapped text with VerticalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+
+ myText->setFontSizeMode(QQuickText::Fit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Should be the same as VerticalFit with wrapping.
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ if (canElide) {
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+
+ myText->setFontSizeMode(QQuickText::FixedSize);
+ myText->setMaximumLineCount(2);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ // The original text wrapped should exceed the height of the item.
+ QVERIFY(originalWidth <= myText->width() + 2);
+ QVERIFY(originalHeight > myText->height());
+
+ myText->setFontSizeMode(QQuickText::HorizontalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
+ // same size as without text wrapping.
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ if (canElide) {
+ // Elide won't affect the size with HorizontalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+
+ myText->setFontSizeMode(QQuickText::VerticalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // VerticalFit should reduce the size to the wrapped text within the vertical height.
+ verticalFitHeight = myText->contentHeight();
+ verticalFitWidth = myText->contentWidth();
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(verticalFitHeight <= myText->height() + 2);
+ QVERIFY(verticalFitHeight < originalHeight);
+
+ if (canElide) {
+ // Elide won't affect the height or width of a wrapped text with VerticalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+
+ myText->setFontSizeMode(QQuickText::Fit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Should be the same as VerticalFit with wrapping.
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ if (canElide) {
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+}
+
+void tst_qquicktext::fontSizeModeMultiline_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<bool>("canElide");
+ QTest::newRow("plain") << "The quick red fox jumped\n over the lazy brown dog" << true;
+ QTest::newRow("richtext") << "<b>The quick red fox jumped<br/> over the lazy brown dog</b>" << false;
+}
+
+void tst_qquicktext::fontSizeModeMultiline()
+{
+ QFETCH(QString, text);
+ QFETCH(bool, canElide);
+
+ QQuickView *canvas = createView(testFile("fontSizeMode.qml"));
+ canvas->show();
+
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ myText->setText(text);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ qreal originalWidth = myText->contentWidth();
+ qreal originalHeight = myText->contentHeight();
+ QCOMPARE(myText->lineCount(), 2);
+
+ // The original text unwrapped should exceed the width and height of the item.
+ QVERIFY(originalWidth > myText->width());
+ QVERIFY(originalHeight > myText->height());
+
+ QFont font = myText->font();
+ font.setPixelSize(64);
+
+ myText->setFont(font);
+ myText->setFontSizeMode(QQuickText::HorizontalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Font size reduced to fit within the width of the item.
+ QCOMPARE(myText->lineCount(), 2);
+ qreal horizontalFitWidth = myText->contentWidth();
+ qreal horizontalFitHeight = myText->contentHeight();
+ QVERIFY(horizontalFitWidth <= myText->width() + 2); // rounding
+ QVERIFY(horizontalFitHeight > myText->height());
+
+ if (canElide) {
+ // Right eliding will remove the last line
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QCOMPARE(myText->lineCount(), 1);
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(myText->contentHeight() <= myText->height() + 2);
+
+ // Left or middle eliding wont have any effect.
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+
+ myText->setFontSizeMode(QQuickText::VerticalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Font size reduced to fit within the height of the item.
+ qreal verticalFitWidth = myText->contentWidth();
+ qreal verticalFitHeight = myText->contentHeight();
+ QVERIFY(verticalFitWidth <= myText->width() + 2);
+ QVERIFY(verticalFitHeight <= myText->height() + 2);
+
+ if (canElide) {
+ // Elide will have no effect.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+
+ myText->setFontSizeMode(QQuickText::Fit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Should be the same as VerticalFit with no wrapping.
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ if (canElide) {
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideLeft);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideMiddle);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+
+ myText->setFontSizeMode(QQuickText::FixedSize);
+ myText->setWrapMode(QQuickText::Wrap);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ originalWidth = myText->contentWidth();
+ originalHeight = myText->contentHeight();
+
+ // The original text wrapped should exceed the height of the item.
+ QVERIFY(originalWidth <= myText->width() + 2);
+ QVERIFY(originalHeight > myText->height());
+
+ myText->setFontSizeMode(QQuickText::HorizontalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
+ // same size as without text wrapping.
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ if (canElide) {
+ // Text will be elided vertically with HorizontalFit
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(myText->contentHeight() <= myText->height() + 2);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+
+ myText->setFontSizeMode(QQuickText::VerticalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // VerticalFit should reduce the size to the wrapped text within the vertical height.
+ verticalFitHeight = myText->contentHeight();
+ verticalFitWidth = myText->contentWidth();
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(verticalFitHeight <= myText->height() + 2);
+ QVERIFY(verticalFitHeight < originalHeight);
+
+ if (canElide) {
+ // Elide won't affect the height or width of a wrapped text with VerticalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+
+ myText->setFontSizeMode(QQuickText::Fit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Should be the same as VerticalFit with wrapping.
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ if (canElide) {
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+
+ myText->setFontSizeMode(QQuickText::FixedSize);
+ myText->setMaximumLineCount(2);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ // The original text wrapped should exceed the height of the item.
+ QVERIFY(originalWidth <= myText->width() + 2);
+ QVERIFY(originalHeight > myText->height());
+
+ myText->setFontSizeMode(QQuickText::HorizontalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the
+ // same size as without text wrapping.
+ QCOMPARE(myText->contentWidth(), horizontalFitWidth);
+ QCOMPARE(myText->contentHeight(), horizontalFitHeight);
+
+ if (canElide) {
+ // Elide won't affect the size with HorizontalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(myText->truncated());
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(myText->contentHeight() <= myText->height() + 2);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+
+ myText->setFontSizeMode(QQuickText::VerticalFit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // VerticalFit should reduce the size to the wrapped text within the vertical height.
+ verticalFitHeight = myText->contentHeight();
+ verticalFitWidth = myText->contentWidth();
+ QVERIFY(myText->contentWidth() <= myText->width() + 2);
+ QVERIFY(verticalFitHeight <= myText->height() + 2);
+ QVERIFY(verticalFitHeight < originalHeight);
+
+ if (canElide) {
+ // Elide won't affect the height or width of a wrapped text with VerticalFit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+
+ myText->setFontSizeMode(QQuickText::Fit);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ // Should be the same as VerticalFit with wrapping.
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ if (canElide) {
+ // Elide won't affect the size with Fit.
+ myText->setElideMode(QQuickText::ElideRight);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ QVERIFY(!myText->truncated());
+ QCOMPARE(myText->contentWidth(), verticalFitWidth);
+ QCOMPARE(myText->contentHeight(), verticalFitHeight);
+
+ myText->setElideMode(QQuickText::ElideNone);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ }
+}
+
+void tst_qquicktext::multilengthStrings_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::newRow("No Wrap") << testFile("multilengthStrings.qml");
+ QTest::newRow("Wrap") << testFile("multilengthStringsWrapped.qml");
+}
+
+void tst_qquicktext::multilengthStrings()
+{
+ QFETCH(QString, source);
+
+ QScopedPointer<QQuickView> canvas(createView(source));
+ canvas->show();
+
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ const QString longText = "the quick brown fox jumped over the lazy dog";
+ const QString mediumText = "the brown fox jumped over the dog";
+ const QString shortText = "fox jumped dog";
+
+ myText->setText(longText);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ const qreal longWidth = myText->contentWidth();
+ const qreal longHeight = myText->contentHeight();
+
+ myText->setText(mediumText);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ const qreal mediumWidth = myText->contentWidth();
+ const qreal mediumHeight = myText->contentHeight();
+
+ myText->setText(shortText);
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+ const qreal shortWidth = myText->contentWidth();
+ const qreal shortHeight = myText->contentHeight();
+
+ myText->setElideMode(QQuickText::ElideRight);
+ myText->setText(longText + QLatin1Char('\x9c') + mediumText + QLatin1Char('\x9c') + shortText);
+
+ myText->setSize(QSizeF(longWidth, longHeight));
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ QCOMPARE(myText->contentWidth(), longWidth);
+ QCOMPARE(myText->contentHeight(), longHeight);
+ QCOMPARE(myText->truncated(), false);
+
+ myText->setSize(QSizeF(mediumWidth, mediumHeight));
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ QCOMPARE(myText->contentWidth(), mediumWidth);
+ QCOMPARE(myText->contentHeight(), mediumHeight);
+#ifdef Q_OS_MAC
+ QEXPECT_FAIL("Wrap", "QTBUG-24310", Continue);
+#endif
+ QCOMPARE(myText->truncated(), true);
+
+ myText->setSize(QSizeF(shortWidth, shortHeight));
+ QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false);
+
+ QCOMPARE(myText->contentWidth(), shortWidth);
+ QCOMPARE(myText->contentHeight(), shortHeight);
+ QCOMPARE(myText->truncated(), true);
+}
+
+QTEST_MAIN(tst_qquicktext)
+
+#include "tst_qquicktext.moc"
diff --git a/tests/auto/qtquick2/qquicktextedit/data/Cursor.qml b/tests/auto/quick/qquicktextedit/data/Cursor.qml
index e5c1853fc5..e5c1853fc5 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/Cursor.qml
+++ b/tests/auto/quick/qquicktextedit/data/Cursor.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/CursorRect.qml b/tests/auto/quick/qquicktextedit/data/CursorRect.qml
index cae3e63b72..cae3e63b72 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/CursorRect.qml
+++ b/tests/auto/quick/qquicktextedit/data/CursorRect.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments.qml b/tests/auto/quick/qquicktextedit/data/alignments.qml
index 7d365da8cb..7d365da8cb 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments.qml
+++ b/tests/auto/quick/qquicktextedit/data/alignments.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_cb.png b/tests/auto/quick/qquicktextedit/data/alignments_cb.png
index 99de2192de..99de2192de 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_cb.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_cb.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_cc.png b/tests/auto/quick/qquicktextedit/data/alignments_cc.png
index cb85251180..cb85251180 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_cc.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_cc.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_ct.png b/tests/auto/quick/qquicktextedit/data/alignments_ct.png
index ddca549c82..ddca549c82 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_ct.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_ct.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_lb.png b/tests/auto/quick/qquicktextedit/data/alignments_lb.png
index 1b50a81f3d..1b50a81f3d 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_lb.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_lb.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_lc.png b/tests/auto/quick/qquicktextedit/data/alignments_lc.png
index f041b868f8..f041b868f8 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_lc.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_lc.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_lt.png b/tests/auto/quick/qquicktextedit/data/alignments_lt.png
index c75e0d158e..c75e0d158e 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_lt.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_lt.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_rb.png b/tests/auto/quick/qquicktextedit/data/alignments_rb.png
index b06a5da715..b06a5da715 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_rb.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_rb.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_rc.png b/tests/auto/quick/qquicktextedit/data/alignments_rc.png
index e468857cd0..e468857cd0 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_rc.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_rc.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/alignments_rt.png b/tests/auto/quick/qquicktextedit/data/alignments_rt.png
index 576715ffce..576715ffce 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/alignments_rt.png
+++ b/tests/auto/quick/qquicktextedit/data/alignments_rt.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/cursorTest.qml b/tests/auto/quick/qquicktextedit/data/cursorTest.qml
index 7bfc869403..7bfc869403 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/cursorTest.qml
+++ b/tests/auto/quick/qquicktextedit/data/cursorTest.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/cursorTestExternal.qml b/tests/auto/quick/qquicktextedit/data/cursorTestExternal.qml
index 7e916ec818..7e916ec818 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/cursorTestExternal.qml
+++ b/tests/auto/quick/qquicktextedit/data/cursorTestExternal.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/cursorTestInline.qml b/tests/auto/quick/qquicktextedit/data/cursorTestInline.qml
index 786f39113c..786f39113c 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/cursorTestInline.qml
+++ b/tests/auto/quick/qquicktextedit/data/cursorTestInline.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/cursorVisible.qml b/tests/auto/quick/qquicktextedit/data/cursorVisible.qml
index 49e9386947..49e9386947 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/cursorVisible.qml
+++ b/tests/auto/quick/qquicktextedit/data/cursorVisible.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocal.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocal.qml
index 150f7bd898..150f7bd898 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocal.qml
+++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocal.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalError.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocalError.qml
index 067b6d72da..067b6d72da 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalError.qml
+++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocalError.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalRelative.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocalRelative.qml
index 200ded196d..200ded196d 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesLocalRelative.qml
+++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesLocalRelative.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemote.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemote.qml
index a823882692..a823882692 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemote.qml
+++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemote.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteError.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteError.qml
index c6172b68dc..c6172b68dc 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteError.qml
+++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteError.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteRelative.qml b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteRelative.qml
index ee39e089ea..ee39e089ea 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/embeddedImagesRemoteRelative.qml
+++ b/tests/auto/quick/qquicktextedit/data/embeddedImagesRemoteRelative.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/geometrySignals.qml b/tests/auto/quick/qquicktextedit/data/geometrySignals.qml
index 3dbe61c74b..3dbe61c74b 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/geometrySignals.qml
+++ b/tests/auto/quick/qquicktextedit/data/geometrySignals.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/horizontalAlignment_RightToLeft.qml b/tests/auto/quick/qquicktextedit/data/horizontalAlignment_RightToLeft.qml
index 2163838488..2163838488 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/horizontalAlignment_RightToLeft.qml
+++ b/tests/auto/quick/qquicktextedit/data/horizontalAlignment_RightToLeft.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/ErrItem.qml b/tests/auto/quick/qquicktextedit/data/http/ErrItem.qml
index 68c0e0c093..68c0e0c093 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/http/ErrItem.qml
+++ b/tests/auto/quick/qquicktextedit/data/http/ErrItem.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/NormItem.qml b/tests/auto/quick/qquicktextedit/data/http/NormItem.qml
index 2e4c1ed440..2e4c1ed440 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/http/NormItem.qml
+++ b/tests/auto/quick/qquicktextedit/data/http/NormItem.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTest.qml b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTest.qml
index be4526e22b..be4526e22b 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTest.qml
+++ b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTest.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail1.qml b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail1.qml
index 1d7763f913..1d7763f913 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail1.qml
+++ b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail1.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail2.qml b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail2.qml
index c82ec02e68..c82ec02e68 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestFail2.qml
+++ b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestFail2.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestPass.qml b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestPass.qml
index 96d582c95d..96d582c95d 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/http/cursorHttpTestPass.qml
+++ b/tests/auto/quick/qquicktextedit/data/http/cursorHttpTestPass.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/exists.png b/tests/auto/quick/qquicktextedit/data/http/exists.png
index 399bd0b1d9..399bd0b1d9 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/http/exists.png
+++ b/tests/auto/quick/qquicktextedit/data/http/exists.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextedit/data/http/qmldir b/tests/auto/quick/qquicktextedit/data/http/qmldir
index 886e6ffec0..886e6ffec0 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/http/qmldir
+++ b/tests/auto/quick/qquicktextedit/data/http/qmldir
diff --git a/tests/auto/qtquick2/qquicktextedit/data/httpfail/FailItem.qml b/tests/auto/quick/qquicktextedit/data/httpfail/FailItem.qml
index 8161843479..8161843479 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/httpfail/FailItem.qml
+++ b/tests/auto/quick/qquicktextedit/data/httpfail/FailItem.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/httpslow/WaitItem.qml b/tests/auto/quick/qquicktextedit/data/httpslow/WaitItem.qml
index 8161843479..8161843479 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/httpslow/WaitItem.qml
+++ b/tests/auto/quick/qquicktextedit/data/httpslow/WaitItem.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/inputContext.qml b/tests/auto/quick/qquicktextedit/data/inputContext.qml
index a37c77e3bf..a37c77e3bf 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/inputContext.qml
+++ b/tests/auto/quick/qquicktextedit/data/inputContext.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/inputMethodEvent.qml b/tests/auto/quick/qquicktextedit/data/inputMethodEvent.qml
index e3f629ce3e..e3f629ce3e 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/inputMethodEvent.qml
+++ b/tests/auto/quick/qquicktextedit/data/inputMethodEvent.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/inputmethodhints.qml b/tests/auto/quick/qquicktextedit/data/inputmethodhints.qml
index dec3b978e7..dec3b978e7 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/inputmethodhints.qml
+++ b/tests/auto/quick/qquicktextedit/data/inputmethodhints.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/linkActivated.qml b/tests/auto/quick/qquicktextedit/data/linkActivated.qml
index d3bba82b59..d3bba82b59 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/linkActivated.qml
+++ b/tests/auto/quick/qquicktextedit/data/linkActivated.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_default.qml b/tests/auto/quick/qquicktextedit/data/mouseselection_default.qml
index ac32f4ced7..ac32f4ced7 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_default.qml
+++ b/tests/auto/quick/qquicktextedit/data/mouseselection_default.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_false.qml b/tests/auto/quick/qquicktextedit/data/mouseselection_false.qml
index ac32f4ced7..ac32f4ced7 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_false.qml
+++ b/tests/auto/quick/qquicktextedit/data/mouseselection_false.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_false_words.qml b/tests/auto/quick/qquicktextedit/data/mouseselection_false_words.qml
index 86aea46a85..86aea46a85 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_false_words.qml
+++ b/tests/auto/quick/qquicktextedit/data/mouseselection_false_words.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_true.qml b/tests/auto/quick/qquicktextedit/data/mouseselection_true.qml
index 7c7cb0b6fc..7c7cb0b6fc 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_true.qml
+++ b/tests/auto/quick/qquicktextedit/data/mouseselection_true.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_true_words.qml b/tests/auto/quick/qquicktextedit/data/mouseselection_true_words.qml
index c356999220..c356999220 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/mouseselection_true_words.qml
+++ b/tests/auto/quick/qquicktextedit/data/mouseselection_true_words.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_characters.qml b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_characters.qml
index c1fe42fd57..c1fe42fd57 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_characters.qml
+++ b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_characters.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_default.qml b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_default.qml
index 7c7cb0b6fc..7c7cb0b6fc 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_default.qml
+++ b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_default.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_words.qml b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_words.qml
index 0a372bbf83..0a372bbf83 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/mouseselectionmode_words.qml
+++ b/tests/auto/quick/qquicktextedit/data/mouseselectionmode_words.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/navigation.qml b/tests/auto/quick/qquicktextedit/data/navigation.qml
index 0201c62b3c..0201c62b3c 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/navigation.qml
+++ b/tests/auto/quick/qquicktextedit/data/navigation.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/openInputPanel.qml b/tests/auto/quick/qquicktextedit/data/openInputPanel.qml
index d3aecf21be..d3aecf21be 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/openInputPanel.qml
+++ b/tests/auto/quick/qquicktextedit/data/openInputPanel.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/persistentSelection.qml b/tests/auto/quick/qquicktextedit/data/persistentSelection.qml
index fb2fe0cd6c..fb2fe0cd6c 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/persistentSelection.qml
+++ b/tests/auto/quick/qquicktextedit/data/persistentSelection.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/positionAt.qml b/tests/auto/quick/qquicktextedit/data/positionAt.qml
index 19093281fe..19093281fe 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/positionAt.qml
+++ b/tests/auto/quick/qquicktextedit/data/positionAt.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/qtbug-22058.qml b/tests/auto/quick/qquicktextedit/data/qtbug-22058.qml
index 8ad1514fbf..8ad1514fbf 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/qtbug-22058.qml
+++ b/tests/auto/quick/qquicktextedit/data/qtbug-22058.qml
diff --git a/tests/auto/qtquick2/qquicktextedit/data/readOnly.qml b/tests/auto/quick/qquicktextedit/data/readOnly.qml
index 085adba5fb..085adba5fb 100644
--- a/tests/auto/qtquick2/qquicktextedit/data/readOnly.qml
+++ b/tests/auto/quick/qquicktextedit/data/readOnly.qml
diff --git a/tests/auto/quick/qquicktextedit/qquicktextedit.pro b/tests/auto/quick/qquicktextedit/qquicktextedit.pro
new file mode 100644
index 0000000000..39a5178c7d
--- /dev/null
+++ b/tests/auto/quick/qquicktextedit/qquicktextedit.pro
@@ -0,0 +1,16 @@
+CONFIG += testcase
+TARGET = tst_qquicktextedit
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicktextedit.cpp \
+ ../../shared/testhttpserver.cpp
+
+HEADERS += ../../shared/testhttpserver.h
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+QT += core-private gui-private v8-private qml-private quick-private opengl-private network widgets-private testlib
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
new file mode 100644
index 0000000000..314a523602
--- /dev/null
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -0,0 +1,3884 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include "../../shared/testhttpserver.h"
+#include <math.h>
+#include <QFile>
+#include <QTextDocument>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtGui/qguiapplication.h>
+#include <private/qquicktextedit_p.h>
+#include <private/qquicktextedit_p_p.h>
+#include <private/qquicktext_p_p.h>
+#include <QFontMetrics>
+#include <QtQuick/QQuickView>
+#include <QDir>
+#include <QStyle>
+#include <QInputMethod>
+#include <QClipboard>
+#include <QMimeData>
+#include <private/qquicktextcontrol_p.h>
+#include "../../shared/util.h"
+#include "../../shared/platforminputcontext.h"
+#include <private/qinputmethod_p.h>
+
+#ifdef Q_OS_MAC
+#include <Carbon/Carbon.h>
+#endif
+
+
+Q_DECLARE_METATYPE(QQuickTextEdit::SelectionMode)
+DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
+
+QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual)
+{
+ // XXX This will be replaced by some clever persistent platform image store.
+ QString persistent_dir = QQmlDataTest::instance()->dataDirectory();
+ QString arch = "unknown-architecture"; // QTest needs to help with this.
+
+ QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png";
+
+ if (!QFile::exists(expectfile)) {
+ actual.save(expectfile);
+ qWarning() << "created" << expectfile;
+ }
+
+ return expectfile;
+}
+
+typedef QPair<int, QChar> Key;
+
+class tst_qquicktextedit : public QQmlDataTest
+
+{
+ Q_OBJECT
+public:
+ tst_qquicktextedit();
+
+private slots:
+ void cleanup();
+ void text();
+ void width();
+ void wrap();
+ void textFormat();
+ void alignments();
+ void alignments_data();
+
+ // ### these tests may be trivial
+ void hAlign();
+ void hAlign_RightToLeft();
+ void vAlign();
+ void font();
+ void color();
+ void textMargin();
+ void persistentSelection();
+ void focusOnPress();
+ void selection();
+ void isRightToLeft_data();
+ void isRightToLeft();
+ void keySelection();
+ void moveCursorSelection_data();
+ void moveCursorSelection();
+ void moveCursorSelectionSequence_data();
+ void moveCursorSelectionSequence();
+ void mouseSelection_data();
+ void mouseSelection();
+ void mouseSelectionMode_data();
+ void mouseSelectionMode();
+ void dragMouseSelection();
+ void inputMethodHints();
+
+ void positionAt();
+
+ void linkActivated();
+
+ void cursorDelegate_data();
+ void cursorDelegate();
+ void cursorVisible();
+ void delegateLoading_data();
+ void delegateLoading();
+ void navigation();
+ void readOnly();
+ void copyAndPaste();
+ void canPaste();
+ void canPasteEmpty();
+ void textInput();
+ void inputMethodUpdate();
+ void openInputPanel();
+ void geometrySignals();
+ void pastingRichText_QTBUG_14003();
+ void implicitSize_data();
+ void implicitSize();
+ void contentSize();
+
+ void preeditCursorRectangle();
+ void inputMethodComposing();
+ void cursorRectangleSize();
+
+ void getText_data();
+ void getText();
+ void getFormattedText_data();
+ void getFormattedText();
+ void insert_data();
+ void insert();
+ void remove_data();
+ void remove();
+
+ void keySequence_data();
+ void keySequence();
+
+ void undo_data();
+ void undo();
+ void redo_data();
+ void redo();
+ void undo_keypressevents_data();
+ void undo_keypressevents();
+
+ void baseUrl();
+ void embeddedImages();
+ void embeddedImages_data();
+
+ void emptytags_QTBUG_22058();
+
+private:
+ void simulateKeys(QWindow *window, const QList<Key> &keys);
+ void simulateKeys(QWindow *window, const QKeySequence &sequence);
+
+ void simulateKey(QQuickView *, int key, Qt::KeyboardModifiers modifiers = 0);
+
+ QStringList standard;
+ QStringList richText;
+
+ QStringList hAlignmentStrings;
+ QStringList vAlignmentStrings;
+
+ QList<Qt::Alignment> vAlignments;
+ QList<Qt::Alignment> hAlignments;
+
+ QStringList colorStrings;
+
+ QQmlEngine engine;
+};
+
+typedef QList<int> IntList;
+Q_DECLARE_METATYPE(IntList)
+
+typedef QList<Key> KeyList;
+Q_DECLARE_METATYPE(KeyList)
+
+Q_DECLARE_METATYPE(QQuickTextEdit::TextFormat)
+
+void tst_qquicktextedit::simulateKeys(QWindow *window, const QList<Key> &keys)
+{
+ for (int i = 0; i < keys.count(); ++i) {
+ const int key = keys.at(i).first;
+ const int modifiers = key & Qt::KeyboardModifierMask;
+ const QString text = !keys.at(i).second.isNull() ? QString(keys.at(i).second) : QString();
+
+ QKeyEvent press(QEvent::KeyPress, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text);
+ QKeyEvent release(QEvent::KeyRelease, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text);
+
+ QGuiApplication::sendEvent(window, &press);
+ QGuiApplication::sendEvent(window, &release);
+ }
+}
+
+void tst_qquicktextedit::simulateKeys(QWindow *window, const QKeySequence &sequence)
+{
+ for (int i = 0; i < sequence.count(); ++i) {
+ const int key = sequence[i];
+ const int modifiers = key & Qt::KeyboardModifierMask;
+
+ QTest::keyClick(window, Qt::Key(key & ~modifiers), Qt::KeyboardModifiers(modifiers));
+ }
+}
+
+QList<Key> &operator <<(QList<Key> &keys, const QKeySequence &sequence)
+{
+ for (int i = 0; i < sequence.count(); ++i)
+ keys << Key(sequence[i], QChar());
+ return keys;
+}
+
+template <int N> QList<Key> &operator <<(QList<Key> &keys, const char (&characters)[N])
+{
+ for (int i = 0; i < N - 1; ++i) {
+ int key = QTest::asciiToKey(characters[i]);
+ QChar character = QLatin1Char(characters[i]);
+ keys << Key(key, character);
+ }
+ return keys;
+}
+
+QList<Key> &operator <<(QList<Key> &keys, Qt::Key key)
+{
+ keys << Key(key, QChar());
+ return keys;
+}
+
+tst_qquicktextedit::tst_qquicktextedit()
+{
+ standard << "the quick brown fox jumped over the lazy dog"
+ << "the quick brown fox\n jumped over the lazy dog"
+ << "Hello, world!"
+ << "!dlrow ,olleH";
+
+ richText << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a> jumped over the <b>lazy</b> dog</i>"
+ << "<i>the <b>quick</b> brown <a href=\\\"http://www.google.com\\\">fox</a><br>jumped over the <b>lazy</b> dog</i>";
+
+ hAlignmentStrings << "AlignLeft"
+ << "AlignRight"
+ << "AlignHCenter";
+
+ vAlignmentStrings << "AlignTop"
+ << "AlignBottom"
+ << "AlignVCenter";
+
+ hAlignments << Qt::AlignLeft
+ << Qt::AlignRight
+ << Qt::AlignHCenter;
+
+ vAlignments << Qt::AlignTop
+ << Qt::AlignBottom
+ << Qt::AlignVCenter;
+
+ colorStrings << "aliceblue"
+ << "antiquewhite"
+ << "aqua"
+ << "darkkhaki"
+ << "darkolivegreen"
+ << "dimgray"
+ << "palevioletred"
+ << "lightsteelblue"
+ << "#000000"
+ << "#AAAAAA"
+ << "#FFFFFF"
+ << "#2AC05F";
+ //
+ // need a different test to do alpha channel test
+ // << "#AA0011DD"
+ // << "#00F16B11";
+ //
+}
+
+void tst_qquicktextedit::cleanup()
+{
+ // ensure not even skipped tests with custom input context leave it dangling
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = 0;
+}
+
+void tst_qquicktextedit::text()
+{
+ {
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\" }", QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->text(), QString(""));
+ QCOMPARE(textEditObject->length(), 0);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + standard.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->text(), standard.at(i));
+ QCOMPARE(textEditObject->length(), standard.at(i).length());
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + richText.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+
+ QString expected = richText.at(i);
+ expected.replace(QRegExp("\\\\(.)"),"\\1");
+ QCOMPARE(textEditObject->text(), expected);
+ QCOMPARE(textEditObject->length(), expected.length());
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+
+ QString actual = textEditObject->text();
+ QString expected = standard.at(i);
+ actual.remove(QRegExp(".*<body[^>]*>"));
+ actual.remove(QRegExp("(<[^>]*>)+"));
+ expected.remove("\n");
+ QCOMPARE(actual.simplified(), expected);
+ QCOMPARE(textEditObject->length(), expected.length());
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QString actual = textEditObject->text();
+ QString expected = richText.at(i);
+ actual.replace(QRegExp(".*<body[^>]*>"),"");
+ actual.replace(QRegExp("(<[^>]*>)+"),"<>");
+ expected.replace(QRegExp("(<[^>]*>)+"),"<>");
+ QCOMPARE(actual.simplified(),expected.simplified());
+
+ expected.replace("<>", " ");
+ QCOMPARE(textEditObject->length(), expected.simplified().length());
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->text(), standard.at(i));
+ QCOMPARE(textEditObject->length(), standard.at(i).length());
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QString actual = textEditObject->text();
+ QString expected = richText.at(i);
+ actual.replace(QRegExp(".*<body[^>]*>"),"");
+ actual.replace(QRegExp("(<[^>]*>)+"),"<>");
+ expected.replace(QRegExp("(<[^>]*>)+"),"<>");
+ QCOMPARE(actual.simplified(),expected.simplified());
+
+ expected.replace("<>", " ");
+ QCOMPARE(textEditObject->length(), expected.simplified().length());
+ }
+}
+
+void tst_qquicktextedit::width()
+{
+ // uses Font metrics to find the width for standard and document to find the width for rich
+ {
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\" }", QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), 0.0);
+ }
+
+ bool requiresUnhintedMetrics = !qmlDisableDistanceField();
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + standard.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QString s = standard.at(i);
+ s.replace(QLatin1Char('\n'), QChar::LineSeparator);
+
+ QTextLayout layout(s);
+ layout.setFont(textEditObject->font());
+ layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic);
+ if (requiresUnhintedMetrics) {
+ QTextOption option;
+ option.setUseDesignMetrics(true);
+ layout.setTextOption(option);
+ }
+
+ layout.beginLayout();
+ forever {
+ QTextLine line = layout.createLine();
+ if (!line.isValid())
+ break;
+ }
+
+ layout.endLayout();
+
+ qreal metricWidth = ceil(layout.boundingRect().width());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), qreal(metricWidth));
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QTextDocument document;
+ document.setHtml(richText.at(i));
+ document.setDocumentMargin(0);
+ if (requiresUnhintedMetrics)
+ document.setUseDesignMetrics(true);
+
+ int documentWidth = ceil(document.idealWidth());
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.RichText; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), qreal(documentWidth));
+ }
+}
+
+void tst_qquicktextedit::wrap()
+{
+ // for specified width and wrap set true
+ {
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData("import QtQuick 2.0\nTextEdit { text: \"\"; wrapMode: TextEdit.WordWrap; width: 300 }", QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), 300.);
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), 300.);
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->width(), 300.);
+ }
+
+}
+
+void tst_qquicktextedit::textFormat()
+{
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nTextEdit { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile(""));
+ QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QQuickTextEdit::RichText);
+ }
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nTextEdit { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl::fromLocalFile(""));
+ QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->textFormat() == QQuickTextEdit::PlainText);
+ }
+}
+
+void tst_qquicktextedit::alignments_data()
+{
+ QTest::addColumn<int>("hAlign");
+ QTest::addColumn<int>("vAlign");
+ QTest::addColumn<QString>("expectfile");
+
+ QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << "alignments_lt";
+ QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << "alignments_rt";
+ QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << "alignments_ct";
+
+ QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << "alignments_lb";
+ QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << "alignments_rb";
+ QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << "alignments_cb";
+
+ QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << "alignments_lc";
+ QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << "alignments_rc";
+ QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << "alignments_cc";
+}
+
+
+void tst_qquicktextedit::alignments()
+{
+ QSKIP("Image comparison of text is almost guaranteed to fail during development");
+
+ QFETCH(int, hAlign);
+ QFETCH(int, vAlign);
+ QFETCH(QString, expectfile);
+
+ QQuickView canvas(testFileUrl("alignments.qml"));
+
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QObject *ob = canvas.rootObject();
+ QVERIFY(ob != 0);
+ ob->setProperty("horizontalAlignment",hAlign);
+ ob->setProperty("verticalAlignment",vAlign);
+ QTRY_COMPARE(ob->property("running").toBool(),false);
+ QImage actual = canvas.grabFrameBuffer();
+
+ expectfile = createExpectedFileIfNotFound(expectfile, actual);
+
+ QImage expect(expectfile);
+
+ QCOMPARE(actual,expect);
+}
+
+
+//the alignment tests may be trivial o.oa
+void tst_qquicktextedit::hAlign()
+{
+ //test one align each, and then test if two align fails.
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ for (int j=0; j < hAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < hAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j));
+ }
+ }
+
+}
+
+void tst_qquicktextedit::hAlign_RightToLeft()
+{
+ PlatformInputContext platformInputContext;
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &platformInputContext;
+
+ QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml"));
+ QQuickTextEdit *textEdit = canvas.rootObject()->findChild<QQuickTextEdit*>("text");
+ QVERIFY(textEdit != 0);
+ canvas.show();
+
+ const QString rtlText = textEdit->text();
+
+ // implicit alignment should follow the reading direction of text
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ // explicitly left aligned
+ textEdit->setHAlign(QQuickTextEdit::AlignLeft);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
+ QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
+
+ // explicitly right aligned
+ textEdit->setHAlign(QQuickTextEdit::AlignRight);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ QString textString = textEdit->text();
+ textEdit->setText(QString("<i>") + textString + QString("</i>"));
+ textEdit->resetHAlign();
+
+ // implicitly aligned rich text should follow the reading direction of RTL text
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign());
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ // explicitly left aligned rich text
+ textEdit->setHAlign(QQuickTextEdit::AlignLeft);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
+ QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign());
+ QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
+
+ // explicitly right aligned rich text
+ textEdit->setHAlign(QQuickTextEdit::AlignRight);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign());
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ textEdit->setText(textString);
+
+ // explicitly center aligned
+ textEdit->setHAlign(QQuickTextEdit::AlignHCenter);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignHCenter);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ // reseted alignment should go back to following the text reading direction
+ textEdit->resetHAlign();
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ // mirror the text item
+ QQuickItemPrivate::get(textEdit)->setLayoutMirror(true);
+
+ // mirrored implicit alignment should continue to follow the reading direction of the text
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ // mirrored explicitly right aligned behaves as left aligned
+ textEdit->setHAlign(QQuickTextEdit::AlignRight);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignLeft);
+ QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
+
+ // mirrored explicitly left aligned behaves as right aligned
+ textEdit->setHAlign(QQuickTextEdit::AlignLeft);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
+ QCOMPARE(textEdit->effectiveHAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ // disable mirroring
+ QQuickItemPrivate::get(textEdit)->setLayoutMirror(false);
+ textEdit->resetHAlign();
+
+ // English text should be implicitly left aligned
+ textEdit->setText("Hello world!");
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
+ QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
+
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ textEdit->setText(QString());
+ { QInputMethodEvent ev(rtlText, QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ { QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
+
+ // Clear pre-edit text. TextEdit should maybe do this itself on setText, but that may be
+ // redundant as an actual input method may take care of it.
+ { QInputMethodEvent ev; QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
+
+ // empty text with implicit alignment follows the system locale-based
+ // keyboard input direction from qApp->inputMethod()->inputDirection
+ textEdit->setText("");
+ platformInputContext.setInputDirection(Qt::LeftToRight);
+ QVERIFY(qApp->inputMethod()->inputDirection() == Qt::LeftToRight);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignLeft);
+ QVERIFY(textEdit->positionToRectangle(0).x() < canvas.width()/2);
+
+ QSignalSpy cursorRectangleSpy(textEdit, SIGNAL(cursorRectangleChanged()));
+
+ platformInputContext.setInputDirection(Qt::RightToLeft);
+ QCOMPARE(cursorRectangleSpy.count(), 1);
+ QVERIFY(qApp->inputMethod()->inputDirection() == Qt::RightToLeft);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+
+ // set input direction while having content
+ platformInputContext.setInputDirection(Qt::LeftToRight);
+ textEdit->setText("a");
+ textEdit->setCursorPosition(1);
+ platformInputContext.setInputDirection(Qt::RightToLeft);
+ QTest::keyClick(&canvas, Qt::Key_Backspace);
+ QVERIFY(textEdit->text().isEmpty());
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->cursorRectangle().left() > canvas.width()/2);
+
+ // input direction changed while not having focus
+ platformInputContext.setInputDirection(Qt::LeftToRight);
+ textEdit->setFocus(false);
+ platformInputContext.setInputDirection(Qt::RightToLeft);
+ textEdit->setFocus(true);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->cursorRectangle().left() > canvas.width()/2);
+
+ textEdit->setHAlign(QQuickTextEdit::AlignRight);
+ QCOMPARE(textEdit->hAlign(), QQuickTextEdit::AlignRight);
+ QVERIFY(textEdit->positionToRectangle(0).x() > canvas.width()/2);
+}
+
+void tst_qquicktextedit::vAlign()
+{
+ //test one align each, and then test if two align fails.
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ for (int j=0; j < vAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
+ }
+ }
+
+ for (int i = 0; i < richText.size(); i++)
+ {
+ for (int j=0; j < vAlignmentStrings.size(); j++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j));
+ }
+ }
+
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(
+ "import QtQuick 2.0\n"
+ "TextEdit { width: 100; height: 100; text: \"Hello World\" }", QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+
+ QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignTop);
+ QVERIFY(textEditObject->cursorRectangle().bottom() < 50);
+ QVERIFY(textEditObject->positionToRectangle(0).bottom() < 50);
+
+ // bottom aligned
+ textEditObject->setVAlign(QQuickTextEdit::AlignBottom);
+ QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignBottom);
+ QVERIFY(textEditObject->cursorRectangle().top() > 50);
+ QVERIFY(textEditObject->positionToRectangle(0).top() > 50);
+
+ // explicitly center aligned
+ textEditObject->setVAlign(QQuickTextEdit::AlignVCenter);
+ QCOMPARE(textEditObject->vAlign(), QQuickTextEdit::AlignVCenter);
+ QVERIFY(textEditObject->cursorRectangle().top() < 50);
+ QVERIFY(textEditObject->cursorRectangle().bottom() > 50);
+ QVERIFY(textEditObject->positionToRectangle(0).top() < 50);
+ QVERIFY(textEditObject->positionToRectangle(0).bottom() > 50);
+}
+
+void tst_qquicktextedit::font()
+{
+ //test size, then bold, then italic, then family
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { font.pointSize: 40; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().pointSize(), 40);
+ QCOMPARE(textEditObject->font().bold(), false);
+ QCOMPARE(textEditObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { font.bold: true; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().bold(), true);
+ QCOMPARE(textEditObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { font.italic: true; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().italic(), true);
+ QCOMPARE(textEditObject->font().bold(), false);
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textEditObject->font().bold(), false);
+ QCOMPARE(textEditObject->font().italic(), false);
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { font.family: \"\"; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->font().family(), QString(""));
+ }
+}
+
+void tst_qquicktextedit::color()
+{
+ //test initial color
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QQuickTextEditPrivate *textEditPrivate = static_cast<QQuickTextEditPrivate*>(QQuickItemPrivate::get(textEditObject));
+
+ QVERIFY(textEditObject);
+ QVERIFY(textEditPrivate);
+ QVERIFY(textEditPrivate->control);
+
+ QPalette pal = textEditPrivate->control->palette();
+ QCOMPARE(textEditPrivate->color, QColor("black"));
+ QCOMPARE(textEditPrivate->color, pal.color(QPalette::Text));
+ }
+ //test normal
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+ //qDebug() << "textEditObject: " << textEditObject->color() << "vs. " << QColor(colorStrings.at(i));
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->color(), QColor(colorStrings.at(i)));
+ }
+
+ //test selection
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->selectionColor(), QColor(colorStrings.at(i)));
+ }
+
+ //test selected text
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->selectedTextColor(), QColor(colorStrings.at(i)));
+ }
+
+ {
+ QString colorStr = "#AA001234";
+ QColor testColor("#001234");
+ testColor.setAlpha(170);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->color(), testColor);
+ }
+}
+
+void tst_qquicktextedit::textMargin()
+{
+ for (qreal i=0; i<=10; i+=0.3) {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { textMargin: " + QString::number(i) + "; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->textMargin(), i);
+ }
+}
+
+void tst_qquicktextedit::persistentSelection()
+{
+ QQuickView canvas(testFileUrl("persistentSelection.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+ canvas.requestActivateWindow();
+
+ QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
+ QVERIFY(edit);
+ QVERIFY(edit->hasActiveFocus());
+
+ QSignalSpy spy(edit, SIGNAL(persistentSelectionChanged(bool)));
+
+ QCOMPARE(edit->persistentSelection(), false);
+
+ edit->setPersistentSelection(false);
+ QCOMPARE(edit->persistentSelection(), false);
+ QCOMPARE(spy.count(), 0);
+
+ edit->select(1, 4);
+ QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
+
+ edit->setFocus(false);
+ QCOMPARE(edit->property("selected").toString(), QString());
+
+ edit->setFocus(true);
+ QCOMPARE(edit->property("selected").toString(), QString());
+
+ edit->setPersistentSelection(true);
+ QCOMPARE(edit->persistentSelection(), true);
+ QCOMPARE(spy.count(), 1);
+
+ edit->select(1, 4);
+ QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
+
+ edit->setFocus(false);
+ QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
+
+ edit->setFocus(true);
+ QCOMPARE(edit->property("selected").toString(), QLatin1String("ell"));
+
+}
+
+void tst_qquicktextedit::focusOnPress()
+{
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { activeFocusOnPress: true; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->focusOnPress(), true);
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextEdit { activeFocusOnPress: false; text: \"Hello World\" }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+ QCOMPARE(textEditObject->focusOnPress(), false);
+ }
+}
+
+void tst_qquicktextedit::selection()
+{
+ QString testStr = standard[0];//TODO: What should happen for multiline/rich text?
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+ QVERIFY(textEditObject != 0);
+
+
+ //Test selection follows cursor
+ for (int i=0; i<= testStr.size(); i++) {
+ textEditObject->setCursorPosition(i);
+ QCOMPARE(textEditObject->cursorPosition(), i);
+ QCOMPARE(textEditObject->selectionStart(), i);
+ QCOMPARE(textEditObject->selectionEnd(), i);
+ QVERIFY(textEditObject->selectedText().isNull());
+ }
+
+ textEditObject->setCursorPosition(0);
+ QVERIFY(textEditObject->cursorPosition() == 0);
+ QVERIFY(textEditObject->selectionStart() == 0);
+ QVERIFY(textEditObject->selectionEnd() == 0);
+ QVERIFY(textEditObject->selectedText().isNull());
+
+ // Verify invalid positions are ignored.
+ textEditObject->setCursorPosition(-1);
+ QVERIFY(textEditObject->cursorPosition() == 0);
+ QVERIFY(textEditObject->selectionStart() == 0);
+ QVERIFY(textEditObject->selectionEnd() == 0);
+ QVERIFY(textEditObject->selectedText().isNull());
+
+ textEditObject->setCursorPosition(textEditObject->text().count()+1);
+ QVERIFY(textEditObject->cursorPosition() == 0);
+ QVERIFY(textEditObject->selectionStart() == 0);
+ QVERIFY(textEditObject->selectionEnd() == 0);
+ QVERIFY(textEditObject->selectedText().isNull());
+
+ //Test selection
+ for (int i=0; i<= testStr.size(); i++) {
+ textEditObject->select(0,i);
+ QCOMPARE(testStr.mid(0,i), textEditObject->selectedText());
+ }
+ for (int i=0; i<= testStr.size(); i++) {
+ textEditObject->select(i,testStr.size());
+ QCOMPARE(testStr.mid(i,testStr.size()-i), textEditObject->selectedText());
+ }
+
+ textEditObject->setCursorPosition(0);
+ QVERIFY(textEditObject->cursorPosition() == 0);
+ QVERIFY(textEditObject->selectionStart() == 0);
+ QVERIFY(textEditObject->selectionEnd() == 0);
+ QVERIFY(textEditObject->selectedText().isNull());
+
+ //Test Error Ignoring behaviour
+ textEditObject->setCursorPosition(0);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->select(-10,0);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->select(100,101);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->select(0,-10);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->select(0,100);
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->select(0,10);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->select(-10,0);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->select(100,101);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->select(0,-10);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->select(0,100);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+
+ textEditObject->deselect();
+ QVERIFY(textEditObject->selectedText().isNull());
+ textEditObject->select(0,10);
+ QVERIFY(textEditObject->selectedText().size() == 10);
+ textEditObject->deselect();
+ QVERIFY(textEditObject->selectedText().isNull());
+}
+
+void tst_qquicktextedit::isRightToLeft_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<bool>("emptyString");
+ QTest::addColumn<bool>("firstCharacter");
+ QTest::addColumn<bool>("lastCharacter");
+ QTest::addColumn<bool>("middleCharacter");
+ QTest::addColumn<bool>("startString");
+ QTest::addColumn<bool>("midString");
+ QTest::addColumn<bool>("endString");
+
+ const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647};
+ QTest::newRow("Empty") << "" << false << false << false << false << false << false << false;
+ QTest::newRow("Neutral") << "23244242" << false << false << false << false << false << false << false;
+ QTest::newRow("LTR") << "Hello world" << false << false << false << false << false << false << false;
+ QTest::newRow("RTL") << QString::fromUtf16(arabic_str, 11) << false << true << true << true << true << true << true;
+ QTest::newRow("Bidi RTL + LTR + RTL") << QString::fromUtf16(arabic_str, 11) + QString("Hello world") + QString::fromUtf16(arabic_str, 11) << false << true << true << false << true << true << true;
+ QTest::newRow("Bidi LTR + RTL + LTR") << QString("Hello world") + QString::fromUtf16(arabic_str, 11) + QString("Hello world") << false << false << false << true << false << false << false;
+}
+
+void tst_qquicktextedit::isRightToLeft()
+{
+ QFETCH(QString, text);
+ QFETCH(bool, emptyString);
+ QFETCH(bool, firstCharacter);
+ QFETCH(bool, lastCharacter);
+ QFETCH(bool, middleCharacter);
+ QFETCH(bool, startString);
+ QFETCH(bool, midString);
+ QFETCH(bool, endString);
+
+ QQuickTextEdit textEdit;
+ textEdit.setText(text);
+
+ // first test that the right string is delivered to the QString::isRightToLeft()
+ QCOMPARE(textEdit.isRightToLeft(0,0), text.mid(0,0).isRightToLeft());
+ QCOMPARE(textEdit.isRightToLeft(0,1), text.mid(0,1).isRightToLeft());
+ QCOMPARE(textEdit.isRightToLeft(text.count()-2, text.count()-1), text.mid(text.count()-2, text.count()-1).isRightToLeft());
+ QCOMPARE(textEdit.isRightToLeft(text.count()/2, text.count()/2 + 1), text.mid(text.count()/2, text.count()/2 + 1).isRightToLeft());
+ QCOMPARE(textEdit.isRightToLeft(0,text.count()/4), text.mid(0,text.count()/4).isRightToLeft());
+ QCOMPARE(textEdit.isRightToLeft(text.count()/4,3*text.count()/4), text.mid(text.count()/4,3*text.count()/4).isRightToLeft());
+ if (text.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start.");
+ QCOMPARE(textEdit.isRightToLeft(3*text.count()/4,text.count()-1), text.mid(3*text.count()/4,text.count()-1).isRightToLeft());
+
+ // then test that the feature actually works
+ QCOMPARE(textEdit.isRightToLeft(0,0), emptyString);
+ QCOMPARE(textEdit.isRightToLeft(0,1), firstCharacter);
+ QCOMPARE(textEdit.isRightToLeft(text.count()-2, text.count()-1), lastCharacter);
+ QCOMPARE(textEdit.isRightToLeft(text.count()/2, text.count()/2 + 1), middleCharacter);
+ QCOMPARE(textEdit.isRightToLeft(0,text.count()/4), startString);
+ QCOMPARE(textEdit.isRightToLeft(text.count()/4,3*text.count()/4), midString);
+ if (text.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start.");
+ QCOMPARE(textEdit.isRightToLeft(3*text.count()/4,text.count()-1), endString);
+}
+
+void tst_qquicktextedit::keySelection()
+{
+ QQuickView canvas(testFileUrl("navigation.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+ canvas.requestActivateWindow();
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QQuickTextEdit *input = qobject_cast<QQuickTextEdit *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ QTRY_VERIFY(input->hasActiveFocus() == true);
+
+ QSignalSpy spy(input, SIGNAL(selectionChanged()));
+
+ simulateKey(&canvas, Qt::Key_Right, Qt::ShiftModifier);
+ QVERIFY(input->hasActiveFocus() == true);
+ QCOMPARE(input->selectedText(), QString("a"));
+ QCOMPARE(spy.count(), 1);
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == true);
+ QCOMPARE(input->selectedText(), QString());
+ QCOMPARE(spy.count(), 2);
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == false);
+ QCOMPARE(input->selectedText(), QString());
+ QCOMPARE(spy.count(), 2);
+
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == true);
+ QCOMPARE(spy.count(), 2);
+ simulateKey(&canvas, Qt::Key_Left, Qt::ShiftModifier);
+ QVERIFY(input->hasActiveFocus() == true);
+ QCOMPARE(input->selectedText(), QString("a"));
+ QCOMPARE(spy.count(), 3);
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == true);
+ QCOMPARE(input->selectedText(), QString());
+ QCOMPARE(spy.count(), 4);
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == false);
+ QCOMPARE(input->selectedText(), QString());
+ QCOMPARE(spy.count(), 4);
+}
+
+void tst_qquicktextedit::moveCursorSelection_data()
+{
+ QTest::addColumn<QString>("testStr");
+ QTest::addColumn<int>("cursorPosition");
+ QTest::addColumn<int>("movePosition");
+ QTest::addColumn<QQuickTextEdit::SelectionMode>("mode");
+ QTest::addColumn<int>("selectionStart");
+ QTest::addColumn<int>("selectionEnd");
+ QTest::addColumn<bool>("reversible");
+
+ QTest::newRow("(t)he|characters")
+ << standard[0] << 0 << 1 << QQuickTextEdit::SelectCharacters << 0 << 1 << true;
+ QTest::newRow("do(g)|characters")
+ << standard[0] << 43 << 44 << QQuickTextEdit::SelectCharacters << 43 << 44 << true;
+ QTest::newRow("jum(p)ed|characters")
+ << standard[0] << 23 << 24 << QQuickTextEdit::SelectCharacters << 23 << 24 << true;
+ QTest::newRow("jumped( )over|characters")
+ << standard[0] << 26 << 27 << QQuickTextEdit::SelectCharacters << 26 << 27 << true;
+ QTest::newRow("(the )|characters")
+ << standard[0] << 0 << 4 << QQuickTextEdit::SelectCharacters << 0 << 4 << true;
+ QTest::newRow("( dog)|characters")
+ << standard[0] << 40 << 44 << QQuickTextEdit::SelectCharacters << 40 << 44 << true;
+ QTest::newRow("( jumped )|characters")
+ << standard[0] << 19 << 27 << QQuickTextEdit::SelectCharacters << 19 << 27 << true;
+ QTest::newRow("th(e qu)ick|characters")
+ << standard[0] << 2 << 6 << QQuickTextEdit::SelectCharacters << 2 << 6 << true;
+ QTest::newRow("la(zy d)og|characters")
+ << standard[0] << 38 << 42 << QQuickTextEdit::SelectCharacters << 38 << 42 << true;
+ QTest::newRow("jum(ped ov)er|characters")
+ << standard[0] << 23 << 29 << QQuickTextEdit::SelectCharacters << 23 << 29 << true;
+ QTest::newRow("()the|characters")
+ << standard[0] << 0 << 0 << QQuickTextEdit::SelectCharacters << 0 << 0 << true;
+ QTest::newRow("dog()|characters")
+ << standard[0] << 44 << 44 << QQuickTextEdit::SelectCharacters << 44 << 44 << true;
+ QTest::newRow("jum()ped|characters")
+ << standard[0] << 23 << 23 << QQuickTextEdit::SelectCharacters << 23 << 23 << true;
+
+ QTest::newRow("<(t)he>|words")
+ << standard[0] << 0 << 1 << QQuickTextEdit::SelectWords << 0 << 3 << true;
+ QTest::newRow("<do(g)>|words")
+ << standard[0] << 43 << 44 << QQuickTextEdit::SelectWords << 41 << 44 << true;
+ QTest::newRow("<jum(p)ed>|words")
+ << standard[0] << 23 << 24 << QQuickTextEdit::SelectWords << 20 << 26 << true;
+ QTest::newRow("<jumped( )>over|words")
+ << standard[0] << 26 << 27 << QQuickTextEdit::SelectWords << 20 << 27 << false;
+ QTest::newRow("jumped<( )over>|words,reversed")
+ << standard[0] << 27 << 26 << QQuickTextEdit::SelectWords << 26 << 31 << false;
+ QTest::newRow("<(the )>quick|words")
+ << standard[0] << 0 << 4 << QQuickTextEdit::SelectWords << 0 << 4 << false;
+ QTest::newRow("<(the )quick>|words,reversed")
+ << standard[0] << 4 << 0 << QQuickTextEdit::SelectWords << 0 << 9 << false;
+ QTest::newRow("<lazy( dog)>|words")
+ << standard[0] << 40 << 44 << QQuickTextEdit::SelectWords << 36 << 44 << false;
+ QTest::newRow("lazy<( dog)>|words,reversed")
+ << standard[0] << 44 << 40 << QQuickTextEdit::SelectWords << 40 << 44 << false;
+ QTest::newRow("<fox( jumped )>over|words")
+ << standard[0] << 19 << 27 << QQuickTextEdit::SelectWords << 16 << 27 << false;
+ QTest::newRow("fox<( jumped )over>|words,reversed")
+ << standard[0] << 27 << 19 << QQuickTextEdit::SelectWords << 19 << 31 << false;
+ QTest::newRow("<th(e qu)ick>|words")
+ << standard[0] << 2 << 6 << QQuickTextEdit::SelectWords << 0 << 9 << true;
+ QTest::newRow("<la(zy d)og|words>")
+ << standard[0] << 38 << 42 << QQuickTextEdit::SelectWords << 36 << 44 << true;
+ QTest::newRow("<jum(ped ov)er>|words")
+ << standard[0] << 23 << 29 << QQuickTextEdit::SelectWords << 20 << 31 << true;
+ QTest::newRow("<()>the|words")
+ << standard[0] << 0 << 0 << QQuickTextEdit::SelectWords << 0 << 0 << true;
+ QTest::newRow("dog<()>|words")
+ << standard[0] << 44 << 44 << QQuickTextEdit::SelectWords << 44 << 44 << true;
+ QTest::newRow("jum<()>ped|words")
+ << standard[0] << 23 << 23 << QQuickTextEdit::SelectWords << 23 << 23 << true;
+
+ QTest::newRow("Hello<(,)> |words")
+ << standard[2] << 5 << 6 << QQuickTextEdit::SelectWords << 5 << 6 << true;
+ QTest::newRow("Hello<(, )>world|words")
+ << standard[2] << 5 << 7 << QQuickTextEdit::SelectWords << 5 << 7 << false;
+ QTest::newRow("Hello<(, )world>|words,reversed")
+ << standard[2] << 7 << 5 << QQuickTextEdit::SelectWords << 5 << 12 << false;
+ QTest::newRow("<Hel(lo, )>world|words")
+ << standard[2] << 3 << 7 << QQuickTextEdit::SelectWords << 0 << 7 << false;
+ QTest::newRow("<Hel(lo, )world>|words,reversed")
+ << standard[2] << 7 << 3 << QQuickTextEdit::SelectWords << 0 << 12 << false;
+ QTest::newRow("<Hel(lo)>,|words")
+ << standard[2] << 3 << 5 << QQuickTextEdit::SelectWords << 0 << 5 << true;
+ QTest::newRow("Hello<()>,|words")
+ << standard[2] << 5 << 5 << QQuickTextEdit::SelectWords << 5 << 5 << true;
+ QTest::newRow("Hello,<()>|words")
+ << standard[2] << 6 << 6 << QQuickTextEdit::SelectWords << 6 << 6 << true;
+ QTest::newRow("Hello<,( )>world|words")
+ << standard[2] << 6 << 7 << QQuickTextEdit::SelectWords << 5 << 7 << false;
+ QTest::newRow("Hello,<( )world>|words,reversed")
+ << standard[2] << 7 << 6 << QQuickTextEdit::SelectWords << 6 << 12 << false;
+ QTest::newRow("Hello<,( world)>|words")
+ << standard[2] << 6 << 12 << QQuickTextEdit::SelectWords << 5 << 12 << false;
+ QTest::newRow("Hello,<( world)>|words,reversed")
+ << standard[2] << 12 << 6 << QQuickTextEdit::SelectWords << 6 << 12 << false;
+ QTest::newRow("Hello<,( world!)>|words")
+ << standard[2] << 6 << 13 << QQuickTextEdit::SelectWords << 5 << 13 << false;
+ QTest::newRow("Hello,<( world!)>|words,reversed")
+ << standard[2] << 13 << 6 << QQuickTextEdit::SelectWords << 6 << 13 << false;
+ QTest::newRow("Hello<(, world!)>|words")
+ << standard[2] << 5 << 13 << QQuickTextEdit::SelectWords << 5 << 13 << true;
+ QTest::newRow("world<(!)>|words")
+ << standard[2] << 12 << 13 << QQuickTextEdit::SelectWords << 12 << 13 << true;
+ QTest::newRow("world!<()>)|words")
+ << standard[2] << 13 << 13 << QQuickTextEdit::SelectWords << 13 << 13 << true;
+ QTest::newRow("world<()>!)|words")
+ << standard[2] << 12 << 12 << QQuickTextEdit::SelectWords << 12 << 12 << true;
+
+ QTest::newRow("<(,)>olleH |words")
+ << standard[3] << 7 << 8 << QQuickTextEdit::SelectWords << 7 << 8 << true;
+ QTest::newRow("<dlrow( ,)>olleH|words")
+ << standard[3] << 6 << 8 << QQuickTextEdit::SelectWords << 1 << 8 << false;
+ QTest::newRow("dlrow<( ,)>olleH|words,reversed")
+ << standard[3] << 8 << 6 << QQuickTextEdit::SelectWords << 6 << 8 << false;
+ QTest::newRow("<dlrow( ,ol)leH>|words")
+ << standard[3] << 6 << 10 << QQuickTextEdit::SelectWords << 1 << 13 << false;
+ QTest::newRow("dlrow<( ,ol)leH>|words,reversed")
+ << standard[3] << 10 << 6 << QQuickTextEdit::SelectWords << 6 << 13 << false;
+ QTest::newRow(",<(ol)leH>,|words")
+ << standard[3] << 8 << 10 << QQuickTextEdit::SelectWords << 8 << 13 << true;
+ QTest::newRow(",<()>olleH|words")
+ << standard[3] << 8 << 8 << QQuickTextEdit::SelectWords << 8 << 8 << true;
+ QTest::newRow("<()>,olleH|words")
+ << standard[3] << 7 << 7 << QQuickTextEdit::SelectWords << 7 << 7 << true;
+ QTest::newRow("<dlrow( )>,olleH|words")
+ << standard[3] << 6 << 7 << QQuickTextEdit::SelectWords << 1 << 7 << false;
+ QTest::newRow("dlrow<( ),>olleH|words,reversed")
+ << standard[3] << 7 << 6 << QQuickTextEdit::SelectWords << 6 << 8 << false;
+ QTest::newRow("<(dlrow )>,olleH|words")
+ << standard[3] << 1 << 7 << QQuickTextEdit::SelectWords << 1 << 7 << false;
+ QTest::newRow("<(dlrow ),>olleH|words,reversed")
+ << standard[3] << 7 << 1 << QQuickTextEdit::SelectWords << 1 << 8 << false;
+ QTest::newRow("<(!dlrow )>,olleH|words")
+ << standard[3] << 0 << 7 << QQuickTextEdit::SelectWords << 0 << 7 << false;
+ QTest::newRow("<(!dlrow ),>olleH|words,reversed")
+ << standard[3] << 7 << 0 << QQuickTextEdit::SelectWords << 0 << 8 << false;
+ QTest::newRow("(!dlrow ,)olleH|words")
+ << standard[3] << 0 << 8 << QQuickTextEdit::SelectWords << 0 << 8 << true;
+ QTest::newRow("<(!)>dlrow|words")
+ << standard[3] << 0 << 1 << QQuickTextEdit::SelectWords << 0 << 1 << true;
+ QTest::newRow("<()>!dlrow|words")
+ << standard[3] << 0 << 0 << QQuickTextEdit::SelectWords << 0 << 0 << true;
+ QTest::newRow("!<()>dlrow|words")
+ << standard[3] << 1 << 1 << QQuickTextEdit::SelectWords << 1 << 1 << true;
+}
+
+void tst_qquicktextedit::moveCursorSelection()
+{
+ QFETCH(QString, testStr);
+ QFETCH(int, cursorPosition);
+ QFETCH(int, movePosition);
+ QFETCH(QQuickTextEdit::SelectionMode, mode);
+ QFETCH(int, selectionStart);
+ QFETCH(int, selectionEnd);
+ QFETCH(bool, reversible);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit*>(textinputComponent.create());
+ QVERIFY(texteditObject != 0);
+
+ texteditObject->setCursorPosition(cursorPosition);
+ texteditObject->moveCursorSelection(movePosition, mode);
+
+ QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
+ QCOMPARE(texteditObject->selectionStart(), selectionStart);
+ QCOMPARE(texteditObject->selectionEnd(), selectionEnd);
+
+ if (reversible) {
+ texteditObject->setCursorPosition(movePosition);
+ texteditObject->moveCursorSelection(cursorPosition, mode);
+
+ QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
+ QCOMPARE(texteditObject->selectionStart(), selectionStart);
+ QCOMPARE(texteditObject->selectionEnd(), selectionEnd);
+ }
+}
+
+void tst_qquicktextedit::moveCursorSelectionSequence_data()
+{
+ QTest::addColumn<QString>("testStr");
+ QTest::addColumn<int>("cursorPosition");
+ QTest::addColumn<int>("movePosition1");
+ QTest::addColumn<int>("movePosition2");
+ QTest::addColumn<int>("selection1Start");
+ QTest::addColumn<int>("selection1End");
+ QTest::addColumn<int>("selection2Start");
+ QTest::addColumn<int>("selection2End");
+
+ QTest::newRow("the {<quick( bro)wn> f^ox} jumped|ltr")
+ << standard[0]
+ << 9 << 13 << 17
+ << 4 << 15
+ << 4 << 19;
+ QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl")
+ << standard[0]
+ << 13 << 9 << 17
+ << 9 << 15
+ << 10 << 19;
+ QTest::newRow("the {<quick( bro)wn> ^}fox jumped|ltr")
+ << standard[0]
+ << 9 << 13 << 16
+ << 4 << 15
+ << 4 << 16;
+ QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl")
+ << standard[0]
+ << 13 << 9 << 16
+ << 9 << 15
+ << 10 << 16;
+ QTest::newRow("the {<quick( bro)wn^>} fox jumped|ltr")
+ << standard[0]
+ << 9 << 13 << 15
+ << 4 << 15
+ << 4 << 15;
+ QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl")
+ << standard[0]
+ << 13 << 9 << 15
+ << 9 << 15
+ << 10 << 15;
+ QTest::newRow("the {<quick() ^}bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 10
+ << 4 << 15
+ << 4 << 10;
+ QTest::newRow("the quick<(^ {^bro)wn>} fox|rtl")
+ << standard[0]
+ << 13 << 9 << 10
+ << 9 << 15
+ << 10 << 15;
+ QTest::newRow("the {<quick^}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 9
+ << 4 << 15
+ << 4 << 9;
+ QTest::newRow("the quick{<(^ bro)wn>} fox|rtl")
+ << standard[0]
+ << 13 << 9 << 9
+ << 9 << 15
+ << 9 << 15;
+ QTest::newRow("the {<qui^ck}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 7
+ << 4 << 15
+ << 4 << 9;
+ QTest::newRow("the {<qui^ck}( bro)wn> fox|rtl")
+ << standard[0]
+ << 13 << 9 << 7
+ << 9 << 15
+ << 4 << 15;
+ QTest::newRow("the {<^quick}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 4
+ << 4 << 15
+ << 4 << 9;
+ QTest::newRow("the {<^quick}( bro)wn> fox|rtl")
+ << standard[0]
+ << 13 << 9 << 4
+ << 9 << 15
+ << 4 << 15;
+ QTest::newRow("the{^ <quick}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 3
+ << 4 << 15
+ << 3 << 9;
+ QTest::newRow("the{^ <quick}( bro)wn> fox|rtl")
+ << standard[0]
+ << 13 << 9 << 3
+ << 9 << 15
+ << 3 << 15;
+ QTest::newRow("{t^he <quick}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 1
+ << 4 << 15
+ << 0 << 9;
+ QTest::newRow("{t^he <quick}( bro)wn> fox|rtl")
+ << standard[0]
+ << 13 << 9 << 1
+ << 9 << 15
+ << 0 << 15;
+
+ QTest::newRow("{<He(ll)o>, w^orld}!|ltr")
+ << standard[2]
+ << 2 << 4 << 8
+ << 0 << 5
+ << 0 << 12;
+ QTest::newRow("{<He(ll)o>, w^orld}!|rtl")
+ << standard[2]
+ << 4 << 2 << 8
+ << 0 << 5
+ << 0 << 12;
+
+ QTest::newRow("!{dlro^w ,<o(ll)eH>}|ltr")
+ << standard[3]
+ << 9 << 11 << 5
+ << 8 << 13
+ << 1 << 13;
+ QTest::newRow("!{dlro^w ,<o(ll)eH>}|rtl")
+ << standard[3]
+ << 11 << 9 << 5
+ << 8 << 13
+ << 1 << 13;
+}
+
+void tst_qquicktextedit::moveCursorSelectionSequence()
+{
+ QFETCH(QString, testStr);
+ QFETCH(int, cursorPosition);
+ QFETCH(int, movePosition1);
+ QFETCH(int, movePosition2);
+ QFETCH(int, selection1Start);
+ QFETCH(int, selection1End);
+ QFETCH(int, selection2Start);
+ QFETCH(int, selection2End);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \""+ testStr +"\"; }";
+ QQmlComponent texteditComponent(&engine);
+ texteditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit*>(texteditComponent.create());
+ QVERIFY(texteditObject != 0);
+
+ texteditObject->setCursorPosition(cursorPosition);
+
+ texteditObject->moveCursorSelection(movePosition1, QQuickTextEdit::SelectWords);
+ QCOMPARE(texteditObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start));
+ QCOMPARE(texteditObject->selectionStart(), selection1Start);
+ QCOMPARE(texteditObject->selectionEnd(), selection1End);
+
+ texteditObject->moveCursorSelection(movePosition2, QQuickTextEdit::SelectWords);
+ QCOMPARE(texteditObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start));
+ QCOMPARE(texteditObject->selectionStart(), selection2Start);
+ QCOMPARE(texteditObject->selectionEnd(), selection2End);
+}
+
+
+void tst_qquicktextedit::mouseSelection_data()
+{
+ QTest::addColumn<QString>("qmlfile");
+ QTest::addColumn<int>("from");
+ QTest::addColumn<int>("to");
+ QTest::addColumn<QString>("selectedText");
+
+ // import installed
+ QTest::newRow("on") << testFile("mouseselection_true.qml") << 4 << 9 << "45678";
+ QTest::newRow("off") << testFile("mouseselection_false.qml") << 4 << 9 << QString();
+ QTest::newRow("default") << testFile("mouseselection_default.qml") << 4 << 9 << QString();
+ QTest::newRow("off word selection") << testFile("mouseselection_false_words.qml") << 4 << 9 << QString();
+ QTest::newRow("on word selection (4,9)") << testFile("mouseselection_true_words.qml") << 4 << 9 << "0123456789";
+ QTest::newRow("on word selection (2,13)") << testFile("mouseselection_true_words.qml") << 2 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (2,30)") << testFile("mouseselection_true_words.qml") << 2 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (9,13)") << testFile("mouseselection_true_words.qml") << 9 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (9,30)") << testFile("mouseselection_true_words.qml") << 9 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (13,2)") << testFile("mouseselection_true_words.qml") << 13 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (20,2)") << testFile("mouseselection_true_words.qml") << 20 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (12,9)") << testFile("mouseselection_true_words.qml") << 12 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (30,9)") << testFile("mouseselection_true_words.qml") << 30 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+}
+
+void tst_qquicktextedit::mouseSelection()
+{
+ QFETCH(QString, qmlfile);
+ QFETCH(int, from);
+ QFETCH(int, to);
+ QFETCH(QString, selectedText);
+
+ QQuickView canvas(QUrl::fromLocalFile(qmlfile));
+
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
+ QVERIFY(textEditObject != 0);
+
+ // press-and-drag-and-release from x1 to x2
+ QPoint p1 = textEditObject->positionToRectangle(from).center().toPoint();
+ QPoint p2 = textEditObject->positionToRectangle(to).center().toPoint();
+ QTest::mousePress(&canvas, Qt::LeftButton, 0, p1);
+ QTest::mouseMove(&canvas, p2);
+ QTest::mouseRelease(&canvas, Qt::LeftButton, 0, p2);
+ QTest::qWait(50);
+ QTRY_COMPARE(textEditObject->selectedText(), selectedText);
+
+ // Clicking and shift to clicking between the same points should select the same text.
+ textEditObject->setCursorPosition(0);
+ QTest::mouseClick(&canvas, Qt::LeftButton, Qt::NoModifier, p1);
+ QTest::mouseClick(&canvas, Qt::LeftButton, Qt::ShiftModifier, p2);
+ QTest::qWait(50);
+ QTRY_COMPARE(textEditObject->selectedText(), selectedText);
+}
+
+void tst_qquicktextedit::dragMouseSelection()
+{
+ QString qmlfile = testFile("mouseselection_true.qml");
+
+ QQuickView canvas(QUrl::fromLocalFile(qmlfile));
+
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
+ QVERIFY(textEditObject != 0);
+
+ // press-and-drag-and-release from x1 to x2
+ int x1 = 10;
+ int x2 = 70;
+ int y = textEditObject->height()/2;
+ QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
+ QTest::mouseMove(&canvas, QPoint(x2, y));
+ QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
+ QTest::qWait(300);
+ QString str1;
+ QTRY_VERIFY((str1 = textEditObject->selectedText()).length() > 3);
+
+ // press and drag the current selection.
+ x1 = 40;
+ x2 = 100;
+ QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
+ QTest::mouseMove(&canvas, QPoint(x2, y));
+ QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
+ QTest::qWait(300);
+ QString str2;
+ QTRY_VERIFY((str2 = textEditObject->selectedText()).length() > 3);
+
+ QVERIFY(str1 != str2); // Verify the second press and drag is a new selection and not the first moved.
+}
+
+void tst_qquicktextedit::mouseSelectionMode_data()
+{
+ QTest::addColumn<QString>("qmlfile");
+ QTest::addColumn<bool>("selectWords");
+
+ // import installed
+ QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true;
+ QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false;
+ QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false;
+}
+
+void tst_qquicktextedit::mouseSelectionMode()
+{
+ QFETCH(QString, qmlfile);
+ QFETCH(bool, selectWords);
+
+ QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+ QQuickView canvas(QUrl::fromLocalFile(qmlfile));
+
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
+ QVERIFY(textEditObject != 0);
+
+ // press-and-drag-and-release from x1 to x2
+ int x1 = 10;
+ int x2 = 70;
+ int y = textEditObject->height()/2;
+ QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
+ QTest::mouseMove(&canvas, QPoint(x2, y));
+ //QTest::mouseMove(canvas, QPoint(x2,y)); // doesn't work
+// QMouseEvent mv(QEvent::MouseMove, QPoint(x2,y), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+// QGuiApplication::sendEvent(&canvas, &mv);
+ QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
+ QString str = textEditObject->selectedText();
+ if (selectWords) {
+ QTRY_COMPARE(textEditObject->selectedText(), text);
+ } else {
+ QTRY_VERIFY(textEditObject->selectedText().length() > 3);
+ QVERIFY(str != text);
+ }
+}
+
+void tst_qquicktextedit::inputMethodHints()
+{
+ QQuickView canvas(testFileUrl("inputmethodhints.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextEdit *textEditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
+ QVERIFY(textEditObject != 0);
+ QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText);
+ QSignalSpy inputMethodHintSpy(textEditObject, SIGNAL(inputMethodHintsChanged()));
+ textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
+ QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly);
+ QCOMPARE(inputMethodHintSpy.count(), 1);
+ textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly);
+ QCOMPARE(inputMethodHintSpy.count(), 1);
+
+ QQuickTextEdit plainTextEdit;
+ QCOMPARE(plainTextEdit.inputMethodHints(), Qt::ImhNone);
+}
+
+void tst_qquicktextedit::positionAt()
+{
+ QQuickView canvas(testFileUrl("positionAt.qml"));
+ QVERIFY(canvas.rootObject() != 0);
+ canvas.show();
+ canvas.requestActivateWindow();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+
+ QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
+ QVERIFY(texteditObject != 0);
+
+ QTextLayout layout(texteditObject->text());
+ layout.setFont(texteditObject->font());
+
+ if (!qmlDisableDistanceField()) {
+ QTextOption option;
+ option.setUseDesignMetrics(true);
+ layout.setTextOption(option);
+ }
+
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ const int y0 = line.height() / 2;
+ const int y1 = line.height() * 3 / 2;
+
+ int pos = texteditObject->positionAt(texteditObject->width()/2, y0);
+
+ int widthBegin = floor(line.cursorToX(pos - 1));
+ int widthEnd = ceil(line.cursorToX(pos + 1));
+
+ QVERIFY(widthBegin <= texteditObject->width() / 2);
+ QVERIFY(widthEnd >= texteditObject->width() / 2);
+
+ const qreal x0 = texteditObject->positionToRectangle(pos).x();
+ const qreal x1 = texteditObject->positionToRectangle(pos + 1).x();
+
+ QString preeditText = texteditObject->text().mid(0, pos);
+ texteditObject->setText(texteditObject->text().mid(pos));
+ texteditObject->setCursorPosition(0);
+
+ QInputMethodEvent inputEvent(preeditText, QList<QInputMethodEvent::Attribute>());
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent);
+
+ // Check all points within the preedit text return the same position.
+ QCOMPARE(texteditObject->positionAt(0, y0), 0);
+ QCOMPARE(texteditObject->positionAt(x0 / 2, y0), 0);
+ QCOMPARE(texteditObject->positionAt(x0, y0), 0);
+
+ // Verify positioning returns to normal after the preedit text.
+ QCOMPARE(texteditObject->positionAt(x1, y0), 1);
+ QCOMPARE(texteditObject->positionToRectangle(1).x(), x1);
+
+ QVERIFY(texteditObject->positionAt(x0 / 2, y1) > 0);
+}
+
+void tst_qquicktextedit::linkActivated()
+{
+ QQuickView canvas(testFileUrl("linkActivated.qml"));
+ QVERIFY(canvas.rootObject() != 0);
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+
+ QQuickTextEdit *texteditObject = qobject_cast<QQuickTextEdit *>(canvas.rootObject());
+ QVERIFY(texteditObject != 0);
+
+ QSignalSpy spy(texteditObject, SIGNAL(linkActivated(QString)));
+
+ const QString link("http://example.com/");
+
+ const QPointF linkPos = texteditObject->positionToRectangle(7).center();
+ const QPointF textPos = texteditObject->positionToRectangle(2).center();
+
+ QTest::mouseClick(&canvas, Qt::LeftButton, 0, linkPos.toPoint());
+ QTRY_COMPARE(spy.count(), 1);
+ QCOMPARE(spy.last()[0].toString(), link);
+
+ QTest::mouseClick(&canvas, Qt::LeftButton, 0, textPos.toPoint());
+ QTest::qWait(50);
+ QCOMPARE(spy.count(), 1);
+
+ texteditObject->setReadOnly(true);
+
+ QTest::mouseClick(&canvas, Qt::LeftButton, 0, linkPos.toPoint());
+ QTRY_COMPARE(spy.count(), 2);
+ QCOMPARE(spy.last()[0].toString(), link);
+
+ QTest::mouseClick(&canvas, Qt::LeftButton, 0, textPos.toPoint());
+ QTest::qWait(50);
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktextedit::cursorDelegate_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::newRow("out of line") << testFileUrl("cursorTest.qml");
+ QTest::newRow("in line") << testFileUrl("cursorTestInline.qml");
+ QTest::newRow("external") << testFileUrl("cursorTestExternal.qml");
+}
+
+void tst_qquicktextedit::cursorDelegate()
+{
+ QFETCH(QUrl, source);
+ QQuickView view(source);
+ view.show();
+ view.requestActivateWindow();
+ QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject");
+ QVERIFY(textEditObject != 0);
+ QVERIFY(textEditObject->findChild<QQuickItem*>("cursorInstance"));
+ //Test Delegate gets created
+ textEditObject->setFocus(true);
+ QQuickItem* delegateObject = textEditObject->findChild<QQuickItem*>("cursorInstance");
+ QVERIFY(delegateObject);
+ QCOMPARE(delegateObject->property("localProperty").toString(), QString("Hello"));
+ //Test Delegate gets moved
+ for (int i=0; i<= textEditObject->text().length(); i++) {
+ textEditObject->setCursorPosition(i);
+ QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ }
+ // Clear preedit text;
+ QInputMethodEvent event;
+ QGuiApplication::sendEvent(&view, &event);
+
+
+ // Test delegate gets moved on mouse press.
+ textEditObject->setSelectByMouse(true);
+ textEditObject->setCursorPosition(0);
+ const QPoint point1 = textEditObject->positionToRectangle(5).center().toPoint();
+ QTest::mouseClick(&view, Qt::LeftButton, 0, point1);
+ QTest::qWait(50);
+ QTRY_VERIFY(textEditObject->cursorPosition() != 0);
+ QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+
+ // Test delegate gets moved on mouse drag
+ textEditObject->setCursorPosition(0);
+ const QPoint point2 = textEditObject->positionToRectangle(10).center().toPoint();
+ QTest::mousePress(&view, Qt::LeftButton, 0, point1);
+ QMouseEvent mv(QEvent::MouseMove, point2, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QGuiApplication::sendEvent(&view, &mv);
+ QTest::mouseRelease(&view, Qt::LeftButton, 0, point2);
+ QTest::qWait(50);
+ QTRY_COMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+
+ textEditObject->setReadOnly(true);
+ textEditObject->setCursorPosition(0);
+ QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint());
+ QTest::qWait(50);
+ QTRY_VERIFY(textEditObject->cursorPosition() != 0);
+ QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+
+ textEditObject->setCursorPosition(0);
+ QTest::mouseClick(&view, Qt::LeftButton, 0, textEditObject->positionToRectangle(5).center().toPoint());
+ QTest::qWait(50);
+ QTRY_VERIFY(textEditObject->cursorPosition() != 0);
+ QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+
+ textEditObject->setCursorPosition(0);
+ QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ //Test Delegate gets deleted
+ textEditObject->setCursorDelegate(0);
+ QVERIFY(!textEditObject->findChild<QQuickItem*>("cursorInstance"));
+}
+
+void tst_qquicktextedit::cursorVisible()
+{
+ QQuickView view(testFileUrl("cursorVisible.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+
+ QQuickTextEdit edit;
+ QSignalSpy spy(&edit, SIGNAL(cursorVisibleChanged(bool)));
+
+ QCOMPARE(edit.isCursorVisible(), false);
+
+ edit.setCursorVisible(true);
+ QCOMPARE(edit.isCursorVisible(), true);
+ QCOMPARE(spy.count(), 1);
+
+ edit.setCursorVisible(false);
+ QCOMPARE(edit.isCursorVisible(), false);
+ QCOMPARE(spy.count(), 2);
+
+ edit.setFocus(true);
+ QCOMPARE(edit.isCursorVisible(), false);
+ QCOMPARE(spy.count(), 2);
+
+ edit.setParentItem(view.rootObject());
+ QCOMPARE(edit.isCursorVisible(), true);
+ QCOMPARE(spy.count(), 3);
+
+ edit.setFocus(false);
+ QCOMPARE(edit.isCursorVisible(), false);
+ QCOMPARE(spy.count(), 4);
+
+ edit.setFocus(true);
+ QCOMPARE(edit.isCursorVisible(), true);
+ QCOMPARE(spy.count(), 5);
+
+ QQuickView alternateView;
+ alternateView.show();
+ alternateView.requestActivateWindow();
+ QTest::qWaitForWindowShown(&alternateView);
+
+ QCOMPARE(edit.isCursorVisible(), false);
+ QCOMPARE(spy.count(), 6);
+
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QCOMPARE(edit.isCursorVisible(), true);
+ QCOMPARE(spy.count(), 7);
+}
+
+void tst_qquicktextedit::delegateLoading_data()
+{
+ QTest::addColumn<QString>("qmlfile");
+ QTest::addColumn<QString>("error");
+
+ // import installed
+ QTest::newRow("pass") << "cursorHttpTestPass.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 ";
+}
+
+void tst_qquicktextedit::delegateLoading()
+{
+#ifdef Q_OS_MAC
+ QSKIP("Test crashes during canvas tear down. QTBUG-23010");
+#endif
+ QFETCH(QString, qmlfile);
+ QFETCH(QString, error);
+
+ TestHTTPServer server(42332);
+ server.serveDirectory(testFile("httpfail"), TestHTTPServer::Disconnect);
+ server.serveDirectory(testFile("httpslow"), TestHTTPServer::Delay);
+ server.serveDirectory(testFile("http"));
+
+ QQuickView view(QUrl(QLatin1String("http://localhost:42332/") + qmlfile));
+ view.show();
+ view.requestActivateWindow();
+
+ if (!error.isEmpty()) {
+ QTest::ignoreMessage(QtWarningMsg, error.toUtf8());
+ QTRY_VERIFY(view.status()==QQuickView::Error);
+ QTRY_VERIFY(!view.rootObject()); // there is fail item inside this test
+ } else {
+ QTRY_VERIFY(view.rootObject());//Wait for loading to finish.
+ QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject");
+ // view.rootObject()->dumpObjectTree();
+ QVERIFY(textEditObject != 0);
+ textEditObject->setFocus(true);
+ QQuickItem *delegate;
+ delegate = view.rootObject()->findChild<QQuickItem*>("delegateOkay");
+ QVERIFY(delegate);
+ delegate = view.rootObject()->findChild<QQuickItem*>("delegateSlow");
+ QVERIFY(delegate);
+
+ delete delegate;
+ }
+
+
+ //A test should be added here with a component which is ready but component.create() returns null
+ //Not sure how to accomplish this with QQuickTextEdits cursor delegate
+ //###This was only needed for code coverage, and could be a case of overzealous defensive programming
+ //delegate = view.rootObject()->findChild<QQuickItem*>("delegateErrorB");
+ //QVERIFY(!delegate);
+}
+
+/*
+TextEdit element should only handle left/right keys until the cursor reaches
+the extent of the text, then they should ignore the keys.
+*/
+void tst_qquicktextedit::navigation()
+{
+ QQuickView canvas(testFileUrl("navigation.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QQuickItem *input = qobject_cast<QQuickItem *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ QTRY_VERIFY(input->hasActiveFocus() == true);
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == false);
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == true);
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == true);
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == false);
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == true);
+}
+
+void tst_qquicktextedit::copyAndPaste() {
+#ifndef QT_NO_CLIPBOARD
+
+#ifdef Q_OS_MAC
+ {
+ PasteboardRef pasteboard;
+ OSStatus status = PasteboardCreate(0, &pasteboard);
+ if (status == noErr)
+ CFRelease(pasteboard);
+ else
+ QSKIP("This machine doesn't support the clipboard");
+ }
+#endif
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ // copy and paste
+ QCOMPARE(textEdit->text().length(), 12);
+ textEdit->select(0, textEdit->text().length());;
+ textEdit->copy();
+ QCOMPARE(textEdit->selectedText(), QString("Hello world!"));
+ QCOMPARE(textEdit->selectedText().length(), 12);
+ textEdit->setCursorPosition(0);
+ QVERIFY(textEdit->canPaste());
+ textEdit->paste();
+ QCOMPARE(textEdit->text(), QString("Hello world!Hello world!"));
+ QCOMPARE(textEdit->text().length(), 24);
+
+ // canPaste
+ QVERIFY(textEdit->canPaste());
+ textEdit->setReadOnly(true);
+ QVERIFY(!textEdit->canPaste());
+ textEdit->setReadOnly(false);
+ QVERIFY(textEdit->canPaste());
+
+ // QTBUG-12339
+ // test that document and internal text attribute are in sync
+ QQuickItemPrivate* pri = QQuickItemPrivate::get(textEdit);
+ QQuickTextEditPrivate *editPrivate = static_cast<QQuickTextEditPrivate*>(pri);
+ QCOMPARE(textEdit->text(), editPrivate->text);
+
+ // select word
+ textEdit->setCursorPosition(0);
+ textEdit->selectWord();
+ QCOMPARE(textEdit->selectedText(), QString("Hello"));
+
+ // select all and cut
+ textEdit->selectAll();
+ textEdit->cut();
+ QCOMPARE(textEdit->text().length(), 0);
+ textEdit->paste();
+ QCOMPARE(textEdit->text(), QString("Hello world!Hello world!"));
+ QCOMPARE(textEdit->text().length(), 24);
+#endif
+}
+
+void tst_qquicktextedit::canPaste() {
+#ifndef QT_NO_CLIPBOARD
+
+ QGuiApplication::clipboard()->setText("Some text");
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ // check initial value - QTBUG-17765
+ QQuickTextControl tc(0);
+ QCOMPARE(textEdit->canPaste(), tc.canPaste());
+
+#endif
+}
+
+void tst_qquicktextedit::canPasteEmpty() {
+#ifndef QT_NO_CLIPBOARD
+
+ QGuiApplication::clipboard()->clear();
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"Hello world!\" }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ // check initial value - QTBUG-17765
+ QQuickTextControl tc(0);
+ QCOMPARE(textEdit->canPaste(), tc.canPaste());
+
+#endif
+}
+
+void tst_qquicktextedit::readOnly()
+{
+ QQuickView canvas(testFileUrl("readOnly.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
+
+ QVERIFY(edit != 0);
+ QTRY_VERIFY(edit->hasActiveFocus() == true);
+ QVERIFY(edit->isReadOnly() == true);
+ QString initial = edit->text();
+ for (int k=Qt::Key_0; k<=Qt::Key_Z; k++)
+ simulateKey(&canvas, k);
+ simulateKey(&canvas, Qt::Key_Return);
+ simulateKey(&canvas, Qt::Key_Space);
+ simulateKey(&canvas, Qt::Key_Escape);
+ QCOMPARE(edit->text(), initial);
+
+ edit->setCursorPosition(3);
+ edit->setReadOnly(false);
+ QCOMPARE(edit->isReadOnly(), false);
+ QCOMPARE(edit->cursorPosition(), edit->text().length());
+}
+
+void tst_qquicktextedit::simulateKey(QQuickView *view, int key, Qt::KeyboardModifiers modifiers)
+{
+ QKeyEvent press(QKeyEvent::KeyPress, key, modifiers);
+ QKeyEvent release(QKeyEvent::KeyRelease, key, modifiers);
+
+ QGuiApplication::sendEvent(view, &press);
+ QGuiApplication::sendEvent(view, &release);
+}
+
+void tst_qquicktextedit::textInput()
+{
+ QQuickView view(testFileUrl("inputMethodEvent.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
+ QVERIFY(edit);
+ QVERIFY(edit->hasActiveFocus() == true);
+
+ // test that input method event is committed and change signal is emitted
+ QSignalSpy spy(edit, SIGNAL(textChanged()));
+ QInputMethodEvent event;
+ event.setCommitString( "Hello world!", 0, 0);
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
+ QCOMPARE(edit->text(), QString("Hello world!"));
+ QCOMPARE(spy.count(), 1);
+
+ // QTBUG-12339
+ // test that document and internal text attribute are in sync
+ QQuickTextEditPrivate *editPrivate = static_cast<QQuickTextEditPrivate*>(QQuickItemPrivate::get(edit));
+ QCOMPARE(editPrivate->text, QString("Hello world!"));
+
+ // test that tentative commit is included in text property
+ edit->setText("");
+ spy.clear();
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent event2("preedit", attributes);
+ event2.setTentativeCommitString("string");
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &event2);
+ QCOMPARE(spy.count(), 1);
+ QCOMPARE(edit->text(), QString("string"));
+
+ QInputMethodQueryEvent queryEvent(Qt::ImEnabled);
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &queryEvent);
+ QCOMPARE(queryEvent.value(Qt::ImEnabled).toBool(), true);
+
+ edit->setReadOnly(true);
+ QGuiApplication::sendEvent(edit, &queryEvent);
+ QCOMPARE(queryEvent.value(Qt::ImEnabled).toBool(), false);
+}
+
+void tst_qquicktextedit::inputMethodUpdate()
+{
+ PlatformInputContext platformInputContext;
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &platformInputContext;
+
+ QQuickView view(testFileUrl("inputMethodEvent.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
+ QVERIFY(edit);
+ QVERIFY(edit->hasActiveFocus() == true);
+
+ // text change even without cursor position change needs to trigger update
+ edit->setText("test");
+ platformInputContext.clear();
+ edit->setText("xxxx");
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // input method event replacing text
+ platformInputContext.clear();
+ {
+ QInputMethodEvent inputMethodEvent;
+ inputMethodEvent.setCommitString("y", -1, 1);
+ QGuiApplication::sendEvent(edit, &inputMethodEvent);
+ }
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // input method changing selection
+ platformInputContext.clear();
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 2, QVariant());
+ QInputMethodEvent inputMethodEvent("", attributes);
+ QGuiApplication::sendEvent(edit, &inputMethodEvent);
+ }
+ QVERIFY(edit->selectionStart() != edit->selectionEnd());
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // font changes
+ platformInputContext.clear();
+ QFont font = edit->font();
+ font.setBold(!font.bold());
+ edit->setFont(font);
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // normal input
+ platformInputContext.clear();
+ {
+ QInputMethodEvent inputMethodEvent;
+ inputMethodEvent.setCommitString("y");
+ QGuiApplication::sendEvent(edit, &inputMethodEvent);
+ }
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // changing cursor position
+ platformInputContext.clear();
+ edit->setCursorPosition(0);
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // continuing with selection
+ platformInputContext.clear();
+ edit->moveCursorSelection(1);
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // read only disabled input method
+ platformInputContext.clear();
+ edit->setReadOnly(true);
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+ edit->setReadOnly(false);
+
+ // no updates while no focus
+ edit->setFocus(false);
+ platformInputContext.clear();
+ edit->setText("Foo");
+ QCOMPARE(platformInputContext.m_updateCallCount, 0);
+ edit->setCursorPosition(1);
+ QCOMPARE(platformInputContext.m_updateCallCount, 0);
+ edit->selectAll();
+ QCOMPARE(platformInputContext.m_updateCallCount, 0);
+ edit->setReadOnly(true);
+ QCOMPARE(platformInputContext.m_updateCallCount, 0);
+}
+
+void tst_qquicktextedit::openInputPanel()
+{
+ PlatformInputContext platformInputContext;
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &platformInputContext;
+
+ QQuickView view(testFileUrl("openInputPanel.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+
+ QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
+ QVERIFY(edit);
+
+ // check default values
+ QVERIFY(edit->focusOnPress());
+ QVERIFY(!edit->hasActiveFocus());
+ qDebug() << &edit << qApp->focusObject();
+ QVERIFY(qApp->focusObject() != edit);
+
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+
+ // input panel should open on focus
+ QPoint centerPoint(view.width()/2, view.height()/2);
+ Qt::KeyboardModifiers noModifiers = 0;
+ QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QGuiApplication::processEvents();
+ QVERIFY(edit->hasActiveFocus());
+ QCOMPARE(qApp->focusObject(), edit);
+ QCOMPARE(qApp->inputMethod()->visible(), true);
+ QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
+
+ // input panel should be re-opened when pressing already focused TextEdit
+ qApp->inputMethod()->hide();
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+ QVERIFY(edit->hasActiveFocus());
+ QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QGuiApplication::processEvents();
+ QCOMPARE(qApp->inputMethod()->visible(), true);
+ QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
+
+ // input panel should stay visible if focus is lost to another text editor
+ QSignalSpy inputPanelVisibilitySpy(qApp->inputMethod(), SIGNAL(visibleChanged()));
+ QQuickTextEdit anotherEdit;
+ anotherEdit.setParentItem(view.rootObject());
+ anotherEdit.setFocus(true);
+ QCOMPARE(qApp->inputMethod()->visible(), true);
+ QCOMPARE(qApp->focusObject(), qobject_cast<QObject*>(&anotherEdit));
+ QCOMPARE(inputPanelVisibilitySpy.count(), 0);
+
+ anotherEdit.setFocus(false);
+ QVERIFY(qApp->focusObject() != &anotherEdit);
+ QCOMPARE(view.activeFocusItem(), view.rootItem());
+ anotherEdit.setFocus(true);
+
+ qApp->inputMethod()->hide();
+
+ // input panel should not be opened if TextEdit is read only
+ edit->setReadOnly(true);
+ edit->setFocus(true);
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+ QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QGuiApplication::processEvents();
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+
+ // input panel should not be opened if focusOnPress is set to false
+ edit->setFocusOnPress(false);
+ edit->setFocus(false);
+ edit->setFocus(true);
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+ QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+
+ // input panel should open when openSoftwareInputPanel is called
+ edit->openSoftwareInputPanel();
+ QCOMPARE(qApp->inputMethod()->visible(), true);
+
+ // input panel should close when closeSoftwareInputPanel is called
+ edit->closeSoftwareInputPanel();
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+
+ inputMethodPrivate->testContext = 0;
+}
+
+void tst_qquicktextedit::geometrySignals()
+{
+ QQmlComponent component(&engine, testFileUrl("geometrySignals.qml"));
+ QObject *o = component.create();
+ QVERIFY(o);
+ QCOMPARE(o->property("bindingWidth").toInt(), 400);
+ QCOMPARE(o->property("bindingHeight").toInt(), 500);
+ delete o;
+}
+
+void tst_qquicktextedit::pastingRichText_QTBUG_14003()
+{
+#ifndef QT_NO_CLIPBOARD
+ QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.PlainText }";
+ QQmlComponent component(&engine);
+ component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickTextEdit *obj = qobject_cast<QQuickTextEdit*>(component.create());
+
+ QTRY_VERIFY(obj != 0);
+ QTRY_VERIFY(obj->textFormat() == QQuickTextEdit::PlainText);
+
+ QMimeData *mData = new QMimeData;
+ mData->setHtml("<font color=\"red\">Hello</font>");
+ QGuiApplication::clipboard()->setMimeData(mData);
+
+ obj->paste();
+ QTRY_VERIFY(obj->text() == "");
+ QTRY_VERIFY(obj->textFormat() == QQuickTextEdit::PlainText);
+#endif
+}
+
+void tst_qquicktextedit::implicitSize_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("wrap");
+ QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.NoWrap";
+ QTest::newRow("richtext") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "TextEdit.NoWrap";
+ QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.Wrap";
+ QTest::newRow("richtext_wrap") << "<b>The quick red fox jumped over the lazy brown dog</b>" << "TextEdit.Wrap";
+}
+
+void tst_qquicktextedit::implicitSize()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, wrap);
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\"; width: 50; wrapMode: " + wrap + " }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
+
+ QVERIFY(textObject->width() < textObject->implicitWidth());
+ QVERIFY(textObject->height() == textObject->implicitHeight());
+
+ textObject->resetWidth();
+ QVERIFY(textObject->width() == textObject->implicitWidth());
+ QVERIFY(textObject->height() == textObject->implicitHeight());
+}
+
+void tst_qquicktextedit::contentSize()
+{
+ QString componentStr = "import QtQuick 2.0\nTextEdit { width: 75; height: 16; font.pixelSize: 10 }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> object(textComponent.create());
+ QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit *>(object.data());
+
+ QSignalSpy spy(textObject, SIGNAL(contentSizeChanged()));
+
+ textObject->setText("The quick red fox jumped over the lazy brown dog");
+
+ QVERIFY(textObject->contentWidth() > textObject->width());
+ QVERIFY(textObject->contentHeight() < textObject->height());
+ QCOMPARE(spy.count(), 1);
+
+ textObject->setWrapMode(QQuickTextEdit::WordWrap);
+ QVERIFY(textObject->contentWidth() <= textObject->width());
+ QVERIFY(textObject->contentHeight() > textObject->height());
+ QCOMPARE(spy.count(), 2);
+
+ textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
+
+ QVERIFY(textObject->contentWidth() > textObject->width());
+ QVERIFY(textObject->contentHeight() > textObject->height());
+ QCOMPARE(spy.count(), 3);
+}
+
+void tst_qquicktextedit::preeditCursorRectangle()
+{
+ QString preeditText = "super";
+
+ QQuickView view(testFileUrl("inputMethodEvent.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
+ QVERIFY(edit);
+
+ QSignalSpy editSpy(edit, SIGNAL(cursorRectangleChanged()));
+ QSignalSpy panelSpy(qGuiApp->inputMethod(), SIGNAL(cursorRectangleChanged()));
+
+ QRect currentRect;
+
+ QInputMethodQueryEvent query(Qt::ImCursorRectangle);
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ QRect previousRect = query.value(Qt::ImCursorRectangle).toRect();
+
+ // Verify that the micro focus rect is positioned the same for position 0 as
+ // it would be if there was no preedit text.
+ QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>()
+ << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, preeditText.length(), QVariant()));
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ currentRect = query.value(Qt::ImCursorRectangle).toRect();
+ QCOMPARE(currentRect, previousRect);
+ QCOMPARE(editSpy.count(), 0);
+ QCOMPARE(panelSpy.count(), 0);
+
+ // Verify that the micro focus rect moves to the left as the cursor position
+ // is incremented.
+ for (int i = 1; i <= 5; ++i) {
+ QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>()
+ << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, preeditText.length(), QVariant()));
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ currentRect = query.value(Qt::ImCursorRectangle).toRect();
+ QVERIFY(previousRect.left() < currentRect.left());
+ QVERIFY(editSpy.count() > 0); editSpy.clear();
+ QVERIFY(panelSpy.count() > 0); panelSpy.clear();
+ previousRect = currentRect;
+ }
+
+ // Verify that if there is no preedit cursor then the micro focus rect is the
+ // same as it would be if it were positioned at the end of the preedit text.
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
+ editSpy.clear();
+ panelSpy.clear();
+ { QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>());
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent); }
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ currentRect = query.value(Qt::ImCursorRectangle).toRect();
+ QCOMPARE(currentRect, previousRect);
+ QVERIFY(editSpy.count() > 0);
+ QVERIFY(panelSpy.count() > 0);
+}
+
+void tst_qquicktextedit::inputMethodComposing()
+{
+ QString text = "supercalifragisiticexpialidocious!";
+
+ QQuickView view(testFileUrl("inputContext.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
+ QVERIFY(edit);
+ QSignalSpy spy(edit, SIGNAL(inputMethodComposingChanged()));
+ edit->setCursorPosition(12);
+
+ QCOMPARE(edit->isInputMethodComposing(), false);
+
+ {
+ QInputMethodEvent event(text.mid(3), QList<QInputMethodEvent::Attribute>());
+ QGuiApplication::sendEvent(edit, &event);
+ }
+
+ QCOMPARE(edit->isInputMethodComposing(), true);
+ QCOMPARE(spy.count(), 1);
+
+ {
+ QInputMethodEvent event(text.mid(12), QList<QInputMethodEvent::Attribute>());
+ QGuiApplication::sendEvent(edit, &event);
+ }
+ QCOMPARE(spy.count(), 1);
+
+ {
+ QInputMethodEvent event;
+ QGuiApplication::sendEvent(edit, &event);
+ }
+ QCOMPARE(edit->isInputMethodComposing(), false);
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktextedit::cursorRectangleSize()
+{
+ QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml"));
+ QVERIFY(canvas->rootObject() != 0);
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit *>(canvas->rootObject());
+
+ // make sure cursor rectangle is not at (0,0)
+ textEdit->setX(10);
+ textEdit->setY(10);
+ textEdit->setCursorPosition(3);
+ QVERIFY(textEdit != 0);
+ textEdit->setFocus(true);
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+
+ QInputMethodQueryEvent event(Qt::ImCursorRectangle);
+ qApp->sendEvent(qApp->focusObject(), &event);
+ QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF();
+
+ QRect cursorRectFromItem = textEdit->cursorRectangle();
+ QRectF cursorRectFromPositionToRectangle = textEdit->positionToRectangle(textEdit->cursorPosition());
+
+ // item and input query cursor rectangles match
+ QCOMPARE(cursorRectFromItem, cursorRectFromQuery.toRect());
+
+ // item cursor rectangle and positionToRectangle calculations match
+ QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle.toRect());
+
+ // item-canvas transform and input item transform match
+ QCOMPARE(QQuickItemPrivate::get(textEdit)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform());
+
+ // input panel cursorRectangle property and tranformed item cursor rectangle match
+ QRectF sceneCursorRect = QQuickItemPrivate::get(textEdit)->itemToCanvasTransform().mapRect(cursorRectFromItem);
+ QCOMPARE(sceneCursorRect, qApp->inputMethod()->cursorRectangle());
+
+ delete canvas;
+}
+
+void tst_qquicktextedit::getText_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<int>("start");
+ QTest::addColumn<int>("end");
+ QTest::addColumn<QString>("expectedText");
+
+ const QString richBoldText = QStringLiteral("This is some <b>bold</b> text");
+ const QString plainBoldText = QStringLiteral("This is some bold text");
+
+ QTest::newRow("all plain text")
+ << standard.at(0)
+ << 0 << standard.at(0).length()
+ << standard.at(0);
+
+ QTest::newRow("plain text sub string")
+ << standard.at(0)
+ << 0 << 12
+ << standard.at(0).mid(0, 12);
+
+ QTest::newRow("plain text sub string reversed")
+ << standard.at(0)
+ << 12 << 0
+ << standard.at(0).mid(0, 12);
+
+ QTest::newRow("plain text cropped beginning")
+ << standard.at(0)
+ << -3 << 4
+ << standard.at(0).mid(0, 4);
+
+ QTest::newRow("plain text cropped end")
+ << standard.at(0)
+ << 23 << standard.at(0).length() + 8
+ << standard.at(0).mid(23);
+
+ QTest::newRow("plain text cropped beginning and end")
+ << standard.at(0)
+ << -9 << standard.at(0).length() + 4
+ << standard.at(0);
+
+ QTest::newRow("all rich text")
+ << richBoldText
+ << 0 << plainBoldText.length()
+ << plainBoldText;
+
+ QTest::newRow("rich text sub string")
+ << richBoldText
+ << 14 << 21
+ << plainBoldText.mid(14, 7);
+}
+
+void tst_qquicktextedit::getText()
+{
+ QFETCH(QString, text);
+ QFETCH(int, start);
+ QFETCH(int, end);
+ QFETCH(QString, expectedText);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { textFormat: TextEdit.AutoText; text: \"" + text + "\" }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ QCOMPARE(textEdit->getText(start, end), expectedText);
+}
+
+void tst_qquicktextedit::getFormattedText_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QQuickTextEdit::TextFormat>("textFormat");
+ QTest::addColumn<int>("start");
+ QTest::addColumn<int>("end");
+ QTest::addColumn<QString>("expectedText");
+
+ const QString richBoldText = QStringLiteral("This is some <b>bold</b> text");
+ const QString plainBoldText = QStringLiteral("This is some bold text");
+
+ QTest::newRow("all plain text")
+ << standard.at(0)
+ << QQuickTextEdit::PlainText
+ << 0 << standard.at(0).length()
+ << standard.at(0);
+
+ QTest::newRow("plain text sub string")
+ << standard.at(0)
+ << QQuickTextEdit::PlainText
+ << 0 << 12
+ << standard.at(0).mid(0, 12);
+
+ QTest::newRow("plain text sub string reversed")
+ << standard.at(0)
+ << QQuickTextEdit::PlainText
+ << 12 << 0
+ << standard.at(0).mid(0, 12);
+
+ QTest::newRow("plain text cropped beginning")
+ << standard.at(0)
+ << QQuickTextEdit::PlainText
+ << -3 << 4
+ << standard.at(0).mid(0, 4);
+
+ QTest::newRow("plain text cropped end")
+ << standard.at(0)
+ << QQuickTextEdit::PlainText
+ << 23 << standard.at(0).length() + 8
+ << standard.at(0).mid(23);
+
+ QTest::newRow("plain text cropped beginning and end")
+ << standard.at(0)
+ << QQuickTextEdit::PlainText
+ << -9 << standard.at(0).length() + 4
+ << standard.at(0);
+
+ QTest::newRow("all rich (Auto) text")
+ << richBoldText
+ << QQuickTextEdit::AutoText
+ << 0 << plainBoldText.length()
+ << QString("This is some \\<.*\\>bold\\</.*\\> text");
+
+ QTest::newRow("all rich (Rich) text")
+ << richBoldText
+ << QQuickTextEdit::RichText
+ << 0 << plainBoldText.length()
+ << QString("This is some \\<.*\\>bold\\</.*\\> text");
+
+ QTest::newRow("all rich (Plain) text")
+ << richBoldText
+ << QQuickTextEdit::PlainText
+ << 0 << richBoldText.length()
+ << richBoldText;
+
+ QTest::newRow("rich (Auto) text sub string")
+ << richBoldText
+ << QQuickTextEdit::AutoText
+ << 14 << 21
+ << QString("\\<.*\\>old\\</.*\\> tex");
+
+ QTest::newRow("rich (Rich) text sub string")
+ << richBoldText
+ << QQuickTextEdit::RichText
+ << 14 << 21
+ << QString("\\<.*\\>old\\</.*\\> tex");
+
+ QTest::newRow("rich (Plain) text sub string")
+ << richBoldText
+ << QQuickTextEdit::PlainText
+ << 17 << 27
+ << richBoldText.mid(17, 10);
+}
+
+void tst_qquicktextedit::getFormattedText()
+{
+ QFETCH(QString, text);
+ QFETCH(QQuickTextEdit::TextFormat, textFormat);
+ QFETCH(int, start);
+ QFETCH(int, end);
+ QFETCH(QString, expectedText);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit {}";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ textEdit->setTextFormat(textFormat);
+ textEdit->setText(text);
+
+ if (textFormat == QQuickTextEdit::RichText
+ || (textFormat == QQuickTextEdit::AutoText && Qt::mightBeRichText(text))) {
+ QVERIFY(textEdit->getFormattedText(start, end).contains(QRegExp(expectedText)));
+ } else {
+ QCOMPARE(textEdit->getFormattedText(start, end), expectedText);
+ }
+}
+
+void tst_qquicktextedit::insert_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QQuickTextEdit::TextFormat>("textFormat");
+ QTest::addColumn<int>("selectionStart");
+ QTest::addColumn<int>("selectionEnd");
+ QTest::addColumn<int>("insertPosition");
+ QTest::addColumn<QString>("insertText");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<int>("expectedSelectionStart");
+ QTest::addColumn<int>("expectedSelectionEnd");
+ QTest::addColumn<int>("expectedCursorPosition");
+ QTest::addColumn<bool>("selectionChanged");
+ QTest::addColumn<bool>("cursorPositionChanged");
+
+ QTest::newRow("at cursor position (beginning)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0 << 0
+ << QString("Hello")
+ << QString("Hello") + standard.at(0)
+ << 5 << 5 << 5
+ << false << true;
+
+ QTest::newRow("at cursor position (end)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << standard.at(0).length() << standard.at(0).length() << standard.at(0).length()
+ << QString("Hello")
+ << standard.at(0) + QString("Hello")
+ << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
+ << false << true;
+
+ QTest::newRow("at cursor position (middle)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 18 << 18 << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << 23 << 23 << 23
+ << false << true;
+
+ QTest::newRow("after cursor position (beginning)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0 << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("before cursor position (end)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << standard.at(0).length() << standard.at(0).length() << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
+ << false << true;
+
+ QTest::newRow("before cursor position (middle)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 18 << 18 << 0
+ << QString("Hello")
+ << QString("Hello") + standard.at(0)
+ << 23 << 23 << 23
+ << false << true;
+
+ QTest::newRow("after cursor position (middle)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 18 << 18 << standard.at(0).length()
+ << QString("Hello")
+ << standard.at(0) + QString("Hello")
+ << 18 << 18 << 18
+ << false << false;
+
+ QTest::newRow("before selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 14 << 19 << 0
+ << QString("Hello")
+ << QString("Hello") + standard.at(0)
+ << 19 << 24 << 24
+ << false << true;
+
+ QTest::newRow("before reversed selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 19 << 14 << 0
+ << QString("Hello")
+ << QString("Hello") + standard.at(0)
+ << 19 << 24 << 19
+ << false << true;
+
+ QTest::newRow("after selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 14 << 19 << standard.at(0).length()
+ << QString("Hello")
+ << standard.at(0) + QString("Hello")
+ << 14 << 19 << 19
+ << false << false;
+
+ QTest::newRow("after reversed selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 19 << 14 << standard.at(0).length()
+ << QString("Hello")
+ << standard.at(0) + QString("Hello")
+ << 14 << 19 << 14
+ << false << false;
+
+ QTest::newRow("into selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 14 << 19 << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << 14 << 24 << 24
+ << true << true;
+
+ QTest::newRow("into reversed selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 19 << 14 << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << 14 << 24 << 14
+ << true << false;
+
+ QTest::newRow("rich text into plain text")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0 << 0
+ << QString("<b>Hello</b>")
+ << QString("<b>Hello</b>") + standard.at(0)
+ << 12 << 12 << 12
+ << false << true;
+
+ QTest::newRow("rich text into rich text")
+ << standard.at(0) << QQuickTextEdit::RichText
+ << 0 << 0 << 0
+ << QString("<b>Hello</b>")
+ << QString("Hello") + standard.at(0)
+ << 5 << 5 << 5
+ << false << true;
+
+ QTest::newRow("rich text into auto text")
+ << standard.at(0) << QQuickTextEdit::AutoText
+ << 0 << 0 << 0
+ << QString("<b>Hello</b>")
+ << QString("Hello") + standard.at(0)
+ << 5 << 5 << 5
+ << false << true;
+
+ QTest::newRow("before start")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0 << -3
+ << QString("Hello")
+ << standard.at(0)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("past end")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0 << standard.at(0).length() + 3
+ << QString("Hello")
+ << standard.at(0)
+ << 0 << 0 << 0
+ << false << false;
+}
+
+void tst_qquicktextedit::insert()
+{
+ QFETCH(QString, text);
+ QFETCH(QQuickTextEdit::TextFormat, textFormat);
+ QFETCH(int, selectionStart);
+ QFETCH(int, selectionEnd);
+ QFETCH(int, insertPosition);
+ QFETCH(QString, insertText);
+ QFETCH(QString, expectedText);
+ QFETCH(int, expectedSelectionStart);
+ QFETCH(int, expectedSelectionEnd);
+ QFETCH(int, expectedCursorPosition);
+ QFETCH(bool, selectionChanged);
+ QFETCH(bool, cursorPositionChanged);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\" }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ textEdit->setTextFormat(textFormat);
+ textEdit->select(selectionStart, selectionEnd);
+
+ QSignalSpy selectionSpy(textEdit, SIGNAL(selectionChanged()));
+ QSignalSpy selectionStartSpy(textEdit, SIGNAL(selectionStartChanged()));
+ QSignalSpy selectionEndSpy(textEdit, SIGNAL(selectionEndChanged()));
+ QSignalSpy textSpy(textEdit, SIGNAL(textChanged()));
+ QSignalSpy cursorPositionSpy(textEdit, SIGNAL(cursorPositionChanged()));
+
+ textEdit->insert(insertPosition, insertText);
+
+ if (textFormat == QQuickTextEdit::RichText || (textFormat == QQuickTextEdit::AutoText && (
+ Qt::mightBeRichText(text) || Qt::mightBeRichText(insertText)))) {
+ QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText);
+ } else {
+ QCOMPARE(textEdit->text(), expectedText);
+
+ }
+ QCOMPARE(textEdit->length(), expectedText.length());
+
+ QCOMPARE(textEdit->selectionStart(), expectedSelectionStart);
+ QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd);
+ QCOMPARE(textEdit->cursorPosition(), expectedCursorPosition);
+
+ if (selectionStart > selectionEnd)
+ qSwap(selectionStart, selectionEnd);
+
+ QEXPECT_FAIL("into selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
+ QEXPECT_FAIL("into reversed selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
+ QCOMPARE(selectionSpy.count() > 0, selectionChanged);
+ QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
+ QEXPECT_FAIL("into reversed selection", "selectionEndChanged signal not emitted", Continue);
+ QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
+ QCOMPARE(textSpy.count() > 0, text != expectedText);
+ QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
+}
+
+void tst_qquicktextedit::remove_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QQuickTextEdit::TextFormat>("textFormat");
+ QTest::addColumn<int>("selectionStart");
+ QTest::addColumn<int>("selectionEnd");
+ QTest::addColumn<int>("removeStart");
+ QTest::addColumn<int>("removeEnd");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<int>("expectedSelectionStart");
+ QTest::addColumn<int>("expectedSelectionEnd");
+ QTest::addColumn<int>("expectedCursorPosition");
+ QTest::addColumn<bool>("selectionChanged");
+ QTest::addColumn<bool>("cursorPositionChanged");
+
+ const QString richBoldText = QStringLiteral("This is some <b>bold</b> text");
+ const QString plainBoldText = QStringLiteral("This is some bold text");
+
+ QTest::newRow("from cursor position (beginning)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0
+ << 0 << 5
+ << standard.at(0).mid(5)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("to cursor position (beginning)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0
+ << 5 << 0
+ << standard.at(0).mid(5)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("to cursor position (end)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << standard.at(0).length() << standard.at(0).length()
+ << standard.at(0).length() << standard.at(0).length() - 5
+ << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << false << true;
+
+ QTest::newRow("to cursor position (end)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << standard.at(0).length() << standard.at(0).length()
+ << standard.at(0).length() - 5 << standard.at(0).length()
+ << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << false << true;
+
+ QTest::newRow("from cursor position (middle)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 18 << 18
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 18 << 18 << 18
+ << false << false;
+
+ QTest::newRow("to cursor position (middle)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 23 << 23
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 18 << 18 << 18
+ << false << true;
+
+ QTest::newRow("after cursor position (beginning)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("before cursor position (end)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << standard.at(0).length() << standard.at(0).length()
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << false << true;
+
+ QTest::newRow("before cursor position (middle)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 23 << 23
+ << 0 << 5
+ << standard.at(0).mid(5)
+ << 18 << 18 << 18
+ << false << true;
+
+ QTest::newRow("after cursor position (middle)")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 18 << 18
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 18 << 18 << 18
+ << false << false;
+
+ QTest::newRow("before selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 14 << 19
+ << 0 << 5
+ << standard.at(0).mid(5)
+ << 9 << 14 << 14
+ << false << true;
+
+ QTest::newRow("before reversed selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 19 << 14
+ << 0 << 5
+ << standard.at(0).mid(5)
+ << 9 << 14 << 9
+ << false << true;
+
+ QTest::newRow("after selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 14 << 19
+ << standard.at(0).length() - 5 << standard.at(0).length()
+ << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << 14 << 19 << 19
+ << false << false;
+
+ QTest::newRow("after reversed selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 19 << 14
+ << standard.at(0).length() - 5 << standard.at(0).length()
+ << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << 14 << 19 << 14
+ << false << false;
+
+ QTest::newRow("from selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 14 << 24
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 14 << 19 << 19
+ << true << true;
+
+ QTest::newRow("from reversed selection")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 24 << 14
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 14 << 19 << 14
+ << true << false;
+
+ QTest::newRow("plain text cropped beginning")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0
+ << -3 << 4
+ << standard.at(0).mid(4)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("plain text cropped end")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0
+ << 23 << standard.at(0).length() + 8
+ << standard.at(0).mid(0, 23)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("plain text cropped beginning and end")
+ << standard.at(0) << QQuickTextEdit::PlainText
+ << 0 << 0
+ << -9 << standard.at(0).length() + 4
+ << QString()
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("all rich text")
+ << richBoldText << QQuickTextEdit::RichText
+ << 0 << 0
+ << 0 << plainBoldText.length()
+ << QString()
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("rick text sub string")
+ << richBoldText << QQuickTextEdit::RichText
+ << 0 << 0
+ << 14 << 21
+ << plainBoldText.mid(0, 14) + plainBoldText.mid(21)
+ << 0 << 0 << 0
+ << false << false;
+}
+
+void tst_qquicktextedit::remove()
+{
+ QFETCH(QString, text);
+ QFETCH(QQuickTextEdit::TextFormat, textFormat);
+ QFETCH(int, selectionStart);
+ QFETCH(int, selectionEnd);
+ QFETCH(int, removeStart);
+ QFETCH(int, removeEnd);
+ QFETCH(QString, expectedText);
+ QFETCH(int, expectedSelectionStart);
+ QFETCH(int, expectedSelectionEnd);
+ QFETCH(int, expectedCursorPosition);
+ QFETCH(bool, selectionChanged);
+ QFETCH(bool, cursorPositionChanged);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { text: \"" + text + "\" }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ textEdit->setTextFormat(textFormat);
+ textEdit->select(selectionStart, selectionEnd);
+
+ QSignalSpy selectionSpy(textEdit, SIGNAL(selectionChanged()));
+ QSignalSpy selectionStartSpy(textEdit, SIGNAL(selectionStartChanged()));
+ QSignalSpy selectionEndSpy(textEdit, SIGNAL(selectionEndChanged()));
+ QSignalSpy textSpy(textEdit, SIGNAL(textChanged()));
+ QSignalSpy cursorPositionSpy(textEdit, SIGNAL(cursorPositionChanged()));
+
+ textEdit->remove(removeStart, removeEnd);
+
+ if (textFormat == QQuickTextEdit::RichText
+ || (textFormat == QQuickTextEdit::AutoText && Qt::mightBeRichText(text))) {
+ QCOMPARE(textEdit->getText(0, expectedText.length()), expectedText);
+ } else {
+ QCOMPARE(textEdit->text(), expectedText);
+ }
+ QCOMPARE(textEdit->length(), expectedText.length());
+
+ if (selectionStart > selectionEnd) //
+ qSwap(selectionStart, selectionEnd);
+
+ QCOMPARE(textEdit->selectionStart(), expectedSelectionStart);
+ QCOMPARE(textEdit->selectionEnd(), expectedSelectionEnd);
+ QCOMPARE(textEdit->cursorPosition(), expectedCursorPosition);
+
+ QEXPECT_FAIL("from selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
+ QEXPECT_FAIL("from reversed selection", "selectionChanged signal isn't emitted on edits within selection", Continue);
+ QCOMPARE(selectionSpy.count() > 0, selectionChanged);
+ QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
+ QEXPECT_FAIL("from reversed selection", "selectionEndChanged signal not emitted", Continue);
+ QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
+ QCOMPARE(textSpy.count() > 0, text != expectedText);
+
+
+ if (cursorPositionChanged) //
+ QVERIFY(cursorPositionSpy.count() > 0);
+}
+
+
+void tst_qquicktextedit::keySequence_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QKeySequence>("sequence");
+ QTest::addColumn<int>("selectionStart");
+ QTest::addColumn<int>("selectionEnd");
+ QTest::addColumn<int>("cursorPosition");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<QString>("selectedText");
+
+ // standard[0] == "the [4]quick [10]brown [16]fox [20]jumped [27]over [32]the [36]lazy [41]dog"
+
+ QTest::newRow("select all")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectAll) << 0 << 0
+ << 44 << standard.at(0) << standard.at(0);
+ QTest::newRow("select end of line")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfLine) << 5 << 5
+ << 44 << standard.at(0) << standard.at(0).mid(5);
+ QTest::newRow("select end of document")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfDocument) << 3 << 3
+ << 44 << standard.at(0) << standard.at(0).mid(3);
+ QTest::newRow("select end of block")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfBlock) << 18 << 18
+ << 44 << standard.at(0) << standard.at(0).mid(18);
+ QTest::newRow("delete end of line")
+ << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfLine) << 24 << 24
+ << 24 << standard.at(0).mid(0, 24) << QString();
+ QTest::newRow("move to start of line")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfLine) << 31 << 31
+ << 0 << standard.at(0) << QString();
+ QTest::newRow("move to start of block")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfBlock) << 25 << 25
+ << 0 << standard.at(0) << QString();
+ QTest::newRow("move to next char")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToNextChar) << 12 << 12
+ << 13 << standard.at(0) << QString();
+ QTest::newRow("move to previous char")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 3
+ << 2 << standard.at(0) << QString();
+ QTest::newRow("select next char")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectNextChar) << 23 << 23
+ << 24 << standard.at(0) << standard.at(0).mid(23, 1);
+ QTest::newRow("select previous char")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousChar) << 19 << 19
+ << 18 << standard.at(0) << standard.at(0).mid(18, 1);
+ QTest::newRow("move to next word")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7
+ << 10 << standard.at(0) << QString();
+ QTest::newRow("move to previous word")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7
+ << 4 << standard.at(0) << QString();
+ QTest::newRow("select previous word")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousWord) << 11 << 11
+ << 10 << standard.at(0) << standard.at(0).mid(10, 1);
+ QTest::newRow("delete (selection)")
+ << standard.at(0) << QKeySequence(QKeySequence::Delete) << 12 << 15
+ << 12 << (standard.at(0).mid(0, 12) + standard.at(0).mid(15)) << QString();
+ QTest::newRow("delete (no selection)")
+ << standard.at(0) << QKeySequence(QKeySequence::Delete) << 15 << 15
+ << 15 << (standard.at(0).mid(0, 15) + standard.at(0).mid(16)) << QString();
+ QTest::newRow("delete end of word")
+ << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfWord) << 24 << 24
+ << 24 << (standard.at(0).mid(0, 24) + standard.at(0).mid(27)) << QString();
+ QTest::newRow("delete start of word")
+ << standard.at(0) << QKeySequence(QKeySequence::DeleteStartOfWord) << 7 << 7
+ << 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString();
+}
+
+void tst_qquicktextedit::keySequence()
+{
+ QFETCH(QString, text);
+ QFETCH(QKeySequence, sequence);
+ QFETCH(int, selectionStart);
+ QFETCH(int, selectionEnd);
+ QFETCH(int, cursorPosition);
+ QFETCH(QString, expectedText);
+ QFETCH(QString, selectedText);
+
+ if (sequence.isEmpty()) {
+ QSKIP("Key sequence is undefined");
+ }
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true; text: \"" + text + "\" }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ QQuickCanvas canvas;
+ textEdit->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ textEdit->select(selectionStart, selectionEnd);
+
+ simulateKeys(&canvas, sequence);
+
+ QCOMPARE(textEdit->cursorPosition(), cursorPosition);
+ QCOMPARE(textEdit->text(), expectedText);
+ QCOMPARE(textEdit->selectedText(), selectedText);
+}
+
+#define NORMAL 0
+#define REPLACE_UNTIL_END 1
+
+void tst_qquicktextedit::undo_data()
+{
+ QTest::addColumn<QStringList>("insertString");
+ QTest::addColumn<IntList>("insertIndex");
+ QTest::addColumn<IntList>("insertMode");
+ QTest::addColumn<QStringList>("expectedString");
+ QTest::addColumn<bool>("use_keys");
+
+ for (int i=0; i<2; i++) {
+ QString keys_str = "keyboard";
+ bool use_keys = true;
+ if (i==0) {
+ keys_str = "insert";
+ use_keys = false;
+ }
+
+ {
+ IntList insertIndex;
+ IntList insertMode;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "1";
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "5";
+
+ insertIndex << 1;
+ insertMode << NORMAL;
+ insertString << "3";
+
+ insertIndex << 1;
+ insertMode << NORMAL;
+ insertString << "2";
+
+ insertIndex << 3;
+ insertMode << NORMAL;
+ insertString << "4";
+
+ expectedString << "12345";
+ expectedString << "1235";
+ expectedString << "135";
+ expectedString << "15";
+ expectedString << "";
+
+ QTest::newRow(QString(keys_str + "_numbers").toLatin1()) <<
+ insertString <<
+ insertIndex <<
+ insertMode <<
+ expectedString <<
+ bool(use_keys);
+ }
+ {
+ IntList insertIndex;
+ IntList insertMode;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "World"; // World
+
+ insertIndex << 0;
+ insertMode << NORMAL;
+ insertString << "Hello"; // HelloWorld
+
+ insertIndex << 0;
+ insertMode << NORMAL;
+ insertString << "Well"; // WellHelloWorld
+
+ insertIndex << 9;
+ insertMode << NORMAL;
+ insertString << "There"; // WellHelloThereWorld;
+
+ expectedString << "WellHelloThereWorld";
+ expectedString << "WellHelloWorld";
+ expectedString << "HelloWorld";
+ expectedString << "World";
+ expectedString << "";
+
+ QTest::newRow(QString(keys_str + "_helloworld").toLatin1()) <<
+ insertString <<
+ insertIndex <<
+ insertMode <<
+ expectedString <<
+ bool(use_keys);
+ }
+ {
+ IntList insertIndex;
+ IntList insertMode;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "Ensuring";
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << " instan";
+
+ insertIndex << 9;
+ insertMode << NORMAL;
+ insertString << "an ";
+
+ insertIndex << 10;
+ insertMode << REPLACE_UNTIL_END;
+ insertString << " unique instance.";
+
+ expectedString << "Ensuring a unique instance.";
+ expectedString << "Ensuring a "; // ### Not present in TextInput.
+ expectedString << "Ensuring an instan";
+ expectedString << "Ensuring instan";
+ expectedString << "";
+
+ QTest::newRow(QString(keys_str + "_patterns").toLatin1()) <<
+ insertString <<
+ insertIndex <<
+ insertMode <<
+ expectedString <<
+ bool(use_keys);
+ }
+ }
+}
+
+void tst_qquicktextedit::undo()
+{
+ QFETCH(QStringList, insertString);
+ QFETCH(IntList, insertIndex);
+ QFETCH(IntList, insertMode);
+ QFETCH(QStringList, expectedString);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ QQuickCanvas canvas;
+ textEdit->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ QVERIFY(!textEdit->canUndo());
+
+ QSignalSpy spy(textEdit, SIGNAL(canUndoChanged()));
+
+ int i;
+
+// STEP 1: First build up an undo history by inserting or typing some strings...
+ for (i = 0; i < insertString.size(); ++i) {
+ if (insertIndex[i] > -1)
+ textEdit->setCursorPosition(insertIndex[i]);
+
+ // experimental stuff
+ if (insertMode[i] == REPLACE_UNTIL_END) {
+ textEdit->select(insertIndex[i], insertIndex[i] + 8);
+
+ // This is what I actually want...
+ // QTest::keyClick(testWidget, Qt::Key_End, Qt::ShiftModifier);
+ }
+
+ for (int j = 0; j < insertString.at(i).length(); j++)
+ QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1());
+ }
+
+ QCOMPARE(spy.count(), 1);
+
+// STEP 2: Next call undo several times and see if we can restore to the previous state
+ for (i = 0; i < expectedString.size() - 1; ++i) {
+ QCOMPARE(textEdit->text(), expectedString[i]);
+ QVERIFY(textEdit->canUndo());
+ textEdit->undo();
+ }
+
+// STEP 3: Verify that we have undone everything
+ QVERIFY(textEdit->text().isEmpty());
+ QVERIFY(!textEdit->canUndo());
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktextedit::redo_data()
+{
+ QTest::addColumn<QStringList>("insertString");
+ QTest::addColumn<IntList>("insertIndex");
+ QTest::addColumn<QStringList>("expectedString");
+
+ {
+ IntList insertIndex;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertString << "World"; // World
+ insertIndex << 0;
+ insertString << "Hello"; // HelloWorld
+ insertIndex << 0;
+ insertString << "Well"; // WellHelloWorld
+ insertIndex << 9;
+ insertString << "There"; // WellHelloThereWorld;
+
+ expectedString << "World";
+ expectedString << "HelloWorld";
+ expectedString << "WellHelloWorld";
+ expectedString << "WellHelloThereWorld";
+
+ QTest::newRow("Inserts and setting cursor") << insertString << insertIndex << expectedString;
+ }
+}
+
+void tst_qquicktextedit::redo()
+{
+ QFETCH(QStringList, insertString);
+ QFETCH(IntList, insertIndex);
+ QFETCH(QStringList, expectedString);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ QQuickCanvas canvas;
+ textEdit->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ QVERIFY(!textEdit->canUndo());
+ QVERIFY(!textEdit->canRedo());
+
+ QSignalSpy spy(textEdit, SIGNAL(canRedoChanged()));
+
+ int i;
+ // inserts the diff strings at diff positions
+ for (i = 0; i < insertString.size(); ++i) {
+ if (insertIndex[i] > -1)
+ textEdit->setCursorPosition(insertIndex[i]);
+ for (int j = 0; j < insertString.at(i).length(); j++)
+ QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1());
+ QVERIFY(textEdit->canUndo());
+ QVERIFY(!textEdit->canRedo());
+ }
+
+ QCOMPARE(spy.count(), 0);
+
+ // undo everything
+ while (!textEdit->text().isEmpty()) {
+ QVERIFY(textEdit->canUndo());
+ textEdit->undo();
+ QVERIFY(textEdit->canRedo());
+ }
+
+ QCOMPARE(spy.count(), 1);
+
+ for (i = 0; i < expectedString.size(); ++i) {
+ QVERIFY(textEdit->canRedo());
+ textEdit->redo();
+ QCOMPARE(textEdit->text() , expectedString[i]);
+ QVERIFY(textEdit->canUndo());
+ }
+ QVERIFY(!textEdit->canRedo());
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktextedit::undo_keypressevents_data()
+{
+ QTest::addColumn<KeyList>("keys");
+ QTest::addColumn<QStringList>("expectedString");
+
+ {
+ KeyList keys;
+ QStringList expectedString;
+
+ keys << "AFRAID"
+ << Qt::Key_Home
+ << "VERY"
+ << Qt::Key_Left
+ << Qt::Key_Left
+ << Qt::Key_Left
+ << Qt::Key_Left
+ << "BE"
+ << Qt::Key_End
+ << "!";
+
+ expectedString << "BEVERYAFRAID!";
+ expectedString << "BEVERYAFRAID";
+ expectedString << "VERYAFRAID";
+ expectedString << "AFRAID";
+
+ QTest::newRow("Inserts and moving cursor") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting '1234'
+ keys << "1234" << Qt::Key_Home
+ // skipping '12'
+ << Qt::Key_Right << Qt::Key_Right
+ // selecting '34'
+ << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
+ // deleting '34'
+ << Qt::Key_Delete;
+
+ expectedString << "12";
+ expectedString << "1234";
+
+ QTest::newRow("Inserts,moving,selection and delete") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting 'AB12'
+ keys << "AB12"
+ << Qt::Key_Home
+ // selecting 'AB'
+ << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
+ << Qt::Key_Delete
+ << QKeySequence::Undo
+ // ### Text is selected in text input
+// << Qt::Key_Right
+ << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
+ << Qt::Key_Delete;
+
+ expectedString << "AB";
+ expectedString << "AB12";
+
+ QTest::newRow("Inserts,moving,selection, delete and undo") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting 'ABCD'
+ keys << "abcd"
+ //move left two
+ << Qt::Key_Left << Qt::Key_Left
+ // inserting '1234'
+ << "1234"
+ // selecting '1234'
+ << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier)
+ // overwriting '1234' with '5'
+ << "5"
+ // undoing deletion of 'AB'
+ << QKeySequence::Undo
+ // ### Text is selected in text input
+ << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier)
+ // overwriting '1234' with '6'
+ << "6";
+
+ expectedString << "ab6cd";
+ // for versions previous to 3.2 we overwrite needed two undo operations
+ expectedString << "ab1234cd";
+ expectedString << "abcd";
+
+ QTest::newRow("Inserts,moving,selection and undo, removing selection") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting 'ABC'
+ keys << "ABC"
+ // removes 'C'
+ << Qt::Key_Backspace;
+
+ expectedString << "AB";
+ expectedString << "ABC";
+
+ QTest::newRow("Inserts,backspace") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ keys << "ABC"
+ // removes 'C'
+ << Qt::Key_Backspace
+ // inserting 'Z'
+ << "Z";
+
+ expectedString << "ABZ";
+ expectedString << "AB";
+ expectedString << "ABC";
+
+ QTest::newRow("Inserts,backspace,inserts") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting '123'
+ keys << "123" << Qt::Key_Home
+ // selecting '123'
+ << (Qt::Key_End | Qt::ShiftModifier)
+ // overwriting '123' with 'ABC'
+ << "ABC";
+
+ expectedString << "ABC";
+ // ### One operation in TextInput.
+ expectedString << "A";
+ expectedString << "123";
+
+ QTest::newRow("Inserts,moving,selection and overwriting") << keys << expectedString;
+ }
+}
+
+void tst_qquicktextedit::undo_keypressevents()
+{
+ QFETCH(KeyList, keys);
+ QFETCH(QStringList, expectedString);
+
+ QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }";
+ QQmlComponent textEditComponent(&engine);
+ textEditComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit*>(textEditComponent.create());
+ QVERIFY(textEdit != 0);
+
+ QQuickCanvas canvas;
+ textEdit->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ simulateKeys(&canvas, keys);
+
+ for (int i = 0; i < expectedString.size(); ++i) {
+ QCOMPARE(textEdit->text() , expectedString[i]);
+ textEdit->undo();
+ }
+ QVERIFY(textEdit->text().isEmpty());
+}
+
+void tst_qquicktextedit::baseUrl()
+{
+ QUrl localUrl("file:///tests/text.qml");
+ QUrl remoteUrl("http://qt.nokia.com/test.qml");
+
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\n TextEdit {}", localUrl);
+ QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit *>(textComponent.create());
+
+ QCOMPARE(textObject->baseUrl(), localUrl);
+
+ QSignalSpy spy(textObject, SIGNAL(baseUrlChanged()));
+
+ textObject->setBaseUrl(localUrl);
+ QCOMPARE(textObject->baseUrl(), localUrl);
+ QCOMPARE(spy.count(), 0);
+
+ textObject->setBaseUrl(remoteUrl);
+ QCOMPARE(textObject->baseUrl(), remoteUrl);
+ QCOMPARE(spy.count(), 1);
+
+ textObject->resetBaseUrl();
+ QCOMPARE(textObject->baseUrl(), localUrl);
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktextedit::embeddedImages_data()
+{
+ QTest::addColumn<QUrl>("qmlfile");
+ QTest::addColumn<QString>("error");
+ QTest::newRow("local") << testFileUrl("embeddedImagesLocal.qml") << "";
+ QTest::newRow("local-error") << testFileUrl("embeddedImagesLocalError.qml")
+ << testFileUrl("embeddedImagesLocalError.qml").toString()+":3:1: QML TextEdit: Cannot open: " + testFileUrl("http/notexists.png").toString();
+ QTest::newRow("local") << testFileUrl("embeddedImagesLocalRelative.qml") << "";
+ QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << "";
+ QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml")
+ << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML TextEdit: Error downloading http://127.0.0.1:42332/notexists.png - server replied: Not found";
+ QTest::newRow("remote") << testFileUrl("embeddedImagesRemoteRelative.qml") << "";
+}
+
+void tst_qquicktextedit::embeddedImages()
+{
+ QFETCH(QUrl, qmlfile);
+ QFETCH(QString, error);
+
+ TestHTTPServer server(42332);
+ server.serveDirectory(testFile("http"));
+
+ if (!error.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
+
+ QQmlComponent textComponent(&engine, qmlfile);
+ QQuickTextEdit *textObject = qobject_cast<QQuickTextEdit*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QTRY_COMPARE(QQuickTextEditPrivate::get(textObject)->document->resourcesLoading(), 0);
+
+ QPixmap pm(testFile("http/exists.png"));
+ if (error.isEmpty()) {
+ QCOMPARE(textObject->width(), double(pm.width()));
+ QCOMPARE(textObject->height(), double(pm.height()));
+ } else {
+ QVERIFY(16 != pm.width()); // check test is effective
+ QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon
+ QCOMPARE(textObject->height(), 16.0);
+ }
+
+ delete textObject;
+}
+
+void tst_qquicktextedit::emptytags_QTBUG_22058()
+{
+ QQuickView canvas(testFileUrl("qtbug-22058.qml"));
+ QVERIFY(canvas.rootObject() != 0);
+
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QQuickTextEdit *input = qobject_cast<QQuickTextEdit *>(qvariant_cast<QObject *>(canvas.rootObject()->property("inputField")));
+ QVERIFY(input->hasActiveFocus());
+
+ QInputMethodEvent event("", QList<QInputMethodEvent::Attribute>());
+ event.setCommitString("<b>Bold<");
+ QGuiApplication::sendEvent(input, &event);
+ QCOMPARE(input->text(), QString("<b>Bold<"));
+ event.setCommitString(">");
+ QGuiApplication::sendEvent(input, &event);
+ QCOMPARE(input->text(), QString("<b>Bold<>"));
+}
+
+QTEST_MAIN(tst_qquicktextedit)
+
+#include "tst_qquicktextedit.moc"
diff --git a/tests/auto/qtquick2/qquicktextinput/data/Cursor.qml b/tests/auto/quick/qquicktextinput/data/Cursor.qml
index e5c1853fc5..e5c1853fc5 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/Cursor.qml
+++ b/tests/auto/quick/qquicktextinput/data/Cursor.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/cursorTest.qml b/tests/auto/quick/qquicktextinput/data/cursorTest.qml
index 71a420ee7c..71a420ee7c 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/cursorTest.qml
+++ b/tests/auto/quick/qquicktextinput/data/cursorTest.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/cursorTestExternal.qml b/tests/auto/quick/qquicktextinput/data/cursorTestExternal.qml
index 9277dcc518..9277dcc518 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/cursorTestExternal.qml
+++ b/tests/auto/quick/qquicktextinput/data/cursorTestExternal.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/cursorTestInline.qml b/tests/auto/quick/qquicktextinput/data/cursorTestInline.qml
index efc4b191da..efc4b191da 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/cursorTestInline.qml
+++ b/tests/auto/quick/qquicktextinput/data/cursorTestInline.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/cursorVisible.qml b/tests/auto/quick/qquicktextinput/data/cursorVisible.qml
index 49e9386947..49e9386947 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/cursorVisible.qml
+++ b/tests/auto/quick/qquicktextinput/data/cursorVisible.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/echoMode.qml b/tests/auto/quick/qquicktextinput/data/echoMode.qml
index f8a6cf1c89..f8a6cf1c89 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/echoMode.qml
+++ b/tests/auto/quick/qquicktextinput/data/echoMode.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/geometrySignals.qml b/tests/auto/quick/qquicktextinput/data/geometrySignals.qml
index 90855a61cf..90855a61cf 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/geometrySignals.qml
+++ b/tests/auto/quick/qquicktextinput/data/geometrySignals.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/halign_center.png b/tests/auto/quick/qquicktextinput/data/halign_center.png
index 53e09a8e5b..53e09a8e5b 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/halign_center.png
+++ b/tests/auto/quick/qquicktextinput/data/halign_center.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextinput/data/halign_left.png b/tests/auto/quick/qquicktextinput/data/halign_left.png
index 247acbc9df..247acbc9df 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/halign_left.png
+++ b/tests/auto/quick/qquicktextinput/data/halign_left.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextinput/data/halign_right.png b/tests/auto/quick/qquicktextinput/data/halign_right.png
index 691bc75c89..691bc75c89 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/halign_right.png
+++ b/tests/auto/quick/qquicktextinput/data/halign_right.png
Binary files differ
diff --git a/tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment.qml b/tests/auto/quick/qquicktextinput/data/horizontalAlignment.qml
index 89934532e3..89934532e3 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment.qml
+++ b/tests/auto/quick/qquicktextinput/data/horizontalAlignment.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment_RightToLeft.qml b/tests/auto/quick/qquicktextinput/data/horizontalAlignment_RightToLeft.qml
index 5f88025536..5f88025536 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/horizontalAlignment_RightToLeft.qml
+++ b/tests/auto/quick/qquicktextinput/data/horizontalAlignment_RightToLeft.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/inputContext.qml b/tests/auto/quick/qquicktextinput/data/inputContext.qml
index dfc80990c6..dfc80990c6 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/inputContext.qml
+++ b/tests/auto/quick/qquicktextinput/data/inputContext.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/inputMethodEvent.qml b/tests/auto/quick/qquicktextinput/data/inputMethodEvent.qml
index 7aefdf28f4..7aefdf28f4 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/inputMethodEvent.qml
+++ b/tests/auto/quick/qquicktextinput/data/inputMethodEvent.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/inputmethods.qml b/tests/auto/quick/qquicktextinput/data/inputmethods.qml
index 711e89144c..711e89144c 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/inputmethods.qml
+++ b/tests/auto/quick/qquicktextinput/data/inputmethods.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/masks.qml b/tests/auto/quick/qquicktextinput/data/masks.qml
index 589b6a3c15..589b6a3c15 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/masks.qml
+++ b/tests/auto/quick/qquicktextinput/data/masks.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/maxLength.qml b/tests/auto/quick/qquicktextinput/data/maxLength.qml
index cca537ed6b..cca537ed6b 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/maxLength.qml
+++ b/tests/auto/quick/qquicktextinput/data/maxLength.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/mouseselection_true.qml b/tests/auto/quick/qquicktextinput/data/mouseselection_true.qml
index 974041b04a..974041b04a 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/mouseselection_true.qml
+++ b/tests/auto/quick/qquicktextinput/data/mouseselection_true.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_characters.qml b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_characters.qml
index f7c658b618..f7c658b618 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_characters.qml
+++ b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_characters.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_default.qml b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_default.qml
index 974041b04a..974041b04a 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_default.qml
+++ b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_default.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_words.qml b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_words.qml
index 20e777e470..20e777e470 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/mouseselectionmode_words.qml
+++ b/tests/auto/quick/qquicktextinput/data/mouseselectionmode_words.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/navigation.qml b/tests/auto/quick/qquicktextinput/data/navigation.qml
index 3a7d07b3c7..3a7d07b3c7 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/navigation.qml
+++ b/tests/auto/quick/qquicktextinput/data/navigation.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/negativeDimensions.qml b/tests/auto/quick/qquicktextinput/data/negativeDimensions.qml
index 7a58c85b1d..7a58c85b1d 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/negativeDimensions.qml
+++ b/tests/auto/quick/qquicktextinput/data/negativeDimensions.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/openInputPanel.qml b/tests/auto/quick/qquicktextinput/data/openInputPanel.qml
index ca5cb263aa..ca5cb263aa 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/openInputPanel.qml
+++ b/tests/auto/quick/qquicktextinput/data/openInputPanel.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/persistentSelection.qml b/tests/auto/quick/qquicktextinput/data/persistentSelection.qml
index dea6e48b08..dea6e48b08 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/persistentSelection.qml
+++ b/tests/auto/quick/qquicktextinput/data/persistentSelection.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/positionAt.qml b/tests/auto/quick/qquicktextinput/data/positionAt.qml
index edb4744107..edb4744107 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/positionAt.qml
+++ b/tests/auto/quick/qquicktextinput/data/positionAt.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/preeditAutoScroll.qml b/tests/auto/quick/qquicktextinput/data/preeditAutoScroll.qml
index 9d98a2e220..9d98a2e220 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/preeditAutoScroll.qml
+++ b/tests/auto/quick/qquicktextinput/data/preeditAutoScroll.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956double.qml b/tests/auto/quick/qquicktextinput/data/qtbug-19956double.qml
index e9b80fceb2..e9b80fceb2 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956double.qml
+++ b/tests/auto/quick/qquicktextinput/data/qtbug-19956double.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956int.qml b/tests/auto/quick/qquicktextinput/data/qtbug-19956int.qml
index 0d70eedb80..0d70eedb80 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956int.qml
+++ b/tests/auto/quick/qquicktextinput/data/qtbug-19956int.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956regexp.qml b/tests/auto/quick/qquicktextinput/data/qtbug-19956regexp.qml
index b5af13cc4c..b5af13cc4c 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/qtbug-19956regexp.qml
+++ b/tests/auto/quick/qquicktextinput/data/qtbug-19956regexp.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/readOnly.qml b/tests/auto/quick/qquicktextinput/data/readOnly.qml
index 9cda7fbd1d..9cda7fbd1d 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/readOnly.qml
+++ b/tests/auto/quick/qquicktextinput/data/readOnly.qml
diff --git a/tests/auto/qtquick2/qquicktextinput/data/validators.qml b/tests/auto/quick/qquicktextinput/data/validators.qml
index 0ba87e0592..0ba87e0592 100644
--- a/tests/auto/qtquick2/qquicktextinput/data/validators.qml
+++ b/tests/auto/quick/qquicktextinput/data/validators.qml
diff --git a/tests/auto/quick/qquicktextinput/qquicktextinput.pro b/tests/auto/quick/qquicktextinput/qquicktextinput.pro
new file mode 100644
index 0000000000..78b39a2981
--- /dev/null
+++ b/tests/auto/quick/qquicktextinput/qquicktextinput.pro
@@ -0,0 +1,13 @@
+CONFIG += testcase
+TARGET = tst_qquicktextinput
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicktextinput.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+QT += core-private gui-private v8-private qml-private quick-private opengl-private testlib
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
new file mode 100644
index 0000000000..4141fea26f
--- /dev/null
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -0,0 +1,4706 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include "../../shared/util.h"
+#include <private/qinputmethod_p.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlexpression.h>
+#include <QFile>
+#include <QtQuick/qquickview.h>
+#include <QtGui/qguiapplication.h>
+#include <QtGui/qstylehints.h>
+#include <QInputMethod>
+#include <private/qquicktextinput_p.h>
+#include <private/qquicktextinput_p_p.h>
+#include <QDebug>
+#include <QDir>
+#include <QStyle>
+#include <QtOpenGL/QGLShaderProgram>
+#include <math.h>
+
+#ifdef Q_OS_MAC
+#include <Carbon/Carbon.h>
+#endif
+
+#include "qplatformdefs.h"
+#include "../../shared/platforminputcontext.h"
+
+Q_DECLARE_METATYPE(QQuickTextInput::SelectionMode)
+DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
+
+QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual)
+{
+ // XXX This will be replaced by some clever persistent platform image store.
+ QString persistent_dir = QQmlDataTest::instance()->dataDirectory();
+ QString arch = "unknown-architecture"; // QTest needs to help with this.
+
+ QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png";
+
+ if (!QFile::exists(expectfile)) {
+ actual.save(expectfile);
+ qWarning() << "created" << expectfile;
+ }
+
+ return expectfile;
+}
+
+template <typename T> static T evaluate(QObject *scope, const QString &expression)
+{
+ QQmlExpression expr(qmlContext(scope), scope, expression);
+ T result = expr.evaluate().value<T>();
+ if (expr.hasError())
+ qWarning() << expr.error().toString();
+ return result;
+}
+
+typedef QPair<int, QChar> Key;
+
+class tst_qquicktextinput : public QQmlDataTest
+
+{
+ Q_OBJECT
+public:
+ tst_qquicktextinput();
+
+private slots:
+ void cleanup();
+ void text();
+ void width();
+ void font();
+ void color();
+ void wrap();
+ void selection();
+ void persistentSelection();
+ void isRightToLeft_data();
+ void isRightToLeft();
+ void moveCursorSelection_data();
+ void moveCursorSelection();
+ void moveCursorSelectionSequence_data();
+ void moveCursorSelectionSequence();
+ void dragMouseSelection();
+ void mouseSelectionMode_data();
+ void mouseSelectionMode();
+ void tripleClickSelectsAll();
+
+ void horizontalAlignment_data();
+ void horizontalAlignment();
+ void horizontalAlignment_RightToLeft();
+ void verticalAlignment();
+
+ void boundingRect();
+
+ void positionAt();
+
+ void maxLength();
+ void masks();
+ void validators();
+ void inputMethods();
+
+ void passwordCharacter();
+ void cursorDelegate_data();
+ void cursorDelegate();
+ void cursorVisible();
+ void cursorRectangle();
+ void navigation();
+ void navigation_RTL();
+ void copyAndPaste();
+ void copyAndPasteKeySequence();
+ void canPasteEmpty();
+ void canPaste();
+ void readOnly();
+
+ void openInputPanel();
+ void setHAlignClearCache();
+ void focusOutClearSelection();
+
+ void echoMode();
+#ifdef QT_GUI_PASSWORD_ECHO_DELAY
+ void passwordEchoDelay();
+#endif
+ void geometrySignals();
+ void contentSize();
+
+ void preeditAutoScroll();
+ void preeditCursorRectangle();
+ void inputContextMouseHandler();
+ void inputMethodComposing();
+ void inputMethodUpdate();
+ void cursorRectangleSize();
+
+ void getText_data();
+ void getText();
+ void insert_data();
+ void insert();
+ void remove_data();
+ void remove();
+
+ void keySequence_data();
+ void keySequence();
+
+ void undo_data();
+ void undo();
+ void redo_data();
+ void redo();
+ void undo_keypressevents_data();
+ void undo_keypressevents();
+
+ void QTBUG_19956();
+ void QTBUG_19956_data();
+ void QTBUG_19956_regexp();
+
+ void negativeDimensions();
+
+private:
+ void simulateKey(QQuickView *, int key);
+
+ void simulateKeys(QWindow *window, const QList<Key> &keys);
+ void simulateKeys(QWindow *window, const QKeySequence &sequence);
+
+ QQmlEngine engine;
+ QStringList standard;
+ QStringList colorStrings;
+};
+
+typedef QList<int> IntList;
+Q_DECLARE_METATYPE(IntList)
+
+typedef QList<Key> KeyList;
+Q_DECLARE_METATYPE(KeyList)
+
+void tst_qquicktextinput::simulateKeys(QWindow *window, const QList<Key> &keys)
+{
+ for (int i = 0; i < keys.count(); ++i) {
+ const int key = keys.at(i).first;
+ const int modifiers = key & Qt::KeyboardModifierMask;
+ const QString text = !keys.at(i).second.isNull() ? QString(keys.at(i).second) : QString();
+
+ QKeyEvent press(QEvent::KeyPress, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text);
+ QKeyEvent release(QEvent::KeyRelease, Qt::Key(key), Qt::KeyboardModifiers(modifiers), text);
+
+ QGuiApplication::sendEvent(window, &press);
+ QGuiApplication::sendEvent(window, &release);
+ }
+}
+
+void tst_qquicktextinput::simulateKeys(QWindow *window, const QKeySequence &sequence)
+{
+ for (int i = 0; i < sequence.count(); ++i) {
+ const int key = sequence[i];
+ const int modifiers = key & Qt::KeyboardModifierMask;
+
+ QTest::keyClick(window, Qt::Key(key & ~modifiers), Qt::KeyboardModifiers(modifiers));
+ }
+}
+
+QList<Key> &operator <<(QList<Key> &keys, const QKeySequence &sequence)
+{
+ for (int i = 0; i < sequence.count(); ++i)
+ keys << Key(sequence[i], QChar());
+ return keys;
+}
+
+template <int N> QList<Key> &operator <<(QList<Key> &keys, const char (&characters)[N])
+{
+ for (int i = 0; i < N - 1; ++i) {
+ int key = QTest::asciiToKey(characters[i]);
+ QChar character = QLatin1Char(characters[i]);
+ keys << Key(key, character);
+ }
+ return keys;
+}
+
+QList<Key> &operator <<(QList<Key> &keys, Qt::Key key)
+{
+ keys << Key(key, QChar());
+ return keys;
+}
+
+void tst_qquicktextinput::cleanup()
+{
+ // ensure not even skipped tests with custom input context leave it dangling
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = 0;
+}
+
+tst_qquicktextinput::tst_qquicktextinput()
+{
+ standard << "the quick brown fox jumped over the lazy dog"
+ << "It's supercalifragisiticexpialidocious!"
+ << "Hello, world!"
+ << "!dlrow ,olleH"
+ << " spacey text ";
+
+ colorStrings << "aliceblue"
+ << "antiquewhite"
+ << "aqua"
+ << "darkkhaki"
+ << "darkolivegreen"
+ << "dimgray"
+ << "palevioletred"
+ << "lightsteelblue"
+ << "#000000"
+ << "#AAAAAA"
+ << "#FFFFFF"
+ << "#2AC05F";
+}
+
+void tst_qquicktextinput::text()
+{
+ {
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData("import QtQuick 2.0\nTextInput { text: \"\" }", QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->text(), QString(""));
+ QCOMPARE(textinputObject->length(), 0);
+
+ delete textinputObject;
+ }
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->text(), standard.at(i));
+ QCOMPARE(textinputObject->length(), standard.at(i).length());
+
+ delete textinputObject;
+ }
+
+}
+
+void tst_qquicktextinput::width()
+{
+ // uses Font metrics to find the width for standard
+ {
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData("import QtQuick 2.0\nTextInput { text: \"\" }", QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->width(), 0.0);
+
+ delete textinputObject;
+ }
+
+ bool requiresUnhintedMetrics = !qmlDisableDistanceField();
+
+ for (int i = 0; i < standard.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QString s = standard.at(i);
+ s.replace(QLatin1Char('\n'), QChar::LineSeparator);
+
+ QTextLayout layout(s);
+ layout.setFont(textinputObject->font());
+ layout.setFlags(Qt::TextExpandTabs | Qt::TextShowMnemonic);
+ if (requiresUnhintedMetrics) {
+ QTextOption option;
+ option.setUseDesignMetrics(true);
+ layout.setTextOption(option);
+ }
+
+ layout.beginLayout();
+ forever {
+ QTextLine line = layout.createLine();
+ if (!line.isValid())
+ break;
+ }
+
+ layout.endLayout();
+
+ qreal metricWidth = ceil(layout.boundingRect().width());
+
+ QVERIFY(textinputObject != 0);
+ int delta = abs(int(int(textinputObject->width()) - metricWidth));
+ QVERIFY(delta <= 3.0); // As best as we can hope for cross-platform.
+
+ delete textinputObject;
+ }
+}
+
+void tst_qquicktextinput::font()
+{
+ //test size, then bold, then italic, then family
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { font.pointSize: 40; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().pointSize(), 40);
+ QCOMPARE(textinputObject->font().bold(), false);
+ QCOMPARE(textinputObject->font().italic(), false);
+
+ delete textinputObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { font.bold: true; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().bold(), true);
+ QCOMPARE(textinputObject->font().italic(), false);
+
+ delete textinputObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { font.italic: true; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().italic(), true);
+ QCOMPARE(textinputObject->font().bold(), false);
+
+ delete textinputObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().family(), QString("Helvetica"));
+ QCOMPARE(textinputObject->font().bold(), false);
+ QCOMPARE(textinputObject->font().italic(), false);
+
+ delete textinputObject;
+ }
+
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { font.family: \"\"; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->font().family(), QString(""));
+
+ delete textinputObject;
+ }
+}
+
+void tst_qquicktextinput::color()
+{
+ //test color
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i)));
+
+ delete textinputObject;
+ }
+
+ //test selection color
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i)));
+
+ delete textinputObject;
+ }
+
+ //test selected text color
+ for (int i = 0; i < colorStrings.size(); i++)
+ {
+ QString componentStr = "import QtQuick 2.0\nTextInput { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i)));
+
+ delete textinputObject;
+ }
+
+ {
+ QString colorStr = "#AA001234";
+ QColor testColor("#001234");
+ testColor.setAlpha(170);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { color: \"" + colorStr + "\"; text: \"Hello World\" }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+
+ QVERIFY(textinputObject != 0);
+ QCOMPARE(textinputObject->color(), testColor);
+
+ delete textinputObject;
+ }
+}
+
+void tst_qquicktextinput::wrap()
+{
+ int textHeight = 0;
+ // for specified width and wrap set true
+ {
+ QQmlComponent textComponent(&engine);
+ textComponent.setData("import QtQuick 2.0\nTextInput { text: \"Hello\"; wrapMode: Text.WrapAnywhere; width: 300 }", QUrl::fromLocalFile(""));
+ QQuickTextInput *textObject = qobject_cast<QQuickTextInput*>(textComponent.create());
+ textHeight = textObject->height();
+
+ QVERIFY(textObject != 0);
+ QVERIFY(textObject->wrapMode() == QQuickTextInput::WrapAnywhere);
+ QCOMPARE(textObject->width(), 300.);
+
+ delete textObject;
+ }
+
+ for (int i = 0; i < standard.count(); i++) {
+ QString componentStr = "import QtQuick 2.0\nTextInput { wrapMode: Text.WrapAnywhere; width: 30; text: \"" + standard.at(i) + "\" }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QQuickTextInput *textObject = qobject_cast<QQuickTextInput*>(textComponent.create());
+
+ QVERIFY(textObject != 0);
+ QCOMPARE(textObject->width(), 30.);
+ QVERIFY(textObject->height() > textHeight);
+
+ int oldHeight = textObject->height();
+ textObject->setWidth(100);
+ QVERIFY(textObject->height() < oldHeight);
+
+ delete textObject;
+ }
+}
+
+void tst_qquicktextinput::selection()
+{
+ QString testStr = standard[0];
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+
+
+ //Test selection follows cursor
+ for (int i=0; i<= testStr.size(); i++) {
+ textinputObject->setCursorPosition(i);
+ QCOMPARE(textinputObject->cursorPosition(), i);
+ QCOMPARE(textinputObject->selectionStart(), i);
+ QCOMPARE(textinputObject->selectionEnd(), i);
+ QVERIFY(textinputObject->selectedText().isNull());
+ }
+
+ textinputObject->setCursorPosition(0);
+ QVERIFY(textinputObject->cursorPosition() == 0);
+ QVERIFY(textinputObject->selectionStart() == 0);
+ QVERIFY(textinputObject->selectionEnd() == 0);
+ QVERIFY(textinputObject->selectedText().isNull());
+
+ // Verify invalid positions are ignored.
+ textinputObject->setCursorPosition(-1);
+ QVERIFY(textinputObject->cursorPosition() == 0);
+ QVERIFY(textinputObject->selectionStart() == 0);
+ QVERIFY(textinputObject->selectionEnd() == 0);
+ QVERIFY(textinputObject->selectedText().isNull());
+
+ textinputObject->setCursorPosition(textinputObject->text().count()+1);
+ QVERIFY(textinputObject->cursorPosition() == 0);
+ QVERIFY(textinputObject->selectionStart() == 0);
+ QVERIFY(textinputObject->selectionEnd() == 0);
+ QVERIFY(textinputObject->selectedText().isNull());
+
+ //Test selection
+ for (int i=0; i<= testStr.size(); i++) {
+ textinputObject->select(0,i);
+ QCOMPARE(testStr.mid(0,i), textinputObject->selectedText());
+ }
+ for (int i=0; i<= testStr.size(); i++) {
+ textinputObject->select(i,testStr.size());
+ QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText());
+ }
+
+ textinputObject->setCursorPosition(0);
+ QVERIFY(textinputObject->cursorPosition() == 0);
+ QVERIFY(textinputObject->selectionStart() == 0);
+ QVERIFY(textinputObject->selectionEnd() == 0);
+ QVERIFY(textinputObject->selectedText().isNull());
+
+ //Test Error Ignoring behaviour
+ textinputObject->setCursorPosition(0);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->select(-10,0);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->select(100,110);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->select(0,-10);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->select(0,100);
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->select(0,10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->select(-10,10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->select(100,101);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->select(0,-10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->select(0,100);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+
+ textinputObject->deselect();
+ QVERIFY(textinputObject->selectedText().isNull());
+ textinputObject->select(0,10);
+ QVERIFY(textinputObject->selectedText().size() == 10);
+ textinputObject->deselect();
+ QVERIFY(textinputObject->selectedText().isNull());
+
+ // test input method selection
+ QSignalSpy selectionSpy(textinputObject, SIGNAL(selectedTextChanged()));
+ textinputObject->setFocus(true);
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 12, 5, QVariant());
+ QInputMethodEvent event("", attributes);
+ QGuiApplication::sendEvent(textinputObject, &event);
+ }
+ QCOMPARE(selectionSpy.count(), 1);
+ QCOMPARE(textinputObject->selectionStart(), 12);
+ QCOMPARE(textinputObject->selectionEnd(), 17);
+
+ delete textinputObject;
+}
+
+void tst_qquicktextinput::persistentSelection()
+{
+ QQuickView canvas(testFileUrl("persistentSelection.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+ canvas.requestActivateWindow();
+
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(canvas.rootObject());
+ QVERIFY(input);
+ QVERIFY(input->hasActiveFocus());
+
+ QSignalSpy spy(input, SIGNAL(persistentSelectionChanged()));
+
+ QCOMPARE(input->persistentSelection(), false);
+
+ input->setPersistentSelection(false);
+ QCOMPARE(input->persistentSelection(), false);
+ QCOMPARE(spy.count(), 0);
+
+ input->select(1, 4);
+ QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
+
+ input->setFocus(false);
+ QCOMPARE(input->property("selected").toString(), QString());
+
+ input->setFocus(true);
+ QCOMPARE(input->property("selected").toString(), QString());
+
+ input->setPersistentSelection(true);
+ QCOMPARE(input->persistentSelection(), true);
+ QCOMPARE(spy.count(), 1);
+
+ input->select(1, 4);
+ QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
+
+ input->setFocus(false);
+ QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
+
+ input->setFocus(true);
+ QCOMPARE(input->property("selected").toString(), QLatin1String("ell"));
+}
+
+void tst_qquicktextinput::isRightToLeft_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<bool>("emptyString");
+ QTest::addColumn<bool>("firstCharacter");
+ QTest::addColumn<bool>("lastCharacter");
+ QTest::addColumn<bool>("middleCharacter");
+ QTest::addColumn<bool>("startString");
+ QTest::addColumn<bool>("midString");
+ QTest::addColumn<bool>("endString");
+
+ const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647};
+ QTest::newRow("Empty") << "" << false << false << false << false << false << false << false;
+ QTest::newRow("Neutral") << "23244242" << false << false << false << false << false << false << false;
+ QTest::newRow("LTR") << "Hello world" << false << false << false << false << false << false << false;
+ QTest::newRow("RTL") << QString::fromUtf16(arabic_str, 11) << false << true << true << true << true << true << true;
+ QTest::newRow("Bidi RTL + LTR + RTL") << QString::fromUtf16(arabic_str, 11) + QString("Hello world") + QString::fromUtf16(arabic_str, 11) << false << true << true << false << true << true << true;
+ QTest::newRow("Bidi LTR + RTL + LTR") << QString("Hello world") + QString::fromUtf16(arabic_str, 11) + QString("Hello world") << false << false << false << true << false << false << false;
+}
+
+void tst_qquicktextinput::isRightToLeft()
+{
+ QFETCH(QString, text);
+ QFETCH(bool, emptyString);
+ QFETCH(bool, firstCharacter);
+ QFETCH(bool, lastCharacter);
+ QFETCH(bool, middleCharacter);
+ QFETCH(bool, startString);
+ QFETCH(bool, midString);
+ QFETCH(bool, endString);
+
+ QQuickTextInput textInput;
+ textInput.setText(text);
+
+ // first test that the right string is delivered to the QString::isRightToLeft()
+ QCOMPARE(textInput.isRightToLeft(0,0), text.mid(0,0).isRightToLeft());
+ QCOMPARE(textInput.isRightToLeft(0,1), text.mid(0,1).isRightToLeft());
+ QCOMPARE(textInput.isRightToLeft(text.count()-2, text.count()-1), text.mid(text.count()-2, text.count()-1).isRightToLeft());
+ QCOMPARE(textInput.isRightToLeft(text.count()/2, text.count()/2 + 1), text.mid(text.count()/2, text.count()/2 + 1).isRightToLeft());
+ QCOMPARE(textInput.isRightToLeft(0,text.count()/4), text.mid(0,text.count()/4).isRightToLeft());
+ QCOMPARE(textInput.isRightToLeft(text.count()/4,3*text.count()/4), text.mid(text.count()/4,3*text.count()/4).isRightToLeft());
+ if (text.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start.");
+ QCOMPARE(textInput.isRightToLeft(3*text.count()/4,text.count()-1), text.mid(3*text.count()/4,text.count()-1).isRightToLeft());
+
+ // then test that the feature actually works
+ QCOMPARE(textInput.isRightToLeft(0,0), emptyString);
+ QCOMPARE(textInput.isRightToLeft(0,1), firstCharacter);
+ QCOMPARE(textInput.isRightToLeft(text.count()-2, text.count()-1), lastCharacter);
+ QCOMPARE(textInput.isRightToLeft(text.count()/2, text.count()/2 + 1), middleCharacter);
+ QCOMPARE(textInput.isRightToLeft(0,text.count()/4), startString);
+ QCOMPARE(textInput.isRightToLeft(text.count()/4,3*text.count()/4), midString);
+ if (text.isEmpty())
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start.");
+ QCOMPARE(textInput.isRightToLeft(3*text.count()/4,text.count()-1), endString);
+}
+
+void tst_qquicktextinput::moveCursorSelection_data()
+{
+ QTest::addColumn<QString>("testStr");
+ QTest::addColumn<int>("cursorPosition");
+ QTest::addColumn<int>("movePosition");
+ QTest::addColumn<QQuickTextInput::SelectionMode>("mode");
+ QTest::addColumn<int>("selectionStart");
+ QTest::addColumn<int>("selectionEnd");
+ QTest::addColumn<bool>("reversible");
+
+ // () contains the text selected by the cursor.
+ // <> contains the actual selection.
+
+ QTest::newRow("(t)he|characters")
+ << standard[0] << 0 << 1 << QQuickTextInput::SelectCharacters << 0 << 1 << true;
+ QTest::newRow("do(g)|characters")
+ << standard[0] << 43 << 44 << QQuickTextInput::SelectCharacters << 43 << 44 << true;
+ QTest::newRow("jum(p)ed|characters")
+ << standard[0] << 23 << 24 << QQuickTextInput::SelectCharacters << 23 << 24 << true;
+ QTest::newRow("jumped( )over|characters")
+ << standard[0] << 26 << 27 << QQuickTextInput::SelectCharacters << 26 << 27 << true;
+ QTest::newRow("(the )|characters")
+ << standard[0] << 0 << 4 << QQuickTextInput::SelectCharacters << 0 << 4 << true;
+ QTest::newRow("( dog)|characters")
+ << standard[0] << 40 << 44 << QQuickTextInput::SelectCharacters << 40 << 44 << true;
+ QTest::newRow("( jumped )|characters")
+ << standard[0] << 19 << 27 << QQuickTextInput::SelectCharacters << 19 << 27 << true;
+ QTest::newRow("th(e qu)ick|characters")
+ << standard[0] << 2 << 6 << QQuickTextInput::SelectCharacters << 2 << 6 << true;
+ QTest::newRow("la(zy d)og|characters")
+ << standard[0] << 38 << 42 << QQuickTextInput::SelectCharacters << 38 << 42 << true;
+ QTest::newRow("jum(ped ov)er|characters")
+ << standard[0] << 23 << 29 << QQuickTextInput::SelectCharacters << 23 << 29 << true;
+ QTest::newRow("()the|characters")
+ << standard[0] << 0 << 0 << QQuickTextInput::SelectCharacters << 0 << 0 << true;
+ QTest::newRow("dog()|characters")
+ << standard[0] << 44 << 44 << QQuickTextInput::SelectCharacters << 44 << 44 << true;
+ QTest::newRow("jum()ped|characters")
+ << standard[0] << 23 << 23 << QQuickTextInput::SelectCharacters << 23 << 23 << true;
+
+ QTest::newRow("<(t)he>|words")
+ << standard[0] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 3 << true;
+ QTest::newRow("<do(g)>|words")
+ << standard[0] << 43 << 44 << QQuickTextInput::SelectWords << 41 << 44 << true;
+ QTest::newRow("<jum(p)ed>|words")
+ << standard[0] << 23 << 24 << QQuickTextInput::SelectWords << 20 << 26 << true;
+ QTest::newRow("<jumped( )>over|words,ltr")
+ << standard[0] << 26 << 27 << QQuickTextInput::SelectWords << 20 << 27 << false;
+ QTest::newRow("jumped<( )over>|words,rtl")
+ << standard[0] << 27 << 26 << QQuickTextInput::SelectWords << 26 << 31 << false;
+ QTest::newRow("<(the )>quick|words,ltr")
+ << standard[0] << 0 << 4 << QQuickTextInput::SelectWords << 0 << 4 << false;
+ QTest::newRow("<(the )quick>|words,rtl")
+ << standard[0] << 4 << 0 << QQuickTextInput::SelectWords << 0 << 9 << false;
+ QTest::newRow("<lazy( dog)>|words,ltr")
+ << standard[0] << 40 << 44 << QQuickTextInput::SelectWords << 36 << 44 << false;
+ QTest::newRow("lazy<( dog)>|words,rtl")
+ << standard[0] << 44 << 40 << QQuickTextInput::SelectWords << 40 << 44 << false;
+ QTest::newRow("<fox( jumped )>over|words,ltr")
+ << standard[0] << 19 << 27 << QQuickTextInput::SelectWords << 16 << 27 << false;
+ QTest::newRow("fox<( jumped )over>|words,rtl")
+ << standard[0] << 27 << 19 << QQuickTextInput::SelectWords << 19 << 31 << false;
+ QTest::newRow("<th(e qu)ick>|words")
+ << standard[0] << 2 << 6 << QQuickTextInput::SelectWords << 0 << 9 << true;
+ QTest::newRow("<la(zy d)og|words>")
+ << standard[0] << 38 << 42 << QQuickTextInput::SelectWords << 36 << 44 << true;
+ QTest::newRow("<jum(ped ov)er>|words")
+ << standard[0] << 23 << 29 << QQuickTextInput::SelectWords << 20 << 31 << true;
+ QTest::newRow("<()>the|words")
+ << standard[0] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << true;
+ QTest::newRow("dog<()>|words")
+ << standard[0] << 44 << 44 << QQuickTextInput::SelectWords << 44 << 44 << true;
+ QTest::newRow("jum<()>ped|words")
+ << standard[0] << 23 << 23 << QQuickTextInput::SelectWords << 23 << 23 << true;
+
+ QTest::newRow("Hello<(,)> |words")
+ << standard[2] << 5 << 6 << QQuickTextInput::SelectWords << 5 << 6 << true;
+ QTest::newRow("Hello<(, )>world|words,ltr")
+ << standard[2] << 5 << 7 << QQuickTextInput::SelectWords << 5 << 7 << false;
+ QTest::newRow("Hello<(, )world>|words,rtl")
+ << standard[2] << 7 << 5 << QQuickTextInput::SelectWords << 5 << 12 << false;
+ QTest::newRow("<Hel(lo, )>world|words,ltr")
+ << standard[2] << 3 << 7 << QQuickTextInput::SelectWords << 0 << 7 << false;
+ QTest::newRow("<Hel(lo, )world>|words,rtl")
+ << standard[2] << 7 << 3 << QQuickTextInput::SelectWords << 0 << 12 << false;
+ QTest::newRow("<Hel(lo)>,|words")
+ << standard[2] << 3 << 5 << QQuickTextInput::SelectWords << 0 << 5 << true;
+ QTest::newRow("Hello<()>,|words")
+ << standard[2] << 5 << 5 << QQuickTextInput::SelectWords << 5 << 5 << true;
+ QTest::newRow("Hello,<()>|words")
+ << standard[2] << 6 << 6 << QQuickTextInput::SelectWords << 6 << 6 << true;
+ QTest::newRow("Hello<,( )>world|words,ltr")
+ << standard[2] << 6 << 7 << QQuickTextInput::SelectWords << 5 << 7 << false;
+ QTest::newRow("Hello,<( )world>|words,rtl")
+ << standard[2] << 7 << 6 << QQuickTextInput::SelectWords << 6 << 12 << false;
+ QTest::newRow("Hello<,( world)>|words,ltr")
+ << standard[2] << 6 << 12 << QQuickTextInput::SelectWords << 5 << 12 << false;
+ QTest::newRow("Hello,<( world)>|words,rtl")
+ << standard[2] << 12 << 6 << QQuickTextInput::SelectWords << 6 << 12 << false;
+ QTest::newRow("Hello<,( world!)>|words,ltr")
+ << standard[2] << 6 << 13 << QQuickTextInput::SelectWords << 5 << 13 << false;
+ QTest::newRow("Hello,<( world!)>|words,rtl")
+ << standard[2] << 13 << 6 << QQuickTextInput::SelectWords << 6 << 13 << false;
+ QTest::newRow("Hello<(, world!)>|words")
+ << standard[2] << 5 << 13 << QQuickTextInput::SelectWords << 5 << 13 << true;
+ // Fails due to an issue with QTextBoundaryFinder and punctuation at the end of strings.
+ // QTBUG-11365
+ // QTest::newRow("world<(!)>|words")
+ // << standard[2] << 12 << 13 << QQuickTextInput::SelectWords << 12 << 13 << true;
+ QTest::newRow("world!<()>)|words")
+ << standard[2] << 13 << 13 << QQuickTextInput::SelectWords << 13 << 13 << true;
+ QTest::newRow("world<()>!)|words")
+ << standard[2] << 12 << 12 << QQuickTextInput::SelectWords << 12 << 12 << true;
+
+ QTest::newRow("<(,)>olleH |words")
+ << standard[3] << 7 << 8 << QQuickTextInput::SelectWords << 7 << 8 << true;
+ QTest::newRow("<dlrow( ,)>olleH|words,ltr")
+ << standard[3] << 6 << 8 << QQuickTextInput::SelectWords << 1 << 8 << false;
+ QTest::newRow("dlrow<( ,)>olleH|words,rtl")
+ << standard[3] << 8 << 6 << QQuickTextInput::SelectWords << 6 << 8 << false;
+ QTest::newRow("<dlrow( ,ol)leH>|words,ltr")
+ << standard[3] << 6 << 10 << QQuickTextInput::SelectWords << 1 << 13 << false;
+ QTest::newRow("dlrow<( ,ol)leH>|words,rtl")
+ << standard[3] << 10 << 6 << QQuickTextInput::SelectWords << 6 << 13 << false;
+ QTest::newRow(",<(ol)leH>,|words")
+ << standard[3] << 8 << 10 << QQuickTextInput::SelectWords << 8 << 13 << true;
+ QTest::newRow(",<()>olleH|words")
+ << standard[3] << 8 << 8 << QQuickTextInput::SelectWords << 8 << 8 << true;
+ QTest::newRow("<()>,olleH|words")
+ << standard[3] << 7 << 7 << QQuickTextInput::SelectWords << 7 << 7 << true;
+ QTest::newRow("<dlrow( )>,olleH|words,ltr")
+ << standard[3] << 6 << 7 << QQuickTextInput::SelectWords << 1 << 7 << false;
+ QTest::newRow("dlrow<( ),>olleH|words,rtl")
+ << standard[3] << 7 << 6 << QQuickTextInput::SelectWords << 6 << 8 << false;
+ QTest::newRow("<(dlrow )>,olleH|words,ltr")
+ << standard[3] << 1 << 7 << QQuickTextInput::SelectWords << 1 << 7 << false;
+ QTest::newRow("<(dlrow ),>olleH|words,rtl")
+ << standard[3] << 7 << 1 << QQuickTextInput::SelectWords << 1 << 8 << false;
+ QTest::newRow("<(!dlrow )>,olleH|words,ltr")
+ << standard[3] << 0 << 7 << QQuickTextInput::SelectWords << 0 << 7 << false;
+ QTest::newRow("<(!dlrow ),>olleH|words,rtl")
+ << standard[3] << 7 << 0 << QQuickTextInput::SelectWords << 0 << 8 << false;
+ QTest::newRow("(!dlrow ,)olleH|words")
+ << standard[3] << 0 << 8 << QQuickTextInput::SelectWords << 0 << 8 << true;
+ QTest::newRow("<(!)>dlrow|words")
+ << standard[3] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 1 << true;
+ QTest::newRow("<()>!dlrow|words")
+ << standard[3] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << true;
+ QTest::newRow("!<()>dlrow|words")
+ << standard[3] << 1 << 1 << QQuickTextInput::SelectWords << 1 << 1 << true;
+
+ QTest::newRow(" <s(pac)ey> text |words")
+ << standard[4] << 1 << 4 << QQuickTextInput::SelectWords << 1 << 7 << true;
+ QTest::newRow(" spacey <t(ex)t> |words")
+ << standard[4] << 11 << 13 << QQuickTextInput::SelectWords << 10 << 14 << false; // Should be reversible. QTBUG-11365
+ QTest::newRow("<( )>spacey text |words|ltr")
+ << standard[4] << 0 << 1 << QQuickTextInput::SelectWords << 0 << 1 << false;
+ QTest::newRow("<( )spacey> text |words|rtl")
+ << standard[4] << 1 << 0 << QQuickTextInput::SelectWords << 0 << 7 << false;
+ QTest::newRow("spacey <text( )>|words|ltr")
+ << standard[4] << 14 << 15 << QQuickTextInput::SelectWords << 10 << 15 << false;
+// QTBUG-11365
+// QTest::newRow("spacey text<( )>|words|rtl")
+// << standard[4] << 15 << 14 << QQuickTextInput::SelectWords << 14 << 15 << false;
+ QTest::newRow("<()> spacey text |words")
+ << standard[4] << 0 << 0 << QQuickTextInput::SelectWords << 0 << 0 << false;
+ QTest::newRow(" spacey text <()>|words")
+ << standard[4] << 15 << 15 << QQuickTextInput::SelectWords << 15 << 15 << false;
+}
+
+void tst_qquicktextinput::moveCursorSelection()
+{
+ QFETCH(QString, testStr);
+ QFETCH(int, cursorPosition);
+ QFETCH(int, movePosition);
+ QFETCH(QQuickTextInput::SelectionMode, mode);
+ QFETCH(int, selectionStart);
+ QFETCH(int, selectionEnd);
+ QFETCH(bool, reversible);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+
+ textinputObject->setCursorPosition(cursorPosition);
+ textinputObject->moveCursorSelection(movePosition, mode);
+
+ QCOMPARE(textinputObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
+ QCOMPARE(textinputObject->selectionStart(), selectionStart);
+ QCOMPARE(textinputObject->selectionEnd(), selectionEnd);
+
+ if (reversible) {
+ textinputObject->setCursorPosition(movePosition);
+ textinputObject->moveCursorSelection(cursorPosition, mode);
+
+ QCOMPARE(textinputObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart));
+ QCOMPARE(textinputObject->selectionStart(), selectionStart);
+ QCOMPARE(textinputObject->selectionEnd(), selectionEnd);
+ }
+
+ delete textinputObject;
+}
+
+void tst_qquicktextinput::moveCursorSelectionSequence_data()
+{
+ QTest::addColumn<QString>("testStr");
+ QTest::addColumn<int>("cursorPosition");
+ QTest::addColumn<int>("movePosition1");
+ QTest::addColumn<int>("movePosition2");
+ QTest::addColumn<int>("selection1Start");
+ QTest::addColumn<int>("selection1End");
+ QTest::addColumn<int>("selection2Start");
+ QTest::addColumn<int>("selection2End");
+
+ // () contains the text selected by the cursor.
+ // <> contains the actual selection.
+ // ^ is the revised cursor position.
+ // {} contains the revised selection.
+
+ QTest::newRow("the {<quick( bro)wn> f^ox} jumped|ltr")
+ << standard[0]
+ << 9 << 13 << 17
+ << 4 << 15
+ << 4 << 19;
+ QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl")
+ << standard[0]
+ << 13 << 9 << 17
+ << 9 << 15
+ << 10 << 19;
+ QTest::newRow("the {<quick( bro)wn> ^}fox jumped|ltr")
+ << standard[0]
+ << 9 << 13 << 16
+ << 4 << 15
+ << 4 << 16;
+ QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl")
+ << standard[0]
+ << 13 << 9 << 16
+ << 9 << 15
+ << 10 << 16;
+ QTest::newRow("the {<quick( bro)wn^>} fox jumped|ltr")
+ << standard[0]
+ << 9 << 13 << 15
+ << 4 << 15
+ << 4 << 15;
+ QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl")
+ << standard[0]
+ << 13 << 9 << 15
+ << 9 << 15
+ << 10 << 15;
+ QTest::newRow("the {<quick() ^}bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 10
+ << 4 << 15
+ << 4 << 10;
+ QTest::newRow("the quick<( {^bro)wn>} fox|rtl")
+ << standard[0]
+ << 13 << 9 << 10
+ << 9 << 15
+ << 10 << 15;
+ QTest::newRow("the {<quick^}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 9
+ << 4 << 15
+ << 4 << 9;
+ QTest::newRow("the quick{<(^ bro)wn>} fox|rtl")
+ << standard[0]
+ << 13 << 9 << 9
+ << 9 << 15
+ << 9 << 15;
+ QTest::newRow("the {<qui^ck}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 7
+ << 4 << 15
+ << 4 << 9;
+ QTest::newRow("the {<qui^ck}( bro)wn> fox|rtl")
+ << standard[0]
+ << 13 << 9 << 7
+ << 9 << 15
+ << 4 << 15;
+ QTest::newRow("the {<^quick}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 4
+ << 4 << 15
+ << 4 << 9;
+ QTest::newRow("the {<^quick}( bro)wn> fox|rtl")
+ << standard[0]
+ << 13 << 9 << 4
+ << 9 << 15
+ << 4 << 15;
+ QTest::newRow("the{^ <quick}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 3
+ << 4 << 15
+ << 3 << 9;
+ QTest::newRow("the{^ <quick}( bro)wn> fox|rtl")
+ << standard[0]
+ << 13 << 9 << 3
+ << 9 << 15
+ << 3 << 15;
+ QTest::newRow("{t^he <quick}( bro)wn> fox|ltr")
+ << standard[0]
+ << 9 << 13 << 1
+ << 4 << 15
+ << 0 << 9;
+ QTest::newRow("{t^he <quick}( bro)wn> fox|rtl")
+ << standard[0]
+ << 13 << 9 << 1
+ << 9 << 15
+ << 0 << 15;
+
+ QTest::newRow("{<He(ll)o>, w^orld}!|ltr")
+ << standard[2]
+ << 2 << 4 << 8
+ << 0 << 5
+ << 0 << 12;
+ QTest::newRow("{<He(ll)o>, w^orld}!|rtl")
+ << standard[2]
+ << 4 << 2 << 8
+ << 0 << 5
+ << 0 << 12;
+
+ QTest::newRow("!{dlro^w ,<o(ll)eH>}|ltr")
+ << standard[3]
+ << 9 << 11 << 5
+ << 8 << 13
+ << 1 << 13;
+ QTest::newRow("!{dlro^w ,<o(ll)eH>}|rtl")
+ << standard[3]
+ << 11 << 9 << 5
+ << 8 << 13
+ << 1 << 13;
+
+ QTest::newRow("{<(^} sp)acey> text |ltr")
+ << standard[4]
+ << 0 << 3 << 0
+ << 0 << 7
+ << 0 << 0;
+ QTest::newRow("{<( ^}sp)acey> text |ltr")
+ << standard[4]
+ << 0 << 3 << 1
+ << 0 << 7
+ << 0 << 1;
+ QTest::newRow("<( {s^p)acey>} text |rtl")
+ << standard[4]
+ << 3 << 0 << 2
+ << 0 << 7
+ << 1 << 7;
+ QTest::newRow("<( {^sp)acey>} text |rtl")
+ << standard[4]
+ << 3 << 0 << 1
+ << 0 << 7
+ << 1 << 7;
+
+ QTest::newRow(" spacey <te(xt {^)>}|rtl")
+ << standard[4]
+ << 15 << 12 << 15
+ << 10 << 15
+ << 15 << 15;
+// QTBUG-11365
+// QTest::newRow(" spacey <te(xt{^ )>}|rtl")
+// << standard[4]
+// << 15 << 12 << 14
+// << 10 << 15
+// << 14 << 15;
+ QTest::newRow(" spacey {<te(x^t} )>|ltr")
+ << standard[4]
+ << 12 << 15 << 13
+ << 10 << 15
+ << 10 << 14;
+// QTBUG-11365
+// QTest::newRow(" spacey {<te(xt^} )>|ltr")
+// << standard[4]
+// << 12 << 15 << 14
+// << 10 << 15
+// << 10 << 14;
+}
+
+void tst_qquicktextinput::moveCursorSelectionSequence()
+{
+ QFETCH(QString, testStr);
+ QFETCH(int, cursorPosition);
+ QFETCH(int, movePosition1);
+ QFETCH(int, movePosition2);
+ QFETCH(int, selection1Start);
+ QFETCH(int, selection1End);
+ QFETCH(int, selection2Start);
+ QFETCH(int, selection2End);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \""+ testStr +"\"; }";
+ QQmlComponent textinputComponent(&engine);
+ textinputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput*>(textinputComponent.create());
+ QVERIFY(textinputObject != 0);
+
+ textinputObject->setCursorPosition(cursorPosition);
+
+ textinputObject->moveCursorSelection(movePosition1, QQuickTextInput::SelectWords);
+ QCOMPARE(textinputObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start));
+ QCOMPARE(textinputObject->selectionStart(), selection1Start);
+ QCOMPARE(textinputObject->selectionEnd(), selection1End);
+
+ textinputObject->moveCursorSelection(movePosition2, QQuickTextInput::SelectWords);
+ QCOMPARE(textinputObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start));
+ QCOMPARE(textinputObject->selectionStart(), selection2Start);
+ QCOMPARE(textinputObject->selectionEnd(), selection2End);
+
+ delete textinputObject;
+}
+
+void tst_qquicktextinput::dragMouseSelection()
+{
+ QString qmlfile = testFile("mouseselection_true.qml");
+
+ QQuickView canvas(QUrl::fromLocalFile(qmlfile));
+
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextInput *textInputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
+ QVERIFY(textInputObject != 0);
+
+ // press-and-drag-and-release from x1 to x2
+ int x1 = 10;
+ int x2 = 70;
+ int y = textInputObject->height()/2;
+ QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
+ QTest::mouseMove(&canvas, QPoint(x2, y));
+ QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
+ QTest::qWait(100);
+ QString str1;
+ QVERIFY((str1 = textInputObject->selectedText()).length() > 3);
+ QVERIFY(str1.length() > 3);
+
+ // press and drag the current selection.
+ x1 = 40;
+ x2 = 100;
+ QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
+ QTest::mouseMove(&canvas, QPoint(x2, y));
+ QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
+ QTest::qWait(300);
+ QString str2 = textInputObject->selectedText();
+ QVERIFY(str2.length() > 3);
+
+ QVERIFY(str1 != str2);
+}
+
+void tst_qquicktextinput::mouseSelectionMode_data()
+{
+ QTest::addColumn<QString>("qmlfile");
+ QTest::addColumn<bool>("selectWords");
+
+ // import installed
+ QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true;
+ QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false;
+ QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false;
+}
+
+void tst_qquicktextinput::mouseSelectionMode()
+{
+ QFETCH(QString, qmlfile);
+ QFETCH(bool, selectWords);
+
+ QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+ QQuickView canvas(QUrl::fromLocalFile(qmlfile));
+
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextInput *textInputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
+ QVERIFY(textInputObject != 0);
+
+ // press-and-drag-and-release from x1 to x2
+ int x1 = 10;
+ int x2 = 70;
+ int y = textInputObject->height()/2;
+ QTest::mousePress(&canvas, Qt::LeftButton, 0, QPoint(x1,y));
+ QTest::mouseMove(&canvas, QPoint(x2,y)); // doesn't work
+ QTest::mouseRelease(&canvas, Qt::LeftButton, 0, QPoint(x2,y));
+ QTest::qWait(300);
+ if (selectWords) {
+ QTRY_COMPARE(textInputObject->selectedText(), text);
+ } else {
+ QTRY_VERIFY(textInputObject->selectedText().length() > 3);
+ QVERIFY(textInputObject->selectedText() != text);
+ }
+}
+
+void tst_qquicktextinput::horizontalAlignment_data()
+{
+ QTest::addColumn<int>("hAlign");
+ QTest::addColumn<QString>("expectfile");
+
+ QTest::newRow("L") << int(Qt::AlignLeft) << "halign_left";
+ QTest::newRow("R") << int(Qt::AlignRight) << "halign_right";
+ QTest::newRow("C") << int(Qt::AlignHCenter) << "halign_center";
+}
+
+void tst_qquicktextinput::horizontalAlignment()
+{
+ QSKIP("Image comparison of text is almost guaranteed to fail during development");
+
+ QFETCH(int, hAlign);
+ QFETCH(QString, expectfile);
+
+ QQuickView canvas(testFileUrl("horizontalAlignment.qml"));
+
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+ QObject *ob = canvas.rootObject();
+ QVERIFY(ob != 0);
+ ob->setProperty("horizontalAlignment",hAlign);
+ QImage actual = canvas.grabFrameBuffer();
+
+ expectfile = createExpectedFileIfNotFound(expectfile, actual);
+
+ QImage expect(expectfile);
+
+ QCOMPARE(actual,expect);
+}
+
+void tst_qquicktextinput::horizontalAlignment_RightToLeft()
+{
+ PlatformInputContext platformInputContext;
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &platformInputContext;
+
+ QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml"));
+ QQuickTextInput *textInput = canvas.rootObject()->findChild<QQuickTextInput*>("text");
+ QVERIFY(textInput != 0);
+ canvas.show();
+
+ const QString rtlText = textInput->text();
+
+ QQuickTextInputPrivate *textInputPrivate = QQuickTextInputPrivate::get(textInput);
+ QVERIFY(textInputPrivate != 0);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ // implicit alignment should follow the reading direction of RTL text
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ // explicitly left aligned
+ textInput->setHAlign(QQuickTextInput::AlignLeft);
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
+ QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
+
+ // explicitly right aligned
+ textInput->setHAlign(QQuickTextInput::AlignRight);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ // explicitly center aligned
+ textInput->setHAlign(QQuickTextInput::AlignHCenter);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignHCenter);
+ QVERIFY(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll > 0);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll < textInput->width());
+
+ // reseted alignment should go back to following the text reading direction
+ textInput->resetHAlign();
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ // mirror the text item
+ QQuickItemPrivate::get(textInput)->setLayoutMirror(true);
+
+ // mirrored implicit alignment should continue to follow the reading direction of the text
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ // explicitly right aligned behaves as left aligned
+ textInput->setHAlign(QQuickTextInput::AlignRight);
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QCOMPARE(textInput->effectiveHAlign(), QQuickTextInput::AlignLeft);
+ QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
+
+ // mirrored explicitly left aligned behaves as right aligned
+ textInput->setHAlign(QQuickTextInput::AlignLeft);
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
+ QCOMPARE(textInput->effectiveHAlign(), QQuickTextInput::AlignRight);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ // disable mirroring
+ QQuickItemPrivate::get(textInput)->setLayoutMirror(false);
+ QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign());
+ textInput->resetHAlign();
+
+ // English text should be implicitly left aligned
+ textInput->setText("Hello world!");
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
+ QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
+
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ // If there is no commited text, the preedit text should determine the alignment.
+ textInput->setText(QString());
+ { QInputMethodEvent ev(rtlText, QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ { QInputMethodEvent ev("Hello world!", QList<QInputMethodEvent::Attribute>()); QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
+
+ // Clear pre-edit text. TextInput should maybe do this itself on setText, but that may be
+ // redundant as an actual input method may take care of it.
+ { QInputMethodEvent ev; QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev); }
+
+ // empty text with implicit alignment follows the system locale-based
+ // keyboard input direction from QInputMethod::inputDirection()
+ textInput->setText("");
+ platformInputContext.setInputDirection(Qt::LeftToRight);
+ QVERIFY(qApp->inputMethod()->inputDirection() == Qt::LeftToRight);
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignLeft);
+ QCOMPARE(textInputPrivate->boundingRect.left() - textInputPrivate->hscroll, qreal(0));
+
+ QSignalSpy cursorRectangleSpy(textInput, SIGNAL(cursorRectangleChanged()));
+ platformInputContext.setInputDirection(Qt::RightToLeft);
+ QVERIFY(qApp->inputMethod()->inputDirection() == Qt::RightToLeft);
+ QCOMPARE(cursorRectangleSpy.count(), 1);
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ // set input direction while having content
+ platformInputContext.setInputDirection(Qt::LeftToRight);
+ textInput->setText("a");
+ platformInputContext.setInputDirection(Qt::RightToLeft);
+ QTest::keyClick(&canvas, Qt::Key_Backspace);
+ QVERIFY(textInput->text().isEmpty());
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ // input direction changed while not having focus
+ platformInputContext.setInputDirection(Qt::LeftToRight);
+ textInput->setFocus(false);
+ platformInputContext.setInputDirection(Qt::RightToLeft);
+ textInput->setFocus(true);
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+
+ textInput->setHAlign(QQuickTextInput::AlignRight);
+ QCOMPARE(textInput->hAlign(), QQuickTextInput::AlignRight);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll >= textInput->width() - 1);
+ QVERIFY(textInputPrivate->boundingRect.right() - textInputPrivate->hscroll <= textInput->width() + 1);
+}
+
+void tst_qquicktextinput::verticalAlignment()
+{
+ QQuickView canvas(testFileUrl("horizontalAlignment.qml"));
+ QQuickTextInput *textInput = canvas.rootObject()->findChild<QQuickTextInput*>("text");
+ QVERIFY(textInput != 0);
+ canvas.show();
+
+ QQuickTextInputPrivate *textInputPrivate = QQuickTextInputPrivate::get(textInput);
+ QVERIFY(textInputPrivate != 0);
+
+ QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignTop);
+ QVERIFY(textInputPrivate->boundingRect.bottom() - textInputPrivate->vscroll < canvas.height() / 2);
+ QVERIFY(textInput->cursorRectangle().bottom() < canvas.height() / 2);
+ QVERIFY(textInput->positionToRectangle(0).bottom() < canvas.height() / 2);
+
+ // bottom aligned
+ textInput->setVAlign(QQuickTextInput::AlignBottom);
+ QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignBottom);
+ QVERIFY(textInputPrivate->boundingRect.top() - textInputPrivate->vscroll > canvas.height() / 2);
+ QVERIFY(textInput->cursorRectangle().top() > canvas.height() / 2);
+ QVERIFY(textInput->positionToRectangle(0).top() > canvas.height() / 2);
+
+ // explicitly center aligned
+ textInput->setVAlign(QQuickTextInput::AlignVCenter);
+ QCOMPARE(textInput->vAlign(), QQuickTextInput::AlignVCenter);
+ QVERIFY(textInputPrivate->boundingRect.top() - textInputPrivate->vscroll < canvas.height() / 2);
+ QVERIFY(textInputPrivate->boundingRect.bottom() - textInputPrivate->vscroll > canvas.height() / 2);
+ QVERIFY(textInput->cursorRectangle().top() < canvas.height() / 2);
+ QVERIFY(textInput->cursorRectangle().bottom() > canvas.height() / 2);
+ QVERIFY(textInput->positionToRectangle(0).top() < canvas.height() / 2);
+ QVERIFY(textInput->positionToRectangle(0).bottom() > canvas.height() / 2);
+}
+
+void tst_qquicktextinput::boundingRect()
+{
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\n TextInput {}", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(object.data());
+ QVERIFY(input);
+
+ QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width());
+ QCOMPARE(input->height(), input->boundingRect().height());
+
+ input->setText("Hello World");
+ QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width());
+ QCOMPARE(input->height(), input->boundingRect().height());
+
+ // bounding rect shouldn't exceed the size of the item, expect for the cursor width;
+ input->setWidth(input->width() / 2);
+ QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width());
+ QCOMPARE(input->height(), input->boundingRect().height());
+
+ input->setHeight(input->height() * 2);
+ QCOMPARE(input->width() + input->cursorRectangle().width(), input->boundingRect().width());
+ QCOMPARE(input->height(), input->boundingRect().height());
+
+ QQmlComponent cursorComponent(&engine);
+ cursorComponent.setData("import QtQuick 2.0\nRectangle { height: 20; width: 8 }", QUrl());
+
+ input->setCursorDelegate(&cursorComponent);
+
+ // If a cursor delegate is used it's size should determine the excess width.
+ QCOMPARE(input->width() + 8, input->boundingRect().width());
+ QCOMPARE(input->height(), input->boundingRect().height());
+}
+
+void tst_qquicktextinput::positionAt()
+{
+ QQuickView canvas(testFileUrl("positionAt.qml"));
+ QVERIFY(canvas.rootObject() != 0);
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
+ QVERIFY(textinputObject != 0);
+
+ // Check autoscrolled...
+
+ int pos = evaluate<int>(textinputObject, QString("positionAt(%1)").arg(textinputObject->width()/2));
+
+ QTextLayout layout(textinputObject->text());
+ layout.setFont(textinputObject->font());
+
+ if (!qmlDisableDistanceField()) {
+ QTextOption option;
+ option.setUseDesignMetrics(true);
+ layout.setTextOption(option);
+ }
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ int textLeftWidthBegin = floor(line.cursorToX(pos - 1));
+ int textLeftWidthEnd = ceil(line.cursorToX(pos + 1));
+ int textWidth = floor(line.horizontalAdvance());
+
+ QVERIFY(textLeftWidthBegin <= textWidth - textinputObject->width() / 2);
+ QVERIFY(textLeftWidthEnd >= textWidth - textinputObject->width() / 2);
+
+ int x = textinputObject->positionToRectangle(pos + 1).x() - 1;
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, 0, TextInput.CursorBetweenCharacters)").arg(x)), pos + 1);
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, 0, TextInput.CursorOnCharacter)").arg(x)), pos);
+
+ // Check without autoscroll...
+ textinputObject->setAutoScroll(false);
+ pos = evaluate<int>(textinputObject, QString("positionAt(%1)").arg(textinputObject->width() / 2));
+
+ textLeftWidthBegin = floor(line.cursorToX(pos - 1));
+ textLeftWidthEnd = ceil(line.cursorToX(pos + 1));
+
+ QVERIFY(textLeftWidthBegin <= textinputObject->width() / 2);
+ QVERIFY(textLeftWidthEnd >= textinputObject->width() / 2);
+
+ x = textinputObject->positionToRectangle(pos + 1).x() - 1;
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, 0, TextInput.CursorBetweenCharacters)").arg(x)), pos + 1);
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, 0, TextInput.CursorOnCharacter)").arg(x)), pos);
+
+ const qreal x0 = textinputObject->positionToRectangle(pos).x();
+ const qreal x1 = textinputObject->positionToRectangle(pos + 1).x();
+
+ QString preeditText = textinputObject->text().mid(0, pos);
+ textinputObject->setText(textinputObject->text().mid(pos));
+ textinputObject->setCursorPosition(0);
+
+ { QInputMethodEvent inputEvent(preeditText, QList<QInputMethodEvent::Attribute>());
+ QVERIFY(qGuiApp->focusObject());
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent); }
+
+ // Check all points within the preedit text return the same position.
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1)").arg(0)), 0);
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1)").arg(x0 / 2)), 0);
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1)").arg(x0)), 0);
+
+ // Verify positioning returns to normal after the preedit text.
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1)").arg(x1)), 1);
+ QCOMPARE(textinputObject->positionToRectangle(1).x(), x1);
+
+ { QInputMethodEvent inputEvent;
+ QVERIFY(qGuiApp->focusObject());
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &inputEvent); }
+
+ // With wrapping.
+ textinputObject->setWrapMode(QQuickTextInput::WrapAnywhere);
+
+ const qreal y0 = line.height() / 2;
+ const qreal y1 = line.height() * 3 / 2;
+
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, %2)").arg(x0).arg(y0)), pos);
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, %2)").arg(x1).arg(y0)), pos + 1);
+
+ int newLinePos = evaluate<int>(textinputObject, QString("positionAt(%1, %2)").arg(x0).arg(y1));
+ QVERIFY(newLinePos > pos);
+ QCOMPARE(evaluate<int>(textinputObject, QString("positionAt(%1, %2)").arg(x1).arg(y1)), newLinePos + 1);
+}
+
+void tst_qquicktextinput::maxLength()
+{
+ QQuickView canvas(testFileUrl("maxLength.qml"));
+ QVERIFY(canvas.rootObject() != 0);
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
+ QVERIFY(textinputObject != 0);
+ QVERIFY(textinputObject->text().isEmpty());
+ QVERIFY(textinputObject->maxLength() == 10);
+ foreach (const QString &str, standard) {
+ QVERIFY(textinputObject->text().length() <= 10);
+ textinputObject->setText(str);
+ QVERIFY(textinputObject->text().length() <= 10);
+ }
+
+ textinputObject->setText("");
+ QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
+ for (int i=0; i<20; i++) {
+ QTRY_COMPARE(textinputObject->text().length(), qMin(i,10));
+ //simulateKey(&canvas, Qt::Key_A);
+ QTest::keyPress(&canvas, Qt::Key_A);
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ }
+}
+
+void tst_qquicktextinput::masks()
+{
+ //Not a comprehensive test of the possible masks, that's done elsewhere (QLineEdit)
+ //QString componentStr = "import QtQuick 2.0\nTextInput { inputMask: 'HHHHhhhh'; }";
+ QQuickView canvas(testFileUrl("masks.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextInput *textinputObject = qobject_cast<QQuickTextInput *>(canvas.rootObject());
+ QVERIFY(textinputObject != 0);
+ QTRY_VERIFY(textinputObject->hasActiveFocus() == true);
+ QVERIFY(textinputObject->text().length() == 0);
+ QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; "));
+ QCOMPARE(textinputObject->length(), 8);
+ for (int i=0; i<10; i++) {
+ QTRY_COMPARE(qMin(i,8), textinputObject->text().length());
+ QCOMPARE(textinputObject->length(), 8);
+ QCOMPARE(textinputObject->getText(0, qMin(i, 8)), QString(qMin(i, 8), 'a'));
+ QCOMPARE(textinputObject->getText(qMin(i, 8), 8), QString(8 - qMin(i, 8), ' '));
+ QCOMPARE(i>=4, textinputObject->hasAcceptableInput());
+ //simulateKey(&canvas, Qt::Key_A);
+ QTest::keyPress(&canvas, Qt::Key_A);
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ }
+}
+
+void tst_qquicktextinput::validators()
+{
+ // Note that this test assumes that the validators are working properly
+ // so you may need to run their tests first. All validators are checked
+ // here to ensure that their exposure to QML is working.
+
+ QLocale::setDefault(QLocale(QStringLiteral("C")));
+
+ QQuickView canvas(testFileUrl("validators.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QLocale defaultLocale;
+ QLocale enLocale("en");
+ QLocale deLocale("de_DE");
+
+ QQuickTextInput *intInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("intInput")));
+ QVERIFY(intInput);
+ QSignalSpy intSpy(intInput, SIGNAL(acceptableInputChanged()));
+
+ QQuickIntValidator *intValidator = qobject_cast<QQuickIntValidator *>(intInput->validator());
+ QVERIFY(intValidator);
+ QCOMPARE(intValidator->localeName(), defaultLocale.name());
+ QCOMPARE(intInput->validator()->locale(), defaultLocale);
+ intValidator->setLocaleName(enLocale.name());
+ QCOMPARE(intValidator->localeName(), enLocale.name());
+ QCOMPARE(intInput->validator()->locale(), enLocale);
+ intValidator->resetLocaleName();
+ QCOMPARE(intValidator->localeName(), defaultLocale.name());
+ QCOMPARE(intInput->validator()->locale(), defaultLocale);
+
+ intInput->setFocus(true);
+ QTRY_VERIFY(intInput->hasActiveFocus());
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ QCOMPARE(intInput->property("acceptable").toBool(), false);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(intInput->text(), QLatin1String("1"));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ QCOMPARE(intInput->property("acceptable").toBool(), false);
+ QCOMPARE(intSpy.count(), 0);
+ QTest::keyPress(&canvas, Qt::Key_2);
+ QTest::keyRelease(&canvas, Qt::Key_2, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(intInput->text(), QLatin1String("1"));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ QCOMPARE(intInput->property("acceptable").toBool(), false);
+ QCOMPARE(intSpy.count(), 0);
+ QTest::keyPress(&canvas, Qt::Key_Period);
+ QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(intInput->text(), QLatin1String("1"));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ QTest::keyPress(&canvas, Qt::Key_Comma);
+ QTest::keyRelease(&canvas, Qt::Key_Comma, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(intInput->text(), QLatin1String("1,"));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(intInput->text(), QLatin1String("1"));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ intValidator->setLocaleName(deLocale.name());
+ QTest::keyPress(&canvas, Qt::Key_Period);
+ QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(intInput->text(), QLatin1String("1."));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(intInput->text(), QLatin1String("1"));
+ QCOMPARE(intInput->hasAcceptableInput(), false);
+ intValidator->resetLocaleName();
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QCOMPARE(intInput->text(), QLatin1String("11"));
+ QCOMPARE(intInput->hasAcceptableInput(), true);
+ QCOMPARE(intInput->property("acceptable").toBool(), true);
+ QCOMPARE(intSpy.count(), 1);
+ QTest::keyPress(&canvas, Qt::Key_0);
+ QTest::keyRelease(&canvas, Qt::Key_0, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QCOMPARE(intInput->text(), QLatin1String("11"));
+ QCOMPARE(intInput->hasAcceptableInput(), true);
+ QCOMPARE(intInput->property("acceptable").toBool(), true);
+ QCOMPARE(intSpy.count(), 1);
+
+ QQuickTextInput *dblInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("dblInput")));
+ QVERIFY(dblInput);
+ QSignalSpy dblSpy(dblInput, SIGNAL(acceptableInputChanged()));
+
+ QQuickDoubleValidator *dblValidator = qobject_cast<QQuickDoubleValidator *>(dblInput->validator());
+ QVERIFY(dblValidator);
+ QCOMPARE(dblValidator->localeName(), defaultLocale.name());
+ QCOMPARE(dblInput->validator()->locale(), defaultLocale);
+ dblValidator->setLocaleName(enLocale.name());
+ QCOMPARE(dblValidator->localeName(), enLocale.name());
+ QCOMPARE(dblInput->validator()->locale(), enLocale);
+ dblValidator->resetLocaleName();
+ QCOMPARE(dblValidator->localeName(), defaultLocale.name());
+ QCOMPARE(dblInput->validator()->locale(), defaultLocale);
+
+ dblInput->setFocus(true);
+ QVERIFY(dblInput->hasActiveFocus() == true);
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QCOMPARE(dblSpy.count(), 0);
+ QTest::keyPress(&canvas, Qt::Key_2);
+ QTest::keyRelease(&canvas, Qt::Key_2, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QCOMPARE(dblInput->property("acceptable").toBool(), true);
+ QCOMPARE(dblSpy.count(), 1);
+ QTest::keyPress(&canvas, Qt::Key_Comma);
+ QTest::keyRelease(&canvas, Qt::Key_Comma, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12,"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12,"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ dblValidator->setLocaleName(deLocale.name());
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12,1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12,11"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12,1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12,"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ dblValidator->resetLocaleName();
+ QTest::keyPress(&canvas, Qt::Key_Period);
+ QTest::keyRelease(&canvas, Qt::Key_Period, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12."));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QCOMPARE(dblInput->property("acceptable").toBool(), true);
+ QCOMPARE(dblSpy.count(), 1);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12.1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QCOMPARE(dblInput->property("acceptable").toBool(), true);
+ QCOMPARE(dblSpy.count(), 1);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QCOMPARE(dblInput->property("acceptable").toBool(), true);
+ QCOMPARE(dblSpy.count(), 1);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QCOMPARE(dblInput->property("acceptable").toBool(), true);
+ QCOMPARE(dblSpy.count(), 1);
+
+ // Ensure the validator doesn't prevent characters being removed.
+ dblInput->setValidator(intInput->validator());
+ QCOMPARE(dblInput->text(), QLatin1String("12.11"));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QCOMPARE(dblSpy.count(), 2);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12.1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QCOMPARE(dblSpy.count(), 2);
+ // Once unacceptable input is in anything goes until it reaches an acceptable state again.
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12.11"));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblSpy.count(), 2);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12.1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QCOMPARE(dblSpy.count(), 2);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12."));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QCOMPARE(dblSpy.count(), 2);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("12"));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QCOMPARE(dblSpy.count(), 2);
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QTest::keyRelease(&canvas, Qt::Key_Backspace, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(dblInput->text(), QLatin1String("1"));
+ QCOMPARE(dblInput->hasAcceptableInput(), false);
+ QCOMPARE(dblInput->property("acceptable").toBool(), false);
+ QCOMPARE(dblSpy.count(), 2);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QCOMPARE(dblInput->text(), QLatin1String("11"));
+ QCOMPARE(dblInput->property("acceptable").toBool(), true);
+ QCOMPARE(dblInput->hasAcceptableInput(), true);
+ QCOMPARE(dblSpy.count(), 3);
+
+ QQuickTextInput *strInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("strInput")));
+ QVERIFY(strInput);
+ QSignalSpy strSpy(strInput, SIGNAL(acceptableInputChanged()));
+ strInput->setFocus(true);
+ QVERIFY(strInput->hasActiveFocus() == true);
+ QCOMPARE(strInput->hasAcceptableInput(), false);
+ QCOMPARE(strInput->property("acceptable").toBool(), false);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String(""));
+ QCOMPARE(strInput->hasAcceptableInput(), false);
+ QCOMPARE(strInput->property("acceptable").toBool(), false);
+ QCOMPARE(strSpy.count(), 0);
+ QTest::keyPress(&canvas, Qt::Key_A);
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String("a"));
+ QCOMPARE(strInput->hasAcceptableInput(), false);
+ QCOMPARE(strInput->property("acceptable").toBool(), false);
+ QCOMPARE(strSpy.count(), 0);
+ QTest::keyPress(&canvas, Qt::Key_A);
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String("aa"));
+ QCOMPARE(strInput->hasAcceptableInput(), true);
+ QCOMPARE(strInput->property("acceptable").toBool(), true);
+ QCOMPARE(strSpy.count(), 1);
+ QTest::keyPress(&canvas, Qt::Key_A);
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String("aaa"));
+ QCOMPARE(strInput->hasAcceptableInput(), true);
+ QCOMPARE(strInput->property("acceptable").toBool(), true);
+ QCOMPARE(strSpy.count(), 1);
+ QTest::keyPress(&canvas, Qt::Key_A);
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String("aaaa"));
+ QCOMPARE(strInput->hasAcceptableInput(), true);
+ QCOMPARE(strInput->property("acceptable").toBool(), true);
+ QCOMPARE(strSpy.count(), 1);
+ QTest::keyPress(&canvas, Qt::Key_A);
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(strInput->text(), QLatin1String("aaaa"));
+ QCOMPARE(strInput->hasAcceptableInput(), true);
+ QCOMPARE(strInput->property("acceptable").toBool(), true);
+ QCOMPARE(strSpy.count(), 1);
+
+ QQuickTextInput *unvalidatedInput = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("unvalidatedInput")));
+ QVERIFY(unvalidatedInput);
+ QSignalSpy unvalidatedSpy(unvalidatedInput, SIGNAL(acceptableInputChanged()));
+ unvalidatedInput->setFocus(true);
+ QVERIFY(unvalidatedInput->hasActiveFocus() == true);
+ QCOMPARE(unvalidatedInput->hasAcceptableInput(), true);
+ QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true);
+ QTest::keyPress(&canvas, Qt::Key_1);
+ QTest::keyRelease(&canvas, Qt::Key_1, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(unvalidatedInput->text(), QLatin1String("1"));
+ QCOMPARE(unvalidatedInput->hasAcceptableInput(), true);
+ QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true);
+ QCOMPARE(unvalidatedSpy.count(), 0);
+ QTest::keyPress(&canvas, Qt::Key_A);
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QTest::qWait(50);
+ QTRY_COMPARE(unvalidatedInput->text(), QLatin1String("1a"));
+ QCOMPARE(unvalidatedInput->hasAcceptableInput(), true);
+ QCOMPARE(unvalidatedInput->property("acceptable").toBool(), true);
+ QCOMPARE(unvalidatedSpy.count(), 0);
+}
+
+void tst_qquicktextinput::inputMethods()
+{
+ QQuickView canvas(testFileUrl("inputmethods.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+
+ // test input method hints
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(canvas.rootObject());
+ QVERIFY(input != 0);
+ QVERIFY(input->inputMethodHints() & Qt::ImhNoPredictiveText);
+ QSignalSpy inputMethodHintSpy(input, SIGNAL(inputMethodHintsChanged()));
+ input->setInputMethodHints(Qt::ImhUppercaseOnly);
+ QVERIFY(input->inputMethodHints() & Qt::ImhUppercaseOnly);
+ QCOMPARE(inputMethodHintSpy.count(), 1);
+ input->setInputMethodHints(Qt::ImhUppercaseOnly);
+ QCOMPARE(inputMethodHintSpy.count(), 1);
+
+ // default value
+ QQuickTextInput plainInput;
+ QCOMPARE(plainInput.inputMethodHints(), Qt::ImhNone);
+
+ input->setFocus(true);
+ QVERIFY(input->hasActiveFocus() == true);
+ // test that input method event is committed
+ QInputMethodEvent event;
+ event.setCommitString( "My ", -12, 0);
+ QTRY_COMPARE(qGuiApp->focusObject(), input);
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
+ QCOMPARE(input->text(), QString("My Hello world!"));
+
+ input->setCursorPosition(2);
+ event.setCommitString("Your", -2, 2);
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
+ QCOMPARE(input->text(), QString("Your Hello world!"));
+ QCOMPARE(input->cursorPosition(), 4);
+
+ input->setCursorPosition(7);
+ event.setCommitString("Goodbye", -2, 5);
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
+ QCOMPARE(input->text(), QString("Your Goodbye world!"));
+ QCOMPARE(input->cursorPosition(), 12);
+
+ input->setCursorPosition(8);
+ event.setCommitString("Our", -8, 4);
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
+ QCOMPARE(input->text(), QString("Our Goodbye world!"));
+ QCOMPARE(input->cursorPosition(), 7);
+
+ // test that basic tentative commit gets to text property on preedit state
+ input->setText("");
+ QList<QInputMethodEvent::Attribute> attributes;
+ QInputMethodEvent preeditEvent("test", attributes);
+ preeditEvent.setTentativeCommitString("test");
+ QGuiApplication::sendEvent(input, &preeditEvent);
+ QCOMPARE(input->text(), QString("test"));
+
+ // tentative commit not allowed present in surrounding text
+ QInputMethodQueryEvent queryEvent(Qt::ImSurroundingText);
+ QGuiApplication::sendEvent(input, &queryEvent);
+ QCOMPARE(queryEvent.value(Qt::ImSurroundingText).toString(), QString(""));
+
+ // if text with tentative commit does not validate, not allowed to be part of text property
+ input->setText(""); // ensure input state is reset
+ QValidator *validator = new QIntValidator(0, 100);
+ input->setValidator(validator);
+ QGuiApplication::sendEvent(input, &preeditEvent);
+ QCOMPARE(input->text(), QString(""));
+ input->setValidator(0);
+ delete validator;
+
+ // input should reset selection even if replacement parameters are out of bounds
+ input->setText("text");
+ input->setCursorPosition(0);
+ input->moveCursorSelection(input->text().length());
+ event.setCommitString("replacement", -input->text().length(), input->text().length());
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
+ QCOMPARE(input->selectionStart(), input->selectionEnd());
+
+ QInputMethodQueryEvent enabledQueryEvent(Qt::ImEnabled);
+ QGuiApplication::sendEvent(input, &enabledQueryEvent);
+ QCOMPARE(enabledQueryEvent.value(Qt::ImEnabled).toBool(), true);
+
+ input->setReadOnly(true);
+ QGuiApplication::sendEvent(input, &enabledQueryEvent);
+ QCOMPARE(enabledQueryEvent.value(Qt::ImEnabled).toBool(), false);
+}
+
+/*
+TextInput element should only handle left/right keys until the cursor reaches
+the extent of the text, then they should ignore the keys.
+
+*/
+void tst_qquicktextinput::navigation()
+{
+ QQuickView canvas(testFileUrl("navigation.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ input->setCursorPosition(0);
+ QTRY_VERIFY(input->hasActiveFocus() == true);
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == false);
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == true);
+ //QT-2944: If text is selected, ensure we deselect upon cursor motion
+ input->setCursorPosition(input->text().length());
+ input->select(0,input->text().length());
+ QVERIFY(input->selectionStart() != input->selectionEnd());
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->selectionStart() == input->selectionEnd());
+ QVERIFY(input->selectionStart() == input->text().length());
+ QVERIFY(input->hasActiveFocus() == true);
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == false);
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == true);
+
+ // Up and Down should NOT do Home/End, even on Mac OS X (QTBUG-10438).
+ input->setCursorPosition(2);
+ QCOMPARE(input->cursorPosition(),2);
+ simulateKey(&canvas, Qt::Key_Up);
+ QCOMPARE(input->cursorPosition(),2);
+ simulateKey(&canvas, Qt::Key_Down);
+ QCOMPARE(input->cursorPosition(),2);
+}
+
+void tst_qquicktextinput::navigation_RTL()
+{
+ QQuickView canvas(testFileUrl("navigation.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647};
+ input->setText(QString::fromUtf16(arabic_str, 11));
+
+ input->setCursorPosition(0);
+ QTRY_VERIFY(input->hasActiveFocus() == true);
+
+ // move off
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == false);
+
+ // move back
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == true);
+
+ input->setCursorPosition(input->text().length());
+ QVERIFY(input->hasActiveFocus() == true);
+
+ // move off
+ simulateKey(&canvas, Qt::Key_Left);
+ QVERIFY(input->hasActiveFocus() == false);
+
+ // move back
+ simulateKey(&canvas, Qt::Key_Right);
+ QVERIFY(input->hasActiveFocus() == true);
+}
+
+void tst_qquicktextinput::copyAndPaste() {
+#ifndef QT_NO_CLIPBOARD
+
+#ifdef Q_OS_MAC
+ {
+ PasteboardRef pasteboard;
+ OSStatus status = PasteboardCreate(0, &pasteboard);
+ if (status == noErr)
+ CFRelease(pasteboard);
+ else
+ QSKIP("This machine doesn't support the clipboard");
+ }
+#endif
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ // copy and paste
+ QCOMPARE(textInput->text().length(), 12);
+ textInput->select(0, textInput->text().length());;
+ textInput->copy();
+ QCOMPARE(textInput->selectedText(), QString("Hello world!"));
+ QCOMPARE(textInput->selectedText().length(), 12);
+ textInput->setCursorPosition(0);
+ QVERIFY(textInput->canPaste());
+ textInput->paste();
+ QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
+ QCOMPARE(textInput->text().length(), 24);
+
+ // can paste
+ QVERIFY(textInput->canPaste());
+ textInput->setReadOnly(true);
+ QVERIFY(!textInput->canPaste());
+ textInput->setReadOnly(false);
+ QVERIFY(textInput->canPaste());
+
+ // select word
+ textInput->setCursorPosition(0);
+ textInput->selectWord();
+ QCOMPARE(textInput->selectedText(), QString("Hello"));
+
+ // select all and cut
+ textInput->selectAll();
+ textInput->cut();
+ QCOMPARE(textInput->text().length(), 0);
+ textInput->paste();
+ QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
+ QCOMPARE(textInput->text().length(), 24);
+
+ // clear copy buffer
+ QClipboard *clipboard = QGuiApplication::clipboard();
+ QVERIFY(clipboard);
+ clipboard->clear();
+ QVERIFY(!textInput->canPaste());
+
+ // test that copy functionality is disabled
+ // when echo mode is set to hide text/password mode
+ int index = 0;
+ while (index < 4) {
+ QQuickTextInput::EchoMode echoMode = QQuickTextInput::EchoMode(index);
+ textInput->setEchoMode(echoMode);
+ textInput->setText("My password");
+ textInput->select(0, textInput->text().length());;
+ textInput->copy();
+ if (echoMode == QQuickTextInput::Normal) {
+ QVERIFY(!clipboard->text().isEmpty());
+ QCOMPARE(clipboard->text(), QString("My password"));
+ clipboard->clear();
+ } else {
+ QVERIFY(clipboard->text().isEmpty());
+ }
+ index++;
+ }
+
+ delete textInput;
+#endif
+}
+
+void tst_qquicktextinput::copyAndPasteKeySequence() {
+#ifndef QT_NO_CLIPBOARD
+
+#ifdef Q_OS_MAC
+ {
+ PasteboardRef pasteboard;
+ OSStatus status = PasteboardCreate(0, &pasteboard);
+ if (status == noErr)
+ CFRelease(pasteboard);
+ else
+ QSKIP("This machine doesn't support the clipboard");
+ }
+#endif
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\"; focus: true }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ QQuickCanvas canvas;
+ textInput->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ // copy and paste
+ QVERIFY(textInput->hasActiveFocus());
+ QCOMPARE(textInput->text().length(), 12);
+ textInput->select(0, textInput->text().length());
+ simulateKeys(&canvas, QKeySequence::Copy);
+ QCOMPARE(textInput->selectedText(), QString("Hello world!"));
+ QCOMPARE(textInput->selectedText().length(), 12);
+ textInput->setCursorPosition(0);
+ QVERIFY(textInput->canPaste());
+ simulateKeys(&canvas, QKeySequence::Paste);
+ QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
+ QCOMPARE(textInput->text().length(), 24);
+
+ // select all and cut
+ simulateKeys(&canvas, QKeySequence::SelectAll);
+ simulateKeys(&canvas, QKeySequence::Cut);
+ QCOMPARE(textInput->text().length(), 0);
+ simulateKeys(&canvas, QKeySequence::Paste);
+ QCOMPARE(textInput->text(), QString("Hello world!Hello world!"));
+ QCOMPARE(textInput->text().length(), 24);
+
+ // clear copy buffer
+ QClipboard *clipboard = QGuiApplication::clipboard();
+ QVERIFY(clipboard);
+ clipboard->clear();
+ QVERIFY(!textInput->canPaste());
+
+ // test that copy functionality is disabled
+ // when echo mode is set to hide text/password mode
+ int index = 0;
+ while (index < 4) {
+ QQuickTextInput::EchoMode echoMode = QQuickTextInput::EchoMode(index);
+ textInput->setEchoMode(echoMode);
+ textInput->setText("My password");
+ textInput->select(0, textInput->text().length());;
+ simulateKeys(&canvas, QKeySequence::Copy);
+ if (echoMode == QQuickTextInput::Normal) {
+ QVERIFY(!clipboard->text().isEmpty());
+ QCOMPARE(clipboard->text(), QString("My password"));
+ clipboard->clear();
+ } else {
+ QVERIFY(clipboard->text().isEmpty());
+ }
+ index++;
+ }
+
+ delete textInput;
+#endif
+}
+
+void tst_qquicktextinput::canPasteEmpty() {
+#ifndef QT_NO_CLIPBOARD
+
+ QGuiApplication::clipboard()->clear();
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ bool cp = !textInput->isReadOnly() && QGuiApplication::clipboard()->text().length() != 0;
+ QCOMPARE(textInput->canPaste(), cp);
+
+#endif
+}
+
+void tst_qquicktextinput::canPaste() {
+#ifndef QT_NO_CLIPBOARD
+
+ QGuiApplication::clipboard()->setText("Some text");
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\" }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ bool cp = !textInput->isReadOnly() && QGuiApplication::clipboard()->text().length() != 0;
+ QCOMPARE(textInput->canPaste(), cp);
+
+#endif
+}
+
+void tst_qquicktextinput::passwordCharacter()
+{
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"Hello world!\"; font.family: \"Helvetica\"; echoMode: TextInput.Password }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ textInput->setPasswordCharacter("X");
+ qreal implicitWidth = textInput->implicitWidth();
+ textInput->setPasswordCharacter(".");
+
+ // QTBUG-12383 content is updated and redrawn
+ QVERIFY(textInput->implicitWidth() < implicitWidth);
+
+ delete textInput;
+}
+
+void tst_qquicktextinput::cursorDelegate_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::newRow("out of line") << testFileUrl("cursorTest.qml");
+ QTest::newRow("in line") << testFileUrl("cursorTestInline.qml");
+ QTest::newRow("external") << testFileUrl("cursorTestExternal.qml");
+}
+
+void tst_qquicktextinput::cursorDelegate()
+{
+ QFETCH(QUrl, source);
+ QQuickView view(source);
+ view.show();
+ view.requestActivateWindow();
+ QQuickTextInput *textInputObject = view.rootObject()->findChild<QQuickTextInput*>("textInputObject");
+ QVERIFY(textInputObject != 0);
+ QVERIFY(textInputObject->findChild<QQuickItem*>("cursorInstance"));
+ //Test Delegate gets created
+ textInputObject->setFocus(true);
+ QQuickItem* delegateObject = textInputObject->findChild<QQuickItem*>("cursorInstance");
+ QVERIFY(delegateObject);
+ QCOMPARE(delegateObject->property("localProperty").toString(), QString("Hello"));
+ //Test Delegate gets moved
+ for (int i=0; i<= textInputObject->text().length(); i++) {
+ textInputObject->setCursorPosition(i);
+ QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ }
+ textInputObject->setCursorPosition(0);
+ QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x()));
+ QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y()));
+ //Test Delegate gets deleted
+ textInputObject->setCursorDelegate(0);
+ QVERIFY(!textInputObject->findChild<QQuickItem*>("cursorInstance"));
+}
+
+void tst_qquicktextinput::cursorVisible()
+{
+ QQuickView view(testFileUrl("cursorVisible.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+
+ QQuickTextInput input;
+ input.componentComplete();
+ QSignalSpy spy(&input, SIGNAL(cursorVisibleChanged(bool)));
+
+ QCOMPARE(input.isCursorVisible(), false);
+
+ input.setCursorVisible(true);
+ QCOMPARE(input.isCursorVisible(), true);
+ QCOMPARE(spy.count(), 1);
+
+ input.setCursorVisible(false);
+ QCOMPARE(input.isCursorVisible(), false);
+ QCOMPARE(spy.count(), 2);
+
+ input.setFocus(true);
+ QCOMPARE(input.isCursorVisible(), false);
+ QCOMPARE(spy.count(), 2);
+
+ input.setParentItem(view.rootObject());
+ QCOMPARE(input.isCursorVisible(), true);
+ QCOMPARE(spy.count(), 3);
+
+ input.setFocus(false);
+ QCOMPARE(input.isCursorVisible(), false);
+ QCOMPARE(spy.count(), 4);
+
+ input.setFocus(true);
+ QCOMPARE(input.isCursorVisible(), true);
+ QCOMPARE(spy.count(), 5);
+
+ QQuickView alternateView;
+ alternateView.show();
+ alternateView.requestActivateWindow();
+ QTest::qWaitForWindowShown(&alternateView);
+
+ QCOMPARE(input.isCursorVisible(), false);
+ QCOMPARE(spy.count(), 6);
+
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QCOMPARE(input.isCursorVisible(), true);
+ QCOMPARE(spy.count(), 7);
+}
+
+static QRect round(const QRectF &r) {
+ return QRect(qRound(r.left()), qRound(r.top()), qCeil(r.width()), qCeil(r.height())); }
+
+void tst_qquicktextinput::cursorRectangle()
+{
+
+ QString text = "Hello World!";
+
+ QQuickTextInput input;
+ input.setText(text);
+ input.componentComplete();
+
+ QTextLayout layout(text);
+ layout.setFont(input.font());
+ if (!qmlDisableDistanceField()) {
+ QTextOption option;
+ option.setUseDesignMetrics(true);
+ layout.setTextOption(option);
+ }
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ input.setWidth(line.cursorToX(5, QTextLine::Leading));
+ input.setHeight(qCeil(line.height() * 3 / 2));
+
+ QRect r;
+
+ // some tolerance for different fonts.
+#ifdef Q_OS_LINUX
+ const int error = 2;
+#else
+ const int error = 5;
+#endif
+
+ for (int i = 0; i <= 5; ++i) {
+ input.setCursorPosition(i);
+ r = input.cursorRectangle();
+
+ QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing)));
+ QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading)));
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
+ QCOMPARE(round(input.positionToRectangle(i)), r);
+ }
+
+ // Check the cursor rectangle remains within the input bounding rect when auto scrolling.
+ QVERIFY(r.left() < input.width());
+ QVERIFY(r.right() >= input.width() - error);
+
+ for (int i = 6; i < text.length(); ++i) {
+ input.setCursorPosition(i);
+ QCOMPARE(r, input.cursorRectangle());
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
+ QCOMPARE(round(input.positionToRectangle(i)), r);
+ }
+
+ for (int i = text.length() - 2; i >= 0; --i) {
+ input.setCursorPosition(i);
+ r = input.cursorRectangle();
+ QCOMPARE(r.top(), 0);
+ QVERIFY(r.right() >= 0);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
+ QCOMPARE(round(input.positionToRectangle(i)), r);
+ }
+
+ // Check position with word wrap.
+ input.setWrapMode(QQuickTextInput::WordWrap);
+ input.setAutoScroll(false);
+ for (int i = 0; i <= 5; ++i) {
+ input.setCursorPosition(i);
+ r = input.cursorRectangle();
+
+ QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing)));
+ QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading)));
+ QCOMPARE(r.top(), 0);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
+ QCOMPARE(round(input.positionToRectangle(i)), r);
+ }
+
+ input.setCursorPosition(6);
+ r = input.cursorRectangle();
+ QCOMPARE(r.left(), 0);
+ QVERIFY(r.top() > line.height() - error);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
+ QCOMPARE(round(input.positionToRectangle(6)), r);
+
+ for (int i = 7; i < text.length(); ++i) {
+ input.setCursorPosition(i);
+ r = input.cursorRectangle();
+ QVERIFY(r.top() > line.height() - error);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
+ QCOMPARE(round(input.positionToRectangle(i)), r);
+ }
+
+ // Check vertical scrolling with word wrap.
+ input.setAutoScroll(true);
+ for (int i = 0; i <= 5; ++i) {
+ input.setCursorPosition(i);
+ r = input.cursorRectangle();
+
+ QVERIFY(r.left() < qCeil(line.cursorToX(i, QTextLine::Trailing)));
+ QVERIFY(r.right() >= qFloor(line.cursorToX(i , QTextLine::Leading)));
+ QCOMPARE(r.top(), 0);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
+ QCOMPARE(round(round(input.positionToRectangle(i))), r);
+ }
+
+ input.setCursorPosition(6);
+ r = input.cursorRectangle();
+ QCOMPARE(r.left(), 0);
+ QVERIFY(r.bottom() >= input.height() - error);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
+ QCOMPARE(round(input.positionToRectangle(6)), r);
+
+ for (int i = 7; i < text.length(); ++i) {
+ input.setCursorPosition(i);
+ r = input.cursorRectangle();
+ QVERIFY(r.bottom() >= input.height() - error);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
+ QCOMPARE(round(input.positionToRectangle(i)), r);
+ }
+
+ for (int i = text.length() - 2; i >= 6; --i) {
+ input.setCursorPosition(i);
+ r = input.cursorRectangle();
+ QVERIFY(r.bottom() >= input.height() - error);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
+ QCOMPARE(round(input.positionToRectangle(i)), r);
+ }
+
+ for (int i = 5; i >= 0; --i) {
+ input.setCursorPosition(i);
+ r = input.cursorRectangle();
+ QCOMPARE(r.top(), 0);
+ QCOMPARE(input.inputMethodQuery(Qt::ImCursorRectangle).toRect(), r);
+ QCOMPARE(round(input.positionToRectangle(i)), r);
+ }
+
+ input.setText("Hi!");
+ input.setHAlign(QQuickTextInput::AlignRight);
+ r = input.cursorRectangle();
+ QVERIFY(r.left() < input.width() + error);
+ QVERIFY(r.right() >= input.width() - error);
+}
+
+void tst_qquicktextinput::readOnly()
+{
+ QQuickView canvas(testFileUrl("readOnly.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ QTRY_VERIFY(input->hasActiveFocus() == true);
+ QVERIFY(input->isReadOnly() == true);
+ QString initial = input->text();
+ for (int k=Qt::Key_0; k<=Qt::Key_Z; k++)
+ simulateKey(&canvas, k);
+ simulateKey(&canvas, Qt::Key_Return);
+ simulateKey(&canvas, Qt::Key_Space);
+ simulateKey(&canvas, Qt::Key_Escape);
+ QCOMPARE(input->text(), initial);
+
+ input->setCursorPosition(3);
+ input->setReadOnly(false);
+ QCOMPARE(input->isReadOnly(), false);
+ QCOMPARE(input->cursorPosition(), input->text().length());
+}
+
+void tst_qquicktextinput::echoMode()
+{
+ QQuickView canvas(testFileUrl("echoMode.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
+
+ QVERIFY(input != 0);
+ QTRY_VERIFY(input->hasActiveFocus() == true);
+ QString initial = input->text();
+ Qt::InputMethodHints ref;
+ QCOMPARE(initial, QLatin1String("ABCDefgh"));
+ QCOMPARE(input->echoMode(), QQuickTextInput::Normal);
+ QCOMPARE(input->displayText(), input->text());
+ //Normal
+ ref &= ~Qt::ImhHiddenText;
+ ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
+ QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
+ input->setEchoMode(QQuickTextInput::NoEcho);
+ QCOMPARE(input->text(), initial);
+ QCOMPARE(input->displayText(), QLatin1String(""));
+ QCOMPARE(input->passwordCharacter(), QLatin1String("*"));
+ //NoEcho
+ ref |= Qt::ImhHiddenText;
+ ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
+ QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
+ input->setEchoMode(QQuickTextInput::Password);
+ //Password
+ ref |= Qt::ImhHiddenText;
+ ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
+ QCOMPARE(input->text(), initial);
+ QCOMPARE(input->displayText(), QLatin1String("********"));
+ QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
+ // clearing input hints do not clear bits set by echo mode
+ input->setInputMethodHints(Qt::ImhNone);
+ QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
+ input->setPasswordCharacter(QChar('Q'));
+ QCOMPARE(input->passwordCharacter(), QLatin1String("Q"));
+ QCOMPARE(input->text(), initial);
+ QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
+ input->setEchoMode(QQuickTextInput::PasswordEchoOnEdit);
+ //PasswordEchoOnEdit
+ ref &= ~Qt::ImhHiddenText;
+ ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText | Qt::ImhSensitiveData);
+ QCOMPARE((Qt::InputMethodHints) input->inputMethodQuery(Qt::ImHints).toInt(), ref);
+ QCOMPARE(input->text(), initial);
+ QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
+ QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("QQQQQQQQ"));
+ QTest::keyPress(&canvas, Qt::Key_A);//Clearing previous entry is part of PasswordEchoOnEdit
+ QTest::keyRelease(&canvas, Qt::Key_A, Qt::NoModifier ,10);
+ QCOMPARE(input->text(), QLatin1String("a"));
+ QCOMPARE(input->displayText(), QLatin1String("a"));
+ QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("a"));
+ input->setFocus(false);
+ QVERIFY(input->hasActiveFocus() == false);
+ QCOMPARE(input->displayText(), QLatin1String("Q"));
+ QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("Q"));
+ input->setFocus(true);
+ QVERIFY(input->hasActiveFocus());
+ QInputMethodEvent inputEvent;
+ inputEvent.setCommitString(initial);
+ QGuiApplication::sendEvent(input, &inputEvent);
+ QCOMPARE(input->text(), initial);
+ QCOMPARE(input->displayText(), initial);
+ QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), initial);
+}
+
+#ifdef QT_GUI_PASSWORD_ECHO_DELAY
+void tst_qquicktextinput::passwordEchoDelay()
+{
+ QQuickView canvas(testFileUrl("echoMode.qml"));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(&canvas, qGuiApp->focusWindow());
+
+ QVERIFY(canvas.rootObject() != 0);
+
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(qvariant_cast<QObject *>(canvas.rootObject()->property("myInput")));
+
+ QChar fillChar = QLatin1Char('*');
+
+ input->setEchoMode(QQuickTextInput::Password);
+ QCOMPARE(input->displayText(), QString(8, fillChar));
+ input->setText(QString());
+ QCOMPARE(input->displayText(), QString());
+
+ QTest::keyPress(&canvas, '0');
+ QTest::keyPress(&canvas, '1');
+ QTest::keyPress(&canvas, '2');
+ QCOMPARE(input->displayText(), QString(2, fillChar) + QLatin1Char('2'));
+ QTest::keyPress(&canvas, '3');
+ QTest::keyPress(&canvas, '4');
+ QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4'));
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QCOMPARE(input->displayText(), QString(4, fillChar));
+ QTest::keyPress(&canvas, '4');
+ QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4'));
+ QTest::qWait(QT_GUI_PASSWORD_ECHO_DELAY);
+ QTRY_COMPARE(input->displayText(), QString(5, fillChar));
+ QTest::keyPress(&canvas, '5');
+ QCOMPARE(input->displayText(), QString(5, fillChar) + QLatin1Char('5'));
+ input->setFocus(false);
+ QVERIFY(!input->hasFocus());
+ QCOMPARE(input->displayText(), QString(6, fillChar));
+ input->setFocus(true);
+ QTRY_VERIFY(input->hasFocus());
+ QCOMPARE(input->displayText(), QString(6, fillChar));
+ QTest::keyPress(&canvas, '6');
+ QCOMPARE(input->displayText(), QString(6, fillChar) + QLatin1Char('6'));
+
+ QInputMethodEvent ev;
+ ev.setCommitString(QLatin1String("7"));
+ QGuiApplication::sendEvent(qGuiApp->focusObject(), &ev);
+ QCOMPARE(input->displayText(), QString(7, fillChar) + QLatin1Char('7'));
+
+ input->setCursorPosition(3);
+ QCOMPARE(input->displayText(), QString(7, fillChar) + QLatin1Char('7'));
+ QTest::keyPress(&canvas, 'a');
+ QCOMPARE(input->displayText(), QString(3, fillChar) + QLatin1Char('a') + QString(5, fillChar));
+ QTest::keyPress(&canvas, Qt::Key_Backspace);
+ QCOMPARE(input->displayText(), QString(8, fillChar));
+}
+#endif
+
+
+void tst_qquicktextinput::simulateKey(QQuickView *view, int key)
+{
+ QKeyEvent press(QKeyEvent::KeyPress, key, 0);
+ QKeyEvent release(QKeyEvent::KeyRelease, key, 0);
+
+ QGuiApplication::sendEvent(view, &press);
+ QGuiApplication::sendEvent(view, &release);
+}
+
+
+void tst_qquicktextinput::openInputPanel()
+{
+ PlatformInputContext platformInputContext;
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &platformInputContext;
+
+ QQuickView view(testFileUrl("openInputPanel.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
+ QVERIFY(input);
+
+ // check default values
+ QVERIFY(input->focusOnPress());
+ QVERIFY(!input->hasActiveFocus());
+ QVERIFY(qApp->focusObject() != input);
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+
+ // input panel should open on focus
+ QPoint centerPoint(view.width()/2, view.height()/2);
+ Qt::KeyboardModifiers noModifiers = 0;
+ QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QGuiApplication::processEvents();
+ QVERIFY(input->hasActiveFocus());
+ QCOMPARE(qApp->focusObject(), input);
+ QCOMPARE(qApp->inputMethod()->visible(), true);
+ QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
+
+ // input panel should be re-opened when pressing already focused TextInput
+ qApp->inputMethod()->hide();
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+ QVERIFY(input->hasActiveFocus());
+ QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QGuiApplication::processEvents();
+ QCOMPARE(qApp->inputMethod()->visible(), true);
+ QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
+
+ // input panel should stay visible if focus is lost to another text inputor
+ QSignalSpy inputPanelVisibilitySpy(qApp->inputMethod(), SIGNAL(visibleChanged()));
+ QQuickTextInput anotherInput;
+ anotherInput.componentComplete();
+ anotherInput.setParentItem(view.rootObject());
+ anotherInput.setFocus(true);
+ QCOMPARE(qApp->inputMethod()->visible(), true);
+ QCOMPARE(qApp->focusObject(), qobject_cast<QObject*>(&anotherInput));
+ QCOMPARE(inputPanelVisibilitySpy.count(), 0);
+
+ anotherInput.setFocus(false);
+ QVERIFY(qApp->focusObject() != &anotherInput);
+ QCOMPARE(view.activeFocusItem(), view.rootItem());
+ anotherInput.setFocus(true);
+
+ qApp->inputMethod()->hide();
+
+ // input panel should not be opened if TextInput is read only
+ input->setReadOnly(true);
+ input->setFocus(true);
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+ QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QGuiApplication::processEvents();
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+
+ // input panel should not be opened if focusOnPress is set to false
+ input->setFocusOnPress(false);
+ input->setFocus(false);
+ input->setFocus(true);
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+ QTest::mousePress(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QTest::mouseRelease(&view, Qt::LeftButton, noModifiers, centerPoint);
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+
+ // input panel should open when openSoftwareInputPanel is called
+ input->openSoftwareInputPanel();
+ QCOMPARE(qApp->inputMethod()->visible(), true);
+
+ // input panel should close when closeSoftwareInputPanel is called
+ input->closeSoftwareInputPanel();
+ QCOMPARE(qApp->inputMethod()->visible(), false);
+}
+
+class MyTextInput : public QQuickTextInput
+{
+public:
+ MyTextInput(QQuickItem *parent = 0) : QQuickTextInput(parent)
+ {
+ nbPaint = 0;
+ }
+ virtual QSGNode *updatePaintNode(QSGNode *node, UpdatePaintNodeData *data)
+ {
+ nbPaint++;
+ return QQuickTextInput::updatePaintNode(node, data);
+ }
+ int nbPaint;
+};
+
+void tst_qquicktextinput::setHAlignClearCache()
+{
+ QQuickView view;
+ MyTextInput input;
+ input.setText("Hello world");
+ input.setParentItem(view.rootItem());
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+#ifdef Q_OS_MAC
+ QEXPECT_FAIL("", "QTBUG-23485", Abort);
+#endif
+ QTRY_COMPARE(input.nbPaint, 1);
+ input.setHAlign(QQuickTextInput::AlignRight);
+ //Changing the alignment should trigger a repaint
+ QTRY_COMPARE(input.nbPaint, 2);
+}
+
+void tst_qquicktextinput::focusOutClearSelection()
+{
+ QQuickView view;
+ QQuickTextInput input;
+ QQuickTextInput input2;
+ input.setText(QLatin1String("Hello world"));
+ input.setFocus(true);
+ input2.setParentItem(view.rootItem());
+ input.setParentItem(view.rootItem());
+ input.componentComplete();
+ input2.componentComplete();
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ input.select(2,5);
+ //The selection should work
+ QTRY_COMPARE(input.selectedText(), QLatin1String("llo"));
+ input2.setFocus(true);
+ QGuiApplication::processEvents();
+ //The input lost the focus selection should be cleared
+ QTRY_COMPARE(input.selectedText(), QLatin1String(""));
+}
+
+void tst_qquicktextinput::geometrySignals()
+{
+ QQmlComponent component(&engine, testFileUrl("geometrySignals.qml"));
+ QObject *o = component.create();
+ QVERIFY(o);
+ QCOMPARE(o->property("bindingWidth").toInt(), 400);
+ QCOMPARE(o->property("bindingHeight").toInt(), 500);
+ delete o;
+}
+
+void tst_qquicktextinput::contentSize()
+{
+ QString componentStr = "import QtQuick 2.0\nTextInput { width: 75; height: 16; font.pixelSize: 10 }";
+ QQmlComponent textComponent(&engine);
+ textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> object(textComponent.create());
+ QQuickTextInput *textObject = qobject_cast<QQuickTextInput *>(object.data());
+
+ QSignalSpy spy(textObject, SIGNAL(contentSizeChanged()));
+
+ textObject->setText("The quick red fox jumped over the lazy brown dog");
+
+ QVERIFY(textObject->contentWidth() > textObject->width());
+ QVERIFY(textObject->contentHeight() < textObject->height());
+ QCOMPARE(spy.count(), 1);
+
+ textObject->setWrapMode(QQuickTextInput::WordWrap);
+ QVERIFY(textObject->contentWidth() <= textObject->width());
+ QVERIFY(textObject->contentHeight() > textObject->height());
+ QCOMPARE(spy.count(), 2);
+
+ textObject->setText("The quickredfoxjumpedoverthe lazy brown dog");
+
+ QVERIFY(textObject->contentWidth() > textObject->width());
+ QVERIFY(textObject->contentHeight() > textObject->height());
+ QCOMPARE(spy.count(), 3);
+}
+
+static void sendPreeditText(const QString &text, int cursor)
+{
+ QInputMethodEvent event(text, QList<QInputMethodEvent::Attribute>()
+ << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor, text.length(), QVariant()));
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &event);
+}
+
+void tst_qquicktextinput::preeditAutoScroll()
+{
+ QString preeditText = "califragisiticexpialidocious!";
+
+ QQuickView view(testFileUrl("preeditAutoScroll.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
+ QVERIFY(input);
+ QVERIFY(input->hasActiveFocus());
+
+ input->setWidth(input->implicitWidth());
+
+ QSignalSpy cursorRectangleSpy(input, SIGNAL(cursorRectangleChanged()));
+ int cursorRectangleChanges = 0;
+
+ // test the text is scrolled so the preedit is visible.
+ sendPreeditText(preeditText.mid(0, 3), 1);
+ QVERIFY(evaluate<int>(input, QString("positionAt(0)")) != 0);
+ QVERIFY(input->cursorRectangle().left() < input->boundingRect().width());
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+
+ // test the text is scrolled back when the preedit is removed.
+ QInputMethodEvent imEvent;
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
+ QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(0)), 0);
+ QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(input->width())), 5);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+
+ QTextLayout layout(preeditText);
+ layout.setFont(input->font());
+ if (!qmlDisableDistanceField()) {
+ QTextOption option;
+ option.setUseDesignMetrics(true);
+ layout.setTextOption(option);
+ }
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ // test if the preedit is larger than the text input that the
+ // character preceding the cursor is still visible.
+ qreal x = input->positionToRectangle(0).x();
+ for (int i = 0; i < 3; ++i) {
+ sendPreeditText(preeditText, i + 1);
+ int width = ceil(line.cursorToX(i, QTextLine::Trailing)) - floor(line.cursorToX(i));
+ QVERIFY(input->cursorRectangle().right() >= width - 3);
+ QVERIFY(input->positionToRectangle(0).x() < x);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ x = input->positionToRectangle(0).x();
+ }
+ for (int i = 1; i >= 0; --i) {
+ sendPreeditText(preeditText, i + 1);
+ int width = ceil(line.cursorToX(i, QTextLine::Trailing)) - floor(line.cursorToX(i));
+ QVERIFY(input->cursorRectangle().right() >= width - 3);
+ QVERIFY(input->positionToRectangle(0).x() > x);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ x = input->positionToRectangle(0).x();
+ }
+
+ // Test incrementing the preedit cursor doesn't cause further
+ // scrolling when right most text is visible.
+ sendPreeditText(preeditText, preeditText.length() - 3);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ x = input->positionToRectangle(0).x();
+ for (int i = 2; i >= 0; --i) {
+ sendPreeditText(preeditText, preeditText.length() - i);
+ QCOMPARE(input->positionToRectangle(0).x(), x);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ }
+ for (int i = 1; i < 3; ++i) {
+ sendPreeditText(preeditText, preeditText.length() - i);
+ QCOMPARE(input->positionToRectangle(0).x(), x);
+ QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges);
+ }
+
+ // Test disabling auto scroll.
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
+
+ input->setAutoScroll(false);
+ sendPreeditText(preeditText.mid(0, 3), 1);
+ QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(0)), 0);
+ QCOMPARE(evaluate<int>(input, QString("positionAt(%1)").arg(input->width())), 5);
+}
+
+void tst_qquicktextinput::preeditCursorRectangle()
+{
+ QString preeditText = "super";
+
+ QQuickView view(testFileUrl("inputMethodEvent.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
+ QVERIFY(input);
+
+ QRect currentRect;
+
+ QInputMethodQueryEvent query(Qt::ImCursorRectangle);
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ QRect previousRect = query.value(Qt::ImCursorRectangle).toRect();
+
+ // Verify that the micro focus rect is positioned the same for position 0 as
+ // it would be if there was no preedit text.
+ sendPreeditText(preeditText, 0);
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ currentRect = query.value(Qt::ImCursorRectangle).toRect();
+ QCOMPARE(currentRect, previousRect);
+
+ QSignalSpy inputSpy(input, SIGNAL(cursorRectangleChanged()));
+ QSignalSpy panelSpy(qGuiApp->inputMethod(), SIGNAL(cursorRectangleChanged()));
+
+ // Verify that the micro focus rect moves to the left as the cursor position
+ // is incremented.
+ for (int i = 1; i <= 5; ++i) {
+ sendPreeditText(preeditText, i);
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ currentRect = query.value(Qt::ImCursorRectangle).toRect();
+ QVERIFY(previousRect.left() < currentRect.left());
+ QVERIFY(inputSpy.count() > 0); inputSpy.clear();
+ QVERIFY(panelSpy.count() > 0); panelSpy.clear();
+ previousRect = currentRect;
+ }
+
+ // Verify that if there is no preedit cursor then the micro focus rect is the
+ // same as it would be if it were positioned at the end of the preedit text.
+ sendPreeditText(preeditText, 0);
+ QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>());
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &imEvent);
+ QCoreApplication::sendEvent(qGuiApp->focusObject(), &query);
+ currentRect = query.value(Qt::ImCursorRectangle).toRect();
+ QCOMPARE(currentRect, previousRect);
+ QVERIFY(inputSpy.count() > 0);
+ QVERIFY(panelSpy.count() > 0);
+}
+
+void tst_qquicktextinput::inputContextMouseHandler()
+{
+ PlatformInputContext platformInputContext;
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &platformInputContext;
+
+ QString text = "supercalifragisiticexpialidocious!";
+ QQuickView view(testFileUrl("inputContext.qml"));
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
+ QVERIFY(input);
+
+ input->setFocus(true);
+ input->setText("");
+
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+
+ QTextLayout layout(text);
+ layout.setFont(input->font());
+ if (!qmlDisableDistanceField()) {
+ QTextOption option;
+ option.setUseDesignMetrics(true);
+ layout.setTextOption(option);
+ }
+ layout.beginLayout();
+ QTextLine line = layout.createLine();
+ layout.endLayout();
+
+ const qreal x = line.cursorToX(2, QTextLine::Leading);
+ const qreal y = line.height() / 2;
+ QPoint position = QPointF(x, y).toPoint();
+
+ QInputMethodEvent inputEvent(text.mid(0, 5), QList<QInputMethodEvent::Attribute>());
+ QGuiApplication::sendEvent(input, &inputEvent);
+
+ QTest::mousePress(&view, Qt::LeftButton, Qt::NoModifier, position);
+ QTest::mouseRelease(&view, Qt::LeftButton, Qt::NoModifier, position);
+ QGuiApplication::processEvents();
+
+ QCOMPARE(platformInputContext.m_action, QInputMethod::Click);
+ QCOMPARE(platformInputContext.m_invokeActionCallCount, 1);
+ QCOMPARE(platformInputContext.m_cursorPosition, 2);
+}
+
+void tst_qquicktextinput::inputMethodComposing()
+{
+ QString text = "supercalifragisiticexpialidocious!";
+
+ QQuickView view(testFileUrl("inputContext.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
+ QVERIFY(input);
+ QSignalSpy spy(input, SIGNAL(inputMethodComposingChanged()));
+
+ QCOMPARE(input->isInputMethodComposing(), false);
+ {
+ QInputMethodEvent event(text.mid(3), QList<QInputMethodEvent::Attribute>());
+ QGuiApplication::sendEvent(input, &event);
+ }
+ QCOMPARE(input->isInputMethodComposing(), true);
+ QCOMPARE(spy.count(), 1);
+
+ {
+ QInputMethodEvent event(text.mid(12), QList<QInputMethodEvent::Attribute>());
+ QGuiApplication::sendEvent(input, &event);
+ }
+ QCOMPARE(spy.count(), 1);
+
+ {
+ QInputMethodEvent event;
+ QGuiApplication::sendEvent(input, &event);
+ }
+ QCOMPARE(input->isInputMethodComposing(), false);
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktextinput::inputMethodUpdate()
+{
+ PlatformInputContext platformInputContext;
+ QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod());
+ inputMethodPrivate->testContext = &platformInputContext;
+
+ QQuickView view(testFileUrl("inputContext.qml"));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+ QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
+ QVERIFY(input);
+
+ // text change even without cursor position change needs to trigger update
+ input->setText("test");
+ platformInputContext.clear();
+ input->setText("xxxx");
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // input method event replacing text
+ platformInputContext.clear();
+ {
+ QInputMethodEvent inputMethodEvent;
+ inputMethodEvent.setCommitString("y", -1, 1);
+ QGuiApplication::sendEvent(input, &inputMethodEvent);
+ }
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // input method changing selection
+ platformInputContext.clear();
+ {
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 2, QVariant());
+ QInputMethodEvent inputMethodEvent("", attributes);
+ QGuiApplication::sendEvent(input, &inputMethodEvent);
+ }
+ QVERIFY(input->selectionStart() != input->selectionEnd());
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // programmatical selections trigger update
+ platformInputContext.clear();
+ input->selectAll();
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // font changes
+ platformInputContext.clear();
+ QFont font = input->font();
+ font.setBold(!font.bold());
+ input->setFont(font);
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // normal input
+ platformInputContext.clear();
+ {
+ QInputMethodEvent inputMethodEvent;
+ inputMethodEvent.setCommitString("y");
+ QGuiApplication::sendEvent(input, &inputMethodEvent);
+ }
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // changing cursor position
+ platformInputContext.clear();
+ input->setCursorPosition(0);
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+
+ // read only disabled input method
+ platformInputContext.clear();
+ input->setReadOnly(true);
+ QVERIFY(platformInputContext.m_updateCallCount > 0);
+ input->setReadOnly(false);
+
+ // no updates while no focus
+ input->setFocus(false);
+ platformInputContext.clear();
+ input->setText("Foo");
+ QCOMPARE(platformInputContext.m_updateCallCount, 0);
+ input->setCursorPosition(1);
+ QCOMPARE(platformInputContext.m_updateCallCount, 0);
+ input->selectAll();
+ QCOMPARE(platformInputContext.m_updateCallCount, 0);
+ input->setReadOnly(true);
+ QCOMPARE(platformInputContext.m_updateCallCount, 0);
+}
+
+void tst_qquicktextinput::cursorRectangleSize()
+{
+ QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml"));
+ QVERIFY(canvas->rootObject() != 0);
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput *>(canvas->rootObject());
+
+ // make sure cursor rectangle is not at (0,0)
+ textInput->setX(10);
+ textInput->setY(10);
+ textInput->setCursorPosition(3);
+ QVERIFY(textInput != 0);
+ textInput->setFocus(true);
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_VERIFY(qApp->focusObject());
+
+ QInputMethodQueryEvent event(Qt::ImCursorRectangle);
+ qApp->sendEvent(qApp->focusObject(), &event);
+ QRectF cursorRectFromQuery = event.value(Qt::ImCursorRectangle).toRectF();
+
+ QRect cursorRectFromItem = textInput->cursorRectangle();
+ QRectF cursorRectFromPositionToRectangle = textInput->positionToRectangle(textInput->cursorPosition());
+
+ // item and input query cursor rectangles match
+ QCOMPARE(cursorRectFromItem, cursorRectFromQuery.toRect());
+
+ // item cursor rectangle and positionToRectangle calculations match
+ QCOMPARE(cursorRectFromItem, cursorRectFromPositionToRectangle.toRect());
+
+ // item-canvas transform and input item transform match
+ QCOMPARE(QQuickItemPrivate::get(textInput)->itemToCanvasTransform(), qApp->inputMethod()->inputItemTransform());
+
+ // input panel cursorRectangle property and tranformed item cursor rectangle match
+ QRectF sceneCursorRect = QQuickItemPrivate::get(textInput)->itemToCanvasTransform().mapRect(cursorRectFromItem);
+ QCOMPARE(sceneCursorRect, qApp->inputMethod()->cursorRectangle());
+
+ delete canvas;
+}
+
+void tst_qquicktextinput::tripleClickSelectsAll()
+{
+ QString qmlfile = testFile("positionAt.qml");
+ QQuickView view(QUrl::fromLocalFile(qmlfile));
+ view.show();
+ view.requestActivateWindow();
+ QTest::qWaitForWindowShown(&view);
+
+ QTRY_COMPARE(&view, qGuiApp->focusWindow());
+
+ QQuickTextInput* input = qobject_cast<QQuickTextInput*>(view.rootObject());
+ QVERIFY(input);
+
+ QLatin1String hello("Hello world!");
+ input->setSelectByMouse(true);
+ input->setText(hello);
+
+ // Clicking on the same point inside TextInput three times in a row
+ // should trigger a triple click, thus selecting all the text.
+ QPoint pointInside = input->pos().toPoint() + QPoint(2,2);
+ QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside);
+ QTest::mouseClick(&view, Qt::LeftButton, 0, pointInside);
+ QGuiApplication::processEvents();
+ QCOMPARE(input->selectedText(), hello);
+
+ // Now it simulates user moving the mouse between the second and the third click.
+ // In this situation, we don't expect a triple click.
+ QPoint pointInsideButFar = QPoint(input->width(),input->height()) - QPoint(2,2);
+ QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside);
+ QTest::mouseClick(&view, Qt::LeftButton, 0, pointInsideButFar);
+ QGuiApplication::processEvents();
+ QVERIFY(input->selectedText().isEmpty());
+
+ // And now we press the third click too late, so no triple click event is triggered.
+ QTest::mouseDClick(&view, Qt::LeftButton, 0, pointInside);
+ QGuiApplication::processEvents();
+ QTest::qWait(qApp->styleHints()->mouseDoubleClickInterval() + 1);
+ QTest::mouseClick(&view, Qt::LeftButton, 0, pointInside);
+ QGuiApplication::processEvents();
+ QVERIFY(input->selectedText().isEmpty());
+}
+
+void tst_qquicktextinput::QTBUG_19956_data()
+{
+ QTest::addColumn<QString>("url");
+ QTest::newRow("intvalidator") << "qtbug-19956int.qml";
+ QTest::newRow("doublevalidator") << "qtbug-19956double.qml";
+}
+
+
+void tst_qquicktextinput::getText_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("inputMask");
+ QTest::addColumn<int>("start");
+ QTest::addColumn<int>("end");
+ QTest::addColumn<QString>("expectedText");
+
+ QTest::newRow("all plain text")
+ << standard.at(0)
+ << QString()
+ << 0 << standard.at(0).length()
+ << standard.at(0);
+
+ QTest::newRow("plain text sub string")
+ << standard.at(0)
+ << QString()
+ << 0 << 12
+ << standard.at(0).mid(0, 12);
+
+ QTest::newRow("plain text sub string reversed")
+ << standard.at(0)
+ << QString()
+ << 12 << 0
+ << standard.at(0).mid(0, 12);
+
+ QTest::newRow("plain text cropped beginning")
+ << standard.at(0)
+ << QString()
+ << -3 << 4
+ << standard.at(0).mid(0, 4);
+
+ QTest::newRow("plain text cropped end")
+ << standard.at(0)
+ << QString()
+ << 23 << standard.at(0).length() + 8
+ << standard.at(0).mid(23);
+
+ QTest::newRow("plain text cropped beginning and end")
+ << standard.at(0)
+ << QString()
+ << -9 << standard.at(0).length() + 4
+ << standard.at(0);
+}
+
+void tst_qquicktextinput::getText()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, inputMask);
+ QFETCH(int, start);
+ QFETCH(int, end);
+ QFETCH(QString, expectedText);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ QCOMPARE(textInput->getText(start, end), expectedText);
+}
+
+void tst_qquicktextinput::insert_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("inputMask");
+ QTest::addColumn<int>("selectionStart");
+ QTest::addColumn<int>("selectionEnd");
+ QTest::addColumn<int>("insertPosition");
+ QTest::addColumn<QString>("insertText");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<int>("expectedSelectionStart");
+ QTest::addColumn<int>("expectedSelectionEnd");
+ QTest::addColumn<int>("expectedCursorPosition");
+ QTest::addColumn<bool>("selectionChanged");
+ QTest::addColumn<bool>("cursorPositionChanged");
+
+ QTest::newRow("at cursor position (beginning)")
+ << standard.at(0)
+ << QString()
+ << 0 << 0 << 0
+ << QString("Hello")
+ << QString("Hello") + standard.at(0)
+ << 5 << 5 << 5
+ << false << true;
+
+ QTest::newRow("at cursor position (end)")
+ << standard.at(0)
+ << QString()
+ << standard.at(0).length() << standard.at(0).length() << standard.at(0).length()
+ << QString("Hello")
+ << standard.at(0) + QString("Hello")
+ << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
+ << false << true;
+
+ QTest::newRow("at cursor position (middle)")
+ << standard.at(0)
+ << QString()
+ << 18 << 18 << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << 23 << 23 << 23
+ << false << true;
+
+ QTest::newRow("after cursor position (beginning)")
+ << standard.at(0)
+ << QString()
+ << 0 << 0 << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("before cursor position (end)")
+ << standard.at(0)
+ << QString()
+ << standard.at(0).length() << standard.at(0).length() << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << standard.at(0).length() + 5 << standard.at(0).length() + 5 << standard.at(0).length() + 5
+ << false << true;
+
+ QTest::newRow("before cursor position (middle)")
+ << standard.at(0)
+ << QString()
+ << 18 << 18 << 0
+ << QString("Hello")
+ << QString("Hello") + standard.at(0)
+ << 23 << 23 << 23
+ << false << true;
+
+ QTest::newRow("after cursor position (middle)")
+ << standard.at(0)
+ << QString()
+ << 18 << 18 << standard.at(0).length()
+ << QString("Hello")
+ << standard.at(0) + QString("Hello")
+ << 18 << 18 << 18
+ << false << false;
+
+ QTest::newRow("before selection")
+ << standard.at(0)
+ << QString()
+ << 14 << 19 << 0
+ << QString("Hello")
+ << QString("Hello") + standard.at(0)
+ << 19 << 24 << 24
+ << false << true;
+
+ QTest::newRow("before reversed selection")
+ << standard.at(0)
+ << QString()
+ << 19 << 14 << 0
+ << QString("Hello")
+ << QString("Hello") + standard.at(0)
+ << 19 << 24 << 19
+ << false << true;
+
+ QTest::newRow("after selection")
+ << standard.at(0)
+ << QString()
+ << 14 << 19 << standard.at(0).length()
+ << QString("Hello")
+ << standard.at(0) + QString("Hello")
+ << 14 << 19 << 19
+ << false << false;
+
+ QTest::newRow("after reversed selection")
+ << standard.at(0)
+ << QString()
+ << 19 << 14 << standard.at(0).length()
+ << QString("Hello")
+ << standard.at(0) + QString("Hello")
+ << 14 << 19 << 14
+ << false << false;
+
+ QTest::newRow("into selection")
+ << standard.at(0)
+ << QString()
+ << 14 << 19 << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << 14 << 24 << 24
+ << true << true;
+
+ QTest::newRow("into reversed selection")
+ << standard.at(0)
+ << QString()
+ << 19 << 14 << 18
+ << QString("Hello")
+ << standard.at(0).mid(0, 18) + QString("Hello") + standard.at(0).mid(18)
+ << 14 << 24 << 14
+ << true << false;
+
+ QTest::newRow("rich text into plain text")
+ << standard.at(0)
+ << QString()
+ << 0 << 0 << 0
+ << QString("<b>Hello</b>")
+ << QString("<b>Hello</b>") + standard.at(0)
+ << 12 << 12 << 12
+ << false << true;
+
+ QTest::newRow("before start")
+ << standard.at(0)
+ << QString()
+ << 0 << 0 << -3
+ << QString("Hello")
+ << standard.at(0)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("past end")
+ << standard.at(0)
+ << QString()
+ << 0 << 0 << standard.at(0).length() + 3
+ << QString("Hello")
+ << standard.at(0)
+ << 0 << 0 << 0
+ << false << false;
+
+ const QString inputMask = "009.009.009.009";
+ const QString ip = "192.168.2.14";
+
+ QTest::newRow("mask: at cursor position (beginning)")
+ << ip
+ << inputMask
+ << 0 << 0 << 0
+ << QString("125")
+ << QString("125.168.2.14")
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("mask: at cursor position (end)")
+ << ip
+ << inputMask
+ << inputMask.length() << inputMask.length() << inputMask.length()
+ << QString("8")
+ << ip
+ << inputMask.length() << inputMask.length() << inputMask.length()
+ << false << false;
+
+ QTest::newRow("mask: at cursor position (middle)")
+ << ip
+ << inputMask
+ << 6 << 6 << 6
+ << QString("75.2")
+ << QString("192.167.5.24")
+ << 6 << 6 << 6
+ << false << false;
+
+ QTest::newRow("mask: after cursor position (beginning)")
+ << ip
+ << inputMask
+ << 0 << 0 << 6
+ << QString("75.2")
+ << QString("192.167.5.24")
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("mask: before cursor position (end)")
+ << ip
+ << inputMask
+ << inputMask.length() << inputMask.length() << 6
+ << QString("75.2")
+ << QString("192.167.5.24")
+ << inputMask.length() << inputMask.length() << inputMask.length()
+ << false << false;
+
+ QTest::newRow("mask: before cursor position (middle)")
+ << ip
+ << inputMask
+ << 6 << 6 << 0
+ << QString("125")
+ << QString("125.168.2.14")
+ << 6 << 6 << 6
+ << false << false;
+
+ QTest::newRow("mask: after cursor position (middle)")
+ << ip
+ << inputMask
+ << 6 << 6 << 13
+ << QString("8")
+ << "192.168.2.18"
+ << 6 << 6 << 6
+ << false << false;
+
+ QTest::newRow("mask: before selection")
+ << ip
+ << inputMask
+ << 6 << 8 << 0
+ << QString("125")
+ << QString("125.168.2.14")
+ << 6 << 8 << 8
+ << false << false;
+
+ QTest::newRow("mask: before reversed selection")
+ << ip
+ << inputMask
+ << 8 << 6 << 0
+ << QString("125")
+ << QString("125.168.2.14")
+ << 6 << 8 << 6
+ << false << false;
+
+ QTest::newRow("mask: after selection")
+ << ip
+ << inputMask
+ << 6 << 8 << 13
+ << QString("8")
+ << "192.168.2.18"
+ << 6 << 8 << 8
+ << false << false;
+
+ QTest::newRow("mask: after reversed selection")
+ << ip
+ << inputMask
+ << 8 << 6 << 13
+ << QString("8")
+ << "192.168.2.18"
+ << 6 << 8 << 6
+ << false << false;
+
+ QTest::newRow("mask: into selection")
+ << ip
+ << inputMask
+ << 5 << 8 << 6
+ << QString("75.2")
+ << QString("192.167.5.24")
+ << 5 << 8 << 8
+ << true << false;
+
+ QTest::newRow("mask: into reversed selection")
+ << ip
+ << inputMask
+ << 8 << 5 << 6
+ << QString("75.2")
+ << QString("192.167.5.24")
+ << 5 << 8 << 5
+ << true << false;
+
+ QTest::newRow("mask: before start")
+ << ip
+ << inputMask
+ << 0 << 0 << -3
+ << QString("4")
+ << ip
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("mask: past end")
+ << ip
+ << inputMask
+ << 0 << 0 << ip.length() + 3
+ << QString("4")
+ << ip
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("mask: invalid characters")
+ << ip
+ << inputMask
+ << 0 << 0 << 0
+ << QString("abc")
+ << QString("192.168.2.14")
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("mask: mixed validity")
+ << ip
+ << inputMask
+ << 0 << 0 << 0
+ << QString("a1b2c5")
+ << QString("125.168.2.14")
+ << 0 << 0 << 0
+ << false << false;
+}
+
+void tst_qquicktextinput::insert()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, inputMask);
+ QFETCH(int, selectionStart);
+ QFETCH(int, selectionEnd);
+ QFETCH(int, insertPosition);
+ QFETCH(QString, insertText);
+ QFETCH(QString, expectedText);
+ QFETCH(int, expectedSelectionStart);
+ QFETCH(int, expectedSelectionEnd);
+ QFETCH(int, expectedCursorPosition);
+ QFETCH(bool, selectionChanged);
+ QFETCH(bool, cursorPositionChanged);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ textInput->select(selectionStart, selectionEnd);
+
+ QSignalSpy selectionSpy(textInput, SIGNAL(selectedTextChanged()));
+ QSignalSpy selectionStartSpy(textInput, SIGNAL(selectionStartChanged()));
+ QSignalSpy selectionEndSpy(textInput, SIGNAL(selectionEndChanged()));
+ QSignalSpy textSpy(textInput, SIGNAL(textChanged()));
+ QSignalSpy cursorPositionSpy(textInput, SIGNAL(cursorPositionChanged()));
+
+ textInput->insert(insertPosition, insertText);
+
+ QCOMPARE(textInput->text(), expectedText);
+ QCOMPARE(textInput->length(), inputMask.isEmpty() ? expectedText.length() : inputMask.length());
+
+ QCOMPARE(textInput->selectionStart(), expectedSelectionStart);
+ QCOMPARE(textInput->selectionEnd(), expectedSelectionEnd);
+ QCOMPARE(textInput->cursorPosition(), expectedCursorPosition);
+
+ if (selectionStart > selectionEnd)
+ qSwap(selectionStart, selectionEnd);
+
+ QCOMPARE(selectionSpy.count() > 0, selectionChanged);
+ QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
+ QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
+ QCOMPARE(textSpy.count() > 0, text != expectedText);
+ QCOMPARE(cursorPositionSpy.count() > 0, cursorPositionChanged);
+}
+
+void tst_qquicktextinput::remove_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QString>("inputMask");
+ QTest::addColumn<int>("selectionStart");
+ QTest::addColumn<int>("selectionEnd");
+ QTest::addColumn<int>("removeStart");
+ QTest::addColumn<int>("removeEnd");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<int>("expectedSelectionStart");
+ QTest::addColumn<int>("expectedSelectionEnd");
+ QTest::addColumn<int>("expectedCursorPosition");
+ QTest::addColumn<bool>("selectionChanged");
+ QTest::addColumn<bool>("cursorPositionChanged");
+
+ QTest::newRow("from cursor position (beginning)")
+ << standard.at(0)
+ << QString()
+ << 0 << 0
+ << 0 << 5
+ << standard.at(0).mid(5)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("to cursor position (beginning)")
+ << standard.at(0)
+ << QString()
+ << 0 << 0
+ << 5 << 0
+ << standard.at(0).mid(5)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("to cursor position (end)")
+ << standard.at(0)
+ << QString()
+ << standard.at(0).length() << standard.at(0).length()
+ << standard.at(0).length() << standard.at(0).length() - 5
+ << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << false << true;
+
+ QTest::newRow("to cursor position (end)")
+ << standard.at(0)
+ << QString()
+ << standard.at(0).length() << standard.at(0).length()
+ << standard.at(0).length() - 5 << standard.at(0).length()
+ << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << false << true;
+
+ QTest::newRow("from cursor position (middle)")
+ << standard.at(0)
+ << QString()
+ << 18 << 18
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 18 << 18 << 18
+ << false << false;
+
+ QTest::newRow("to cursor position (middle)")
+ << standard.at(0)
+ << QString()
+ << 23 << 23
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 18 << 18 << 18
+ << false << true;
+
+ QTest::newRow("after cursor position (beginning)")
+ << standard.at(0)
+ << QString()
+ << 0 << 0
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("before cursor position (end)")
+ << standard.at(0)
+ << QString()
+ << standard.at(0).length() << standard.at(0).length()
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << standard.at(0).length() - 5 << standard.at(0).length() - 5 << standard.at(0).length() - 5
+ << false << true;
+
+ QTest::newRow("before cursor position (middle)")
+ << standard.at(0)
+ << QString()
+ << 23 << 23
+ << 0 << 5
+ << standard.at(0).mid(5)
+ << 18 << 18 << 18
+ << false << true;
+
+ QTest::newRow("after cursor position (middle)")
+ << standard.at(0)
+ << QString()
+ << 18 << 18
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 18 << 18 << 18
+ << false << false;
+
+ QTest::newRow("before selection")
+ << standard.at(0)
+ << QString()
+ << 14 << 19
+ << 0 << 5
+ << standard.at(0).mid(5)
+ << 9 << 14 << 14
+ << false << true;
+
+ QTest::newRow("before reversed selection")
+ << standard.at(0)
+ << QString()
+ << 19 << 14
+ << 0 << 5
+ << standard.at(0).mid(5)
+ << 9 << 14 << 9
+ << false << true;
+
+ QTest::newRow("after selection")
+ << standard.at(0)
+ << QString()
+ << 14 << 19
+ << standard.at(0).length() - 5 << standard.at(0).length()
+ << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << 14 << 19 << 19
+ << false << false;
+
+ QTest::newRow("after reversed selection")
+ << standard.at(0)
+ << QString()
+ << 19 << 14
+ << standard.at(0).length() - 5 << standard.at(0).length()
+ << standard.at(0).mid(0, standard.at(0).length() - 5)
+ << 14 << 19 << 14
+ << false << false;
+
+ QTest::newRow("from selection")
+ << standard.at(0)
+ << QString()
+ << 14 << 24
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 14 << 19 << 19
+ << true << true;
+
+ QTest::newRow("from reversed selection")
+ << standard.at(0)
+ << QString()
+ << 24 << 14
+ << 18 << 23
+ << standard.at(0).mid(0, 18) + standard.at(0).mid(23)
+ << 14 << 19 << 14
+ << true << false;
+
+ QTest::newRow("cropped beginning")
+ << standard.at(0)
+ << QString()
+ << 0 << 0
+ << -3 << 4
+ << standard.at(0).mid(4)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("cropped end")
+ << standard.at(0)
+ << QString()
+ << 0 << 0
+ << 23 << standard.at(0).length() + 8
+ << standard.at(0).mid(0, 23)
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("cropped beginning and end")
+ << standard.at(0)
+ << QString()
+ << 0 << 0
+ << -9 << standard.at(0).length() + 4
+ << QString()
+ << 0 << 0 << 0
+ << false << false;
+
+ const QString inputMask = "009.009.009.009";
+ const QString ip = "192.168.2.14";
+
+ QTest::newRow("mask: from cursor position")
+ << ip
+ << inputMask
+ << 6 << 6
+ << 6 << 9
+ << QString("192.16..14")
+ << 6 << 6 << 6
+ << false << false;
+
+ QTest::newRow("mask: to cursor position")
+ << ip
+ << inputMask
+ << 6 << 6
+ << 2 << 6
+ << QString("19.8.2.14")
+ << 6 << 6 << 6
+ << false << false;
+
+ QTest::newRow("mask: before cursor position")
+ << ip
+ << inputMask
+ << 6 << 6
+ << 0 << 2
+ << QString("2.168.2.14")
+ << 6 << 6 << 6
+ << false << false;
+
+ QTest::newRow("mask: after cursor position")
+ << ip
+ << inputMask
+ << 6 << 6
+ << 12 << 16
+ << QString("192.168.2.")
+ << 6 << 6 << 6
+ << false << false;
+
+ QTest::newRow("mask: before selection")
+ << ip
+ << inputMask
+ << 6 << 8
+ << 0 << 2
+ << QString("2.168.2.14")
+ << 6 << 8 << 8
+ << false << false;
+
+ QTest::newRow("mask: before reversed selection")
+ << ip
+ << inputMask
+ << 8 << 6
+ << 0 << 2
+ << QString("2.168.2.14")
+ << 6 << 8 << 6
+ << false << false;
+
+ QTest::newRow("mask: after selection")
+ << ip
+ << inputMask
+ << 6 << 8
+ << 12 << 16
+ << QString("192.168.2.")
+ << 6 << 8 << 8
+ << false << false;
+
+ QTest::newRow("mask: after reversed selection")
+ << ip
+ << inputMask
+ << 8 << 6
+ << 12 << 16
+ << QString("192.168.2.")
+ << 6 << 8 << 6
+ << false << false;
+
+ QTest::newRow("mask: from selection")
+ << ip
+ << inputMask
+ << 6 << 13
+ << 8 << 10
+ << QString("192.168..14")
+ << 6 << 13 << 13
+ << true << false;
+
+ QTest::newRow("mask: from reversed selection")
+ << ip
+ << inputMask
+ << 13 << 6
+ << 8 << 10
+ << QString("192.168..14")
+ << 6 << 13 << 6
+ << true << false;
+
+ QTest::newRow("mask: cropped beginning")
+ << ip
+ << inputMask
+ << 0 << 0
+ << -3 << 4
+ << QString(".168.2.14")
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("mask: cropped end")
+ << ip
+ << inputMask
+ << 0 << 0
+ << 13 << 28
+ << QString("192.168.2.1")
+ << 0 << 0 << 0
+ << false << false;
+
+ QTest::newRow("mask: cropped beginning and end")
+ << ip
+ << inputMask
+ << 0 << 0
+ << -9 << 28
+ << QString("...")
+ << 0 << 0 << 0
+ << false << false;
+}
+
+void tst_qquicktextinput::remove()
+{
+ QFETCH(QString, text);
+ QFETCH(QString, inputMask);
+ QFETCH(int, selectionStart);
+ QFETCH(int, selectionEnd);
+ QFETCH(int, removeStart);
+ QFETCH(int, removeEnd);
+ QFETCH(QString, expectedText);
+ QFETCH(int, expectedSelectionStart);
+ QFETCH(int, expectedSelectionEnd);
+ QFETCH(int, expectedCursorPosition);
+ QFETCH(bool, selectionChanged);
+ QFETCH(bool, cursorPositionChanged);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { text: \"" + text + "\"; inputMask: \"" + inputMask + "\" }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ textInput->select(selectionStart, selectionEnd);
+
+ QSignalSpy selectionSpy(textInput, SIGNAL(selectedTextChanged()));
+ QSignalSpy selectionStartSpy(textInput, SIGNAL(selectionStartChanged()));
+ QSignalSpy selectionEndSpy(textInput, SIGNAL(selectionEndChanged()));
+ QSignalSpy textSpy(textInput, SIGNAL(textChanged()));
+ QSignalSpy cursorPositionSpy(textInput, SIGNAL(cursorPositionChanged()));
+
+ textInput->remove(removeStart, removeEnd);
+
+ QCOMPARE(textInput->text(), expectedText);
+ QCOMPARE(textInput->length(), inputMask.isEmpty() ? expectedText.length() : inputMask.length());
+
+ if (selectionStart > selectionEnd) //
+ qSwap(selectionStart, selectionEnd);
+
+ QCOMPARE(textInput->selectionStart(), expectedSelectionStart);
+ QCOMPARE(textInput->selectionEnd(), expectedSelectionEnd);
+ QCOMPARE(textInput->cursorPosition(), expectedCursorPosition);
+
+ QCOMPARE(selectionSpy.count() > 0, selectionChanged);
+ QCOMPARE(selectionStartSpy.count() > 0, selectionStart != expectedSelectionStart);
+ QCOMPARE(selectionEndSpy.count() > 0, selectionEnd != expectedSelectionEnd);
+ QCOMPARE(textSpy.count() > 0, text != expectedText);
+
+ if (cursorPositionChanged) //
+ QVERIFY(cursorPositionSpy.count() > 0);
+}
+
+void tst_qquicktextinput::keySequence_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<QKeySequence>("sequence");
+ QTest::addColumn<int>("selectionStart");
+ QTest::addColumn<int>("selectionEnd");
+ QTest::addColumn<int>("cursorPosition");
+ QTest::addColumn<QString>("expectedText");
+ QTest::addColumn<QString>("selectedText");
+
+ // standard[0] == "the [4]quick [10]brown [16]fox [20]jumped [27]over [32]the [36]lazy [41]dog"
+
+ QTest::newRow("select all")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectAll) << 0 << 0
+ << 44 << standard.at(0) << standard.at(0);
+ QTest::newRow("select end of line")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfLine) << 5 << 5
+ << 44 << standard.at(0) << standard.at(0).mid(5);
+ QTest::newRow("select end of document") // ### Not handled.
+ << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfDocument) << 3 << 3
+ << 3 << standard.at(0) << QString();
+ QTest::newRow("select end of block")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectEndOfBlock) << 18 << 18
+ << 44 << standard.at(0) << standard.at(0).mid(18);
+ QTest::newRow("delete end of line")
+ << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfLine) << 24 << 24
+ << 24 << standard.at(0).mid(0, 24) << QString();
+ QTest::newRow("move to start of line")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfLine) << 31 << 31
+ << 0 << standard.at(0) << QString();
+ QTest::newRow("move to start of block")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToStartOfBlock) << 25 << 25
+ << 0 << standard.at(0) << QString();
+ QTest::newRow("move to next char")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToNextChar) << 12 << 12
+ << 13 << standard.at(0) << QString();
+ QTest::newRow("move to previous char")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousChar) << 3 << 3
+ << 2 << standard.at(0) << QString();
+ QTest::newRow("select next char")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectNextChar) << 23 << 23
+ << 24 << standard.at(0) << standard.at(0).mid(23, 1);
+ QTest::newRow("select previous char")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousChar) << 19 << 19
+ << 18 << standard.at(0) << standard.at(0).mid(18, 1);
+ QTest::newRow("move to next word")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToNextWord) << 7 << 7
+ << 10 << standard.at(0) << QString();
+ QTest::newRow("move to previous word")
+ << standard.at(0) << QKeySequence(QKeySequence::MoveToPreviousWord) << 7 << 7
+ << 4 << standard.at(0) << QString();
+ QTest::newRow("select previous word")
+ << standard.at(0) << QKeySequence(QKeySequence::SelectPreviousWord) << 11 << 11
+ << 10 << standard.at(0) << standard.at(0).mid(10, 1);
+ QTest::newRow("delete (selection)")
+ << standard.at(0) << QKeySequence(QKeySequence::Delete) << 12 << 15
+ << 12 << (standard.at(0).mid(0, 12) + standard.at(0).mid(15)) << QString();
+ QTest::newRow("delete (no selection)")
+ << standard.at(0) << QKeySequence(QKeySequence::Delete) << 15 << 15
+ << 15 << (standard.at(0).mid(0, 15) + standard.at(0).mid(16)) << QString();
+ QTest::newRow("delete end of word")
+ << standard.at(0) << QKeySequence(QKeySequence::DeleteEndOfWord) << 24 << 24
+ << 24 << (standard.at(0).mid(0, 24) + standard.at(0).mid(27)) << QString();
+ QTest::newRow("delete start of word")
+ << standard.at(0) << QKeySequence(QKeySequence::DeleteStartOfWord) << 7 << 7
+ << 4 << (standard.at(0).mid(0, 4) + standard.at(0).mid(7)) << QString();
+}
+
+void tst_qquicktextinput::keySequence()
+{
+ QFETCH(QString, text);
+ QFETCH(QKeySequence, sequence);
+ QFETCH(int, selectionStart);
+ QFETCH(int, selectionEnd);
+ QFETCH(int, cursorPosition);
+ QFETCH(QString, expectedText);
+ QFETCH(QString, selectedText);
+
+ if (sequence.isEmpty()) {
+ QSKIP("Key sequence is undefined");
+ }
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { focus: true; text: \"" + text + "\" }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ QQuickCanvas canvas;
+ textInput->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ textInput->select(selectionStart, selectionEnd);
+
+ simulateKeys(&canvas, sequence);
+
+ QCOMPARE(textInput->cursorPosition(), cursorPosition);
+ QCOMPARE(textInput->text(), expectedText);
+ QCOMPARE(textInput->selectedText(), selectedText);
+}
+
+#define NORMAL 0
+#define REPLACE_UNTIL_END 1
+
+void tst_qquicktextinput::undo_data()
+{
+ QTest::addColumn<QStringList>("insertString");
+ QTest::addColumn<IntList>("insertIndex");
+ QTest::addColumn<IntList>("insertMode");
+ QTest::addColumn<QStringList>("expectedString");
+ QTest::addColumn<bool>("use_keys");
+
+ for (int i=0; i<2; i++) {
+ QString keys_str = "keyboard";
+ bool use_keys = true;
+ if (i==0) {
+ keys_str = "insert";
+ use_keys = false;
+ }
+
+ {
+ IntList insertIndex;
+ IntList insertMode;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "1";
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "5";
+
+ insertIndex << 1;
+ insertMode << NORMAL;
+ insertString << "3";
+
+ insertIndex << 1;
+ insertMode << NORMAL;
+ insertString << "2";
+
+ insertIndex << 3;
+ insertMode << NORMAL;
+ insertString << "4";
+
+ expectedString << "12345";
+ expectedString << "1235";
+ expectedString << "135";
+ expectedString << "15";
+ expectedString << "";
+
+ QTest::newRow(QString(keys_str + "_numbers").toLatin1()) <<
+ insertString <<
+ insertIndex <<
+ insertMode <<
+ expectedString <<
+ bool(use_keys);
+ }
+ {
+ IntList insertIndex;
+ IntList insertMode;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "World"; // World
+
+ insertIndex << 0;
+ insertMode << NORMAL;
+ insertString << "Hello"; // HelloWorld
+
+ insertIndex << 0;
+ insertMode << NORMAL;
+ insertString << "Well"; // WellHelloWorld
+
+ insertIndex << 9;
+ insertMode << NORMAL;
+ insertString << "There"; // WellHelloThereWorld;
+
+ expectedString << "WellHelloThereWorld";
+ expectedString << "WellHelloWorld";
+ expectedString << "HelloWorld";
+ expectedString << "World";
+ expectedString << "";
+
+ QTest::newRow(QString(keys_str + "_helloworld").toLatin1()) <<
+ insertString <<
+ insertIndex <<
+ insertMode <<
+ expectedString <<
+ bool(use_keys);
+ }
+ {
+ IntList insertIndex;
+ IntList insertMode;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << "Ensuring";
+
+ insertIndex << -1;
+ insertMode << NORMAL;
+ insertString << " instan";
+
+ insertIndex << 9;
+ insertMode << NORMAL;
+ insertString << "an ";
+
+ insertIndex << 10;
+ insertMode << REPLACE_UNTIL_END;
+ insertString << " unique instance.";
+
+ expectedString << "Ensuring a unique instance.";
+ expectedString << "Ensuring an instan";
+ expectedString << "Ensuring instan";
+ expectedString << "";
+
+ QTest::newRow(QString(keys_str + "_patterns").toLatin1()) <<
+ insertString <<
+ insertIndex <<
+ insertMode <<
+ expectedString <<
+ bool(use_keys);
+ }
+ }
+}
+
+void tst_qquicktextinput::undo()
+{
+ QFETCH(QStringList, insertString);
+ QFETCH(IntList, insertIndex);
+ QFETCH(IntList, insertMode);
+ QFETCH(QStringList, expectedString);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ QQuickCanvas canvas;
+ textInput->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ QVERIFY(!textInput->canUndo());
+
+ QSignalSpy spy(textInput, SIGNAL(canUndoChanged()));
+
+ int i;
+
+// STEP 1: First build up an undo history by inserting or typing some strings...
+ for (i = 0; i < insertString.size(); ++i) {
+ if (insertIndex[i] > -1)
+ textInput->setCursorPosition(insertIndex[i]);
+
+ // experimental stuff
+ if (insertMode[i] == REPLACE_UNTIL_END) {
+ textInput->select(insertIndex[i], insertIndex[i] + 8);
+
+ // This is what I actually want...
+ // QTest::keyClick(testWidget, Qt::Key_End, Qt::ShiftModifier);
+ }
+
+ for (int j = 0; j < insertString.at(i).length(); j++)
+ QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1());
+ }
+
+ QCOMPARE(spy.count(), 1);
+
+// STEP 2: Next call undo several times and see if we can restore to the previous state
+ for (i = 0; i < expectedString.size() - 1; ++i) {
+ QCOMPARE(textInput->text(), expectedString[i]);
+ QVERIFY(textInput->canUndo());
+ textInput->undo();
+ }
+
+// STEP 3: Verify that we have undone everything
+ QVERIFY(textInput->text().isEmpty());
+ QVERIFY(!textInput->canUndo());
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktextinput::redo_data()
+{
+ QTest::addColumn<QStringList>("insertString");
+ QTest::addColumn<IntList>("insertIndex");
+ QTest::addColumn<QStringList>("expectedString");
+
+ {
+ IntList insertIndex;
+ QStringList insertString;
+ QStringList expectedString;
+
+ insertIndex << -1;
+ insertString << "World"; // World
+ insertIndex << 0;
+ insertString << "Hello"; // HelloWorld
+ insertIndex << 0;
+ insertString << "Well"; // WellHelloWorld
+ insertIndex << 9;
+ insertString << "There"; // WellHelloThereWorld;
+
+ expectedString << "World";
+ expectedString << "HelloWorld";
+ expectedString << "WellHelloWorld";
+ expectedString << "WellHelloThereWorld";
+
+ QTest::newRow("Inserts and setting cursor") << insertString << insertIndex << expectedString;
+ }
+}
+
+void tst_qquicktextinput::redo()
+{
+ QFETCH(QStringList, insertString);
+ QFETCH(IntList, insertIndex);
+ QFETCH(QStringList, expectedString);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ QQuickCanvas canvas;
+ textInput->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ QVERIFY(!textInput->canUndo());
+ QVERIFY(!textInput->canRedo());
+
+ QSignalSpy spy(textInput, SIGNAL(canRedoChanged()));
+
+ int i;
+ // inserts the diff strings at diff positions
+ for (i = 0; i < insertString.size(); ++i) {
+ if (insertIndex[i] > -1)
+ textInput->setCursorPosition(insertIndex[i]);
+ for (int j = 0; j < insertString.at(i).length(); j++)
+ QTest::keyClick(&canvas, insertString.at(i).at(j).toLatin1());
+ QVERIFY(textInput->canUndo());
+ QVERIFY(!textInput->canRedo());
+ }
+
+ QCOMPARE(spy.count(), 0);
+
+ // undo everything
+ while (!textInput->text().isEmpty()) {
+ QVERIFY(textInput->canUndo());
+ textInput->undo();
+ QVERIFY(textInput->canRedo());
+ }
+
+ QCOMPARE(spy.count(), 1);
+
+ for (i = 0; i < expectedString.size(); ++i) {
+ QVERIFY(textInput->canRedo());
+ textInput->redo();
+ QCOMPARE(textInput->text() , expectedString[i]);
+ QVERIFY(textInput->canUndo());
+ }
+ QVERIFY(!textInput->canRedo());
+ QCOMPARE(spy.count(), 2);
+}
+
+void tst_qquicktextinput::undo_keypressevents_data()
+{
+ QTest::addColumn<KeyList>("keys");
+ QTest::addColumn<QStringList>("expectedString");
+
+ {
+ KeyList keys;
+ QStringList expectedString;
+
+ keys << "AFRAID"
+ << QKeySequence::MoveToStartOfLine
+ << "VERY"
+ << Qt::Key_Left
+ << Qt::Key_Left
+ << Qt::Key_Left
+ << Qt::Key_Left
+ << "BE"
+ << QKeySequence::MoveToEndOfLine
+ << "!";
+
+ expectedString << "BEVERYAFRAID!";
+ expectedString << "BEVERYAFRAID";
+ expectedString << "VERYAFRAID";
+ expectedString << "AFRAID";
+
+ QTest::newRow("Inserts and moving cursor") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting '1234'
+ keys << "1234" << QKeySequence::MoveToStartOfLine
+ // skipping '12'
+ << Qt::Key_Right << Qt::Key_Right
+ // selecting '34'
+ << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
+ // deleting '34'
+ << Qt::Key_Delete;
+
+ expectedString << "12";
+ expectedString << "1234";
+
+ QTest::newRow("Inserts,moving,selection and delete") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting 'AB12'
+ keys << "AB12"
+ << QKeySequence::MoveToStartOfLine
+ // selecting 'AB'
+ << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
+ << Qt::Key_Delete
+ << QKeySequence::Undo
+ << Qt::Key_Right
+#ifdef Q_OS_WIN //Mac(?) has a specialcase to handle jumping to the end of a selection
+ << Qt::Key_Left
+#endif
+ << (Qt::Key_Right | Qt::ShiftModifier) << (Qt::Key_Right | Qt::ShiftModifier)
+ << Qt::Key_Delete;
+
+ expectedString << "AB";
+ expectedString << "AB12";
+
+ QTest::newRow("Inserts,moving,selection, delete and undo") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting 'ABCD'
+ keys << "abcd"
+ //move left two
+ << Qt::Key_Left << Qt::Key_Left
+ // inserting '1234'
+ << "1234"
+ // selecting '1234'
+ << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier) << (Qt::Key_Left | Qt::ShiftModifier)
+ // overwriting '1234' with '5'
+ << "5"
+ // undoing deletion of 'AB'
+ << QKeySequence::Undo
+ // overwriting '1234' with '6'
+ << "6";
+
+ expectedString << "ab6cd";
+ // for versions previous to 3.2 we overwrite needed two undo operations
+ expectedString << "ab1234cd";
+ expectedString << "abcd";
+
+ QTest::newRow("Inserts,moving,selection and undo, removing selection") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting 'ABC'
+ keys << "ABC"
+ // removes 'C'
+ << Qt::Key_Backspace;
+
+ expectedString << "AB";
+ expectedString << "ABC";
+
+ QTest::newRow("Inserts,backspace") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ keys << "ABC"
+ // removes 'C'
+ << Qt::Key_Backspace
+ // inserting 'Z'
+ << "Z";
+
+ expectedString << "ABZ";
+ expectedString << "AB";
+ expectedString << "ABC";
+
+ QTest::newRow("Inserts,backspace,inserts") << keys << expectedString;
+ } {
+ KeyList keys;
+ QStringList expectedString;
+
+ // inserting '123'
+ keys << "123" << QKeySequence::MoveToStartOfLine
+ // selecting '123'
+ << QKeySequence::SelectEndOfLine
+ // overwriting '123' with 'ABC'
+ << "ABC";
+
+ expectedString << "ABC";
+ // for versions previous to 3.2 we overwrite needed two undo operations
+ expectedString << "123";
+
+ QTest::newRow("Inserts,moving,selection and overwriting") << keys << expectedString;
+ }
+}
+
+void tst_qquicktextinput::undo_keypressevents()
+{
+ QFETCH(KeyList, keys);
+ QFETCH(QStringList, expectedString);
+
+ QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }";
+ QQmlComponent textInputComponent(&engine);
+ textInputComponent.setData(componentStr.toLatin1(), QUrl());
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(textInputComponent.create());
+ QVERIFY(textInput != 0);
+
+ QQuickCanvas canvas;
+ textInput->setParentItem(canvas.rootItem());
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QTRY_COMPARE(QGuiApplication::activeWindow(), &canvas);
+
+ simulateKeys(&canvas, keys);
+
+ for (int i = 0; i < expectedString.size(); ++i) {
+ QCOMPARE(textInput->text() , expectedString[i]);
+ textInput->undo();
+ }
+ QVERIFY(textInput->text().isEmpty());
+}
+
+void tst_qquicktextinput::QTBUG_19956()
+{
+ QFETCH(QString, url);
+
+ QQuickView canvas(testFileUrl(url));
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextInput *input = qobject_cast<QQuickTextInput*>(canvas.rootObject());
+ QVERIFY(input);
+ input->setFocus(true);
+ QVERIFY(input->hasActiveFocus());
+
+ QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 30);
+ QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 10);
+ QCOMPARE(canvas.rootObject()->property("text").toString(), QString("20"));
+ QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
+
+ canvas.rootObject()->setProperty("topvalue", 15);
+ QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 15);
+ QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool());
+
+ canvas.rootObject()->setProperty("topvalue", 25);
+ QCOMPARE(canvas.rootObject()->property("topvalue").toInt(), 25);
+ QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
+
+ canvas.rootObject()->setProperty("bottomvalue", 21);
+ QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 21);
+ QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool());
+
+ canvas.rootObject()->setProperty("bottomvalue", 10);
+ QCOMPARE(canvas.rootObject()->property("bottomvalue").toInt(), 10);
+ QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
+}
+
+void tst_qquicktextinput::QTBUG_19956_regexp()
+{
+ QUrl url = testFileUrl("qtbug-19956regexp.qml");
+
+ QString warning = url.toString() + ":11: Unable to assign [undefined] to QRegExp";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ QQuickView canvas(url);
+ canvas.show();
+ canvas.requestActivateWindow();
+ QTest::qWaitForWindowShown(&canvas);
+ QVERIFY(canvas.rootObject() != 0);
+ QQuickTextInput *input = qobject_cast<QQuickTextInput*>(canvas.rootObject());
+ QVERIFY(input);
+ input->setFocus(true);
+ QVERIFY(input->hasActiveFocus());
+
+ canvas.rootObject()->setProperty("regexvalue", QRegExp("abc"));
+ QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abc"));
+ QCOMPARE(canvas.rootObject()->property("text").toString(), QString("abc"));
+ QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
+
+ canvas.rootObject()->setProperty("regexvalue", QRegExp("abcd"));
+ QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abcd"));
+ QVERIFY(!canvas.rootObject()->property("acceptableInput").toBool());
+
+ canvas.rootObject()->setProperty("regexvalue", QRegExp("abc"));
+ QCOMPARE(canvas.rootObject()->property("regexvalue").toRegExp(), QRegExp("abc"));
+ QVERIFY(canvas.rootObject()->property("acceptableInput").toBool());
+}
+
+
+void tst_qquicktextinput::negativeDimensions()
+{
+ // Verify this doesn't assert during initialization.
+ QQmlComponent component(&engine, testFileUrl("negativeDimensions.qml"));
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY(o);
+ QQuickTextInput *input = o->findChild<QQuickTextInput *>("input");
+ QVERIFY(input);
+ QCOMPARE(input->width(), qreal(-1));
+ QCOMPARE(input->height(), qreal(-1));
+}
+
+QTEST_MAIN(tst_qquicktextinput)
+
+#include "tst_qquicktextinput.moc"
diff --git a/tests/auto/quick/qquicktimer/qquicktimer.pro b/tests/auto/quick/qquicktimer/qquicktimer.pro
new file mode 100644
index 0000000000..7b399c778d
--- /dev/null
+++ b/tests/auto/quick/qquicktimer/qquicktimer.pro
@@ -0,0 +1,8 @@
+CONFIG += testcase
+TARGET = tst_qquicktimer
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquicktimer.cpp
+
+CONFIG += parallel_test
+QT += core-private gui-private qml-private quick-private gui testlib
diff --git a/tests/auto/quick/qquicktimer/tst_qquicktimer.cpp b/tests/auto/quick/qquicktimer/tst_qquicktimer.cpp
new file mode 100644
index 0000000000..ff33609c06
--- /dev/null
+++ b/tests/auto/quick/qquicktimer/tst_qquicktimer.cpp
@@ -0,0 +1,393 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QSignalSpy>
+#include <qtest.h>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQuick/private/qquicktimer_p.h>
+#include <QtQuick/qquickitem.h>
+#include <QDebug>
+
+class tst_qquicktimer : public QObject
+{
+ Q_OBJECT
+public:
+ tst_qquicktimer();
+
+private slots:
+ void notRepeating();
+ void notRepeatingStart();
+ void repeat();
+ void noTriggerIfNotRunning();
+ void triggeredOnStart();
+ void triggeredOnStartRepeat();
+ void changeDuration();
+ void restart();
+ void restartFromTriggered();
+ void runningFromTriggered();
+ void parentProperty();
+};
+
+class TimerHelper : public QObject
+{
+ Q_OBJECT
+public:
+ TimerHelper() : QObject(), count(0)
+ {
+ }
+
+ int count;
+
+public slots:
+ void timeout() {
+ ++count;
+ }
+};
+
+#define TIMEOUT_TIMEOUT 200
+
+tst_qquicktimer::tst_qquicktimer()
+{
+}
+
+void tst_qquicktimer::notRepeating()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true }"), QUrl::fromLocalFile(""));
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(component.create());
+ QVERIFY(timer != 0);
+ QVERIFY(timer->isRunning());
+ QVERIFY(!timer->isRepeating());
+ QCOMPARE(timer->interval(), 100);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 1);
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 1);
+ QVERIFY(timer->isRunning() == false);
+}
+
+void tst_qquicktimer::notRepeatingStart()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100 }"), QUrl::fromLocalFile(""));
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(component.create());
+ QVERIFY(timer != 0);
+ QVERIFY(!timer->isRunning());
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 0);
+
+ timer->start();
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 1);
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 1);
+ QVERIFY(timer->isRunning() == false);
+
+ delete timer;
+}
+
+void tst_qquicktimer::repeat()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; repeat: true; running: true }"), QUrl::fromLocalFile(""));
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(component.create());
+ QVERIFY(timer != 0);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QCOMPARE(helper.count, 0);
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count > 0);
+ int oldCount = helper.count;
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count > oldCount);
+ QVERIFY(timer->isRunning());
+
+ oldCount = helper.count;
+ timer->stop();
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count == oldCount);
+ QVERIFY(timer->isRunning() == false);
+
+ QSignalSpy spy(timer, SIGNAL(repeatChanged()));
+
+ timer->setRepeating(false);
+ QVERIFY(!timer->isRepeating());
+ QCOMPARE(spy.count(),1);
+
+ timer->setRepeating(false);
+ QCOMPARE(spy.count(),1);
+
+ timer->setRepeating(true);
+ QCOMPARE(spy.count(),2);
+
+ delete timer;
+}
+
+void tst_qquicktimer::triggeredOnStart()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true; triggeredOnStart: true }"), QUrl::fromLocalFile(""));
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(component.create());
+ QVERIFY(timer != 0);
+ QVERIFY(timer->triggeredOnStart());
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QTest::qWait(1);
+ QCOMPARE(helper.count, 1);
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 2);
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(helper.count, 2);
+ QVERIFY(timer->isRunning() == false);
+
+ QSignalSpy spy(timer, SIGNAL(triggeredOnStartChanged()));
+
+ timer->setTriggeredOnStart(false);
+ QVERIFY(!timer->triggeredOnStart());
+ QCOMPARE(spy.count(),1);
+
+ timer->setTriggeredOnStart(false);
+ QCOMPARE(spy.count(),1);
+
+ timer->setTriggeredOnStart(true);
+ QCOMPARE(spy.count(),2);
+
+ delete timer;
+}
+
+void tst_qquicktimer::triggeredOnStartRepeat()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 100; running: true; triggeredOnStart: true; repeat: true }"), QUrl::fromLocalFile(""));
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(component.create());
+ QVERIFY(timer != 0);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QTest::qWait(1);
+ QCOMPARE(helper.count, 1);
+
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count > 1);
+ int oldCount = helper.count;
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QVERIFY(helper.count > oldCount);
+ QVERIFY(timer->isRunning());
+
+ delete timer;
+}
+
+void tst_qquicktimer::noTriggerIfNotRunning()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray(
+ "import QtQuick 2.0\n"
+ "Item { property bool ok: true\n"
+ "Timer { id: t1; interval: 100; repeat: true; running: true; onTriggered: if (!running) ok=false }"
+ "Timer { interval: 10; running: true; onTriggered: t1.running=false }"
+ "}"
+ ), QUrl::fromLocalFile(""));
+ QObject *item = component.create();
+ QVERIFY(item != 0);
+ QTest::qWait(TIMEOUT_TIMEOUT);
+ QCOMPARE(item->property("ok").toBool(), true);
+
+ delete item;
+}
+
+void tst_qquicktimer::changeDuration()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 200; repeat: true; running: true }"), QUrl::fromLocalFile(""));
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(component.create());
+ QVERIFY(timer != 0);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QCOMPARE(helper.count, 0);
+
+ QTest::qWait(500);
+ QCOMPARE(helper.count, 2);
+
+ timer->setInterval(500);
+
+ QTest::qWait(600);
+ QCOMPARE(helper.count, 3);
+ QVERIFY(timer->isRunning());
+
+ QSignalSpy spy(timer, SIGNAL(intervalChanged()));
+
+ timer->setInterval(200);
+ QCOMPARE(timer->interval(), 200);
+ QCOMPARE(spy.count(),1);
+
+ timer->setInterval(200);
+ QCOMPARE(spy.count(),1);
+
+ timer->setInterval(300);
+ QCOMPARE(spy.count(),2);
+
+ delete timer;
+}
+
+void tst_qquicktimer::restart()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { interval: 500; repeat: true; running: true }"), QUrl::fromLocalFile(""));
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(component.create());
+ QVERIFY(timer != 0);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QCOMPARE(helper.count, 0);
+
+ QTest::qWait(600);
+ QCOMPARE(helper.count, 1);
+
+ QTest::qWait(300);
+
+ timer->restart();
+
+ QTest::qWait(700);
+
+ QCOMPARE(helper.count, 2);
+ QVERIFY(timer->isRunning());
+
+ delete timer;
+}
+
+void tst_qquicktimer::restartFromTriggered()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { "
+ "interval: 500; "
+ "repeat: false; "
+ "running: true; "
+ "onTriggered: restart()"
+ " }"), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> object(component.create());
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(object.data());
+ QVERIFY(timer != 0);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QCOMPARE(helper.count, 0);
+
+ QTest::qWait(600);
+ QCOMPARE(helper.count, 1);
+ QVERIFY(timer->isRunning());
+
+ QTest::qWait(600);
+ QCOMPARE(helper.count, 2);
+ QVERIFY(timer->isRunning());
+}
+
+void tst_qquicktimer::runningFromTriggered()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nTimer { "
+ "property bool ok: false; "
+ "interval: 500; "
+ "repeat: false; "
+ "running: true; "
+ "onTriggered: { ok = !running; running = true }"
+ " }"), QUrl::fromLocalFile(""));
+ QScopedPointer<QObject> object(component.create());
+ QQuickTimer *timer = qobject_cast<QQuickTimer*>(object.data());
+ QVERIFY(timer != 0);
+
+ TimerHelper helper;
+ connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout()));
+ QCOMPARE(helper.count, 0);
+
+ QTest::qWait(600);
+ QCOMPARE(helper.count, 1);
+ QVERIFY(timer->property("ok").toBool());
+ QVERIFY(timer->isRunning());
+
+ QTest::qWait(600);
+ QCOMPARE(helper.count, 2);
+ QVERIFY(timer->property("ok").toBool());
+ QVERIFY(timer->isRunning());
+}
+
+void tst_qquicktimer::parentProperty()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtQuick 2.0\nItem { Timer { objectName: \"timer\"; running: parent.visible } }"), QUrl::fromLocalFile(""));
+ QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(item != 0);
+ QQuickTimer *timer = item->findChild<QQuickTimer*>("timer");
+ QVERIFY(timer != 0);
+
+ QVERIFY(timer->isRunning());
+
+ delete timer;
+}
+
+QTEST_MAIN(tst_qquicktimer)
+
+#include "tst_qquicktimer.moc"
diff --git a/tests/auto/qtquick2/qquickview/data/error1.qml b/tests/auto/quick/qquickview/data/error1.qml
index 09df679555..09df679555 100644
--- a/tests/auto/qtquick2/qquickview/data/error1.qml
+++ b/tests/auto/quick/qquickview/data/error1.qml
diff --git a/tests/auto/qtquick2/qquickview/data/resizemodeitem.qml b/tests/auto/quick/qquickview/data/resizemodeitem.qml
index ed73009b26..ed73009b26 100644
--- a/tests/auto/qtquick2/qquickview/data/resizemodeitem.qml
+++ b/tests/auto/quick/qquickview/data/resizemodeitem.qml
diff --git a/tests/auto/quick/qquickview/qquickview.pro b/tests/auto/quick/qquickview/qquickview.pro
new file mode 100644
index 0000000000..77b0f7d86a
--- /dev/null
+++ b/tests/auto/quick/qquickview/qquickview.pro
@@ -0,0 +1,13 @@
+CONFIG += testcase
+TARGET = tst_qquickview
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickview.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+QT += core-private gui-private qml-private quick-private testlib
diff --git a/tests/auto/quick/qquickview/tst_qquickview.cpp b/tests/auto/quick/qquickview/tst_qquickview.cpp
new file mode 100644
index 0000000000..e5e8a83424
--- /dev/null
+++ b/tests/auto/quick/qquickview/tst_qquickview.cpp
@@ -0,0 +1,207 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/qquickitem.h>
+#include "../../shared/util.h"
+#include <QtGui/QWindow>
+#include <QtCore/QDebug>
+
+class tst_QQuickView : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_QQuickView();
+
+private slots:
+ void resizemodeitem();
+ void errors();
+};
+
+
+tst_QQuickView::tst_QQuickView()
+{
+}
+
+void tst_QQuickView::resizemodeitem()
+{
+ QWindow window;
+ window.setGeometry(0, 0, 400, 400);
+
+ QQuickView *canvas = new QQuickView(&window);
+ QVERIFY(canvas);
+ canvas->setResizeMode(QQuickView::SizeRootObjectToView);
+ QCOMPARE(QSize(0,0), canvas->initialSize());
+ canvas->setSource(testFileUrl("resizemodeitem.qml"));
+ QQuickItem* item = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(item);
+ window.show();
+
+ canvas->show();
+
+ // initial size from root object
+ QCOMPARE(item->width(), 200.0);
+ QCOMPARE(item->height(), 200.0);
+ QCOMPARE(canvas->size(), QSize(200, 200));
+ QCOMPARE(canvas->size(), canvas->sizeHint());
+ QCOMPARE(canvas->size(), canvas->initialSize());
+
+ // size update from view
+ canvas->resize(QSize(80,100));
+
+ QTRY_COMPARE(item->width(), 80.0);
+ QCOMPARE(item->height(), 100.0);
+ QCOMPARE(canvas->size(), QSize(80, 100));
+ QCOMPARE(canvas->size(), canvas->sizeHint());
+
+ canvas->setResizeMode(QQuickView::SizeViewToRootObject);
+
+ // size update from view disabled
+ canvas->resize(QSize(60,80));
+ QCOMPARE(item->width(), 80.0);
+ QCOMPARE(item->height(), 100.0);
+ QTest::qWait(50);
+ QCOMPARE(canvas->size(), QSize(60, 80));
+
+ // size update from root object
+ item->setWidth(250);
+ item->setHeight(350);
+ QCOMPARE(item->width(), 250.0);
+ QCOMPARE(item->height(), 350.0);
+ QTRY_COMPARE(canvas->size(), QSize(250, 350));
+ QCOMPARE(canvas->size(), QSize(250, 350));
+ QCOMPARE(canvas->size(), canvas->sizeHint());
+
+ // reset canvas
+ window.hide();
+ delete canvas;
+ canvas = new QQuickView(&window);
+ QVERIFY(canvas);
+ canvas->setResizeMode(QQuickView::SizeViewToRootObject);
+ canvas->setSource(testFileUrl("resizemodeitem.qml"));
+ item = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(item);
+ window.show();
+
+ canvas->show();
+
+ // initial size for root object
+ QCOMPARE(item->width(), 200.0);
+ QCOMPARE(item->height(), 200.0);
+ QCOMPARE(canvas->size(), canvas->sizeHint());
+ QCOMPARE(canvas->size(), canvas->initialSize());
+
+ // size update from root object
+ item->setWidth(80);
+ item->setHeight(100);
+ QCOMPARE(item->width(), 80.0);
+ QCOMPARE(item->height(), 100.0);
+ QTRY_COMPARE(canvas->size(), QSize(80, 100));
+ QCOMPARE(canvas->size(), QSize(80, 100));
+ QCOMPARE(canvas->size(), canvas->sizeHint());
+
+ // size update from root object disabled
+ canvas->setResizeMode(QQuickView::SizeRootObjectToView);
+ item->setWidth(60);
+ item->setHeight(80);
+ QCOMPARE(canvas->width(), 80);
+ QCOMPARE(canvas->height(), 100);
+ QCOMPARE(QSize(item->width(), item->height()), canvas->sizeHint());
+
+ // size update from view
+ canvas->resize(QSize(200,300));
+ QTest::qWait(50);
+ QCOMPARE(item->width(), 200.0);
+ QCOMPARE(item->height(), 300.0);
+ QCOMPARE(canvas->size(), QSize(200, 300));
+ QCOMPARE(canvas->size(), canvas->sizeHint());
+
+ window.hide();
+ delete canvas;
+
+ // if we set a specific size for the view then it should keep that size
+ // for SizeRootObjectToView mode.
+ canvas = new QQuickView(&window);
+ canvas->resize(300, 300);
+ canvas->setResizeMode(QQuickView::SizeRootObjectToView);
+ QCOMPARE(QSize(0,0), canvas->initialSize());
+ canvas->setSource(testFileUrl("resizemodeitem.qml"));
+ canvas->resize(300, 300);
+ item = qobject_cast<QQuickItem*>(canvas->rootObject());
+ QVERIFY(item);
+ window.show();
+
+ canvas->show();
+ QTest::qWait(50);
+
+ // initial size from root object
+ QCOMPARE(item->width(), 300.0);
+ QCOMPARE(item->height(), 300.0);
+ QCOMPARE(canvas->size(), QSize(300, 300));
+ QCOMPARE(canvas->size(), canvas->sizeHint());
+ QCOMPARE(canvas->initialSize(), QSize(200, 200)); // initial object size
+
+ delete canvas;
+}
+
+static void silentErrorsMsgHandler(QtMsgType, const char *)
+{
+}
+
+void tst_QQuickView::errors()
+{
+ QQuickView *canvas = new QQuickView;
+ QVERIFY(canvas);
+ QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler);
+ canvas->setSource(testFileUrl("error1.qml"));
+ qInstallMsgHandler(old);
+ QVERIFY(canvas->status() == QQuickView::Error);
+ QVERIFY(canvas->errors().count() == 1);
+ delete canvas;
+}
+
+
+QTEST_MAIN(tst_QQuickView)
+
+#include "tst_qquickview.moc"
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/create.qml b/tests/auto/quick/qquickvisualdatamodel/data/create.qml
index 9f4b754552..9f4b754552 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/create.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/create.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/datalist-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/datalist-package.qml
index ae3bd81d91..ae3bd81d91 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/datalist-package.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/datalist-package.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/datalist.qml b/tests/auto/quick/qquickvisualdatamodel/data/datalist.qml
index 8ce59caddc..8ce59caddc 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/datalist.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/datalist.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups-invalid.qml b/tests/auto/quick/qquickvisualdatamodel/data/groups-invalid.qml
index 70c6f9f995..70c6f9f995 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups-invalid.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/groups-invalid.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/groups-package.qml
index ea5ad5d3bd..ea5ad5d3bd 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups-package.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/groups-package.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups.qml b/tests/auto/quick/qquickvisualdatamodel/data/groups.qml
index 7502dd2502..7502dd2502 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/groups.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/groups.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_listView.qml b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_listView.qml
index 103c4d2eb6..103c4d2eb6 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_listView.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_listView.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_package.qml b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_package.qml
index b47f22dc34..b47f22dc34 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_package.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_package.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml
index bc619124fd..bc619124fd 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_pathView.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml
index e97e0dad2e..e97e0dad2e 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/itemsDestroyed_repeater.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties-package.qml
index b6b56727e8..b6b56727e8 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties-package.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties-package.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties.qml
index d2dfc37e07..d2dfc37e07 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/listmodelproperties.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/listmodelproperties.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/modelproperties.qml
index 73b766f1af..73b766f1af 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/modelproperties.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties2.qml b/tests/auto/quick/qquickvisualdatamodel/data/modelproperties2.qml
index ea5c240b29..ea5c240b29 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/modelproperties2.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/modelproperties2.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties-package.qml
index 964ac426f8..964ac426f8 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties-package.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties-package.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties.qml
index 77e30b69b9..77e30b69b9 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/multipleroleproperties.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/multipleroleproperties.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlist.qml b/tests/auto/quick/qquickvisualdatamodel/data/objectlist.qml
index b3952a8a4d..b3952a8a4d 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlist.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/objectlist.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties-package.qml
index c69e54c2f8..c69e54c2f8 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties-package.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties-package.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties.qml
index 0dbe2f5459..0dbe2f5459 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/objectlistproperties.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/objectlistproperties.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/onChanged.qml b/tests/auto/quick/qquickvisualdatamodel/data/onChanged.qml
index 71dc7d72d7..71dc7d72d7 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/onChanged.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/onChanged.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/packageView.qml b/tests/auto/quick/qquickvisualdatamodel/data/packageView.qml
index 682f3833d1..682f3833d1 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/packageView.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/packageView.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole1.qml b/tests/auto/quick/qquickvisualdatamodel/data/singlerole1.qml
index c471893e1d..c471893e1d 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole1.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/singlerole1.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole2.qml b/tests/auto/quick/qquickvisualdatamodel/data/singlerole2.qml
index ab1798999d..ab1798999d 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/singlerole2.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/singlerole2.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties-package.qml
index 910df816f3..910df816f3 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties-package.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties-package.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties.qml
index 6133c61bc5..6133c61bc5 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/singleroleproperties.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/singleroleproperties.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties-package.qml b/tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties-package.qml
index d1a4604b77..d1a4604b77 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties-package.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties-package.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties.qml b/tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties.qml
index a075ccb4d9..a075ccb4d9 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/stringlistproperties.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/stringlistproperties.qml
diff --git a/tests/auto/qtquick2/qquickvisualdatamodel/data/visualdatamodel.qml b/tests/auto/quick/qquickvisualdatamodel/data/visualdatamodel.qml
index 0d4d9e2e46..0d4d9e2e46 100644
--- a/tests/auto/qtquick2/qquickvisualdatamodel/data/visualdatamodel.qml
+++ b/tests/auto/quick/qquickvisualdatamodel/data/visualdatamodel.qml
diff --git a/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro b/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro
new file mode 100644
index 0000000000..bfadf196f9
--- /dev/null
+++ b/tests/auto/quick/qquickvisualdatamodel/qquickvisualdatamodel.pro
@@ -0,0 +1,16 @@
+CONFIG += testcase
+TARGET = tst_qquickvisualdatamodel
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickvisualdatamodel.cpp
+
+include (../../shared/util.pri)
+include (../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private quick-private widgets testlib
diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
new file mode 100644
index 0000000000..dbfd4919b9
--- /dev/null
+++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
@@ -0,0 +1,3446 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/util.h"
+#include "../shared/visualtestutil.h"
+
+#include <qtest.h>
+#include <QtTest/QSignalSpy>
+#include <QStandardItemModel>
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qqmlcontext.h>
+#include <QtQml/qqmlexpression.h>
+#include <QtQuick/qquickview.h>
+#include <private/qquicklistview_p.h>
+#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuick/private/qquickvisualdatamodel_p.h>
+#include <private/qqmlvaluetype_p.h>
+#include <private/qquickchangeset_p.h>
+#include <private/qqmlengine_p.h>
+#include <math.h>
+
+using namespace QQuickVisualTestUtil;
+
+template <typename T, int N> int lengthOf(const T (&)[N]) { return N; }
+
+static void initStandardTreeModel(QStandardItemModel *model)
+{
+ QStandardItem *item;
+ item = new QStandardItem(QLatin1String("Row 1 Item"));
+ model->insertRow(0, item);
+
+ item = new QStandardItem(QLatin1String("Row 2 Item"));
+ item->setCheckable(true);
+ model->insertRow(1, item);
+
+ QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item"));
+ item->setChild(0, childItem);
+
+ item = new QStandardItem(QLatin1String("Row 3 Item"));
+ item->setIcon(QIcon());
+ model->insertRow(2, item);
+}
+
+class SingleRoleModel : public QAbstractListModel
+{
+ Q_OBJECT
+ Q_PROPERTY(QStringList values WRITE setList)
+public:
+ SingleRoleModel(const QByteArray &role = "name", QObject *parent = 0)
+ : QAbstractListModel(parent)
+ {
+ QHash<int, QByteArray> roles;
+ roles.insert(Qt::DisplayRole , role);
+ setRoleNames(roles);
+ list << "one" << "two" << "three" << "four";
+ }
+
+ void emitMove(int sourceFirst, int sourceLast, int destinationChild) {
+ emit beginMoveRows(QModelIndex(), sourceFirst, sourceLast, QModelIndex(), destinationChild);
+ emit endMoveRows();
+ }
+
+ QStringList list;
+
+ void setList(const QStringList &l) { list = l; }
+
+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();
+ }
+};
+
+class StandardItem : public QObject, public QStandardItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QString text WRITE setText)
+
+public:
+ void writeText(const QString &text) { setText(text); }
+};
+
+class StandardItemModel : public QStandardItemModel
+{
+ Q_OBJECT
+ Q_PROPERTY(QQmlListProperty<StandardItem> items READ items CONSTANT)
+ Q_CLASSINFO("DefaultProperty", "items")
+public:
+ QQmlListProperty<StandardItem> items() { return QQmlListProperty<StandardItem>(this, 0, append); }
+
+ static void append(QQmlListProperty<StandardItem> *property, StandardItem *item)
+ {
+ static_cast<QStandardItemModel *>(property->object)->appendRow(item);
+ }
+};
+
+class DataObject : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
+ Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
+
+public:
+ DataObject(QObject *parent=0) : QObject(parent) {}
+ DataObject(const QString &name, const QString &color, QObject *parent=0)
+ : QObject(parent), m_name(name), m_color(color) { }
+
+
+ QString name() const { return m_name; }
+ void setName(const QString &name) {
+ if (name != m_name) {
+ m_name = name;
+ emit nameChanged();
+ }
+ }
+
+ QString color() const { return m_color; }
+ void setColor(const QString &color) {
+ if (color != m_color) {
+ m_color = color;
+ emit colorChanged();
+ }
+ }
+
+signals:
+ void nameChanged();
+ void colorChanged();
+
+private:
+ QString m_name;
+ QString m_color;
+};
+
+QML_DECLARE_TYPE(SingleRoleModel)
+QML_DECLARE_TYPE(StandardItem)
+QML_DECLARE_TYPE(StandardItemModel)
+QML_DECLARE_TYPE(DataObject)
+
+class tst_qquickvisualdatamodel : public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_qquickvisualdatamodel();
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void rootIndex();
+ void updateLayout_data();
+ void updateLayout();
+ void childChanged_data();
+ void childChanged();
+ void objectListModel();
+ void singleRole();
+ void modelProperties();
+ void noDelegate_data();
+ void noDelegate();
+ void itemsDestroyed_data();
+ void itemsDestroyed();
+ void packagesDestroyed();
+ void qaimRowsMoved();
+ void qaimRowsMoved_data();
+ void remove_data();
+ void remove();
+ void move_data();
+ void move();
+ void groups_data();
+ void groups();
+ void invalidGroups();
+ void get();
+ void onChanged_data();
+ void onChanged();
+ void create();
+ void incompleteModel();
+ void insert_data();
+ void insert();
+ void resolve_data();
+ void resolve();
+ void warnings_data();
+ void warnings();
+
+private:
+ template <int N> void groups_verify(
+ const SingleRoleModel &model,
+ QQuickItem *contentItem,
+ const int (&mIndex)[N],
+ const int (&iIndex)[N],
+ const int (&vIndex)[N],
+ const int (&sIndex)[N],
+ const bool (&vMember)[N],
+ const bool (&sMember)[N]);
+
+ template <int N> void get_verify(
+ const SingleRoleModel &model,
+ QQuickVisualDataModel *visualModel,
+ QQuickVisualDataGroup *visibleItems,
+ QQuickVisualDataGroup *selectedItems,
+ const int (&mIndex)[N],
+ const int (&iIndex)[N],
+ const int (&vIndex)[N],
+ const int (&sIndex)[N],
+ const bool (&vMember)[N],
+ const bool (&sMember)[N]);
+
+ bool failed;
+ QQmlEngine engine;
+};
+
+Q_DECLARE_METATYPE(QQuickChangeSet)
+
+template <typename T> static T evaluate(QObject *scope, const QString &expression)
+{
+ QQmlExpression expr(qmlContext(scope), scope, expression);
+ T result = expr.evaluate().value<T>();
+ if (expr.hasError())
+ qWarning() << expr.error().toString();
+ return result;
+}
+
+template <> void evaluate<void>(QObject *scope, const QString &expression)
+{
+ QQmlExpression expr(qmlContext(scope), scope, expression);
+ expr.evaluate();
+ if (expr.hasError())
+ qWarning() << expr.error().toString();
+}
+
+void tst_qquickvisualdatamodel::initTestCase()
+{
+ QQmlDataTest::initTestCase();
+ qRegisterMetaType<QQuickChangeSet>();
+
+ qmlRegisterType<SingleRoleModel>("tst_qquickvisualdatamodel", 1, 0, "SingleRoleModel");
+ qmlRegisterType<StandardItem>("tst_qquickvisualdatamodel", 1, 0, "StandardItem");
+ qmlRegisterType<StandardItemModel>("tst_qquickvisualdatamodel", 1, 0, "StandardItemModel");
+ qmlRegisterType<DataObject>("tst_qquickvisualdatamodel", 1, 0, "DataObject");
+}
+
+void tst_qquickvisualdatamodel::cleanupTestCase()
+{
+
+}
+
+tst_qquickvisualdatamodel::tst_qquickvisualdatamodel()
+{
+}
+
+void tst_qquickvisualdatamodel::rootIndex()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("visualdatamodel.qml"));
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+
+ engine.rootContext()->setContextProperty("myModel", &model);
+
+ QQuickVisualDataModel *obj = qobject_cast<QQuickVisualDataModel*>(c.create());
+ QVERIFY(obj != 0);
+
+ QMetaObject::invokeMethod(obj, "setRoot");
+ QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == model.index(0,0));
+
+ QMetaObject::invokeMethod(obj, "setRootToParent");
+ QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex());
+
+ QMetaObject::invokeMethod(obj, "setRoot");
+ QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == model.index(0,0));
+ model.clear(); // will emit modelReset()
+ QVERIFY(qvariant_cast<QModelIndex>(obj->rootIndex()) == QModelIndex());
+
+ delete obj;
+}
+
+void tst_qquickvisualdatamodel::updateLayout_data()
+{
+ QTest::addColumn<QUrl>("source");
+
+ QTest::newRow("item delegate") << testFileUrl("datalist.qml");
+ QTest::newRow("package delegate") << testFileUrl("datalist-package.qml");
+}
+
+void tst_qquickvisualdatamodel::updateLayout()
+{
+ QFETCH(QUrl, source);
+
+ QQuickView view;
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+
+ view.rootContext()->setContextProperty("myModel", &model);
+
+ view.setSource(source);
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 1 Item"));
+ name = findItem<QQuickText>(contentItem, "display", 1);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Item"));
+ name = findItem<QQuickText>(contentItem, "display", 2);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 3 Item"));
+
+ model.invisibleRootItem()->sortChildren(0, Qt::DescendingOrder);
+
+ name = findItem<QQuickText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 3 Item"));
+ name = findItem<QQuickText>(contentItem, "display", 1);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Item"));
+ name = findItem<QQuickText>(contentItem, "display", 2);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 1 Item"));
+}
+
+void tst_qquickvisualdatamodel::childChanged_data()
+{
+ QTest::addColumn<QUrl>("source");
+
+ QTest::newRow("item delegate") << testFileUrl("datalist.qml");
+ QTest::newRow("package delegate") << testFileUrl("datalist-package.qml");
+}
+
+void tst_qquickvisualdatamodel::childChanged()
+{
+ QFETCH(QUrl, source);
+
+ QQuickView view;
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+
+ view.rootContext()->setContextProperty("myModel", &model);
+
+ view.setSource(source);
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickVisualDataModel *vdm = listview->findChild<QQuickVisualDataModel*>("visualModel");
+ vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0))));
+ QCOMPARE(listview->count(), 1);
+
+ QQuickText *name = findItem<QQuickText>(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<QQuickText>(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")));
+ QCOMPARE(listview->count(), 2);
+
+ name = findItem<QQuickText>(contentItem, "display", 1);
+ QVERIFY(name != 0);
+ QCOMPARE(name->text(), QString("Row 2 Child Item 2"));
+
+ model.item(1,0)->takeRow(1);
+ name = findItem<QQuickText>(contentItem, "display", 1);
+ QVERIFY(name == 0);
+
+ vdm->setRootIndex(QVariant::fromValue(QModelIndex()));
+ QCOMPARE(listview->count(), 3);
+ name = findItem<QQuickText>(contentItem, "display", 0);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 1 Item"));
+ name = findItem<QQuickText>(contentItem, "display", 1);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 2 Item"));
+ name = findItem<QQuickText>(contentItem, "display", 2);
+ QVERIFY(name);
+ QCOMPARE(name->text(), QString("Row 3 Item"));
+}
+
+void tst_qquickvisualdatamodel::objectListModel()
+{
+ QQuickView view;
+
+ QList<QObject*> dataList;
+ dataList.append(new DataObject("Item 1", "red"));
+ dataList.append(new DataObject("Item 2", "green"));
+ dataList.append(new DataObject("Item 3", "blue"));
+ dataList.append(new DataObject("Item 4", "yellow"));
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+
+ view.setSource(testFileUrl("objectlist.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "name", 0);
+ QCOMPARE(name->text(), QString("Item 1"));
+
+ QQuickText *section = findItem<QQuickText>(contentItem, "section", 0);
+ QCOMPARE(section->text(), QString("Item 1"));
+
+ dataList[0]->setProperty("name", QLatin1String("Changed"));
+ QCOMPARE(name->text(), QString("Changed"));
+}
+
+void tst_qquickvisualdatamodel::singleRole()
+{
+ {
+ QQuickView view;
+
+ SingleRoleModel model;
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(testFileUrl("singlerole1.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "name", 1);
+ QCOMPARE(name->text(), QString("two"));
+
+ model.set(1, "Changed");
+ QCOMPARE(name->text(), QString("Changed"));
+ }
+ {
+ QQuickView view;
+
+ SingleRoleModel model;
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(testFileUrl("singlerole2.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "name", 1);
+ QCOMPARE(name->text(), QString("two"));
+
+ model.set(1, "Changed");
+ QCOMPARE(name->text(), QString("Changed"));
+ }
+ {
+ QQuickView view;
+
+ SingleRoleModel model("modelData");
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(testFileUrl("singlerole2.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickText *name = findItem<QQuickText>(contentItem, "name", 1);
+ QCOMPARE(name->text(), QString("two"));
+
+ model.set(1, "Changed");
+ QCOMPARE(name->text(), QString("Changed"));
+ }
+}
+
+void tst_qquickvisualdatamodel::modelProperties()
+{
+ {
+ QQuickView view;
+
+ SingleRoleModel model;
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(testFileUrl("modelproperties.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 1);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(),QString("two"));
+ QCOMPARE(delegate->property("test2").toString(),QString("two"));
+ QCOMPARE(delegate->property("test3").toString(),QString("two"));
+ QCOMPARE(delegate->property("test4").toString(),QString("two"));
+ QVERIFY(!delegate->property("test9").isValid());
+ QCOMPARE(delegate->property("test5").toString(),QString(""));
+ QVERIFY(delegate->property("test6").value<QObject*>() != 0);
+ QCOMPARE(delegate->property("test7").toInt(),1);
+ QCOMPARE(delegate->property("test8").toInt(),1);
+ }
+
+ {
+ QQuickView view;
+
+ QList<QObject*> dataList;
+ dataList.append(new DataObject("Item 1", "red"));
+ dataList.append(new DataObject("Item 2", "green"));
+ dataList.append(new DataObject("Item 3", "blue"));
+ dataList.append(new DataObject("Item 4", "yellow"));
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+
+ view.setSource(testFileUrl("modelproperties.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 1);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(),QString("Item 2"));
+ QCOMPARE(delegate->property("test2").toString(),QString("Item 2"));
+ QVERIFY(qobject_cast<DataObject*>(delegate->property("test3").value<QObject*>()) != 0);
+ QVERIFY(qobject_cast<DataObject*>(delegate->property("test4").value<QObject*>()) != 0);
+ QCOMPARE(delegate->property("test5").toString(),QString("Item 2"));
+ QCOMPARE(delegate->property("test9").toString(),QString("Item 2"));
+ QVERIFY(delegate->property("test6").value<QObject*>() != 0);
+ QCOMPARE(delegate->property("test7").toInt(),1);
+ QCOMPARE(delegate->property("test8").toInt(),1);
+ }
+
+ {
+ QQuickView view;
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+
+ view.rootContext()->setContextProperty("myModel", &model);
+
+ QUrl source(testFileUrl("modelproperties2.qml"));
+
+ //3 items, 3 i each
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData");
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData");
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData");
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData");
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined");
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined");
+ QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":17: TypeError: Cannot read property 'display' of undefined");
+
+ view.setSource(source);
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 1);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(),QString("Row 2 Item"));
+ QCOMPARE(delegate->property("test2").toString(),QString("Row 2 Item"));
+ QVERIFY(!delegate->property("test3").isValid());
+ QVERIFY(!delegate->property("test4").isValid());
+ QVERIFY(!delegate->property("test5").isValid());
+ QVERIFY(!delegate->property("test9").isValid());
+ QVERIFY(delegate->property("test6").value<QObject*>() != 0);
+ QCOMPARE(delegate->property("test7").toInt(),1);
+ QCOMPARE(delegate->property("test8").toInt(),1);
+ }
+
+ //### should also test QStringList and QVariantList
+}
+
+void tst_qquickvisualdatamodel::noDelegate_data()
+{
+ QTest::addColumn<QUrl>("source");
+
+ QTest::newRow("item delegate") << testFileUrl("datalist.qml");
+ QTest::newRow("package delegate") << testFileUrl("datalist-package.qml");
+}
+
+void tst_qquickvisualdatamodel::noDelegate()
+{
+ QFETCH(QUrl, source);
+
+ QQuickView view;
+
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+
+ view.rootContext()->setContextProperty("myModel", &model);
+
+ view.setSource(source);
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickVisualDataModel *vdm = listview->findChild<QQuickVisualDataModel*>("visualModel");
+ QVERIFY(vdm != 0);
+ QCOMPARE(vdm->count(), 3);
+
+ vdm->setDelegate(0);
+ QCOMPARE(vdm->count(), 0);
+}
+
+void tst_qquickvisualdatamodel::itemsDestroyed_data()
+{
+ QTest::addColumn<QUrl>("source");
+
+ QTest::newRow("listView") << testFileUrl("itemsDestroyed_listView.qml");
+ QTest::newRow("package") << testFileUrl("itemsDestroyed_package.qml");
+ QTest::newRow("pathView") << testFileUrl("itemsDestroyed_pathView.qml");
+ QTest::newRow("repeater") << testFileUrl("itemsDestroyed_repeater.qml");
+}
+
+void tst_qquickvisualdatamodel::itemsDestroyed()
+{
+ QFETCH(QUrl, source);
+
+ QQmlGuard<QQuickItem> delegate;
+
+ {
+ QQuickView view;
+ QStandardItemModel model;
+ initStandardTreeModel(&model);
+ view.rootContext()->setContextProperty("myModel", &model);
+ view.setSource(source);
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QVERIFY(delegate = findItem<QQuickItem>(view.rootItem(), "delegate", 1));
+ }
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QVERIFY(!delegate);
+}
+
+void tst_qquickvisualdatamodel::packagesDestroyed()
+{
+ SingleRoleModel model;
+ model.list.clear();
+ for (int i=0; i<30; i++)
+ model.list << ("item " + i);
+
+ QQuickView view;
+ view.rootContext()->setContextProperty("testModel", &model);
+
+ QString filename(testFile("packageView.qml"));
+ view.setSource(QUrl::fromLocalFile(filename));
+
+ qApp->processEvents();
+
+ QQuickListView *leftview = findItem<QQuickListView>(view.rootObject(), "leftList");
+ QTRY_VERIFY(leftview != 0);
+
+ QQuickListView *rightview = findItem<QQuickListView>(view.rootObject(), "rightList");
+ QTRY_VERIFY(rightview != 0);
+
+ QQuickItem *leftContent = leftview->contentItem();
+ QTRY_VERIFY(leftContent != 0);
+
+ QQuickItem *rightContent = rightview->contentItem();
+ QTRY_VERIFY(rightContent != 0);
+
+ QCOMPARE(leftview->currentIndex(), 0);
+ QCOMPARE(rightview->currentIndex(), 0);
+
+ rightview->setCurrentIndex(20);
+ QTRY_COMPARE(rightview->contentY(), 100.0);
+
+ QQmlGuard<QQuickItem> left;
+ QQmlGuard<QQuickItem> right;
+
+ QVERIFY(findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QVERIFY(findItem<QQuickItem>(rightContent, "wrapper", 1));
+
+ QVERIFY(left = findItem<QQuickItem>(leftContent, "wrapper", 19));
+ QVERIFY(right = findItem<QQuickItem>(rightContent, "wrapper", 19));
+
+ rightview->setCurrentIndex(0);
+ QCOMPARE(rightview->currentIndex(), 0);
+
+ QTRY_COMPARE(rightview->contentY(), 0.0);
+ QCoreApplication::sendPostedEvents();
+
+ QVERIFY(!left);
+ QVERIFY(!right);
+
+ QVERIFY(left = findItem<QQuickItem>(leftContent, "wrapper", 1));
+ QVERIFY(right = findItem<QQuickItem>(rightContent, "wrapper", 1));
+
+ rightview->setCurrentIndex(20);
+ QTRY_COMPARE(rightview->contentY(), 100.0);
+
+ QVERIFY(left);
+ QVERIFY(right);
+
+ QVERIFY(findItem<QQuickItem>(leftContent, "wrapper", 19));
+ QVERIFY(findItem<QQuickItem>(rightContent, "wrapper", 19));
+
+ leftview->setCurrentIndex(20);
+ QTRY_COMPARE(leftview->contentY(), 100.0);
+
+ QVERIFY(!left);
+ QVERIFY(!right);
+}
+
+void tst_qquickvisualdatamodel::qaimRowsMoved()
+{
+ // Test parameters passed in QAIM::rowsMoved() signal are converted correctly
+ // when translated and emitted as the QListModelInterface::itemsMoved() signal
+ QFETCH(int, sourceFirst);
+ QFETCH(int, sourceLast);
+ QFETCH(int, destinationChild);
+ QFETCH(int, expectFrom);
+ QFETCH(int, expectTo);
+ QFETCH(int, expectCount);
+
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("visualdatamodel.qml"));
+
+ SingleRoleModel model;
+ model.list.clear();
+ for (int i=0; i<30; i++)
+ model.list << ("item " + i);
+ engine.rootContext()->setContextProperty("myModel", &model);
+
+ QQuickVisualDataModel *obj = qobject_cast<QQuickVisualDataModel*>(c.create());
+ QVERIFY(obj != 0);
+
+ QSignalSpy spy(obj, SIGNAL(modelUpdated(QQuickChangeSet,bool)));
+ model.emitMove(sourceFirst, sourceLast, destinationChild);
+ QCOMPARE(spy.count(), 1);
+
+ QCOMPARE(spy[0].count(), 2);
+ QQuickChangeSet changeSet = spy[0][0].value<QQuickChangeSet>();
+ QCOMPARE(changeSet.removes().count(), 1);
+ QCOMPARE(changeSet.removes().at(0).index, expectFrom);
+ QCOMPARE(changeSet.removes().at(0).count, expectCount);
+ QCOMPARE(changeSet.inserts().count(), 1);
+ QCOMPARE(changeSet.inserts().at(0).index, expectTo);
+ QCOMPARE(changeSet.inserts().at(0).count, expectCount);
+ QCOMPARE(changeSet.removes().at(0).moveId, changeSet.inserts().at(0).moveId);
+ QCOMPARE(spy[0][1].toBool(), false);
+
+ delete obj;
+}
+
+void tst_qquickvisualdatamodel::qaimRowsMoved_data()
+{
+ QTest::addColumn<int>("sourceFirst");
+ QTest::addColumn<int>("sourceLast");
+ QTest::addColumn<int>("destinationChild");
+ QTest::addColumn<int>("expectFrom");
+ QTest::addColumn<int>("expectTo");
+ QTest::addColumn<int>("expectCount");
+
+ QTest::newRow("move 1 forward")
+ << 1 << 1 << 6
+ << 1 << 5 << 1;
+
+ QTest::newRow("move 1 backwards")
+ << 4 << 4 << 1
+ << 4 << 1 << 1;
+
+ QTest::newRow("move multiple forwards")
+ << 0 << 2 << 13
+ << 0 << 10 << 3;
+
+ QTest::newRow("move multiple forwards, with same to")
+ << 0 << 1 << 3
+ << 0 << 1 << 2;
+
+ QTest::newRow("move multiple backwards")
+ << 10 << 14 << 1
+ << 10 << 1 << 5;
+}
+
+void tst_qquickvisualdatamodel::remove_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::addColumn<QString>("package delegate");
+
+ QTest::newRow("item delegate")
+ << testFileUrl("groups.qml")
+ << QString();
+ QTest::newRow("package")
+ << testFileUrl("groups-package.qml")
+ << QString("package.");
+}
+
+void tst_qquickvisualdatamodel::remove()
+{
+ QQuickView view;
+
+ SingleRoleModel model;
+ model.list = QStringList()
+ << "one"
+ << "two"
+ << "three"
+ << "four"
+ << "five"
+ << "six"
+ << "seven"
+ << "eight"
+ << "nine"
+ << "ten"
+ << "eleven"
+ << "twelve";
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(testFileUrl("groups.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
+ QVERIFY(visualModel);
+
+ {
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+
+ for (int i = 0; i < lengthOf(mIndex); ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
+ QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
+ QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
+ }
+ } {
+ evaluate<void>(visualModel, "items.remove(2)");
+ QCOMPARE(listview->count(), 11);
+ QCOMPARE(visualModel->items()->count(), 11);
+ static const int mIndex[] = { 0, 1, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10 };
+
+ for (int i = 0; i < lengthOf(mIndex); ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
+ QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
+ QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
+ }
+ } {
+ evaluate<void>(visualModel, "items.remove(1, 4)");
+ QCOMPARE(listview->count(), 7);
+ QCOMPARE(visualModel->items()->count(), 7);
+ static const int mIndex[] = { 0, 6, 7, 8, 9,10,11 };
+ static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6 };
+
+ for (int i = 0; i < lengthOf(mIndex); ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
+ QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
+ QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
+ }
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: remove: index out of range");
+ evaluate<void>(visualModel, "items.remove(-8, 4)");
+ QCOMPARE(listview->count(), 7);
+ QCOMPARE(visualModel->items()->count(), 7);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: remove: index out of range");
+ evaluate<void>(visualModel, "items.remove(12, 2)");
+ QCOMPARE(listview->count(), 7);
+ QCOMPARE(visualModel->items()->count(), 7);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: remove: invalid count");
+ evaluate<void>(visualModel, "items.remove(5, 3)");
+ QCOMPARE(listview->count(), 7);
+ QCOMPARE(visualModel->items()->count(), 7);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: remove: invalid count");
+ evaluate<void>(visualModel, "items.remove(5, -2)");
+ QCOMPARE(listview->count(), 7);
+ QCOMPARE(visualModel->items()->count(), 7);
+ }
+}
+
+void tst_qquickvisualdatamodel::move_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::addColumn<QString>("package delegate");
+
+ QTest::newRow("item delegate")
+ << testFileUrl("groups.qml")
+ << QString();
+ QTest::newRow("package")
+ << testFileUrl("groups-package.qml")
+ << QString("package.");
+}
+
+void tst_qquickvisualdatamodel::move()
+{
+ QQuickView view;
+
+ SingleRoleModel model;
+ model.list = QStringList()
+ << "one"
+ << "two"
+ << "three"
+ << "four"
+ << "five"
+ << "six"
+ << "seven"
+ << "eight"
+ << "nine"
+ << "ten"
+ << "eleven"
+ << "twelve";
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(testFileUrl("groups.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
+ QVERIFY(visualModel);
+
+ {
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+
+ for (int i = 0; i < lengthOf(mIndex); ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
+ QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
+ QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
+ }
+ } {
+ evaluate<void>(visualModel, "items.move(2, 4)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ static const int mIndex[] = { 0, 1, 3, 4, 2, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+
+ for (int i = 0; i < lengthOf(mIndex); ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
+ QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
+ QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
+ }
+ } {
+ evaluate<void>(visualModel, "items.move(4, 2)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ static const int mIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+
+ for (int i = 0; i < lengthOf(mIndex); ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
+ QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
+ QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
+ }
+ } {
+ evaluate<void>(visualModel, "items.move(8, 0, 4)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ static const int mIndex[] = { 8, 9,10,11, 0, 1, 2, 3, 4, 5, 6, 7 };
+ static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+
+ for (int i = 0; i < lengthOf(mIndex); ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
+ QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
+ QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
+ }
+ } {
+ evaluate<void>(visualModel, "items.move(3, 4, 5)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ static const int mIndex[] = { 8, 9,10,4, 11, 0, 1, 2, 3, 5, 6, 7 };
+ static const int iIndex[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+
+ for (int i = 0; i < lengthOf(mIndex); ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(delegate->property("test1").toString(), model.list.at(mIndex[i]));
+ QCOMPARE(delegate->property("test2").toInt(), mIndex[i]);
+ QCOMPARE(delegate->property("test3").toInt(), iIndex[i]);
+ }
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: invalid count");
+ evaluate<void>(visualModel, "items.move(5, 2, -2)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: from index out of range");
+ evaluate<void>(visualModel, "items.move(-6, 2, 1)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: from index out of range");
+ evaluate<void>(visualModel, "items.move(15, 2, 1)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: from index out of range");
+ evaluate<void>(visualModel, "items.move(11, 1, 3)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: to index out of range");
+ evaluate<void>(visualModel, "items.move(2, -5, 1)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: to index out of range");
+ evaluate<void>(visualModel, "items.move(2, 14, 1)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: move: to index out of range");
+ evaluate<void>(visualModel, "items.move(2, 11, 4)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ }
+}
+
+void tst_qquickvisualdatamodel::groups_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::addColumn<QString>("part");
+
+ QTest::newRow("item delegate")
+ << testFileUrl("groups.qml")
+ << QString();
+ QTest::newRow("package")
+ << testFileUrl("groups-package.qml")
+ << QString("visualModel.parts.package.");
+}
+
+template <int N> void tst_qquickvisualdatamodel::groups_verify(
+ const SingleRoleModel &model,
+ QQuickItem *contentItem,
+ const int (&mIndex)[N],
+ const int (&iIndex)[N],
+ const int (&vIndex)[N],
+ const int (&sIndex)[N],
+ const bool (&vMember)[N],
+ const bool (&sMember)[N])
+{
+ failed = true;
+ for (int i = 0; i < N; ++i) {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", mIndex[i]);
+ QVERIFY(delegate);
+ QCOMPARE(evaluate<QString>(delegate, "test1"), model.list.at(mIndex[i]));
+ QCOMPARE(evaluate<int>(delegate, "test2") , mIndex[i]);
+ QCOMPARE(evaluate<int>(delegate, "test3") , iIndex[i]);
+ QCOMPARE(evaluate<bool>(delegate, "test4"), true);
+ QCOMPARE(evaluate<int>(delegate, "test5") , vIndex[i]);
+ QCOMPARE(evaluate<bool>(delegate, "test6"), vMember[i]);
+ QCOMPARE(evaluate<int>(delegate, "test7") , sIndex[i]);
+ QCOMPARE(evaluate<bool>(delegate, "test8"), sMember[i]);
+ QCOMPARE(evaluate<QStringList>(delegate, "test9").contains("items") , bool(true));
+ QCOMPARE(evaluate<QStringList>(delegate, "test9").contains("visible") , bool(vMember[i]));
+ QCOMPARE(evaluate<QStringList>(delegate, "test9").contains("selected"), bool(sMember[i]));
+ }
+ failed = false;
+}
+
+#define VERIFY_GROUPS \
+ groups_verify(model, contentItem, mIndex, iIndex, vIndex, sIndex, vMember, sMember); \
+ QVERIFY(!failed)
+
+
+void tst_qquickvisualdatamodel::groups()
+{
+ QFETCH(QUrl, source);
+ QFETCH(QString, part);
+
+ QQuickView view;
+
+ SingleRoleModel model;
+ model.list = QStringList()
+ << "one"
+ << "two"
+ << "three"
+ << "four"
+ << "five"
+ << "six"
+ << "seven"
+ << "eight"
+ << "nine"
+ << "ten"
+ << "eleven"
+ << "twelve";
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(source);
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickVisualDataModel *visualModel = listview->findChild<QQuickVisualDataModel *>("visualModel");
+ QVERIFY(visualModel);
+
+ QQuickVisualDataGroup *visibleItems = listview->findChild<QQuickVisualDataGroup *>("visibleItems");
+ QVERIFY(visibleItems);
+
+ QQuickVisualDataGroup *selectedItems = listview->findChild<QQuickVisualDataGroup *>("selectedItems");
+ QVERIFY(selectedItems);
+
+ const bool f = false;
+ const bool t = true;
+
+ {
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 12);
+ QCOMPARE(selectedItems->count(), 0);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, f, f, f, f };
+ VERIFY_GROUPS;
+ } {
+ evaluate<void>(visualModel, "items.addGroups(8, \"selected\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 12);
+ QCOMPARE(selectedItems->count(), 1);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, t, f, f, f };
+ VERIFY_GROUPS;
+ } {
+ evaluate<void>(visualModel, "items.addGroups(6, 4, [\"visible\", \"selected\"])");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 12);
+ QCOMPARE(selectedItems->count(), 4);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4 };
+ static const bool sMember[] = { f, f, f, f, f, f, t, t, t, t, f, f };
+ VERIFY_GROUPS;
+ } {
+ evaluate<void>(visualModel, "items.setGroups(2, [\"items\", \"selected\"])");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 11);
+ QCOMPARE(selectedItems->count(), 5);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9,10 };
+ static const bool vMember[] = { t, t, f, t, t, t, t, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5, 5 };
+ static const bool sMember[] = { f, f, t, f, f, f, t, t, t, t, f, f };
+ VERIFY_GROUPS;
+ } {
+ evaluate<void>(selectedItems, "setGroups(0, 3, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 };
+ static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
+ VERIFY_GROUPS;
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: addGroups: invalid count");
+ evaluate<void>(visualModel, "items.addGroups(11, -4, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: addGroups: index out of range");
+ evaluate<void>(visualModel, "items.addGroups(-1, 3, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: addGroups: index out of range");
+ evaluate<void>(visualModel, "items.addGroups(14, 3, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: addGroups: invalid count");
+ evaluate<void>(visualModel, "items.addGroups(11, 5, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: setGroups: invalid count");
+ evaluate<void>(visualModel, "items.setGroups(11, -4, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: setGroups: index out of range");
+ evaluate<void>(visualModel, "items.setGroups(-1, 3, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: setGroups: index out of range");
+ evaluate<void>(visualModel, "items.setGroups(14, 3, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: setGroups: invalid count");
+ evaluate<void>(visualModel, "items.setGroups(11, 5, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: removeGroups: invalid count");
+ evaluate<void>(visualModel, "items.removeGroups(11, -4, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: removeGroups: index out of range");
+ evaluate<void>(visualModel, "items.removeGroups(-1, 3, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: removeGroups: index out of range");
+ evaluate<void>(visualModel, "items.removeGroups(14, 3, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: removeGroups: invalid count");
+ evaluate<void>(visualModel, "items.removeGroups(11, 5, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ } {
+ evaluate<void>(visualModel, part + "filterOnGroup = \"visible\"");
+ QCOMPARE(listview->count(), 9);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ QCOMPARE(evaluate<QString>(visualModel, part + "filterOnGroup"), QString("visible"));
+ } {
+ evaluate<void>(visualModel, part + "filterOnGroup = \"selected\"");
+ QCOMPARE(listview->count(), 2);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ QCOMPARE(evaluate<QString>(visualModel, part + "filterOnGroup"), QString("selected"));
+ } {
+ evaluate<void>(visualModel, part + "filterOnGroup = undefined");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ QCOMPARE(evaluate<QString>(visualModel, part + "filterOnGroup"), QString("items"));
+ } {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 5);
+ QVERIFY(delegate);
+
+ evaluate<void>(delegate, "hide()");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 8);
+ QCOMPARE(selectedItems->count(), 2);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 };
+ static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
+ VERIFY_GROUPS;
+ } {
+ QQuickItem *delegate = findItem<QQuickItem>(contentItem, "delegate", 5);
+ QVERIFY(delegate);
+
+ evaluate<void>(delegate, "select()");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 8);
+ QCOMPARE(selectedItems->count(), 3);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 };
+ static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 3, 3 };
+ static const bool sMember[] = { f, f, f, f, f, t, f, f, t, t, f, f };
+ VERIFY_GROUPS;
+ } {
+ evaluate<void>(visualModel, "items.move(2, 6, 3)");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 8);
+ QCOMPARE(selectedItems->count(), 3);
+ static const int mIndex [] = { 0, 1, 5, 6, 7, 8, 2, 3, 4, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 2, 2, 3, 3, 4, 5, 6, 7 };
+ static const bool vMember[] = { t, t, f, f, f, t, f, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3 };
+ static const bool sMember[] = { f, f, t, f, f, t, f, f, f, t, f, f };
+ VERIFY_GROUPS;
+ }
+}
+
+template <int N> void tst_qquickvisualdatamodel::get_verify(
+ const SingleRoleModel &model,
+ QQuickVisualDataModel *visualModel,
+ QQuickVisualDataGroup *visibleItems,
+ QQuickVisualDataGroup *selectedItems,
+ const int (&mIndex)[N],
+ const int (&iIndex)[N],
+ const int (&vIndex)[N],
+ const int (&sIndex)[N],
+ const bool (&vMember)[N],
+ const bool (&sMember)[N])
+{
+ failed = true;
+ for (int i = 0; i < N; ++i) {
+ QCOMPARE(evaluate<QString>(visualModel, QString("items.get(%1).model.name").arg(i)), model.list.at(mIndex[i]));
+ QCOMPARE(evaluate<QString>(visualModel, QString("items.get(%1).model.modelData").arg(i)), model.list.at(mIndex[i]));
+ QCOMPARE(evaluate<int>(visualModel, QString("items.get(%1).model.index").arg(i)), mIndex[i]);
+ QCOMPARE(evaluate<int>(visualModel, QString("items.get(%1).itemsIndex").arg(i)), iIndex[i]);
+ QCOMPARE(evaluate<bool>(visualModel, QString("items.get(%1).inItems").arg(i)), true);
+ QCOMPARE(evaluate<int>(visualModel, QString("items.get(%1).visibleIndex").arg(i)), vIndex[i]);
+ QCOMPARE(evaluate<bool>(visualModel, QString("items.get(%1).inVisible").arg(i)), vMember[i]);
+ QCOMPARE(evaluate<int>(visualModel, QString("items.get(%1).selectedIndex").arg(i)), sIndex[i]);
+ QCOMPARE(evaluate<bool>(visualModel, QString("items.get(%1).inSelected").arg(i)), sMember[i]);
+ QCOMPARE(evaluate<bool>(visualModel, QString("contains(items.get(%1).groups, \"items\")").arg(i)), true);
+ QCOMPARE(evaluate<bool>(visualModel, QString("contains(items.get(%1).groups, \"visible\")").arg(i)), vMember[i]);
+ QCOMPARE(evaluate<bool>(visualModel, QString("contains(items.get(%1).groups, \"selected\")").arg(i)), sMember[i]);
+
+ if (vMember[i]) {
+ QCOMPARE(evaluate<QString>(visibleItems, QString("get(%1).model.name").arg(vIndex[i])), model.list.at(mIndex[i]));
+ QCOMPARE(evaluate<QString>(visibleItems, QString("get(%1).model.modelData").arg(vIndex[i])), model.list.at(mIndex[i]));
+ QCOMPARE(evaluate<int>(visibleItems, QString("get(%1).model.index").arg(vIndex[i])), mIndex[i]);
+ QCOMPARE(evaluate<int>(visibleItems, QString("get(%1).itemsIndex").arg(vIndex[i])), iIndex[i]);
+ QCOMPARE(evaluate<bool>(visibleItems, QString("get(%1).inItems").arg(vIndex[i])), true);
+ QCOMPARE(evaluate<int>(visibleItems, QString("get(%1).visibleIndex").arg(vIndex[i])), vIndex[i]);
+ QCOMPARE(evaluate<bool>(visibleItems, QString("get(%1).inVisible").arg(vIndex[i])), vMember[i]);
+ QCOMPARE(evaluate<int>(visibleItems, QString("get(%1).selectedIndex").arg(vIndex[i])), sIndex[i]);
+ QCOMPARE(evaluate<bool>(visibleItems, QString("get(%1).inSelected").arg(vIndex[i])), sMember[i]);
+
+ QCOMPARE(evaluate<bool>(visibleItems, QString("contains(get(%1).groups, \"items\")").arg(vIndex[i])), true);
+ QCOMPARE(evaluate<bool>(visibleItems, QString("contains(get(%1).groups, \"visible\")").arg(vIndex[i])), vMember[i]);
+ QCOMPARE(evaluate<bool>(visibleItems, QString("contains(get(%1).groups, \"selected\")").arg(vIndex[i])), sMember[i]);
+ }
+ if (sMember[i]) {
+ QCOMPARE(evaluate<QString>(selectedItems, QString("get(%1).model.name").arg(sIndex[i])), model.list.at(mIndex[i]));
+ QCOMPARE(evaluate<QString>(selectedItems, QString("get(%1).model.modelData").arg(sIndex[i])), model.list.at(mIndex[i]));
+ QCOMPARE(evaluate<int>(selectedItems, QString("get(%1).model.index").arg(sIndex[i])), mIndex[i]);
+ QCOMPARE(evaluate<int>(selectedItems, QString("get(%1).itemsIndex").arg(sIndex[i])), iIndex[i]);
+ QCOMPARE(evaluate<bool>(selectedItems, QString("get(%1).inItems").arg(sIndex[i])), true);
+ QCOMPARE(evaluate<int>(selectedItems, QString("get(%1).visibleIndex").arg(sIndex[i])), vIndex[i]);
+ QCOMPARE(evaluate<bool>(selectedItems, QString("get(%1).inVisible").arg(sIndex[i])), vMember[i]);
+ QCOMPARE(evaluate<int>(selectedItems, QString("get(%1).selectedIndex").arg(sIndex[i])), sIndex[i]);
+ QCOMPARE(evaluate<bool>(selectedItems, QString("get(%1).inSelected").arg(sIndex[i])), sMember[i]);
+ QCOMPARE(evaluate<bool>(selectedItems, QString("contains(get(%1).groups, \"items\")").arg(sIndex[i])), true);
+ QCOMPARE(evaluate<bool>(selectedItems, QString("contains(get(%1).groups, \"visible\")").arg(sIndex[i])), vMember[i]);
+ QCOMPARE(evaluate<bool>(selectedItems, QString("contains(get(%1).groups, \"selected\")").arg(sIndex[i])), sMember[i]);
+ }
+ }
+ failed = false;
+}
+
+#define VERIFY_GET \
+ get_verify(model, visualModel, visibleItems, selectedItems, mIndex, iIndex, vIndex, sIndex, vMember, sMember); \
+ QVERIFY(!failed)
+
+void tst_qquickvisualdatamodel::get()
+{
+ QQuickView view;
+
+ SingleRoleModel model;
+ model.list = QStringList()
+ << "one"
+ << "two"
+ << "three"
+ << "four"
+ << "five"
+ << "six"
+ << "seven"
+ << "eight"
+ << "nine"
+ << "ten"
+ << "eleven"
+ << "twelve";
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(testFileUrl("groups.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
+ QVERIFY(visualModel);
+
+ QQuickVisualDataGroup *visibleItems = visualModel->findChild<QQuickVisualDataGroup *>("visibleItems");
+ QVERIFY(visibleItems);
+
+ QQuickVisualDataGroup *selectedItems = visualModel->findChild<QQuickVisualDataGroup *>("selectedItems");
+ QVERIFY(selectedItems);
+
+ QV8Engine *v8Engine = QQmlEnginePrivate::getV8Engine(ctxt->engine());
+ QVERIFY(v8Engine);
+
+ const bool f = false;
+ const bool t = true;
+
+ {
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 12);
+ QCOMPARE(selectedItems->count(), 0);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, f, f, f, f };
+ VERIFY_GET;
+ } {
+ evaluate<void>(visualModel, "items.addGroups(8, \"selected\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 12);
+ QCOMPARE(selectedItems->count(), 1);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, t, f, f, f };
+ VERIFY_GET;
+ } {
+ evaluate<void>(visualModel, "items.addGroups(6, 4, [\"visible\", \"selected\"])");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 12);
+ QCOMPARE(selectedItems->count(), 4);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const bool vMember[] = { t, t, t, t, t, t, t, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4 };
+ static const bool sMember[] = { f, f, f, f, f, f, t, t, t, t, f, f };
+ VERIFY_GET;
+ } {
+ evaluate<void>(visualModel, "items.setGroups(2, [\"items\", \"selected\"])");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 11);
+ QCOMPARE(selectedItems->count(), 5);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9,10 };
+ static const bool vMember[] = { t, t, f, t, t, t, t, t, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 1, 1, 1, 1, 2, 3, 4, 5, 5 };
+ static const bool sMember[] = { f, f, t, f, f, f, t, t, t, t, f, f };
+ VERIFY_GET;
+ } {
+ evaluate<void>(selectedItems, "setGroups(0, 3, \"items\")");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 };
+ static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
+ VERIFY_GET;
+ } {
+ evaluate<void>(visualModel, "items.get(5).inVisible = false");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 8);
+ QCOMPARE(selectedItems->count(), 2);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 };
+ static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
+ VERIFY_GET;
+ } {
+ evaluate<void>(visualModel, "items.get(5).inSelected = true");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 8);
+ QCOMPARE(selectedItems->count(), 3);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 6, 7 };
+ static const bool vMember[] = { t, t, f, t, t, f, f, f, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 3, 3 };
+ static const bool sMember[] = { f, f, f, f, f, t, f, f, t, t, f, f };
+ VERIFY_GET;
+ } {
+ evaluate<void>(visualModel, "items.get(5).groups = [\"visible\", \"items\"]");
+ QCOMPARE(listview->count(), 12);
+ QCOMPARE(visualModel->items()->count(), 12);
+ QCOMPARE(visibleItems->count(), 9);
+ QCOMPARE(selectedItems->count(), 2);
+ static const int mIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int iIndex [] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 };
+ static const int vIndex [] = { 0, 1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8 };
+ static const bool vMember[] = { t, t, f, t, t, t, f, f, t, t, t, t };
+ static const int sIndex [] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2 };
+ static const bool sMember[] = { f, f, f, f, f, f, f, f, t, t, f, f };
+ VERIFY_GET;
+ }
+}
+
+void tst_qquickvisualdatamodel::invalidGroups()
+{
+ QUrl source = testFileUrl("groups-invalid.qml");
+ QTest::ignoreMessage(QtWarningMsg, (source.toString() + ":12:9: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("Group names must start with a lower case letter")).toUtf8());
+
+ QQmlComponent component(&engine, source);
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object);
+
+ QCOMPARE(evaluate<int>(object.data(), "groups.length"), 4);
+ QCOMPARE(evaluate<QString>(object.data(), "groups[0].name"), QString("items"));
+ QCOMPARE(evaluate<QString>(object.data(), "groups[1].name"), QString("persistedItems"));
+ QCOMPARE(evaluate<QString>(object.data(), "groups[2].name"), QString("visible"));
+ QCOMPARE(evaluate<QString>(object.data(), "groups[3].name"), QString("selected"));
+}
+
+void tst_qquickvisualdatamodel::onChanged_data()
+{
+ QTest::addColumn<QString>("expression");
+ QTest::addColumn<QStringList>("tests");
+
+ QTest::newRow("item appended")
+ << QString("listModel.append({\"number\": \"five\"})")
+ << (QStringList()
+ << "verify(vm.removed, [], [], [])"
+ << "verify(vm.inserted, [4], [1], [undefined])"
+ << "verify(vi.removed, [], [], [])"
+ << "verify(vi.inserted, [4], [1], [undefined])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+ QTest::newRow("item prepended")
+ << QString("listModel.insert(0, {\"number\": \"five\"})")
+ << (QStringList()
+ << "verify(vm.removed, [], [], [])"
+ << "verify(vm.inserted, [0], [1], [undefined])"
+ << "verify(vi.removed, [], [], [])"
+ << "verify(vi.inserted, [0], [1], [undefined])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+ QTest::newRow("item inserted")
+ << QString("listModel.insert(2, {\"number\": \"five\"})")
+ << (QStringList()
+ << "verify(vm.removed, [], [], [])"
+ << "verify(vm.inserted, [2], [1], [undefined])"
+ << "verify(vi.removed, [], [], [])"
+ << "verify(vi.inserted, [2], [1], [undefined])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+
+ QTest::newRow("item removed tail")
+ << QString("listModel.remove(3)")
+ << (QStringList()
+ << "verify(vm.removed, [3], [1], [undefined])"
+ << "verify(vm.inserted, [], [], [])"
+ << "verify(vi.removed, [3], [1], [undefined])"
+ << "verify(vi.inserted, [], [], [])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+ QTest::newRow("item removed head")
+ << QString("listModel.remove(0)")
+ << (QStringList()
+ << "verify(vm.removed, [0], [1], [undefined])"
+ << "verify(vm.inserted, [], [], [])"
+ << "verify(vi.removed, [0], [1], [undefined])"
+ << "verify(vi.inserted, [], [], [])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+ QTest::newRow("item removed middle")
+ << QString("listModel.remove(1)")
+ << (QStringList()
+ << "verify(vm.removed, [1], [1], [undefined])"
+ << "verify(vm.inserted, [], [], [])"
+ << "verify(vi.removed, [1], [1], [undefined])"
+ << "verify(vi.inserted, [], [], [])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+
+
+ QTest::newRow("item moved from tail")
+ << QString("listModel.move(3, 0, 1)")
+ << (QStringList()
+ << "verify(vm.removed, [3], [1], [vm.inserted[0].moveId])"
+ << "verify(vm.inserted, [0], [1], [vm.removed[0].moveId])"
+ << "verify(vi.removed, [3], [1], [vi.inserted[0].moveId])"
+ << "verify(vi.inserted, [0], [1], [vi.removed[0].moveId])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+ QTest::newRow("item moved from head")
+ << QString("listModel.move(0, 2, 2)")
+ << (QStringList()
+ << "verify(vm.removed, [0], [2], [vm.inserted[0].moveId])"
+ << "verify(vm.inserted, [2], [2], [vm.removed[0].moveId])"
+ << "verify(vi.removed, [0], [2], [vi.inserted[0].moveId])"
+ << "verify(vi.inserted, [2], [2], [vi.removed[0].moveId])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+
+ QTest::newRow("groups changed")
+ << QString("items.setGroups(1, 2, [\"items\", \"selected\"])")
+ << (QStringList()
+ << "verify(vm.inserted, [], [], [])"
+ << "verify(vm.removed, [], [], [])"
+ << "verify(vi.removed, [1], [2], [undefined])"
+ << "verify(vi.inserted, [], [], [])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [0], [2], [undefined])");
+
+ QTest::newRow("multiple removes")
+ << QString("{ vi.remove(1, 1); "
+ "vi.removeGroups(0, 2, \"items\") }")
+ << (QStringList()
+ << "verify(vm.removed, [0, 1], [1, 1], [undefined, undefined])"
+ << "verify(vm.inserted, [], [], [])"
+ << "verify(vi.removed, [1], [1], [undefined])"
+ << "verify(vi.inserted, [], [], [])"
+ << "verify(si.removed, [], [], [])"
+ << "verify(si.inserted, [], [], [])");
+}
+
+void tst_qquickvisualdatamodel::onChanged()
+{
+ QFETCH(QString, expression);
+ QFETCH(QStringList, tests);
+
+ QQmlComponent component(&engine, testFileUrl("onChanged.qml"));
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object);
+
+ evaluate<void>(object.data(), expression);
+
+ foreach (const QString &test, tests) {
+ bool passed = evaluate<bool>(object.data(), test);
+ if (!passed)
+ qWarning() << test;
+ QVERIFY(passed);
+ }
+}
+
+void tst_qquickvisualdatamodel::create()
+{
+ QQuickView view;
+
+ SingleRoleModel model;
+ model.list = QStringList()
+ << "one"
+ << "two"
+ << "three"
+ << "four"
+ << "five"
+ << "six"
+ << "seven"
+ << "eight"
+ << "nine"
+ << "ten"
+ << "eleven"
+ << "twelve"
+ << "thirteen"
+ << "fourteen"
+ << "fifteen"
+ << "sixteen"
+ << "seventeen"
+ << "eighteen"
+ << "nineteen"
+ << "twenty";
+
+ QQmlContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("myModel", &model);
+
+ view.setSource(testFileUrl("create.qml"));
+
+ QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
+ QVERIFY(listview != 0);
+
+ QQuickItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
+
+ QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel *>(qvariant_cast<QObject *>(listview->model()));
+ QVERIFY(visualModel);
+
+ QCOMPARE(listview->count(), 20);
+
+ QQmlGuard<QQuickItem> delegate;
+
+ // persistedItems.includeByDefault is true, so all items belong to persistedItems initially.
+ QVERIFY(delegate = findItem<QQuickItem>(contentItem, "delegate", 1));
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
+
+ // changing include by default doesn't remove persistance.
+ evaluate<void>(visualModel, "persistedItems.includeByDefault = false");
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
+
+ // removing from persistedItems does.
+ evaluate<void>(visualModel, "persistedItems.remove(0, 20)");
+ QCOMPARE(listview->count(), 20);
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), false);
+
+ // Request an item instantiated by the view.
+ QVERIFY(delegate = qobject_cast<QQuickItem *>(evaluate<QObject *>(visualModel, "items.create(1)")));
+ QCOMPARE(delegate.data(), findItem<QQuickItem>(contentItem, "delegate", 1));
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
+
+ evaluate<void>(delegate, "VisualDataModel.inPersistedItems = false");
+ QCOMPARE(listview->count(), 20);
+ QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
+ QVERIFY(delegate);
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), false);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 0);
+
+ // Request an item not instantiated by the view.
+ QVERIFY(!findItem<QQuickItem>(contentItem, "delegate", 15));
+ QVERIFY(delegate = qobject_cast<QQuickItem *>(evaluate<QObject *>(visualModel, "items.create(15)")));
+ QCOMPARE(delegate.data(), findItem<QQuickItem>(contentItem, "delegate", 15));
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
+
+ evaluate<void>(visualModel, "persistedItems.remove(0)");
+ QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
+ QVERIFY(!delegate);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 0);
+
+ // Request an item not instantiated by the view, then scroll the view so it will request it.
+ QVERIFY(!findItem<QQuickItem>(contentItem, "delegate", 16));
+ QVERIFY(delegate = qobject_cast<QQuickItem *>(evaluate<QObject *>(visualModel, "items.create(16)")));
+ QCOMPARE(delegate.data(), findItem<QQuickItem>(contentItem, "delegate", 16));
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
+
+ evaluate<void>(listview, "positionViewAtIndex(19, ListView.End)");
+ QCOMPARE(listview->count(), 20);
+ evaluate<void>(delegate, "VisualDataModel.groups = [\"items\"]");
+ QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
+ QVERIFY(delegate);
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), false);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 0);
+
+ // Request and release an item instantiated by the view, then scroll the view so it releases it.
+ QVERIFY(findItem<QQuickItem>(contentItem, "delegate", 17));
+ QVERIFY(delegate = qobject_cast<QQuickItem *>(evaluate<QObject *>(visualModel, "items.create(17)")));
+ QCOMPARE(delegate.data(), findItem<QQuickItem>(contentItem, "delegate", 17));
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
+
+ evaluate<void>(visualModel, "items.removeGroups(17, \"persistedItems\")");
+ QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
+ QVERIFY(delegate);
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), false);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 0);
+ evaluate<void>(listview, "positionViewAtIndex(1, ListView.Beginning)");
+ QCOMPARE(listview->count(), 20);
+ QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
+ QVERIFY(!delegate);
+
+ // Adding an item to the persistedItems group won't instantiate it, but if later requested by
+ // the view it will be persisted.
+ evaluate<void>(visualModel, "items.addGroups(18, \"persistedItems\")");
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 1);
+ QVERIFY(!findItem<QQuickItem>(contentItem, "delegate", 18));
+ evaluate<void>(listview, "positionViewAtIndex(19, ListView.End)");
+ QCOMPARE(listview->count(), 20);
+ QVERIFY(delegate = findItem<QQuickItem>(contentItem, "delegate", 18));
+ QCOMPARE(evaluate<bool>(delegate, "VisualDataModel.inPersistedItems"), true);
+ QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
+ QVERIFY(delegate);
+ evaluate<void>(listview, "positionViewAtIndex(1, ListView.Beginning)");
+ QCOMPARE(listview->count(), 20);
+ QCoreApplication::sendPostedEvents(delegate, QEvent::DeferredDelete);
+ QVERIFY(delegate);
+
+ // Remove an uninstantiated but cached item from the persistedItems group.
+ evaluate<void>(visualModel, "items.addGroups(19, \"persistedItems\")");
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), 2);
+ QVERIFY(!findItem<QQuickItem>(contentItem, "delegate", 19));
+ // Store a reference to the item so it is retained in the cache.
+ evaluate<void>(visualModel, "persistentHandle = items.get(19)");
+ QCOMPARE(evaluate<bool>(visualModel, "persistentHandle.inPersistedItems"), true);
+ evaluate<void>(visualModel, "items.removeGroups(19, \"persistedItems\")");
+ QCOMPARE(evaluate<bool>(visualModel, "persistentHandle.inPersistedItems"), false);
+}
+
+void tst_qquickvisualdatamodel::incompleteModel()
+{
+ // VisualDataModel is first populated in componentComplete. Verify various functions are
+ // harmlessly ignored until then.
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\n VisualDataModel {}", testFileUrl(""));
+
+ QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
+
+ QQuickVisualDataModel *model = qobject_cast<QQuickVisualDataModel *>(object.data());
+ QVERIFY(model);
+
+ QSignalSpy itemsSpy(model->items(), SIGNAL(countChanged()));
+ QSignalSpy persistedItemsSpy(model->items(), SIGNAL(countChanged()));
+
+ evaluate<void>(model, "items.removeGroups(0, items.count, \"items\")");
+ QCOMPARE(itemsSpy.count(), 0);
+ QCOMPARE(persistedItemsSpy.count(), 0);
+
+ evaluate<void>(model, "items.setGroups(0, items.count, \"persistedItems\")");
+ QCOMPARE(itemsSpy.count(), 0);
+ QCOMPARE(persistedItemsSpy.count(), 0);
+
+ evaluate<void>(model, "items.addGroups(0, items.count, \"persistedItems\")");
+ QCOMPARE(itemsSpy.count(), 0);
+ QCOMPARE(persistedItemsSpy.count(), 0);
+
+ evaluate<void>(model, "items.remove(0, items.count)");
+ QCOMPARE(itemsSpy.count(), 0);
+ QCOMPARE(persistedItemsSpy.count(), 0);
+
+ evaluate<void>(model, "items.insert([ \"color\": \"blue\" ])");
+ QCOMPARE(itemsSpy.count(), 0);
+ QCOMPARE(persistedItemsSpy.count(), 0);
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML VisualDataGroup: get: index out of range");
+ QVERIFY(evaluate<bool>(model, "items.get(0) === undefined"));
+
+ component.completeCreate();
+}
+
+void tst_qquickvisualdatamodel::insert_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::addColumn<QString>("expression");
+ QTest::addColumn<int>("modelCount");
+ QTest::addColumn<int>("visualCount");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<bool>("inItems");
+ QTest::addColumn<bool>("persisted");
+ QTest::addColumn<bool>("visible");
+ QTest::addColumn<bool>("selected");
+ QTest::addColumn<bool>("modelData");
+ QTest::addColumn<QString>("property");
+ QTest::addColumn<QStringList>("propertyData");
+
+ const QUrl listModelSource[] = {
+ testFileUrl("listmodelproperties.qml"),
+ testFileUrl("listmodelproperties-package.qml") };
+ const QUrl singleRoleSource[] = {
+ testFileUrl("singleroleproperties.qml"),
+ testFileUrl("singleroleproperties-package.qml") };
+ const QUrl multipleRoleSource[] = {
+ testFileUrl("multipleroleproperties.qml"),
+ testFileUrl("multipleroleproperties-package.qml") };
+ const QUrl stringListSource[] = {
+ testFileUrl("stringlistproperties.qml"),
+ testFileUrl("stringlistproperties-package.qml") };
+ const QUrl objectListSource[] = {
+ testFileUrl("objectlistproperties.qml"),
+ testFileUrl("objectlistproperties-package.qml") };
+
+ for (int i = 0; i < 2; ++i) {
+ // List Model.
+ QTest::newRow("ListModel.items prepend")
+ << listModelSource[i]
+ << QString("items.insert(0, {\"number\": \"eight\"})")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items append")
+ << listModelSource[i]
+ << QString("items.insert({\"number\": \"eight\"})")
+ << 4 << 5 << 4 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "eight");
+
+ QTest::newRow("ListModel.items insert at 2")
+ << listModelSource[i]
+ << QString("items.insert(2, {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items insert at items.get(2)")
+ << listModelSource[i]
+ << QString("items.insert(items.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items insert at visibleItems.get(2)")
+ << listModelSource[i]
+ << QString("items.insert(visibleItems.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.selectedItems insert at items.get(2)")
+ << listModelSource[i]
+ << QString("selectedItems.insert(items.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << false << false << false << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.selectedItems insert at visibleItems.get(2)")
+ << listModelSource[i]
+ << QString("selectedItems.insert(visibleItems.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << false << false << false << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items prepend modelData")
+ << listModelSource[i]
+ << QString("items.insert(0, {\"modelData\": \"eight\"})")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items prepend, edit number")
+ << listModelSource[i]
+ << QString("{ "
+ "items.insert(0, {\"number\": \"eight\"}); "
+ "items.get(0).model.number = \"seven\"; }")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items prepend, edit modelData")
+ << listModelSource[i]
+ << QString("{ "
+ "items.insert(0, {\"number\": \"eight\"}); "
+ "items.get(0).model.modelData = \"seven\"; }")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items prepend, edit resolved")
+ << listModelSource[i]
+ << QString("{ "
+ "items.insert(0, {\"number\": \"eight\"}); "
+ "items.get(2).model.number = \"seven\"; }")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items prepend with groups")
+ << listModelSource[i]
+ << QString("items.insert(0, {\"number\": \"eight\"}, [\"visible\", \"truncheon\"])")
+ << 4 << 5 << 0 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items append with groups")
+ << listModelSource[i]
+ << QString("items.insert({\"number\": \"eight\"}, [\"visible\", \"selected\"])")
+ << 4 << 5 << 4 << true << false << true << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "eight");
+
+ QTest::newRow("ListModel.items insert at 2 with groups")
+ << listModelSource[i]
+ << QString("items.insert(2, {\"number\": \"eight\"}, \"visible\")")
+ << 4 << 5 << 2 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ // create ListModel
+ QTest::newRow("ListModel.items prepend")
+ << listModelSource[i]
+ << QString("items.create(0, {\"number\": \"eight\"})")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items append")
+ << listModelSource[i]
+ << QString("items.create({\"number\": \"eight\"})")
+ << 4 << 5 << 4 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "eight");
+
+ QTest::newRow("ListModel.items create at 2")
+ << listModelSource[i]
+ << QString("items.create(2, {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items create at items.get(2)")
+ << listModelSource[i]
+ << QString("items.create(items.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items create at visibleItems.get(2)")
+ << listModelSource[i]
+ << QString("items.create(visibleItems.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.selectedItems create at items.get(2)")
+ << listModelSource[i]
+ << QString("selectedItems.create(items.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << false << true << false << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.selectedItems create at visibleItems.get(2)")
+ << listModelSource[i]
+ << QString("selectedItems.create(visibleItems.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << false << true << false << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items create prepended")
+ << listModelSource[i]
+ << QString("items.create(0, {\"number\": \"eight\"})")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items create appended")
+ << listModelSource[i]
+ << QString("items.create({\"number\": \"eight\"})")
+ << 4 << 5 << 4 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "eight");
+
+ QTest::newRow("ListModel.items create at 2")
+ << listModelSource[i]
+ << QString("items.create(2, {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items create at items.get(2)")
+ << listModelSource[i]
+ << QString("items.create(items.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items create at visibleItems.get(2)")
+ << listModelSource[i]
+ << QString("items.create(visibleItems.get(2), {\"number\": \"eight\"})")
+ << 4 << 5 << 2 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.create prepend modelData")
+ << listModelSource[i]
+ << QString("items.create(0, {\"modelData\": \"eight\"})")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items create prepended, edit number")
+ << listModelSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"number\": \"eight\"}); "
+ "item.setTest3(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items create prepended, edit model.number")
+ << listModelSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"number\": \"eight\"}); "
+ "item.setTest4(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items create prepended, edit modelData")
+ << listModelSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"number\": \"eight\"}); "
+ "item.setTest5(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items create prepended, edit model.modelData")
+ << listModelSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"number\": \"eight\"}); "
+ "item.setTest6(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items create prepended with groups")
+ << listModelSource[i]
+ << QString("items.create(0, {\"number\": \"eight\"}, [\"visible\", \"truncheon\"])")
+ << 4 << 5 << 0 << true << true << true << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items create appended with groups")
+ << listModelSource[i]
+ << QString("items.create({\"number\": \"eight\"}, [\"visible\", \"selected\"])")
+ << 4 << 5 << 4 << true << true << true << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "eight");
+
+ QTest::newRow("ListModel.items create inserted with groups")
+ << listModelSource[i]
+ << QString("items.create(2, {\"number\": \"eight\"}, \"visible\")")
+ << 4 << 5 << 2 << true << true << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("ListModel.items create prepended clear persistence")
+ << listModelSource[i]
+ << QString("{ items.create(0, {\"number\": \"eight\"}); "
+ "items.get(0).inPersistedItems = false }")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items create appended clear persistence")
+ << listModelSource[i]
+ << QString("{ items.create({\"number\": \"eight\"}); "
+ "items.get(4).inPersistedItems = false }")
+ << 4 << 5 << 4 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "eight");
+
+ QTest::newRow("ListModel.items create inserted clear persistence")
+ << listModelSource[i]
+ << QString("{ items.create(2, {\"number\": \"eight\"}); "
+ "items.get(2).inPersistedItems = false }")
+ << 4 << 5 << 2 << true << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ // AbstractItemModel (Single Role).
+ QTest::newRow("AbstractItemModel.items prepend")
+ << singleRoleSource[i]
+ << QString("items.insert(0, {\"name\": \"eight\"})")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("name")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items append")
+ << singleRoleSource[i]
+ << QString("items.insert({\"name\": \"eight\"})")
+ << 4 << 5 << 4 << true << false << false << false << true
+ << QString("name")
+ << (QStringList() << "one" << "two" << "three" << "four" << "eight");
+
+ QTest::newRow("AbstractItemModel.items insert at 2")
+ << singleRoleSource[i]
+ << QString("items.insert(2, {\"name\": \"eight\"})")
+ << 4 << 5 << 2 << true << false << false << false << true
+ << QString("name")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items prepend modelData")
+ << singleRoleSource[i]
+ << QString("items.insert(0, {\"modelData\": \"eight\"})")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("name")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items prepend, edit name")
+ << singleRoleSource[i]
+ << QString("{ "
+ "items.insert(0, {\"name\": \"eight\"}); "
+ "items.get(0).model.name = \"seven\"; }")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("name")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items prepend, edit modelData")
+ << singleRoleSource[i]
+ << QString("{ "
+ "items.insert(0, {\"name\": \"eight\"}); "
+ "items.get(0).model.modelData = \"seven\"; }")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("name")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items prepend, edit resolved")
+ << singleRoleSource[i]
+ << QString("{ "
+ "items.insert(0, {\"name\": \"eight\"}); "
+ "items.get(2).model.name = \"seven\"; }")
+ << 4 << 5 << 0 << true << false << false << false << true
+ << QString("name")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.create prepend modelData")
+ << singleRoleSource[i]
+ << QString("items.create(0, {\"modelData\": \"eight\"})")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("name")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items create prepended, edit name")
+ << singleRoleSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"name\": \"eight\"}); "
+ "item.setTest3(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("name")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items create prepended, edit model.name")
+ << singleRoleSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"name\": \"eight\"}); "
+ "item.setTest4(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("name")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items create prepended, edit modelData")
+ << singleRoleSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"name\": \"eight\"}); "
+ "item.setTest5(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("name")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items create prepended, edit model.modelData")
+ << singleRoleSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"name\": \"eight\"}); "
+ "item.setTest6(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << true
+ << QString("name")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ // AbstractItemModel (Multiple Roles).
+ QTest::newRow("StandardItemModel.items prepend")
+ << multipleRoleSource[i]
+ << QString("items.insert(0, {\"display\": \"Row 8 Item\"})")
+ << 4 << 5 << 0 << true << false << false << false << false
+ << QString("display")
+ << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items append")
+ << multipleRoleSource[i]
+ << QString("items.insert({\"display\": \"Row 8 Item\"})")
+ << 4 << 5 << 4 << true << false << false << false << false
+ << QString("display")
+ << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item" << "Row 8 Item");
+
+ QTest::newRow("StandardItemModel.items insert at 2")
+ << multipleRoleSource[i]
+ << QString("items.insert(2, {\"display\": \"Row 8 Item\"})")
+ << 4 << 5 << 2 << true << false << false << false << false
+ << QString("display")
+ << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 8 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items prepend modelData")
+ << multipleRoleSource[i]
+ << QString("items.insert(0, {\"modelData\": \"Row 8 Item\"})")
+ << 4 << 5 << 0 << true << false << false << false << false
+ << QString("display")
+ << (QStringList() << QString() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items prepend, edit display")
+ << multipleRoleSource[i]
+ << QString("{ "
+ "items.insert(0, {\"display\": \"Row 8 Item\"}); "
+ "items.get(0).model.display = \"Row 7 Item\"; }")
+ << 4 << 5 << 0 << true << false << false << false << false
+ << QString("display")
+ << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items prepend, edit modelData")
+ << multipleRoleSource[i]
+ << QString("{ "
+ "items.insert(0, {\"display\": \"Row 8 Item\"}); "
+ "items.get(0).model.modelData = \"Row 7 Item\"; }")
+ << 4 << 5 << 0 << true << false << false << false << false
+ << QString("display")
+ << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items prepend, edit resolved")
+ << multipleRoleSource[i]
+ << QString("{ "
+ "items.insert(0, {\"display\": \"Row 8 Item\"}); "
+ "items.get(2).model.display = \"Row 7 Item\"; }")
+ << 4 << 5 << 0 << true << false << false << false << false
+ << QString("display")
+ << (QStringList() << "Row 8 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.create prepend modelData")
+ << multipleRoleSource[i]
+ << QString("items.create(0, {\"modelData\": \"Row 8 Item\"})")
+ << 4 << 5 << 0 << true << true << false << false << false
+ << QString("display")
+ << (QStringList() << QString() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items create prepended, edit display")
+ << multipleRoleSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"display\": \"Row 8 Item\"}); "
+ "item.setTest3(\"Row 7 Item\"); }")
+ << 4 << 5 << 0 << true << true << false << false << false
+ << QString("display")
+ << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items create prepended, edit model.display")
+ << multipleRoleSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"display\": \"Row 8 Item\"}); "
+ "item.setTest4(\"Row 7 Item\"); }")
+ << 4 << 5 << 0 << true << true << false << false << false
+ << QString("display")
+ << (QStringList() << "Row 7 Item" << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ // StringList.
+ QTest::newRow("StringList.items prepend")
+ << stringListSource[i]
+ << QString("items.insert(0, {\"modelData\": \"eight\"})")
+ << 4 << 5 << 0 << true << false << false << false << false
+ << QString("modelData")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("StringList.items append")
+ << stringListSource[i]
+ << QString("items.insert({\"modelData\": \"eight\"})")
+ << 4 << 5 << 4 << true << false << false << false << false
+ << QString("modelData")
+ << (QStringList() << "one" << "two" << "three" << "four" << "eight");
+
+ QTest::newRow("StringList.items insert at 2")
+ << stringListSource[i]
+ << QString("items.insert(2, {\"modelData\": \"eight\"})")
+ << 4 << 5 << 2 << true << false << false << false << false
+ << QString("modelData")
+ << (QStringList() << "one" << "two" << "eight" << "three" << "four");
+
+ QTest::newRow("StringList.items prepend, edit modelData")
+ << stringListSource[i]
+ << QString("{ "
+ "items.insert(0, {\"modelData\": \"eight\"}); "
+ "items.get(0).model.modelData = \"seven\"; }")
+ << 4 << 5 << 0 << true << false << false << false << false
+ << QString("modelData")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("StringList.items prepend, edit resolved")
+ << stringListSource[i]
+ << QString("{ "
+ "items.insert(0, {\"modelData\": \"eight\"}); "
+ "items.get(2).model.modelData = \"seven\"; }")
+ << 4 << 5 << 0 << true << false << false << false << false
+ << QString("modelData")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("StringList.create prepend modelData")
+ << stringListSource[i]
+ << QString("items.create(0, {\"modelData\": \"eight\"})")
+ << 4 << 5 << 0 << true << true << false << false << false
+ << QString("modelData")
+ << (QStringList() << "eight" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("StringList.items create prepended, edit modelData")
+ << stringListSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"modelData\": \"eight\"}); "
+ "item.setTest3(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << false
+ << QString("modelData")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("StringList.items create prepended, edit model.modelData")
+ << stringListSource[i]
+ << QString("{ "
+ "var item = items.create(0, {\"modelData\": \"eight\"}); "
+ "item.setTest4(\"seven\"); }")
+ << 4 << 5 << 0 << true << true << false << false << false
+ << QString("modelData")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ // ObjectList
+ QTest::newRow("ObjectList.items prepend")
+ << objectListSource[i]
+ << QString("items.insert(0, {\"name\": \"Item 8\"})")
+ << 4 << 4 << 4 << false << false << false << false << false
+ << QString("name")
+ << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4");
+
+ QTest::newRow("ObjectList.items append")
+ << objectListSource[i]
+ << QString("items.insert({\"name\": \"Item 8\"})")
+ << 4 << 4 << 4 << false << false << false << false << false
+ << QString("name")
+ << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4");
+
+ QTest::newRow("ObjectList.items insert at 2")
+ << objectListSource[i]
+ << QString("items.insert(2, {\"name\": \"Item 8\"})")
+ << 4 << 4 << 4 << false << false << false << false << false
+ << QString("name")
+ << (QStringList() << "Item 1" << "Item 2" << "Item 3" << "Item 4");
+ }
+}
+
+void tst_qquickvisualdatamodel::insert()
+{
+ QFETCH(QUrl, source);
+ QFETCH(QString, expression);
+ QFETCH(int, modelCount);
+ QFETCH(int, visualCount);
+ QFETCH(int, index);
+ QFETCH(bool, inItems);
+ QFETCH(bool, persisted);
+ QFETCH(bool, visible);
+ QFETCH(bool, selected);
+ QFETCH(bool, modelData);
+ QFETCH(QString, property);
+ QFETCH(QStringList, propertyData);
+
+ QQuickCanvas canvas;
+
+ QQmlComponent component(&engine);
+ component.loadUrl(source);
+ QScopedPointer<QObject> object(component.create());
+ QQuickListView *listView = qobject_cast<QQuickListView *>(object.data());
+ QVERIFY(listView);
+ listView->setParentItem(canvas.rootItem());
+
+ QQuickItem *contentItem = listView->contentItem();
+ QVERIFY(contentItem);
+
+ QObject *visualModel = listView->findChild<QObject *>("visualModel");
+ QVERIFY(visualModel);
+
+ evaluate<void>(visualModel, expression);
+
+ QCOMPARE(evaluate<int>(listView, "count"), inItems ? visualCount : modelCount);
+ QCOMPARE(evaluate<int>(visualModel, "count"), inItems ? visualCount : modelCount);
+ QCOMPARE(evaluate<int>(visualModel, "items.count"), inItems ? visualCount : modelCount);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), persisted ? 1 : 0);
+ QCOMPARE(evaluate<int>(visualModel, "visibleItems.count"), visible ? visualCount : modelCount);
+ QCOMPARE(evaluate<int>(visualModel, "selectedItems.count"), selected ? 1 : 0);
+
+ QCOMPARE(propertyData.count(), visualCount);
+ for (int i = 0; i < visualCount; ++i) {
+ int modelIndex = i;
+ if (modelIndex > index)
+ modelIndex -= 1;
+ else if (modelIndex == index)
+ modelIndex = -1;
+
+ const int itemsIndex = inItems || i <= index ? i : i - 1;
+ QString get;
+
+ if (i != index) {
+ get = QString("items.get(%1)").arg(itemsIndex);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "delegate", modelIndex);
+ QVERIFY(item);
+
+ QCOMPARE(evaluate<int>(item, "test1"), modelIndex);
+ QCOMPARE(evaluate<int>(item, "test2"), modelIndex);
+ QCOMPARE(evaluate<QString>(item, "test3"), propertyData.at(i));
+ QCOMPARE(evaluate<QString>(item, "test4"), propertyData.at(i));
+
+ if (modelData) {
+ QCOMPARE(evaluate<QString>(item, "test5"), propertyData.at(i));
+ QCOMPARE(evaluate<QString>(item, "test6"), propertyData.at(i));
+ }
+
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inItems"), true);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inPersistedItems"), false);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inVisible"), true);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inSelected"), false);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.isUnresolved"), false);
+
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.itemsIndex"), itemsIndex);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.persistedItemsIndex"), persisted && i > index ? 1 : 0);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.visibleIndex"), visible || i <= index ? i : i - 1);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.selectedIndex"), selected && i > index ? 1 : 0);
+ } else if (inItems) {
+ get = QString("items.get(%1)").arg(index);
+ } else if (persisted) {
+ get = "persistedItems.get(0)";
+ } else if (visible) {
+ get = QString("visibleItems.get(%1)").arg(index);
+ } else if (selected) {
+ get = "selectedItems.get(0)";
+ } else {
+ continue;
+ }
+
+ QCOMPARE(evaluate<int>(visualModel, get + ".model.index"), modelIndex);
+
+ QCOMPARE(evaluate<QString>(visualModel, get + ".model." + property), propertyData.at(i));
+
+ QCOMPARE(evaluate<bool>(visualModel, get + ".inItems"), inItems || i != index);
+ QCOMPARE(evaluate<bool>(visualModel, get + ".inPersistedItems"), persisted && i == index);
+ QCOMPARE(evaluate<bool>(visualModel, get + ".inVisible"), visible || i != index);
+ QCOMPARE(evaluate<bool>(visualModel, get + ".inSelected"), selected && i == index);
+ QCOMPARE(evaluate<bool>(visualModel, get + ".isUnresolved"), i == index);
+
+ QCOMPARE(evaluate<int>(visualModel, get + ".itemsIndex"), inItems || i <= index ? i : i - 1);
+ QCOMPARE(evaluate<int>(visualModel, get + ".persistedItemsIndex"), persisted && i > index ? 1 : 0);
+ QCOMPARE(evaluate<int>(visualModel, get + ".visibleIndex"), visible || i <= index ? i : i - 1);
+ QCOMPARE(evaluate<int>(visualModel, get + ".selectedIndex"), selected && i > index ? 1 : 0);
+ }
+
+ QObject *item = 0;
+
+ if (inItems)
+ item = evaluate<QObject *>(visualModel, QString("items.create(%1)").arg(index));
+ else if (persisted)
+ item = evaluate<QObject *>(visualModel, QString("persistedItems.create(%1)").arg(0));
+ else if (visible)
+ item = evaluate<QObject *>(visualModel, QString("visibleItems.create(%1)").arg(index));
+ else if (selected)
+ item = evaluate<QObject *>(visualModel, QString("selectedItems.create(%1)").arg(0));
+ else
+ return;
+
+ QVERIFY(item);
+
+ QCOMPARE(evaluate<int>(item, "test1"), -1);
+ QCOMPARE(evaluate<int>(item, "test2"), -1);
+ QCOMPARE(evaluate<QString>(item, "test3"), propertyData.at(index));
+ QCOMPARE(evaluate<QString>(item, "test4"), propertyData.at(index));
+
+ if (modelData) {
+ QCOMPARE(evaluate<QString>(item, "test5"), propertyData.at(index));
+ QCOMPARE(evaluate<QString>(item, "test6"), propertyData.at(index));
+ }
+
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inItems"), inItems);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inPersistedItems"), true);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inVisible"), visible);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inSelected"), selected);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.isUnresolved"), true);
+
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.itemsIndex"), index);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.persistedItemsIndex"), 0);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.visibleIndex"), index);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.selectedIndex"), 0);
+}
+
+void tst_qquickvisualdatamodel::resolve_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::addColumn<QString>("setupExpression");
+ QTest::addColumn<QString>("resolveExpression");
+ QTest::addColumn<int>("unresolvedCount");
+ QTest::addColumn<int>("modelCount");
+ QTest::addColumn<int>("visualCount");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<bool>("inItems");
+ QTest::addColumn<bool>("persisted");
+ QTest::addColumn<bool>("visible");
+ QTest::addColumn<bool>("selected");
+ QTest::addColumn<bool>("modelData");
+ QTest::addColumn<QString>("property");
+ QTest::addColumn<QStringList>("propertyData");
+
+ const QUrl listModelSource[] = {
+ testFileUrl("listmodelproperties.qml"),
+ testFileUrl("listmodelproperties-package.qml") };
+ const QUrl singleRoleSource[] = {
+ testFileUrl("singleroleproperties.qml"),
+ testFileUrl("singleroleproperties-package.qml") };
+ const QUrl multipleRoleSource[] = {
+ testFileUrl("multipleroleproperties.qml"),
+ testFileUrl("multipleroleproperties-package.qml") };
+ const QUrl stringListSource[] = {
+ testFileUrl("stringlistproperties.qml"),
+ testFileUrl("stringlistproperties-package.qml") };
+ const QUrl objectListSource[] = {
+ testFileUrl("objectlistproperties.qml"),
+ testFileUrl("objectlistproperties-package.qml") };
+
+ for (int i = 0; i < 2; ++i) {
+ // List Model.
+ QTest::newRow("ListModel.items prepend, resolve prepended")
+ << listModelSource[i]
+ << QString("items.insert(0, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(0, 1) }")
+ << 5 << 5 << 5 << 0 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items prepend, resolve appended")
+ << listModelSource[i]
+ << QString("items.insert(0, {\"number\": \"eight\"})")
+ << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(0, 5) }")
+ << 5 << 5 << 5 << 4 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "seven");
+
+ QTest::newRow("ListModel.items prepend, resolve inserted")
+ << listModelSource[i]
+ << QString("items.insert(0, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(0, 3) }")
+ << 5 << 5 << 5 << 2 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "seven" << "three" << "four");
+
+ QTest::newRow("ListModel.items append, resolve prepended")
+ << listModelSource[i]
+ << QString("items.insert({\"number\": \"eight\"})")
+ << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(5, 0) }")
+ << 5 << 5 << 5 << 0 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items append, resolve appended")
+ << listModelSource[i]
+ << QString("items.insert({\"number\": \"eight\"})")
+ << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(5, 4) }")
+ << 5 << 5 << 5 << 4 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "seven");
+
+ QTest::newRow("ListModel.items append, resolve inserted")
+ << listModelSource[i]
+ << QString("items.insert({\"number\": \"eight\"})")
+ << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(5, 2) }")
+ << 5 << 5 << 5 << 2 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "seven" << "three" << "four");
+
+ QTest::newRow("ListModel.items insert, resolve prepended")
+ << listModelSource[i]
+ << QString("items.insert(2, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(0, {\"number\": \"seven\"}); items.resolve(3, 0) }")
+ << 5 << 5 << 5 << 0 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items insert, resolve appended")
+ << listModelSource[i]
+ << QString("items.insert(2, {\"number\": \"eight\"})")
+ << QString("{ listModel.append({\"number\": \"seven\"}); items.resolve(2, 5) }")
+ << 5 << 5 << 5 << 4 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "seven");
+
+ QTest::newRow("ListModel.items insert, resolve inserted")
+ << listModelSource[i]
+ << QString("items.insert(2, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(2, {\"number\": \"seven\"}); items.resolve(2, 3) }")
+ << 5 << 5 << 5 << 2 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "seven" << "three" << "four");
+
+ QTest::newRow("ListModel.items prepend, move resolved")
+ << listModelSource[i]
+ << QString("items.insert(0, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(0, {\"number\": \"seven\"}); "
+ "items.resolve(0, 1); "
+ "listModel.move(0, 2, 1) }")
+ << 5 << 5 << 5 << 2 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "seven" << "three" << "four");
+
+ QTest::newRow("ListModel.items append, move resolved")
+ << listModelSource[i]
+ << QString("items.insert({\"number\": \"eight\"})")
+ << QString("{ listModel.append({\"number\": \"seven\"}); "
+ "items.resolve(5, 4); "
+ "listModel.move(4, 2, 1) }")
+ << 5 << 5 << 5 << 2 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "seven" << "three" << "four");
+
+ QTest::newRow("ListModel.items insert, move resolved")
+ << listModelSource[i]
+ << QString("items.insert(2, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(2, {\"number\": \"seven\"}); "
+ "items.resolve(2, 3);"
+ "listModel.move(2, 0, 1) }")
+ << 5 << 5 << 5 << 0 << true << false << true << false << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items prepend, remove resolved")
+ << listModelSource[i]
+ << QString("items.insert(0, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(0, {\"number\": \"seven\"}); "
+ "items.resolve(0, 1); "
+ "listModel.remove(0, 1) }")
+ << 5 << 4 << 4 << 4 << false << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items append, remove resolved")
+ << listModelSource[i]
+ << QString("items.insert({\"number\": \"eight\"})")
+ << QString("{ listModel.append({\"number\": \"seven\"}); "
+ "items.resolve(5, 4); "
+ "listModel.remove(4, 1) }")
+ << 5 << 4 << 4 << 4 << false << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items insert, remove resolved")
+ << listModelSource[i]
+ << QString("items.insert(2, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(2, {\"number\": \"seven\"}); "
+ "items.resolve(2, 3);"
+ "listModel.remove(2, 1) }")
+ << 5 << 4 << 4 << 4 << false << false << false << false << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.selectedItems prepend, resolve prepended")
+ << listModelSource[i]
+ << QString("selectedItems.insert(0, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(0, {\"number\": \"seven\"}); "
+ "selectedItems.resolve(selectedItems.get(0), items.get(0)) }")
+ << 4 << 5 << 5 << 0 << true << false << true << true << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.selectedItems prepend, resolve appended")
+ << listModelSource[i]
+ << QString("selectedItems.insert(0, {\"number\": \"eight\"})")
+ << QString("{ listModel.append({\"number\": \"seven\"}); "
+ "selectedItems.resolve(selectedItems.get(0), items.get(4)) }")
+ << 4 << 5 << 5 << 4 << true << false << true << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "seven");
+
+ QTest::newRow("ListModel.selectedItems prepend, resolve inserted")
+ << listModelSource[i]
+ << QString("selectedItems.insert(0, {\"number\": \"eight\"})")
+ << QString("{ listModel.insert(2, {\"number\": \"seven\"}); "
+ "selectedItems.resolve(selectedItems.get(0), items.get(2)) }")
+ << 4 << 5 << 5 << 2 << true << false << true << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "seven" << "three" << "four");
+
+ QTest::newRow("ListModel.selectedItems append, resolve prepended")
+ << listModelSource[i]
+ << QString("selectedItems.insert({\"number\": \"eight\"})")
+ << QString("{ listModel.insert(0, {\"number\": \"seven\"}); "
+ "selectedItems.resolve(selectedItems.get(0), items.get(0)) }")
+ << 4 << 5 << 5 << 0 << true << false << true << true << true
+ << QString("number")
+ << (QStringList() << "seven" << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.selectedItems append, resolve appended")
+ << listModelSource[i]
+ << QString("selectedItems.insert({\"number\": \"eight\"})")
+ << QString("{ listModel.append({\"number\": \"seven\"}); "
+ "selectedItems.resolve(selectedItems.get(0), items.get(4)) }")
+ << 4 << 5 << 5 << 4 << true << false << true << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "three" << "four" << "seven");
+
+ QTest::newRow("ListModel.selectedItems append, resolve inserted")
+ << listModelSource[i]
+ << QString("selectedItems.insert({\"number\": \"eight\"})")
+ << QString("{ listModel.insert(2, {\"number\": \"seven\"}); "
+ "selectedItems.resolve(selectedItems.get(0), items.get(2)) }")
+ << 4 << 5 << 5 << 2 << true << false << true << true << true
+ << QString("number")
+ << (QStringList() << "one" << "two" << "seven" << "three" << "four");
+
+ // AbstractItemModel (Single Role)
+ QTest::newRow("ListModel.items prepend, resolve prepended")
+ << singleRoleSource[i]
+ << QString("items.insert(0, {\"name\": \"eight\"})")
+ << QString("{ items.resolve(0, 1) }")
+ << 5 << 4 << 4 << 0 << true << false << true << false << true
+ << QString("name")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+
+ QTest::newRow("ListModel.items append, resolve appended")
+ << singleRoleSource[i]
+ << QString("items.insert({\"name\": \"eight\"})")
+ << QString("{ items.resolve(4, 3) }")
+ << 5 << 4 << 4 << 3 << true << false << true << false << true
+ << QString("name")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ QTest::newRow("ListModel.items insert, resolve inserted")
+ << singleRoleSource[i]
+ << QString("items.insert(2, {\"name\": \"eight\"})")
+ << QString("{ items.resolve(2, 3) }")
+ << 5 << 4 << 4 << 2 << true << false << true << false << true
+ << QString("name")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ // AbstractItemModel (Single Role)
+ QTest::newRow("AbstractItemModel.items prepend, resolve prepended")
+ << singleRoleSource[i]
+ << QString("items.insert(0, {\"name\": \"eight\"})")
+ << QString("{ items.resolve(0, 1) }")
+ << 5 << 4 << 4 << 0 << true << false << true << false << true
+ << QString("name")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items append, resolve appended")
+ << singleRoleSource[i]
+ << QString("items.insert({\"name\": \"eight\"})")
+ << QString("{ items.resolve(4, 3) }")
+ << 5 << 4 << 4 << 3 << true << false << true << false << true
+ << QString("name")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ QTest::newRow("AbstractItemModel.items insert, resolve inserted")
+ << singleRoleSource[i]
+ << QString("items.insert(2, {\"name\": \"eight\"})")
+ << QString("{ items.resolve(2, 3) }")
+ << 5 << 4 << 4 << 2 << true << false << true << false << true
+ << QString("name")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ // AbstractItemModel (Multiple Roles)
+ QTest::newRow("StandardItemModel.items prepend, resolve prepended")
+ << multipleRoleSource[i]
+ << QString("items.insert(0, {\"display\": \"Row 8 Item\"})")
+ << QString("{ items.resolve(0, 1) }")
+ << 5 << 4 << 4 << 0 << true << false << true << false << false
+ << QString("display")
+ << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items append, resolve appended")
+ << multipleRoleSource[i]
+ << QString("items.insert({\"display\": \"Row 8 Item\"})")
+ << QString("{ items.resolve(4, 3) }")
+ << 5 << 4 << 4 << 3 << true << false << true << false << false
+ << QString("display")
+ << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ QTest::newRow("StandardItemModel.items insert, resolve inserted")
+ << multipleRoleSource[i]
+ << QString("items.insert(2, {\"display\": \"Row 8 Item\"})")
+ << QString("{ items.resolve(2, 3) }")
+ << 5 << 4 << 4 << 2 << true << false << true << false << false
+ << QString("display")
+ << (QStringList() << "Row 1 Item" << "Row 2 Item" << "Row 3 Item" << "Row 4 Item");
+
+ // StringList
+ QTest::newRow("StringList.items prepend, resolve prepended")
+ << stringListSource[i]
+ << QString("items.insert(0, {\"modelData\": \"eight\"})")
+ << QString("{ items.resolve(0, 1) }")
+ << 5 << 4 << 4 << 0 << true << false << true << false << false
+ << QString("modelData")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ QTest::newRow("StringList.items append, resolve appended")
+ << stringListSource[i]
+ << QString("items.insert({\"modelData\": \"eight\"})")
+ << QString("{ items.resolve(4, 3) }")
+ << 5 << 4 << 4 << 3 << true << false << true << false << false
+ << QString("modelData")
+ << (QStringList() << "one" << "two" << "three" << "four");
+
+ QTest::newRow("StringList.items insert, resolve inserted")
+ << stringListSource[i]
+ << QString("items.insert(2, {\"modelData\": \"eight\"})")
+ << QString("{ items.resolve(2, 3) }")
+ << 5 << 4 << 4 << 2 << true << false << true << false << false
+ << QString("modelData")
+ << (QStringList() << "one" << "two" << "three" << "four");
+ }
+}
+
+void tst_qquickvisualdatamodel::resolve()
+{
+ QFETCH(QUrl, source);
+ QFETCH(QString, setupExpression);
+ QFETCH(QString, resolveExpression);
+ QFETCH(int, unresolvedCount);
+ QFETCH(int, modelCount);
+ QFETCH(int, visualCount);
+ QFETCH(int, index);
+ QFETCH(bool, inItems);
+ QFETCH(bool, persisted);
+ QFETCH(bool, visible);
+ QFETCH(bool, selected);
+ QFETCH(bool, modelData);
+ QFETCH(QString, property);
+ QFETCH(QStringList, propertyData);
+
+ QQuickCanvas canvas;
+
+ QQmlComponent component(&engine);
+ component.loadUrl(source);
+ QScopedPointer<QObject> object(component.create());
+ QQuickListView *listView = qobject_cast<QQuickListView *>(object.data());
+ QVERIFY(listView);
+ listView->setParentItem(canvas.rootItem());
+
+ QQuickItem *contentItem = listView->contentItem();
+ QVERIFY(contentItem);
+
+ QObject *visualModel = listView->findChild<QObject *>("visualModel");
+ QVERIFY(visualModel);
+
+ evaluate<void>(visualModel, setupExpression);
+ QCOMPARE(evaluate<int>(listView, "count"), unresolvedCount);
+
+ evaluate<void>(visualModel, resolveExpression);
+
+ QCOMPARE(evaluate<int>(listView, "count"), inItems ? visualCount : modelCount);
+ QCOMPARE(evaluate<int>(visualModel, "count"), inItems ? visualCount : modelCount);
+ QCOMPARE(evaluate<int>(visualModel, "items.count"), inItems ? visualCount : modelCount);
+ QCOMPARE(evaluate<int>(visualModel, "persistedItems.count"), persisted ? 1 : 0);
+ QCOMPARE(evaluate<int>(visualModel, "visibleItems.count"), visible ? visualCount : modelCount);
+ QCOMPARE(evaluate<int>(visualModel, "selectedItems.count"), selected ? 1 : 0);
+
+ QCOMPARE(propertyData.count(), visualCount);
+ for (int i = 0; i < visualCount; ++i) {
+ int modelIndex = i;
+
+ const int itemsIndex = inItems || i <= index ? i : i - 1;
+ QString get;
+
+ if (i != index) {
+ get = QString("items.get(%1)").arg(itemsIndex);
+
+ QQuickItem *item = findItem<QQuickItem>(contentItem, "delegate", modelIndex);
+ QVERIFY(item);
+
+ QCOMPARE(evaluate<int>(item, "test1"), modelIndex);
+ QCOMPARE(evaluate<int>(item, "test2"), modelIndex);
+ QCOMPARE(evaluate<QString>(item, "test3"), propertyData.at(i));
+ QCOMPARE(evaluate<QString>(item, "test4"), propertyData.at(i));
+
+ if (modelData) {
+ QCOMPARE(evaluate<QString>(item, "test5"), propertyData.at(i));
+ QCOMPARE(evaluate<QString>(item, "test6"), propertyData.at(i));
+ }
+
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inItems"), true);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inPersistedItems"), false);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inVisible"), true);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inSelected"), false);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.isUnresolved"), false);
+
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.itemsIndex"), itemsIndex);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.persistedItemsIndex"), persisted && i > index ? 1 : 0);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.visibleIndex"), visible || i <= index ? i : i - 1);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.selectedIndex"), selected && i > index ? 1 : 0);
+ } else if (inItems) {
+ get = QString("items.get(%1)").arg(index);
+ } else if (persisted) {
+ get = "persistedItems.get(0)";
+ } else if (visible) {
+ get = QString("visibleItems.get(%1)").arg(index);
+ } else if (selected) {
+ get = "selectedItems.get(0)";
+ } else {
+ continue;
+ }
+
+ QCOMPARE(evaluate<int>(visualModel, get + ".model.index"), modelIndex);
+
+ QCOMPARE(evaluate<QString>(visualModel, get + ".model." + property), propertyData.at(i));
+
+ QCOMPARE(evaluate<bool>(visualModel, get + ".inItems"), inItems || i != index);
+ QCOMPARE(evaluate<bool>(visualModel, get + ".inPersistedItems"), persisted && i == index);
+ QCOMPARE(evaluate<bool>(visualModel, get + ".inVisible"), visible || i != index);
+ QCOMPARE(evaluate<bool>(visualModel, get + ".inSelected"), selected && i == index);
+ QCOMPARE(evaluate<bool>(visualModel, get + ".isUnresolved"), false);
+
+ QCOMPARE(evaluate<int>(visualModel, get + ".itemsIndex"), inItems || i <= index ? i : i - 1);
+ QCOMPARE(evaluate<int>(visualModel, get + ".persistedItemsIndex"), persisted && i > index ? 1 : 0);
+ QCOMPARE(evaluate<int>(visualModel, get + ".visibleIndex"), visible || i <= index ? i : i - 1);
+ QCOMPARE(evaluate<int>(visualModel, get + ".selectedIndex"), selected && i > index ? 1 : 0);
+ }
+
+ QObject *item = 0;
+
+ if (inItems)
+ item = evaluate<QObject *>(visualModel, QString("items.create(%1)").arg(index));
+ else if (persisted)
+ item = evaluate<QObject *>(visualModel, QString("persistedItems.create(%1)").arg(0));
+ else if (visible)
+ item = evaluate<QObject *>(visualModel, QString("visibleItems.create(%1)").arg(index));
+ else if (selected)
+ item = evaluate<QObject *>(visualModel, QString("selectedItems.create(%1)").arg(0));
+ else
+ return;
+
+ QVERIFY(item);
+
+ QCOMPARE(evaluate<int>(item, "test1"), index);
+ QCOMPARE(evaluate<int>(item, "test2"), index);
+ QCOMPARE(evaluate<QString>(item, "test3"), propertyData.at(index));
+ QCOMPARE(evaluate<QString>(item, "test4"), propertyData.at(index));
+
+ if (modelData) {
+ QCOMPARE(evaluate<QString>(item, "test5"), propertyData.at(index));
+ QCOMPARE(evaluate<QString>(item, "test6"), propertyData.at(index));
+ }
+
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inItems"), inItems);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inPersistedItems"), true);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inVisible"), visible);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.inSelected"), selected);
+ QCOMPARE(evaluate<bool>(item, "delegate.VisualDataModel.isUnresolved"), false);
+
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.itemsIndex"), index);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.persistedItemsIndex"), 0);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.visibleIndex"), index);
+ QCOMPARE(evaluate<int>(item, "delegate.VisualDataModel.selectedIndex"), 0);
+}
+
+void tst_qquickvisualdatamodel::warnings_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::addColumn<QString>("expression");
+ QTest::addColumn<QString>("warning");
+ QTest::addColumn<int>("count");
+
+ QTest::newRow("insert < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.insert(-2, {\"number\": \"eight\"})")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range"))
+ << 4;
+
+ QTest::newRow("insert > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.insert(8, {\"number\": \"eight\"})")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("insert: index out of range"))
+ << 4;
+
+ QTest::newRow("create < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.create(-2, {\"number\": \"eight\"})")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range"))
+ << 4;
+
+ QTest::newRow("create > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.create(8, {\"number\": \"eight\"})")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("create: index out of range"))
+ << 4;
+
+ QTest::newRow("resolve from < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.resolve(-2, 3)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range"))
+ << 4;
+
+ QTest::newRow("resolve from > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.resolve(8, 3)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index out of range"))
+ << 4;
+
+ QTest::newRow("resolve to < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.resolve(3, -2)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range"))
+ << 4;
+
+ QTest::newRow("resolve to > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.resolve(3, 8)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index out of range"))
+ << 4;
+
+ QTest::newRow("resolve from invalid index")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.resolve(\"two\", 3)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from index invalid"))
+ << 4;
+
+ QTest::newRow("resolve to invalid index")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.resolve(3, \"two\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to index invalid"))
+ << 4;
+
+ QTest::newRow("resolve already resolved item")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.resolve(3, 2)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: from is not an unresolved item"))
+ << 4;
+
+ QTest::newRow("resolve already resolved item")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("{ items.insert(0, {\"number\": \"eight\"});"
+ "items.insert(1, {\"number\": \"seven\"});"
+ "items.resolve(0, 1)}")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("resolve: to is not a model item"))
+ << 6;
+
+ QTest::newRow("remove index < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.remove(-2, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range"))
+ << 4;
+
+ QTest::newRow("remove index == length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.remove(4, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range"))
+ << 4;
+
+ QTest::newRow("remove index > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.remove(9, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: index out of range"))
+ << 4;
+
+ QTest::newRow("remove invalid index")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.remove(\"nine\", 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid index"))
+ << 4;
+
+ QTest::newRow("remove count < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.remove(1, -2)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count"))
+ << 4;
+
+ QTest::newRow("remove index + count > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.remove(2, 4, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("remove: invalid count"))
+ << 4;
+
+ QTest::newRow("addGroups index < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.addGroups(-2, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("addGroups index == length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.addGroups(4, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("addGroups index > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.addGroups(9, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("addGroups count < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.addGroups(1, -2, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count"))
+ << 4;
+
+ QTest::newRow("addGroups index + count > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.addGroups(2, 4, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("addGroups: invalid count"))
+ << 4;
+
+ QTest::newRow("removeGroups index < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.removeGroups(-2, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("removeGroups index == length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.removeGroups(4, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("removeGroups index > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.removeGroups(9, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("removeGroups count < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.removeGroups(1, -2, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count"))
+ << 4;
+
+ QTest::newRow("removeGroups index + count > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.removeGroups(2, 4, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("removeGroups: invalid count"))
+ << 4;
+
+ QTest::newRow("setGroups index < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.setGroups(-2, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("setGroups index == length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.setGroups(4, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("setGroups index > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.setGroups(9, 1, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: index out of range"))
+ << 4;
+
+ QTest::newRow("setGroups count < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.setGroups(1, -2, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count"))
+ << 4;
+
+ QTest::newRow("setGroups index + count > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.setGroups(2, 4, \"selected\")")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("setGroups: invalid count"))
+ << 4;
+
+ QTest::newRow("move from < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(-2, 1, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
+ << 4;
+
+ QTest::newRow("move from == length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(4, 1, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
+ << 4;
+
+ QTest::newRow("move from > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(9, 1, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
+ << 4;
+
+ QTest::newRow("move invalid from")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(\"nine\", 1, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid from index"))
+ << 4;
+
+ QTest::newRow("move to < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(1, -2, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range"))
+ << 4;
+
+ QTest::newRow("move to == length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(1, 4, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range"))
+ << 4;
+
+ QTest::newRow("move to > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(1, 9, 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: to index out of range"))
+ << 4;
+
+ QTest::newRow("move invalid to")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(1, \"nine\", 1)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid to index"))
+ << 4;
+
+ QTest::newRow("move count < 0")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(1, 1, -2)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: invalid count"))
+ << 4;
+
+ QTest::newRow("move from + count > length")
+ << testFileUrl("listmodelproperties.qml")
+ << QString("items.move(2, 1, 4)")
+ << ("<Unknown File>: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("move: from index out of range"))
+ << 4;
+}
+
+void tst_qquickvisualdatamodel::warnings()
+{
+ QFETCH(QUrl, source);
+ QFETCH(QString, expression);
+ QFETCH(QString, warning);
+ QFETCH(int, count);
+
+ QQuickCanvas canvas;
+
+ QQmlComponent component(&engine);
+ component.loadUrl(source);
+ QScopedPointer<QObject> object(component.create());
+ QQuickListView *listView = qobject_cast<QQuickListView *>(object.data());
+ QVERIFY(listView);
+ listView->setParentItem(canvas.rootItem());
+
+ QQuickItem *contentItem = listView->contentItem();
+ QVERIFY(contentItem);
+
+ QObject *visualModel = evaluate<QObject *>(listView, "model");
+ QVERIFY(visualModel);
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toUtf8());
+
+ evaluate<void>(visualModel, expression);
+ QCOMPARE(evaluate<int>(listView, "count"), count);
+}
+
+
+QTEST_MAIN(tst_qquickvisualdatamodel)
+
+#include "tst_qquickvisualdatamodel.moc"
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/empty.xml b/tests/auto/quick/qquickxmllistmodel/data/empty.xml
index e69de29bb2..e69de29bb2 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/empty.xml
+++ b/tests/auto/quick/qquickxmllistmodel/data/empty.xml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/get.qml b/tests/auto/quick/qquickxmllistmodel/data/get.qml
index 509da7174b..509da7174b 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/get.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/get.qml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.qml b/tests/auto/quick/qquickxmllistmodel/data/model.qml
index 2df3927479..2df3927479 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/model.qml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.xml b/tests/auto/quick/qquickxmllistmodel/data/model.xml
index 40cd6d0432..40cd6d0432 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model.xml
+++ b/tests/auto/quick/qquickxmllistmodel/data/model.xml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model2.xml b/tests/auto/quick/qquickxmllistmodel/data/model2.xml
index dab2ec6dc0..dab2ec6dc0 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/model2.xml
+++ b/tests/auto/quick/qquickxmllistmodel/data/model2.xml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/propertychanges.qml b/tests/auto/quick/qquickxmllistmodel/data/propertychanges.qml
index f8a97bffc3..f8a97bffc3 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/propertychanges.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/propertychanges.qml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.qml b/tests/auto/quick/qquickxmllistmodel/data/recipes.qml
index dc609e95e3..dc609e95e3 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/recipes.qml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.xml b/tests/auto/quick/qquickxmllistmodel/data/recipes.xml
index d71de60710..d71de60710 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/recipes.xml
+++ b/tests/auto/quick/qquickxmllistmodel/data/recipes.xml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleCrash.qml b/tests/auto/quick/qquickxmllistmodel/data/roleCrash.qml
index 6a7059bb45..6a7059bb45 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleCrash.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/roleCrash.qml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleErrors.qml b/tests/auto/quick/qquickxmllistmodel/data/roleErrors.qml
index 91664b6d4a..91664b6d4a 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleErrors.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/roleErrors.qml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleKeys.qml b/tests/auto/quick/qquickxmllistmodel/data/roleKeys.qml
index 9f667d86e5..9f667d86e5 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/roleKeys.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/roleKeys.qml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/testtypes.qml b/tests/auto/quick/qquickxmllistmodel/data/testtypes.qml
index 5ec1ffa35f..5ec1ffa35f 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/testtypes.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/testtypes.qml
diff --git a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/unique.qml b/tests/auto/quick/qquickxmllistmodel/data/unique.qml
index 322a2e4e5c..322a2e4e5c 100644
--- a/tests/auto/qtquick2/qdeclarativexmllistmodel/data/unique.qml
+++ b/tests/auto/quick/qquickxmllistmodel/data/unique.qml
diff --git a/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro b/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro
new file mode 100644
index 0000000000..b18af50c9e
--- /dev/null
+++ b/tests/auto/quick/qquickxmllistmodel/qquickxmllistmodel.pro
@@ -0,0 +1,15 @@
+CONFIG += testcase
+TARGET = tst_qquickxmllistmodel
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qquickxmllistmodel.cpp
+
+include (../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+QT += core-private gui-private v8-private qml-private network testlib xmlpatterns
diff --git a/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
new file mode 100644
index 0000000000..4d337564c0
--- /dev/null
+++ b/tests/auto/quick/qquickxmllistmodel/tst_qquickxmllistmodel.cpp
@@ -0,0 +1,962 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtGlobal>
+#include <math.h>
+#include <QMetaObject>
+#include <qtest.h>
+#include <QtTest/qsignalspy.h>
+#include <QtQml/qqmlnetworkaccessmanagerfactory.h>
+#include <QtNetwork/qnetworkaccessmanager.h>
+#include <QtNetwork/qnetworkrequest.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qtemporaryfile.h>
+#include "../../shared/util.h"
+#include <private/qqmlengine_p.h>
+
+#include <QtQml/qqmlengine.h>
+#include <QtQml/qqmlcomponent.h>
+#include <private/qlistmodelinterface_p.h>
+#include "../../../../src/imports/xmllistmodel/qqmlxmllistmodel_p.h"
+
+typedef QPair<int, int> QQuickXmlListRange;
+typedef QList<QVariantList> QQmlXmlModelData;
+
+Q_DECLARE_METATYPE(QList<QQuickXmlListRange>)
+Q_DECLARE_METATYPE(QQmlXmlModelData)
+Q_DECLARE_METATYPE(QQuickXmlListModel::Status)
+
+class tst_qquickxmllistmodel : public QQmlDataTest
+
+{
+ Q_OBJECT
+public:
+ tst_qquickxmllistmodel() {}
+
+private slots:
+ void initTestCase() {
+ QQmlDataTest::initTestCase();
+ qRegisterMetaType<QQuickXmlListModel::Status>();
+ }
+
+ void buildModel();
+ void testTypes();
+ void testTypes_data();
+ void cdata();
+ void attributes();
+ void roles();
+ void roleErrors();
+ void uniqueRoleNames();
+ void headers();
+ void xml();
+ void xml_data();
+ void source();
+ void source_data();
+ void data();
+ void get();
+ void reload();
+ void useKeys();
+ void useKeys_data();
+ void noKeysValueChanges();
+ void keysChanged();
+ void threading();
+ void threading_data();
+ void propertyChanges();
+
+ void roleCrash();
+
+private:
+ QString errorString(QListModelInterface* model) {
+ QString ret;
+ QMetaObject::invokeMethod(model, "errorString", Q_RETURN_ARG(QString, ret));
+ return ret;
+ }
+
+ QString makeItemXmlAndData(const QString &data, QQmlXmlModelData *modelData = 0) const
+ {
+ if (modelData)
+ modelData->clear();
+ QString xml;
+
+ if (!data.isEmpty()) {
+ QStringList items = data.split(";");
+ foreach(const QString &item, items) {
+ if (item.isEmpty())
+ continue;
+ QVariantList variants;
+ xml += QLatin1String("<item>");
+ QStringList fields = item.split(",");
+ foreach(const QString &field, fields) {
+ QStringList values = field.split("=");
+ if (values.count() != 2) {
+ qWarning() << "makeItemXmlAndData: invalid field:" << field;
+ continue;
+ }
+ xml += QString("<%1>%2</%1>").arg(values[0], values[1]);
+ if (!modelData)
+ continue;
+ bool isNum = false;
+ int number = values[1].toInt(&isNum);
+ if (isNum)
+ variants << number;
+ else
+ variants << values[1];
+ }
+ xml += QLatin1String("</item>");
+ if (modelData)
+ modelData->append(variants);
+ }
+ }
+
+ QString decl = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>";
+ return decl + QLatin1String("<data>") + xml + QLatin1String("</data>");
+ }
+
+ QQmlEngine engine;
+};
+
+class CustomNetworkAccessManagerFactory : public QObject, public QQmlNetworkAccessManagerFactory
+{
+ Q_OBJECT
+public:
+ QVariantMap lastSentHeaders;
+
+protected:
+ QNetworkAccessManager *create(QObject *parent);
+};
+
+class CustomNetworkAccessManager : public QNetworkAccessManager
+{
+ Q_OBJECT
+public:
+ CustomNetworkAccessManager(CustomNetworkAccessManagerFactory *factory, QObject *parent)
+ : QNetworkAccessManager(parent), m_factory(factory) {}
+
+protected:
+ QNetworkReply *createRequest(Operation op, const QNetworkRequest &req, QIODevice * outgoingData = 0)
+ {
+ if (m_factory) {
+ QVariantMap map;
+ foreach (const QString &header, req.rawHeaderList())
+ map[header] = req.rawHeader(header.toUtf8());
+ m_factory->lastSentHeaders = map;
+ }
+ return QNetworkAccessManager::createRequest(op, req, outgoingData);
+ }
+
+ QPointer<CustomNetworkAccessManagerFactory> m_factory;
+};
+
+QNetworkAccessManager *CustomNetworkAccessManagerFactory::create(QObject *parent)
+{
+ return new CustomNetworkAccessManager(this, parent);
+}
+
+
+void tst_qquickxmllistmodel::buildModel()
+{
+ QQmlComponent component(&engine, testFileUrl("model.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 9);
+
+ QCOMPARE(model->data(3, Qt::UserRole).toString(), QLatin1String("Spot"));
+ QCOMPARE(model->data(3, Qt::UserRole+1).toString(), QLatin1String("Dog"));
+ QCOMPARE(model->data(3, Qt::UserRole+2).toInt(), 9);
+ QCOMPARE(model->data(3, Qt::UserRole+3).toString(), QLatin1String("Medium"));
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::testTypes()
+{
+ QFETCH(QString, xml);
+ QFETCH(QString, roleName);
+ QFETCH(QVariant, expectedValue);
+
+ QQmlComponent component(&engine, testFileUrl("testtypes.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ model->setProperty("xml",xml.toUtf8());
+ QMetaObject::invokeMethod(model, "reload");
+ QTRY_COMPARE(model->count(), 1);
+
+ int role = -1;
+ foreach (int i, model->roles()) {
+ if (model->toString(i) == roleName) {
+ role = i;
+ break;
+ }
+ }
+ QVERIFY(role >= 0);
+
+ if (expectedValue.toString() == "nan")
+ QVERIFY(qIsNaN(model->data(0, role).toDouble()));
+ else
+ QCOMPARE(model->data(0, role), expectedValue);
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::testTypes_data()
+{
+ QTest::addColumn<QString>("xml");
+ QTest::addColumn<QString>("roleName");
+ QTest::addColumn<QVariant>("expectedValue");
+
+ QTest::newRow("missing string field") << "<data></data>"
+ << "stringValue" << QVariant("");
+ QTest::newRow("empty string") << "<data><a-string></a-string></data>"
+ << "stringValue" << QVariant("");
+ QTest::newRow("1-char string") << "<data><a-string>5</a-string></data>"
+ << "stringValue" << QVariant("5");
+ QTest::newRow("string ok") << "<data><a-string>abc def g</a-string></data>"
+ << "stringValue" << QVariant("abc def g");
+
+ QTest::newRow("missing number field") << "<data></data>"
+ << "numberValue" << QVariant("");
+ double nan = qQNaN();
+ QTest::newRow("empty number field") << "<data><a-number></a-number></data>"
+ << "numberValue" << QVariant(nan);
+ QTest::newRow("number field with string") << "<data><a-number>a string</a-number></data>"
+ << "numberValue" << QVariant(nan);
+ QTest::newRow("-1") << "<data><a-number>-1</a-number></data>"
+ << "numberValue" << QVariant("-1");
+ QTest::newRow("-1.5") << "<data><a-number>-1.5</a-number></data>"
+ << "numberValue" << QVariant("-1.5");
+ QTest::newRow("0") << "<data><a-number>0</a-number></data>"
+ << "numberValue" << QVariant("0");
+ QTest::newRow("+1") << "<data><a-number>1</a-number></data>"
+ << "numberValue" << QVariant("1");
+ QTest::newRow("+1.5") << "<data><a-number>1.5</a-number></data>"
+ << "numberValue" << QVariant("1.5");
+}
+
+void tst_qquickxmllistmodel::cdata()
+{
+ QQmlComponent component(&engine, testFileUrl("recipes.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 5);
+
+ QVERIFY(model->data(2, Qt::UserRole+2).toString().startsWith(QLatin1String("<html>")));
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::attributes()
+{
+ QQmlComponent component(&engine, testFileUrl("recipes.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 5);
+ QCOMPARE(model->data(2, Qt::UserRole).toString(), QLatin1String("Vegetable Soup"));
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::roles()
+{
+ QQmlComponent component(&engine, testFileUrl("model.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 9);
+
+ QList<int> roles = model->roles();
+ QCOMPARE(roles.count(), 4);
+ QCOMPARE(model->toString(roles.at(0)), QLatin1String("name"));
+ QCOMPARE(model->toString(roles.at(1)), QLatin1String("type"));
+ QCOMPARE(model->toString(roles.at(2)), QLatin1String("age"));
+ QCOMPARE(model->toString(roles.at(3)), QLatin1String("size"));
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::roleErrors()
+{
+ QQmlComponent component(&engine, testFileUrl("roleErrors.qml"));
+ QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":7:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData());
+ QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":10:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData());
+
+ //### make sure we receive all expected warning messages.
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 9);
+
+
+ //### should any of these return valid values?
+ QCOMPARE(model->data(3, Qt::UserRole), QVariant());
+ QCOMPARE(model->data(3, Qt::UserRole+1), QVariant());
+ QCOMPARE(model->data(3, Qt::UserRole+2), QVariant());
+
+ QEXPECT_FAIL("", "QTBUG-10797", Continue);
+ QCOMPARE(model->data(3, Qt::UserRole+3), QVariant());
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::uniqueRoleNames()
+{
+ QQmlComponent component(&engine, testFileUrl("unique.qml"));
+ QTest::ignoreMessage(QtWarningMsg, (testFileUrl("unique.qml").toString() + ":8:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 9);
+
+ QList<int> roles = model->roles();
+ QCOMPARE(roles.count(), 1);
+
+ delete model;
+}
+
+
+void tst_qquickxmllistmodel::xml()
+{
+ QFETCH(QString, xml);
+ QFETCH(int, count);
+
+ QQmlComponent component(&engine, testFileUrl("model.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+
+ QSignalSpy spy(model, SIGNAL(statusChanged(QQuickXmlListModel::Status)));
+ QVERIFY(errorString(model).isEmpty());
+ QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Loading);
+ QTRY_COMPARE(spy.count(), 1); spy.clear();
+ QTest::qWait(50);
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Ready);
+ QVERIFY(errorString(model).isEmpty());
+ QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
+ QCOMPARE(model->count(), 9);
+
+ // if xml is empty (i.e. clearing) it won't have any effect if a source is set
+ if (xml.isEmpty())
+ model->setProperty("source",QUrl());
+ model->setProperty("xml",xml);
+ QCOMPARE(model->property("progress").toDouble(), qreal(1.0)); // immediately goes to 1.0 if using setXml()
+ QTRY_COMPARE(spy.count(), 1); spy.clear();
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Loading);
+ QTRY_COMPARE(spy.count(), 1); spy.clear();
+ if (xml.isEmpty())
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Null);
+ else
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Ready);
+ QVERIFY(errorString(model).isEmpty());
+ QCOMPARE(model->count(), count);
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::xml_data()
+{
+ QTest::addColumn<QString>("xml");
+ QTest::addColumn<int>("count");
+
+ QTest::newRow("xml with no items") << "<Pets></Pets>" << 0;
+ QTest::newRow("empty xml") << "" << 0;
+ QTest::newRow("one item") << "<Pets><Pet><name>Hobbes</name><type>Tiger</type><age>7</age><size>Large</size></Pet></Pets>" << 1;
+}
+
+void tst_qquickxmllistmodel::headers()
+{
+ // ensure the QNetworkAccessManagers created for this test are immediately deleted
+ QQmlEngine qmlEng;
+
+ CustomNetworkAccessManagerFactory factory;
+ qmlEng.setNetworkAccessManagerFactory(&factory);
+
+ QQmlComponent component(&qmlEng, testFileUrl("model.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Ready);
+
+ QVariantMap expectedHeaders;
+ expectedHeaders["Accept"] = "application/xml,*/*";
+
+ QCOMPARE(factory.lastSentHeaders.count(), expectedHeaders.count());
+ foreach (const QString &header, expectedHeaders.keys()) {
+ QVERIFY(factory.lastSentHeaders.contains(header));
+ QCOMPARE(factory.lastSentHeaders[header].toString(), expectedHeaders[header].toString());
+ }
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::source()
+{
+ QFETCH(QUrl, source);
+ QFETCH(int, count);
+ QFETCH(QQuickXmlListModel::Status, status);
+
+ QQmlComponent component(&engine, testFileUrl("model.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QSignalSpy spy(model, SIGNAL(statusChanged(QQuickXmlListModel::Status)));
+
+ QVERIFY(errorString(model).isEmpty());
+ QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Loading);
+ QTRY_COMPARE(spy.count(), 1); spy.clear();
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Ready);
+ QVERIFY(errorString(model).isEmpty());
+ QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
+ QCOMPARE(model->count(), 9);
+
+ model->setProperty("source",source);
+ if (model->property("source").toString().isEmpty())
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Null);
+ QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
+ QTRY_COMPARE(spy.count(), 1); spy.clear();
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")),
+ QQuickXmlListModel::Loading);
+ QVERIFY(errorString(model).isEmpty());
+
+ QEventLoop loop;
+ QTimer timer;
+ timer.setSingleShot(true);
+ connect(model, SIGNAL(statusChanged(QQuickXmlListModel::Status)), &loop, SLOT(quit()));
+ connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ timer.start(20000);
+ loop.exec();
+
+ if (spy.count() == 0 && status != QQuickXmlListModel::Ready) {
+ qWarning("QQuickXmlListModel invalid source test timed out");
+ } else {
+ QCOMPARE(spy.count(), 1); spy.clear();
+ }
+
+ QCOMPARE(qvariant_cast<QQuickXmlListModel::Status>(model->property("status")), status);
+ QCOMPARE(model->count(), count);
+
+ if (status == QQuickXmlListModel::Ready)
+ QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
+
+ QCOMPARE(errorString(model).isEmpty(), status == QQuickXmlListModel::Ready);
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::source_data()
+{
+ QTest::addColumn<QUrl>("source");
+ QTest::addColumn<int>("count");
+ QTest::addColumn<QQuickXmlListModel::Status>("status");
+
+ QTest::newRow("valid") << testFileUrl("model2.xml") << 2
+ << QQuickXmlListModel::Ready;
+ QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0
+ << QQuickXmlListModel::Error;
+
+ // empty file
+ QTemporaryFile *temp = new QTemporaryFile(this);
+ if (temp->open())
+ QTest::newRow("empty file") << QUrl::fromLocalFile(temp->fileName()) << 0
+ << QQuickXmlListModel::Ready;
+ temp->close();
+}
+
+void tst_qquickxmllistmodel::data()
+{
+ QQmlComponent component(&engine, testFileUrl("model.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+
+ for (int i=0; i<9; i++) {
+ for (int j=0; j<model->roles().count(); j++) {
+ QCOMPARE(model->data(i, j), QVariant());
+ }
+ }
+ QTRY_COMPARE(model->count(), 9);
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::get()
+{
+ QQmlComponent component(&engine, testFileUrl("get.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+
+ QVERIFY(model != 0);
+
+ QVERIFY(QMetaObject::invokeMethod(model, "runPreTest"));
+ QCOMPARE(model->property("preTest").toBool(), true);
+
+ QTRY_COMPARE(model->count(), 9);
+
+ QVERIFY(QMetaObject::invokeMethod(model, "runPostTest"));
+ QCOMPARE(model->property("postTest").toBool(), true);
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::reload()
+{
+ // If no keys are used, the model should be rebuilt from scratch when
+ // reload() is called.
+
+ QQmlComponent component(&engine, testFileUrl("model.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 9);
+
+ QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
+ QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
+ QSignalSpy spyCount(model, SIGNAL(countChanged()));
+ //reload multiple times to test the xml query aborting
+ QMetaObject::invokeMethod(model, "reload");
+ QMetaObject::invokeMethod(model, "reload");
+ QCoreApplication::processEvents();
+ QMetaObject::invokeMethod(model, "reload");
+ QMetaObject::invokeMethod(model, "reload");
+ QTRY_COMPARE(spyCount.count(), 1);
+ QTRY_COMPARE(spyInsert.count(), 1);
+ QTRY_COMPARE(spyRemove.count(), 1);
+
+ QCOMPARE(spyInsert[0][0].toInt(), 0);
+ QCOMPARE(spyInsert[0][1].toInt(), 9);
+
+ QCOMPARE(spyRemove[0][0].toInt(), 0);
+ QCOMPARE(spyRemove[0][1].toInt(), 9);
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::useKeys()
+{
+ // If using incremental updates through keys, the model should only
+ // insert & remove some of the items, instead of throwing everything
+ // away and causing the view to repaint the whole view.
+
+ QFETCH(QString, oldXml);
+ QFETCH(int, oldCount);
+ QFETCH(QString, newXml);
+ QFETCH(QQmlXmlModelData, newData);
+ QFETCH(QList<QQuickXmlListRange>, insertRanges);
+ QFETCH(QList<QQuickXmlListRange>, removeRanges);
+
+ QQmlComponent component(&engine, testFileUrl("roleKeys.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+
+ model->setProperty("xml",oldXml);
+ QTRY_COMPARE(model->count(), oldCount);
+
+ QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
+ QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
+ QSignalSpy spyCount(model, SIGNAL(countChanged()));
+
+ model->setProperty("xml",newXml);
+
+ if (oldCount != newData.count()) {
+ QTRY_COMPARE(model->count(), newData.count());
+ QCOMPARE(spyCount.count(), 1);
+ } else {
+ QTRY_VERIFY(spyInsert.count() > 0 || spyRemove.count() > 0);
+ QCOMPARE(spyCount.count(), 0);
+ }
+
+ QList<int> roles = model->roles();
+ for (int i=0; i<model->count(); i++) {
+ for (int j=0; j<roles.count(); j++)
+ QCOMPARE(model->data(i, roles[j]), newData[i][j]);
+ }
+
+ QCOMPARE(spyInsert.count(), insertRanges.count());
+ for (int i=0; i<spyInsert.count(); i++) {
+ QCOMPARE(spyInsert[i][0].toInt(), insertRanges[i].first);
+ QCOMPARE(spyInsert[i][1].toInt(), insertRanges[i].second);
+ }
+
+ QCOMPARE(spyRemove.count(), removeRanges.count());
+ for (int i=0; i<spyRemove.count(); i++) {
+ QCOMPARE(spyRemove[i][0].toInt(), removeRanges[i].first);
+ QCOMPARE(spyRemove[i][1].toInt(), removeRanges[i].second);
+ }
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::useKeys_data()
+{
+ QTest::addColumn<QString>("oldXml");
+ QTest::addColumn<int>("oldCount");
+ QTest::addColumn<QString>("newXml");
+ QTest::addColumn<QQmlXmlModelData>("newData");
+ QTest::addColumn<QList<QQuickXmlListRange> >("insertRanges");
+ QTest::addColumn<QList<QQuickXmlListRange> >("removeRanges");
+
+ QQmlXmlModelData modelData;
+
+ QTest::newRow("append 1")
+ << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(1, 1))
+ << QList<QQuickXmlListRange>();
+
+ QTest::newRow("append multiple")
+ << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(1, 2))
+ << QList<QQuickXmlListRange>();
+
+ QTest::newRow("insert in different spots")
+ << makeItemXmlAndData("name=B,age=35,sport=Athletics") << 1
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 1) << qMakePair(2,2))
+ << QList<QQuickXmlListRange>();
+
+ QTest::newRow("insert in middle")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=D,age=55,sport=Golf") << 2
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(1, 2))
+ << QList<QQuickXmlListRange>();
+
+ QTest::newRow("remove first")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2
+ << makeItemXmlAndData("name=B,age=35,sport=Athletics", &modelData)
+ << modelData
+ << QList<QQuickXmlListRange>()
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 1));
+
+ QTest::newRow("remove last")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2
+ << makeItemXmlAndData("name=A,age=25,sport=Football", &modelData)
+ << modelData
+ << QList<QQuickXmlListRange>()
+ << (QList<QQuickXmlListRange>() << qMakePair(1, 1));
+
+ QTest::newRow("remove from multiple spots")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 5
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=C,age=45,sport=Curling", &modelData)
+ << modelData
+ << QList<QQuickXmlListRange>()
+ << (QList<QQuickXmlListRange>() << qMakePair(1, 1) << qMakePair(3,2));
+
+ QTest::newRow("remove all")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3
+ << makeItemXmlAndData("", &modelData)
+ << modelData
+ << QList<QQuickXmlListRange>()
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 3));
+
+ QTest::newRow("replace item")
+ << makeItemXmlAndData("name=A,age=25,sport=Football") << 1
+ << makeItemXmlAndData("name=ZZZ,age=25,sport=Football", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 1))
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 1));
+
+ QTest::newRow("add and remove simultaneously, in different spots")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf") << 4
+ << makeItemXmlAndData("name=B,age=35,sport=Athletics;name=E,age=65,sport=Fencing", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(1, 1))
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 1) << qMakePair(2,2));
+
+ QTest::newRow("insert at start, remove at end i.e. rss feed")
+ << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 3
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 2))
+ << (QList<QQuickXmlListRange>() << qMakePair(1, 2));
+
+ QTest::newRow("remove at start, insert at end")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3
+ << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(1, 2))
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 2));
+
+ QTest::newRow("all data has changed")
+ << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35") << 2
+ << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData)
+ << modelData
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 2))
+ << (QList<QQuickXmlListRange>() << qMakePair(0, 2));
+}
+
+void tst_qquickxmllistmodel::noKeysValueChanges()
+{
+ // The 'key' roles are 'name' and 'age', as defined in roleKeys.qml.
+ // If a 'sport' value is changed, the model should not be reloaded,
+ // since 'sport' is not marked as a key.
+
+ QQmlComponent component(&engine, testFileUrl("roleKeys.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+
+ QString xml;
+
+ xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
+ model->setProperty("xml",xml);
+ QTRY_COMPARE(model->count(), 2);
+
+ model->setProperty("xml","");
+
+ QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
+ QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
+ QSignalSpy spyCount(model, SIGNAL(countChanged()));
+
+ xml = makeItemXmlAndData("name=A,age=25,sport=AussieRules;name=B,age=35,sport=Athletics");
+ model->setProperty("xml",xml);
+
+ // wait for the new xml data to be set, and verify no signals were emitted
+ QTRY_VERIFY(model->data(0, model->roles()[2]).toString() != QLatin1String("Football"));
+ QCOMPARE(model->data(0, model->roles()[2]).toString(), QLatin1String("AussieRules"));
+
+ QVERIFY(spyInsert.count() == 0);
+ QVERIFY(spyRemove.count() == 0);
+ QVERIFY(spyCount.count() == 0);
+
+ QCOMPARE(model->count(), 2);
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::keysChanged()
+{
+ // If the key roles change, the next time the data is reloaded, it should
+ // delete all its data and build a clean model (i.e. same behaviour as
+ // if no keys are set).
+
+ QQmlComponent component(&engine, testFileUrl("roleKeys.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+
+ QString xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
+ model->setProperty("xml",xml);
+ QTRY_COMPARE(model->count(), 2);
+
+ model->setProperty("xml","");
+
+ QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
+ QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
+ QSignalSpy spyCount(model, SIGNAL(countChanged()));
+
+ QVERIFY(QMetaObject::invokeMethod(model, "disableNameKey"));
+ model->setProperty("xml",xml);
+
+ QTRY_VERIFY(spyInsert.count() > 0 && spyRemove.count() > 0);
+
+ QCOMPARE(spyInsert.count(), 1);
+ QCOMPARE(spyInsert[0][0].toInt(), 0);
+ QCOMPARE(spyInsert[0][1].toInt(), 2);
+
+ QCOMPARE(spyRemove.count(), 1);
+ QCOMPARE(spyRemove[0][0].toInt(), 0);
+ QCOMPARE(spyRemove[0][1].toInt(), 2);
+
+ QCOMPARE(spyCount.count(), 0);
+
+ delete model;
+}
+
+void tst_qquickxmllistmodel::threading()
+{
+ QFETCH(int, xmlDataCount);
+
+ QQmlComponent component(&engine, testFileUrl("roleKeys.qml"));
+
+ QListModelInterface *m1 = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(m1 != 0);
+ QListModelInterface *m2 = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(m2 != 0);
+ QListModelInterface *m3 = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(m3 != 0);
+
+ for (int dataCount=0; dataCount<xmlDataCount; dataCount++) {
+
+ QString data1, data2, data3;
+ for (int i=0; i<dataCount; i++) {
+ data1 += "name=A" + QString::number(i) + ",age=1" + QString::number(i) + ",sport=Football;";
+ data2 += "name=B" + QString::number(i) + ",age=2" + QString::number(i) + ",sport=Athletics;";
+ data3 += "name=C" + QString::number(i) + ",age=3" + QString::number(i) + ",sport=Curling;";
+ }
+
+ //Set the xml data multiple times with randomized order and mixed with multiple event loops
+ //to test the xml query reloading/aborting, the result should be stable.
+ m1->setProperty("xml",makeItemXmlAndData(data1));
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ m3->setProperty("xml",makeItemXmlAndData(data3));
+ QCoreApplication::processEvents();
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ m1->setProperty("xml",makeItemXmlAndData(data1));
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ QCoreApplication::processEvents();
+ m3->setProperty("xml",makeItemXmlAndData(data3));
+ QCoreApplication::processEvents();
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ m1->setProperty("xml",makeItemXmlAndData(data1));
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ m3->setProperty("xml",makeItemXmlAndData(data3));
+ QCoreApplication::processEvents();
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ m3->setProperty("xml",makeItemXmlAndData(data3));
+ m3->setProperty("xml",makeItemXmlAndData(data3));
+ QCoreApplication::processEvents();
+
+ QTRY_VERIFY(m1->count() == dataCount && m2->count() == dataCount && m3->count() == dataCount);
+
+ for (int i=0; i<dataCount; i++) {
+ QCOMPARE(m1->data(i, m1->roles()[0]).toString(), QString("A" + QString::number(i)));
+ QCOMPARE(m1->data(i, m1->roles()[1]).toString(), QString("1" + QString::number(i)));
+ QCOMPARE(m1->data(i, m1->roles()[2]).toString(), QString("Football"));
+
+ QCOMPARE(m2->data(i, m2->roles()[0]).toString(), QString("B" + QString::number(i)));
+ QCOMPARE(m2->data(i, m2->roles()[1]).toString(), QString("2" + QString::number(i)));
+ QCOMPARE(m2->data(i, m2->roles()[2]).toString(), QString("Athletics"));
+
+ QCOMPARE(m3->data(i, m3->roles()[0]).toString(), QString("C" + QString::number(i)));
+ QCOMPARE(m3->data(i, m3->roles()[1]).toString(), QString("3" + QString::number(i)));
+ QCOMPARE(m3->data(i, m3->roles()[2]).toString(), QString("Curling"));
+ }
+ }
+
+ delete m1;
+ delete m2;
+ delete m3;
+}
+
+void tst_qquickxmllistmodel::threading_data()
+{
+ QTest::addColumn<int>("xmlDataCount");
+
+ QTest::newRow("1") << 1;
+ QTest::newRow("2") << 2;
+ QTest::newRow("10") << 10;
+}
+
+void tst_qquickxmllistmodel::propertyChanges()
+{
+ QQmlComponent component(&engine, testFileUrl("propertychanges.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ QTRY_COMPARE(model->count(), 9);
+
+ QObject *role = model->findChild<QObject*>("role");
+ QVERIFY(role);
+
+ QSignalSpy nameSpy(role, SIGNAL(nameChanged()));
+ QSignalSpy querySpy(role, SIGNAL(queryChanged()));
+ QSignalSpy isKeySpy(role, SIGNAL(isKeyChanged()));
+
+ role->setProperty("name","size");
+ role->setProperty("query","size/string()");
+ role->setProperty("isKey",true);
+
+ QCOMPARE(role->property("name").toString(), QString("size"));
+ QCOMPARE(role->property("query").toString(), QString("size/string()"));
+ QVERIFY(role->property("isKey").toBool());
+
+ QCOMPARE(nameSpy.count(),1);
+ QCOMPARE(querySpy.count(),1);
+ QCOMPARE(isKeySpy.count(),1);
+
+ role->setProperty("name","size");
+ role->setProperty("query","size/string()");
+ role->setProperty("isKey",true);
+
+ QCOMPARE(nameSpy.count(),1);
+ QCOMPARE(querySpy.count(),1);
+ QCOMPARE(isKeySpy.count(),1);
+
+ QSignalSpy sourceSpy(model, SIGNAL(sourceChanged()));
+ QSignalSpy xmlSpy(model, SIGNAL(xmlChanged()));
+ QSignalSpy modelQuerySpy(model, SIGNAL(queryChanged()));
+ QSignalSpy namespaceDeclarationsSpy(model, SIGNAL(namespaceDeclarationsChanged()));
+
+ model->setProperty("source",QUrl(""));
+ model->setProperty("xml","<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
+ model->setProperty("query","/Pets");
+ model->setProperty("namespaceDeclarations","declare namespace media=\"http://search.yahoo.com/mrss/\";");
+
+ QCOMPARE(model->property("source").toUrl(), QUrl(""));
+ QCOMPARE(model->property("xml").toString(), QString("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>"));
+ QCOMPARE(model->property("query").toString(), QString("/Pets"));
+ QCOMPARE(model->property("namespaceDeclarations").toString(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";"));
+
+ QTRY_VERIFY(model->count() == 1);
+
+ QCOMPARE(sourceSpy.count(),1);
+ QCOMPARE(xmlSpy.count(),1);
+ QCOMPARE(modelQuerySpy.count(),1);
+ QCOMPARE(namespaceDeclarationsSpy.count(),1);
+
+ model->setProperty("source",QUrl(""));
+ model->setProperty("xml","<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
+ model->setProperty("query","/Pets");
+ model->setProperty("namespaceDeclarations","declare namespace media=\"http://search.yahoo.com/mrss/\";");
+
+ QCOMPARE(sourceSpy.count(),1);
+ QCOMPARE(xmlSpy.count(),1);
+ QCOMPARE(modelQuerySpy.count(),1);
+ QCOMPARE(namespaceDeclarationsSpy.count(),1);
+
+ QTRY_VERIFY(model->count() == 1);
+ delete model;
+}
+
+void tst_qquickxmllistmodel::roleCrash()
+{
+ // don't crash
+ QQmlComponent component(&engine, testFileUrl("roleCrash.qml"));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
+ QVERIFY(model != 0);
+ delete model;
+}
+
+QTEST_MAIN(tst_qquickxmllistmodel)
+
+#include "tst_qquickxmllistmodel.moc"
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
new file mode 100644
index 0000000000..6fba193790
--- /dev/null
+++ b/tests/auto/quick/quick.pro
@@ -0,0 +1,70 @@
+TEMPLATE = subdirs
+
+PUBLICTESTS += \
+ examples \
+ geometry \
+ nodes \
+ rendernode \
+ qquickpixmapcache
+
+# This test requires the qtconcurrent module
+!contains(QT_CONFIG, concurrent):PUBLICTESTS -= qqmlpixmapcache
+
+PRIVATETESTS += \
+ qquickanimations \
+ qquickapplication \
+ qquickbehaviors \
+ qquickfontloader \
+ qquickpath \
+ qquicksmoothedanimation \
+ qquickspringanimation \
+ qquickstyledtext \
+ qquickstates \
+ qquicksystempalette \
+ qquicktimer \
+ qquickxmllistmodel
+
+# This test requires the xmlpatterns module
+!contains(QT_CONFIG,xmlpatterns):PRIVATETESTS -= qqmlxmllistmodel
+
+QUICKTESTS = \
+ qquickaccessible \
+ qquickanchors \
+ qquickanimatedimage \
+ qquickborderimage \
+ qquickcanvas \
+ qquickdrag \
+ qquickdroparea \
+ qquickflickable \
+ qquickflipable \
+ qquickfocusscope \
+ qquickgridview \
+ qquickimage \
+ qquickitem \
+ qquickitem2 \
+ qquickitemlayer \
+ qquicklistview \
+ qquickloader \
+ qquickmousearea \
+ qquickmultipointtoucharea \
+ qquickpathview \
+ qquickpincharea \
+ qquickpositioners \
+ qquickrepeater \
+ qquickshadereffect \
+ qquickspriteimage \
+ qquicktext \
+ qquicktextedit \
+ qquicktextinput \
+ qquickvisualdatamodel \
+ qquickview \
+ qquickcanvasitem \
+ qquickscreen \
+
+
+SUBDIRS += $$PUBLICTESTS
+
+contains(QT_CONFIG, private_tests) {
+ SUBDIRS += $$PRIVATETESTS
+ SUBDIRS += $$QUICKTESTS
+}
diff --git a/tests/auto/qtquick2/rendernode/data/MessUpState.qml b/tests/auto/quick/rendernode/data/MessUpState.qml
index 58f6e80a2c..58f6e80a2c 100644
--- a/tests/auto/qtquick2/rendernode/data/MessUpState.qml
+++ b/tests/auto/quick/rendernode/data/MessUpState.qml
diff --git a/tests/auto/qtquick2/rendernode/data/RenderOrder.qml b/tests/auto/quick/rendernode/data/RenderOrder.qml
index 3342756e06..3342756e06 100644
--- a/tests/auto/qtquick2/rendernode/data/RenderOrder.qml
+++ b/tests/auto/quick/rendernode/data/RenderOrder.qml
diff --git a/tests/auto/quick/rendernode/rendernode.pro b/tests/auto/quick/rendernode/rendernode.pro
new file mode 100644
index 0000000000..8484d591e5
--- /dev/null
+++ b/tests/auto/quick/rendernode/rendernode.pro
@@ -0,0 +1,18 @@
+CONFIG += testcase
+TARGET = tst_rendernode
+SOURCES += tst_rendernode.cpp
+
+macx:CONFIG -= app_bundle
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+include(../../shared/util.pri)
+
+CONFIG += parallel_test
+QT += core-private gui-private v8-private qml-private quick-private testlib
+
+OTHER_FILES += \
+ data/RenderOrder.qml \
+ data/MessUpState.qml \
diff --git a/tests/auto/quick/rendernode/tst_rendernode.cpp b/tests/auto/quick/rendernode/tst_rendernode.cpp
new file mode 100644
index 0000000000..b456a5980e
--- /dev/null
+++ b/tests/auto/quick/rendernode/tst_rendernode.cpp
@@ -0,0 +1,242 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qtest.h>
+
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+#include <QtGui/qopenglcontext.h>
+#include <private/qsgrendernode_p.h>
+
+#include "../../shared/util.h"
+
+class tst_rendernode: public QQmlDataTest
+{
+ Q_OBJECT
+public:
+ tst_rendernode();
+
+ QImage runTest(const QString &url)
+ {
+ QQuickView view;
+ view.setSource(QUrl(url));
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ return view.grabFrameBuffer();
+ }
+
+private slots:
+ void renderOrder();
+ void messUpState();
+};
+
+class ClearNode : public QSGRenderNode
+{
+public:
+ virtual StateFlags changedStates()
+ {
+ return ColorState;
+ }
+
+ virtual void render(const RenderState &)
+ {
+ // If clip has been set, scissoring will make sure the right area is cleared.
+ glClearColor(color.redF(), color.greenF(), color.blueF(), 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+ }
+
+ QColor color;
+};
+
+class ClearItem : public QQuickItem
+{
+ Q_OBJECT
+ Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
+public:
+ ClearItem() : m_color(Qt::black)
+ {
+ setFlag(ItemHasContents, true);
+ }
+
+ QColor color() const { return m_color; }
+ void setColor(const QColor &color)
+ {
+ if (color == m_color)
+ return;
+ m_color = color;
+ emit colorChanged();
+ }
+
+protected:
+ virtual QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
+ {
+ ClearNode *node = static_cast<ClearNode *>(oldNode);
+ if (!node)
+ node = new ClearNode;
+ node->color = m_color;
+ return node;
+ }
+
+Q_SIGNALS:
+ void colorChanged();
+
+private:
+ QColor m_color;
+};
+
+class MessUpNode : public QSGRenderNode
+{
+public:
+ virtual StateFlags changedStates()
+ {
+ return StateFlags(DepthState) | StencilState | ScissorState | ColorState | BlendState
+ | CullState | ViewportState;
+ }
+
+ virtual void render(const RenderState &)
+ {
+ // Don't draw anything, just mess up the state
+ glViewport(10, 10, 10, 10);
+ glDisable(GL_SCISSOR_TEST);
+ glDepthMask(true);
+ glEnable(GL_DEPTH_TEST);
+ glDepthFunc(GL_EQUAL);
+#if defined(QT_OPENGL_ES)
+ glClearDepthf(1);
+#else
+ glClearDepth(1);
+#endif
+ glClearStencil(42);
+ glClearColor(1.0f, 0.5f, 1.0f, 0.0f);
+ glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+ glEnable(GL_SCISSOR_TEST);
+ glScissor(190, 190, 10, 10);
+ glStencilFunc(GL_EQUAL, 28, 0xff);
+ glBlendFunc(GL_ZERO, GL_ZERO);
+ GLint frontFace;
+ glGetIntegerv(GL_FRONT_FACE, &frontFace);
+ glFrontFace(frontFace == GL_CW ? GL_CCW : GL_CW);
+ glEnable(GL_CULL_FACE);
+ }
+};
+
+class MessUpItem : public QQuickItem
+{
+ Q_OBJECT
+public:
+ MessUpItem()
+ {
+ setFlag(ItemHasContents, true);
+ }
+
+protected:
+ virtual QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
+ {
+ MessUpNode *node = static_cast<MessUpNode *>(oldNode);
+ if (!node)
+ node = new MessUpNode;
+ return node;
+ }
+};
+
+tst_rendernode::tst_rendernode()
+{
+ qmlRegisterType<ClearItem>("Test", 1, 0, "ClearItem");
+ qmlRegisterType<MessUpItem>("Test", 1, 0, "MessUpItem");
+}
+
+static void fuzzyCompareColor(QRgb x, QRgb y)
+{
+ QVERIFY(qAbs(qRed(x) - qRed(y)) < 4);
+ QVERIFY(qAbs(qGreen(x) - qGreen(y)) < 4);
+ QVERIFY(qAbs(qBlue(x) - qBlue(y)) < 4);
+}
+
+void tst_rendernode::renderOrder()
+{
+ QImage fb = runTest(testFile("RenderOrder.qml"));
+ int x1 = fb.width() / 8;
+ int x2 = fb.width() * 3 / 8;
+ int x3 = fb.width() * 5 / 8;
+ int x4 = fb.width() * 7 / 8;
+ int y1 = fb.height() / 8;
+ int y2 = fb.height() * 3 / 8;
+ int y3 = fb.height() * 5 / 8;
+ int y4 = fb.height() * 7 / 8;
+
+ fuzzyCompareColor(fb.pixel(x1, y1), qRgb(0x7f, 0x00, 0x00));
+ QCOMPARE(fb.pixel(x2, y2), qRgb(0xff, 0xff, 0xff));
+ QCOMPARE(fb.pixel(x3, y2), qRgb(0x00, 0x00, 0xff));
+ QCOMPARE(fb.pixel(x4, y1), qRgb(0x00, 0x00, 0xff));
+ QCOMPARE(fb.pixel(x1, y4), qRgb(0xff, 0x00, 0x00));
+ QCOMPARE(fb.pixel(x2, y3), qRgb(0xff, 0xff, 0xff));
+ fuzzyCompareColor(fb.pixel(x3, y3), qRgb(0x7f, 0x7f, 0xff));
+ fuzzyCompareColor(fb.pixel(x4, y4), qRgb(0x00, 0x00, 0x7f));
+}
+
+void tst_rendernode::messUpState()
+{
+ QImage fb = runTest(testFile("MessUpState.qml"));
+ int x1 = 0;
+ int x2 = fb.width() / 2;
+ int x3 = fb.width() - 1;
+ int y1 = 0;
+ int y2 = fb.height() * 3 / 16;
+ int y3 = fb.height() / 2;
+ int y4 = fb.height() * 13 / 16;
+ int y5 = fb.height() - 1;
+
+ QCOMPARE(fb.pixel(x1, y3), qRgb(0xff, 0xff, 0xff));
+ QCOMPARE(fb.pixel(x3, y3), qRgb(0xff, 0xff, 0xff));
+
+ QCOMPARE(fb.pixel(x2, y1), qRgb(0x00, 0x00, 0x00));
+ QCOMPARE(fb.pixel(x2, y2), qRgb(0x00, 0x00, 0x00));
+ fuzzyCompareColor(fb.pixel(x2, y3), qRgb(0x7f, 0x00, 0x7f));
+ QCOMPARE(fb.pixel(x2, y4), qRgb(0x00, 0x00, 0x00));
+ QCOMPARE(fb.pixel(x2, y5), qRgb(0x00, 0x00, 0x00));
+}
+
+
+QTEST_MAIN(tst_rendernode)
+
+#include "tst_rendernode.moc"
diff --git a/tests/auto/quick/shared/util.pri b/tests/auto/quick/shared/util.pri
new file mode 100644
index 0000000000..aa79c7ca98
--- /dev/null
+++ b/tests/auto/quick/shared/util.pri
@@ -0,0 +1,7 @@
+
+HEADERS += $$PWD/visualtestutil.h \
+ $$PWD/viewtestutil.h
+SOURCES += $$PWD/visualtestutil.cpp \
+ $$PWD/viewtestutil.cpp
+
+DEFINES += QT_QMLTEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\"
diff --git a/tests/auto/quick/shared/viewtestutil.cpp b/tests/auto/quick/shared/viewtestutil.cpp
new file mode 100644
index 0000000000..d00a0e2a96
--- /dev/null
+++ b/tests/auto/quick/shared/viewtestutil.cpp
@@ -0,0 +1,493 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "viewtestutil.h"
+
+#include <QtQuick/QQuickView>
+
+#include <QtTest/QTest>
+
+template<typename T>
+static void qquickmodelviewstestutil_move(int from, int to, int n, T *items)
+{
+ if (from > to) {
+ // Only move forwards - flip if backwards moving
+ int tfrom = from;
+ int tto = to;
+ from = tto;
+ to = tto+n;
+ n = tfrom-tto;
+ }
+
+ T replaced;
+ int i=0;
+ typename T::ConstIterator it=items->begin(); it += from+n;
+ for (; i<to-from; ++i,++it)
+ replaced.append(*it);
+ i=0;
+ it=items->begin(); it += from;
+ for (; i<n; ++i,++it)
+ replaced.append(*it);
+ typename T::ConstIterator f=replaced.begin();
+ typename T::Iterator t=items->begin(); t += from;
+ for (; f != replaced.end(); ++f, ++t)
+ *t = *f;
+}
+
+QQuickView *QQuickViewTestUtil::createView()
+{
+ QQuickView *canvas = new QQuickView(0);
+ canvas->setGeometry(0,0,240,320);
+
+ return canvas;
+}
+
+void QQuickViewTestUtil::flick(QQuickView *canvas, const QPoint &from, const QPoint &to, int duration)
+{
+ const int pointCount = 5;
+ QPoint diff = to - from;
+
+ // send press, five equally spaced moves, and release.
+ QTest::mousePress(canvas, Qt::LeftButton, 0, from);
+
+ for (int i = 0; i < pointCount; ++i) {
+ QMouseEvent mv(QEvent::MouseMove, from + (i+1)*diff/pointCount, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
+ QGuiApplication::sendEvent(canvas, &mv);
+ QTest::qWait(duration/pointCount);
+ QCoreApplication::processEvents();
+ }
+
+ QTest::mouseRelease(canvas, Qt::LeftButton, 0, to);
+ QTest::qWait(50);
+}
+
+QList<int> QQuickViewTestUtil::adjustIndexesForAddDisplaced(const QList<int> &indexes, int index, int count)
+{
+ QList<int> result;
+ for (int i=0; i<indexes.count(); i++) {
+ int num = indexes[i];
+ if (num >= index) {
+ num += count;
+ }
+ result << num;
+ }
+ return result;
+}
+
+QList<int> QQuickViewTestUtil::adjustIndexesForMove(const QList<int> &indexes, int from, int to, int count)
+{
+ QList<int> result;
+ for (int i=0; i<indexes.count(); i++) {
+ int num = indexes[i];
+ if (from < to) {
+ if (num >= from && num < from + count)
+ num += (to - from); // target
+ else if (num >= from && num < to + count)
+ num -= count; // displaced
+ } else if (from > to) {
+ if (num >= from && num < from + count)
+ num -= (from - to); // target
+ else if (num >= to && num < from + count)
+ num += count; // displaced
+ }
+ result << num;
+ }
+ return result;
+}
+
+QList<int> QQuickViewTestUtil::adjustIndexesForRemoveDisplaced(const QList<int> &indexes, int index, int count)
+{
+ QList<int> result;
+ for (int i=0; i<indexes.count(); i++) {
+ int num = indexes[i];
+ if (num >= index)
+ num -= count;
+ result << num;
+ }
+ return result;
+}
+
+
+QQuickViewTestUtil::QmlListModel::QmlListModel(QObject *parent)
+ : QListModelInterface(parent)
+{
+}
+
+QQuickViewTestUtil::QmlListModel::~QmlListModel()
+{
+}
+
+QString QQuickViewTestUtil::QmlListModel::name(int index) const
+{
+ return list.at(index).first;
+}
+
+QString QQuickViewTestUtil::QmlListModel::number(int index) const
+{
+ return list.at(index).second;
+}
+
+int QQuickViewTestUtil::QmlListModel::count() const
+{
+ return list.count();
+}
+
+QList<int> QQuickViewTestUtil::QmlListModel::roles() const
+{
+ return QList<int>() << Name << Number;
+}
+
+QString QQuickViewTestUtil::QmlListModel::toString(int role) const
+{
+ switch (role) {
+ case Name:
+ return "name";
+ case Number:
+ return "number";
+ default:
+ return "";
+ }
+}
+
+QVariant QQuickViewTestUtil::QmlListModel::data(int index, int role) const
+{
+ if (role==0)
+ return list.at(index).first;
+ if (role==1)
+ return list.at(index).second;
+ return QVariant();
+}
+
+QHash<int, QVariant> QQuickViewTestUtil::QmlListModel::data(int index, const QList<int> &roles) const
+{
+ QHash<int,QVariant> returnHash;
+
+ for (int i = 0; i < roles.size(); ++i) {
+ int role = roles.at(i);
+ QVariant info;
+ switch (role) {
+ case Name:
+ info = list.at(index).first;
+ break;
+ case Number:
+ info = list.at(index).second;
+ break;
+ default:
+ break;
+ }
+ returnHash.insert(role, info);
+ }
+ return returnHash;
+}
+
+void QQuickViewTestUtil::QmlListModel::addItem(const QString &name, const QString &number)
+{
+ list.append(QPair<QString,QString>(name, number));
+ emit itemsInserted(list.count()-1, 1);
+}
+
+void QQuickViewTestUtil::QmlListModel::insertItem(int index, const QString &name, const QString &number)
+{
+ list.insert(index, QPair<QString,QString>(name, number));
+ emit itemsInserted(index, 1);
+}
+
+void QQuickViewTestUtil::QmlListModel::insertItems(int index, const QList<QPair<QString, QString> > &items)
+{
+ for (int i=0; i<items.count(); i++)
+ list.insert(index + i, QPair<QString,QString>(items[i].first, items[i].second));
+ emit itemsInserted(index, items.count());
+}
+
+void QQuickViewTestUtil::QmlListModel::removeItem(int index)
+{
+ list.removeAt(index);
+ emit itemsRemoved(index, 1);
+}
+
+void QQuickViewTestUtil::QmlListModel::removeItems(int index, int count)
+{
+ int c = count;
+ while (c--)
+ list.removeAt(index);
+ emit itemsRemoved(index, count);
+}
+
+void QQuickViewTestUtil::QmlListModel::moveItem(int from, int to)
+{
+ list.move(from, to);
+ emit itemsMoved(from, to, 1);
+}
+
+void QQuickViewTestUtil::QmlListModel::moveItems(int from, int to, int count)
+{
+ qquickmodelviewstestutil_move(from, to, count, &list);
+ emit itemsMoved(from, to, count);
+}
+
+void QQuickViewTestUtil::QmlListModel::modifyItem(int index, const QString &name, const QString &number)
+{
+ list[index] = QPair<QString,QString>(name, number);
+ emit itemsChanged(index, 1, roles());
+}
+
+void QQuickViewTestUtil::QmlListModel::clear() {
+ int count = list.count();
+ list.clear();
+ emit itemsRemoved(0, count);
+}
+
+void QQuickViewTestUtil::QmlListModel::matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2) {
+ for (int i=0; i<other.count(); i++) {
+ QVERIFY2(list.contains(other[i]),
+ QTest::toString(other[i].first + " " + other[i].second + " " + error1));
+ }
+ for (int i=0; i<list.count(); i++) {
+ QVERIFY2(other.contains(list[i]),
+ QTest::toString(list[i].first + " " + list[i].second + " " + error2));
+ }
+}
+
+
+QQuickViewTestUtil::QaimModel::QaimModel(QObject *parent)
+ : QAbstractListModel(parent)
+{
+ QHash<int, QByteArray> roles;
+ roles[Name] = "name";
+ roles[Number] = "number";
+ setRoleNames(roles);
+}
+
+int QQuickViewTestUtil::QaimModel::rowCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent);
+ return list.count();
+}
+
+QVariant QQuickViewTestUtil::QaimModel::data(const QModelIndex &index, int role) const
+{
+ QVariant rv;
+ if (role == Name)
+ rv = list.at(index.row()).first;
+ else if (role == Number)
+ rv = list.at(index.row()).second;
+
+ return rv;
+}
+
+int QQuickViewTestUtil::QaimModel::count() const
+{
+ return rowCount();
+}
+
+QString QQuickViewTestUtil::QaimModel::name(int index) const
+{
+ return list.at(index).first;
+}
+
+QString QQuickViewTestUtil::QaimModel::number(int index) const
+{
+ return list.at(index).second;
+}
+
+void QQuickViewTestUtil::QaimModel::addItem(const QString &name, const QString &number)
+{
+ emit beginInsertRows(QModelIndex(), list.count(), list.count());
+ list.append(QPair<QString,QString>(name, number));
+ emit endInsertRows();
+}
+
+void QQuickViewTestUtil::QaimModel::addItems(const QList<QPair<QString, QString> > &items)
+{
+ emit beginInsertRows(QModelIndex(), list.count(), list.count()+items.count()-1);
+ for (int i=0; i<items.count(); i++)
+ list.append(QPair<QString,QString>(items[i].first, items[i].second));
+ emit endInsertRows();
+}
+
+void QQuickViewTestUtil::QaimModel::insertItem(int index, const QString &name, const QString &number)
+{
+ emit beginInsertRows(QModelIndex(), index, index);
+ list.insert(index, QPair<QString,QString>(name, number));
+ emit endInsertRows();
+}
+
+void QQuickViewTestUtil::QaimModel::insertItems(int index, const QList<QPair<QString, QString> > &items)
+{
+ emit beginInsertRows(QModelIndex(), index, index+items.count()-1);
+ for (int i=0; i<items.count(); i++)
+ list.insert(index + i, QPair<QString,QString>(items[i].first, items[i].second));
+ emit endInsertRows();
+}
+
+void QQuickViewTestUtil::QaimModel::removeItem(int index)
+{
+ emit beginRemoveRows(QModelIndex(), index, index);
+ list.removeAt(index);
+ emit endRemoveRows();
+}
+
+void QQuickViewTestUtil::QaimModel::removeItems(int index, int count)
+{
+ emit beginRemoveRows(QModelIndex(), index, index+count-1);
+ while (count--)
+ list.removeAt(index);
+ emit endRemoveRows();
+}
+
+void QQuickViewTestUtil::QaimModel::moveItem(int from, int to)
+{
+ emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to);
+ list.move(from, to);
+ emit endMoveRows();
+}
+
+void QQuickViewTestUtil::QaimModel::moveItems(int from, int to, int count)
+{
+ emit beginMoveRows(QModelIndex(), from, from+count-1, QModelIndex(), to > from ? to+count : to);
+ qquickmodelviewstestutil_move(from, to, count, &list);
+ emit endMoveRows();
+}
+
+void QQuickViewTestUtil::QaimModel::modifyItem(int idx, const QString &name, const QString &number)
+{
+ list[idx] = QPair<QString,QString>(name, number);
+ emit dataChanged(index(idx,0), index(idx,0));
+}
+
+void QQuickViewTestUtil::QaimModel::clear()
+{
+ int count = list.count();
+ emit beginRemoveRows(QModelIndex(), 0, count-1);
+ list.clear();
+ emit endRemoveRows();
+}
+
+void QQuickViewTestUtil::QaimModel::reset()
+{
+ emit beginResetModel();
+ emit endResetModel();
+}
+
+void QQuickViewTestUtil::QaimModel::matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2) {
+ for (int i=0; i<other.count(); i++) {
+ QVERIFY2(list.contains(other[i]),
+ QTest::toString(other[i].first + " " + other[i].second + " " + error1));
+ }
+ for (int i=0; i<list.count(); i++) {
+ QVERIFY2(other.contains(list[i]),
+ QTest::toString(list[i].first + " " + list[i].second + " " + error2));
+ }
+}
+
+
+
+QQuickViewTestUtil::ListRange::ListRange()
+ : valid(false)
+{
+}
+
+QQuickViewTestUtil::ListRange::ListRange(const ListRange &other)
+ : valid(other.valid)
+{
+ indexes = other.indexes;
+}
+
+QQuickViewTestUtil::ListRange::ListRange(int start, int end)
+ : valid(true)
+{
+ for (int i=start; i<=end; i++)
+ indexes << i;
+}
+
+QQuickViewTestUtil::ListRange::~ListRange()
+{
+}
+
+QQuickViewTestUtil::ListRange QQuickViewTestUtil::ListRange::operator+(const ListRange &other) const
+{
+ if (other == *this)
+ return *this;
+ ListRange a(*this);
+ a.indexes.append(other.indexes);
+ return a;
+}
+
+bool QQuickViewTestUtil::ListRange::operator==(const ListRange &other) const
+{
+ return indexes.toSet() == other.indexes.toSet();
+}
+
+bool QQuickViewTestUtil::ListRange::operator!=(const ListRange &other) const
+{
+ return !(*this == other);
+}
+
+bool QQuickViewTestUtil::ListRange::isValid() const
+{
+ return valid;
+}
+
+int QQuickViewTestUtil::ListRange::count() const
+{
+ return indexes.count();
+}
+
+QList<QPair<QString,QString> > QQuickViewTestUtil::ListRange::getModelDataValues(const QmlListModel &model)
+{
+ QList<QPair<QString,QString> > data;
+ if (!valid)
+ return data;
+ for (int i=0; i<indexes.count(); i++)
+ data.append(qMakePair(model.name(indexes[i]), model.number(indexes[i])));
+ return data;
+}
+
+QList<QPair<QString,QString> > QQuickViewTestUtil::ListRange::getModelDataValues(const QaimModel &model)
+{
+ QList<QPair<QString,QString> > data;
+ if (!valid)
+ return data;
+ for (int i=0; i<indexes.count(); i++)
+ data.append(qMakePair(model.name(indexes[i]), model.number(indexes[i])));
+ return data;
+}
+
diff --git a/tests/auto/quick/shared/viewtestutil.h b/tests/auto/quick/shared/viewtestutil.h
new file mode 100644
index 0000000000..e940727789
--- /dev/null
+++ b/tests/auto/quick/shared/viewtestutil.h
@@ -0,0 +1,180 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKVIEWTESTUTIL_H
+#define QQUICKVIEWTESTUTIL_H
+
+#include <QtQuick/QQuickItem>
+#include <QtQml/QQmlExpression>
+#include <QtQml/private/qlistmodelinterface_p.h>
+#include <QtCore/QAbstractListModel>
+
+QT_FORWARD_DECLARE_CLASS(QQuickView)
+
+namespace QQuickViewTestUtil
+{
+ QQuickView *createView();
+
+ void flick(QQuickView *canvas, const QPoint &from, const QPoint &to, int duration);
+
+ QList<int> adjustIndexesForAddDisplaced(const QList<int> &indexes, int index, int count);
+ QList<int> adjustIndexesForMove(const QList<int> &indexes, int from, int to, int count);
+ QList<int> adjustIndexesForRemoveDisplaced(const QList<int> &indexes, int index, int count);
+
+ struct ListChange {
+ enum { Inserted, Removed, Moved, SetCurrent, SetContentY } type;
+ int index;
+ int count;
+ int to; // Move
+ qreal pos; // setContentY
+
+ static ListChange insert(int index, int count = 1) { ListChange c = { Inserted, index, count, -1, 0.0 }; return c; }
+ static ListChange remove(int index, int count = 1) { ListChange c = { Removed, index, count, -1, 0.0 }; return c; }
+ static ListChange move(int index, int to, int count) { ListChange c = { Moved, index, count, to, 0.0 }; return c; }
+ static ListChange setCurrent(int index) { ListChange c = { SetCurrent, index, -1, -1, 0.0 }; return c; }
+ static ListChange setContentY(qreal pos) { ListChange c = { SetContentY, -1, -1, -1, pos }; return c; }
+ };
+
+ class QmlListModel : public QListModelInterface
+ {
+ Q_OBJECT
+ public:
+ QmlListModel(QObject *parent = 0);
+ ~QmlListModel();
+
+ enum Roles { Name, Number };
+
+ QString name(int index) const;
+ QString number(int index) const;
+
+ int count() const;
+
+ QList<int> roles() const;
+ QString toString(int role) const;
+
+ QVariant data(int index, int role) const;
+ QHash<int, QVariant> data(int index, const QList<int> &roles) const;
+
+ Q_INVOKABLE void addItem(const QString &name, const QString &number);
+ void insertItem(int index, const QString &name, const QString &number);
+ void insertItems(int index, const QList<QPair<QString, QString> > &items);
+
+ void removeItem(int index);
+ void removeItems(int index, int count);
+
+ void moveItem(int from, int to);
+ void moveItems(int from, int to, int count);
+
+ void modifyItem(int index, const QString &name, const QString &number);
+
+ void clear();
+
+ void matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2);
+
+ private:
+ QList<QPair<QString,QString> > list;
+ };
+
+ class QaimModel : public QAbstractListModel
+ {
+ Q_OBJECT
+ public:
+ enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 };
+
+ QaimModel(QObject *parent=0);
+
+ int rowCount(const QModelIndex &parent=QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
+
+ int count() const;
+ QString name(int index) const;
+ QString number(int index) const;
+
+ Q_INVOKABLE void addItem(const QString &name, const QString &number);
+ void addItems(const QList<QPair<QString, QString> > &items);
+ void insertItem(int index, const QString &name, const QString &number);
+ void insertItems(int index, const QList<QPair<QString, QString> > &items);
+
+ void removeItem(int index);
+ void removeItems(int index, int count);
+
+ void moveItem(int from, int to);
+ void moveItems(int from, int to, int count);
+
+ void modifyItem(int idx, const QString &name, const QString &number);
+
+ void clear();
+ void reset();
+
+ void matchAgainst(const QList<QPair<QString, QString> > &other, const QString &error1, const QString &error2);
+
+ private:
+ QList<QPair<QString,QString> > list;
+ };
+
+ class ListRange
+ {
+ public:
+ ListRange();
+ ListRange(const ListRange &other);
+ ListRange(int start, int end);
+
+ ~ListRange();
+
+ ListRange operator+(const ListRange &other) const;
+ bool operator==(const ListRange &other) const;
+ bool operator!=(const ListRange &other) const;
+
+ bool isValid() const;
+ int count() const;
+
+ QList<QPair<QString,QString> > getModelDataValues(const QmlListModel &model);
+ QList<QPair<QString,QString> > getModelDataValues(const QaimModel &model);
+
+ QList<int> indexes;
+ bool valid;
+ };
+}
+
+Q_DECLARE_METATYPE(QList<QQuickViewTestUtil::ListChange>)
+Q_DECLARE_METATYPE(QQuickViewTestUtil::ListRange)
+
+#endif // QQUICKVIEWTESTUTIL_H
diff --git a/tests/auto/qtquick2/shared/visualtestutil.cpp b/tests/auto/quick/shared/visualtestutil.cpp
index 8680df10e9..8680df10e9 100644
--- a/tests/auto/qtquick2/shared/visualtestutil.cpp
+++ b/tests/auto/quick/shared/visualtestutil.cpp
diff --git a/tests/auto/quick/shared/visualtestutil.h b/tests/auto/quick/shared/visualtestutil.h
new file mode 100644
index 0000000000..9407ff8e8f
--- /dev/null
+++ b/tests/auto/quick/shared/visualtestutil.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKVISUALTESTUTIL_H
+#define QQUICKVISUALTESTUTIL_H
+
+#include <QtQuick/QQuickItem>
+#include <QtQml/QQmlExpression>
+
+namespace QQuickVisualTestUtil
+{
+ QQuickItem *findVisibleChild(QQuickItem *parent, const QString &objectName);
+
+ void dumpTree(QQuickItem *parent, int depth = 0);
+
+
+ /*
+ Find an item with the specified objectName. If index is supplied then the
+ item must also evaluate the {index} expression equal to index
+ */
+ template<typename T>
+ T *findItem(QQuickItem *parent, const QString &objectName, int index = -1)
+ {
+ const QMetaObject &mo = T::staticMetaObject;
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QQuickItem *item = qobject_cast<QQuickItem*>(parent->childItems().at(i));
+ if (!item)
+ continue;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
+ if (index != -1) {
+ QQmlExpression e(qmlContext(item), item, "index");
+ if (e.evaluate().toInt() == index)
+ return static_cast<T*>(item);
+ } else {
+ return static_cast<T*>(item);
+ }
+ }
+ item = findItem<T>(item, objectName, index);
+ if (item)
+ return static_cast<T*>(item);
+ }
+
+ return 0;
+ }
+
+ template<typename T>
+ QList<T*> findItems(QQuickItem *parent, const QString &objectName, bool visibleOnly = true)
+ {
+ QList<T*> items;
+ const QMetaObject &mo = T::staticMetaObject;
+ for (int i = 0; i < parent->childItems().count(); ++i) {
+ QQuickItem *item = qobject_cast<QQuickItem*>(parent->childItems().at(i));
+ if (!item || (visibleOnly && !item->isVisible()))
+ continue;
+ if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName))
+ items.append(static_cast<T*>(item));
+ items += findItems<T>(item, objectName);
+ }
+
+ return items;
+ }
+
+ template<typename T>
+ QList<T*> findItems(QQuickItem *parent, const QString &objectName, const QList<int> &indexes)
+ {
+ QList<T*> items;
+ for (int i=0; i<indexes.count(); i++)
+ items << qobject_cast<QQuickItem*>(findItem<T>(parent, objectName, indexes[i]));
+ return items;
+ }
+
+}
+
+#endif // QQUICKVISUALTESTUTIL_H
diff --git a/tests/auto/shared/util.cpp b/tests/auto/shared/util.cpp
index 5a3d50f695..c015898ab7 100644
--- a/tests/auto/shared/util.cpp
+++ b/tests/auto/shared/util.cpp
@@ -41,19 +41,19 @@
#include "util.h"
-#include <QtDeclarative/QDeclarativeComponent>
-#include <QtDeclarative/QDeclarativeError>
-#include <QtDeclarative/QDeclarativeContext>
-#include <QtDeclarative/QDeclarativeEngine>
+#include <QtQml/QQmlComponent>
+#include <QtQml/QQmlError>
+#include <QtQml/QQmlContext>
+#include <QtQml/QQmlEngine>
#include <QtCore/QTextStream>
-QDeclarativeDataTest *QDeclarativeDataTest::m_instance = 0;
+QQmlDataTest *QQmlDataTest::m_instance = 0;
-QDeclarativeDataTest::QDeclarativeDataTest() :
+QQmlDataTest::QQmlDataTest() :
#ifdef QT_TESTCASE_BUILDDIR
- m_dataDirectory(QTest::qFindTestData("data", QT_DECLARATIVETEST_DATADIR, 0, QT_TESTCASE_BUILDDIR)),
+ m_dataDirectory(QTest::qFindTestData("data", QT_QMLTEST_DATADIR, 0, QT_TESTCASE_BUILDDIR)),
#else
- m_dataDirectory(QTest::qFindTestData("data", QT_DECLARATIVETEST_DATADIR, 0)),
+ m_dataDirectory(QTest::qFindTestData("data", QT_QMLTEST_DATADIR, 0)),
#endif
m_dataDirectoryUrl(QUrl::fromLocalFile(m_dataDirectory + QLatin1Char('/')))
@@ -61,33 +61,33 @@ QDeclarativeDataTest::QDeclarativeDataTest() :
m_instance = this;
}
-QDeclarativeDataTest::~QDeclarativeDataTest()
+QQmlDataTest::~QQmlDataTest()
{
m_instance = 0;
}
-void QDeclarativeDataTest::initTestCase()
+void QQmlDataTest::initTestCase()
{
QVERIFY2(!m_dataDirectory.isEmpty(), "'data' directory not found");
m_directory = QFileInfo(m_dataDirectory).absolutePath();
QVERIFY2(QDir::setCurrent(m_directory), qPrintable(QLatin1String("Could not chdir to ") + m_directory));
}
-QString QDeclarativeDataTest::testFile(const QString &fileName) const
+QString QQmlDataTest::testFile(const QString &fileName) const
{
if (m_directory.isEmpty())
- qFatal("QDeclarativeDataTest::initTestCase() not called.");
+ qFatal("QQmlDataTest::initTestCase() not called.");
QString result = m_dataDirectory;
result += QLatin1Char('/');
result += fileName;
return result;
}
-QByteArray QDeclarativeDataTest::msgComponentError(const QDeclarativeComponent &c,
- const QDeclarativeEngine *engine /* = 0 */)
+QByteArray QQmlDataTest::msgComponentError(const QQmlComponent &c,
+ const QQmlEngine *engine /* = 0 */)
{
QString result;
- const QList<QDeclarativeError> errors = c.errors();
+ const QList<QQmlError> errors = c.errors();
QTextStream str(&result);
str << "Component '" << c.url().toString() << "' has " << errors.size()
<< " errors: '";
@@ -98,7 +98,7 @@ QByteArray QDeclarativeDataTest::msgComponentError(const QDeclarativeComponent &
}
if (!engine)
- if (QDeclarativeContext *context = c.creationContext())
+ if (QQmlContext *context = c.creationContext())
engine = context->engine();
if (engine) {
str << " Import paths: (" << engine->importPathList().join(QStringLiteral(", "))
diff --git a/tests/auto/shared/util.h b/tests/auto/shared/util.h
index 9f73d9eb05..5a31ebd719 100644
--- a/tests/auto/shared/util.h
+++ b/tests/auto/shared/util.h
@@ -39,25 +39,25 @@
**
****************************************************************************/
-#ifndef QDECLARATIVETESTUTILS_H
-#define QDECLARATIVETESTUTILS_H
+#ifndef QQMLTESTUTILS_H
+#define QQMLTESTUTILS_H
#include <QtCore/QDir>
#include <QtCore/QUrl>
#include <QtCore/QCoreApplication>
#include <QtTest/QTest>
-QT_FORWARD_DECLARE_CLASS(QDeclarativeComponent)
-QT_FORWARD_DECLARE_CLASS(QDeclarativeEngine)
+QT_FORWARD_DECLARE_CLASS(QQmlComponent)
+QT_FORWARD_DECLARE_CLASS(QQmlEngine)
/* Base class for tests with data that are located in a "data" subfolder. */
-class QDeclarativeDataTest : public QObject
+class QQmlDataTest : public QObject
{
Q_OBJECT
public:
- QDeclarativeDataTest();
- virtual ~QDeclarativeDataTest();
+ QQmlDataTest();
+ virtual ~QQmlDataTest();
QString testFile(const QString &fileName) const;
inline QString testFile(const char *fileName) const
@@ -71,20 +71,20 @@ public:
inline QUrl dataDirectoryUrl() const { return m_dataDirectoryUrl; }
inline QString directory() const { return m_directory; }
- static inline QDeclarativeDataTest *instance() { return m_instance; }
+ static inline QQmlDataTest *instance() { return m_instance; }
- static QByteArray msgComponentError(const QDeclarativeComponent &,
- const QDeclarativeEngine *engine = 0);
+ static QByteArray msgComponentError(const QQmlComponent &,
+ const QQmlEngine *engine = 0);
public slots:
virtual void initTestCase();
private:
- static QDeclarativeDataTest *m_instance;
+ static QQmlDataTest *m_instance;
const QString m_dataDirectory;
const QUrl m_dataDirectoryUrl;
QString m_directory;
};
-#endif // QDECLARATIVETESTUTILS_H
+#endif // QQMLTESTUTILS_H
diff --git a/tests/auto/shared/util.pri b/tests/auto/shared/util.pri
index 916e5fb32a..8e82dcb33b 100644
--- a/tests/auto/shared/util.pri
+++ b/tests/auto/shared/util.pri
@@ -2,4 +2,4 @@
HEADERS += $$PWD/util.h
SOURCES += $$PWD/util.cpp
-DEFINES += QT_DECLARATIVETEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\"
+DEFINES += QT_QMLTEST_DATADIR=\\\"$${_PRO_FILE_PWD_}/data\\\"